Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_plasma_window_model.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 52 | private Q_SLOTS: | |||
---|---|---|---|---|---|
71 | void testIsDemandingAttention(); | 71 | void testIsDemandingAttention(); | ||
72 | void testSkipTaskbar(); | 72 | void testSkipTaskbar(); | ||
73 | void testIsShadeable(); | 73 | void testIsShadeable(); | ||
74 | void testIsShaded(); | 74 | void testIsShaded(); | ||
75 | void testIsMovable(); | 75 | void testIsMovable(); | ||
76 | void testIsResizable(); | 76 | void testIsResizable(); | ||
77 | void testIsVirtualDesktopChangeable(); | 77 | void testIsVirtualDesktopChangeable(); | ||
78 | void testIsCloseable(); | 78 | void testIsCloseable(); | ||
79 | void testGeometry(); | ||||
79 | void testTitle(); | 80 | void testTitle(); | ||
80 | void testAppId(); | 81 | void testAppId(); | ||
81 | void testVirtualDesktop(); | 82 | void testVirtualDesktop(); | ||
82 | // TODO icon: can we ensure a theme is installed on CI? | 83 | // TODO icon: can we ensure a theme is installed on CI? | ||
83 | void testRequests(); | 84 | void testRequests(); | ||
84 | // TODO: minimized geometry | 85 | // TODO: minimized geometry | ||
85 | // TODO: model reset | 86 | // TODO: model reset | ||
86 | void testCreateWithUnmappedWindow(); | 87 | void testCreateWithUnmappedWindow(); | ||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Line(s) | 215 | { | |||
233 | QTest::newRow("IsDemandingAttention") << int(PlasmaWindowModel::IsDemandingAttention) << QByteArrayLiteral("IsDemandingAttention"); | 234 | QTest::newRow("IsDemandingAttention") << int(PlasmaWindowModel::IsDemandingAttention) << QByteArrayLiteral("IsDemandingAttention"); | ||
234 | QTest::newRow("SkipTaskbar") << int(PlasmaWindowModel::SkipTaskbar) << QByteArrayLiteral("SkipTaskbar"); | 235 | QTest::newRow("SkipTaskbar") << int(PlasmaWindowModel::SkipTaskbar) << QByteArrayLiteral("SkipTaskbar"); | ||
235 | QTest::newRow("IsShadeable") << int(PlasmaWindowModel::IsShadeable) << QByteArrayLiteral("IsShadeable"); | 236 | QTest::newRow("IsShadeable") << int(PlasmaWindowModel::IsShadeable) << QByteArrayLiteral("IsShadeable"); | ||
236 | QTest::newRow("IsShaded") << int(PlasmaWindowModel::IsShaded) << QByteArrayLiteral("IsShaded"); | 237 | QTest::newRow("IsShaded") << int(PlasmaWindowModel::IsShaded) << QByteArrayLiteral("IsShaded"); | ||
237 | QTest::newRow("IsMovable") << int(PlasmaWindowModel::IsMovable) << QByteArrayLiteral("IsMovable"); | 238 | QTest::newRow("IsMovable") << int(PlasmaWindowModel::IsMovable) << QByteArrayLiteral("IsMovable"); | ||
238 | QTest::newRow("IsResizable") << int(PlasmaWindowModel::IsResizable) << QByteArrayLiteral("IsResizable"); | 239 | QTest::newRow("IsResizable") << int(PlasmaWindowModel::IsResizable) << QByteArrayLiteral("IsResizable"); | ||
239 | QTest::newRow("IsVirtualDesktopChangeable") << int(PlasmaWindowModel::IsVirtualDesktopChangeable) << QByteArrayLiteral("IsVirtualDesktopChangeable"); | 240 | QTest::newRow("IsVirtualDesktopChangeable") << int(PlasmaWindowModel::IsVirtualDesktopChangeable) << QByteArrayLiteral("IsVirtualDesktopChangeable"); | ||
240 | QTest::newRow("IsCloseable") << int(PlasmaWindowModel::IsCloseable) << QByteArrayLiteral("IsCloseable"); | 241 | QTest::newRow("IsCloseable") << int(PlasmaWindowModel::IsCloseable) << QByteArrayLiteral("IsCloseable"); | ||
242 | QTest::newRow("Geometry") << int(PlasmaWindowModel::Geometry) << QByteArrayLiteral("Geometry"); | ||||
241 | } | 243 | } | ||
242 | 244 | | |||
243 | void PlasmaWindowModelTest::testRoleNames() | 245 | void PlasmaWindowModelTest::testRoleNames() | ||
244 | { | 246 | { | ||
245 | // just verifies that all role names are available | 247 | // just verifies that all role names are available | ||
246 | auto model = m_pw->createWindowModel(); | 248 | auto model = m_pw->createWindowModel(); | ||
247 | QVERIFY(model); | 249 | QVERIFY(model); | ||
248 | const auto roles = model->roleNames(); | 250 | const auto roles = model->roleNames(); | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 307 | { | |||
323 | QTest::newRow("IsOnAllDesktops") << int(PlasmaWindowModel::IsOnAllDesktops) << QVariant(false); | 325 | QTest::newRow("IsOnAllDesktops") << int(PlasmaWindowModel::IsOnAllDesktops) << QVariant(false); | ||
324 | QTest::newRow("IsDemandingAttention") << int(PlasmaWindowModel::IsDemandingAttention) << QVariant(false); | 326 | QTest::newRow("IsDemandingAttention") << int(PlasmaWindowModel::IsDemandingAttention) << QVariant(false); | ||
325 | QTest::newRow("IsShadeable") << int(PlasmaWindowModel::IsShadeable) << QVariant(false); | 327 | QTest::newRow("IsShadeable") << int(PlasmaWindowModel::IsShadeable) << QVariant(false); | ||
326 | QTest::newRow("IsShaded") << int(PlasmaWindowModel::IsShaded) << QVariant(false); | 328 | QTest::newRow("IsShaded") << int(PlasmaWindowModel::IsShaded) << QVariant(false); | ||
327 | QTest::newRow("SkipTaskbar") << int(PlasmaWindowModel::SkipTaskbar) << QVariant(false); | 329 | QTest::newRow("SkipTaskbar") << int(PlasmaWindowModel::SkipTaskbar) << QVariant(false); | ||
328 | QTest::newRow("IsMovable") << int(PlasmaWindowModel::IsMovable) << QVariant(false); | 330 | QTest::newRow("IsMovable") << int(PlasmaWindowModel::IsMovable) << QVariant(false); | ||
329 | QTest::newRow("IsResizable") << int(PlasmaWindowModel::IsResizable) << QVariant(false); | 331 | QTest::newRow("IsResizable") << int(PlasmaWindowModel::IsResizable) << QVariant(false); | ||
330 | QTest::newRow("IsVirtualDesktopChangeable") << int(PlasmaWindowModel::IsVirtualDesktopChangeable) << QVariant(false); | 332 | QTest::newRow("IsVirtualDesktopChangeable") << int(PlasmaWindowModel::IsVirtualDesktopChangeable) << QVariant(false); | ||
331 | QTest::newRow("IsCloseable") << int(PlasmaWindowModel::IsCloseable) << QVariant(false); | 333 | QTest::newRow("IsCloseable") << int(PlasmaWindowModel::IsCloseable) << QVariant(false); | ||
334 | QTest::newRow("Geometry") << int(PlasmaWindowModel::Geometry) << QVariant(QRect()); | ||||
332 | } | 335 | } | ||
333 | 336 | | |||
334 | void PlasmaWindowModelTest::testDefaultData() | 337 | void PlasmaWindowModelTest::testDefaultData() | ||
335 | { | 338 | { | ||
336 | // this test validates the default data of a PlasmaWindow without having set any values | 339 | // this test validates the default data of a PlasmaWindow without having set any values | ||
337 | // first create a model with a window | 340 | // first create a model with a window | ||
338 | auto model = m_pw->createWindowModel(); | 341 | auto model = m_pw->createWindowModel(); | ||
339 | QVERIFY(model); | 342 | QVERIFY(model); | ||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | 435 | { | |||
433 | QVERIFY(testBooleanData(PlasmaWindowModel::IsVirtualDesktopChangeable, &PlasmaWindowInterface::setVirtualDesktopChangeable)); | 436 | QVERIFY(testBooleanData(PlasmaWindowModel::IsVirtualDesktopChangeable, &PlasmaWindowInterface::setVirtualDesktopChangeable)); | ||
434 | } | 437 | } | ||
435 | 438 | | |||
436 | void PlasmaWindowModelTest::testIsCloseable() | 439 | void PlasmaWindowModelTest::testIsCloseable() | ||
437 | { | 440 | { | ||
438 | QVERIFY(testBooleanData(PlasmaWindowModel::IsCloseable, &PlasmaWindowInterface::setCloseable)); | 441 | QVERIFY(testBooleanData(PlasmaWindowModel::IsCloseable, &PlasmaWindowInterface::setCloseable)); | ||
439 | } | 442 | } | ||
440 | 443 | | |||
444 | void PlasmaWindowModelTest::testGeometry() | ||||
445 | { | ||||
446 | auto model = m_pw->createWindowModel(); | ||||
447 | QVERIFY(model); | ||||
graesslin: you don't need to create a model. You have one in m_pw | |||||
hein: I copied that from testBooleanData | |||||
hein: Also m_pw is not actually a model but a PlasmaWindowManagement :-) | |||||
448 | | ||||
449 | QSignalSpy rowInsertedSpy(model, &PlasmaWindowModel::rowsInserted); | ||||
450 | QVERIFY(rowInsertedSpy.isValid()); | ||||
451 | | ||||
452 | auto w = m_pwInterface->createWindow(m_pwInterface); | ||||
453 | QVERIFY(w); | ||||
454 | QVERIFY(rowInsertedSpy.wait()); | ||||
455 | | ||||
456 | const QModelIndex index = model->index(0); | ||||
457 | | ||||
458 | QCOMPARE(model->data(index, PlasmaWindowModel::Geometry).toRect(), QRect()); | ||||
459 | | ||||
460 | m_connection->flush(); | ||||
461 | m_display->dispatchEvents(); | ||||
graesslin: those two should not be needed. | |||||
hein: Dropped. | |||||
462 | | ||||
463 | QSignalSpy dataChangedSpy(model, &PlasmaWindowModel::dataChanged); | ||||
graesslin: and what about x and y? | |||||
464 | QVERIFY(dataChangedSpy.isValid()); | ||||
465 | | ||||
466 | const QRect geom(0, 0, 50, 50); | ||||
could you use different values? E.g. if we swapped width and height, we wouldn't notice. graesslin: could you use different values? E.g. if we swapped width and height, we wouldn't notice. | |||||
hein: Done. | |||||
467 | w->setGeometry(geom); | ||||
468 | | ||||
469 | QVERIFY(dataChangedSpy.wait()); | ||||
470 | QCOMPARE(dataChangedSpy.count(), 1); | ||||
471 | QCOMPARE(dataChangedSpy.last().first().toModelIndex(), index); | ||||
472 | QCOMPARE(dataChangedSpy.last().last().value<QVector<int>>(), QVector<int>{int(PlasmaWindowModel::Geometry)}); | ||||
473 | | ||||
474 | QCOMPARE(model->data(index, PlasmaWindowModel::Geometry).toRect(), geom); | ||||
475 | } | ||||
476 | | ||||
441 | void PlasmaWindowModelTest::testTitle() | 477 | void PlasmaWindowModelTest::testTitle() | ||
442 | { | 478 | { | ||
443 | auto model = m_pw->createWindowModel(); | 479 | auto model = m_pw->createWindowModel(); | ||
444 | QVERIFY(model); | 480 | QVERIFY(model); | ||
445 | QSignalSpy rowInsertedSpy(model, &PlasmaWindowModel::rowsInserted); | 481 | QSignalSpy rowInsertedSpy(model, &PlasmaWindowModel::rowsInserted); | ||
446 | QVERIFY(rowInsertedSpy.isValid()); | 482 | QVERIFY(rowInsertedSpy.isValid()); | ||
447 | auto w = m_pwInterface->createWindow(m_pwInterface); | 483 | auto w = m_pwInterface->createWindow(m_pwInterface); | ||
448 | QVERIFY(w); | 484 | QVERIFY(w); | ||
▲ Show 20 Lines • Show All 358 Lines • Show Last 20 Lines |
you don't need to create a model. You have one in m_pw