MCPcopy Create free account
hub / github.com/KDE/kwin / testInternalWindow

Method testInternalWindow

autotests/integration/debug_console_test.cpp:411–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409};
410
411void DebugConsoleTest::testInternalWindow()
412{
413 DebugConsoleModel model;
414 QModelIndex internalTopLevelIndex = model.index(3, 0, QModelIndex());
415 QVERIFY(internalTopLevelIndex.isValid());
416
417 // there might already be some internal windows, so we cannot reliable test whether there are children
418 // given that we just test whether adding a window works.
419
420 QSignalSpy rowsInsertedSpy(&model, &QAbstractItemModel::rowsInserted);
421
422 std::unique_ptr<HelperWindow> w(new HelperWindow);
423 w->setGeometry(0, 0, 100, 100);
424 w->show();
425
426 QTRY_COMPARE(rowsInsertedSpy.count(), 1);
427 QCOMPARE(rowsInsertedSpy.first().first().value<QModelIndex>(), internalTopLevelIndex);
428
429 QModelIndex windowIndex = model.index(rowsInsertedSpy.first().last().toInt(), 0, internalTopLevelIndex);
430 QVERIFY(windowIndex.isValid());
431 QCOMPARE(model.parent(windowIndex), internalTopLevelIndex);
432 QVERIFY(model.hasChildren(windowIndex));
433 QVERIFY(model.rowCount(windowIndex) != 0);
434 QCOMPARE(model.columnCount(windowIndex), 2);
435 // other indexes are still invalid
436 QVERIFY(!model.index(rowsInsertedSpy.first().last().toInt(), 1, internalTopLevelIndex).isValid());
437 QVERIFY(!model.index(rowsInsertedSpy.first().last().toInt(), 2, internalTopLevelIndex).isValid());
438 QVERIFY(!model.index(rowsInsertedSpy.first().last().toInt() + 1, 0, internalTopLevelIndex).isValid());
439
440 // the wayland shell client top level should not have gained this window
441 QVERIFY(!model.hasChildren(model.index(2, 0, QModelIndex())));
442
443 // the windowIndex has children and those are properties
444 for (int i = 0; i < model.rowCount(windowIndex); i++) {
445 const QModelIndex propNameIndex = model.index(i, 0, windowIndex);
446 QVERIFY(propNameIndex.isValid());
447 QCOMPARE(model.parent(propNameIndex), windowIndex);
448 QVERIFY(!model.hasChildren(propNameIndex));
449 QVERIFY(!model.index(0, 0, propNameIndex).isValid());
450 QVERIFY(model.data(propNameIndex, Qt::DisplayRole).isValid());
451 QCOMPARE(model.data(propNameIndex, Qt::DisplayRole).userType(), int(QMetaType::QString));
452
453 // and the value
454 const QModelIndex propValueIndex = model.index(i, 1, windowIndex);
455 QVERIFY(propValueIndex.isValid());
456 QCOMPARE(model.parent(propValueIndex), windowIndex);
457 QVERIFY(!model.index(0, 0, propValueIndex).isValid());
458 QVERIFY(!model.hasChildren(propValueIndex));
459 // TODO: how to test whether the values actually work?
460
461 // and on third column we should not get an index any more
462 QVERIFY(!model.index(i, 2, windowIndex).isValid());
463 }
464 // row after count should be invalid
465 QVERIFY(!model.index(model.rowCount(windowIndex), 0, windowIndex).isValid());
466
467 // now close the window again, it should be removed from the model
468 QSignalSpy rowsRemovedSpy(&model, &QAbstractItemModel::rowsRemoved);

Callers

nothing calls this directly

Calls 12

firstMethod · 0.80
indexMethod · 0.45
isValidMethod · 0.45
setGeometryMethod · 0.45
showMethod · 0.45
countMethod · 0.45
parentMethod · 0.45
rowCountMethod · 0.45
columnCountMethod · 0.45
dataMethod · 0.45
hideMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected