Merge lp:~nick-dedekind/unity8/lp1236267 into lp:unity8

Proposed by Nick Dedekind
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 469
Merged at revision: 514
Proposed branch: lp:~nick-dedekind/unity8/lp1236267
Merge into: lp:unity8
Prerequisite: lp:~nick-dedekind/unity8/indicator.submenu-reinit
Diff against target: 345 lines (+217/-21)
8 files modified
Panel/Indicators/DefaultIndicatorWidget.qml (+32/-10)
plugins/Unity/Indicators/qml/IndicatorWidget.qml (+1/-1)
tests/mocks/Unity/Indicators/IndicatorBase.qml (+37/-0)
tests/mocks/Unity/Indicators/IndicatorWidget.qml (+28/-0)
tests/mocks/Unity/Indicators/RootActionState.qml (+18/-10)
tests/mocks/Unity/Indicators/qmldir (+2/-0)
tests/qmltests/CMakeLists.txt (+2/-0)
tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml (+97/-0)
To merge this branch: bzr merge lp:~nick-dedekind/unity8/lp1236267
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Albert Astals Cid (community) Approve
Review via email: mp+192924@code.launchpad.net

This proposal supersedes a proposal from 2013-10-16.

Commit message

Round indicator widget icon/label width up to closest gu for alignment.

Description of the change

Round indicator widget icon/label width up to closest gu for alignment.
Preserve icon aspect ratio.

Added test for DefaultIndicatorWidget width rounding.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:466
http://jenkins.qa.ubuntu.com/job/unity8-ci/1421/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy/5047
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/2985/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-saucy/2289
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-amd64-ci/444
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1421
        deb: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1421/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-i386-ci/1420
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-saucy/1217
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-amd64/922
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-amd64/922/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/2987
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/2987/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2493/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2537/console

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/unity8-ci/1421/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

Do you think it makes sense for guRoundUp to be somewhere more central so it can be eventually reused? Or maybe do it when we need to?

review: Needs Information
Revision history for this message
MichaƂ Sawicz (saviq) wrote : Posted in a previous version of this proposal

On 17.10.2013 11:24, Albert Astals Cid wrote:
> Do you think it makes sense for guRoundUp to be somewhere more central so it can be eventually reused? Or maybe do it when we need to?

Maybe we should even put it in the UITK for others to use? I.e. put it
on units.guRoundUp()?

Revision history for this message
Nick Dedekind (nick-dedekind) wrote : Posted in a previous version of this proposal

> On 17.10.2013 11:24, Albert Astals Cid wrote:
> > Do you think it makes sense for guRoundUp to be somewhere more central so it
> can be eventually reused? Or maybe do it when we need to?
>
> Maybe we should even put it in the UITK for others to use? I.e. put it
> on units.guRoundUp()?

I'll put add a request to the toolkit, and up a TODO in here. Don't think it should be held up until we get that in though.

Revision history for this message
Nick Dedekind (nick-dedekind) wrote : Posted in a previous version of this proposal
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

Ok

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:467
http://jenkins.qa.ubuntu.com/job/unity8-ci/1454/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy/5107
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3081/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-saucy/2325
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-amd64-ci/477
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity8-saucy-armhf-ci/1454/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-saucy-i386-ci/1453
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-saucy/1271
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-amd64/982
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-amd64/982/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3083
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3083/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2579/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2630/console
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/189
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/188

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/unity8-ci/1454/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

can we add a test for this?

Revision history for this message
Nick Dedekind (nick-dedekind) wrote : Posted in a previous version of this proposal

> can we add a test for this?

Yes.
I've put it back into 'Needs review' until tests added.

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Added DefaultIndicatorWidget width test.
Requires lp:~nick-dedekind/unity8/indicator.submenu-reinit

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:469
http://jenkins.qa.ubuntu.com/job/unity8-ci/1508/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/138/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/132/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/35/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/32
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/32
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/32/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/32/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/129/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/138
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/138/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/132
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/132/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2759/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2809
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/558
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/557

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/unity8-ci/1508/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Looks good

review: Approve
Revision history for this message
MichaƂ Sawicz (saviq) wrote :

There's a failed autolanding coming - it's caused by the prerequisite branch.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
http://jenkins.qa.ubuntu.com/job/unity8-autolanding/624/
Executed test runs:
    SUCCESS: http://10.97.0.26:8080/job/generic-cleanup-mbs/3061
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/293
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/283
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/81
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-autolanding/10
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-autolanding/10
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-autolanding/10/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-autolanding/10
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/277
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/293
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/293/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/283
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/283/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2900
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2951
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/846
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/847

review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Pre-requisite got merged, try to land again.

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Panel/Indicators/DefaultIndicatorWidget.qml'
--- Panel/Indicators/DefaultIndicatorWidget.qml 2013-10-02 16:07:39 +0000
+++ Panel/Indicators/DefaultIndicatorWidget.qml 2013-10-28 18:24:51 +0000
@@ -24,7 +24,7 @@
24Indicators.IndicatorWidget {24Indicators.IndicatorWidget {
25 id: indicatorWidget25 id: indicatorWidget
2626
27 width: itemRow.width + units.gu(0.5)27 width: itemRow.width
2828
29 property alias leftLabel: itemLeftLabel.text29 property alias leftLabel: itemLeftLabel.text
30 property alias rightLabel: itemRightLabel.text30 property alias rightLabel: itemRightLabel.text
@@ -32,16 +32,17 @@
3232
33 Row {33 Row {
34 id: itemRow34 id: itemRow
35 width: childrenRect.width
35 objectName: "itemRow"36 objectName: "itemRow"
36 anchors {37 anchors {
37 top: parent.top38 top: parent.top
38 bottom: parent.bottom39 bottom: parent.bottom
39 horizontalCenter: parent.horizontalCenter40 horizontalCenter: parent.horizontalCenter
40 }41 }
41 spacing: units.gu(0.5)
4242
43 Label {43 Label {
44 id: itemLeftLabel44 id: itemLeftLabel
45 width: guRoundUp(implicitWidth)
45 objectName: "leftLabel"46 objectName: "leftLabel"
46 color: Theme.palette.selected.backgroundText47 color: Theme.palette.selected.backgroundText
47 opacity: 0.848 opacity: 0.8
@@ -57,25 +58,35 @@
57 top: parent.top58 top: parent.top
58 bottom: parent.bottom59 bottom: parent.bottom
59 }60 }
60 spacing: units.gu(0.5)
6161
62 Repeater {62 Repeater {
63 model: indicatorWidget.icons63 model: indicatorWidget.icons
6464
65 Image {65 Item {
66 id: itemImage66 width: guRoundUp(itemImage.width)
67 objectName: "itemImage"
68 visible: source != ""
69 source: modelData
70 height: indicatorWidget.iconSize67 height: indicatorWidget.iconSize
71 width: indicatorWidget.iconSize68
72 anchors.verticalCenter: parent.verticalCenter69 Image {
70 id: itemImage
71 objectName: "itemImage"
72 visible: source != ""
73 source: modelData
74 height: parent.height
75 anchors.horizontalCenter: parent.horizontalCenter
76 fillMode: Image.PreserveAspectFit
77
78 sourceSize {
79 width: indicatorWidget.iconSize
80 height: indicatorWidget.iconSize
81 }
82 }
73 }83 }
74 }84 }
75 }85 }
7686
77 Label {87 Label {
78 id: itemRightLabel88 id: itemRightLabel
89 width: guRoundUp(implicitWidth)
79 objectName: "rightLabel"90 objectName: "rightLabel"
80 color: Theme.palette.selected.backgroundText91 color: Theme.palette.selected.backgroundText
81 opacity: 0.892 opacity: 0.8
@@ -86,6 +97,17 @@
86 }97 }
87 }98 }
8899
100 // TODO: Use toolkit function https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242575
101 function guRoundUp(width) {
102 if (width == 0) {
103 return 0;
104 }
105 var gu1 = units.gu(1.0);
106 var mod = (width % gu1);
107
108 return mod == 0 ? width : width + (gu1 - mod);
109 }
110
89 onRootActionStateChanged: {111 onRootActionStateChanged: {
90 if (rootActionState == undefined) {112 if (rootActionState == undefined) {
91 leftLabel = "";113 leftLabel = "";
92114
=== modified file 'plugins/Unity/Indicators/qml/IndicatorWidget.qml'
--- plugins/Unity/Indicators/qml/IndicatorWidget.qml 2013-09-30 16:37:55 +0000
+++ plugins/Unity/Indicators/qml/IndicatorWidget.qml 2013-10-28 18:24:51 +0000
@@ -24,5 +24,5 @@
24 id: indicatorWidget24 id: indicatorWidget
2525
26 enabled: false26 enabled: false
27 property int iconSize: height - units.gu(0.5)27 property int iconSize: height
28}28}
2929
=== added file 'tests/mocks/Unity/Indicators/IndicatorBase.qml'
--- tests/mocks/Unity/Indicators/IndicatorBase.qml 1970-01-01 00:00:00 +0000
+++ tests/mocks/Unity/Indicators/IndicatorBase.qml 2013-10-28 18:24:51 +0000
@@ -0,0 +1,37 @@
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
20import QtQuick 2.0
21import QMenuModel 0.1
22
23Item {
24 id: indicatorBase
25
26 //const
27 property string busName
28 property string actionsObjectPath
29 property string rootMenuType: "com.canonical.indicator.root"
30 property string deviceMenuObjectPath
31
32 property var menuModel: UnityMenuModel {}
33
34 property RootActionState rootActionState: RootActionState {
35 onUpdated: indicatorBase.rootActionStateChanged()
36 }
37}
038
=== added file 'tests/mocks/Unity/Indicators/IndicatorWidget.qml'
--- tests/mocks/Unity/Indicators/IndicatorWidget.qml 1970-01-01 00:00:00 +0000
+++ tests/mocks/Unity/Indicators/IndicatorWidget.qml 2013-10-28 18:24:51 +0000
@@ -0,0 +1,28 @@
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
20import QtQuick 2.0
21import Unity.Indicators 0.1 as Indicators
22
23IndicatorBase {
24 id: indicatorWidget
25
26 enabled: false
27 property int iconSize: height
28}
029
=== modified file 'tests/mocks/Unity/Indicators/RootActionState.qml'
--- tests/mocks/Unity/Indicators/RootActionState.qml 2013-10-11 18:58:51 +0000
+++ tests/mocks/Unity/Indicators/RootActionState.qml 2013-10-28 18:24:51 +0000
@@ -20,14 +20,22 @@
20import QtQuick 2.020import QtQuick 2.0
2121
22QtObject {22QtObject {
23 property var menu23 property var menu
24 property bool valid: false24 property bool valid: false
25 property string title25 property string title
26 property string leftLabel26 property string leftLabel
27 property string rightLabel27 property string rightLabel
28 property var icons28 property var icons
29 property string accessibleName29 property string accessibleName
30 property bool visible: true30 property bool visible: true
3131
32 signal updated32 signal updated
33
34 onValidChanged: updated()
35 onTitleChanged: updated()
36 onLeftLabelChanged: updated()
37 onRightLabelChanged: updated()
38 onIconsChanged: updated()
39 onAccessibleNameChanged: updated()
40 onVisibleChanged: updated()
33}41}
3442
=== modified file 'tests/mocks/Unity/Indicators/qmldir'
--- tests/mocks/Unity/Indicators/qmldir 2013-10-11 18:58:51 +0000
+++ tests/mocks/Unity/Indicators/qmldir 2013-10-28 18:24:51 +0000
@@ -2,6 +2,8 @@
2plugin IndicatorsFakeQml2plugin IndicatorsFakeQml
33
4CachedUnityMenuModel 0.1 CachedUnityMenuModel.qml4CachedUnityMenuModel 0.1 CachedUnityMenuModel.qml
5IndicatorBase 0.1 IndicatorBase.qml
6IndicatorWidget 0.1 IndicatorWidget.qml
5IndicatorsModel 0.1 IndicatorsModel.qml7IndicatorsModel 0.1 IndicatorsModel.qml
6FakeMenuPage 0.1 FakeMenuPage.qml8FakeMenuPage 0.1 FakeMenuPage.qml
7RootActionState 0.1 RootActionState.qml9RootActionState 0.1 RootActionState.qml
810
=== modified file 'tests/qmltests/CMakeLists.txt'
--- tests/qmltests/CMakeLists.txt 2013-10-28 18:24:51 +0000
+++ tests/qmltests/CMakeLists.txt 2013-10-28 18:24:51 +0000
@@ -71,6 +71,8 @@
71add_qml_test(Panel MenuContent IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})71add_qml_test(Panel MenuContent IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
72add_qml_test(Panel Panel IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})72add_qml_test(Panel Panel IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
73add_qml_test(Panel SearchIndicator)73add_qml_test(Panel SearchIndicator)
74add_qml_test(Panel/Indicators DefaultIndicatorWidget IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
75 ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
74add_qml_test(SideStage SideStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}76add_qml_test(SideStage SideStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
75 ${CMAKE_BINARY_DIR}/tests/mocks77 ${CMAKE_BINARY_DIR}/tests/mocks
76 ${CMAKE_BINARY_DIR}/plugins)78 ${CMAKE_BINARY_DIR}/plugins)
7779
=== added directory 'tests/qmltests/Panel/Indicators'
=== added file 'tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml'
--- tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml 1970-01-01 00:00:00 +0000
+++ tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml 2013-10-28 18:24:51 +0000
@@ -0,0 +1,97 @@
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
17import QtQuick 2.0
18import QtTest 1.0
19import Unity.Test 0.1 as UT
20import QMenuModel 0.1
21import "../../../../Panel/Indicators"
22
23Item {
24 id: testView
25 width: units.gu(40)
26 height: units.gu(70)
27
28 DefaultIndicatorWidget {
29 id: widget
30
31 anchors {
32 left: parent.left
33 top: parent.top
34 }
35
36 busName: "test"
37 actionsObjectPath: "test"
38 deviceMenuObjectPath: "test"
39
40 rootMenuType: ""
41
42 iconSize: units.gu(3.2)
43 height: units.gu(3)
44
45 rootActionState {
46 icons: [ "image://theme/audio-volume-high", "image://theme/audio-volume-low" ]
47 leftLabel: "left"
48 rightLabel: "right"
49 }
50 }
51
52 UT.UnityTestCase {
53 name: "DefaultIndicatorWidget"
54 when: windowShown
55
56 function init() {
57 widget.rootActionState.icons = [];
58 widget.rootActionState.leftLabel = "";
59 widget.rootActionState.rightLabel = "";
60 wait(50);
61 }
62
63 function test_guRoundedWidth_data() {
64 return [
65 { tag: "empty", icons: [], leftLabel: "", rightLabel: "" },
66 { tag: "1-icon-no-label", icons: [ "image://theme/audio-volume-high" ], leftLabel: "", rightLabel: "" },
67 { tag: "2-icon-no-label", icons: [ "image://theme/audio-volume-high", "image://theme/audio-volume-low" ], leftLabel: "", rightLabel: "" },
68 { tag: "no-icon-l-label", icons: [], leftLabel: "left", rightLabel: "" },
69 { tag: "no-icon-lr-label", icons: [], leftLabel: "left", rightLabel: "right" },
70 { tag: "1-icon-l-label", icons: [ "image://theme/audio-volume-high" ], leftLabel: "left", rightLabel: "" },
71 { tag: "1-icon-lr-label", icons: [ "image://theme/audio-volume-high" ], leftLabel: "left", rightLabel: "right" },
72 { tag: "2-icon-l-label", icons: [ "image://theme/audio-volume-high", "image://theme/audio-volume-low" ], leftLabel: "left", rightLabel: "" },
73 { tag: "2-icon-lr-label", icons: [ "image://theme/audio-volume-high", "image://theme/audio-volume-low" ], leftLabel: "left", rightLabel: "right" }
74 ];
75 }
76
77 function test_guRoundedWidth(data) {
78 widget.rootActionState.icons = data.icons
79 widget.rootActionState.leftLabel = data.leftLabel;
80 widget.rootActionState.rightLabel = data.rightLabel;
81 wait(50);
82
83 compare(widget.width, guRoundUp(widget.width));
84 }
85 }
86
87 // TODO: Use toolkit function https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242575
88 function guRoundUp(width) {
89 if (width == 0) {
90 return 0;
91 }
92 var gu1 = units.gu(1.0);
93 var mod = (width % gu1);
94
95 return mod == 0 ? width : width + (gu1 - mod);
96 }
97}

Subscribers

People subscribed via source and target branches