┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/CMakeLists.txt6
-rw-r--r--src/tests/dolphinmainwindowtest.cpp55
-rw-r--r--src/tests/placesitemmodeltest.cpp3
3 files changed, 62 insertions, 2 deletions
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index c656173a8..07e4257a0 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -54,10 +54,14 @@ TEST_NAME viewpropertiestest
LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test)
# DolphinMainWindowTest
-ecm_add_test(dolphinmainwindowtest.cpp
+set(dolphinmainwindowtest_SRCS dolphinmainwindowtest.cpp)
+qt5_add_resources(dolphinmainwindowtest_SRCS ${CMAKE_SOURCE_DIR}/src/dolphin.qrc)
+
+ecm_add_test(${dolphinmainwindowtest_SRCS}
TEST_NAME dolphinmainwindowtest
LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test)
+# DragAndDropHelperTest
ecm_add_test(draganddrophelpertest.cpp LINK_LIBRARIES dolphinprivate Qt5::Test)
# PlacesItemModelTest
diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp
index a31237f3c..70ec8dba0 100644
--- a/src/tests/dolphinmainwindowtest.cpp
+++ b/src/tests/dolphinmainwindowtest.cpp
@@ -34,6 +34,8 @@ class DolphinMainWindowTest : public QObject
private slots:
void init();
void testClosingTabsWithSearchBoxVisible();
+ void testActiveViewAfterClosingSplitView_data();
+ void testActiveViewAfterClosingSplitView();
void testUpdateWindowTitleAfterClosingSplitView();
private:
@@ -68,6 +70,58 @@ void DolphinMainWindowTest::testClosingTabsWithSearchBoxVisible()
QCOMPARE(tabWidget->count(), 1);
}
+void DolphinMainWindowTest::testActiveViewAfterClosingSplitView_data()
+{
+ QTest::addColumn<bool>("closeLeftView");
+
+ QTest::newRow("close left view") << true;
+ QTest::newRow("close right view") << false;
+}
+
+void DolphinMainWindowTest::testActiveViewAfterClosingSplitView()
+{
+ m_mainWindow->openDirectories({ QUrl::fromLocalFile(QDir::homePath()) }, false);
+ m_mainWindow->show();
+ QVERIFY(QTest::qWaitForWindowExposed(m_mainWindow.data()));
+ QVERIFY(m_mainWindow->isVisible());
+
+ auto tabWidget = m_mainWindow->findChild<DolphinTabWidget*>("tabWidget");
+ QVERIFY(tabWidget);
+ QVERIFY(tabWidget->currentTabPage()->primaryViewContainer());
+ QVERIFY(!tabWidget->currentTabPage()->secondaryViewContainer());
+
+ // Open split view.
+ m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
+ QVERIFY(tabWidget->currentTabPage()->splitViewEnabled());
+ QVERIFY(tabWidget->currentTabPage()->secondaryViewContainer());
+
+ // Make sure the right view is the active one.
+ auto leftViewContainer = tabWidget->currentTabPage()->primaryViewContainer();
+ auto rightViewContainer = tabWidget->currentTabPage()->secondaryViewContainer();
+ QVERIFY(!leftViewContainer->isActive());
+ QVERIFY(rightViewContainer->isActive());
+
+ QFETCH(bool, closeLeftView);
+ if (closeLeftView) {
+ // Activate left view.
+ leftViewContainer->setActive(true);
+ QVERIFY(leftViewContainer->isActive());
+ QVERIFY(!rightViewContainer->isActive());
+
+ // Close left view. The secondary view (which was on the right) will become the primary one and must be active.
+ m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
+ QVERIFY(!leftViewContainer->isActive());
+ QVERIFY(rightViewContainer->isActive());
+ QCOMPARE(rightViewContainer, tabWidget->currentTabPage()->activeViewContainer());
+ } else {
+ // Close right view. The left view will become active.
+ m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
+ QVERIFY(leftViewContainer->isActive());
+ QVERIFY(!rightViewContainer->isActive());
+ QCOMPARE(leftViewContainer, tabWidget->currentTabPage()->activeViewContainer());
+ }
+}
+
// Test case for bug #385111
void DolphinMainWindowTest::testUpdateWindowTitleAfterClosingSplitView()
{
@@ -99,6 +153,7 @@ void DolphinMainWindowTest::testUpdateWindowTitleAfterClosingSplitView()
// Close split view. The secondary view (which was on the right) will become the primary one and must be active.
m_mainWindow->actionCollection()->action(QStringLiteral("split_view"))->trigger();
+ QVERIFY(!leftViewContainer->isActive());
QVERIFY(rightViewContainer->isActive());
QCOMPARE(rightViewContainer, tabWidget->currentTabPage()->activeViewContainer());
diff --git a/src/tests/placesitemmodeltest.cpp b/src/tests/placesitemmodeltest.cpp
index 3263537f9..fc21ce055 100644
--- a/src/tests/placesitemmodeltest.cpp
+++ b/src/tests/placesitemmodeltest.cpp
@@ -228,7 +228,8 @@ void PlacesItemModelTest::init()
void PlacesItemModelTest::cleanup()
{
- for (int i : m_tobeRemoved) {
+ const auto tobeRemoved = m_tobeRemoved;
+ for (const int i : tobeRemoved) {
int before = m_model->count();
m_model->deleteItem(i);
QTRY_COMPARE(m_model->count(), before - 1);