mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-20 23:32:09 +00:00

The platform lowering pass was called before we collected globals, so visit_all_used_components never called the pass on any globals. Fixes #8777
53 lines
1.6 KiB
Text
53 lines
1.6 KiB
Text
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
|
|
|
// Basic test for Platform.os and Platform.style-name. This is done in JS, as with Rust and C++ the style is fixed
|
|
// to fluent.
|
|
|
|
export global Info {
|
|
out property <string> style-name: Platform.style-name;
|
|
}
|
|
|
|
export component TestCase inherits Window {
|
|
out property <string> os: {
|
|
if Platform.os == OperatingSystemType.android {
|
|
"android"
|
|
} else if Platform.os == OperatingSystemType.ios {
|
|
"ios"
|
|
} else if Platform.os == OperatingSystemType.macos {
|
|
"macos"
|
|
} else if Platform.os == OperatingSystemType.linux {
|
|
"linux"
|
|
} else if Platform.os == OperatingSystemType.windows {
|
|
"windows"
|
|
} else if Platform.os == OperatingSystemType.other {
|
|
"other"
|
|
} else {
|
|
"error"
|
|
}
|
|
}
|
|
out property <string> style-name: Info.style-name;
|
|
}
|
|
|
|
/*
|
|
```js
|
|
let instance = new slint.TestCase({});
|
|
let os = instance.os;
|
|
let style_name = instance.style_name;
|
|
console.log(style_name);
|
|
|
|
const { platform } = require('node:process');
|
|
if (platform === 'win32') {
|
|
assert.strictEqual(os, "windows");
|
|
assert.strictEqual(style_name, "fluent");
|
|
} else if (platform === 'darwin') {
|
|
assert.strictEqual(os, "macos");
|
|
assert.strictEqual(style_name, "cupertino");
|
|
} else if (platform === 'linux') {
|
|
assert.strictEqual(os, "linux");
|
|
assert(style_name == "qt" || style_name == "fluent");
|
|
} else {
|
|
throw new Error("Unknown platform for this test: " + platform);
|
|
}
|
|
```
|
|
*/
|