Commit 29b90408 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(tests/main-view): add a `testMainMenuEntries` method

parent 62e9a393
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
* Author: Ronan Abhamon * Author: Ronan Abhamon
*/ */
#include <QQmlProperty>
#include <QSignalSpy>
#include <QTest> #include <QTest>
#include "../../app/App.hpp" #include "../../app/App.hpp"
...@@ -42,6 +44,8 @@ void MainViewTest::showAboutPopup () { ...@@ -42,6 +44,8 @@ void MainViewTest::showAboutPopup () {
QVERIFY(!TestUtils::getVirtualWindowContent(mainWindow)); QVERIFY(!TestUtils::getVirtualWindowContent(mainWindow));
} }
// -----------------------------------------------------------------------------
void MainViewTest::showManageAccountsPopup () { void MainViewTest::showManageAccountsPopup () {
QQuickWindow *mainWindow = App::getInstance()->getMainWindow(); QQuickWindow *mainWindow = App::getInstance()->getMainWindow();
...@@ -55,6 +59,8 @@ void MainViewTest::showManageAccountsPopup () { ...@@ -55,6 +59,8 @@ void MainViewTest::showManageAccountsPopup () {
QVERIFY(!TestUtils::getVirtualWindowContent(mainWindow)); QVERIFY(!TestUtils::getVirtualWindowContent(mainWindow));
} }
// -----------------------------------------------------------------------------
void MainViewTest::showSettingsWindow () { void MainViewTest::showSettingsWindow () {
App *app = App::getInstance(); App *app = App::getInstance();
...@@ -68,3 +74,29 @@ void MainViewTest::showSettingsWindow () { ...@@ -68,3 +74,29 @@ void MainViewTest::showSettingsWindow () {
TestUtils::executeKeySequence(settingsWindow, QKeySequence::Close); TestUtils::executeKeySequence(settingsWindow, QKeySequence::Close);
QVERIFY(!settingsWindow->isVisible()); QVERIFY(!settingsWindow->isVisible());
} }
// -----------------------------------------------------------------------------
void MainViewTest::testMainMenuEntries_data () {
QTest::addColumn<int>("y");
QTest::addColumn<QString>("source");
QTest::newRow("home view 1") << 100 << "qrc:/ui/views/App/Main/Home.qml";
QTest::newRow("contacts view 1") << 150 << "qrc:/ui/views/App/Main/Contacts.qml";
QTest::newRow("home view 2") << 100 << "qrc:/ui/views/App/Main/Home.qml";
QTest::newRow("contacts view 2") << 150 << "qrc:/ui/views/App/Main/Contacts.qml";
}
void MainViewTest::testMainMenuEntries () {
QQuickItem *contentLoader = App::getInstance()->getMainWindow()->findChild<QQuickItem *>("__contentLoader");
QVERIFY(contentLoader);
QSignalSpy spyLoaderReady(contentLoader, SIGNAL(loaded()));
QFETCH(int, y);
QTest::mouseClick(App::getInstance()->getMainWindow(), Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(110, y));
QVERIFY(spyLoaderReady.count() == 1);
QFETCH(QString, source);
QCOMPARE(QQmlProperty::read(contentLoader, "source").toString(), source);
}
...@@ -35,4 +35,7 @@ private slots: ...@@ -35,4 +35,7 @@ private slots:
void showAboutPopup (); void showAboutPopup ();
void showManageAccountsPopup (); void showManageAccountsPopup ();
void showSettingsWindow (); void showSettingsWindow ();
void testMainMenuEntries_data ();
void testMainMenuEntries ();
}; };
...@@ -231,6 +231,8 @@ ApplicationWindow { ...@@ -231,6 +231,8 @@ ApplicationWindow {
Loader { Loader {
id: contentLoader id: contentLoader
objectName: '__contentLoader'
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment