]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/tests/kitemlistcontrollertest.cpp
Merge branch 'Applications/18.12'
[dolphin.git] / src / tests / kitemlistcontrollertest.cpp
index e34731fa4b59c1f058bc8ec6bd3255fc4b142f07..2fd71483e9465a23ba4865cfe440d359556f36d5 100644 (file)
@@ -37,6 +37,7 @@
  */
 class KItemListControllerTestStyle : public QProxyStyle
 {
+    Q_OBJECT
 public:
     KItemListControllerTestStyle(QStyle* style) :
         QProxyStyle(style),
@@ -57,7 +58,7 @@ public:
     int styleHint(StyleHint hint,
                   const QStyleOption* option = nullptr,
                   const QWidget* widget = nullptr,
-                  QStyleHintReturn* returnData = nullptr) const Q_DECL_OVERRIDE
+                  QStyleHintReturn* returnData = nullptr) const override
     {
         switch (hint) {
         case QStyle::SH_ItemView_ActivateItemOnSingleClick:
@@ -71,10 +72,10 @@ private:
     bool m_activateItemOnSingleClick;
 };
 
-Q_DECLARE_METATYPE(KFileItemListView::ItemLayout);
-Q_DECLARE_METATYPE(Qt::Orientation);
-Q_DECLARE_METATYPE(KItemListController::SelectionBehavior);
-Q_DECLARE_METATYPE(KItemSet);
+Q_DECLARE_METATYPE(KFileItemListView::ItemLayout)
+Q_DECLARE_METATYPE(Qt::Orientation)
+Q_DECLARE_METATYPE(KItemListController::SelectionBehavior)
+Q_DECLARE_METATYPE(KItemSet)
 
 class KItemListControllerTest : public QObject
 {
@@ -138,20 +139,20 @@ void KItemListControllerTest::initTestCase()
 
     m_testDir->createFiles(files);
     m_model->loadDirectory(m_testDir->url());
-    QSignalSpy spyDirectoryLoadingCompleted(m_model, SIGNAL(directoryLoadingCompleted()));
+    QSignalSpy spyDirectoryLoadingCompleted(m_model, &KFileItemModel::directoryLoadingCompleted);
     QVERIFY(spyDirectoryLoadingCompleted.wait());
 
     m_container->show();
-    QTest::qWaitForWindowExposed(m_container);
+    QVERIFY(QTest::qWaitForWindowExposed(m_container));
 }
 
 void KItemListControllerTest::cleanupTestCase()
 {
     delete m_container;
-    m_container = 0;
+    m_container = nullptr;
 
     delete m_testDir;
-    m_testDir = 0;
+    m_testDir = nullptr;
 }
 
 /** Before each test, the current item, selection, and item size are reset to the defaults. */
@@ -196,7 +197,7 @@ struct KeyPress {
  */
 struct ViewState {
 
-    ViewState(int current, const KItemSet selection, bool activated = false) :
+    ViewState(int current, const KItemSet &selection, bool activated = false) :
         m_current(current),
         m_selection(selection),
         m_activated(activated)
@@ -209,7 +210,7 @@ struct ViewState {
 
 // We have to define a typedef for the pair in order to make the test compile.
 typedef QPair<KeyPress, ViewState> keyPressViewStatePair;
-Q_DECLARE_METATYPE(QList<keyPressViewStatePair>);
+Q_DECLARE_METATYPE(QList<keyPressViewStatePair>)
 
 /**
  * This function provides the data for the actual test function
@@ -506,8 +507,8 @@ void KItemListControllerTest::testKeyboardNavigation()
     adjustGeometryForColumnCount(columnCount);
     QCOMPARE(m_view->m_layouter->m_columnCount, columnCount);
 
-    QSignalSpy spySingleItemActivated(m_controller, SIGNAL(itemActivated(int)));
-    QSignalSpy spyMultipleItemsActivated(m_controller, SIGNAL(itemsActivated(KItemSet)));
+    QSignalSpy spySingleItemActivated(m_controller, &KItemListController::itemActivated);
+    QSignalSpy spyMultipleItemsActivated(m_controller, &KItemListController::itemsActivated);
 
     while (!testList.isEmpty()) {
         const QPair<KeyPress, ViewState> test = testList.takeFirst();
@@ -544,6 +545,7 @@ void KItemListControllerTest::testKeyboardNavigation()
                 }
                 // No items are selected. Therefore, the current item should be activated.
                 // This is handled by falling through to the NoSelection/SingleSelection case.
+                Q_FALLTHROUGH();
             case KItemListController::NoSelection:
             case KItemListController::SingleSelection:
                 // In NoSelection and SingleSelection mode, the current item should be activated.
@@ -583,7 +585,7 @@ void KItemListControllerTest::testMouseClickActivation()
     mouseReleaseEvent.setButton(Qt::LeftButton);
     mouseReleaseEvent.setButtons(Qt::NoButton);
 
-    QSignalSpy spyItemActivated(m_controller, SIGNAL(itemActivated(int)));
+    QSignalSpy spyItemActivated(m_controller, &KItemListController::itemActivated);
 
     // Default setting: single click activation.
     m_testStyle->setActivateItemOnSingleClick(true);