Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/shell_client_rules_test.cpp
Show All 39 Lines | 39 | private Q_SLOTS: | |||
---|---|---|---|---|---|
40 | void initTestCase(); | 40 | void initTestCase(); | ||
41 | void init(); | 41 | void init(); | ||
42 | void cleanup(); | 42 | void cleanup(); | ||
43 | 43 | | |||
44 | void testApplyInitialDesktop_data(); | 44 | void testApplyInitialDesktop_data(); | ||
45 | void testApplyInitialDesktop(); | 45 | void testApplyInitialDesktop(); | ||
46 | void testApplyInitialMinimize_data(); | 46 | void testApplyInitialMinimize_data(); | ||
47 | void testApplyInitialMinimize(); | 47 | void testApplyInitialMinimize(); | ||
48 | void testApplyInitialSkipTaskbar_data(); | ||||
49 | void testApplyInitialSkipTaskbar(); | ||||
50 | void testApplyInitialSkipPager_data(); | ||||
51 | void testApplyInitialSkipPager(); | ||||
52 | void testApplyInitialSkipSwitcher_data(); | ||||
53 | void testApplyInitialSkipSwitcher(); | ||||
48 | }; | 54 | }; | ||
49 | 55 | | |||
50 | void TestShellClientRules::initTestCase() | 56 | void TestShellClientRules::initTestCase() | ||
51 | { | 57 | { | ||
52 | qRegisterMetaType<KWin::ShellClient*>(); | 58 | qRegisterMetaType<KWin::ShellClient*>(); | ||
53 | qRegisterMetaType<KWin::AbstractClient*>(); | 59 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
54 | 60 | | |||
55 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 61 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
Show All 18 Lines | 76 | { | |||
74 | screens()->setCurrent(0); | 80 | screens()->setCurrent(0); | ||
75 | } | 81 | } | ||
76 | 82 | | |||
77 | void TestShellClientRules::cleanup() | 83 | void TestShellClientRules::cleanup() | ||
78 | { | 84 | { | ||
79 | Test::destroyWaylandConnection(); | 85 | Test::destroyWaylandConnection(); | ||
80 | } | 86 | } | ||
81 | 87 | | |||
82 | void TestShellClientRules::testApplyInitialDesktop_data() | 88 | #define TEST_DATA( name ) \ | ||
83 | { | 89 | void TestShellClientRules::name##_data() \ | ||
84 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 90 | { \ | ||
85 | QTest::addColumn<int>("ruleNumber"); | 91 | QTest::addColumn<Test::ShellSurfaceType>("type"); \ | ||
86 | 92 | QTest::addColumn<int>("ruleNumber"); \ | |||
87 | QTest::newRow("wlShell|Force") << Test::ShellSurfaceType::WlShell << 2; | 93 | QTest::newRow("wlShell|Force") << Test::ShellSurfaceType::WlShell << 2; \ | ||
88 | QTest::newRow("xdgShellV5|Force") << Test::ShellSurfaceType::XdgShellV5 << 2; | 94 | QTest::newRow("xdgShellV5|Force") << Test::ShellSurfaceType::XdgShellV5 << 2; \ | ||
89 | QTest::newRow("xdgShellV6|Force") << Test::ShellSurfaceType::XdgShellV6 << 2; | 95 | QTest::newRow("xdgShellV6|Force") << Test::ShellSurfaceType::XdgShellV6 << 2; \ | ||
90 | 96 | QTest::newRow("wlShell|Apply") << Test::ShellSurfaceType::WlShell << 3; \ | |||
91 | QTest::newRow("wlShell|Apply") << Test::ShellSurfaceType::WlShell << 3; | 97 | QTest::newRow("xdgShellV5|Apply") << Test::ShellSurfaceType::XdgShellV5 << 3; \ | ||
92 | QTest::newRow("xdgShellV5|Apply") << Test::ShellSurfaceType::XdgShellV5 << 3; | 98 | QTest::newRow("xdgShellV6|Apply") << Test::ShellSurfaceType::XdgShellV6 << 3; \ | ||
93 | QTest::newRow("xdgShellV6|Apply") << Test::ShellSurfaceType::XdgShellV6 << 3; | 99 | QTest::newRow("wlShell|ApplyNow") << Test::ShellSurfaceType::WlShell << 5; \ | ||
94 | 100 | QTest::newRow("xdgShellV5|ApplyNow") << Test::ShellSurfaceType::XdgShellV5 << 5; \ | |||
95 | QTest::newRow("wlShell|ApplyNow") << Test::ShellSurfaceType::WlShell << 5; | 101 | QTest::newRow("xdgShellV6|ApplyNow") << Test::ShellSurfaceType::XdgShellV6 << 5; \ | ||
96 | QTest::newRow("xdgShellV5|ApplyNow") << Test::ShellSurfaceType::XdgShellV5 << 5; | 102 | QTest::newRow("wlShell|ForceTemporarily") << Test::ShellSurfaceType::WlShell << 6; \ | ||
97 | QTest::newRow("xdgShellV6|ApplyNow") << Test::ShellSurfaceType::XdgShellV6 << 5; | 103 | QTest::newRow("xdgShellV5|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV5 << 6; \ | ||
98 | 104 | QTest::newRow("xdgShellV6|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV6 << 6; \ | |||
99 | QTest::newRow("wlShell|ForceTemporarily") << Test::ShellSurfaceType::WlShell << 6; | | |||
100 | QTest::newRow("xdgShellV5|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV5 << 6; | | |||
101 | QTest::newRow("xdgShellV6|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV6 << 6; | | |||
102 | } | 105 | } | ||
103 | 106 | | |||
107 | TEST_DATA(testApplyInitialDesktop) | ||||
108 | | ||||
104 | void TestShellClientRules::testApplyInitialDesktop() | 109 | void TestShellClientRules::testApplyInitialDesktop() | ||
105 | { | 110 | { | ||
106 | // ensure we have two desktops and are on first desktop | 111 | // ensure we have two desktops and are on first desktop | ||
107 | VirtualDesktopManager::self()->setCount(2); | 112 | VirtualDesktopManager::self()->setCount(2); | ||
108 | VirtualDesktopManager::self()->setCurrent(VirtualDesktopManager::self()->desktops().first()); | 113 | VirtualDesktopManager::self()->setCurrent(VirtualDesktopManager::self()->desktops().first()); | ||
109 | 114 | | |||
110 | // install the temporary rule | 115 | // install the temporary rule | ||
111 | QFETCH(int, ruleNumber); | 116 | QFETCH(int, ruleNumber); | ||
112 | QString rule = QStringLiteral("desktop=2\ndesktoprule=%1").arg(ruleNumber); | 117 | QString rule = QStringLiteral("desktop=2\ndesktoprule=%1").arg(ruleNumber); | ||
113 | QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule)); | 118 | QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule)); | ||
114 | 119 | | |||
115 | QScopedPointer<Surface> surface(Test::createSurface()); | 120 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
116 | QFETCH(Test::ShellSurfaceType, type); | 121 | QFETCH(Test::ShellSurfaceType, type); | ||
117 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 122 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | ||
118 | 123 | | |||
119 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 124 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
120 | QVERIFY(c); | 125 | QVERIFY(c); | ||
121 | QCOMPARE(c->desktop(), 2); | 126 | QCOMPARE(c->desktop(), 2); | ||
122 | QCOMPARE(c->isMinimized(), false); | 127 | QCOMPARE(c->isMinimized(), false); | ||
123 | QCOMPARE(c->isActive(), true); | 128 | QCOMPARE(c->isActive(), true); | ||
129 | QCOMPARE(c->skipTaskbar(), false); | ||||
130 | QCOMPARE(c->skipPager(), false); | ||||
131 | QCOMPARE(c->skipSwitcher(), false); | ||||
124 | } | 132 | } | ||
125 | 133 | | |||
126 | void TestShellClientRules::testApplyInitialMinimize_data() | 134 | TEST_DATA(testApplyInitialMinimize) | ||
127 | { | | |||
128 | QTest::addColumn<Test::ShellSurfaceType>("type"); | | |||
129 | QTest::addColumn<int>("ruleNumber"); | | |||
130 | | ||||
131 | QTest::newRow("wlShell|Force") << Test::ShellSurfaceType::WlShell << 2; | | |||
132 | QTest::newRow("xdgShellV5|Force") << Test::ShellSurfaceType::XdgShellV5 << 2; | | |||
133 | QTest::newRow("xdgShellV6|Force") << Test::ShellSurfaceType::XdgShellV6 << 2; | | |||
134 | | ||||
135 | QTest::newRow("wlShell|Apply") << Test::ShellSurfaceType::WlShell << 3; | | |||
136 | QTest::newRow("xdgShellV5|Apply") << Test::ShellSurfaceType::XdgShellV5 << 3; | | |||
137 | QTest::newRow("xdgShellV6|Apply") << Test::ShellSurfaceType::XdgShellV6 << 3; | | |||
138 | | ||||
139 | QTest::newRow("wlShell|ApplyNow") << Test::ShellSurfaceType::WlShell << 5; | | |||
140 | QTest::newRow("xdgShellV5|ApplyNow") << Test::ShellSurfaceType::XdgShellV5 << 5; | | |||
141 | QTest::newRow("xdgShellV6|ApplyNow") << Test::ShellSurfaceType::XdgShellV6 << 5; | | |||
142 | | ||||
143 | QTest::newRow("wlShell|ForceTemporarily") << Test::ShellSurfaceType::WlShell << 6; | | |||
144 | QTest::newRow("xdgShellV5|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV5 << 6; | | |||
145 | QTest::newRow("xdgShellV6|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV6 << 6; | | |||
146 | } | | |||
147 | 135 | | |||
148 | void TestShellClientRules::testApplyInitialMinimize() | 136 | void TestShellClientRules::testApplyInitialMinimize() | ||
149 | { | 137 | { | ||
150 | // install the temporary rule | 138 | // install the temporary rule | ||
151 | QFETCH(int, ruleNumber); | 139 | QFETCH(int, ruleNumber); | ||
152 | QString rule = QStringLiteral("minimize=1\nminimizerule=%1").arg(ruleNumber); | 140 | QString rule = QStringLiteral("minimize=1\nminimizerule=%1").arg(ruleNumber); | ||
153 | QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule)); | 141 | QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule)); | ||
154 | 142 | | |||
155 | QScopedPointer<Surface> surface(Test::createSurface()); | 143 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
156 | QFETCH(Test::ShellSurfaceType, type); | 144 | QFETCH(Test::ShellSurfaceType, type); | ||
157 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 145 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | ||
158 | 146 | | |||
159 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 147 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
160 | QVERIFY(c); | 148 | QVERIFY(c); | ||
161 | QCOMPARE(c->desktop(), 1); | 149 | QCOMPARE(c->desktop(), 1); | ||
162 | QCOMPARE(c->isMinimized(), true); | 150 | QCOMPARE(c->isMinimized(), true); | ||
163 | QCOMPARE(c->isActive(), false); | 151 | QCOMPARE(c->isActive(), false); | ||
164 | c->setMinimized(false); | 152 | c->setMinimized(false); | ||
165 | QCOMPARE(c->isMinimized(), false); | 153 | QCOMPARE(c->isMinimized(), false); | ||
154 | QCOMPARE(c->skipTaskbar(), false); | ||||
155 | QCOMPARE(c->skipPager(), false); | ||||
156 | QCOMPARE(c->skipSwitcher(), false); | ||||
157 | } | ||||
158 | | ||||
159 | TEST_DATA(testApplyInitialSkipTaskbar) | ||||
160 | | ||||
161 | void TestShellClientRules::testApplyInitialSkipTaskbar() | ||||
162 | { | ||||
163 | // install the temporary rule | ||||
164 | QFETCH(int, ruleNumber); | ||||
165 | QString rule = QStringLiteral("skiptaskbar=true\nskiptaskbarrule=%1").arg(ruleNumber); | ||||
166 | QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule)); | ||||
167 | | ||||
168 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
169 | QFETCH(Test::ShellSurfaceType, type); | ||||
170 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | ||||
171 | | ||||
172 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||||
173 | QVERIFY(c); | ||||
174 | QCOMPARE(c->desktop(), 1); | ||||
175 | QCOMPARE(c->isMinimized(), false); | ||||
176 | QCOMPARE(c->isActive(), true); | ||||
177 | QCOMPARE(c->skipTaskbar(), true); | ||||
178 | QCOMPARE(c->skipPager(), false); | ||||
179 | QCOMPARE(c->skipSwitcher(), false); | ||||
180 | } | ||||
181 | | ||||
182 | TEST_DATA(testApplyInitialSkipPager) | ||||
183 | | ||||
184 | void TestShellClientRules::testApplyInitialSkipPager() | ||||
185 | { | ||||
186 | // install the temporary rule | ||||
187 | QFETCH(int, ruleNumber); | ||||
188 | QString rule = QStringLiteral("skippager=true\nskippagerrule=%1").arg(ruleNumber); | ||||
189 | QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule)); | ||||
190 | | ||||
191 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
192 | QFETCH(Test::ShellSurfaceType, type); | ||||
193 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | ||||
194 | | ||||
195 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||||
196 | QVERIFY(c); | ||||
197 | QCOMPARE(c->desktop(), 1); | ||||
198 | QCOMPARE(c->isMinimized(), false); | ||||
199 | QCOMPARE(c->isActive(), true); | ||||
200 | QCOMPARE(c->skipTaskbar(), false); | ||||
201 | QCOMPARE(c->skipPager(), true); | ||||
202 | QCOMPARE(c->skipSwitcher(), false); | ||||
203 | } | ||||
204 | | ||||
205 | TEST_DATA(testApplyInitialSkipSwitcher) | ||||
206 | | ||||
207 | void TestShellClientRules::testApplyInitialSkipSwitcher() | ||||
208 | { | ||||
209 | // install the temporary rule | ||||
210 | QFETCH(int, ruleNumber); | ||||
211 | QString rule = QStringLiteral("skipswitcher=true\nskipswitcherrule=%1").arg(ruleNumber); | ||||
212 | QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule)); | ||||
213 | | ||||
214 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
215 | QFETCH(Test::ShellSurfaceType, type); | ||||
216 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | ||||
217 | | ||||
218 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||||
219 | QVERIFY(c); | ||||
220 | QCOMPARE(c->desktop(), 1); | ||||
221 | QCOMPARE(c->isMinimized(), false); | ||||
222 | QCOMPARE(c->isActive(), true); | ||||
223 | QCOMPARE(c->skipTaskbar(), false); | ||||
224 | QCOMPARE(c->skipPager(), false); | ||||
225 | QCOMPARE(c->skipSwitcher(), true); | ||||
166 | } | 226 | } | ||
167 | 227 | | |||
168 | WAYLANDTEST_MAIN(TestShellClientRules) | 228 | WAYLANDTEST_MAIN(TestShellClientRules) | ||
169 | #include "shell_client_rules_test.moc" | 229 | #include "shell_client_rules_test.moc" |