on xenial help sign in
Merge
commit730e254bf330b8a9aeec8b2774404aea7619be2d authorAlbert Astals <albert.astals@canonical.com> dateTue 14 Jan 2014, 14:58 (13 years ago) parent789c672ccacdf0
48 files changed+2132−344
CODING+29 cmake/modules/autopilot.cmake+5−1 debian/control+1 plugins/DashViews/horizontaljournal.cpp+2−2 plugins/Unity/Indicators/Messaging/qml/MessageMenuItemFactory.qml+8 plugins/Unity/Indicators/Network/qml/AccessPoint.qml+2−2 plugins/Unity/Indicators/qml/ButtonMenuItem.qml+1−1 plugins/Unity/Indicators/qml/IndicatorPage.qml−219 plugins/Unity/Indicators/qml/MenuItemFactory.qml+18−3 plugins/Unity/Indicators/qml/qmldir−2 po/ca.po+7−7 po/cs.po+9−7 po/lv.po+6−6 po/pl.po+7−7 qml/Dash/Card.qml+83 qml/Dash/CardHeader.qml+112 qml/Panel/IndicatorItem.qml+7 qml/Panel/IndicatorRow.qml+1 qml/Panel/Indicators/DefaultIndicatorPage.qml+195−2 qml/Panel/Indicators/DefaultIndicatorWidget.qml+5−3 qml/ScopeTool.qml+26−28 src/CMakeLists.txt+9−1 tests/autopilot/unity8/indicators/__init__.py tests/autopilot/unity8/indicators/tests/__init__.py tests/autopilot/unity8/indicators/tests/test_indicators.py+50 tests/autopilot/unity8/shell/emulators/__init__.py+11−4 tests/autopilot/unity8/shell/emulators/create_interactive_notification.py+1−1 tests/autopilot/unity8/shell/emulators/dash.py+102−8 tests/autopilot/unity8/shell/emulators/greeter.py+2−5 tests/autopilot/unity8/shell/emulators/main_window.py+6 tests/autopilot/unity8/shell/tests/__init__.py+1 tests/autopilot/unity8/shell/tests/test_emulators.py+120 tests/mocks/QMenuModel/unitymenumodel.cpp+3 tests/mocks/Unity/Indicators/CMakeLists.txt+2 tests/mocks/Unity/Indicators/IndicatorBase.qml+2−1 tests/mocks/Unity/Indicators/IndicatorWidget.qml−28 plugins/Unity/Indicators/qml/IndicatorWidget.qml → tests/mocks/Unity/Indicators/MenuItemFactory.qml+15−5 tests/mocks/Unity/Indicators/fakeplugin.cpp+2 tests/mocks/Unity/Indicators/qmldir+1−1 tests/qmltests/CMakeLists.txt+6 tests/qmltests/Dash/CardHelpers.js+75 tests/qmltests/Dash/artwork/avatar@12.png tests/qmltests/Dash/artwork/music-player-design.png tests/qmltests/Dash/tst_Card.qml+337 tests/qmltests/Dash/tst_CardHeader.qml+138 tests/qmltests/Panel/Indicators/tst_DefaultIndicatorPage.qml+179 tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml+369 tests/qmltests/Panel/Indicators/tst_MessageMenuItemFactory.qml+177
CODING+29
@@ -166,3 +166,32 @@ $ make tryDragHandle
166166NB: Manual test or interation doesn't make sense for all components or classes,
167167particularly the non-graphical ones. In such cases no "tryFoo" make target is
168168provided.
169+
170+NB: The tests expect the locale to be the C locale, they may fail if run
171+under a different locale, if you get failures others can not reproduce
172+prepend 'LC_ALL=C' to the 'make test' command
173+
174+Running autopilot tests
175+=======================
176+
177+Autopilot tests are run from the build directory (which will be ./builddir if you used
178+the ./build script).
179+
180+$ make autopilot
181+
182+If you want you can also run tests individually, for that you need to install first,
183+otherwise the tests will run on the system-installed version
184+
185+$ make install
186+
187+To see the list of existing autopilot tests you can do
188+
189+$ PYTHONPATH=../tests/autopilot autopilot list unity8
190+
191+And then run a single test with
192+
193+$ PYTHONPATH=../tests/autopilot autopilot run unity8.some.very.long.test.name
194+
195+or run them all with
196+
197+$ PYTHONPATH=../tests/autopilot autopilot run unity8
cmake/modules/autopilot.cmake+5−1
@@ -4,7 +4,11 @@ function(declare_autopilot_test TEST_NAME TEST_SUITE WORKING_DIR)
44 add_custom_target(autopilot-${TEST_NAME}
55 COMMAND LANG=C UBUNTU_ICON_THEME=ubuntu-mobile QML2_IMPORT_PATH=${SHELL_INSTALL_QML}/mocks autopilot run ${TEST_SUITE}
66 WORKING_DIRECTORY ${WORKING_DIR}
7− DEPENDS install
7+ DEPENDS fake_install
8+ )
9+
10+ add_custom_target(fake_install
11+ COMMAND cmake --build ${CMAKE_BINARY_DIR} --target install
812 )
913
1014 add_dependencies(autopilot autopilot-${TEST_NAME})
debian/control+1
@@ -104,6 +104,7 @@ Depends: gir1.2-glib-2.0,
104104 libqt5widgets5,
105105 python-evdev,
106106 python-gi,
107+ python-mock,
107108 unity8 (>= ${source:Version}),
108109 unity8-fake-env (>= ${source:Version}),
109110 ${misc:Depends},
plugins/DashViews/horizontaljournal.cpp+2−2
@@ -172,7 +172,7 @@ void HorizontalJournal::cleanupExistingItems()
172172 releaseItem(item);
173173 m_visibleItems.clear();
174174 m_lastInRowIndexPosition.clear();
175− m_firstVisibleIndex = 0;
175+ m_firstVisibleIndex = -1;
176176}
177177
178178void HorizontalJournal::calculateImplicitHeight()
@@ -241,7 +241,7 @@ void HorizontalJournal::doRelayout()
241241 }
242242 m_visibleItems.clear();
243243 m_lastInRowIndexPosition.clear();
244− m_firstVisibleIndex = 0;
244+ m_firstVisibleIndex = -1;
245245 }
246246}
247247
plugins/Unity/Indicators/Messaging/qml/MessageMenuItemFactory.qml+8
@@ -60,6 +60,7 @@ Indicators.BaseMenuItem {
6060
6161 Loader {
6262 id: contents
63+ objectName: "loader"
6364 anchors.fill: parent
6465
6566 sourceComponent: loadMessage(actionsDescription);
@@ -67,6 +68,7 @@ Indicators.BaseMenuItem {
6768 Component {
6869 id: simpleTextMessage
6970 SimpleTextMessage {
71+ objectName: "simpleTextMessage"
7072 // text
7173 title: menuData && menuData.label || ""
7274 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
@@ -74,6 +76,8 @@ Indicators.BaseMenuItem {
7476 // icons
7577 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
7678 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
79+ // actions
80+ enabled: menuData && menuData.sensitive || false
7781
7882 onActivateApp: {
7983 menuModel.activate(menuIndex, true);
@@ -91,6 +95,7 @@ Indicators.BaseMenuItem {
9195 Component {
9296 id: textMessage
9397 TextMessage {
98+ objectName: "textMessage"
9499 property var replyActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
95100
96101 property var replyAction: QMenuModel.UnityMenuAction {
@@ -109,6 +114,7 @@ Indicators.BaseMenuItem {
109114 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
110115 // actions
111116 replyEnabled: replyAction.valid && replyAction.enabled
117+ enabled: menuData && menuData.sensitive || false
112118
113119 onActivateApp: {
114120 menuModel.activate(menuIndex, true);
@@ -129,6 +135,7 @@ Indicators.BaseMenuItem {
129135 Component {
130136 id: snapDecision
131137 SnapDecision {
138+ objectName: "snapDecision"
132139 property var activateActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
133140 property var replyActionDescription: actionsDescription && actionsDescription.length > 1 ? actionsDescription[1] : undefined
134141
@@ -156,6 +163,7 @@ Indicators.BaseMenuItem {
156163 // actions
157164 activateEnabled: activateAction.valid && activateAction.enabled
158165 replyEnabled: replyAction.valid && replyAction.enabled
166+ enabled: menuData && menuData.sensitive || false
159167
160168 onActivateApp: {
161169 menuModel.activate(menuIndex, true);
plugins/Unity/Indicators/Network/qml/AccessPoint.qml+2−2
@@ -30,7 +30,7 @@ Indicators.BaseMenuItem {
3030 property bool secure: false
3131 property bool adHoc: false
3232 property int signalStrength: 0
33− property alias text: label.text
33+ property alias label: _label.text
3434
3535 signal activate()
3636
@@ -89,7 +89,7 @@ Indicators.BaseMenuItem {
8989 }
9090
9191 Label {
92− id: label
92+ id: _label
9393 anchors {
9494 left: iconSignal.right
9595 leftMargin: units.gu(1)
plugins/Unity/Indicators/qml/ButtonMenuItem.qml+1−1
@@ -26,7 +26,7 @@ BaseMenuItem {
2626 id: menuItem
2727 implicitHeight: units.gu(7)
2828
29− property alias text: button.text
29+ property alias buttonText: button.text
3030
3131 signal activate()
3232
plugins/Unity/Indicators/qml/IndicatorPage.qmldeleted−219
@@ -1,219 +0,0 @@
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 Lesser 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 Lesser General Public License for more details.
12− *
13− * You should have received a copy of the GNU Lesser General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Authors:
17− * Renato Araujo Oliveira Filho <renato@canonical.com>
18− * Nick Dedekind <nick.dedekind@canonical.com>
19− */
20−
21−import QtQuick 2.0
22−import Ubuntu.Components 0.1 as Components
23−import Unity.Indicators 0.1 as Indicators
24−
25−IndicatorBase {
26− id: main
27−
28− //const
29− property bool contentActive: false
30− property string title: rootActionState.title
31− property alias emptyText: emptyLabel.text
32− property alias highlightFollowsCurrentItem : mainMenu.highlightFollowsCurrentItem
33−
34− Indicators.UnityMenuModelStack {
35− id: menuStack
36− head: contentActive ? main.menuModel : null
37−
38− property var rootMenu: null
39−
40− onTailChanged: {
41− if (!tail) {
42− rootMenu = null;
43− } else if (rootMenu != tail) {
44− if (tail.get(0, "type") === rootMenuType) {
45− rootMenu = menuStack.tail.submenu(0);
46− push(rootMenu, 0);
47− } else {
48− rootMenu = null;
49− }
50− }
51− }
52− }
53−
54− Connections {
55− target: menuStack.tail
56− onRowsInserted: {
57− if (menuStack.rootMenu !== menuStack.tail && menuStack.tail.get(0, "type") === rootMenuType) {
58− menuStack.rootMenu = menuStack.tail.submenu(0);
59− menuStack.push(menuStack.rootMenu, 0);
60− }
61− }
62− }
63−
64− ListView {
65− id: mainMenu
66− model: menuStack.rootMenu
67−
68− anchors {
69− fill: parent
70− bottomMargin: Qt.inputMethod.visible ? (Qt.inputMethod.keyboardRectangle.height - main.anchors.bottomMargin) : 0
71−
72− Behavior on bottomMargin {
73− NumberAnimation {
74− duration: 175
75− easing.type: Easing.OutQuad
76− }
77− }
78− // TODO - does ever frame.
79− onBottomMarginChanged: {
80− mainMenu.positionViewAtIndex(mainMenu.currentIndex, ListView.End)
81− }
82− }
83−
84− // Ensure all delegates are cached in order to improve smoothness of scrolling
85− cacheBuffer: 10000
86−
87− // Only allow flicking if the content doesn't fit on the page
88− interactive: contentHeight > height
89−
90− property int selectedIndex: -1
91− property bool blockCurrentIndexChange: false
92− // for count = 0
93− onCountChanged: {
94− if (count == 0 && selectedIndex != -1) {
95− selectedIndex = -1;
96− }
97− }
98− // for highlight following
99− onSelectedIndexChanged: {
100− if (currentIndex != selectedIndex) {
101− var blocked = blockCurrentIndexChange;
102− blockCurrentIndexChange = true;
103−
104− currentIndex = selectedIndex;
105−
106− blockCurrentIndexChange = blocked;
107− }
108− }
109− // for item addition/removal
110− onCurrentIndexChanged: {
111− if (!blockCurrentIndexChange) {
112− if (selectedIndex != -1 && selectedIndex != currentIndex) {
113− selectedIndex = currentIndex;
114− }
115− }
116− }
117−
118− delegate: Item {
119− id: menuDelegate
120−
121− anchors {
122− left: parent.left
123− right: parent.right
124− }
125− height: loader.height
126− visible: height > 0
127−
128− Loader {
129− id: loader
130− asynchronous: false
131−
132− property int modelIndex: index
133−
134− anchors {
135− left: parent.left
136− right: parent.right
137− }
138−
139− sourceComponent: factory.load(model)
140−
141− onLoaded: {
142− if (item.hasOwnProperty("menuSelected")) {
143− item.menuSelected = mainMenu.selectedIndex == index;
144− item.selectMenu.connect(function() { mainMenu.selectedIndex = index; });
145− item.deselectMenu.connect(function() { mainMenu.selectedIndex = -1; });
146− }
147− if (item.hasOwnProperty("menuData")) {
148− item.menuData = Qt.binding(function() { return model; });
149− }
150− if (item.hasOwnProperty("menuIndex")) {
151− item.menuIndex = Qt.binding(function() { return modelIndex; });
152− }
153− }
154−
155− Binding {
156− target: item ? item : null
157− property: "objectName"
158− value: model.action
159− }
160−
161− // TODO: Fixes lp#1243146
162− // This is a workaround for a Qt bug. https://bugreports.qt-project.org/browse/QTBUG-34351
163− Connections {
164− target: mainMenu
165− onSelectedIndexChanged: {
166− if (loader.item && loader.item.hasOwnProperty("menuSelected")) {
167− loader.item.menuSelected = mainMenu.selectedIndex == index;
168− }
169− }
170− }
171− }
172− }
173− }
174−
175− MenuItemFactory {
176− id: factory
177− menuModel: mainMenu.model ? mainMenu.model : null
178− }
179−
180− Components.Label {
181− id: emptyLabel
182− visible: mainMenu.count == 0
183− anchors {
184− top: parent.top
185− left: parent.left
186− right: parent.right
187− topMargin: units.gu(2)
188− }
189− wrapMode: Text.WordWrap
190− horizontalAlignment: Text.AlignHCenter
191−
192− //style
193− color: "#e8e1d0"
194− fontSize: "medium"
195−
196− text: "Empty!"
197− }
198−
199− function start()
200− {
201− reset()
202− if (!contentActive) {
203− contentActive = true;
204− }
205− }
206−
207− function stop()
208− {
209− if (contentActive) {
210− contentActive = false;
211− }
212− }
213−
214− function reset()
215− {
216− mainMenu.selectedIndex = -1;
217− mainMenu.positionViewAtBeginning();
218− }
219−}
plugins/Unity/Indicators/qml/MenuItemFactory.qml+18−3
@@ -57,11 +57,17 @@ Item {
5757 return defaultValue;
5858 }
5959
60− Component { id: divMenu; Indicators.DivMenuItem {} }
60+ Component {
61+ id: divMenu;
62+ Indicators.DivMenuItem {
63+ objectName: "divMenu"
64+ }
65+ }
6166
6267 Component {
6368 id: sliderMenu;
6469 Indicators.SliderMenuItem {
70+ objectName: "sliderMenu"
6571 property QtObject menuData: null
6672 property var menuModel: menuFactory.menuModel
6773 property int menuIndex: -1
@@ -106,11 +112,12 @@ Item {
106112 Component {
107113 id: buttonMenu;
108114 Indicators.ButtonMenuItem {
115+ objectName: "buttonMenu"
109116 property QtObject menuData: null
110117 property var menuModel: menuFactory.menuModel
111118 property int menuIndex: -1
112119
113− text: menuData && menuData.label || ""
120+ buttonText: menuData && menuData.label || ""
114121 enabled: menuData && menuData.sensitive || false
115122
116123 onActivate: {
@@ -122,6 +129,7 @@ Item {
122129 Component {
123130 id: sectionMenu;
124131 Indicators.SectionMenuItem {
132+ objectName: "sectionMenu"
125133 property QtObject menuData: null
126134 property var menuIndex: undefined
127135
@@ -132,6 +140,7 @@ Item {
132140 Component {
133141 id: progressMenu;
134142 Indicators.ProgressMenuItem {
143+ objectName: "progressMenu"
135144 property QtObject menuData: null
136145 property int menuIndex: -1
137146
@@ -145,6 +154,7 @@ Item {
145154 Component {
146155 id: standardMenu;
147156 Indicators.StandardMenuItem {
157+ objectName: "standardMenu"
148158 property QtObject menuData: null
149159 property int menuIndex: -1
150160
@@ -164,6 +174,7 @@ Item {
164174 Component {
165175 id: switchMenu;
166176 Indicators.SwitchMenuItem {
177+ objectName: "switchMenu"
167178 property QtObject menuData: null
168179 property int menuIndex: -1
169180
@@ -182,6 +193,7 @@ Item {
182193 Component {
183194 id: wifiSection;
184195 Indicators.SectionMenuItem {
196+ objectName: "wifiSection"
185197 property QtObject menuData: null
186198 property var menuModel: menuFactory.menuModel
187199 property int menuIndex: -1
@@ -207,6 +219,7 @@ Item {
207219 Component {
208220 id: accessPoint;
209221 ICNetwork.AccessPoint {
222+ objectName: "accessPoint"
210223 property QtObject menuData: null
211224 property var menuModel: menuFactory.menuModel
212225 property int menuIndex: -1
@@ -218,7 +231,7 @@ Item {
218231 name: getExtendedProperty(extendedData, "xCanonicalWifiApStrengthAction", "")
219232 }
220233
221− text: menuData && menuData.label || ""
234+ label: menuData && menuData.label || ""
222235 enabled: menuData && menuData.sensitive || false
223236 secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
224237 adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
@@ -248,6 +261,7 @@ Item {
248261 Component {
249262 id: messageItem
250263 ICMessaging.MessageMenuItemFactory {
264+ objectName: "messageItem"
251265 menuModel: menuFactory.menuModel
252266 }
253267 }
@@ -255,6 +269,7 @@ Item {
255269 Component {
256270 id: groupedMessage
257271 ICMessaging.GroupedMessage {
272+ objectName: "groupedMessage"
258273 property QtObject menuData: null
259274 property var menuModel: menuFactory.menuModel
260275 property int menuIndex: -1
plugins/Unity/Indicators/qml/qmldir−2
@@ -9,8 +9,6 @@ DivMenuItem 0.1 DivMenuItem.qml
99FramedMenuItem 0.1 FramedMenuItem.qml
1010HLine 0.1 HLine.qml
1111IndicatorBase 0.1 IndicatorBase.qml
12−IndicatorPage 0.1 IndicatorPage.qml
13−IndicatorWidget 0.1 IndicatorWidget.qml
1412MenuActionBinding 0.1 MenuActionBinding.qml
1513MenuItemFactory 0.1 MenuItemFactory.qml
1614ProgressMenuItem 0.1 ProgressMenuItem.qml
po/ca.po+7−7
@@ -8,15 +8,15 @@ msgstr ""
88"Project-Id-Version: unity\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2013-11-29 09:21+0100\n"
11−"PO-Revision-Date: 2013-09-28 07:38+0000\n"
12−"Last-Translator: David Planella <david.planella@ubuntu.com>\n"
11+"PO-Revision-Date: 2014-01-10 07:45+0000\n"
12+"Last-Translator: Adolfo Jayme <fitoschido@gmail.com>\n"
1313"Language-Team: Catalan <ca@li.org>\n"
1414"MIME-Version: 1.0\n"
1515"Content-Type: text/plain; charset=UTF-8\n"
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=2; plural=n != 1;\n"
18−"X-Launchpad-Export-Date: 2013-12-29 06:04+0000\n"
19−"X-Generator: Launchpad (build 16877)\n"
18+"X-Launchpad-Export-Date: 2014-01-11 06:38+0000\n"
19+"X-Generator: Launchpad (build 16890)\n"
2020
2121#: Components/EdgeDemoOverlay.qml:151
2222msgid "Skip intro"
@@ -143,7 +143,7 @@ msgstr "S'està parlant..."
143143
144144#: Notifications/NotificationMenuItemFactory.qml:89
145145msgid "Show password"
146−msgstr ""
146+msgstr "Mostra la contrasenya"
147147
148148#: Panel/SearchIndicator.qml:27
149149msgid "Search"
@@ -152,11 +152,11 @@ msgstr "Cerca"
152152#: plugins/Unity/Launcher/launcheritem.cpp:43
153153#: plugins/Unity/Launcher/launcheritem.cpp:73
154154msgid "Lock to Launcher"
155−msgstr ""
155+msgstr "Mantén-la al llançador"
156156
157157#: plugins/Unity/Launcher/launcheritem.cpp:73
158158msgid "Unlock from Launcher"
159−msgstr ""
159+msgstr "No la mantinguis al llançador"
160160
161161#: Shell.qml:439
162162#, qt-format
po/cs.po+9−7
@@ -8,15 +8,15 @@ msgstr ""
88"Project-Id-Version: unity8\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2013-11-29 09:21+0100\n"
11−"PO-Revision-Date: 2013-10-08 08:09+0000\n"
11+"PO-Revision-Date: 2014-01-08 10:11+0000\n"
1212"Last-Translator: Tadeáš Pařík <tadeas.parik@gmail.com>\n"
1313"Language-Team: Czech <cs@li.org>\n"
1414"MIME-Version: 1.0\n"
1515"Content-Type: text/plain; charset=UTF-8\n"
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
18−"X-Launchpad-Export-Date: 2013-12-29 06:04+0000\n"
19−"X-Generator: Launchpad (build 16877)\n"
18+"X-Launchpad-Export-Date: 2014-01-09 05:41+0000\n"
19+"X-Generator: Launchpad (build 16884)\n"
2020
2121#: Components/EdgeDemoOverlay.qml:151
2222msgid "Skip intro"
@@ -44,7 +44,7 @@ msgstr "Uzavřít"
4444
4545#: Components/EdgeDemo.qml:171
4646msgid "Swipe up again to close the settings screen"
47−msgstr ""
47+msgstr "Přetažením nahoru dojde k uzavření obrazovky nastavení"
4848
4949#: Components/EdgeDemo.qml:198
5050msgid "Left edge"
@@ -63,6 +63,8 @@ msgid ""
6363"You have now mastered the edge gestures and can start using the "
6464"phone<br><br>Tap anywhere to start"
6565msgstr ""
66+"Nyní jste si osvojili gesta potřebná k ovládání telefonu, můžete ho začít "
67+"používat <br><br>Klepnutím kdekoli začnete"
6668
6769#: Components/PageHeader.qml:364
6870msgid "Recent searches"
@@ -138,7 +140,7 @@ msgstr "Mluvte..."
138140
139141#: Notifications/NotificationMenuItemFactory.qml:89
140142msgid "Show password"
141−msgstr ""
143+msgstr "Zobrazit heslo"
142144
143145#: Panel/SearchIndicator.qml:27
144146msgid "Search"
@@ -147,11 +149,11 @@ msgstr "Hledat"
147149#: plugins/Unity/Launcher/launcheritem.cpp:43
148150#: plugins/Unity/Launcher/launcheritem.cpp:73
149151msgid "Lock to Launcher"
150−msgstr ""
152+msgstr "Přidat do Launcheru"
151153
152154#: plugins/Unity/Launcher/launcheritem.cpp:73
153155msgid "Unlock from Launcher"
154−msgstr ""
156+msgstr "Odebrat z Launcheru"
155157
156158#: Shell.qml:439
157159#, qt-format
po/lv.po+6−6
@@ -8,15 +8,15 @@ msgstr ""
88"Project-Id-Version: unity\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2013-11-29 09:21+0100\n"
11−"PO-Revision-Date: 2013-09-28 16:29+0000\n"
11+"PO-Revision-Date: 2014-01-11 16:48+0000\n"
1212"Last-Translator: Jānis-Marks Gailis <jeanmarc.gailis@gmail.com>\n"
1313"Language-Team: Latvian <lv@li.org>\n"
1414"MIME-Version: 1.0\n"
1515"Content-Type: text/plain; charset=UTF-8\n"
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2;\n"
18−"X-Launchpad-Export-Date: 2013-12-29 06:04+0000\n"
19−"X-Generator: Launchpad (build 16877)\n"
18+"X-Launchpad-Export-Date: 2014-01-12 05:52+0000\n"
19+"X-Generator: Launchpad (build 16890)\n"
2020
2121#: Components/EdgeDemoOverlay.qml:151
2222msgid "Skip intro"
@@ -32,7 +32,7 @@ msgstr ""
3232
3333#: Components/EdgeDemo.qml:144
3434msgid "Top edge"
35−msgstr ""
35+msgstr "Augšējā mala"
3636
3737#: Components/EdgeDemo.qml:145
3838msgid "Try swiping from the top edge to access the indicators"
@@ -40,7 +40,7 @@ msgstr ""
4040
4141#: Components/EdgeDemo.qml:170
4242msgid "Close"
43−msgstr ""
43+msgstr "Aizvērt"
4444
4545#: Components/EdgeDemo.qml:171
4646msgid "Swipe up again to close the settings screen"
@@ -48,7 +48,7 @@ msgstr ""
4848
4949#: Components/EdgeDemo.qml:198
5050msgid "Left edge"
51−msgstr ""
51+msgstr "Kreisā mala"
5252
5353#: Components/EdgeDemo.qml:199
5454msgid "Swipe from the left to reveal the launcher for quick access to apps"
po/pl.po+7−7
@@ -8,16 +8,16 @@ msgstr ""
88"Project-Id-Version: unity\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2013-11-29 09:21+0100\n"
11−"PO-Revision-Date: 2013-10-13 13:44+0000\n"
12−"Last-Translator: GTriderXC <gtriderxc@yahoo.com>\n"
11+"PO-Revision-Date: 2014-01-10 11:38+0000\n"
12+"Last-Translator: Michał Sawicz <michal.sawicz@canonical.com>\n"
1313"Language-Team: Polish <pl@li.org>\n"
1414"MIME-Version: 1.0\n"
1515"Content-Type: text/plain; charset=UTF-8\n"
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
1818"|| n%100>=20) ? 1 : 2;\n"
19−"X-Launchpad-Export-Date: 2013-12-29 06:04+0000\n"
20−"X-Generator: Launchpad (build 16877)\n"
19+"X-Launchpad-Export-Date: 2014-01-11 06:38+0000\n"
20+"X-Generator: Launchpad (build 16890)\n"
2121
2222#: Components/EdgeDemoOverlay.qml:151
2323msgid "Skip intro"
@@ -143,7 +143,7 @@ msgstr "Rozpoznanie..."
143143
144144#: Notifications/NotificationMenuItemFactory.qml:89
145145msgid "Show password"
146−msgstr ""
146+msgstr "Wyświetl hasło"
147147
148148#: Panel/SearchIndicator.qml:27
149149msgid "Search"
@@ -152,11 +152,11 @@ msgstr "Szukaj"
152152#: plugins/Unity/Launcher/launcheritem.cpp:43
153153#: plugins/Unity/Launcher/launcheritem.cpp:73
154154msgid "Lock to Launcher"
155−msgstr ""
155+msgstr "Dodaj do panelu uruchamiania"
156156
157157#: plugins/Unity/Launcher/launcheritem.cpp:73
158158msgid "Unlock from Launcher"
159−msgstr ""
159+msgstr "Usuń z panelu uruchamiania"
160160
161161#: Shell.qml:439
162162#, qt-format
qml/Dash/Card.qmlnew file+83
@@ -0,0 +1,83 @@
1+/*
2+ * Copyright (C) 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 Ubuntu.Components 0.1
19+
20+Item {
21+ id: root
22+ property var template
23+ property var components
24+ property var cardData
25+
26+ width: {
27+ if (template !== undefined) {
28+ if (template["card-layout"] === "horizontal") return units.gu(38);
29+ switch (template['card-size']) {
30+ case "small": return units.gu(12);
31+ case "large": return units.gu(38);
32+ }
33+ }
34+ return units.gu(18.5);
35+ }
36+ height: childrenRect.height
37+
38+ UbuntuShape {
39+ id: artShape
40+ objectName: "artShape"
41+ width: image.fillMode === Image.PreserveAspectCrop || aspect < image.aspect ? image.width : height * image.aspect
42+ height: image.fillMode === Image.PreserveAspectCrop || aspect > image.aspect ? image.height : width / image.aspect
43+ anchors.horizontalCenter: template && template["card-layout"] === "horizontal" ? undefined : parent.horizontalCenter
44+
45+ property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1
46+
47+ image: Image {
48+ width: template && template["card-layout"] === "horizontal" ? height * artShape.aspect : root.width
49+ height: template && template["card-layout"] === "horizontal" ? header.height : width / artShape.aspect
50+ objectName: "artImage"
51+ source: cardData && cardData["art"] || ""
52+ // FIXME uncomment when having investigated / fixed the crash
53+ //sourceSize.width: width > height ? width : 0
54+ //sourceSize.height: height > width ? height : 0
55+ fillMode: components["art"]["fill-mode"] === "fit" ? Image.PreserveAspectFit: Image.PreserveAspectCrop
56+
57+ property real aspect: implicitWidth / implicitHeight
58+ }
59+ }
60+
61+ CardHeader {
62+ id: header
63+ objectName: "cardHeader"
64+ anchors {
65+ top: template && template["card-layout"] === "horizontal" ? artShape.top : artShape.bottom
66+ left: template && template["card-layout"] === "horizontal" ? artShape.right : parent.left
67+ right: parent.right
68+ }
69+
70+ mascot: cardData && cardData["mascot"] || ""
71+ title: cardData && cardData["title"] || ""
72+ subtitle: cardData && cardData["subtitle"] || ""
73+ }
74+
75+ Label {
76+ objectName: "summaryLabel"
77+ anchors { top: header.bottom; left: parent.left; right: parent.right }
78+ wrapMode: Text.Wrap
79+ maximumLineCount: 5
80+ elide: Text.ElideRight
81+ text: cardData && cardData["summary"] || ""
82+ }
83+}
qml/Dash/CardHeader.qmlnew file+112
@@ -0,0 +1,112 @@
1+/*
2+ * Copyright (C) 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 Ubuntu.Components 0.1
19+
20+Item {
21+ id: root
22+ property alias mascot: mascotImage.source
23+ property alias title: titleLabel.text
24+ property alias subtitle: subtitleLabel.text
25+ property alias price: priceLabel.text
26+ property alias oldPrice: oldPriceLabel.text
27+ property alias altPrice: altPriceLabel.text
28+
29+ visible: mascotImage.status === Image.Ready || title || price
30+ height: row.height > 0 ? row.height + row.spacing * 2 : 0
31+
32+ Row {
33+ id: row
34+ objectName: "outerRow"
35+
36+ anchors { top: parent.top; left: parent.left; right: parent.right; margins: spacing }
37+ spacing: units.gu(1)
38+
39+ UbuntuShape {
40+ id: mascotShape
41+ objectName: "mascotShape"
42+
43+ width: units.gu(8)
44+ height: units.gu(8)
45+ visible: image.status === Image.Ready
46+
47+ image: Image {
48+ id: mascotImage
49+ sourceSize { width: mascotShape.width; height: mascotShape.height }
50+ }
51+ }
52+
53+ Column {
54+ objectName: "column"
55+ width: parent.width - x
56+
57+ Label {
58+ id: titleLabel
59+ anchors { left: parent.left; right: parent.right }
60+ elide: Text.ElideRight
61+ objectName: "titleLabel"
62+ font.weight: Font.DemiBold
63+ wrapMode: Text.Wrap
64+ maximumLineCount: 2
65+ }
66+
67+ Label {
68+ id: subtitleLabel
69+ anchors { left: parent.left; right: parent.right }
70+ elide: Text.ElideRight
71+ visible: titleLabel.text && text
72+ }
73+
74+ Row {
75+ id: prices
76+ objectName: "prices"
77+ anchors { left: parent.left; right: parent.right }
78+
79+ property int labels: {
80+ var labels = 1; // price always visible
81+ if (oldPriceLabel.text !== "") labels += 1;
82+ if (altPriceLabel.text !== "") labels += 1;
83+ return labels;
84+ }
85+ property real labelWidth: width / labels
86+
87+ Label {
88+ id: priceLabel
89+ width: parent.labelWidth
90+ elide: Text.ElideRight
91+ font.weight: Font.DemiBold
92+ color: Theme.palette.selected.foreground
93+ }
94+
95+ Label {
96+ id: oldPriceLabel
97+ objectName: "oldPriceLabel"
98+ width: parent.labelWidth
99+ elide: Text.ElideRight
100+ horizontalAlignment: parent.labels === 3 ? Text.AlignHCenter : Text.AlignRight
101+ }
102+
103+ Label {
104+ id: altPriceLabel
105+ width: parent.labelWidth
106+ elide: Text.ElideRight
107+ horizontalAlignment: Text.AlignRight
108+ }
109+ }
110+ }
111+ }
112+}
qml/Panel/IndicatorItem.qml+7
@@ -26,6 +26,7 @@ Item {
2626 property bool dimmed: false
2727 property var indicatorProperties: undefined
2828 property bool indicatorVisible: loader.item ? loader.item.enabled : false
29+ property string identifier
2930
3031 opacity: dimmed ? 0.4 : 1
3132 Behavior on opacity { StandardAnimation {} }
@@ -44,5 +45,11 @@ Item {
4445 }
4546 }
4647 }
48+
49+ Binding {
50+ target: loader.item
51+ property: "objectName"
52+ value: identifier + "-widget"
53+ }
4754 }
4855}
qml/Panel/IndicatorRow.qml+1
@@ -95,6 +95,7 @@ Item {
9595
9696 IndicatorItem {
9797 id: indicatorItem
98+ identifier: model.identifier
9899 height: parent.height
99100
100101 dimmed: itemWrapper.dimmed
qml/Panel/Indicators/DefaultIndicatorPage.qml+195−2
@@ -14,12 +14,205 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 *
1616 * Authors:
17+ * Renato Araujo Oliveira Filho <renato@canonical.com>
1718 * Nick Dedekind <nick.dedekind@canonical.com>
1819 */
1920
2021import QtQuick 2.0
22+import Ubuntu.Components 0.1 as Components
2123import Unity.Indicators 0.1 as Indicators
2224
23−Indicators.IndicatorPage {
24− anchors.fill: parent
25+Indicators.IndicatorBase {
26+ id: main
27+
28+ //const
29+ property bool contentActive: false
30+ property string title: rootActionState.title
31+ property alias emptyText: emptyLabel.text
32+ property alias highlightFollowsCurrentItem : mainMenu.highlightFollowsCurrentItem
33+
34+ Indicators.UnityMenuModelStack {
35+ id: menuStack
36+ head: contentActive ? main.menuModel : null
37+
38+ property var rootMenu: null
39+
40+ onTailChanged: {
41+ if (!tail) {
42+ rootMenu = null;
43+ } else if (rootMenu != tail) {
44+ if (tail.get(0, "type") === rootMenuType) {
45+ rootMenu = menuStack.tail.submenu(0);
46+ push(rootMenu, 0);
47+ } else {
48+ rootMenu = null;
49+ }
50+ }
51+ }
52+ }
53+
54+ Connections {
55+ target: menuStack.tail
56+ onRowsInserted: {
57+ if (menuStack.rootMenu !== menuStack.tail && menuStack.tail.get(0, "type") === rootMenuType) {
58+ menuStack.rootMenu = menuStack.tail.submenu(0);
59+ menuStack.push(menuStack.rootMenu, 0);
60+ }
61+ }
62+ onModelReset: {
63+ if (menuStack.rootMenu !== menuStack.tail && menuStack.tail.get(0, "type") === rootMenuType) {
64+ menuStack.rootMenu = menuStack.tail.submenu(0);
65+ menuStack.push(menuStack.rootMenu, 0);
66+ }
67+ }
68+ }
69+
70+ ListView {
71+ id: mainMenu
72+ objectName: "mainMenu"
73+ model: menuStack.rootMenu
74+
75+ anchors {
76+ fill: parent
77+ bottomMargin: Qt.inputMethod.visible ? (Qt.inputMethod.keyboardRectangle.height - main.anchors.bottomMargin) : 0
78+
79+ Behavior on bottomMargin {
80+ NumberAnimation {
81+ duration: 175
82+ easing.type: Easing.OutQuad
83+ }
84+ }
85+ // TODO - does ever frame.
86+ onBottomMarginChanged: {
87+ mainMenu.positionViewAtIndex(mainMenu.currentIndex, ListView.End)
88+ }
89+ }
90+
91+ // Ensure all delegates are cached in order to improve smoothness of scrolling
92+ cacheBuffer: 10000
93+
94+ // Only allow flicking if the content doesn't fit on the page
95+ interactive: contentHeight > height
96+
97+ property int selectedIndex: -1
98+ property bool blockCurrentIndexChange: false
99+ // for count = 0
100+ onCountChanged: {
101+ if (count == 0 && selectedIndex != -1) {
102+ selectedIndex = -1;
103+ }
104+ }
105+ // for highlight following
106+ onSelectedIndexChanged: {
107+ if (currentIndex != selectedIndex) {
108+ var blocked = blockCurrentIndexChange;
109+ blockCurrentIndexChange = true;
110+
111+ currentIndex = selectedIndex;
112+
113+ blockCurrentIndexChange = blocked;
114+ }
115+ }
116+ // for item addition/removal
117+ onCurrentIndexChanged: {
118+ if (!blockCurrentIndexChange) {
119+ if (selectedIndex != -1 && selectedIndex != currentIndex) {
120+ selectedIndex = currentIndex;
121+ }
122+ }
123+ }
124+
125+ delegate: Loader {
126+ id: loader
127+ objectName: "menuItem" + index
128+ asynchronous: false
129+ visible: height > 0
130+
131+ property int modelIndex: index
132+
133+ anchors {
134+ left: parent.left
135+ right: parent.right
136+ }
137+
138+ sourceComponent: factory.load(model)
139+
140+ onLoaded: {
141+ if (item.hasOwnProperty("menuSelected")) {
142+ item.menuSelected = mainMenu.selectedIndex == index;
143+ item.selectMenu.connect(function() { mainMenu.selectedIndex = index; });
144+ item.deselectMenu.connect(function() { mainMenu.selectedIndex = -1; });
145+ }
146+ if (item.hasOwnProperty("menuData")) {
147+ item.menuData = Qt.binding(function() { return model; });
148+ }
149+ if (item.hasOwnProperty("menuIndex")) {
150+ item.menuIndex = Qt.binding(function() { return modelIndex; });
151+ }
152+ }
153+
154+ Binding {
155+ target: item ? item : null
156+ property: "objectName"
157+ value: model.action
158+ }
159+
160+ // TODO: Fixes lp#1243146
161+ // This is a workaround for a Qt bug. https://bugreports.qt-project.org/browse/QTBUG-34351
162+ Connections {
163+ target: mainMenu
164+ onSelectedIndexChanged: {
165+ if (loader.item && loader.item.hasOwnProperty("menuSelected")) {
166+ loader.item.menuSelected = mainMenu.selectedIndex == index;
167+ }
168+ }
169+ }
170+ }
171+ }
172+
173+ Indicators.MenuItemFactory {
174+ id: factory
175+ menuModel: mainMenu.model ? mainMenu.model : null
176+ }
177+
178+ Components.Label {
179+ id: emptyLabel
180+ objectName: "emptyLabel"
181+ visible: mainMenu.count == 0
182+ anchors {
183+ top: parent.top
184+ left: parent.left
185+ right: parent.right
186+ topMargin: units.gu(2)
187+ }
188+ wrapMode: Text.WordWrap
189+ horizontalAlignment: Text.AlignHCenter
190+
191+ //style
192+ color: "#e8e1d0"
193+ fontSize: "medium"
194+
195+ text: "Empty!"
196+ }
197+
198+ function start()
199+ {
200+ reset()
201+ if (!contentActive) {
202+ contentActive = true;
203+ }
204+ }
205+
206+ function stop()
207+ {
208+ if (contentActive) {
209+ contentActive = false;
210+ }
211+ }
212+
213+ function reset()
214+ {
215+ mainMenu.selectedIndex = -1;
216+ mainMenu.positionViewAtBeginning();
217+ }
25218}
qml/Panel/Indicators/DefaultIndicatorWidget.qml+5−3
@@ -21,15 +21,17 @@ import QtQuick 2.0
2121import Ubuntu.Components 0.1
2222import Unity.Indicators 0.1 as Indicators
2323
24−Indicators.IndicatorWidget {
24+Indicators.IndicatorBase {
2525 id: indicatorWidget
2626
27− width: itemRow.width
28−
27+ property int iconSize: height
2928 property alias leftLabel: itemLeftLabel.text
3029 property alias rightLabel: itemRightLabel.text
3130 property var icons: undefined
3231
32+ width: itemRow.width
33+ enabled: false
34+
3335 Row {
3436 id: itemRow
3537 width: childrenRect.width
qml/ScopeTool.qml+26−28
@@ -17,7 +17,9 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import Ubuntu.Components.Popups 0.1
20+import Utils 0.1
2021import Unity 0.1
22+import "Components"
2123import "Dash"
2224
2325Rectangle {
@@ -43,18 +45,28 @@ Rectangle {
4345 signal searchClicked
4446 }
4547
48+ SortFilterProxyModel {
49+ id: filteredScopes
50+ model: Scopes {
51+ id: scopes
52+ }
53+ dynamicSortFilter: true
4654
47− Scopes {
48− id: scopes
55+ filterRole: Scopes.RoleVisible
56+ filterRegExp: RegExp("^true$")
4957 }
5058
5159 Rectangle {
52− anchors.fill: scopeView
60+ anchors.fill: dashContent
5361 color: "#FCFCFC"
5462 }
5563
56− GenericScopeView {
57− id: scopeView
64+ DashContent {
65+ id: dashContent
66+
67+ model: filteredScopes
68+ searchHistory: SearchHistoryModel { }
69+ property Scope scope: scopes.get(currentIndex)
5870
5971 anchors {
6072 top: parent.top
@@ -62,8 +74,6 @@ Rectangle {
6274 left: parent.left
6375 right: controls.left
6476 }
65−
66− scope: scopes.loaded ? scopes.get(scopeSelector.selectedIndex) : undefined
6777 }
6878
6979 Rectangle {
@@ -76,6 +86,10 @@ Rectangle {
7686 right: parent.right
7787 }
7888
89+ MouseArea {
90+ anchors.fill: parent
91+ }
92+
7993 Column {
8094 anchors { fill: parent; margins: units.gu(1) }
8195 spacing: units.gu(1)
@@ -88,27 +102,11 @@ Rectangle {
88102 id: searchField
89103 anchors { left: parent.left; right: parent.right }
90104
91− onTextChanged: scopeView.scope.searchQuery = text
105+ onTextChanged: dashContent.scope.searchQuery = text
92106
93107 Connections {
94− target: scopeView.scope
95− onSearchQueryChanged: searchField.text = scopeView.scope.searchQuery
96− }
97− }
98−
99− Label {
100− text: "Scope selection"
101− height: units.gu(4)
102− verticalAlignment: Text.AlignBottom
103− }
104−
105− OptionSelector {
106− id: scopeSelector
107− anchors { left: parent.left; right: parent.right }
108−
109− model: scopes
110− delegate: OptionSelectorDelegate {
111− text: model.title
108+ target: dashContent.scope
109+ onSearchQueryChanged: searchField.text = dashContent.scope.searchQuery
112110 }
113111 }
114112
@@ -121,7 +119,7 @@ Rectangle {
121119 OptionSelector {
122120 id: categorySelector
123121 anchors { left: parent.left; right: parent.right }
124− model: scopeView.scope ? scopeView.scope.categories : null
122+ model: dashContent.scope ? dashContent.scope.categories : null
125123
126124 property Item selectedItem
127125
@@ -170,7 +168,7 @@ Rectangle {
170168 onCancelClicked: PopupUtils.close(sheet)
171169 onConfirmClicked: {
172170 PopupUtils.close(sheet);
173− scopeView.scope.categories.overrideCategoryJson(categorySelector.selectedItem.categoryId, categoryEditorArea.text);
171+ dashContent.scope.categories.overrideCategoryJson(categorySelector.selectedItem.categoryId, categoryEditorArea.text);
174172 }
175173 }
176174 }
src/CMakeLists.txt+9−1
@@ -5,7 +5,15 @@ include_directories(
55 ${UNITY-MIR_INCLUDE_DIRS}
66)
77
8−file(GLOB_RECURSE QML_FILES ${CMAKE_SOURCE_DIR}/qml/*)
8+file(GLOB_RECURSE QML_FILES
9+ ${CMAKE_SOURCE_DIR}/qml/*
10+ ${CMAKE_SOURCE_DIR}/tests/*.qml
11+ ${CMAKE_SOURCE_DIR}/tests/*.js
12+ ${CMAKE_SOURCE_DIR}/tests/*.jpg
13+ ${CMAKE_SOURCE_DIR}/tests/*.png
14+ ${CMAKE_SOURCE_DIR}/tests/*.sci
15+ ${CMAKE_SOURCE_DIR}/tests/*.svg
16+)
917
1018add_executable(${SHELL_APP}
1119 ApplicationArguments.h
tests/autopilot/unity8/indicators/__init__.pynew file

No changes to the content.

tests/autopilot/unity8/indicators/tests/__init__.pynew file

No changes to the content.

tests/autopilot/unity8/indicators/tests/test_indicators.pynew file+50
@@ -0,0 +1,50 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity - Indicators Autopilot Test Suite
4+# Copyright (C) 2013 Canonical
5+#
6+# This program is free software: you can redistribute it and/or modify
7+# it under the terms of the GNU General Public License as published by
8+# the Free Software Foundation, either version 3 of the License, or
9+# (at your option) any later version.
10+#
11+# This program is distributed in the hope that it will be useful,
12+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+# GNU General Public License for more details.
15+#
16+# You should have received a copy of the GNU General Public License
17+# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+#
19+
20+from __future__ import absolute_import
21+
22+from autopilot import platform
23+from testtools import skipIf
24+
25+from unity8.process_helpers import unlock_unity
26+from unity8.shell.tests import UnityTestCase
27+
28+
29+class IndicatorTestCase(UnityTestCase):
30+
31+ scenarios = [
32+ ('Bluetooth', dict(indicator_name='indicator-bluetooth')),
33+ ('Datetime', dict(indicator_name='indicator-datetime')),
34+ ('Location', dict(indicator_name='indicator-location')),
35+ ('Messaging', dict(indicator_name='indicator-messages')),
36+ ('Network', dict(indicator_name='indicator-network')),
37+ ('Power', dict(indicator_name='indicator-power')),
38+ ('Sound', dict(indicator_name='indicator-sound')),
39+ ]
40+
41+ @skipIf(platform.image_codename() == 'Desktop',
42+ "Unity8/phablet-only test!")
43+ def setUp(self):
44+ super(IndicatorTestCase, self).setUp()
45+
46+ def test_indicator_exists(self):
47+ unity_proxy = self.launch_unity()
48+ unlock_unity(unity_proxy)
49+ indicator = self.main_window.get_indicator(self.indicator_name)
50+ self.assertIsNotNone(indicator)
tests/autopilot/unity8/shell/emulators/__init__.py+11−4
@@ -1,7 +1,7 @@
11# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
22#
33# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
4+# Copyright (C) 2012, 2013, 2014 Canonical
55#
66# This program is free software: you can redistribute it and/or modify
77# it under the terms of the GNU General Public License as published by
@@ -17,9 +17,16 @@
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818#
1919
20+from autopilot import input, introspection
2021
21−from autopilot.introspection import CustomEmulatorBase
2222
23−
24−class UnityEmulatorBase(CustomEmulatorBase):
23+class UnityEmulatorBase(introspection.CustomEmulatorBase):
2524 """A base class for all unity emulators."""
25+
26+ def __init__(self, *args):
27+ super(UnityEmulatorBase, self).__init__(*args)
28+ self.pointing_device = input.Touch.create()
29+
30+
31+class UnityEmulatorException(Exception):
32+ """Exception raised when there is an error with the Unity emulators."""
tests/autopilot/unity8/shell/emulators/create_interactive_notification.py+1−1
@@ -87,7 +87,7 @@ if __name__ == '__main__':
8787 action_id,
8888 action_label,
8989 action_callback,
90− None,
90+ (None, ),
9191 None
9292 )
9393
tests/autopilot/unity8/shell/emulators/dash.py+102−8
@@ -1,7 +1,7 @@
11# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
22#
33# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
4+# Copyright (C) 2012, 2013, 2014 Canonical
55#
66# This program is free software: you can redistribute it and/or modify
77# it under the terms of the GNU General Public License as published by
@@ -17,13 +17,25 @@
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818#
1919
20−from unity8.shell.emulators import UnityEmulatorBase
20+import logging
2121
22+from unity8.shell import emulators
2223
23−class Dash(UnityEmulatorBase):
24+from autopilot import logging as autopilot_logging
25+from autopilot.introspection import dbus
2426
27+
28+logger = logging.getLogger(__name__)
29+
30+
31+class Dash(emulators.UnityEmulatorBase):
2532 """An emulator that understands the Dash."""
2633
34+ def __init__(self, *args):
35+ super(Dash, self).__init__(*args)
36+ self.dash_content_list = self.wait_select_single(
37+ 'QQuickListView', objectName='dashContentList')
38+
2739 def get_home_applications_grid(self):
2840 get_grid = self.get_scope('home').wait_select_single(
2941 "GenericFilterGrid",
@@ -43,9 +55,91 @@ class Dash(UnityEmulatorBase):
4355 return resp_grid.select_single('Tile', text=text)
4456
4557 def get_scope(self, scope_name='home'):
46− dash_content = self.wait_select_single(
47− 'QQuickListView',
48− objectName='dashContentList'
49− )
5058 scope_id = "%s.scope" % scope_name
51− return dash_content.select_single('QQuickLoader', scopeId=scope_id)
59+ return self.dash_content_list.select_single(
60+ 'QQuickLoader', scopeId=scope_id)
61+
62+ @autopilot_logging.log_action(logger.info)
63+ def open_scope(self, scope_name):
64+ """Open a dash scope.
65+
66+ :parameter scope_name: The name of the scope.
67+ :return: The scope.
68+
69+ """
70+ scope_id = "%s.scope" % scope_name
71+ scope_loader = self._get_scope_loader(scope_id)
72+ if scope_loader.isCurrent:
73+ logger.info('The scope is already open.')
74+ return self._get_scope_from_loader(scope_loader)
75+ else:
76+ return self._open_scope_scrolling(scope_loader)
77+
78+ def _get_scope_loader(self, scope_id):
79+ try:
80+ return self.dash_content_list.select_single(
81+ 'QQuickLoader', scopeId=scope_id)
82+ except dbus.StateNotFoundError:
83+ raise emulators.UnityEmulatorException(
84+ 'No scope found with id {0}'.format(scope_id))
85+
86+ def _get_scope_from_loader(self, loader):
87+ if loader.scopeId == 'applications.scope':
88+ return loader.select_single(DashApps)
89+ else:
90+ return loader.select_single(GenericScopeView)
91+
92+ def _open_scope_scrolling(self, scope_loader):
93+ scroll = self._get_scroll_direction(scope_loader)
94+
95+ while not scope_loader.isCurrent:
96+ scroll()
97+
98+ scope = self._get_scope_from_loader(scope_loader)
99+ scope.moving.wait_for(False)
100+ scope.isCurrent.wait_for(True)
101+ return scope
102+
103+ def _get_scroll_direction(self, scope_loader):
104+ current_scope_loader = self.dash_content_list.select_single(
105+ 'QQuickLoader', isCurrent=True)
106+ if scope_loader.globalRect.x < current_scope_loader.globalRect.x:
107+ return self._scroll_to_left_scope
108+ elif scope_loader.globalRect.x > current_scope_loader.globalRect.x:
109+ return self._scroll_to_right_scope
110+ else:
111+ raise emulators.UnityEmulatorException('The scope is already open')
112+
113+ @autopilot_logging.log_action(logger.info)
114+ def _scroll_to_left_scope(self):
115+ original_index = self.dash_content_list.currentIndex
116+ # Scroll on the border of the page header, because some scopes have
117+ # contents that can be scrolled horizontally.
118+ page_header = self.select_single('PageHeader')
119+ border = page_header.select_single('QQuickBorderImage')
120+ start_x = border.width / 3
121+ stop_x = border.width / 3 * 2
122+ start_y = stop_y = border.globalRect.y + border.height / 2
123+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
124+ self.dash_content_list.currentIndex.wait_for(original_index - 1)
125+
126+ @autopilot_logging.log_action(logger.info)
127+ def _scroll_to_right_scope(self):
128+ original_index = self.dash_content_list.currentIndex
129+ # Scroll on the border of the page header, because some scopes have
130+ # contents that can be scrolled horizontally.
131+ page_header = self.select_single('PageHeader')
132+ border = page_header.select_single('QQuickBorderImage')
133+ start_x = border.width / 3 * 2
134+ stop_x = border.width / 3
135+ start_y = stop_y = border.globalRect.y + border.height / 2
136+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
137+ self.dash_content_list.currentIndex.wait_for(original_index + 1)
138+
139+
140+class GenericScopeView(emulators.UnityEmulatorBase):
141+ """Autopilot emulators for generic scopes."""
142+
143+
144+class DashApps(emulators.UnityEmulatorBase):
145+ """Autopilot emulators for the applications scope."""
tests/autopilot/unity8/shell/emulators/greeter.py+2−5
@@ -1,7 +1,7 @@
11# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
22#
33# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
4+# Copyright (C) 2012, 2013, 2014 Canonical
55#
66# This program is free software: you can redistribute it and/or modify
77# it under the terms of the GNU General Public License as published by
@@ -18,24 +18,21 @@
1818#
1919
2020from unity8.shell.emulators import UnityEmulatorBase
21−from autopilot.input import Touch
2221
2322
2423class Greeter(UnityEmulatorBase):
25−
2624 """An emulator that understands the greeter screen."""
2725
2826 def swipe(self):
2927 """Swipe the greeter screen away."""
3028 self.created.wait_for(True)
31− touch = Touch.create()
3229
3330 rect = self.globalRect
3431 start_x = rect[0] + rect[2] - 3
3532 start_y = int(rect[1] + rect[3] / 2)
3633 stop_x = int(rect[0] + rect[2] * 0.2)
3734 stop_y = start_y
38− touch.drag(start_x, start_y, stop_x, stop_y)
35+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
3936
4037 self.created.wait_for(False)
4138
tests/autopilot/unity8/shell/emulators/main_window.py+6
@@ -91,5 +91,11 @@ class MainWindow(object):
9191 def get_pinentryField(self):
9292 return self.app.select_single(objectName="pinentryField")
9393
94+ def get_indicator(self, indicator_name):
95+ return self.app.select_single(
96+ 'DefaultIndicatorWidget',
97+ objectName=indicator_name+'-widget'
98+ )
99+
94100 def get_shell_background(self):
95101 return self.app.select_single("CrossFadeImage", objectName="backgroundImage")
tests/autopilot/unity8/shell/tests/__init__.py+1
@@ -147,6 +147,7 @@ class UnityTestCase(AutopilotTestCase):
147147 if model() != "Desktop":
148148 from autopilot.input import _uinput
149149 _uinput._touch_device = _uinput.create_touch_device()
150+ self.addCleanup(_uinput._touch_device.close)
150151 ####
151152
152153 self.touch = Touch.create()
tests/autopilot/unity8/shell/tests/test_emulators.pynew file+120
@@ -0,0 +1,120 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2014 Canonical
5+#
6+# This program is free software: you can redistribute it and/or modify
7+# it under the terms of the GNU General Public License as published by
8+# the Free Software Foundation, either version 3 of the License, or
9+# (at your option) any later version.
10+#
11+# This program is distributed in the hope that it will be useful,
12+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+# GNU General Public License for more details.
15+#
16+# You should have received a copy of the GNU General Public License
17+# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+#
19+
20+import mock
21+
22+from unity8 import process_helpers
23+from unity8.shell import emulators, tests
24+from unity8.shell.emulators import dash as dash_emulators
25+
26+
27+class DashEmulatorTestCase(tests.UnityTestCase):
28+
29+ scenarios = tests._get_device_emulation_scenarios()
30+
31+ def setUp(self):
32+ super(DashEmulatorTestCase, self).setUp()
33+ unity_proxy = self.launch_unity()
34+ process_helpers.unlock_unity(unity_proxy)
35+ self.dash = self.main_window.get_dash()
36+
37+ def test_open_unexisting_scope(self):
38+ scope_name = 'unexisting'
39+ with mock.patch.object(self.dash, 'pointing_device') as mock_pointer:
40+ exception = self.assertRaises(
41+ emulators.UnityEmulatorException,
42+ self.dash.open_scope, scope_name)
43+
44+ self.assertEqual(
45+ 'No scope found with id unexisting.scope', str(exception))
46+ self.assertFalse(mock_pointer.called)
47+
48+ def test_open_already_opened_scope(self):
49+ scope_id = self._get_current_scope_id()
50+ with mock.patch.object(self.dash, 'pointing_device') as mock_pointer:
51+ scope = self.dash.open_scope(self._get_scope_name_from_id(
52+ scope_id))
53+
54+ self.assertFalse(mock_pointer.called)
55+ self._assert_scope_is_opened(scope, scope_id)
56+
57+ def _assert_scope_is_opened(self, scope, scope_id):
58+ self.assertTrue(scope.isCurrent)
59+ scope_loader = scope.get_parent()
60+ self.assertEqual(scope_loader.scopeId, scope_id)
61+
62+ def _get_current_scope_id(self):
63+ scope = self.dash.dash_content_list.select_single(
64+ 'QQuickLoader', isCurrent=True)
65+ return scope.scopeId
66+
67+ def test_open_scope_to_the_right(self):
68+ leftmost_scope = self._get_scope_name_from_id(
69+ self._get_leftmost_scope_id())
70+ self.dash.open_scope(leftmost_scope)
71+
72+ scope_id = self._get_rightmost_scope_id()
73+ scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id))
74+ self._assert_scope_is_opened(scope, scope_id)
75+
76+ def _get_leftmost_scope_id(self):
77+ scope_loaders = self._get_scope_loaders()
78+ leftmost_scope_loader = scope_loaders[0]
79+ for loader in scope_loaders[1:]:
80+ if loader.globalRect.x < leftmost_scope_loader.globalRect.x:
81+ leftmost_scope_loader = loader
82+ return leftmost_scope_loader.scopeId
83+
84+ def _get_scope_loaders(self):
85+ item = self.dash.dash_content_list.get_children_by_type(
86+ 'QQuickItem')[0]
87+ return item.get_children_by_type('QQuickLoader')
88+
89+ def _get_scope_name_from_id(self, scope_id):
90+ if scope_id.endswith('.scope'):
91+ return scope_id[:-6]
92+
93+ def _get_rightmost_scope_id(self):
94+ scope_loaders = self._get_scope_loaders()
95+ rightmost_scope_loader = scope_loaders[0]
96+ for loader in scope_loaders[1:]:
97+ if loader.globalRect.x > rightmost_scope_loader.globalRect.x:
98+ rightmost_scope_loader = loader
99+ return rightmost_scope_loader.scopeId
100+
101+ def test_open_scope_to_the_left(self):
102+ rightmost_scope = self._get_scope_name_from_id(
103+ self._get_rightmost_scope_id())
104+ self.dash.open_scope(rightmost_scope)
105+
106+ scope_id = self._get_leftmost_scope_id()
107+ scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id))
108+ self._assert_scope_is_opened(scope, scope_id)
109+
110+ def test_open_generic_scope(self):
111+ scope_id = 'home.scope'
112+ scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id))
113+ self._assert_scope_is_opened(scope, scope_id)
114+ self.assertIsInstance(scope, dash_emulators.GenericScopeView)
115+
116+ def test_open_applications_scope(self):
117+ scope_id = 'applications.scope'
118+ scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id))
119+ self._assert_scope_is_opened(scope, scope_id)
120+ self.assertIsInstance(scope, dash_emulators.DashApps)
tests/mocks/QMenuModel/unitymenumodel.cpp+3
@@ -143,6 +143,9 @@ QVariant UnityMenuModel::data(const QModelIndex &index, int role) const
143143
144144QVariantMap UnityMenuModel::rowData(int row) const
145145{
146+ if (m_modelData.count() <= row) {
147+ return QVariantMap();
148+ }
146149 return m_modelData[row].toMap()["rowData"].toMap();
147150}
148151
tests/mocks/Unity/Indicators/CMakeLists.txt+2
@@ -7,12 +7,14 @@ include_directories(
77 ${CMAKE_CURRENT_SOURCE_DIR}
88 ${CMAKE_CURRENT_BINARY_DIR}
99 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators
10+ ${CMAKE_SOURCE_DIR}/tests/mocks/QMenuModel
1011)
1112
1213set(IndicatorsFakeQml_SOURCES
1314 fakeplugin.cpp
1415 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/indicators.h
1516 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/menucontentactivator.cpp
17+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelstack.cpp
1618 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/visibleindicatorsmodel.cpp
1719)
1820
tests/mocks/Unity/Indicators/IndicatorBase.qml+2−1
@@ -26,8 +26,9 @@ Item {
2626 //const
2727 property string busName
2828 property string actionsObjectPath
29+ property string menuObjectPath
2930 property string rootMenuType: "com.canonical.indicator.root"
30− property string deviceMenuObjectPath
31+ property string deviceMenuObjectPath: menuObjectPath
3132
3233 property var menuModel: UnityMenuModel {}
3334
tests/mocks/Unity/Indicators/IndicatorWidget.qmldeleted−28
@@ -1,28 +0,0 @@
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 Lesser 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 Lesser General Public License for more details.
12− *
13− * You should have received a copy of the GNU Lesser General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Authors:
17− * Nick Dedekind <nick.dedekind@canonical.com>
18− */
19−
20−import QtQuick 2.0
21−import Unity.Indicators 0.1 as Indicators
22−
23−IndicatorBase {
24− id: indicatorWidget
25−
26− enabled: false
27− property int iconSize: height
28−}
plugins/Unity/Indicators/qml/IndicatorWidget.qml → tests/mocks/Unity/Indicators/MenuItemFactory.qmlrenamed+15−5
@@ -18,11 +18,21 @@
1818 */
1919
2020import QtQuick 2.0
21−import Unity.Indicators 0.1 as Indicators
21+import Ubuntu.Components.ListItems 0.1 as ListItem
2222
23−IndicatorBase {
24− id: indicatorWidget
23+Item {
24+ id: menuFactory
2525
26− enabled: false
27− property int iconSize: height
26+ property var menuModel: null
27+
28+ Component {
29+ id: standardMenu;
30+ ListItem.Standard {
31+ objectName: "standardMenu"
32+ }
33+ }
34+
35+ function load(modelData) {
36+ return standardMenu;
37+ }
2838}
tests/mocks/Unity/Indicators/fakeplugin.cpp+2
@@ -25,6 +25,7 @@
2525// local
2626#include "indicators.h"
2727#include "menucontentactivator.h"
28+#include "unitymenumodelstack.h"
2829#include "visibleindicatorsmodel.h"
2930
3031void IndicatorsFakePlugin::registerTypes(const char * uri)
@@ -32,6 +33,7 @@ void IndicatorsFakePlugin::registerTypes(const char * uri)
3233 Q_INIT_RESOURCE(indicators_fake);
3334
3435 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
36+ qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack");
3537 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
3638
3739 qmlRegisterUncreatableType<MenuContentState>(uri, 0, 1, "MenuContentState", "Can't create MenuContentState class");
tests/mocks/Unity/Indicators/qmldir+1−1
@@ -3,7 +3,7 @@ plugin IndicatorsFakeQml
33
44CachedUnityMenuModel 0.1 CachedUnityMenuModel.qml
55IndicatorBase 0.1 IndicatorBase.qml
6−IndicatorWidget 0.1 IndicatorWidget.qml
76IndicatorsModel 0.1 IndicatorsModel.qml
87FakeMenuPage 0.1 FakeMenuPage.qml
8+MenuItemFactory 0.1 MenuItemFactory.qml
99RootActionState 0.1 RootActionState.qml
tests/qmltests/CMakeLists.txt+6
@@ -42,6 +42,8 @@ add_qml_test(Dash Dash IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAUL
4242add_qml_test(Dash DashContent IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
4343add_qml_test(Dash DashPreview)
4444add_qml_test(Dash GenericPreview)
45+add_qml_test(Dash Card)
46+add_qml_test(Dash CardHeader)
4547add_qml_test(Dash GenericScopeView IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
4648add_qml_test(Dash FilterGrids IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins
4749 ${CMAKE_BINARY_DIR}/tests/mocks)
@@ -72,6 +74,10 @@ add_qml_test(Panel Panel IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFA
7274add_qml_test(Panel SearchIndicator)
7375add_qml_test(Panel/Indicators DefaultIndicatorWidget IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
7476 ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
77+add_qml_test(Panel/Indicators DefaultIndicatorPage IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
78+ ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
79+add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
80+add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
7581add_qml_test(SideStage SideStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
7682 ${CMAKE_BINARY_DIR}/tests/mocks
7783 ${CMAKE_BINARY_DIR}/plugins)
tests/qmltests/Dash/CardHelpers.jsnew file+75
@@ -0,0 +1,75 @@
1+/*
2+ * Copyright (C) 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+.pragma library
18+
19+var components = ["title", "art", "subtitle", "mascot", "emblem", "old-price", "price", "alt-price", "rating", "alt-rating", "summary"]
20+
21+function tryParse(json, errorLabel) {
22+ var o = undefined;
23+ if (errorLabel !== undefined) {
24+ errorLabel.text = "";
25+ }
26+ try {
27+ o = JSON.parse(json)
28+ } catch(err) {
29+ if (errorLabel !== undefined) {
30+ errorLabel.text = err + "";
31+ } else {
32+ console.debug(err);
33+ }
34+ }
35+ return o;
36+}
37+
38+function mapData(json, layout, errorLabel) {
39+ var o = tryParse(json, errorLabel);
40+ var d = undefined;
41+
42+ if (o !== undefined) {
43+ d = Object();
44+ for (var k in components) {
45+ try {
46+ if (typeof layout[components[k]] == "object") {
47+ d[components[k]] = o[layout[components[k]]['field']];
48+ } else {
49+ d[components[k]] = o[layout[components[k]]];
50+ }
51+ } catch(err) {
52+ d[components[k]] = undefined;
53+ }
54+ }
55+ }
56+ return d;
57+}
58+
59+function update(object, overrides) {
60+ for (var k in overrides) {
61+ if (typeof object[k] == "string" && typeof overrides[k] == "object") {
62+ if (!overrides[k].hasOwnProperty('field')) overrides[k]['field'] = object[k];
63+ }
64+ if (object[k] === null) {
65+ object[k] = overrides[k];
66+ } else if (typeof object[k] == "object" && typeof overrides[k] == "string") {
67+ object[k]['field'] = overrides[k];
68+ } else if (typeof object[k] == "object") {
69+ update(object[k], overrides[k]);
70+ } else {
71+ object[k] = overrides[k];
72+ }
73+ }
74+ return object;
75+}
tests/qmltests/Dash/artwork/avatar@12.pngnew file

Binary file not shown.

tests/qmltests/Dash/artwork/music-player-design.pngnew file

Binary file not shown.

tests/qmltests/Dash/tst_Card.qmlnew file+337
@@ -0,0 +1,337 @@
1+/*
2+ * Copyright (C) 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 Ubuntu.Components 0.1
20+import Unity.Test 0.1 as UT
21+import "../../../qml/Dash"
22+import "CardHelpers.js" as Helpers
23+
24+Rectangle {
25+ id: root
26+ width: units.gu(80)
27+ height: units.gu(72)
28+ color: "#88FFFFFF"
29+
30+ property string defaultLayout: '
31+ {
32+ "schema-version": 1,
33+ "template": {
34+ "category-layout": "grid",
35+ "card-layout": "vertical",
36+ "card-size": "medium",
37+ "overlay-mode": null,
38+ "collapsed-rows": 2
39+ },
40+ "components": {
41+ "title": null,
42+ "art": {
43+ "aspect-ratio": 1.0,
44+ "fill-mode": "crop"
45+ },
46+ "subtitle": null,
47+ "mascot": null,
48+ "emblem": null,
49+ "old-price": null,
50+ "price": null,
51+ "alt-price": null,
52+ "rating": {
53+ "type": "stars",
54+ "range": [0, 5],
55+ "full": "image://theme/rating-star-full",
56+ "half": "image://theme/rating-star-half",
57+ "empty": "image://theme/rating-star-empty"
58+ },
59+ "alt-rating": null,
60+ "summary": null
61+ },
62+ "resources": {}
63+ }'
64+
65+ property string cardData: '
66+ {
67+ "art": "../../tests/qmltests/Dash/artwork/music-player-design.png",
68+ "mascot": "../../tests/qmltests/Dash/artwork/avatar.png",
69+ "title": "foo",
70+ "subtitle": "bar",
71+ "summary": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
72+ }'
73+
74+ property string fullMapping: '
75+ {
76+ "title": "title",
77+ "art": "art",
78+ "subtitle": "subtitle",
79+ "mascot": "mascot",
80+ "summary": "summary"
81+ }'
82+
83+ property var cardsModel: [
84+ {
85+ "name": "Art, header, summary - vertical",
86+ "layout": { "components": JSON.parse(fullMapping) }
87+ },
88+ {
89+ "name": "Art, header, summary - vertical, small",
90+ "layout": { "template": { "card-size": "small" }, "components": JSON.parse(fullMapping) }
91+ },
92+ {
93+ "name": "Art, header, summary - vertical, large",
94+ "layout": { "template": { "card-size": "large" }, "components": JSON.parse(fullMapping) }
95+ },
96+ {
97+ "name": "Art, header, summary - vertical, wide",
98+ "layout": { "components": Helpers.update(JSON.parse(root.fullMapping), { "art": { "aspect-ratio": 2 } }) }
99+ },
100+ {
101+ "name": "Art, title - vertical, fitted",
102+ "layout": { "components": Helpers.update(JSON.parse(root.fullMapping), { "art": { "fill-mode": "fit" } }) }
103+ },
104+ {
105+ "name": "Art, header, summary - horizontal",
106+ "layout": { "template": { "card-layout": "horizontal" },
107+ "components": JSON.parse(fullMapping) }
108+ },
109+ ]
110+
111+ Card {
112+ id: card
113+ anchors { top: parent.top; left: parent.left; margins: units.gu(1) }
114+
115+ template: Helpers.update(JSON.parse(root.defaultLayout), Helpers.tryParse(layoutArea.text, layoutError))['template'];
116+ components: Helpers.update(JSON.parse(root.defaultLayout), Helpers.tryParse(layoutArea.text, layoutError))['components'];
117+ cardData: Helpers.mapData(dataArea.text, components, dataError)
118+ }
119+
120+ Rectangle {
121+ anchors { top: parent.top; bottom: parent.bottom; right: parent.right}
122+ width: units.gu(40)
123+ color: "lightgrey"
124+
125+ Column {
126+ anchors { fill: parent; margins: units.gu(1) }
127+ spacing: units.gu(1)
128+
129+ OptionSelector {
130+ id: selector
131+ model: cardsModel
132+ delegate: OptionSelectorDelegate { text: modelData.name }
133+ onSelectedIndexChanged: updateAreas()
134+ Component.onCompleted: updateAreas()
135+
136+ function updateAreas() {
137+ var element = cardsModel[selectedIndex];
138+ if (element) {
139+ layoutArea.text = JSON.stringify(element.layout, undefined, 2) || "{}";
140+ // FIXME: don't overwrite data
141+ var data = JSON.parse(root.cardData);
142+ Helpers.update(data, element.data);
143+ dataArea.text = JSON.stringify(data, undefined, 2) || "{}";
144+ } else {
145+ layoutArea.text = "";
146+ dataArea.text = "";
147+ }
148+
149+ }
150+ }
151+
152+ TextArea {
153+ id: layoutArea
154+ anchors { left: parent.left; right: parent.right }
155+ height: units.gu(25)
156+ }
157+
158+ Label {
159+ id: layoutError
160+ anchors { left: parent.left; right: parent.right }
161+ height: units.gu(4)
162+ color: "orange"
163+ }
164+
165+ TextArea {
166+ id: dataArea
167+ anchors { left: parent.left; right: parent.right }
168+ height: units.gu(25)
169+ }
170+
171+ Label {
172+ id: dataError
173+ anchors { left: parent.left; right: parent.right }
174+ height: units.gu(4)
175+ color: "orange"
176+ }
177+ }
178+ }
179+
180+ UT.UnityTestCase {
181+ id: testCase
182+ name: "Card"
183+
184+ when: windowShown
185+
186+ property Item header: findChild(card, "cardHeader")
187+ property Item art: findChild(card, "artShape")
188+ property Item artImage: findChild(card, "artImage")
189+ property Item summary: findChild(card, "summaryLabel")
190+
191+ function initTestCase() {
192+ verify(testCase.header !== undefined, "Couldn't find header object.");
193+ }
194+
195+ function cleanup() {
196+ selector.selectedIndex = -1;
197+ }
198+
199+
200+ function test_header_binding_data() {
201+ return [
202+ { tag: "Mascot", property: "mascot", value: Qt.resolvedUrl("artwork/avatar.png"), index: 0 },
203+ { tag: "Title", property: "title", value: "foo", index: 0 },
204+ { tag: "Subtitle", property: "subtitle", value: "bar", index: 0 },
205+ ];
206+ }
207+
208+ function test_header_binding(data) {
209+ selector.selectedIndex = data.index;
210+ tryCompare(testCase.header, data.property, data.value);
211+ }
212+
213+ function test_card_binding_data() {
214+ return [
215+ { tag: "Art", object: artImage, property: "source", value: Qt.resolvedUrl("artwork/music-player-design.png"), index: 0 },
216+ { tag: "Summary", object: summary, property: "text", field: "summary", index: 0 },
217+ { tag: "Fit", object: art, fill: Image.PreserveAspectFit, index: 4 },
218+ ];
219+ }
220+
221+ function test_card_binding(data) {
222+ selector.selectedIndex = data.index;
223+
224+ if (data.hasOwnProperty('value')) {
225+ tryCompare(data.object, data.property, data.value);
226+ }
227+
228+ if (data.hasOwnProperty('field')) {
229+ tryCompare(data.object, data.property, card.cardData[data.field]);
230+ }
231+ }
232+
233+ function test_card_size_data() {
234+ return [
235+ { tag: "Medium", width: units.gu(18.5), index: 0 },
236+ { tag: "Small", width: units.gu(12), size: "small", index: 0 },
237+ { tag: "Large", width: units.gu(38), size: "large", index: 0 },
238+ { tag: "Wide", width: units.gu(18.5), aspect: 0.5, index: 0 },
239+ { tag: "Horizontal", width: units.gu(38), index: 5 },
240+ ]
241+ }
242+
243+ function test_card_size(data) {
244+ selector.selectedIndex = data.index;
245+
246+ if (data.hasOwnProperty("size")) {
247+ card.template['card-size'] = data.size;
248+ card.templateChanged();
249+ }
250+
251+ if (data.hasOwnProperty("aspect")) {
252+ card.components['art']['aspect-ratio'] = data.aspect;
253+ card.componentsChanged();
254+ }
255+
256+ if (data.hasOwnProperty("width")) {
257+ tryCompare(card, "width", data.width);
258+ }
259+
260+ if (data.hasOwnProperty("height")) {
261+ tryCompare(card, "height", data.height);
262+ }
263+ }
264+
265+ function test_art_size_data() {
266+ return [
267+ { tag: "Medium", width: units.gu(18.5), fill: Image.PreserveAspectCrop, index: 0 },
268+ { tag: "Small", width: units.gu(12), index: 1 },
269+ { tag: "Large", width: units.gu(38), index: 2 },
270+ { tag: "Wide", height: units.gu(19), size: "large", index: 3 },
271+ { tag: "Fit", height: units.gu(38), size: "large", width: units.gu(19), index: 4 },
272+ { tag: "VerticalWidth", width: function() { return header.width }, index: 0 },
273+ { tag: "HorizontalHeight", height: function() { return header.height }, index: 5 },
274+ { tag: "HorizontalWidth", width: function() { return header.x }, index: 5 },
275+ ]
276+ }
277+
278+ function test_art_size(data) {
279+ selector.selectedIndex = data.index;
280+
281+ if (data.hasOwnProperty("size")) {
282+ card.template['card-size'] = data.size;
283+ card.templateChanged();
284+ }
285+
286+ if (data.hasOwnProperty("aspect")) {
287+ card.components['art']['aspect-ratio'] = data.aspect;
288+ card.componentsChanged();
289+ }
290+
291+ if (data.hasOwnProperty("width")) {
292+ if (typeof data.width === "function") {
293+ tryCompareFunction(function() { return art.width === data.width() }, true);
294+ } else tryCompare(art, "width", data.width);
295+ }
296+
297+ if (data.hasOwnProperty("height")) {
298+ if (typeof data.height === "function") {
299+ tryCompareFunction(function() { return art.height === data.height() }, true);
300+ } else tryCompare(art, "height", data.height);
301+ }
302+
303+ if (data.hasOwnProperty("fill")) {
304+ tryCompare(artImage, "fillMode", data.fill);
305+ }
306+ }
307+
308+ function test_art_layout_data() {
309+ return [
310+ { tag: "Vertical", left: function() { return 0 }, index: 0},
311+ { tag: "Horizontal", left: function() { return art.width }, index: 5 }
312+ ];
313+ }
314+
315+ function test_art_layout(data) {
316+ selector.selectedIndex = data.index;
317+
318+ tryCompare(testCase.header, "x", data.left());
319+ }
320+
321+ function test_header_layout_data() {
322+ return [
323+ { tag: "Vertical", top: function() { return art.y + art.height },
324+ left: function() { return art.x }, index: 0 },
325+ { tag: "Horizontal", top: function() { return art.y },
326+ left: function() { return art.x + art.width }, index: 5 }
327+ ]
328+ }
329+
330+ function test_header_layout(data) {
331+ selector.selectedIndex = data.index;
332+
333+ tryCompareFunction(function() { return testCase.header.y === data.top() }, true);
334+ tryCompareFunction(function() { return testCase.header.x === data.left() }, true);
335+ }
336+ }
337+}
tests/qmltests/Dash/tst_CardHeader.qmlnew file+138
@@ -0,0 +1,138 @@
1+/*
2+ * Copyright (C) 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 Ubuntu.Components 0.1
20+import Unity.Test 0.1 as UT
21+import "../../../qml/Dash"
22+
23+
24+Rectangle {
25+ width: units.gu(40)
26+ height: units.gu(72)
27+ color: "lightgrey"
28+
29+ CardHeader {
30+ id: cardHeader
31+ anchors { left: parent.left; right: parent.right }
32+ }
33+
34+ Rectangle {
35+ anchors.fill: cardHeader
36+ color: "lightblue"
37+ opacity: 0.5
38+ }
39+
40+ UT.UnityTestCase {
41+ id: testCase
42+ name: "CardHeader"
43+
44+ when: windowShown
45+
46+ property Item mascot: findChild(cardHeader, "mascotShape")
47+ property Item titleLabel: findChild(cardHeader, "titleLabel")
48+ property Item subtitleLabel: findChild(cardHeader, "subtitleLabel")
49+ property Item prices: findChild(cardHeader, "prices")
50+ property Item oldPriceLabel: findChild(cardHeader, "oldPriceLabel")
51+ property Item outerRow: findChild(cardHeader, "outerRow")
52+ property Item column: findChild(cardHeader, "column")
53+
54+ function initTestCase() {
55+ verify(testCase.mascot !== undefined, "Couldn't find mascot object.");
56+ verify(testCase.titleLabel !== undefined, "Couldn't find titleLabel object.");
57+ verify(testCase.subtitleLabel !== undefined, "Couldn't find subtitleLabel object.");
58+ verify(testCase.prices !== undefined, "Couldn't find prices object.");
59+ verify(testCase.oldPriceLabel !== undefined, "Couldn't find oldPriceLabel object.");
60+ }
61+
62+ function cleanup() {
63+ cardHeader.mascot = "";
64+ cardHeader.title = "";
65+ cardHeader.subtitle = "";
66+ cardHeader.price = "";
67+ cardHeader.oldPrice = "";
68+ cardHeader.altPrice = "";
69+ }
70+
71+ function test_mascot_data() {
72+ return [
73+ { tag: "Empty", source: "", visible: false },
74+ { tag: "Invalid", source: "bad_path", visible: false },
75+ { tag: "Valid", source: Qt.resolvedUrl("artwork/avatar.png"), visible: true },
76+ ]
77+ }
78+
79+ function test_mascot(data) {
80+ cardHeader.mascot = data.source;
81+ tryCompare(testCase.mascot, "visible", data.visible);
82+ }
83+
84+ function test_labels_data() {
85+ return [
86+ { tag: "Empty", visible: false },
87+ { tag: "Title only", title: "Foo", visible: true },
88+ { tag: "Subtitle only", subtitle: "Bar", visible: false },
89+ { tag: "Both", title: "Foo", subtitle: "Bar", visible: true }
90+ ]
91+ }
92+
93+ function test_labels(data) {
94+ cardHeader.title = data.title !== undefined ? data.title : "";
95+ cardHeader.subtitle = data.subtitle !== undefined ? data.subtitle : "";
96+ tryCompare(cardHeader, "visible", data.visible);
97+ }
98+
99+ function test_prices_data() {
100+ return [
101+ { tag: "Main", main: "$1.25", visible: true },
102+ { tag: "Alt", alt: "€1.00", visible: false },
103+ { tag: "Old", old: "€2.00", visible: false },
104+ { tag: "Main and Alt", main: "$1.25", alt: "€1.00", visible: true },
105+ { tag: "Main and Old", main: "$1.25", old: "$2.00", visible: true, oldAlign: Text.AlignRight },
106+ { tag: "Alt and Old", alt: "€1.00", old: "$2.00", visible: false },
107+ { tag: "All", main: "$1.25", alt: "€1.00", old: "$2.00", visible: true, oldAlign: Text.AlignHCenter }
108+ ]
109+ }
110+
111+ function test_prices(data) {
112+ cardHeader.price = data.main !== undefined ? data.main : "";
113+ cardHeader.oldPrice = data.old !== undefined ? data.old : "";
114+ cardHeader.altPrice = data.alt !== undefined ? data.alt : "";
115+ tryCompare(cardHeader, "visible", data.visible);
116+ if (data.hasOwnProperty("oldAlign")) {
117+ compare(testCase.oldPriceLabel.horizontalAlignment, data.oldAlign, "Old price label is aligned wrong.")
118+ }
119+ }
120+
121+ function test_dimensions_data() {
122+ return [
123+ { tag: "Column width", object: column, width: cardHeader.width - testCase.outerRow.spacing * 2 },
124+ { tag: "Column width", object: column, width: cardHeader.width - mascot.width - testCase.outerRow.spacing * 3, mascot: "artwork/avatar.png" }
125+ ]
126+ }
127+
128+ function test_dimensions(data) {
129+ if (data.hasOwnProperty("mascot")) {
130+ cardHeader.mascot = data.mascot;
131+ }
132+
133+ if (data.hasOwnProperty("width")) {
134+ tryCompare(data.object, "width", data.width);
135+ }
136+ }
137+ }
138+}
tests/qmltests/Panel/Indicators/tst_DefaultIndicatorPage.qmlnew file+179
@@ -0,0 +1,179 @@
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 QMenuModel 0.1
21+import "../../../../qml/Panel/Indicators"
22+
23+Item {
24+ id: testView
25+ width: units.gu(40)
26+ height: units.gu(70)
27+
28+ DefaultIndicatorPage {
29+ id: page
30+
31+ anchors.fill: parent
32+ contentActive: true
33+
34+ busName: "test"
35+ actionsObjectPath: "test"
36+ menuObjectPath: "test"
37+
38+ rootMenuType: ""
39+ }
40+
41+ property var fullMenuData: [{
42+ "rowData": { // 1
43+ "label": "root",
44+ "sensitive": true,
45+ "isSeparator": false,
46+ "icon": "",
47+ "type": "com.canonical.indicator.root",
48+ "ext": {},
49+ "action": "",
50+ "actionState": {},
51+ "isCheck": false,
52+ "isRadio": false,
53+ "isToggled": false,
54+ },
55+ "submenu": [{
56+ "rowData": { // 1.1
57+ "label": "menu1",
58+ "sensitive": true,
59+ "isSeparator": false,
60+ "icon": "",
61+ "type": "",
62+ "ext": {},
63+ "action": "",
64+ "actionState": {},
65+ "isCheck": false,
66+ "isRadio": false,
67+ "isToggled": false,
68+ }}, {
69+ "rowData": { // 1.2
70+ "label": "menu2",
71+ "sensitive": true,
72+ "isSeparator": false,
73+ "icon": "",
74+ "type": "",
75+ "ext": {},
76+ "action": "",
77+ "actionState": {},
78+ "isCheck": false,
79+ "isRadio": false,
80+ "isToggled": false,
81+ }}, {
82+ "rowData": { // row 1.2
83+ "label": "menu3",
84+ "sensitive": true,
85+ "isSeparator": false,
86+ "icon": "",
87+ "type": "",
88+ "ext": {},
89+ "action": "",
90+ "actionState": {},
91+ "isCheck": false,
92+ "isRadio": false,
93+ "isToggled": false,
94+ }}
95+ ]
96+ }]; // end row 1
97+
98+ property var emptySubMenuData: [{
99+ "rowData": { // 1
100+ "label": "root",
101+ "sensitive": true,
102+ "isSeparator": false,
103+ "icon": "",
104+ "type": "com.canonical.indicator.root",
105+ "ext": {},
106+ "action": "",
107+ "actionState": {},
108+ "isCheck": false,
109+ "isRadio": false,
110+ "isToggled": false,
111+ },
112+ "submenu": []
113+ }]; // end row 1
114+
115+ UT.UnityTestCase {
116+ name: "DefaultIndicatorPage"
117+
118+ function init() {
119+ page.stop();
120+ var mainMenu = findChild(page, "mainMenu");
121+ verify(mainMenu.model === undefined);
122+
123+ page.rootMenuType = "com.canonical.indicator.root";
124+ page.start();
125+
126+ verify(mainMenu.model !== null);
127+ }
128+
129+ function test_reloadData() {
130+ var mainMenu = findChild(page, "mainMenu");
131+
132+ console.log("setting empty data");
133+ page.menuModel.modelData = [];
134+ tryCompare(mainMenu, "count", 0);
135+ console.log("set empty data");
136+
137+ console.log("setting full data");
138+ page.menuModel.modelData = fullMenuData;
139+ console.log("set full data");
140+ tryCompare(mainMenu, "count", 3);
141+
142+ page.menuModel.modelData = [];
143+ tryCompare(mainMenu, "count", 0);
144+
145+ page.menuModel.modelData = fullMenuData;
146+ tryCompare(mainMenu, "count", 3);
147+ }
148+
149+ function test_traverse_rootMenuType_data() {
150+ return [
151+ { tag: "Incorrect", rootMenuType: "com.canonical.indicator", expectedCount: 0},
152+ { tag: "Correct", rootMenuType: "com.canonical.indicator.root", expectedCount: 3},
153+ ]
154+ }
155+
156+ function test_traverse_rootMenuType(data) {
157+ page.rootMenuType = data.rootMenuType;
158+ page.menuModel.modelData = fullMenuData;
159+
160+ var mainMenu = findChild(page, "mainMenu");
161+ tryCompare(mainMenu, "count", data.expectedCount);
162+ }
163+
164+ function test_empty_data() {
165+ return [
166+ { tag: "EmptyNoData", modelData: [], visible: true},
167+ { tag: "EmptySubmenu", modelData: emptySubMenuData, visible: true},
168+ { tag: "NotEmpty", modelData: fullMenuData, visible: false},
169+ ]
170+ }
171+
172+ function test_empty(data) {
173+ page.menuModel.modelData = data.modelData;
174+
175+ var emptyLabel = findChild(page, "emptyLabel");
176+ tryCompare(emptyLabel, "visible", data.visible);
177+ }
178+ }
179+}
tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qmlnew file+369
@@ -0,0 +1,369 @@
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 QMenuModel 0.1
21+import Unity.Indicators 0.1 as Indicators
22+
23+Item {
24+ id: testView
25+ width: units.gu(40)
26+ height: units.gu(70)
27+
28+ Indicators.MenuItemFactory {
29+ id: factory
30+ menuModel: UnityMenuModel {}
31+ }
32+
33+ Loader {
34+ id: loader
35+ property int modelIndex: 0
36+ property var data
37+
38+ onLoaded: {
39+ if (item.hasOwnProperty("menuData")) {
40+ item.menuData = data;
41+ }
42+ }
43+ }
44+
45+ UT.UnityTestCase {
46+ name: "MenuItemFactory"
47+
48+ property QtObject menuData: QtObject {
49+ property string label: "root"
50+ property bool sensitive: true
51+ property bool isSeparator: false
52+ property string icon: ""
53+ property string type: ""
54+ property var ext: undefined
55+ property string action: ""
56+ property var actionState: undefined
57+ property bool isCheck: false
58+ property bool isRadio: false
59+ property bool isToggled: false
60+ }
61+
62+ function init() {
63+ menuData.label = "";
64+ menuData.sensitive = true;
65+ menuData.isSeparator = false;
66+ menuData.icon = "";
67+ menuData.type = "";
68+ menuData.ext = undefined;
69+ menuData.action = "";
70+ menuData.actionState = undefined;
71+ menuData.isCheck = false;
72+ menuData.isRadio = false;
73+ menuData.isToggled = false;
74+
75+ loader.sourceComponent = null;
76+ loader.data = undefined;
77+
78+ verify(loader.item == null);
79+ }
80+
81+ function test_createTypes_data() {
82+ return [
83+ { tag: 'volume', type: "unity.widgets.systemsettings.tablet.volumecontrol", objectName: "sliderMenu" },
84+ { tag: 'switch1', type: "unity.widgets.systemsettings.tablet.switch", objectName: "switchMenu" },
85+
86+ { tag: 'button', type: "com.canonical.indicator.button", objectName: "buttonMenu" },
87+ { tag: 'separator', type: "com.canonical.indicator.div", objectName: "divMenu" },
88+ { tag: 'section', type: "com.canonical.indicator.section", objectName: "sectionMenu" },
89+ { tag: 'progress', type: "com.canonical.indicator.progress", objectName: "progressMenu" },
90+ { tag: 'slider1', type: "com.canonical.indicator.slider", objectName: "sliderMenu" },
91+ { tag: 'switch2', type: "com.canonical.indicator.switch", objectName: "switchMenu" },
92+
93+ { tag: 'messageItem', type: "com.canonical.indicator.messages.messageitem", objectName: "messageItem" },
94+ { tag: 'sourceItem', type: "com.canonical.indicator.messages.sourceitem", objectName: "groupedMessage" },
95+
96+ { tag: 'slider2', type: "com.canonical.unity.slider", objectName: "sliderMenu" },
97+ { tag: 'switch3', type: "com.canonical.unity.switch", objectName: "switchMenu" },
98+
99+ { tag: 'mediaplayer', type: "com.canonical.unity.media-player", objectName: "standardMenu" },
100+ { tag: 'playbackitem', type: "com.canonical.unity.playback-item", objectName: "standardMenu" },
101+
102+ { tag: 'wifisection', type: "unity.widgets.systemsettings.tablet.wifisection", objectName: "wifiSection" },
103+ { tag: 'accesspoint', type: "unity.widgets.systemsettings.tablet.accesspoint", objectName: "accessPoint" },
104+
105+ { tag: 'unknown', type: "", objectName: "standardMenu"}
106+ ];
107+ }
108+
109+ function test_createTypes(data) {
110+ menuData.type = data.type;
111+
112+ loader.data = menuData;
113+ loader.sourceComponent = factory.load(menuData);
114+ tryCompareFunction(function() { return loader.item != undefined; }, true);
115+ compare(loader.item.objectName, data.objectName, "Created object name does not match intended object (" + loader.item.objectName + " != " + data.objectName + ")");
116+ }
117+
118+ function test_create_radio() {
119+ skip("No radio component");
120+ menuData.isRadio = true;
121+
122+ loader.data = menuData;
123+ loader.sourceComponent = factory.load(menuData);
124+ tryCompareFunction(function() { return loader.item != undefined; }, true);
125+ compare(loader.item.objectName, "checkableMenu", "Should have created a checkable menu");
126+ }
127+
128+ function test_create_separator() {
129+ menuData.isSeparator = true;
130+
131+ loader.data = menuData;
132+ loader.sourceComponent = factory.load(menuData);
133+ tryCompareFunction(function() { return loader.item != undefined; }, true);
134+ compare(loader.item.objectName, "divMenu", "Should have created a separator menu");
135+ }
136+
137+ function test_create_sliderMenu_data() {
138+ return [
139+ {label: "testLabel1", enabled: false, minValue: 0, maxValue: 100, value: 10.5 },
140+ {label: "testLabel2", enabled: true, minValue: 0, maxValue: 100, value: 100 },
141+ ];
142+ }
143+
144+ function test_create_sliderMenu(data) {
145+ menuData.type = "com.canonical.indicator.slider"
146+ menuData.label = data.label;
147+ menuData.sensitive = data.enabled;
148+ menuData.actionState = data.value;
149+ menuData.ext = {
150+ 'minIcon': "file:///testMinIcon",
151+ 'maxIcon': "file:///testMaxIcon",
152+ 'minValue': data.minValue,
153+ 'maxValue': data.maxValue
154+ };
155+
156+ loader.data = menuData;
157+ loader.sourceComponent = factory.load(menuData);
158+ tryCompareFunction(function() { return loader.item != undefined; }, true);
159+ compare(loader.item.objectName, "sliderMenu", "Should have created a slider menu");
160+
161+ compare(loader.item.text, data.label, "Label does not match data");
162+ compare(loader.item.minIcon, "file:///testMinIcon", "MinIcon does not match data");
163+ compare(loader.item.maxIcon, "file:///testMaxIcon", "MaxIcon does not match data");
164+ compare(loader.item.minimumValue, data.minValue, "MinValue does not match data");
165+ compare(loader.item.maximumValue, data.maxValue, "MaxValue does not match data");
166+ compare(loader.item.value, data.value, "Calue does not match data");
167+ compare(loader.item.enabled, data.enabled, "Enabled does not match data");
168+ }
169+
170+ function test_create_buttonMenu_data() {
171+ return [
172+ {label: "testLabel1", enabled: false },
173+ {label: "testLabel2", enabled: true },
174+ ];
175+ }
176+
177+ function test_create_buttonMenu(data) {
178+ menuData.type = "com.canonical.indicator.button"
179+ menuData.label = data.label;
180+ menuData.sensitive = data.enabled;
181+
182+ loader.data = menuData;
183+ loader.sourceComponent = factory.load(menuData);
184+ tryCompareFunction(function() { return loader.item != undefined; }, true);
185+ compare(loader.item.objectName, "buttonMenu", "Should have created a button menu");
186+
187+ compare(loader.item.buttonText, data.label, "Label does not match data");
188+ compare(loader.item.enabled, data.enabled, "Enabled does not match data");
189+ }
190+
191+ function test_create_sectionMenu_data() {
192+ return [
193+ {label: "testLabel1" },
194+ {label: "testLabel2" },
195+ ];
196+ }
197+
198+ function test_create_sectionMenu(data) {
199+ menuData.type = "com.canonical.indicator.section"
200+ menuData.label = data.label;
201+
202+ loader.data = menuData;
203+ loader.sourceComponent = factory.load(menuData);
204+ tryCompareFunction(function() { return loader.item != undefined; }, true);
205+ compare(loader.item.objectName, "sectionMenu", "Should have created a section menu");
206+
207+ compare(loader.item.text, data.label, "Label does not match data");
208+ }
209+
210+ function test_create_progressMenu_data() {
211+ return [
212+ {label: "testLabel1", enabled: true, value: 10 },
213+ {label: "testLabel2", enabled: false, value: 55 },
214+ ];
215+ }
216+
217+ function test_create_progressMenu(data) {
218+ menuData.type = "com.canonical.indicator.progress"
219+ menuData.label = data.label;
220+ menuData.sensitive = data.enabled;
221+ menuData.actionState = data.value;
222+
223+ loader.data = menuData;
224+ loader.sourceComponent = factory.load(menuData);
225+ tryCompareFunction(function() { return loader.item != undefined; }, true);
226+ compare(loader.item.objectName, "progressMenu", "Should have created a progress menu");
227+
228+ compare(loader.item.text, data.label, "Label does not match data");
229+ compare(loader.item.value, data.value, "Value does not match data");
230+ compare(loader.item.enabled, data.enabled, "Enabled does not match data");
231+ }
232+
233+ function test_create_standardMenu_data() {
234+ return [
235+ {label: "testLabel1", enabled: true, icon: "file:///testIcon" },
236+ {label: "testLabel2", enabled: false, icon: "file:///testIcon2"},
237+ ];
238+ }
239+
240+ function test_create_standardMenu(data) {
241+ menuData.type = ""
242+ menuData.label = data.label;
243+ menuData.sensitive = data.enabled;
244+ menuData.icon = data.icon;
245+
246+ loader.data = menuData;
247+ loader.sourceComponent = factory.load(menuData);
248+ tryCompareFunction(function() { return loader.item != undefined; }, true);
249+ compare(loader.item.objectName, "standardMenu", "Should have created a standard menu");
250+
251+ compare(loader.item.text, data.label, "Label does not match data");
252+ compare(loader.item.iconSource, data.icon, "MaxIcon does not match data");
253+ compare(loader.item.enabled, data.enabled, "Enabled does not match data");
254+ }
255+
256+ function test_create_switchMenu_data() {
257+ return [
258+ {label: "testLabel1", enabled: true, checked: false },
259+ {label: "testLabel2", enabled: false, checked: true },
260+ ];
261+ }
262+
263+ function test_create_switchMenu(data) {
264+ menuData.type = "com.canonical.indicator.switch";
265+ menuData.label = data.label;
266+ menuData.sensitive = data.enabled;
267+ menuData.icon = "file:///testIcon";
268+ menuData.isToggled = data.checked;
269+
270+ loader.data = menuData;
271+ loader.sourceComponent = factory.load(menuData);
272+ tryCompareFunction(function() { return loader.item != undefined; }, true);
273+ compare(loader.item.objectName, "switchMenu", "Should have created a standard menu");
274+
275+ compare(loader.item.text, data.label, "Label does not match data");
276+ compare(loader.item.icon, "file:///testIcon", "MaxIcon does not match data");
277+ compare(loader.item.checked, data.checked, "Checked does not match data");
278+ compare(loader.item.enabled, data.enabled, "Enabled does not match data");
279+ }
280+
281+ function test_create_wifiSection_data() {
282+ return [
283+ {label: "testLabel1", busy: false },
284+ {label: "testLabel2", busy: true },
285+ ];
286+ }
287+
288+ function test_create_wifiSection(data) {
289+ menuData.type = "unity.widgets.systemsettings.tablet.wifisection";
290+ menuData.label = data.label;
291+ menuData.ext = { 'xCanonicalBusyAction': data.busy }
292+
293+ loader.data = menuData;
294+ loader.sourceComponent = factory.load(menuData);
295+ tryCompareFunction(function() { return loader.item != undefined; }, true);
296+ compare(loader.item.objectName, "wifiSection", "Should have created a wifi section menu");
297+
298+ compare(loader.item.text, data.label, "Label does not match data");
299+ compare(loader.item.busy, data.busy, "Busy does not match data");
300+ }
301+
302+ function test_create_accessPoint_data() {
303+ return [
304+ {label: "testLabel1", enabled: true, checked: false, secure: true, adHoc: false },
305+ {label: "testLabel2", enabled: false, checked: true, secure: false, adHoc: true },
306+ ];
307+ }
308+
309+ function test_create_accessPoint(data) {
310+ menuData.type = "unity.widgets.systemsettings.tablet.accesspoint";
311+ menuData.label = data.label;
312+ menuData.sensitive = data.enabled;
313+ menuData.isToggled = data.checked;
314+ menuData.ext = {
315+ 'xCanonicalWifiApStrengthAction': "action::strength",
316+ 'xCanonicalWifiApIsSecure': data.secure,
317+ 'xCanonicalWifiApIsAdhoc': data.adHoc,
318+ };
319+
320+ loader.data = menuData;
321+ loader.sourceComponent = factory.load(menuData);
322+ tryCompareFunction(function() { return loader.item != undefined; }, true);
323+ compare(loader.item.objectName, "accessPoint", "Should have created a access point menu");
324+
325+ compare(loader.item.label, data.label, "Label does not match data");
326+ compare(loader.item.strengthAction.name, "action::strength", "Strength action incorrect");
327+ compare(loader.item.secure, data.secure, "Secure does not match data");
328+ compare(loader.item.adHoc, data.adHoc, "AdHoc does not match data");
329+ compare(loader.item.checked, data.checked, "Checked does not match data");
330+ compare(loader.item.enabled, data.enabled, "Enabled does not match data");
331+ }
332+
333+ function test_create_messageItem() {
334+ menuData.type = "com.canonical.indicator.messages.messageitem";
335+
336+ loader.data = menuData;
337+ loader.sourceComponent = factory.load(menuData);
338+ tryCompareFunction(function() { return loader.item != undefined; }, true);
339+ compare(loader.item.objectName, "messageItem", "Should have created a message menu");
340+ }
341+
342+ function test_create_groupedMessage_data() {
343+ return [
344+ {label: "testLabel1", enabled: true, count: "5", appIcon: "file:///testIcon" },
345+ {label: "testLabel2", enabled: false, count: "10", appIcon: "file:///testIcon2" },
346+ ];
347+ }
348+
349+ function test_create_groupedMessage(data) {
350+ menuData.type = "com.canonical.indicator.messages.sourceitem";
351+ menuData.label = data.label;
352+ menuData.sensitive = data.enabled;
353+ menuData.icon = data.appIcon;
354+ menuData.ext = { 'icon': data.appIcon };
355+ menuData.actionState = [data.count];
356+ menuData.isToggled = true;
357+
358+ loader.data = menuData;
359+ loader.sourceComponent = factory.load(menuData);
360+ tryCompareFunction(function() { return loader.item != undefined; }, true);
361+ compare(loader.item.objectName, "groupedMessage", "Should have created a group message menu");
362+
363+ compare(loader.item.title, data.label, "Label does not match data");
364+ compare(loader.item.count, data.count, "Count does not match data");
365+ compare(loader.item.appIcon, data.appIcon, "App Icon does not match data");
366+ compare(loader.item.enabled, data.enabled, "Enabled does not match data");
367+ }
368+ }
369+}
tests/qmltests/Panel/Indicators/tst_MessageMenuItemFactory.qmlnew file+177
@@ -0,0 +1,177 @@
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 QMenuModel 0.1
21+import Unity.Indicators.Messaging 0.1 as Indicators
22+
23+Item {
24+ id: testView
25+ width: units.gu(40)
26+ height: units.gu(70)
27+
28+ Indicators.MessageMenuItemFactory {
29+ id: factory
30+ menuModel: UnityMenuModel {}
31+ menuIndex: 0
32+ }
33+
34+ UT.UnityTestCase {
35+ name: "MessageMenuItemFactory"
36+
37+ property QtObject menuData: QtObject {
38+ property string label: "root"
39+ property bool sensitive: true
40+ property bool isSeparator: false
41+ property string icon: ""
42+ property string type: ""
43+ property var ext: undefined
44+ property string action: ""
45+ property var actionState: undefined
46+ property bool isCheck: false
47+ property bool isRadio: false
48+ property bool isToggled: false
49+ }
50+
51+ function init() {
52+ menuData.label = "";
53+ menuData.sensitive = true;
54+ menuData.isSeparator = false;
55+ menuData.icon = "";
56+ menuData.type = "";
57+ menuData.ext = undefined;
58+ menuData.action = "";
59+ menuData.actionState = undefined;
60+ menuData.isCheck = false;
61+ menuData.isRadio = false;
62+ menuData.isToggled = false;
63+
64+ factory.menuData = null;
65+ }
66+
67+ function test_create_simpleTextmessage_data() {
68+ return [
69+ { title: "Title1", time: new Date(2013, 10, 10).getTime()*1000, message: "This is a text message 1", avatar: "file:///avatar1", appIcon: "file:///appIcon1", enabled: true},
70+ { title: "Title2", time: new Date(2014, 12, 10).getTime()*1000, message: "This is a text message 2", avatar: "file:///avatar2", appIcon: "file:///appIcon2", enabled: false},
71+ ];
72+ }
73+
74+ function test_create_simpleTextmessage(data) {
75+ menuData.type = "com.canonical.indicator.messages.messageitem";
76+ menuData.label = data.title;
77+ menuData.sensitive = data.enabled;
78+ menuData.ext = {
79+ 'xCanonicalTime': data.time,
80+ 'xCanonicalText': data.message,
81+ 'icon': data.avatar,
82+ 'xCanonicalAppIcon': data.appIcon,
83+ };
84+ factory.menuData = menuData;
85+
86+ var loader = findChild(factory, "loader");
87+ verify(loader !== undefined);
88+
89+ tryCompare(loader.item, "objectName", "simpleTextMessage");
90+ compare(loader.item.title, data.title, "Title does not match data");
91+ compare(loader.item.time, data.time, "Time does not match data");
92+ compare(loader.item.message, data.message, "Message does not match data");
93+ compare(loader.item.avatar, data.avatar, "Avatar does not match data");
94+ compare(loader.item.appIcon, data.appIcon, "App icon does not match data");
95+ compare(loader.item.enabled, data.enabled, "Enabled does not match data");
96+ }
97+
98+ function test_create_textmessage_data() {
99+ return [
100+ { title: "Title1", time: new Date(2013, 10, 10).getTime()*1000, message: "This is a text message 1", avatar: "file:///avatar1", appIcon: "file:///appIcon1", enabled: true},
101+ { title: "Title2", time: new Date(2014, 12, 10).getTime()*1000, message: "This is a text message 2", avatar: "file:///avatar2", appIcon: "file:///appIcon2", enabled: false},
102+ ];
103+ }
104+
105+ function test_create_textmessage(data) {
106+ menuData.type = "com.canonical.indicator.messages.messageitem";
107+ menuData.label = data.title;
108+ menuData.sensitive = data.enabled;
109+ menuData.ext = {
110+ 'xCanonicalTime': data.time,
111+ 'xCanonicalText': data.message,
112+ 'icon': data.avatar,
113+ 'xCanonicalAppIcon': data.appIcon,
114+ 'xCanonicalMessageActions': [{
115+ 'parameter-type': "s",
116+ 'name': "action::reply",
117+ 'label': "Reply1"
118+ }
119+ ]
120+ };
121+ factory.menuData = menuData;
122+
123+ var loader = findChild(factory, "loader");
124+ verify(loader !== undefined);
125+
126+ tryCompare(loader.item, "objectName", "textMessage");
127+ compare(loader.item.title, data.title, "Title does not match data");
128+ compare(loader.item.time, data.time, "Time does not match data");
129+ compare(loader.item.message, data.message, "Message does not match data");
130+ compare(loader.item.avatar, data.avatar, "Avatar does not match data");
131+ compare(loader.item.appIcon, data.appIcon, "App icon does not match data");
132+ compare(loader.item.enabled, data.enabled, "Enabled does not match data");
133+ }
134+
135+
136+ function test_create_snapDecision_data() {
137+ return [
138+ { title: "Title1", time: new Date(2013, 10, 10).getTime()*1000, message: "This is a text message 1", avatar: "file:///avatar1", appIcon: "file:///appIcon1", enabled: true},
139+ { title: "Title2", time: new Date(2014, 12, 10).getTime()*1000, message: "This is a text message 2", avatar: "file:///avatar2", appIcon: "file:///appIcon2", enabled: false},
140+ ];
141+ }
142+
143+ function test_create_snapDecision(data) {
144+ menuData.type = "com.canonical.indicator.messages.messageitem";
145+ menuData.label = data.title;
146+ menuData.sensitive = data.enabled;
147+ menuData.ext = {
148+ 'xCanonicalTime': data.time,
149+ 'xCanonicalText': data.message,
150+ 'icon': data.avatar,
151+ 'xCanonicalAppIcon': data.appIcon,
152+ 'xCanonicalMessageActions': [{
153+ 'name': "action::callback",
154+ 'label': "Callback1"
155+ },{
156+ 'parameter-type': "s",
157+ 'name': "action::reply",
158+ 'label': "Reply1"
159+ }
160+ ]
161+ };
162+ factory.menuData = menuData;
163+
164+ var loader = findChild(factory, "loader");
165+ verify(loader !== undefined);
166+
167+ tryCompare(loader.item, "objectName", "snapDecision");
168+ compare(loader.item.title, data.title, "Title does not match data");
169+ compare(loader.item.time, data.time, "Time does not match data");
170+ compare(loader.item.message, data.message, "Message does not match data");
171+ compare(loader.item.avatar, data.avatar, "Avatar does not match data");
172+ compare(loader.item.appIcon, data.appIcon, "App icon does not match data");
173+ compare(loader.item.enabled, data.enabled, "Enabled does not match data");
174+ }
175+
176+ }
177+}