on xenial help sign in
Added ActiveCallHint tests
commit91f62af0aee3db69b211e1f376e3d2867d1df6ba authorNick Dedekind <nicholas.dedekind@gmail.com> dateWed 30 Apr 2014, 19:06 (12 years ago) parentcad0962
20 files changed+805−37
qml/Panel/Panel.qml+11−10 qml/Shell.qml+3−2 tests/mocks/Ubuntu/CMakeLists.txt+2 tests/mocks/Ubuntu/Telephony/CMakeLists.txt+22 tests/mocks/Ubuntu/Telephony/ContactWatcherData.cpp+43 tests/mocks/Ubuntu/Telephony/ContactWatcherData.h+46 tests/mocks/Ubuntu/Telephony/MockCallEntry.cpp+67 tests/mocks/Ubuntu/Telephony/MockCallEntry.h+57 tests/mocks/Ubuntu/Telephony/MockCallManager.cpp+65 tests/mocks/Ubuntu/Telephony/MockCallManager.h+55 tests/mocks/Ubuntu/Telephony/MockContactWatcher.cpp+50 tests/mocks/Ubuntu/Telephony/MockContactWatcher.h+49 tests/mocks/Ubuntu/Telephony/MockTelepathyHelper.cpp+35 tests/mocks/Ubuntu/Telephony/MockTelepathyHelper.h+36 tests/mocks/Ubuntu/Telephony/plugin.cpp+52 tests/mocks/Ubuntu/Telephony/plugin.h+37 tests/mocks/Ubuntu/Telephony/qmldir+2 tests/qmltests/CMakeLists.txt+1 tests/qmltests/Panel/tst_ActiveCallHint.qml+131 tests/qmltests/Panel/tst_Panel.qml+41−25
qml/Panel/Panel.qml+11−10
@@ -20,12 +20,10 @@ import "../Components"
2020
2121Item {
2222 id: root
23− readonly property real panelHeight: callHint.active ? callHint.height + lowerPanelHeight : lowerPanelHeight
24− property real indicatorsMenuWidth: (width > units.gu(60)) ? units.gu(40) : width
23+ readonly property real panelHeight: callHint.active ? callHint.height + indicatorArea.indicatorHeight : indicatorArea.indicatorHeight
2524 property alias indicators: indicatorsMenu
2625 property bool fullscreenMode: false
2726 property bool searchVisible: true
28− readonly property real lowerPanelHeight: indicatorsMenu.panelHeight + leftSeparatorLine.height
2927
3028 signal searchClicked
3129
@@ -67,13 +65,16 @@ Item {
6765 }
6866
6967 Item {
70− id: lowerPanel
68+ id: indicatorArea
69+ objectName: "indicatorArea"
70+
71+ readonly property real indicatorHeight: indicatorsMenu.panelHeight + leftSeparatorLine.height
7172
7273 anchors {
7374 left: parent.left
7475 right: parent.right
7576 }
76− height: root.height - lowerPanel.y
77+ height: root.height - indicatorArea.y
7778 z: 0
7879
7980 PanelBackground {
@@ -123,7 +124,7 @@ Item {
123124 right: parent.right
124125 }
125126
126− width: root.indicatorsMenuWidth
127+ width: (root.width > units.gu(60)) ? units.gu(40) : root.width
127128 shown: false
128129 panelHeight: units.gu(3)
129130 openedHeight: parent.height
@@ -173,8 +174,8 @@ Item {
173174 }
174175
175176 anchors {
176− top: panelBackground.top
177− left: panelBackground.left
177+ top: parent.top
178+ left: parent.left
178179 }
179180 height: panelBackground.height
180181
@@ -186,12 +187,12 @@ Item {
186187 State {
187188 name: "in" //fully opaque and visible at top edge of screen
188189 when: !fullscreenMode
189− PropertyChanges { target: lowerPanel; y: callHint.y + callHint.height }
190+ PropertyChanges { target: indicatorArea; y: callHint.y + callHint.height }
190191 },
191192 State {
192193 name: "out" //pushed off screen
193194 when: fullscreenMode
194− PropertyChanges { target: lowerPanel; y: callHint.y + callHint.height - lowerPanelHeight }
195+ PropertyChanges { target: indicatorArea; y: callHint.y + callHint.height - indicatorHeight }
195196 }
196197 ]
197198}
qml/Shell.qml+3−2
@@ -110,7 +110,7 @@ FocusScope {
110110 anchors.rightMargin: -parent.anchors.rightMargin
111111
112112 // Whether the underlay is fully covered by opaque UI elements.
113− property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
113+ property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicators.width
114114
115115 // Whether the user should see the topmost application surface (if there's one at all).
116116 readonly property bool applicationSurfaceShouldBeSeen: stages.shown && !stages.painting && !stages.overlayMode
@@ -471,11 +471,12 @@ FocusScope {
471471 Panel {
472472 id: panel
473473 anchors.fill: parent //because this draws indicator menus
474− indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
475474 indicators {
476475 hides: [launcher]
477476 available: edgeDemo.panelEnabled
478477 contentEnabled: edgeDemo.panelContentEnabled
478+ width: parent.width > units.gu(60) ? units.gu(40) : parent.width
479+ panelHeight: units.gu(3)
479480 }
480481 property string focusedAppId: ApplicationManager.focusedApplicationId
481482 property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
tests/mocks/Ubuntu/CMakeLists.txt+2
@@ -1,2 +1,4 @@
11add_subdirectory(DownloadDaemonListener)
2+add_subdirectory(Telephony)
23add_subdirectory(Thumbnailer)
4+
tests/mocks/Ubuntu/Telephony/CMakeLists.txtnew file+22
@@ -0,0 +1,22 @@
1+set(FakeUbuntuTelephonyQml_SOURCES
2+ plugin.cpp
3+ ContactWatcherData.cpp
4+ MockCallEntry.cpp
5+ MockCallManager.cpp
6+ MockContactWatcher.cpp
7+ MockTelepathyHelper.cpp
8+)
9+
10+add_library(FakeUbuntuTelephonyQml MODULE ${FakeUbuntuTelephonyQml_SOURCES})
11+
12+qt5_use_modules(FakeUbuntuTelephonyQml Core Quick)
13+
14+# copy files into build directory for shadow builds
15+add_custom_target(UbuntuTelephonyQmlDirFile ALL
16+ COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/qmldir" ${CMAKE_CURRENT_BINARY_DIR}
17+ DEPENDS qmldir
18+)
19+
20+install(TARGETS FakeUbuntuTelephonyQml
21+ DESTINATION ${SHELL_INSTALL_QML}/mocks/Ubuntu/Telephony
22+ )
tests/mocks/Ubuntu/Telephony/ContactWatcherData.cppnew file+43
@@ -0,0 +1,43 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
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; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com
17+ */
18+
19+#include "ContactWatcherData.h"
20+
21+ContactWatcherData::ContactWatcherData(QObject *parent)
22+ : QObject(parent)
23+{
24+}
25+
26+ContactWatcherData *ContactWatcherData::instance()
27+{
28+ static ContactWatcherData* contactData = new ContactWatcherData();
29+ return contactData;
30+}
31+
32+QVariant ContactWatcherData::contactData() const
33+{
34+ return m_data;
35+}
36+
37+void ContactWatcherData::setContactData(const QVariant& contactData)
38+{
39+ if(m_data != contactData){
40+ m_data = contactData;
41+ Q_EMIT contactDataChanged();
42+ }
43+}
tests/mocks/Ubuntu/Telephony/ContactWatcherData.hnew file+46
@@ -0,0 +1,46 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
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; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com
17+ */
18+
19+#ifndef CONTACTWATCHERDATA_H
20+#define CONTACTWATCHERDATA_H
21+
22+#include <QObject>
23+#include <QVariant>
24+
25+class ContactWatcherData : public QObject
26+{
27+ Q_OBJECT
28+ Q_DISABLE_COPY(ContactWatcherData)
29+ Q_PROPERTY(QVariant contactData READ contactData WRITE setContactData NOTIFY contactDataChanged)
30+
31+public:
32+ ContactWatcherData(QObject *parent = 0);
33+
34+ static ContactWatcherData *instance();
35+
36+ QVariant contactData() const;
37+ void setContactData(const QVariant& contactData);
38+
39+Q_SIGNALS:
40+ void contactDataChanged();
41+
42+private:
43+ QVariant m_data;
44+};
45+
46+#endif // CONTACTWATCHERDATA_H
tests/mocks/Ubuntu/Telephony/MockCallEntry.cppnew file+67
@@ -0,0 +1,67 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
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; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com
17+ */
18+
19+#include "MockCallEntry.h"
20+
21+MockCallEntry::MockCallEntry(QObject *parent)
22+ : QObject(parent)
23+ , m_conference(false)
24+ , m_elapsed(0)
25+{
26+ startTimer(1000);
27+}
28+
29+QString MockCallEntry::phoneNumber() const
30+{
31+ return m_phoneNumber;
32+}
33+
34+void MockCallEntry::setPhoneNumber(const QString& phoneNumber)
35+{
36+ if(m_phoneNumber != phoneNumber){
37+ m_phoneNumber = phoneNumber;
38+ Q_EMIT phoneNumberChanged();
39+ }
40+}
41+
42+bool MockCallEntry::isConference() const
43+{
44+ return m_conference;
45+}
46+
47+void MockCallEntry::setIsConference(bool isConference)
48+{
49+ if(m_conference != isConference){
50+ m_conference = isConference;
51+ Q_EMIT isConferenceChanged();
52+ }
53+}
54+
55+int MockCallEntry::elapsedTime() const
56+{
57+ return m_elapsed;
58+}
59+
60+void MockCallEntry::timerEvent(QTimerEvent * event)
61+{
62+ Q_UNUSED(event);
63+
64+ m_elapsed++;
65+ Q_EMIT elapsedTimeChanged();
66+}
67+
tests/mocks/Ubuntu/Telephony/MockCallEntry.hnew file+57
@@ -0,0 +1,57 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
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; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com
17+ */
18+
19+#ifndef MOCKCALLENTRY_H
20+#define MOCKCALLENTRY_H
21+
22+#include <QObject>
23+
24+class MockCallEntry : public QObject
25+{
26+ Q_OBJECT
27+ Q_DISABLE_COPY(MockCallEntry)
28+
29+ Q_PROPERTY(QString phoneNumber READ phoneNumber WRITE setPhoneNumber NOTIFY phoneNumberChanged)
30+ Q_PROPERTY(bool isConference READ isConference WRITE setIsConference NOTIFY isConferenceChanged)
31+ Q_PROPERTY(int elapsedTime READ elapsedTime NOTIFY elapsedTimeChanged)
32+
33+public:
34+ MockCallEntry(QObject *parent = 0);
35+
36+ QString phoneNumber() const;
37+ bool isConference() const;
38+ int elapsedTime() const;
39+
40+ void setPhoneNumber(const QString& phoneNumber);
41+ void setIsConference(bool isConference);
42+
43+Q_SIGNALS:
44+ void phoneNumberChanged();
45+ void isConferenceChanged();
46+ void elapsedTimeChanged();
47+
48+protected:
49+ void timerEvent(QTimerEvent * event);
50+
51+private:
52+ QString m_phoneNumber;
53+ bool m_conference;
54+ int m_elapsed;
55+};
56+
57+#endif // MOCKCALLENTRY_H
tests/mocks/Ubuntu/Telephony/MockCallManager.cppnew file+65
@@ -0,0 +1,65 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
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; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com
17+ */
18+
19+#include "MockCallManager.h"
20+
21+MockCallManager::MockCallManager(QObject *parent)
22+ : QObject(parent)
23+ , m_foregroundCall(nullptr)
24+ , m_backgroundCall(nullptr)
25+{
26+}
27+
28+MockCallManager *MockCallManager::instance()
29+{
30+ static MockCallManager* manager = new MockCallManager();
31+ return manager;
32+}
33+
34+QObject* MockCallManager::foregroundCall() const
35+{
36+ return m_foregroundCall;
37+}
38+
39+void MockCallManager::setForegroundCall(QObject* foregroundCall)
40+{
41+ if(m_foregroundCall != foregroundCall){
42+ m_foregroundCall = foregroundCall;
43+ Q_EMIT foregroundCallChanged();
44+ Q_EMIT hasCallsChanged();
45+ }
46+}
47+
48+QObject* MockCallManager::backgroundCall() const
49+{
50+ return m_backgroundCall;
51+}
52+
53+void MockCallManager::setBackgroundCall(QObject* backgroundCall)
54+{
55+ if(m_backgroundCall != backgroundCall){
56+ m_backgroundCall = backgroundCall;
57+ Q_EMIT backgroundCallChanged();
58+ Q_EMIT hasCallsChanged();
59+ }
60+}
61+
62+bool MockCallManager::hasCalls() const
63+{
64+ return m_foregroundCall || m_backgroundCall;
65+}
tests/mocks/Ubuntu/Telephony/MockCallManager.hnew file+55
@@ -0,0 +1,55 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
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; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com
17+ */
18+
19+#ifndef MOCKCALLMANAGER_H
20+#define MOCKCALLMANAGER_H
21+
22+#include <QObject>
23+
24+class MockCallManager : public QObject
25+{
26+ Q_OBJECT
27+ Q_DISABLE_COPY(MockCallManager)
28+
29+ Q_PROPERTY(QObject *foregroundCall READ foregroundCall WRITE setForegroundCall NOTIFY foregroundCallChanged)
30+ Q_PROPERTY(QObject *backgroundCall READ backgroundCall WRITE setBackgroundCall NOTIFY backgroundCallChanged)
31+ Q_PROPERTY(bool hasCalls READ hasCalls NOTIFY hasCallsChanged)
32+
33+public:
34+ explicit MockCallManager(QObject *parent = 0);
35+
36+ static MockCallManager *instance();
37+
38+ QObject* foregroundCall() const;
39+ QObject* backgroundCall() const;
40+ bool hasCalls() const;
41+
42+ void setForegroundCall(QObject* foregroundCall);
43+ void setBackgroundCall(QObject* backgroundCall);
44+
45+Q_SIGNALS:
46+ void foregroundCallChanged();
47+ void backgroundCallChanged();
48+ void hasCallsChanged();
49+
50+private:
51+ QObject* m_foregroundCall;
52+ QObject* m_backgroundCall;
53+};
54+
55+#endif // MOCKCALLMANAGER_H
tests/mocks/Ubuntu/Telephony/MockContactWatcher.cppnew file+50
@@ -0,0 +1,50 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
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; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com
17+ */
18+
19+#include "MockContactWatcher.h"
20+#include "ContactWatcherData.h"
21+
22+MockContactWatcher::MockContactWatcher(QObject *parent)
23+ : QObject(parent)
24+{
25+ connect(ContactWatcherData::instance(), &ContactWatcherData::contactDataChanged,
26+ this, &MockContactWatcher::aliasChanged);
27+}
28+
29+QString MockContactWatcher::phoneNumber() const
30+{
31+ return m_phoneNumber;
32+}
33+
34+void MockContactWatcher::setPhoneNumber(const QString& phoneNumber)
35+{
36+ if(m_phoneNumber != phoneNumber){
37+ m_phoneNumber = phoneNumber;
38+ Q_EMIT phoneNumberChanged();
39+ Q_EMIT aliasChanged();
40+ }
41+}
42+
43+QString MockContactWatcher::alias() const
44+{
45+ QVariantMap data = ContactWatcherData::instance()->contactData().toMap();
46+ if (data.contains(m_phoneNumber)) {
47+ return data[m_phoneNumber].toMap()["alias"].toString();
48+ }
49+ return "";
50+}
tests/mocks/Ubuntu/Telephony/MockContactWatcher.hnew file+49
@@ -0,0 +1,49 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
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; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com
17+ */
18+
19+#ifndef MOCKCONTACTWATCHER_H
20+#define MOCKCONTACTWATCHER_H
21+
22+#include <QObject>
23+#include <QVariant>
24+
25+class MockContactWatcher : public QObject
26+{
27+ Q_OBJECT
28+ Q_DISABLE_COPY(MockContactWatcher)
29+
30+ Q_PROPERTY(QString phoneNumber READ phoneNumber WRITE setPhoneNumber NOTIFY phoneNumberChanged)
31+ Q_PROPERTY(QString alias READ alias NOTIFY aliasChanged)
32+
33+public:
34+ MockContactWatcher(QObject *parent = 0);
35+
36+ QString phoneNumber() const;
37+ QString alias() const;
38+
39+ void setPhoneNumber(const QString& phoneNumber);
40+
41+Q_SIGNALS:
42+ void phoneNumberChanged();
43+ void aliasChanged();
44+
45+private:
46+ QString m_phoneNumber;
47+};
48+
49+#endif // MOCKCONTACTWATCHER_H
tests/mocks/Ubuntu/Telephony/MockTelepathyHelper.cppnew file+35
@@ -0,0 +1,35 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
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; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com
17+ */
18+
19+#include "MockTelepathyHelper.h"
20+
21+MockTelepathyHelper::MockTelepathyHelper(QObject *parent)
22+ : QObject(parent)
23+{
24+}
25+
26+MockTelepathyHelper *MockTelepathyHelper::instance()
27+{
28+ static MockTelepathyHelper* helper = new MockTelepathyHelper();
29+ return helper;
30+}
31+
32+void MockTelepathyHelper::registerChannelObserver(const QString& name)
33+{
34+ Q_UNUSED(name);
35+}
tests/mocks/Ubuntu/Telephony/MockTelepathyHelper.hnew file+36
@@ -0,0 +1,36 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
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; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com
17+ */
18+
19+#ifndef MOCKTELEPATHYHELPER_H
20+#define MOCKTELEPATHYHELPER_H
21+
22+#include <QObject>
23+
24+class MockTelepathyHelper : public QObject
25+{
26+ Q_OBJECT
27+ Q_DISABLE_COPY(MockTelepathyHelper)
28+public:
29+ MockTelepathyHelper(QObject *parent = 0);
30+
31+ static MockTelepathyHelper *instance();
32+
33+ Q_INVOKABLE void registerChannelObserver(const QString& name);
34+};
35+
36+#endif // MOCKCONTACTWATCHER_H
tests/mocks/Ubuntu/Telephony/plugin.cppnew file+52
@@ -0,0 +1,52 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
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; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com
17+ */
18+
19+#include "plugin.h"
20+#include "MockCallEntry.h"
21+#include "MockCallManager.h"
22+#include "MockContactWatcher.h"
23+#include "MockTelepathyHelper.h"
24+#include "ContactWatcherData.h"
25+
26+#include <QtQml/QQmlContext>
27+#include <QtQml/QQmlEngine>
28+#include <qqml.h>
29+
30+void FakeUbuntuTelephonyQmlPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
31+{
32+ Q_ASSERT(engine);
33+
34+ Q_UNUSED(uri);
35+
36+ mRootContext = engine->rootContext();
37+ Q_ASSERT(mRootContext);
38+
39+ mRootContext->setContextProperty("telepathyHelper", MockTelepathyHelper::instance());
40+ mRootContext->setContextProperty("callManager", MockCallManager::instance());
41+ mRootContext->setContextProperty("contactWactherData", ContactWatcherData::instance());
42+}
43+
44+void FakeUbuntuTelephonyQmlPlugin::registerTypes(const char *uri)
45+{
46+ // @uri Telephony
47+ qmlRegisterUncreatableType<MockTelepathyHelper>(uri, 0, 1, "TelepathyHelper", "This is a singleton helper class");
48+ qmlRegisterUncreatableType<MockCallManager>(uri, 0, 1, "CallManager", "This is a singleton manager class");
49+ qmlRegisterUncreatableType<ContactWatcherData>(uri, 0, 1, "ContactWatcherData", "This is a singleton data class");
50+ qmlRegisterType<MockCallEntry>(uri, 0, 1, "CallEntry");
51+ qmlRegisterType<MockContactWatcher>(uri, 0, 1, "ContactWatcher");
52+}
tests/mocks/Ubuntu/Telephony/plugin.hnew file+37
@@ -0,0 +1,37 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
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; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com
17+ */
18+
19+#ifndef PLUGIN_H
20+#define PLUGIN_H
21+
22+#include <QQmlContext>
23+#include <QQmlExtensionPlugin>
24+
25+class FakeUbuntuTelephonyQmlPlugin : public QQmlExtensionPlugin
26+{
27+ Q_OBJECT
28+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
29+public:
30+ void initializeEngine(QQmlEngine *engine, const char *uri);
31+ void registerTypes(const char *uri);
32+
33+private:
34+ QQmlContext *mRootContext;
35+};
36+
37+#endif
tests/mocks/Ubuntu/Telephony/qmldirnew file+2
@@ -0,0 +1,2 @@
1+module Ubuntu.Telephony
2+plugin FakeUbuntuTelephonyQml
tests/qmltests/CMakeLists.txt+1
@@ -69,6 +69,7 @@ add_qml_test(Hud Result)
6969add_qml_test(Launcher Launcher IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
7070add_qml_test(Notifications Notifications IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
7171add_qml_test(Notifications VisualSnapDecisionsQueue IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
72+add_qml_test(Panel ActiveCallHint)
7273add_qml_test(Panel IndicatorRow)
7374add_qml_test(Panel Indicators IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
7475add_qml_test(Panel MenuContent IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
tests/qmltests/Panel/tst_ActiveCallHint.qmlnew file+131
@@ -0,0 +1,131 @@
1+/*
2+ * Copyright 2013 Canonical Ltd.
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; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0
18+import QtTest 1.0
19+import Unity.Test 0.1 as UT
20+import Ubuntu.Telephony 0.1 as Telephony
21+import ".."
22+import "../../../qml/Panel"
23+
24+Item {
25+ width: units.gu(40)
26+ height: units.gu(20)
27+
28+ Telephony.CallEntry {
29+ id: call1
30+ phoneNumber: "+447812221111"
31+ }
32+
33+ Telephony.CallEntry {
34+ id: call2
35+ phoneNumber: "+447812221112"
36+ }
37+
38+ Telephony.CallEntry {
39+ id: call3
40+ phoneNumber: "+447812221113"
41+ }
42+
43+ ActiveCallHint {
44+ id: callHint
45+ anchors {
46+ top: parent.top
47+ left:parent.left
48+ right:parent.right
49+ }
50+ height: units.gu(3)
51+ alternateLabelInterval: 2000
52+ }
53+
54+ Component.onCompleted: {
55+ contactWactherData.contactData = {
56+ "+447812221113": {
57+ "alias": "Bob's Uncle"
58+ }
59+ };
60+ callManager.foregroundCall = call3;
61+ }
62+
63+ UT.UnityTestCase {
64+ name: "ActiveCallHint"
65+ when: windowShown
66+
67+ function init() {
68+ callManager.foregroundCall = null;
69+ callManager.backgroundCall = null;
70+ callHint.alternateLabelInterval = 300;
71+ }
72+
73+ function test_activeCall_data() {
74+ return [
75+ { tag: "empty", foreground: null, background: null, active: false, label: "" },
76+ { tag: "foreground", foreground: call1, background: null, active: true, label: "+447812221111" },
77+ { tag: "background", foreground: null, background: call2, active: true, label: "+447812221112" },
78+ { tag: "multiple", foreground: call1, background: call2, active: true, label: "+447812221111" },
79+ ];
80+ }
81+
82+ function test_activeCall(data) {
83+ callManager.foregroundCall = data.foreground;
84+ callManager.backgroundCall = data.background;
85+
86+ compare(callHint.active, data.active, "Call hint active enabled does not match");
87+
88+ var contactLabel = findChild(callHint, "contactLabel");
89+ verify(contactLabel !== null);
90+
91+ compare(contactLabel.text, data.label, "Contact label does not match call");
92+ }
93+
94+ function test_changeContactData() {
95+ callManager.backgroundCall = call3;
96+
97+ var contactLabel = findChild(callHint, "contactLabel");
98+ verify(contactLabel !== null);
99+
100+ contactWactherData.contactData = { "+447812221113": { "alias": "Bob's Uncle" } };
101+ compare(contactLabel.text, "Bob's Uncle", "Contact label does not match call");
102+
103+ contactWactherData.contactData = { "+447812221113": { "alias": "Freddy" } };
104+ compare(contactLabel.text, "Freddy", "Contact label does not match call");
105+ }
106+
107+ function test_timeLapse() {
108+ callManager.backgroundCall = call3;
109+
110+ var timeLabel = findChild(callHint, "timeLabel");
111+ verify(timeLabel !== null);
112+
113+ var currentLabel = timeLabel.text;
114+ tryCompareFunction(function() { return timeLabel.text !== currentLabel }, true);
115+ currentLabel = timeLabel.text;
116+ tryCompareFunction(function() { return timeLabel.text !== currentLabel }, true);
117+ }
118+
119+ function test_tapToReturn() {
120+ callManager.backgroundCall = call3;
121+
122+ var labelPathView = findChild(callHint, "labelPathView");
123+ verify(labelPathView !== null);
124+
125+ var currentOffset = labelPathView.offset
126+ tryCompareFunction(function() { return labelPathView.offset !== currentOffset }, true);
127+ currentOffset = labelPathView.offset
128+ tryCompareFunction(function() { return labelPathView.offset !== currentOffset }, true);
129+ }
130+ }
131+}
tests/qmltests/Panel/tst_Panel.qml+41−25
@@ -17,6 +17,7 @@
1717import QtQuick 2.0
1818import QtTest 1.0
1919import Unity.Test 0.1 as UT
20+import Ubuntu.Telephony 0.1 as Telephony
2021import ".."
2122import "../../../qml/Panel"
2223
@@ -40,26 +41,23 @@ Item {
4041 Panel {
4142 id: panel
4243 anchors.fill: parent
43− fullscreenMode: true
44+ fullscreenMode: false
4445
4546 indicators {
4647 profile: "test1"
48+ panelHeight: units.gu(5)
4749 }
4850 }
4951
52+ Telephony.CallEntry {
53+ id: phoneCall
54+ phoneNumber: "+447812221111"
55+ }
56+
5057 UT.UnityTestCase {
5158 name: "Panel"
5259 when: windowShown
5360
54− function get_window_data() {
55− return [
56− {tag: "pinned", fullscreenFlag: false, alreadyOpen: false },
57− {tag: "fullscreen", fullscreenFlag: true, alreadyOpen: false },
58− {tag: "pinned-alreadyOpen", fullscreenFlag: false, alreadyOpen: true },
59− {tag: "fullscreen-alreadyOpen", fullscreenFlag: true, alreadyOpen: true }
60− ];
61− }
62−
6361 function init() {
6462 panel.indicators.initialise();
6563
@@ -67,6 +65,7 @@ Item {
6765 panel.indicators.hide();
6866 tryCompare(panel.indicators.hideAnimation, "running", false);
6967 tryCompare(panel.indicators, "state", "initial");
68+ callManager.foregroundCall = null;
7069 }
7170
7271 function get_indicator_item(index) {
@@ -114,7 +113,8 @@ Item {
114113 panel.fullscreenMode = true;
115114 // Wait for the indicators to get into position.
116115 // (switches between normal and fullscreen modes are animated)
117− tryCompare(panel.indicators, "y", -panel.panelHeight);
116+ var indicatorArea = findChild(panel, "indicatorArea");
117+ tryCompare(indicatorArea, "y", -panel.panelHeight);
118118
119119 var indicatorItemCoord = get_indicator_item_position(0);
120120
@@ -124,7 +124,7 @@ Item {
124124 wait(500);
125125
126126 // no hint animation when fullscreen
127− compare(panel.indicators.y, -panel.panelHeight);
127+ compare(indicatorArea.y, -panel.panelHeight);
128128 var indicatorRow = findChild(panel.indicators, "indicatorRow");
129129 verify(indicatorRow !== null);
130130 compare(indicatorRow.y, 0);
@@ -138,34 +138,48 @@ Item {
138138 touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
139139 }
140140
141− function test_drag_show_data() { return get_window_data(); }
141+ function test_drag_show_data() {
142+ return [
143+ { tag: "pinned", fullscreenFlag: false, alreadyOpen: false, call: null,
144+ indicatorY: function() { return 0 } },
145+ { tag: "fullscreen", fullscreenFlag: true, alreadyOpen: false, call: null,
146+ indicatorY: function() {return -panel.panelHeight } },
147+ { tag: "pinned-alreadyOpen", fullscreenFlag: false, alreadyOpen: true, call: null,
148+ indicatorY: function() { return 0 } },
149+ { tag: "fullscreen-alreadyOpen", fullscreenFlag: true, alreadyOpen: true, call: null,
150+ indicatorY: function() {return -panel.panelHeight } },
151+ { tag: "pinned-callActive", fullscreenFlag: false, alreadyOpen: false, call: phoneCall,
152+ indicatorY: function() { return units.gu(3) } },
153+ { tag: "fullscreen-callActive", fullscreenFlag: true, alreadyOpen: false, call: phoneCall,
154+ indicatorY: function() {return units.gu(3) - (panel.panelHeight - units.gu(3)) } }
155+ ];
156+ }
142157
143158 // Dragging from a indicator item in the panel will gradually expose the
144159 // indicators, first by running the hint animation, then after dragging down will
145160 // expose more of the panel, binding it to the selected indicator and opening it's menu.
146161 function test_drag_show(data) {
147162 panel.fullscreenMode = data.fullscreenFlag;
163+
164+ callManager.foregroundCall = data.call;
165+
148166 if (data.alreadyOpen) {
149167 panel.indicators.show();
150168 tryCompare(panel.indicators, "fullyOpened", true);
151169 }
152170
153− var indicatorRow = findChild(panel.indicators, "indicatorRow");
171+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
154172 verify(indicatorRow !== null);
155173
156174 var menuContent = findChild(panel.indicators, "menuContent");
157− verify(indicatorRow !== null);
175+ verify(menuContent !== null);
158176
159− var menuContent = findChild(panel.indicators, "menuContent");
160− verify(indicatorRow !== null);
177+ var indicatorArea = findChild(panel, "indicatorArea");
178+ verify(indicatorArea !== null);
161179
162180 // Wait for the indicators to get into position.
163181 // (switches between normal and fullscreen modes are animated)
164− if (data.fullscreenFlag) {
165− tryCompare(panel.indicators, "y", -panel.panelHeight);
166− } else {
167− tryCompare(panel.indicators, "y", 0);
168− }
182+ tryCompare(indicatorArea, "y", data.indicatorY());
169183
170184 // do this for each indicator item
171185 for (var i = 0; i < indicatorRow.row.count; i++) {
@@ -184,7 +198,7 @@ Item {
184198 // 1) Drag the mouse down
185199 touchFlick(panel,
186200 indicatorItemCoord.x, panel.panelHeight / 2,
187− indicatorItemCoord.x, panel.height * 0.8,
201+ indicatorItemCoord.x, panel.height,
188202 false /* beginTouch */, false /* endTouch */);
189203
190204 // Indicators height should follow the drag, and therefore increase accordingly.
@@ -193,7 +207,7 @@ Item {
193207 function() {return panel.indicators.height >= panel.height * 0.5},
194208 true);
195209
196− touchRelease(panel, indicatorItemCoord.x, panel.height * 0.8);
210+ touchRelease(panel, indicatorItemCoord.x, panel.height);
197211
198212 compare(indicatorRow.currentItem, indicatorItem,
199213 "Incorrect item activated at position " + i);
@@ -201,7 +215,9 @@ Item {
201215
202216 // init for next indicatorItem
203217 if (!data.alreadyOpen) {
204− init();
218+ panel.indicators.hide();
219+ tryCompare(panel.indicators.hideAnimation, "running", false);
220+ tryCompare(panel.indicators, "state", "initial");
205221 }
206222 }
207223 }