Commit 8ea7ec79 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(tests): add AssistantViewTest

parent 651d3103
......@@ -213,6 +213,8 @@ set(HEADERS
)
set(TESTS
src/tests/assistant-view/AssistantViewTest.cpp
src/tests/assistant-view/AssistantViewTest.hpp
src/tests/main-view/MainViewTest.cpp
src/tests/main-view/MainViewTest.hpp
src/tests/self-test/SelfTest.cpp
......
......@@ -20,6 +20,9 @@
* Author: Ronan Abhamon
*/
#ifndef TEST_UTILS_H_
#define TEST_UTILS_H_
#include <QQuickItem>
#include <QQuickWindow>
......@@ -42,3 +45,5 @@ namespace TestUtils {
QQuickItem *getVirtualWindowContent (const QQuickWindow *window);
}
#endif // ifndef TEST_UTILS_H_
/*
* AssistantViewTest.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* 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.
*
* Created on: July 20, 2017
* Author: Ronan Abhamon
*/
#include <QQmlProperty>
#include <QQuickItem>
#include <QSignalSpy>
#include <QTest>
#include "../../app/App.hpp"
#include "AssistantViewTest.hpp"
// =============================================================================
void AssistantViewTest::showAssistantView () {
QQuickWindow *mainWindow = App::getInstance()->getMainWindow();
// Ensure home view is selected.
QQuickItem *contentLoader = mainWindow->findChild<QQuickItem *>("__contentLoader");
QVERIFY(contentLoader);
QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(110, 100));
// Show assistant view.
QSignalSpy spyLoaderReady(contentLoader, SIGNAL(loaded()));
QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(705, 485));
QVERIFY(spyLoaderReady.count() == 1);
QCOMPARE(
QQmlProperty::read(contentLoader, "source").toString(),
QStringLiteral("qrc:/ui/views/App/Main/Assistant.qml")
);
}
/*
* AssistantViewTest.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* 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.
*
* Created on: July 20, 2017
* Author: Ronan Abhamon
*/
#ifndef ASSISTANT_VIEW_TEST_H_
#define ASSISTANT_VIEW_TEST_H_
#include <QObject>
// =============================================================================
class AssistantViewTest : public QObject {
Q_OBJECT;
public:
AssistantViewTest () = default;
~AssistantViewTest () = default;
private slots:
void showAssistantView ();
};
#endif // ifndef ASSISTANT_VIEW_TEST_H_
......@@ -88,13 +88,15 @@ void MainViewTest::testMainMenuEntries_data () {
}
void MainViewTest::testMainMenuEntries () {
QQuickItem *contentLoader = App::getInstance()->getMainWindow()->findChild<QQuickItem *>("__contentLoader");
QQuickWindow *mainWindow = App::getInstance()->getMainWindow();
QQuickItem *contentLoader = mainWindow->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));
QTest::mouseClick(mainWindow, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(110, y));
QVERIFY(spyLoaderReady.count() == 1);
QFETCH(QString, source);
......
......@@ -20,6 +20,9 @@
* Author: Ronan Abhamon
*/
#ifndef MAIN_VIEW_TEST_H_
#define MAIN_VIEW_TEST_H_
#include <QObject>
// =============================================================================
......@@ -39,3 +42,5 @@ private slots:
void testMainMenuEntries_data ();
void testMainMenuEntries ();
};
#endif // ifndef MAIN_VIEW_TEST_H_
......@@ -26,6 +26,7 @@
#include "../app/AppController.hpp"
#include "../utils/Utils.hpp"
#include "assistant-view/AssistantViewTest.hpp"
#include "main-view/MainViewTest.hpp"
#include "self-test/SelfTest.hpp"
......@@ -33,6 +34,7 @@
static QHash<QString, QObject *> initializeTests () {
QHash<QString, QObject *> hash;
hash["assistant-view"] = new AssistantViewTest();
hash["main-view"] = new MainViewTest();
return hash;
}
......
......@@ -20,6 +20,9 @@
* Author: Ronan Abhamon
*/
#ifndef SELF_TEST_H_
#define SELF_TEST_H_
#include <QObject>
// =============================================================================
......@@ -33,3 +36,5 @@ public:
private slots:
void checkAppStartup ();
};
#endif // ifndef SELF_TEST_H_
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