Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
9ccd583c
Commit
9ccd583c
authored
Oct 18, 2022
by
Waqar Ahmed
Browse files
Make the view_mgmt test more robust
parent
a942dbc5
Pipeline
#250276
passed with stage
in 30 minutes and 55 seconds
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
apps/lib/autotests/kate_view_mgmt_tests.cpp
View file @
9ccd583c
...
...
@@ -14,6 +14,11 @@
QTEST_MAIN
(
KateViewManagementTests
)
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()
vm
->
slotSplitViewSpaceVert
();
// 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
QVERIFY
(
!
vm
->
activeView
());
// there should still be 2 views
// widget is not counted in views
QCOMPARE
(
vm
->
m_views
.
size
(),
2
);
// Widget should be active
QVERIFY
(
vm
->
activeViewSpace
()
->
currentWidget
());
// activeView() should be nullptr
QVERIFY
(
!
vm
->
activeView
());
const
auto
sortedViews
=
vm
->
views
();
QCOMPARE
(
sortedViews
.
size
(),
2
);
// ensure we know where both of the views are and
// we close the right one
QVERIFY
(
viewspaceContainsView
(
rightVS
,
sortedViews
.
at
(
0
)));
QVERIFY
(
viewspaceContainsView
(
leftVS
,
sortedViews
.
at
(
1
)));
// Make the
view
active
vm
->
activateView
(
vm
->
m_views
.
begin
()
->
first
);
QVERIFY
(
vm
->
activeView
()
==
vm
->
m_views
.
begin
()
->
first
);
// Make the
KTE::view in right viewspace
active
vm
->
activateView
(
sortedViews
.
at
(
0
)
);
QVERIFY
(
vm
->
activeView
()
==
sortedViews
.
at
(
0
)
);
// close active view
// active view still points to the last active view
// even though it is not in focus by user
vm
->
closeView
(
vm
->
activeView
());
// one view left, but two viewspaces
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment