on xenial help sign in
Merge
730e254Albert Astals
@@ -166,3 +166,32 @@ $ make tryDragHandle
166NB: Manual test or interation doesn't make sense for all components or classes,
166NB: Manual test or interation doesn't make sense for all components or classes,
167particularly the non-graphical ones. In such cases no "tryFoo" make target is
167particularly the non-graphical ones. In such cases no "tryFoo" make target is
168provided.
168provided.
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)
4 add_custom_target(autopilot-${TEST_NAME}
4 add_custom_target(autopilot-${TEST_NAME}
5 COMMAND LANG=C UBUNTU_ICON_THEME=ubuntu-mobile QML2_IMPORT_PATH=${SHELL_INSTALL_QML}/mocks autopilot run ${TEST_SUITE}
5 COMMAND LANG=C UBUNTU_ICON_THEME=ubuntu-mobile QML2_IMPORT_PATH=${SHELL_INSTALL_QML}/mocks autopilot run ${TEST_SUITE}
6 WORKING_DIRECTORY ${WORKING_DIR}
6 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
8 )
12 )
9
13
10 add_dependencies(autopilot autopilot-${TEST_NAME})
14 add_dependencies(autopilot autopilot-${TEST_NAME})
debian/control+1
@@ -104,6 +104,7 @@ Depends: gir1.2-glib-2.0,
104 libqt5widgets5,
104 libqt5widgets5,
105 python-evdev,
105 python-evdev,
106 python-gi,
106 python-gi,
107+ python-mock,
107 unity8 (>= ${source:Version}),
108 unity8 (>= ${source:Version}),
108 unity8-fake-env (>= ${source:Version}),
109 unity8-fake-env (>= ${source:Version}),
109 ${misc:Depends},
110 ${misc:Depends},
plugins/DashViews/horizontaljournal.cpp+2−2
@@ -172,7 +172,7 @@ void HorizontalJournal::cleanupExistingItems()
172 releaseItem(item);
172 releaseItem(item);
173 m_visibleItems.clear();
173 m_visibleItems.clear();
174 m_lastInRowIndexPosition.clear();
174 m_lastInRowIndexPosition.clear();
175− m_firstVisibleIndex = 0;
175+ m_firstVisibleIndex = -1;
176}
176}
177
177
178void HorizontalJournal::calculateImplicitHeight()
178void HorizontalJournal::calculateImplicitHeight()
@@ -241,7 +241,7 @@ void HorizontalJournal::doRelayout()
241 }
241 }
242 m_visibleItems.clear();
242 m_visibleItems.clear();
243 m_lastInRowIndexPosition.clear();
243 m_lastInRowIndexPosition.clear();
244− m_firstVisibleIndex = 0;
244+ m_firstVisibleIndex = -1;
245 }
245 }
246}
246}
247
247
plugins/Unity/Indicators/Messaging/qml/MessageMenuItemFactory.qml+8
@@ -60,6 +60,7 @@ Indicators.BaseMenuItem {
60
60
61 Loader {
61 Loader {
62 id: contents
62 id: contents
63+ objectName: "loader"
63 anchors.fill: parent
64 anchors.fill: parent
64
65
65 sourceComponent: loadMessage(actionsDescription);
66 sourceComponent: loadMessage(actionsDescription);
@@ -67,6 +68,7 @@ Indicators.BaseMenuItem {
67 Component {
68 Component {
68 id: simpleTextMessage
69 id: simpleTextMessage
69 SimpleTextMessage {
70 SimpleTextMessage {
71+ objectName: "simpleTextMessage"
70 // text
72 // text
71 title: menuData && menuData.label || ""
73 title: menuData && menuData.label || ""
72 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
74 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
@@ -74,6 +76,8 @@ Indicators.BaseMenuItem {
74 // icons
76 // icons
75 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
77 avatar: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_contact.png")
76 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
78 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
79+ // actions
80+ enabled: menuData && menuData.sensitive || false
77
81
78 onActivateApp: {
82 onActivateApp: {
79 menuModel.activate(menuIndex, true);
83 menuModel.activate(menuIndex, true);
@@ -91,6 +95,7 @@ Indicators.BaseMenuItem {
91 Component {
95 Component {
92 id: textMessage
96 id: textMessage
93 TextMessage {
97 TextMessage {
98+ objectName: "textMessage"
94 property var replyActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
99 property var replyActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
95
100
96 property var replyAction: QMenuModel.UnityMenuAction {
101 property var replyAction: QMenuModel.UnityMenuAction {
@@ -109,6 +114,7 @@ Indicators.BaseMenuItem {
109 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
114 appIcon: getExtendedProperty(extendedData, "xCanonicalAppIcon", "qrc:/indicators/artwork/messaging/default_app.svg")
110 // actions
115 // actions
111 replyEnabled: replyAction.valid && replyAction.enabled
116 replyEnabled: replyAction.valid && replyAction.enabled
117+ enabled: menuData && menuData.sensitive || false
112
118
113 onActivateApp: {
119 onActivateApp: {
114 menuModel.activate(menuIndex, true);
120 menuModel.activate(menuIndex, true);
@@ -129,6 +135,7 @@ Indicators.BaseMenuItem {
129 Component {
135 Component {
130 id: snapDecision
136 id: snapDecision
131 SnapDecision {
137 SnapDecision {
138+ objectName: "snapDecision"
132 property var activateActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
139 property var activateActionDescription: actionsDescription && actionsDescription.length > 0 ? actionsDescription[0] : undefined
133 property var replyActionDescription: actionsDescription && actionsDescription.length > 1 ? actionsDescription[1] : undefined
140 property var replyActionDescription: actionsDescription && actionsDescription.length > 1 ? actionsDescription[1] : undefined
134
141
@@ -156,6 +163,7 @@ Indicators.BaseMenuItem {
156 // actions
163 // actions
157 activateEnabled: activateAction.valid && activateAction.enabled
164 activateEnabled: activateAction.valid && activateAction.enabled
158 replyEnabled: replyAction.valid && replyAction.enabled
165 replyEnabled: replyAction.valid && replyAction.enabled
166+ enabled: menuData && menuData.sensitive || false
159
167
160 onActivateApp: {
168 onActivateApp: {
161 menuModel.activate(menuIndex, true);
169 menuModel.activate(menuIndex, true);
plugins/Unity/Indicators/Network/qml/AccessPoint.qml+2−2
@@ -30,7 +30,7 @@ Indicators.BaseMenuItem {
30 property bool secure: false
30 property bool secure: false
31 property bool adHoc: false
31 property bool adHoc: false
32 property int signalStrength: 0
32 property int signalStrength: 0
33− property alias text: label.text
33+ property alias label: _label.text
34
34
35 signal activate()
35 signal activate()
36
36
@@ -89,7 +89,7 @@ Indicators.BaseMenuItem {
89 }
89 }
90
90
91 Label {
91 Label {
92− id: label
92+ id: _label
93 anchors {
93 anchors {
94 left: iconSignal.right
94 left: iconSignal.right
95 leftMargin: units.gu(1)
95 leftMargin: units.gu(1)
plugins/Unity/Indicators/qml/ButtonMenuItem.qml+1−1
@@ -26,7 +26,7 @@ BaseMenuItem {
26 id: menuItem
26 id: menuItem
27 implicitHeight: units.gu(7)
27 implicitHeight: units.gu(7)
28
28
29− property alias text: button.text
29+ property alias buttonText: button.text
30
30
31 signal activate()
31 signal activate()
32
32
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 {
57 return defaultValue;
57 return defaultValue;
58 }
58 }
59
59
60+ Component {
61+ id: divMenu;
60− Component { id: divMenu; Indicators.DivMenuItem {} }
62+ Indicators.DivMenuItem {
63+ objectName: "divMenu"
64+ }
65+ }
61
66
62 Component {
67 Component {
63 id: sliderMenu;
68 id: sliderMenu;
64 Indicators.SliderMenuItem {
69 Indicators.SliderMenuItem {
70+ objectName: "sliderMenu"
65 property QtObject menuData: null
71 property QtObject menuData: null
66 property var menuModel: menuFactory.menuModel
72 property var menuModel: menuFactory.menuModel
67 property int menuIndex: -1
73 property int menuIndex: -1
@@ -106,11 +112,12 @@ Item {
106 Component {
112 Component {
107 id: buttonMenu;
113 id: buttonMenu;
108 Indicators.ButtonMenuItem {
114 Indicators.ButtonMenuItem {
115+ objectName: "buttonMenu"
109 property QtObject menuData: null
116 property QtObject menuData: null
110 property var menuModel: menuFactory.menuModel
117 property var menuModel: menuFactory.menuModel
111 property int menuIndex: -1
118 property int menuIndex: -1
112
119
113− text: menuData && menuData.label || ""
120+ buttonText: menuData && menuData.label || ""
114 enabled: menuData && menuData.sensitive || false
121 enabled: menuData && menuData.sensitive || false
115
122
116 onActivate: {
123 onActivate: {
@@ -122,6 +129,7 @@ Item {
122 Component {
129 Component {
123 id: sectionMenu;
130 id: sectionMenu;
124 Indicators.SectionMenuItem {
131 Indicators.SectionMenuItem {
132+ objectName: "sectionMenu"
125 property QtObject menuData: null
133 property QtObject menuData: null
126 property var menuIndex: undefined
134 property var menuIndex: undefined
127
135
@@ -132,6 +140,7 @@ Item {
132 Component {
140 Component {
133 id: progressMenu;
141 id: progressMenu;
134 Indicators.ProgressMenuItem {
142 Indicators.ProgressMenuItem {
143+ objectName: "progressMenu"
135 property QtObject menuData: null
144 property QtObject menuData: null
136 property int menuIndex: -1
145 property int menuIndex: -1
137
146
@@ -145,6 +154,7 @@ Item {
145 Component {
154 Component {
146 id: standardMenu;
155 id: standardMenu;
147 Indicators.StandardMenuItem {
156 Indicators.StandardMenuItem {
157+ objectName: "standardMenu"
148 property QtObject menuData: null
158 property QtObject menuData: null
149 property int menuIndex: -1
159 property int menuIndex: -1
150
160
@@ -164,6 +174,7 @@ Item {
164 Component {
174 Component {
165 id: switchMenu;
175 id: switchMenu;
166 Indicators.SwitchMenuItem {
176 Indicators.SwitchMenuItem {
177+ objectName: "switchMenu"
167 property QtObject menuData: null
178 property QtObject menuData: null
168 property int menuIndex: -1
179 property int menuIndex: -1
169
180
@@ -182,6 +193,7 @@ Item {
182 Component {
193 Component {
183 id: wifiSection;
194 id: wifiSection;
184 Indicators.SectionMenuItem {
195 Indicators.SectionMenuItem {
196+ objectName: "wifiSection"
185 property QtObject menuData: null
197 property QtObject menuData: null
186 property var menuModel: menuFactory.menuModel
198 property var menuModel: menuFactory.menuModel
187 property int menuIndex: -1
199 property int menuIndex: -1
@@ -207,6 +219,7 @@ Item {
207 Component {
219 Component {
208 id: accessPoint;
220 id: accessPoint;
209 ICNetwork.AccessPoint {
221 ICNetwork.AccessPoint {
222+ objectName: "accessPoint"
210 property QtObject menuData: null
223 property QtObject menuData: null
211 property var menuModel: menuFactory.menuModel
224 property var menuModel: menuFactory.menuModel
212 property int menuIndex: -1
225 property int menuIndex: -1
@@ -218,7 +231,7 @@ Item {
218 name: getExtendedProperty(extendedData, "xCanonicalWifiApStrengthAction", "")
231 name: getExtendedProperty(extendedData, "xCanonicalWifiApStrengthAction", "")
219 }
232 }
220
233
221− text: menuData && menuData.label || ""
234+ label: menuData && menuData.label || ""
222 enabled: menuData && menuData.sensitive || false
235 enabled: menuData && menuData.sensitive || false
223 secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
236 secure: getExtendedProperty(extendedData, "xCanonicalWifiApIsSecure", false)
224 adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
237 adHoc: getExtendedProperty(extendedData, "xCanonicalWifiApIsAdhoc", false)
@@ -248,6 +261,7 @@ Item {
248 Component {
261 Component {
249 id: messageItem
262 id: messageItem
250 ICMessaging.MessageMenuItemFactory {
263 ICMessaging.MessageMenuItemFactory {
264+ objectName: "messageItem"
251 menuModel: menuFactory.menuModel
265 menuModel: menuFactory.menuModel
252 }
266 }
253 }
267 }
@@ -255,6 +269,7 @@ Item {
255 Component {
269 Component {
256 id: groupedMessage
270 id: groupedMessage
257 ICMessaging.GroupedMessage {
271 ICMessaging.GroupedMessage {
272+ objectName: "groupedMessage"
258 property QtObject menuData: null
273 property QtObject menuData: null
259 property var menuModel: menuFactory.menuModel
274 property var menuModel: menuFactory.menuModel
260 property int menuIndex: -1
275 property int menuIndex: -1
plugins/Unity/Indicators/qml/qmldir−2
@@ -9,8 +9,6 @@ DivMenuItem 0.1 DivMenuItem.qml
9FramedMenuItem 0.1 FramedMenuItem.qml
9FramedMenuItem 0.1 FramedMenuItem.qml
10HLine 0.1 HLine.qml
10HLine 0.1 HLine.qml
11IndicatorBase 0.1 IndicatorBase.qml
11IndicatorBase 0.1 IndicatorBase.qml
12−IndicatorPage 0.1 IndicatorPage.qml
13−IndicatorWidget 0.1 IndicatorWidget.qml
14MenuActionBinding 0.1 MenuActionBinding.qml
12MenuActionBinding 0.1 MenuActionBinding.qml
15MenuItemFactory 0.1 MenuItemFactory.qml
13MenuItemFactory 0.1 MenuItemFactory.qml
16ProgressMenuItem 0.1 ProgressMenuItem.qml
14ProgressMenuItem 0.1 ProgressMenuItem.qml
po/ca.po+7−7
@@ -8,15 +8,15 @@ msgstr ""
8"Project-Id-Version: unity\n"
8"Project-Id-Version: unity\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2013-11-29 09:21+0100\n"
10"POT-Creation-Date: 2013-11-29 09:21+0100\n"
11−"PO-Revision-Date: 2013-09-28 07:38+0000\n"
11+"PO-Revision-Date: 2014-01-10 07:45+0000\n"
12−"Last-Translator: David Planella <david.planella@ubuntu.com>\n"
12+"Last-Translator: Adolfo Jayme <fitoschido@gmail.com>\n"
13"Language-Team: Catalan <ca@li.org>\n"
13"Language-Team: Catalan <ca@li.org>\n"
14"MIME-Version: 1.0\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
16"Content-Transfer-Encoding: 8bit\n"
17"Plural-Forms: nplurals=2; plural=n != 1;\n"
17"Plural-Forms: nplurals=2; plural=n != 1;\n"
18−"X-Launchpad-Export-Date: 2013-12-29 06:04+0000\n"
18+"X-Launchpad-Export-Date: 2014-01-11 06:38+0000\n"
19−"X-Generator: Launchpad (build 16877)\n"
19+"X-Generator: Launchpad (build 16890)\n"
20
20
21#: Components/EdgeDemoOverlay.qml:151
21#: Components/EdgeDemoOverlay.qml:151
22msgid "Skip intro"
22msgid "Skip intro"
@@ -143,7 +143,7 @@ msgstr "S'està parlant..."
143
143
144#: Notifications/NotificationMenuItemFactory.qml:89
144#: Notifications/NotificationMenuItemFactory.qml:89
145msgid "Show password"
145msgid "Show password"
146−msgstr ""
146+msgstr "Mostra la contrasenya"
147
147
148#: Panel/SearchIndicator.qml:27
148#: Panel/SearchIndicator.qml:27
149msgid "Search"
149msgid "Search"
@@ -152,11 +152,11 @@ msgstr "Cerca"
152#: plugins/Unity/Launcher/launcheritem.cpp:43
152#: plugins/Unity/Launcher/launcheritem.cpp:43
153#: plugins/Unity/Launcher/launcheritem.cpp:73
153#: plugins/Unity/Launcher/launcheritem.cpp:73
154msgid "Lock to Launcher"
154msgid "Lock to Launcher"
155−msgstr ""
155+msgstr "Mantén-la al llançador"
156
156
157#: plugins/Unity/Launcher/launcheritem.cpp:73
157#: plugins/Unity/Launcher/launcheritem.cpp:73
158msgid "Unlock from Launcher"
158msgid "Unlock from Launcher"
159−msgstr ""
159+msgstr "No la mantinguis al llançador"
160
160
161#: Shell.qml:439
161#: Shell.qml:439
162#, qt-format
162#, qt-format
po/cs.po+9−7
@@ -8,15 +8,15 @@ msgstr ""
8"Project-Id-Version: unity8\n"
8"Project-Id-Version: unity8\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2013-11-29 09:21+0100\n"
10"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"
12"Last-Translator: Tadeáš Pařík <tadeas.parik@gmail.com>\n"
12"Last-Translator: Tadeáš Pařík <tadeas.parik@gmail.com>\n"
13"Language-Team: Czech <cs@li.org>\n"
13"Language-Team: Czech <cs@li.org>\n"
14"MIME-Version: 1.0\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
16"Content-Transfer-Encoding: 8bit\n"
17"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
17"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"
18+"X-Launchpad-Export-Date: 2014-01-09 05:41+0000\n"
19−"X-Generator: Launchpad (build 16877)\n"
19+"X-Generator: Launchpad (build 16884)\n"
20
20
21#: Components/EdgeDemoOverlay.qml:151
21#: Components/EdgeDemoOverlay.qml:151
22msgid "Skip intro"
22msgid "Skip intro"
@@ -44,7 +44,7 @@ msgstr "Uzavřít"
44
44
45#: Components/EdgeDemo.qml:171
45#: Components/EdgeDemo.qml:171
46msgid "Swipe up again to close the settings screen"
46msgid "Swipe up again to close the settings screen"
47−msgstr ""
47+msgstr "Přetažením nahoru dojde k uzavření obrazovky nastavení"
48
48
49#: Components/EdgeDemo.qml:198
49#: Components/EdgeDemo.qml:198
50msgid "Left edge"
50msgid "Left edge"
@@ -63,6 +63,8 @@ msgid ""
63"You have now mastered the edge gestures and can start using the "
63"You have now mastered the edge gestures and can start using the "
64"phone<br><br>Tap anywhere to start"
64"phone<br><br>Tap anywhere to start"
65msgstr ""
65msgstr ""
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"
66
68
67#: Components/PageHeader.qml:364
69#: Components/PageHeader.qml:364
68msgid "Recent searches"
70msgid "Recent searches"
@@ -138,7 +140,7 @@ msgstr "Mluvte..."
138
140
139#: Notifications/NotificationMenuItemFactory.qml:89
141#: Notifications/NotificationMenuItemFactory.qml:89
140msgid "Show password"
142msgid "Show password"
141−msgstr ""
143+msgstr "Zobrazit heslo"
142
144
143#: Panel/SearchIndicator.qml:27
145#: Panel/SearchIndicator.qml:27
144msgid "Search"
146msgid "Search"
@@ -147,11 +149,11 @@ msgstr "Hledat"
147#: plugins/Unity/Launcher/launcheritem.cpp:43
149#: plugins/Unity/Launcher/launcheritem.cpp:43
148#: plugins/Unity/Launcher/launcheritem.cpp:73
150#: plugins/Unity/Launcher/launcheritem.cpp:73
149msgid "Lock to Launcher"
151msgid "Lock to Launcher"
150−msgstr ""
152+msgstr "Přidat do Launcheru"
151
153
152#: plugins/Unity/Launcher/launcheritem.cpp:73
154#: plugins/Unity/Launcher/launcheritem.cpp:73
153msgid "Unlock from Launcher"
155msgid "Unlock from Launcher"
154−msgstr ""
156+msgstr "Odebrat z Launcheru"
155
157
156#: Shell.qml:439
158#: Shell.qml:439
157#, qt-format
159#, qt-format
po/lv.po+6−6
@@ -8,15 +8,15 @@ msgstr ""
8"Project-Id-Version: unity\n"
8"Project-Id-Version: unity\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2013-11-29 09:21+0100\n"
10"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"
12"Last-Translator: Jānis-Marks Gailis <jeanmarc.gailis@gmail.com>\n"
12"Last-Translator: Jānis-Marks Gailis <jeanmarc.gailis@gmail.com>\n"
13"Language-Team: Latvian <lv@li.org>\n"
13"Language-Team: Latvian <lv@li.org>\n"
14"MIME-Version: 1.0\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
16"Content-Transfer-Encoding: 8bit\n"
17"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2;\n"
17"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"
18+"X-Launchpad-Export-Date: 2014-01-12 05:52+0000\n"
19−"X-Generator: Launchpad (build 16877)\n"
19+"X-Generator: Launchpad (build 16890)\n"
20
20
21#: Components/EdgeDemoOverlay.qml:151
21#: Components/EdgeDemoOverlay.qml:151
22msgid "Skip intro"
22msgid "Skip intro"
@@ -32,7 +32,7 @@ msgstr ""
32
32
33#: Components/EdgeDemo.qml:144
33#: Components/EdgeDemo.qml:144
34msgid "Top edge"
34msgid "Top edge"
35−msgstr ""
35+msgstr "Augšējā mala"
36
36
37#: Components/EdgeDemo.qml:145
37#: Components/EdgeDemo.qml:145
38msgid "Try swiping from the top edge to access the indicators"
38msgid "Try swiping from the top edge to access the indicators"
@@ -40,7 +40,7 @@ msgstr ""
40
40
41#: Components/EdgeDemo.qml:170
41#: Components/EdgeDemo.qml:170
42msgid "Close"
42msgid "Close"
43−msgstr ""
43+msgstr "Aizvērt"
44
44
45#: Components/EdgeDemo.qml:171
45#: Components/EdgeDemo.qml:171
46msgid "Swipe up again to close the settings screen"
46msgid "Swipe up again to close the settings screen"
@@ -48,7 +48,7 @@ msgstr ""
48
48
49#: Components/EdgeDemo.qml:198
49#: Components/EdgeDemo.qml:198
50msgid "Left edge"
50msgid "Left edge"
51−msgstr ""
51+msgstr "Kreisā mala"
52
52
53#: Components/EdgeDemo.qml:199
53#: Components/EdgeDemo.qml:199
54msgid "Swipe from the left to reveal the launcher for quick access to apps"
54msgid "Swipe from the left to reveal the launcher for quick access to apps"
po/pl.po+7−7
@@ -8,16 +8,16 @@ msgstr ""
8"Project-Id-Version: unity\n"
8"Project-Id-Version: unity\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2013-11-29 09:21+0100\n"
10"POT-Creation-Date: 2013-11-29 09:21+0100\n"
11−"PO-Revision-Date: 2013-10-13 13:44+0000\n"
11+"PO-Revision-Date: 2014-01-10 11:38+0000\n"
12−"Last-Translator: GTriderXC <gtriderxc@yahoo.com>\n"
12+"Last-Translator: Michał Sawicz <michal.sawicz@canonical.com>\n"
13"Language-Team: Polish <pl@li.org>\n"
13"Language-Team: Polish <pl@li.org>\n"
14"MIME-Version: 1.0\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
16"Content-Transfer-Encoding: 8bit\n"
17"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
17"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
18"|| n%100>=20) ? 1 : 2;\n"
18"|| n%100>=20) ? 1 : 2;\n"
19−"X-Launchpad-Export-Date: 2013-12-29 06:04+0000\n"
19+"X-Launchpad-Export-Date: 2014-01-11 06:38+0000\n"
20−"X-Generator: Launchpad (build 16877)\n"
20+"X-Generator: Launchpad (build 16890)\n"
21
21
22#: Components/EdgeDemoOverlay.qml:151
22#: Components/EdgeDemoOverlay.qml:151
23msgid "Skip intro"
23msgid "Skip intro"
@@ -143,7 +143,7 @@ msgstr "Rozpoznanie..."
143
143
144#: Notifications/NotificationMenuItemFactory.qml:89
144#: Notifications/NotificationMenuItemFactory.qml:89
145msgid "Show password"
145msgid "Show password"
146−msgstr ""
146+msgstr "Wyświetl hasło"
147
147
148#: Panel/SearchIndicator.qml:27
148#: Panel/SearchIndicator.qml:27
149msgid "Search"
149msgid "Search"
@@ -152,11 +152,11 @@ msgstr "Szukaj"
152#: plugins/Unity/Launcher/launcheritem.cpp:43
152#: plugins/Unity/Launcher/launcheritem.cpp:43
153#: plugins/Unity/Launcher/launcheritem.cpp:73
153#: plugins/Unity/Launcher/launcheritem.cpp:73
154msgid "Lock to Launcher"
154msgid "Lock to Launcher"
155−msgstr ""
155+msgstr "Dodaj do panelu uruchamiania"
156
156
157#: plugins/Unity/Launcher/launcheritem.cpp:73
157#: plugins/Unity/Launcher/launcheritem.cpp:73
158msgid "Unlock from Launcher"
158msgid "Unlock from Launcher"
159−msgstr ""
159+msgstr "Usuń z panelu uruchamiania"
160
160
161#: Shell.qml:439
161#: Shell.qml:439
162#, qt-format
162#, 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 {
26 property bool dimmed: false
26 property bool dimmed: false
27 property var indicatorProperties: undefined
27 property var indicatorProperties: undefined
28 property bool indicatorVisible: loader.item ? loader.item.enabled : false
28 property bool indicatorVisible: loader.item ? loader.item.enabled : false
29+ property string identifier
29
30
30 opacity: dimmed ? 0.4 : 1
31 opacity: dimmed ? 0.4 : 1
31 Behavior on opacity { StandardAnimation {} }
32 Behavior on opacity { StandardAnimation {} }
@@ -44,5 +45,11 @@ Item {
44 }
45 }
45 }
46 }
46 }
47 }
48+
49+ Binding {
50+ target: loader.item
51+ property: "objectName"
52+ value: identifier + "-widget"
53+ }
47 }
54 }
48}
55}
qml/Panel/IndicatorRow.qml+1
@@ -95,6 +95,7 @@ Item {
95
95
96 IndicatorItem {
96 IndicatorItem {
97 id: indicatorItem
97 id: indicatorItem
98+ identifier: model.identifier
98 height: parent.height
99 height: parent.height
99
100
100 dimmed: itemWrapper.dimmed
101 dimmed: itemWrapper.dimmed
qml/Panel/Indicators/DefaultIndicatorPage.qml+195−2
@@ -14,12 +14,205 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
15 *
16 * Authors:
16 * Authors:
17+ * Renato Araujo Oliveira Filho <renato@canonical.com>
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19 */
19
20
20import QtQuick 2.0
21import QtQuick 2.0
22+import Ubuntu.Components 0.1 as Components
21import Unity.Indicators 0.1 as Indicators
23import Unity.Indicators 0.1 as Indicators
22
24
23−Indicators.IndicatorPage {
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 {
24− anchors.fill: parent
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+ }
25}
218}
qml/Panel/Indicators/DefaultIndicatorWidget.qml+5−3
@@ -21,15 +21,17 @@ import QtQuick 2.0
21import Ubuntu.Components 0.1
21import Ubuntu.Components 0.1
22import Unity.Indicators 0.1 as Indicators
22import Unity.Indicators 0.1 as Indicators
23
23
24−Indicators.IndicatorWidget {
24+Indicators.IndicatorBase {
25 id: indicatorWidget
25 id: indicatorWidget
26
26
27− width: itemRow.width
27+ property int iconSize: height
28−
29 property alias leftLabel: itemLeftLabel.text
28 property alias leftLabel: itemLeftLabel.text
30 property alias rightLabel: itemRightLabel.text
29 property alias rightLabel: itemRightLabel.text
31 property var icons: undefined
30 property var icons: undefined
32
31
32+ width: itemRow.width
33+ enabled: false
34+
33 Row {
35 Row {
34 id: itemRow
36 id: itemRow
35 width: childrenRect.width
37 width: childrenRect.width
qml/ScopeTool.qml+26−28
@@ -17,7 +17,9 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19import Ubuntu.Components.Popups 0.1
19import Ubuntu.Components.Popups 0.1
20+import Utils 0.1
20import Unity 0.1
21import Unity 0.1
22+import "Components"
21import "Dash"
23import "Dash"
22
24
23Rectangle {
25Rectangle {
@@ -43,18 +45,28 @@ Rectangle {
43 signal searchClicked
45 signal searchClicked
44 }
46 }
45
47
48+ SortFilterProxyModel {
49+ id: filteredScopes
50+ model: Scopes {
51+ id: scopes
52+ }
53+ dynamicSortFilter: true
46
54
47− Scopes {
55+ filterRole: Scopes.RoleVisible
48− id: scopes
56+ filterRegExp: RegExp("^true$")
49 }
57 }
50
58
51 Rectangle {
59 Rectangle {
52− anchors.fill: scopeView
60+ anchors.fill: dashContent
53 color: "#FCFCFC"
61 color: "#FCFCFC"
54 }
62 }
55
63
56− GenericScopeView {
64+ DashContent {
57− id: scopeView
65+ id: dashContent
66+
67+ model: filteredScopes
68+ searchHistory: SearchHistoryModel { }
69+ property Scope scope: scopes.get(currentIndex)
58
70
59 anchors {
71 anchors {
60 top: parent.top
72 top: parent.top
@@ -62,8 +74,6 @@ Rectangle {
62 left: parent.left
74 left: parent.left
63 right: controls.left
75 right: controls.left
64 }
76 }
65−
66− scope: scopes.loaded ? scopes.get(scopeSelector.selectedIndex) : undefined
67 }
77 }
68
78
69 Rectangle {
79 Rectangle {
@@ -76,6 +86,10 @@ Rectangle {
76 right: parent.right
86 right: parent.right
77 }
87 }
78
88
89+ MouseArea {
90+ anchors.fill: parent
91+ }
92+
79 Column {
93 Column {
80 anchors { fill: parent; margins: units.gu(1) }
94 anchors { fill: parent; margins: units.gu(1) }
81 spacing: units.gu(1)
95 spacing: units.gu(1)
@@ -88,27 +102,11 @@ Rectangle {
88 id: searchField
102 id: searchField
89 anchors { left: parent.left; right: parent.right }
103 anchors { left: parent.left; right: parent.right }
90
104
91− onTextChanged: scopeView.scope.searchQuery = text
105+ onTextChanged: dashContent.scope.searchQuery = text
92
106
93 Connections {
107 Connections {
94− target: scopeView.scope
108+ target: dashContent.scope
95− onSearchQueryChanged: searchField.text = scopeView.scope.searchQuery
109+ onSearchQueryChanged: searchField.text = dashContent.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
112 }
110 }
113 }
111 }
114
112
@@ -121,7 +119,7 @@ Rectangle {
121 OptionSelector {
119 OptionSelector {
122 id: categorySelector
120 id: categorySelector
123 anchors { left: parent.left; right: parent.right }
121 anchors { left: parent.left; right: parent.right }
124− model: scopeView.scope ? scopeView.scope.categories : null
122+ model: dashContent.scope ? dashContent.scope.categories : null
125
123
126 property Item selectedItem
124 property Item selectedItem
127
125
@@ -170,7 +168,7 @@ Rectangle {
170 onCancelClicked: PopupUtils.close(sheet)
168 onCancelClicked: PopupUtils.close(sheet)
171 onConfirmClicked: {
169 onConfirmClicked: {
172 PopupUtils.close(sheet);
170 PopupUtils.close(sheet);
173− scopeView.scope.categories.overrideCategoryJson(categorySelector.selectedItem.categoryId, categoryEditorArea.text);
171+ dashContent.scope.categories.overrideCategoryJson(categorySelector.selectedItem.categoryId, categoryEditorArea.text);
174 }
172 }
175 }
173 }
176 }
174 }
src/CMakeLists.txt+9−1
@@ -5,7 +5,15 @@ include_directories(
5 ${UNITY-MIR_INCLUDE_DIRS}
5 ${UNITY-MIR_INCLUDE_DIRS}
6)
6)
7
7
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+)
9
17
10add_executable(${SHELL_APP}
18add_executable(${SHELL_APP}
11 ApplicationArguments.h
19 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 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
2#
3# Unity Autopilot Test Suite
3# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
4+# Copyright (C) 2012, 2013, 2014 Canonical
5#
5#
6# This program is free software: you can redistribute it and/or modify
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
7# it under the terms of the GNU General Public License as published by
@@ -17,9 +17,16 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
18#
19
19
20+from autopilot import input, introspection
20
21
21−from autopilot.introspection import CustomEmulatorBase
22
22
23−
24−class UnityEmulatorBase(CustomEmulatorBase):
23+class UnityEmulatorBase(introspection.CustomEmulatorBase):
25 """A base class for all unity emulators."""
24 """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__':
87 action_id,
87 action_id,
88 action_label,
88 action_label,
89 action_callback,
89 action_callback,
90− None,
90+ (None, ),
91 None
91 None
92 )
92 )
93
93
tests/autopilot/unity8/shell/emulators/dash.py+102−8
@@ -1,7 +1,7 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
2#
3# Unity Autopilot Test Suite
3# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
4+# Copyright (C) 2012, 2013, 2014 Canonical
5#
5#
6# This program is free software: you can redistribute it and/or modify
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
7# it under the terms of the GNU General Public License as published by
@@ -17,13 +17,25 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
18#
19
19
20−from unity8.shell.emulators import UnityEmulatorBase
20+import logging
21
21
22+from unity8.shell import emulators
22
23
23−class Dash(UnityEmulatorBase):
24+from autopilot import logging as autopilot_logging
25+from autopilot.introspection import dbus
24
26
27+
28+logger = logging.getLogger(__name__)
29+
30+
31+class Dash(emulators.UnityEmulatorBase):
25 """An emulator that understands the Dash."""
32 """An emulator that understands the Dash."""
26
33
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+
27 def get_home_applications_grid(self):
39 def get_home_applications_grid(self):
28 get_grid = self.get_scope('home').wait_select_single(
40 get_grid = self.get_scope('home').wait_select_single(
29 "GenericFilterGrid",
41 "GenericFilterGrid",
@@ -43,9 +55,91 @@ class Dash(UnityEmulatorBase):
43 return resp_grid.select_single('Tile', text=text)
55 return resp_grid.select_single('Tile', text=text)
44
56
45 def get_scope(self, scope_name='home'):
57 def get_scope(self, scope_name='home'):
46− dash_content = self.wait_select_single(
47− 'QQuickListView',
48− objectName='dashContentList'
49− )
50 scope_id = "%s.scope" % scope_name
58 scope_id = "%s.scope" % scope_name
59+ return self.dash_content_list.select_single(
51− return dash_content.select_single('QQuickLoader', scopeId=scope_id)
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 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
2#
3# Unity Autopilot Test Suite
3# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
4+# Copyright (C) 2012, 2013, 2014 Canonical
5#
5#
6# This program is free software: you can redistribute it and/or modify
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
7# it under the terms of the GNU General Public License as published by
@@ -18,24 +18,21 @@
18#
18#
19
19
20from unity8.shell.emulators import UnityEmulatorBase
20from unity8.shell.emulators import UnityEmulatorBase
21−from autopilot.input import Touch
22
21
23
22
24class Greeter(UnityEmulatorBase):
23class Greeter(UnityEmulatorBase):
25−
26 """An emulator that understands the greeter screen."""
24 """An emulator that understands the greeter screen."""
27
25
28 def swipe(self):
26 def swipe(self):
29 """Swipe the greeter screen away."""
27 """Swipe the greeter screen away."""
30 self.created.wait_for(True)
28 self.created.wait_for(True)
31− touch = Touch.create()
32
29
33 rect = self.globalRect
30 rect = self.globalRect
34 start_x = rect[0] + rect[2] - 3
31 start_x = rect[0] + rect[2] - 3
35 start_y = int(rect[1] + rect[3] / 2)
32 start_y = int(rect[1] + rect[3] / 2)
36 stop_x = int(rect[0] + rect[2] * 0.2)
33 stop_x = int(rect[0] + rect[2] * 0.2)
37 stop_y = start_y
34 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)
39
36
40 self.created.wait_for(False)
37 self.created.wait_for(False)
41
38
tests/autopilot/unity8/shell/emulators/main_window.py+6
@@ -91,5 +91,11 @@ class MainWindow(object):
91 def get_pinentryField(self):
91 def get_pinentryField(self):
92 return self.app.select_single(objectName="pinentryField")
92 return self.app.select_single(objectName="pinentryField")
93
93
94+ def get_indicator(self, indicator_name):
95+ return self.app.select_single(
96+ 'DefaultIndicatorWidget',
97+ objectName=indicator_name+'-widget'
98+ )
99+
94 def get_shell_background(self):
100 def get_shell_background(self):
95 return self.app.select_single("CrossFadeImage", objectName="backgroundImage")
101 return self.app.select_single("CrossFadeImage", objectName="backgroundImage")
tests/autopilot/unity8/shell/tests/__init__.py+1
@@ -147,6 +147,7 @@ class UnityTestCase(AutopilotTestCase):
147 if model() != "Desktop":
147 if model() != "Desktop":
148 from autopilot.input import _uinput
148 from autopilot.input import _uinput
149 _uinput._touch_device = _uinput.create_touch_device()
149 _uinput._touch_device = _uinput.create_touch_device()
150+ self.addCleanup(_uinput._touch_device.close)
150 ####
151 ####
151
152
152 self.touch = Touch.create()
153 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
143
143
144QVariantMap UnityMenuModel::rowData(int row) const
144QVariantMap UnityMenuModel::rowData(int row) const
145{
145{
146+ if (m_modelData.count() <= row) {
147+ return QVariantMap();
148+ }
146 return m_modelData[row].toMap()["rowData"].toMap();
149 return m_modelData[row].toMap()["rowData"].toMap();
147}
150}
148
151
tests/mocks/Unity/Indicators/CMakeLists.txt+2
@@ -7,12 +7,14 @@ include_directories(
7 ${CMAKE_CURRENT_SOURCE_DIR}
7 ${CMAKE_CURRENT_SOURCE_DIR}
8 ${CMAKE_CURRENT_BINARY_DIR}
8 ${CMAKE_CURRENT_BINARY_DIR}
9 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators
9 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators
10+ ${CMAKE_SOURCE_DIR}/tests/mocks/QMenuModel
10)
11)
11
12
12set(IndicatorsFakeQml_SOURCES
13set(IndicatorsFakeQml_SOURCES
13 fakeplugin.cpp
14 fakeplugin.cpp
14 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/indicators.h
15 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/indicators.h
15 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/menucontentactivator.cpp
16 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/menucontentactivator.cpp
17+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelstack.cpp
16 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/visibleindicatorsmodel.cpp
18 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/visibleindicatorsmodel.cpp
17)
19)
18
20
tests/mocks/Unity/Indicators/IndicatorBase.qml+2−1
@@ -26,8 +26,9 @@ Item {
26 //const
26 //const
27 property string busName
27 property string busName
28 property string actionsObjectPath
28 property string actionsObjectPath
29+ property string menuObjectPath
29 property string rootMenuType: "com.canonical.indicator.root"
30 property string rootMenuType: "com.canonical.indicator.root"
30− property string deviceMenuObjectPath
31+ property string deviceMenuObjectPath: menuObjectPath
31
32
32 property var menuModel: UnityMenuModel {}
33 property var menuModel: UnityMenuModel {}
33
34
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 @@
18 */
18 */
19
19
20import QtQuick 2.0
20import QtQuick 2.0
21−import Unity.Indicators 0.1 as Indicators
21+import Ubuntu.Components.ListItems 0.1 as ListItem
22
22
23−IndicatorBase {
23+Item {
24− id: indicatorWidget
24+ id: menuFactory
25
25
26− enabled: false
26+ property var menuModel: null
27− property int iconSize: height
27+
28+ Component {
29+ id: standardMenu;
30+ ListItem.Standard {
31+ objectName: "standardMenu"
32+ }
33+ }
34+
35+ function load(modelData) {
36+ return standardMenu;
37+ }
28}
38}
tests/mocks/Unity/Indicators/fakeplugin.cpp+2
@@ -25,6 +25,7 @@
25// local
25// local
26#include "indicators.h"
26#include "indicators.h"
27#include "menucontentactivator.h"
27#include "menucontentactivator.h"
28+#include "unitymenumodelstack.h"
28#include "visibleindicatorsmodel.h"
29#include "visibleindicatorsmodel.h"
29
30
30void IndicatorsFakePlugin::registerTypes(const char * uri)
31void IndicatorsFakePlugin::registerTypes(const char * uri)
@@ -32,6 +33,7 @@ void IndicatorsFakePlugin::registerTypes(const char * uri)
32 Q_INIT_RESOURCE(indicators_fake);
33 Q_INIT_RESOURCE(indicators_fake);
33
34
34 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
35 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
36+ qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack");
35 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
37 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
36
38
37 qmlRegisterUncreatableType<MenuContentState>(uri, 0, 1, "MenuContentState", "Can't create MenuContentState class");
39 qmlRegisterUncreatableType<MenuContentState>(uri, 0, 1, "MenuContentState", "Can't create MenuContentState class");
tests/mocks/Unity/Indicators/qmldir+1−1
@@ -3,7 +3,7 @@ plugin IndicatorsFakeQml
3
3
4CachedUnityMenuModel 0.1 CachedUnityMenuModel.qml
4CachedUnityMenuModel 0.1 CachedUnityMenuModel.qml
5IndicatorBase 0.1 IndicatorBase.qml
5IndicatorBase 0.1 IndicatorBase.qml
6−IndicatorWidget 0.1 IndicatorWidget.qml
7IndicatorsModel 0.1 IndicatorsModel.qml
6IndicatorsModel 0.1 IndicatorsModel.qml
8FakeMenuPage 0.1 FakeMenuPage.qml
7FakeMenuPage 0.1 FakeMenuPage.qml
8+MenuItemFactory 0.1 MenuItemFactory.qml
9RootActionState 0.1 RootActionState.qml
9RootActionState 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
42add_qml_test(Dash DashContent IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
42add_qml_test(Dash DashContent IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
43add_qml_test(Dash DashPreview)
43add_qml_test(Dash DashPreview)
44add_qml_test(Dash GenericPreview)
44add_qml_test(Dash GenericPreview)
45+add_qml_test(Dash Card)
46+add_qml_test(Dash CardHeader)
45add_qml_test(Dash GenericScopeView IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
47add_qml_test(Dash GenericScopeView IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
46add_qml_test(Dash FilterGrids IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins
48add_qml_test(Dash FilterGrids IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins
47 ${CMAKE_BINARY_DIR}/tests/mocks)
49 ${CMAKE_BINARY_DIR}/tests/mocks)
@@ -72,6 +74,10 @@ add_qml_test(Panel Panel IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFA
72add_qml_test(Panel SearchIndicator)
74add_qml_test(Panel SearchIndicator)
73add_qml_test(Panel/Indicators DefaultIndicatorWidget IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
75add_qml_test(Panel/Indicators DefaultIndicatorWidget IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
74 ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
76 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)
75add_qml_test(SideStage SideStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
81add_qml_test(SideStage SideStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
76 ${CMAKE_BINARY_DIR}/tests/mocks
82 ${CMAKE_BINARY_DIR}/tests/mocks
77 ${CMAKE_BINARY_DIR}/plugins)
83 ${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+}