@@ -1,5 +1,6 @@
11/*
22 * Copyright 2013-2015 Canonical Ltd.
3+ * Copyright 2020 UBports Foundation
34 *
45 * This program is free software; you can redistribute it and/or modify
56 * it under the terms of the GNU General Public License as published by
@@ -30,213 +31,9 @@ import "../../../qml/Components/PanelState"
3031import "../Stage"
3132import ".."
3233
33−PanelTest {
34+PanelUI {
3435 id: root
3536 width: units.gu(120)
36− height: units.gu(71)
37− color: "black"
38−
39− Binding {
40− target: QuickUtils
41− property: "keyboardAttached"
42− value: keyboardAttached.checked
43− }
44−
45− SurfaceManager { id: sMgr }
46− ApplicationMenuDataLoader {
47− id: appMenuData
48− surfaceManager: sMgr
49− }
50−
51− Component.onCompleted: {
52− theme.name = "Ubuntu.Components.Themes.SuruDark"
53− }
54−
55− Rectangle {
56− anchors.fill: parent
57− color: "darkgrey"
58− }
59−
60− SignalSpy {
61− id: aboutToShowCalledSpy
62− signalName: "aboutToShowCalled"
63− }
64−
65− RowLayout {
66− anchors.fill: parent
67− anchors.margins: units.gu(1)
68− clip: true
69−
70− Rectangle {
71− Layout.fillWidth: true
72− Layout.fillHeight: true
73−
74− id: itemArea
75− color: backgroundMouseArea.pressed ? "red" : "blue"
76−
77− MouseArea {
78− id: backgroundMouseArea
79− anchors.fill: parent
80− hoverEnabled: true
81−
82− Panel {
83− id: panel
84− anchors.fill: parent
85− mode: modeSelector.model[modeSelector.selectedIndex]
86−
87− indicatorMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
88− applicationMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
89−
90− applicationMenus {
91− model: UnityMenuModel {
92− modelData: appMenuData.generateTestData(5, 4, 2, 3, "menu")
93− }
94−
95− hides: [ panel.indicators ]
96− }
97−
98− indicators {
99− model: root.indicatorsModel
100− hides: [ panel.applicationMenus ]
101− }
102− }
103− }
104− }
105−
106− ColumnLayout {
107− Layout.alignment: Qt.AlignTop
108− Layout.fillWidth: false
109−
110− ListItem.ItemSelector {
111− id: modeSelector
112− anchors { left: parent.left; right: parent.right }
113− activeFocusOnPress: false
114− text: "Mode"
115− model: ["staged", "windowed" ]
116− onSelectedIndexChanged: {
117− panel.mode = model[selectedIndex];
118− keyboardAttached.checked = panel.mode == "windowed"
119− }
120− }
121−
122− Button {
123− Layout.fillWidth: true
124− text: panel.indicators.shown ? "Hide" : "Show"
125− onClicked: {
126− if (panel.indicators.shown) {
127− panel.indicators.hide();
128− } else {
129− panel.indicators.show();
130− }
131− }
132− }
133−
134− Button {
135− text: panel.fullscreenMode ? "Maximize" : "FullScreen"
136− Layout.fillWidth: true
137− onClicked: panel.fullscreenMode = !panel.fullscreenMode
138− }
139−
140− Button {
141− Layout.fillWidth: true
142− text: callManager.hasCalls ? "Called" : "No Calls"
143− onClicked: {
144− if (callManager.foregroundCall) {
145− callManager.foregroundCall = null;
146− } else {
147− callManager.foregroundCall = phoneCall;
148− }
149− }
150− }
151−
152− RowLayout {
153− Layout.fillWidth: true
154− CheckBox {
155− id: windowControlsCB
156− onClicked: PanelState.decorationsVisible = checked
157− }
158− Label {
159− text: "Show window decorations"
160− color: "white"
161− }
162− }
163−
164− RowLayout {
165− Layout.fillWidth: true
166− CheckBox {
167− onClicked: PanelState.title = checked ? "Fake window title" : ""
168− }
169− Label {
170− text: "Show fake window title"
171− color: "white"
172− }
173− }
174−
175− Rectangle {
176− Layout.preferredHeight: units.dp(1);
177− Layout.fillWidth: true;
178− color: "black"
179− }
180−
181− Rectangle {
182− Layout.preferredHeight: units.dp(1);
183− Layout.fillWidth: true;
184− color: "black"
185− }
186−
187− Repeater {
188− model: root.originalModelData
189− RowLayout {
190− CheckBox {
191− checked: true
192− onCheckedChanged: checked ? insertIndicator(index) : removeIndicator(index);
193− }
194− Label {
195− Layout.fillWidth: true
196− text: modelData["identifier"]
197− color: "white"
198− }
199−
200− CheckBox {
201− checked: true
202− onCheckedChanged: setIndicatorVisible(index, checked);
203− }
204− Label {
205− text: "visible"
206− color: "white"
207− }
208− }
209− }
210−
211− Rectangle {
212− Layout.preferredHeight: units.dp(1);
213− Layout.fillWidth: true;
214− color: "black"
215− }
216−
217− MouseTouchEmulationCheckbox {
218− id: mouseEmulation
219− color: "white"
220− checked: panel.mode == "staged"
221− }
222−
223− RowLayout {
224− Layout.fillWidth: true
225− CheckBox {
226− id: keyboardAttached
227− }
228− Label {
229− text: "Keyboard Attached"
230− color: "white"
231− }
232− }
233− }
234− }
235−
236− Telephony.CallEntry {
237− id: phoneCall
238− phoneNumber: "+447812221111"
239− }
24037
24138 UnityTestCase {
24239 name: "Panel"
@@ -255,12 +52,18 @@ PanelTest {
25552 }
25653
25754 function init() {
55+ var messagingMenu = findChild(panel, "fake-indicator-messages-panelItem");
56+ // Make all indicators visible again
57+ for (var i = 0; i < originalModelData.length; i++) {
58+ root.setIndicatorVisible(i, false);
59+ root.setIndicatorVisible(i, true);
60+ }
25861 panel.mode = "staged";
25962 mouseEmulation.checked = true;
26063 panel.fullscreenMode = false;
26164 callManager.foregroundCall = null;
26265
263− PanelState.title = "";
66+ PanelState.title = "Fake Window Title"
26467 PanelState.decorationsVisible = false;
26568
26669 // Put the mouse somewhere neutral so it doesn't hover over things
@@ -278,6 +81,8 @@ PanelTest {
27881 compare(windowControlButtonsSpy.valid, true);
27982
28083 waitForRendering(panel);
84+ // Wait for indicators to fade in all the way using a sample
85+ tryCompare(messagingMenu, "opacity", 1);
28186 }
28287
28388 function cleanup() {
@@ -353,8 +158,6 @@ PanelTest {
353158 // expose more of the panel, binding it to the selected indicator and opening it's menu.
354159 // Tested from first Y pixel to check for swipe from offscreen.
355160 function test_drag_indicator_item_down_shows_menu(data) {
356− skip("Unstable test; panel expansion refactor may be required");
357−
358161 panel.fullscreenMode = data.fullscreen;
359162 callManager.foregroundCall = data.call;
360163
@@ -376,12 +179,18 @@ PanelTest {
376179
377180 var indicatorItem = get_indicator_item(i);
378181
182+ if (indicatorItem.hidden) {
183+ // Getting to this item would require swiping left after
184+ // pulling down
185+ continue;
186+ }
187+
379188 var startXPosition = panel.mapFromItem(indicatorItem, indicatorItem.width / 2, 0).x;
380189
381190 touchFlick(panel,
382191 startXPosition, 0,
383192 startXPosition, panel.height,
384− true /* beginTouch */, false /* endTouch */, 1, 15);
193+ true /* beginTouch */, false /* endTouch */);
385194
386195 // Indicators height should follow the drag, and therefore increase accordingly.
387196 // They should be at least half-way through the screen
@@ -435,7 +244,7 @@ PanelTest {
435244 touchFlick(data.section,
436245 data.section.width / 2, panel.height,
437246 data.section.width / 2, 0,
438− true /* beginTouch */, false /* endTouch */, units.gu(5), 15);
247+ true /* beginTouch */, false /* endTouch */);
439248
440249 // Indicators height should follow the drag, and therefore increase accordingly.
441250 // They should be at least half-way through the screen
@@ -462,7 +271,6 @@ PanelTest {
462271 }
463272
464273 function test_hint(data) {
465− PanelState.title = "Fake Title"
466274 panel.fullscreenMode = data.fullscreen;
467275 callManager.foregroundCall = data.call;
468276
@@ -504,7 +312,6 @@ PanelTest {
504312 // menus, first by running the hint animation, then after dragging down will
505313 // expose more of the panel. Releasing the touch will complete the show.
506314 function test_drag_applicationMenu_down_shows_menu(data) {
507− PanelState.title = "Fake Title";
508315 panel.fullscreenMode = data.fullscreen;
509316 callManager.foregroundCall = data.call;
510317
@@ -524,7 +331,7 @@ PanelTest {
524331 touchFlick(panel,
525332 units.gu(1), 0,
526333 units.gu(1), panel.height,
527− true /* beginTouch */, false /* endTouch */, units.gu(5), 15);
334+ true /* beginTouch */, false /* endTouch */);
528335
529336 // Indicators height should follow the drag, and therefore increase accordingly.
530337 // They should be at least half-way through the screen
@@ -596,7 +403,6 @@ PanelTest {
596403 }
597404
598405 function test_darkenedAreaEatsAllApplicationMenuEvents() {
599− PanelState.title = "Fake Title"
600406
601407 // The center of the area not covered by the indicators menu
602408 // Ie, the visible darkened area behind the menu
@@ -780,7 +586,6 @@ PanelTest {
780586 }
781587
782588 function test_windowedApplicationMenuBarShowOnMouseHover() {
783− PanelState.title = "Fake Title";
784589 panel.mode = "windowed";
785590 mouseEmulation.checked = false;
786591
@@ -844,7 +649,6 @@ PanelTest {
844649
845650 var indicatorsBar = findChild(panel.applicationMenus, "indicatorsBar");
846651
847− PanelState.title = "Fake Title";
848652 waitForRendering(panel);
849653 pullDownApplicationsMenu(0 /*xPos*/);
850654 compare(aboutToShowCalledSpy.count, 1);
@@ -878,7 +682,6 @@ PanelTest {
878682
879683 var indicatorsBar = findChild(panel.applicationMenus, "indicatorsBar");
880684
881− PanelState.title = "Fake Title"
882685 pullDownApplicationsMenu(0 /*xPos*/);
883686
884687 tryCompare(indicatorsBar, "currentItemIndex", 0);