Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_plasma_window_model.cpp
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 52 | private Q_SLOTS: | |||
---|---|---|---|---|---|
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 testGeometry(); | ||
80 | void testTitle(); | 80 | void testTitle(); | ||
81 | void testAppId(); | 81 | void testAppId(); | ||
82 | void testPid(); | ||||
82 | void testVirtualDesktop(); | 83 | void testVirtualDesktop(); | ||
83 | // TODO icon: can we ensure a theme is installed on CI? | 84 | // TODO icon: can we ensure a theme is installed on CI? | ||
84 | void testRequests(); | 85 | void testRequests(); | ||
85 | // TODO: minimized geometry | 86 | // TODO: minimized geometry | ||
86 | // TODO: model reset | 87 | // TODO: model reset | ||
87 | void testCreateWithUnmappedWindow(); | 88 | void testCreateWithUnmappedWindow(); | ||
88 | void testChangeWindowAfterModelDestroy_data(); | 89 | void testChangeWindowAfterModelDestroy_data(); | ||
89 | void testChangeWindowAfterModelDestroy(); | 90 | void testChangeWindowAfterModelDestroy(); | ||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | 178 | if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ | |||
206 | COMPARE(dataChangedSpy.last().last().value<QVector<int>>(), QVector<int>{int(role)}); | 207 | COMPARE(dataChangedSpy.last().last().value<QVector<int>>(), QVector<int>{int(role)}); | ||
207 | COMPARE(model->data(index, role).toBool(), false); | 208 | COMPARE(model->data(index, role).toBool(), false); | ||
208 | 209 | | |||
209 | #undef COMPARE | 210 | #undef COMPARE | ||
210 | #undef VERIFY | 211 | #undef VERIFY | ||
211 | return true; | 212 | return true; | ||
212 | } | 213 | } | ||
213 | 214 | | |||
214 | void PlasmaWindowModelTest::testRoleNames_data() | 215 | void PlasmaWindowModelTest::testRoleNames_data() | ||
graesslin: Please extend this | |||||
215 | { | 216 | { | ||
216 | QTest::addColumn<int>("role"); | 217 | QTest::addColumn<int>("role"); | ||
217 | QTest::addColumn<QByteArray>("name"); | 218 | QTest::addColumn<QByteArray>("name"); | ||
218 | 219 | | |||
219 | QTest::newRow("display") << int(Qt::DisplayRole) << QByteArrayLiteral("DisplayRole"); | 220 | QTest::newRow("display") << int(Qt::DisplayRole) << QByteArrayLiteral("DisplayRole"); | ||
220 | QTest::newRow("decoration") << int(Qt::DecorationRole) << QByteArrayLiteral("DecorationRole"); | 221 | QTest::newRow("decoration") << int(Qt::DecorationRole) << QByteArrayLiteral("DecorationRole"); | ||
221 | 222 | | |||
222 | QTest::newRow("AppId") << int(PlasmaWindowModel::AppId) << QByteArrayLiteral("AppId"); | 223 | QTest::newRow("AppId") << int(PlasmaWindowModel::AppId) << QByteArrayLiteral("AppId"); | ||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Line(s) | 308 | { | |||
327 | QTest::newRow("IsShadeable") << int(PlasmaWindowModel::IsShadeable) << QVariant(false); | 328 | QTest::newRow("IsShadeable") << int(PlasmaWindowModel::IsShadeable) << QVariant(false); | ||
328 | QTest::newRow("IsShaded") << int(PlasmaWindowModel::IsShaded) << QVariant(false); | 329 | QTest::newRow("IsShaded") << int(PlasmaWindowModel::IsShaded) << QVariant(false); | ||
329 | QTest::newRow("SkipTaskbar") << int(PlasmaWindowModel::SkipTaskbar) << QVariant(false); | 330 | QTest::newRow("SkipTaskbar") << int(PlasmaWindowModel::SkipTaskbar) << QVariant(false); | ||
330 | QTest::newRow("IsMovable") << int(PlasmaWindowModel::IsMovable) << QVariant(false); | 331 | QTest::newRow("IsMovable") << int(PlasmaWindowModel::IsMovable) << QVariant(false); | ||
331 | QTest::newRow("IsResizable") << int(PlasmaWindowModel::IsResizable) << QVariant(false); | 332 | QTest::newRow("IsResizable") << int(PlasmaWindowModel::IsResizable) << QVariant(false); | ||
332 | QTest::newRow("IsVirtualDesktopChangeable") << int(PlasmaWindowModel::IsVirtualDesktopChangeable) << QVariant(false); | 333 | QTest::newRow("IsVirtualDesktopChangeable") << int(PlasmaWindowModel::IsVirtualDesktopChangeable) << QVariant(false); | ||
333 | QTest::newRow("IsCloseable") << int(PlasmaWindowModel::IsCloseable) << QVariant(false); | 334 | QTest::newRow("IsCloseable") << int(PlasmaWindowModel::IsCloseable) << QVariant(false); | ||
334 | QTest::newRow("Geometry") << int(PlasmaWindowModel::Geometry) << QVariant(QRect()); | 335 | QTest::newRow("Geometry") << int(PlasmaWindowModel::Geometry) << QVariant(QRect()); | ||
336 | QTest::newRow("Pid") << int(PlasmaWindowModel::Pid) << QVariant(0); | ||||
335 | } | 337 | } | ||
336 | 338 | | |||
337 | void PlasmaWindowModelTest::testDefaultData() | 339 | void PlasmaWindowModelTest::testDefaultData() | ||
338 | { | 340 | { | ||
339 | // this test validates the default data of a PlasmaWindow without having set any values | 341 | // this test validates the default data of a PlasmaWindow without having set any values | ||
340 | // first create a model with a window | 342 | // first create a model with a window | ||
341 | auto model = m_pw->createWindowModel(); | 343 | auto model = m_pw->createWindowModel(); | ||
342 | QVERIFY(model); | 344 | QVERIFY(model); | ||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Line(s) | 502 | { | |||
516 | w->setAppId(QStringLiteral("org.kde.testapp")); | 518 | w->setAppId(QStringLiteral("org.kde.testapp")); | ||
517 | QVERIFY(dataChangedSpy.wait()); | 519 | QVERIFY(dataChangedSpy.wait()); | ||
518 | QCOMPARE(dataChangedSpy.count(), 1); | 520 | QCOMPARE(dataChangedSpy.count(), 1); | ||
519 | QCOMPARE(dataChangedSpy.last().first().toModelIndex(), index); | 521 | QCOMPARE(dataChangedSpy.last().first().toModelIndex(), index); | ||
520 | QCOMPARE(dataChangedSpy.last().last().value<QVector<int>>(), QVector<int>{int(PlasmaWindowModel::AppId)}); | 522 | QCOMPARE(dataChangedSpy.last().last().value<QVector<int>>(), QVector<int>{int(PlasmaWindowModel::AppId)}); | ||
521 | QCOMPARE(model->data(index, PlasmaWindowModel::AppId).toString(), QStringLiteral("org.kde.testapp")); | 523 | QCOMPARE(model->data(index, PlasmaWindowModel::AppId).toString(), QStringLiteral("org.kde.testapp")); | ||
522 | } | 524 | } | ||
523 | 525 | | |||
526 | void PlasmaWindowModelTest::testPid() | ||||
527 | { | ||||
528 | auto model = m_pw->createWindowModel(); | ||||
529 | QVERIFY(model); | ||||
530 | QSignalSpy rowInsertedSpy(model, &PlasmaWindowModel::rowsInserted); | ||||
531 | QVERIFY(rowInsertedSpy.isValid()); | ||||
532 | auto w = m_pwInterface->createWindow(m_pwInterface); | ||||
533 | QVERIFY(w); | ||||
534 | QVERIFY(rowInsertedSpy.wait()); | ||||
535 | m_connection->flush(); | ||||
536 | m_display->dispatchEvents(); | ||||
537 | QSignalSpy dataChangedSpy(model, &PlasmaWindowModel::dataChanged); | ||||
538 | QVERIFY(dataChangedSpy.isValid()); | ||||
539 | | ||||
540 | const QModelIndex index = model->index(0); | ||||
541 | QCOMPARE(model->data(index, PlasmaWindowModel::Pid).toInt(), 0); | ||||
542 | | ||||
543 | w->setPid(1337); | ||||
544 | QVERIFY(dataChangedSpy.wait()); | ||||
545 | QCOMPARE(dataChangedSpy.count(), 1); | ||||
546 | QCOMPARE(dataChangedSpy.last().first().toModelIndex(), index); | ||||
547 | QCOMPARE(dataChangedSpy.last().last().value<QVector<int>>(), QVector<int>{int(PlasmaWindowModel::Pid)}); | ||||
548 | QCOMPARE(model->data(index, PlasmaWindowModel::Pid).toInt(), 1337); | ||||
549 | } | ||||
550 | | ||||
524 | void PlasmaWindowModelTest::testVirtualDesktop() | 551 | void PlasmaWindowModelTest::testVirtualDesktop() | ||
525 | { | 552 | { | ||
526 | auto model = m_pw->createWindowModel(); | 553 | auto model = m_pw->createWindowModel(); | ||
527 | QVERIFY(model); | 554 | QVERIFY(model); | ||
528 | QSignalSpy rowInsertedSpy(model, &PlasmaWindowModel::rowsInserted); | 555 | QSignalSpy rowInsertedSpy(model, &PlasmaWindowModel::rowsInserted); | ||
529 | QVERIFY(rowInsertedSpy.isValid()); | 556 | QVERIFY(rowInsertedSpy.isValid()); | ||
530 | auto w = m_pwInterface->createWindow(m_pwInterface); | 557 | auto w = m_pwInterface->createWindow(m_pwInterface); | ||
531 | QVERIFY(w); | 558 | QVERIFY(w); | ||
▲ Show 20 Lines • Show All 308 Lines • Show Last 20 Lines |
Please extend this