Commit 9ccd583c authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Make the view_mgmt test more robust

parent a942dbc5
Pipeline #250276 passed with stage
in 30 minutes and 55 seconds
......@@ -14,6 +14,11 @@
static bool viewspaceContainsView(KateViewSpace *vs, KTextEditor::View *v)
return vs->hasDocument(v->document());
KateViewManagementTests::KateViewManagementTests(QObject *)
m_tempdir = new QTemporaryDir;
......@@ -92,27 +97,37 @@ void KateViewManagementTests::testViewspaceClosesWhenThereIsWidget()
// Now we have two viewspaces
QCOMPARE(vm->m_viewSpaceList.size(), 2);
auto *leftVS = vm->m_viewSpaceList[0];
auto *rightVS = vm->m_viewSpaceList[1];
QCOMPARE(rightVS, vm->activeViewSpace());
// add a widget
QPointer<QWidget> widget = new QWidget;
Utils::addWidget(widget, app->activeMainWindow());
// active viewspace remains the same
QCOMPARE(vm->m_viewSpaceList[1], vm->activeViewSpace());
// the widget should be active in activeViewSpace
QCOMPARE(vm->activeViewSpace()->currentWidget(), widget);
// activeView() should be nullptr
// there should still be 2 views
// widget is not counted in views
QCOMPARE(vm->m_views.size(), 2);
// Widget should be active
// activeView() should be nullptr
const auto sortedViews = vm->views();
QCOMPARE(sortedViews.size(), 2);
// ensure we know where both of the views are and
// we close the right one
// Make the view active
QVERIFY(vm->activeView() == vm->m_views.begin()->first);
// Make the KTE::view in right viewspace active
QVERIFY(vm->activeView() ==;
// close active view
// active view still points to the last active view
// even though it is not in focus by user
// one view left, but two viewspaces
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment