1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
3 | |
4 | #define CATCH_CONFIG_MAIN |
5 | #include "catch2/catch.hpp" |
6 | |
7 | #include <slint.h> |
8 | #include <thread> |
9 | |
10 | #include <slint-interpreter.h> |
11 | |
12 | TEST_CASE("Basic Window Visibility" ) |
13 | { |
14 | using namespace slint::interpreter; |
15 | using namespace slint; |
16 | |
17 | ComponentCompiler compiler; |
18 | auto comp_def = compiler.build_from_source(R"( |
19 | export App := Window { |
20 | } |
21 | )" , |
22 | "" ); |
23 | REQUIRE(comp_def.has_value()); |
24 | auto instance = comp_def->create(); |
25 | REQUIRE(instance->window().is_visible() == false); |
26 | instance->show(); |
27 | REQUIRE(instance->window().is_visible() == true); |
28 | instance->hide(); |
29 | REQUIRE(instance->window().is_visible() == false); |
30 | } |
31 | |
32 | TEST_CASE("Window Scale Factory Existence" ) |
33 | { |
34 | using namespace slint::interpreter; |
35 | using namespace slint; |
36 | |
37 | ComponentCompiler compiler; |
38 | auto comp_def = compiler.build_from_source(R"( |
39 | export App := Window { |
40 | } |
41 | )" , |
42 | "" ); |
43 | REQUIRE(comp_def.has_value()); |
44 | auto instance = comp_def->create(); |
45 | REQUIRE(instance->window().scale_factor() > 0); |
46 | } |
47 | |