Skip to content

Commit ec967dd

Browse files
committed
Port more tests
1 parent 915ae0b commit ec967dd

File tree

13 files changed

+285
-126
lines changed

13 files changed

+285
-126
lines changed

autotests/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ project(autotests)
22
add_subdirectory(addbookmarkdialog)
33
add_subdirectory(autosaver)
44
add_subdirectory(bookmarknode)
5-
add_subdirectory(downloadmanager)
5+
add_subdirectory(downloadmanager)
6+
add_subdirectory(historyfiltermodel)
7+
add_subdirectory(historymanager)

autotests/addbookmarkdialog/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ INCLUDE_DIRECTORIES(
1616
)
1717
add_definitions(-DNO_BROWSERAPPLICATION)
1818
add_definitions(-DFOR_AUTOTEST)
19+
add_definitions(-DNO_HISTORYDIALOG)
1920
set(SRCS
2021
tst_addbookmarkdialog.cpp
2122
../../src/bookmarks/addbookmarkdialog.cpp

autotests/bookmarknode/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ QT5_WRAP_CPP(MOCS
1919
tst_bookmarknode.h
2020
)
2121

22-
add_executable(test-bookmarknode ${SRCS} ${UIS} ${MOCS})
22+
add_executable(test-bookmarknode ${SRCS} ${MOCS})
2323
qt5_use_modules(test-bookmarknode Core)
2424
qt5_use_modules(test-bookmarknode Test)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
project(test-historyfiltermodel)
2+
3+
find_package(Qt5Core REQUIRED)
4+
find_package(Qt5Test REQUIRED)
5+
find_package(Qt5Gui REQUIRED)
6+
find_package(Qt5Widgets REQUIRED)
7+
find_package(Qt5WebEngine REQUIRED)
8+
find_package(Qt5WebEngineWidgets REQUIRED)
9+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
10+
set(CMAKE_AUTOUIC ON)
11+
set(CMAKE_AUTOUIC_SEARCH_PATHS
12+
${CMAKE_CURRENT_SOURCE_DIR}/..
13+
${CMAKE_CURRENT_SOURCE_DIR}/../../src
14+
${CMAKE_CURRENT_SOURCE_DIR}/../../src/history
15+
${CMAKE_CURRENT_SOURCE_DIR}/../../src/utils
16+
)
17+
INCLUDE_DIRECTORIES(
18+
${CMAKE_CURRENT_SOURCE_DIR}/..
19+
${CMAKE_CURRENT_SOURCE_DIR}/../../src
20+
${CMAKE_CURRENT_SOURCE_DIR}/../../src/history
21+
${CMAKE_CURRENT_SOURCE_DIR}/../../src/utils
22+
${RUNTIME_OUTPUT_DIRECTORY}
23+
)
24+
add_definitions(-DNO_BROWSERAPPLICATION)
25+
add_definitions(-DFOR_AUTOTEST)
26+
set(SRCS
27+
tst_historyfiltermodel.cpp
28+
../../src/autosaver.cpp
29+
../../src/clearbutton.cpp
30+
../../src/searchbutton.cpp
31+
../../src/searchlineedit.cpp
32+
../../src/history/history.cpp
33+
../../src/history/historymanager.cpp
34+
../../src/utils/edittreeview.cpp
35+
../../src/utils/lineedit.cpp
36+
../../src/utils/treesortfilterproxymodel.cpp
37+
)
38+
39+
QT5_WRAP_CPP(MOCS
40+
tst_historyfiltermodel.h
41+
../../src/autosaver.h
42+
../../src/clearbutton.h
43+
../../src/searchbutton.h
44+
../../src/searchlineedit.h
45+
../../src/history/history.h
46+
../../src/history/historymanager.h
47+
../../src/utils/edittreeview.h
48+
../../src/utils/lineedit.h
49+
../../src/utils/lineedit_p.h
50+
../../src/utils/treesortfilterproxymodel.h
51+
)
52+
53+
add_executable(test-historyfiltermodel ${SRCS} ${UIS} ${MOCS})
54+
qt5_use_modules(test-historyfiltermodel Core)
55+
qt5_use_modules(test-historyfiltermodel Test)
56+
qt5_use_modules(test-historyfiltermodel Widgets)
57+
qt5_use_modules(test-historyfiltermodel Gui)
58+
qt5_use_modules(test-historyfiltermodel WebEngine)
59+
qt5_use_modules(test-historyfiltermodel WebEngineWidgets)

autotests/historyfiltermodel/tst_historyfiltermodel.cpp

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,52 +20,8 @@
2020
#include <QtTest/QtTest>
2121
#include <history.h>
2222
#include <historymanager.h>
23-
24-
class tst_HistoryFilterModel : public QObject
25-
{
26-
Q_OBJECT
27-
28-
public slots:
29-
void initTestCase();
30-
void cleanupTestCase();
31-
void init();
32-
void cleanup();
33-
34-
private slots:
35-
void historyfiltermodel_data();
36-
void historyfiltermodel();
37-
38-
void historyContains_data();
39-
void historyContains();
40-
41-
void setSourceModel();
42-
43-
void historyLocation_data();
44-
void historyLocation();
45-
46-
void addRow_data();
47-
void addRow();
48-
49-
void removeRows_data();
50-
void removeRows();
51-
};
52-
53-
// Subclass that exposes the protected functions.
54-
class SubHistoryFilterModel : public HistoryFilterModel
55-
{
56-
public:
57-
SubHistoryFilterModel(QObject *parent = 0)
58-
: HistoryFilterModel(0, parent)
59-
{
60-
history = new HistoryManager(this);
61-
historyModel = new HistoryModel(history, this);
62-
setSourceModel(historyModel);
63-
history->setDaysToExpire(-1);
64-
}
65-
66-
HistoryModel *historyModel;
67-
HistoryManager *history;
68-
};
23+
#include <ui_history.h>
24+
#include "tst_historyfiltermodel.h"
6925

7026
// This will be called before the first test function is executed.
7127
// It is only called once.
@@ -331,5 +287,3 @@ void tst_HistoryFilterModel::removeRows()
331287
}
332288

333289
QTEST_MAIN(tst_HistoryFilterModel)
334-
#include "tst_historyfiltermodel.moc"
335-
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright 2020 Aaron Dewes <[email protected]>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
17+
* Boston, MA 02110-1301 USA
18+
*/
19+
20+
#include <history.h>
21+
#include <historymanager.h>
22+
23+
class tst_HistoryFilterModel : public QObject
24+
{
25+
Q_OBJECT
26+
27+
public slots:
28+
void initTestCase();
29+
void cleanupTestCase();
30+
void init();
31+
void cleanup();
32+
33+
private slots:
34+
void historyfiltermodel_data();
35+
void historyfiltermodel();
36+
37+
void historyContains_data();
38+
void historyContains();
39+
40+
void setSourceModel();
41+
42+
void historyLocation_data();
43+
void historyLocation();
44+
45+
void addRow_data();
46+
void addRow();
47+
48+
void removeRows_data();
49+
void removeRows();
50+
};
51+
52+
// Subclass that exposes the protected functions.
53+
class SubHistoryFilterModel : public HistoryFilterModel
54+
{
55+
public:
56+
SubHistoryFilterModel(QObject *parent = 0)
57+
: HistoryFilterModel(0, parent)
58+
{
59+
history = new HistoryManager(this);
60+
historyModel = new HistoryModel(history, this);
61+
setSourceModel(historyModel);
62+
history->setDaysToExpire(-1);
63+
}
64+
65+
HistoryModel *historyModel;
66+
HistoryManager *history;
67+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
project(test-historymanager)
2+
3+
find_package(Qt5Core REQUIRED)
4+
find_package(Qt5Test REQUIRED)
5+
find_package(Qt5Gui REQUIRED)
6+
find_package(Qt5Widgets REQUIRED)
7+
find_package(Qt5WebEngine REQUIRED)
8+
find_package(Qt5WebEngineWidgets REQUIRED)
9+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
10+
set(CMAKE_AUTOUIC ON)
11+
set(CMAKE_AUTOMOC ON)
12+
set(CMAKE_AUTOUIC_SEARCH_PATHS
13+
${CMAKE_CURRENT_SOURCE_DIR}/..
14+
${CMAKE_CURRENT_SOURCE_DIR}/../../src
15+
${CMAKE_CURRENT_SOURCE_DIR}/../../src/history
16+
${CMAKE_CURRENT_SOURCE_DIR}/../../src/utils
17+
)
18+
INCLUDE_DIRECTORIES(
19+
${CMAKE_CURRENT_SOURCE_DIR}/..
20+
${CMAKE_CURRENT_SOURCE_DIR}/../modeltest
21+
${CMAKE_CURRENT_SOURCE_DIR}/../../src
22+
${CMAKE_CURRENT_SOURCE_DIR}/../../src/history
23+
${CMAKE_CURRENT_SOURCE_DIR}/../../src/utils
24+
${RUNTIME_OUTPUT_DIRECTORY}
25+
)
26+
add_definitions(-DNO_BROWSERAPPLICATION)
27+
add_definitions(-DFOR_AUTOTEST)
28+
set(SRCS
29+
tst_historymanager.cpp
30+
../modeltest/modeltest.cpp
31+
../../src/autosaver.cpp
32+
../../src/clearbutton.cpp
33+
../../src/searchbutton.cpp
34+
../../src/searchlineedit.cpp
35+
../../src/history/history.cpp
36+
../../src/history/historycompleter.cpp
37+
../../src/history/historymanager.cpp
38+
../../src/utils/edittreeview.cpp
39+
../../src/utils/lineedit.cpp
40+
../../src/utils/treesortfilterproxymodel.cpp
41+
)
42+
43+
add_executable(test-historymanager ${SRCS} ${UIS} ${MOCS})
44+
qt5_use_modules(test-historymanager Core)
45+
qt5_use_modules(test-historymanager Test)
46+
qt5_use_modules(test-historymanager Widgets)
47+
qt5_use_modules(test-historymanager Gui)
48+
qt5_use_modules(test-historymanager WebEngine)
49+
qt5_use_modules(test-historymanager WebEngineWidgets)

autotests/historymanager/tst_historymanager.cpp

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -18,73 +18,15 @@
1818
*/
1919

2020
#include <QtTest/QtTest>
21-
#include "qtest_endorphin.h"
2221

2322
#include <historymanager.h>
24-
#include <history.h>
23+
#include "history.h"
2524
#include <historycompleter.h>
2625
#include <modeltest.h>
2726

2827
#include <QWebEngineSettings>
2928

30-
class tst_HistoryManager : public QObject
31-
{
32-
Q_OBJECT
33-
34-
public slots:
35-
void initTestCase();
36-
void cleanupTestCase();
37-
void init();
38-
void cleanup();
39-
40-
private slots:
41-
void history_data();
42-
void history();
43-
void addHistoryEntry_data();
44-
void addHistoryEntry();
45-
void addHistoryEntry_private();
46-
void addHistoryEntry_url();
47-
void updateHistoryEntry_data();
48-
void updateHistoryEntry();
49-
void daysToExpire_data();
50-
void daysToExpire();
51-
void clear_data();
52-
void clear();
53-
void setHistory_data();
54-
void setHistory();
55-
void saveload_data();
56-
void saveload();
57-
58-
// TODO move to their own tests
59-
void big();
60-
61-
void historyDialog_data();
62-
void historyDialog();
63-
64-
private:
65-
QList<HistoryEntry> bigHistory;
66-
};
67-
68-
// Subclass that exposes the protected functions.
69-
class SubHistory : public HistoryManager
70-
{
71-
public:
72-
SubHistory() : HistoryManager()
73-
{
74-
QWidget w;
75-
setParent(&w);
76-
if (QWebHistoryInterface::defaultInterface() == this)
77-
QWebHistoryInterface::setDefaultInterface(0);
78-
setParent(0);
79-
}
80-
81-
~SubHistory() {
82-
setDaysToExpire(30);
83-
}
84-
85-
void prependHistoryEntry(const HistoryEntry &item)
86-
{ HistoryManager::prependHistoryEntry(item); }
87-
};
29+
#include "tst_historymanager.h"
8830

8931
// This will be called before the first test function is executed.
9032
// It is only called once.
@@ -209,17 +151,6 @@ void tst_HistoryManager::addHistoryEntry()
209151
QCOMPARE(history.history(), expected);
210152
}
211153

212-
void tst_HistoryManager::addHistoryEntry_private()
213-
{
214-
SubHistory history;
215-
history.setHistory(HistoryList());
216-
QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
217-
globalSettings->setAttribute(QWebEngineSettings::PrivateBrowsingEnabled, true);
218-
history.prependHistoryEntry(HistoryEntry());
219-
globalSettings->setAttribute(QWebEngineSettings::PrivateBrowsingEnabled, false);
220-
QVERIFY(history.history().isEmpty());
221-
}
222-
223154
void tst_HistoryManager::addHistoryEntry_url()
224155
{
225156
SubHistory history;
@@ -428,8 +359,6 @@ void tst_HistoryManager::big()
428359

429360
QCOMPARE(history.history().count(), bigHistory.count());
430361

431-
HistoryMenu menu;
432-
433362
HistoryModel model(&history);
434363
ModelTest test(&model);
435364
QCOMPARE(model.rowCount(), bigHistory.count());
@@ -547,5 +476,3 @@ void tst_HistoryManager::historyDialog()
547476
}
548477

549478
QTEST_MAIN(tst_HistoryManager)
550-
#include "tst_historymanager.moc"
551-

0 commit comments

Comments
 (0)