on xenial help sign in
DefaultIndicatorPage -> IndicatorPage
commitb0e0a81230bcf12290d54fcd0c0ef34aa5b157c4 authorNick Dedekind <nick.dedekind@canonical.com> dateThu 2 Oct 2014, 15:35 (12 years ago) parentfdb56be
6 files changed+25−42
qml/Panel/Indicators/DefaultIndicatorPage.qml → qml/Panel/IndicatorPage.qml+1 qml/Panel/MenuContent.qml+12−25 tests/qmltests/CMakeLists.txt+2−1 tests/qmltests/Panel/Indicators/tst_DefaultIndicatorPage.qml → tests/qmltests/Panel/tst_IndicatorPage.qml+3−3 tests/qmltests/Panel/tst_IndicatorsMenu.qml+1−1 tests/qmltests/Panel/tst_MenuContent.qml+6−12
qml/Panel/Indicators/DefaultIndicatorPage.qml → qml/Panel/IndicatorPage.qmlrenamed+1
@@ -21,6 +21,7 @@
2121import QtQuick 2.0
2222import Ubuntu.Components 0.1 as Components
2323import Unity.Indicators 0.1 as Indicators
24+import "Indicators"
2425
2526IndicatorBase {
2627 id: main
qml/Panel/MenuContent.qml+12−25
@@ -20,7 +20,6 @@ import Ubuntu.Components 1.1
2020import Unity.Indicators 0.1 as Indicators
2121import Utils 0.1
2222import "../Components"
23−import "Indicators"
2423
2524Rectangle {
2625 id: content
@@ -54,38 +53,26 @@ Rectangle {
5453
5554 delegate: Loader {
5655 id: loader
56+
5757 width: ListView.view.width
5858 height: ListView.view.height
5959 objectName: identifier
60−
61− source: pageSource !== undefined && pageSource !== "" ? pageSource : Qt.resolvedUrl("Indicators/DefaultIndicatorPage.qml")
6260 asynchronous: true
6361
64− onVisibleChanged: {
65− // Reset the indicator states
66− if (!visible && item && item["reset"]) {
67− item.reset()
68− }
69− }
70−
71− onLoaded: {
72− for(var pName in indicatorProperties) {
73− if (item.hasOwnProperty(pName)) {
74− item[pName] = indicatorProperties[pName]
75− }
76− }
77− }
62+ sourceComponent: IndicatorPage {
63+ objectName: identifier + "-page"
7864
79− Binding {
80− target: loader.item
81− property: "identifier"
82− value: identifier
65+ identifier: model.identifier
66+ busName: indicatorProperties.busName
67+ actionsObjectPath: indicatorProperties.actionsObjectPath
68+ menuObjectPath: indicatorProperties.menuObjectPath
8369 }
8470
85− Binding {
86− target: loader.item
87− property: "objectName"
88− value: identifier + "-page"
71+ onVisibleChanged: {
72+ // Reset the indicator states
73+ if (!visible && status == Loader.Ready) {
74+ item.reset();
75+ }
8976 }
9077 }
9178 }
tests/qmltests/CMakeLists.txt+2−1
@@ -71,10 +71,11 @@ add_qml_test(Notifications Notifications)
7171add_qml_test(Notifications VisualSnapDecisionsQueue)
7272add_qml_test(Panel IndicatorItem)
7373add_qml_test(Panel IndicatorItemRow ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
74+add_qml_test(Panel IndicatorPage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
7475add_qml_test(Panel IndicatorsBar ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
7576add_qml_test(Panel IndicatorsMenu ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
77+add_qml_test(Panel MenuContent ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
7678add_qml_test(Panel Panel ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
77−add_qml_test(Panel/Indicators DefaultIndicatorPage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
7879# These MenuItemFactory tests need the test/mocks/ to come before plugins/
7980add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
8081add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
tests/qmltests/Panel/Indicators/tst_DefaultIndicatorPage.qml → tests/qmltests/Panel/tst_IndicatorPage.qmlrenamed+3−3
@@ -18,14 +18,14 @@ import QtQuick 2.0
1818import QtTest 1.0
1919import Unity.Test 0.1 as UT
2020import Unity.Indicators 0.1 as Indicators
21−import "../../../../qml/Panel/Indicators"
21+import "../../../qml/Panel"
2222
2323Item {
2424 id: testView
2525 width: units.gu(40)
2626 height: units.gu(70)
2727
28− DefaultIndicatorPage {
28+ IndicatorPage {
2929 id: page
3030 anchors.fill: parent
3131
@@ -117,7 +117,7 @@ Item {
117117 }
118118
119119 UT.UnityTestCase {
120− name: "DefaultIndicatorPage"
120+ name: "IndicatorPage"
121121
122122 function init() {
123123 initMenuData([]);
tests/qmltests/Panel/tst_IndicatorsMenu.qml+1−1
@@ -220,7 +220,7 @@ IndicatorTest {
220220 firstItemMappedPosition.x, indicatorsMenu.minimizedPanelHeight * 2,
221221 nextItemMappedPosition.x, indicatorsMenu.openedHeight / 3,
222222 false /* beginTouch */, true /* endTouch */,
223− units.gu(5) /* speed */, 30 /* iterations */); // more samples needed for accurate velocity
223+ units.gu(5) /* speed */, 10 /* iterations */); // more samples needed for accurate velocity
224224
225225 compare(indicatorItemRow.currentItem, firstItem, "First indicator should still be the current item");
226226 }
tests/qmltests/Panel/tst_MenuContent.qml+6−12
@@ -17,11 +17,11 @@
1717import QtQuick 2.0
1818import QtTest 1.0
1919import Unity.Test 0.1 as UT
20−import "../../qml/Panel"
20+import "../../../qml/Panel"
2121import Unity.Indicators 0.1 as Indicators
2222
23−Item {
24− id: shell
23+IndicatorTest {
24+ id: root
2525 width: units.gu(40)
2626 height: units.gu(70)
2727
@@ -29,14 +29,9 @@ Item {
2929 Item { id: greeter }
3030 Item { id: handle }
3131
32− Indicators.IndicatorsModel {
33− id: indicatorsModel
34− Component.onCompleted: load("test1")
35− }
36−
3732 MenuContent {
3833 id: menuContent
39− indicatorsModel: indicatorsModel
34+ indicatorsModel: root.indicatorsModel
4035 height: parent.height - 50
4136 }
4237
@@ -105,7 +100,7 @@ Item {
105100
106101 // Check that the correct menus are displayed for the requested item.
107102 function test_show_menu() {
108− var menuCount = indicatorsModel.count;
103+ var menuCount = root.indicatorsModel.count;
109104 verify(menuCount > 0, "Menu count should be greater than zero");
110105
111106 var listView = menu_content_test.findChild(menuContent, "indicatorsContentListView")
@@ -124,14 +119,13 @@ Item {
124119
125120 // Tests QTBUG-30632 - asynchronous loader crashes when changing index quickly.
126121 function test_multi_activate() {
127− var menuCount = indicatorsModel.count;
122+ var menuCount = root.indicatorsModel.count;
128123 verify(menuCount > 0, "Menu count should be greater than zero");
129124
130125 for (var i = 0; i < 100; i++) {
131126 activate_content(i % menuCount);
132127 compare(menuContent.currentMenuIndex, i%menuCount);
133128 }
134− wait(100);
135129 }
136130 }
137131}