┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/CMakeLists.txt156
-rw-r--r--src/tests/dolphinmainwindowtest.cpp69
-rw-r--r--src/tests/kfileitemmodeltest.cpp3
-rw-r--r--src/tests/kitemlistselectionmanagertest.cpp37
4 files changed, 119 insertions, 146 deletions
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index c7159bf1b..1c2335cbf 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -1,155 +1,59 @@
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
find_package(Qt5Test CONFIG REQUIRED)
-include(ECMMarkAsTest)
-
-# needed on windows to correctly use the files from dolphinprivate
-add_definitions(-DDOLPHIN_EXPORT=)
+include(ECMAddTests)
# KItemSetTest
-set(kitemsettest_SRCS
- kitemsettest.cpp
-)
-
-add_executable(kitemsettest ${kitemsettest_SRCS})
-add_test(kitemsettest kitemsettest)
-ecm_mark_as_test(kitemsettest)
-target_link_libraries(kitemsettest dolphinprivate Qt5::Test)
+ecm_add_test(kitemsettest.cpp LINK_LIBRARIES dolphinprivate Qt5::Test)
# KItemRangeTest
-set(kitemrangetest_SRCS
- kitemrangetest.cpp
-)
-
-add_executable(kitemrangetest ${kitemrangetest_SRCS})
-add_test(kitemrangetest kitemrangetest)
-ecm_mark_as_test(kitemrangetest)
-target_link_libraries(kitemrangetest dolphinprivate Qt5::Test)
+ecm_add_test(kitemrangetest.cpp LINK_LIBRARIES dolphinprivate Qt5::Test)
# KItemListSelectionManagerTest
-set(kitemlistselectionmanagertest_SRCS
- kitemlistselectionmanagertest.cpp
-)
-
-add_executable(kitemlistselectionmanagertest ${kitemlistselectionmanagertest_SRCS})
-add_test(kitemlistselectionmanagertest kitemlistselectionmanagertest)
-ecm_mark_as_test(kitemlistselectionmanagertest)
-target_link_libraries(kitemlistselectionmanagertest dolphinprivate Qt5::Test)
+ecm_add_test(kitemlistselectionmanagertest.cpp LINK_LIBRARIES dolphinprivate Qt5::Test)
# KItemListControllerTest
-set(kitemlistcontrollertest_SRCS
- kitemlistcontrollertest.cpp
- testdir.cpp
- ../dolphindebug.cpp
-)
-
-kconfig_add_kcfg_files(kitemlistcontrollertest_SRCS GENERATE_MOC
- ../settings/dolphin_generalsettings.kcfgc
-)
-
-add_executable(kitemlistcontrollertest ${kitemlistcontrollertest_SRCS})
-add_test(kitemlistcontrollertest kitemlistcontrollertest)
-ecm_mark_as_test(kitemlistcontrollertest)
-target_link_libraries(kitemlistcontrollertest dolphinprivate Qt5::Test)
+ecm_add_test(kitemlistcontrollertest.cpp testdir.cpp
+TEST_NAME kitemlistcontrollertest
+LINK_LIBRARIES dolphinprivate Qt5::Test)
# KFileItemListViewTest
-set(kfileitemlistviewtest_SRCS
- kfileitemlistviewtest.cpp
- testdir.cpp
- ../dolphindebug.cpp
-)
-
-kconfig_add_kcfg_files(kfileitemlistviewtest_SRCS GENERATE_MOC
- ../settings/dolphin_generalsettings.kcfgc
-)
-
-add_executable(kfileitemlistviewtest ${kfileitemlistviewtest_SRCS})
-add_test(kfileitemlistviewtest kfileitemlistviewtest)
-ecm_mark_as_test(kfileitemlistviewtest)
-target_link_libraries(kfileitemlistviewtest dolphinprivate Qt5::Test)
+ecm_add_test(kfileitemlistviewtest.cpp testdir.cpp
+TEST_NAME kfileitemlistviewtest
+LINK_LIBRARIES dolphinprivate Qt5::Test)
# KFileItemModelTest
-set(kfileitemmodeltest_SRCS
- kfileitemmodeltest.cpp
- testdir.cpp
- ../dolphindebug.cpp
-)
-
-kconfig_add_kcfg_files(kfileitemmodeltest_SRCS GENERATE_MOC
- ../settings/dolphin_generalsettings.kcfgc
-)
-
-add_executable(kfileitemmodeltest ${kfileitemmodeltest_SRCS})
-add_test(kfileitemmodeltest kfileitemmodeltest)
-ecm_mark_as_test(kfileitemmodeltest)
-target_link_libraries(kfileitemmodeltest dolphinprivate Qt5::Test)
+ecm_add_test(kfileitemmodeltest.cpp testdir.cpp
+TEST_NAME kfileitemmodeltest
+LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test)
# KFileItemModelBenchmark
-set(kfileitemmodelbenchmark_SRCS
- kfileitemmodelbenchmark.cpp
- testdir.cpp
- ../dolphindebug.cpp
-)
-
-kconfig_add_kcfg_files(kfileitemmodelbenchmark_SRCS GENERATE_MOC
- ../settings/dolphin_generalsettings.kcfgc
-)
-
-add_executable(kfileitemmodelbenchmark ${kfileitemmodelbenchmark_SRCS})
-ecm_mark_as_test(kfileitemmodelbenchmark)
-target_link_libraries(kfileitemmodelbenchmark dolphinprivate Qt5::Test)
+ecm_add_test(kfileitemmodelbenchmark.cpp testdir.cpp
+TEST_NAME kfileitemmodelbenchmark
+LINK_LIBRARIES dolphinprivate Qt5::Test)
# KItemListKeyboardSearchManagerTest
-set(kitemlistkeyboardsearchmanagertest_SRCS
- kitemlistkeyboardsearchmanagertest.cpp
-)
-
-add_executable(kitemlistkeyboardsearchmanagertest ${kitemlistkeyboardsearchmanagertest_SRCS})
-add_test(kitemlistkeyboardsearchmanagertest kitemlistkeyboardsearchmanagertest)
-ecm_mark_as_test(kitemlistkeyboardsearchmanagertest)
-target_link_libraries(kitemlistkeyboardsearchmanagertest dolphinprivate Qt5::Test)
+ecm_add_test(kitemlistkeyboardsearchmanagertest.cpp LINK_LIBRARIES dolphinprivate Qt5::Test)
# DolphinSearchBox
if (KF5Baloo_FOUND)
- set(dolphinsearchboxtest_SRCS
- dolphinsearchboxtest.cpp
- ../search/dolphinfacetswidget.cpp
- ../search/dolphinsearchbox.cpp
- )
- kconfig_add_kcfg_files(dolphinsearchboxtest_SRCS
- ../search/dolphin_searchsettings.kcfgc
- )
-
- add_executable(dolphinsearchboxtest ${dolphinsearchboxtest_SRCS})
- add_test(dolphinsearchboxtest dolphinsearchboxtest)
- ecm_mark_as_test(dolphinsearchboxtest)
- target_link_libraries(dolphinsearchboxtest dolphinprivate Qt5::Test)
+ ecm_add_test(dolphinsearchboxtest.cpp
+ TEST_NAME dolphinsearchboxtest
+ LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test)
endif()
# KStandardItemModelTest
-set(kstandarditemmodeltest_SRCS
- kstandarditemmodeltest.cpp
- ../dolphindebug.cpp
-)
-
-add_executable(kstandarditemmodeltest ${kstandarditemmodeltest_SRCS})
-add_test(kstandarditemmodeltest kstandarditemmodeltest)
-ecm_mark_as_test(kstandarditemmodeltest)
-target_link_libraries(kstandarditemmodeltest dolphinprivate Qt5::Test)
+ecm_add_test(kstandarditemmodeltest.cpp
+TEST_NAME kstandarditemmodeltest
+LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test)
# ViewPropertiesTest
-set(viewpropertiestest_SRCS
- viewpropertiestest.cpp
- testdir.cpp
- ../dolphindebug.cpp
-)
-kconfig_add_kcfg_files(viewpropertiestest_SRCS GENERATE_MOC
- ../settings/dolphin_generalsettings.kcfgc
- ../settings/dolphin_directoryviewpropertysettings.kcfgc
-)
+ecm_add_test(viewpropertiestest.cpp testdir.cpp
+TEST_NAME viewpropertiestest
+LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test)
-add_executable(viewpropertiestest ${viewpropertiestest_SRCS})
-add_test(viewpropertiestest viewpropertiestest)
-ecm_mark_as_test(viewpropertiestest)
-target_link_libraries(viewpropertiestest dolphinprivate Qt5::Test)
+# DolphinMainWindowTest
+ecm_add_test(dolphinmainwindowtest.cpp
+TEST_NAME dolphinmainwindowtest
+LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test)
diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp
new file mode 100644
index 000000000..be86c5016
--- /dev/null
+++ b/src/tests/dolphinmainwindowtest.cpp
@@ -0,0 +1,69 @@
+/***************************************************************************
+ * Copyright (C) 2017 by Elvis Angelaccio <[email protected]> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#include "dolphinmainwindow.h"
+#include "dolphintabpage.h"
+#include "dolphintabwidget.h"
+#include "dolphinviewcontainer.h"
+
+#include <QTest>
+
+class DolphinMainWindowTest : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void init();
+ void testClosingTabsWithSearchBoxVisible();
+
+private:
+ QScopedPointer<DolphinMainWindow> m_mainWindow;
+};
+
+void DolphinMainWindowTest::init()
+{
+ m_mainWindow.reset(new DolphinMainWindow());
+}
+
+// See https://bugs.kde.org/show_bug.cgi?id=379135
+void DolphinMainWindowTest::testClosingTabsWithSearchBoxVisible()
+{
+ m_mainWindow->openDirectories({ QUrl::fromLocalFile(QDir::homePath()) }, false);
+ m_mainWindow->show();
+ // Without this call the searchbox doesn't get FocusIn events.
+ QTest::qWaitForWindowExposed(m_mainWindow.data());
+ QVERIFY(m_mainWindow->isVisible());
+
+ auto tabWidget = m_mainWindow->findChild<DolphinTabWidget*>("tabWidget");
+ QVERIFY(tabWidget);
+
+ // Show search box on first tab.
+ tabWidget->currentTabPage()->activeViewContainer()->setSearchModeEnabled(true);
+
+ tabWidget->openNewActivatedTab(QUrl::fromLocalFile(QDir::homePath()));
+ QCOMPARE(tabWidget->count(), 2);
+
+ // Triggers the crash in bug #379135.
+ tabWidget->closeTab();
+ QCOMPARE(tabWidget->count(), 1);
+}
+
+QTEST_MAIN(DolphinMainWindowTest)
+
+#include "dolphinmainwindowtest.moc"
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp
index 59ff63069..b8e089530 100644
--- a/src/tests/kfileitemmodeltest.cpp
+++ b/src/tests/kfileitemmodeltest.cpp
@@ -135,10 +135,11 @@ void KFileItemModelTest::cleanup()
void KFileItemModelTest::testDefaultRoles()
{
const QSet<QByteArray> roles = m_model->roles();
- QCOMPARE(roles.count(), 3);
+ QCOMPARE(roles.count(), 4);
QVERIFY(roles.contains("text"));
QVERIFY(roles.contains("isDir"));
QVERIFY(roles.contains("isLink"));
+ QVERIFY(roles.contains("isHidden"));
}
void KFileItemModelTest::testDefaultSortRole()
diff --git a/src/tests/kitemlistselectionmanagertest.cpp b/src/tests/kitemlistselectionmanagertest.cpp
index 18a79bd3f..48e8dce04 100644
--- a/src/tests/kitemlistselectionmanagertest.cpp
+++ b/src/tests/kitemlistselectionmanagertest.cpp
@@ -335,27 +335,26 @@ Q_DECLARE_METATYPE(QList<int>)
*
* The test is data-driven and takes the following arguments:
*
- * \param initialSelection The selection at the beginning.
- * \param anchor This item will be the anchor item.
- * \param current This item will be the current item.
- * \param expectedSelection Expected selection after anchor and current are set.
- * \param changeType Type of the change that is done then:
- * - NoChange
- * - InsertItems -> data.at(0) provides the KItemRangeList. \sa KItemListSelectionManager::itemsInserted()
- * - RemoveItems -> data.at(0) provides the KItemRangeList. \sa KItemListSelectionManager::itemsRemoved()
- * - MoveItems -> data.at(0) provides the KItemRange containing the original indices,
- * data.at(1) provides the list containing the new indices
- * \sa KItemListSelectionManager::itemsMoved(), KItemModelBase::itemsMoved()
- * - EndAnchoredSelection
- * - SetSelected -> data.at(0) provides the index where the selection process starts,
- * data.at(1) provides the number of indices to be selected,
- * data.at(2) provides the selection mode.
- * \sa KItemListSelectionManager::setSelected()
- * \param data A list of QVariants which will be cast to the arguments needed for the chosen ChangeType (see above).
- * \param finalSelection The expected final selection.
+ * param initialSelection The selection at the beginning.
+ * param anchor This item will be the anchor item.
+ * param current This item will be the current item.
+ * param expectedSelection Expected selection after anchor and current are set.
+ * param changeType Type of the change that is done then:
+ * - NoChange
+ * - InsertItems -> data.at(0) provides the KItemRangeList. \sa KItemListSelectionManager::itemsInserted()
+ * - RemoveItems -> data.at(0) provides the KItemRangeList. \sa KItemListSelectionManager::itemsRemoved()
+ * - MoveItems -> data.at(0) provides the KItemRange containing the original indices,
+ * data.at(1) provides the list containing the new indices
+ * \sa KItemListSelectionManager::itemsMoved(), KItemModelBase::itemsMoved()
+ * - EndAnchoredSelection
+ * - SetSelected -> data.at(0) provides the index where the selection process starts,
+ * data.at(1) provides the number of indices to be selected,
+ * data.at(2) provides the selection mode.
+ * \sa KItemListSelectionManager::setSelected()
+ * param data A list of QVariants which will be cast to the arguments needed for the chosen ChangeType (see above).
+ * param finalSelection The expected final selection.
*
*/
-
void KItemListSelectionManagerTest::testChangeSelection_data()
{
QTest::addColumn<KItemSet>("initialSelection");