@@ -1,5 +1,6 @@
2 * Copyright 2013-2015 Canonical Ltd.
2 * Copyright 2013-2015 Canonical Ltd.
3+ * Copyright 2020 UBports Foundation
4 * This program is free software; you can redistribute it and/or modify
5 * 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 * it under the terms of the GNU General Public License as published by
@@ -30,213 +31,9 @@ import "../../../qml/Components/PanelState"
30import "../Stage"
31import "../Stage"
31import ".."
32import ".."
33−PanelTest {
34+PanelUI {
35 width: units.gu(120)
36 width: units.gu(120)
41− property: "keyboardAttached"
42− value: keyboardAttached.checked
45− SurfaceManager { id: sMgr }
46− ApplicationMenuDataLoader {
51− Component.onCompleted: {
52− theme.name = "Ubuntu.Components.Themes.SuruDark"
61− id: aboutToShowCalledSpy
62− signalName: "aboutToShowCalled"
67− anchors.margins: units.gu(1)
71− Layout.fillWidth: true
72− Layout.fillHeight: true
75− color: backgroundMouseArea.pressed ? "red" : "blue"
78− id: backgroundMouseArea
85− mode: modeSelector.model[modeSelector.selectedIndex]
87− indicatorMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
88− applicationMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
91− model: UnityMenuModel {
92− modelData: appMenuData.generateTestData(5, 4, 2, 3, "menu")
95− hides: [ panel.indicators ]
99− model: root.indicatorsModel
100− hides: [ panel.applicationMenus ]
107− Layout.alignment: Qt.AlignTop
108− Layout.fillWidth: false
110− ListItem.ItemSelector {
112− anchors { left: parent.left; right: parent.right }
113− activeFocusOnPress: false
115− model: ["staged", "windowed" ]
116− onSelectedIndexChanged: {
117− panel.mode = model[selectedIndex];
118− keyboardAttached.checked = panel.mode == "windowed"
123− Layout.fillWidth: true
124− text: panel.indicators.shown ? "Hide" : "Show"
126− if (panel.indicators.shown) {
127− panel.indicators.hide();
129− panel.indicators.show();
135− text: panel.fullscreenMode ? "Maximize" : "FullScreen"
136− Layout.fillWidth: true
137− onClicked: panel.fullscreenMode = !panel.fullscreenMode
141− Layout.fillWidth: true
142− text: callManager.hasCalls ? "Called" : "No Calls"
144− if (callManager.foregroundCall) {
145− callManager.foregroundCall = null;
147− callManager.foregroundCall = phoneCall;
153− Layout.fillWidth: true
155− id: windowControlsCB
156− onClicked: PanelState.decorationsVisible = checked
159− text: "Show window decorations"
165− Layout.fillWidth: true
167− onClicked: PanelState.title = checked ? "Fake window title" : ""
170− text: "Show fake window title"
176− Layout.preferredHeight: units.dp(1);
177− Layout.fillWidth: true;
182− Layout.preferredHeight: units.dp(1);
183− Layout.fillWidth: true;
188− model: root.originalModelData
192− onCheckedChanged: checked ? insertIndicator(index) : removeIndicator(index);
195− Layout.fillWidth: true
196− text: modelData["identifier"]
202− onCheckedChanged: setIndicatorVisible(index, checked);
212− Layout.preferredHeight: units.dp(1);
213− Layout.fillWidth: true;
217− MouseTouchEmulationCheckbox {
220− checked: panel.mode == "staged"
224− Layout.fillWidth: true
226− id: keyboardAttached
229− text: "Keyboard Attached"
236− Telephony.CallEntry {
238− phoneNumber: "+447812221111"
241 UnityTestCase {
38 UnityTestCase {
242 name: "Panel"
39 name: "Panel"
@@ -255,12 +52,18 @@ PanelTest {
257 function init() {
54 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);
258 panel.mode = "staged";
61 panel.mode = "staged";
259 mouseEmulation.checked = true;
62 mouseEmulation.checked = true;
260 panel.fullscreenMode = false;
63 panel.fullscreenMode = false;
261 callManager.foregroundCall = null;
64 callManager.foregroundCall = null;
263− PanelState.title = "";
66+ PanelState.title = "Fake Window Title"
264 PanelState.decorationsVisible = false;
67 PanelState.decorationsVisible = false;
266 // Put the mouse somewhere neutral so it doesn't hover over things
69 // Put the mouse somewhere neutral so it doesn't hover over things
@@ -278,6 +81,8 @@ PanelTest {
278 compare(windowControlButtonsSpy.valid, true);
81 compare(windowControlButtonsSpy.valid, true);
280 waitForRendering(panel);
83 waitForRendering(panel);
84+ // Wait for indicators to fade in all the way using a sample
85+ tryCompare(messagingMenu, "opacity", 1);
283 function cleanup() {
88 function cleanup() {
@@ -353,8 +158,6 @@ PanelTest {
353 // expose more of the panel, binding it to the selected indicator and opening it's menu.
158 // expose more of the panel, binding it to the selected indicator and opening it's menu.
354 // Tested from first Y pixel to check for swipe from offscreen.
159 // Tested from first Y pixel to check for swipe from offscreen.
355 function test_drag_indicator_item_down_shows_menu(data) {
160 function test_drag_indicator_item_down_shows_menu(data) {
356− skip("Unstable test; panel expansion refactor may be required");
358 panel.fullscreenMode = data.fullscreen;
161 panel.fullscreenMode = data.fullscreen;
359 callManager.foregroundCall = data.call;
162 callManager.foregroundCall = data.call;
@@ -376,12 +179,18 @@ PanelTest {
377 var indicatorItem = get_indicator_item(i);
180 var indicatorItem = get_indicator_item(i);
182+ if (indicatorItem.hidden) {
183+ // Getting to this item would require swiping left after
379 var startXPosition = panel.mapFromItem(indicatorItem, indicatorItem.width / 2, 0).x;
188 var startXPosition = panel.mapFromItem(indicatorItem, indicatorItem.width / 2, 0).x;
381 touchFlick(panel,
190 touchFlick(panel,
382 startXPosition, 0,
191 startXPosition, 0,
383 startXPosition, panel.height,
192 startXPosition, panel.height,
384− true /* beginTouch */, false /* endTouch */, 1, 15);
193+ true /* beginTouch */, false /* endTouch */);
386 // Indicators height should follow the drag, and therefore increase accordingly.
195 // Indicators height should follow the drag, and therefore increase accordingly.
387 // They should be at least half-way through the screen
196 // They should be at least half-way through the screen
@@ -435,7 +244,7 @@ PanelTest {
435 touchFlick(data.section,
244 touchFlick(data.section,
436 data.section.width / 2, panel.height,
245 data.section.width / 2, panel.height,
437 data.section.width / 2, 0,
246 data.section.width / 2, 0,
438− true /* beginTouch */, false /* endTouch */, units.gu(5), 15);
247+ true /* beginTouch */, false /* endTouch */);
440 // Indicators height should follow the drag, and therefore increase accordingly.
249 // Indicators height should follow the drag, and therefore increase accordingly.
441 // They should be at least half-way through the screen
250 // They should be at least half-way through the screen
@@ -462,7 +271,6 @@ PanelTest {
464 function test_hint(data) {
273 function test_hint(data) {
465− PanelState.title = "Fake Title"
466 panel.fullscreenMode = data.fullscreen;
274 panel.fullscreenMode = data.fullscreen;
467 callManager.foregroundCall = data.call;
275 callManager.foregroundCall = data.call;
@@ -504,7 +312,6 @@ PanelTest {
504 // menus, first by running the hint animation, then after dragging down will
312 // menus, first by running the hint animation, then after dragging down will
505 // expose more of the panel. Releasing the touch will complete the show.
313 // expose more of the panel. Releasing the touch will complete the show.
506 function test_drag_applicationMenu_down_shows_menu(data) {
314 function test_drag_applicationMenu_down_shows_menu(data) {
507− PanelState.title = "Fake Title";
508 panel.fullscreenMode = data.fullscreen;
315 panel.fullscreenMode = data.fullscreen;
509 callManager.foregroundCall = data.call;
316 callManager.foregroundCall = data.call;
@@ -524,7 +331,7 @@ PanelTest {
524 touchFlick(panel,
331 touchFlick(panel,
525 units.gu(1), 0,
332 units.gu(1), 0,
526 units.gu(1), panel.height,
333 units.gu(1), panel.height,
527− true /* beginTouch */, false /* endTouch */, units.gu(5), 15);
334+ true /* beginTouch */, false /* endTouch */);
529 // Indicators height should follow the drag, and therefore increase accordingly.
336 // Indicators height should follow the drag, and therefore increase accordingly.
530 // They should be at least half-way through the screen
337 // They should be at least half-way through the screen
@@ -596,7 +403,6 @@ PanelTest {
598 function test_darkenedAreaEatsAllApplicationMenuEvents() {
405 function test_darkenedAreaEatsAllApplicationMenuEvents() {
599− PanelState.title = "Fake Title"
601 // The center of the area not covered by the indicators menu
407 // The center of the area not covered by the indicators menu
602 // Ie, the visible darkened area behind the menu
408 // Ie, the visible darkened area behind the menu
@@ -780,7 +586,6 @@ PanelTest {
782 function test_windowedApplicationMenuBarShowOnMouseHover() {
588 function test_windowedApplicationMenuBarShowOnMouseHover() {
783− PanelState.title = "Fake Title";
784 panel.mode = "windowed";
589 panel.mode = "windowed";
785 mouseEmulation.checked = false;
590 mouseEmulation.checked = false;
@@ -844,7 +649,6 @@ PanelTest {
845 var indicatorsBar = findChild(panel.applicationMenus, "indicatorsBar");
650 var indicatorsBar = findChild(panel.applicationMenus, "indicatorsBar");
847− PanelState.title = "Fake Title";
848 waitForRendering(panel);
652 waitForRendering(panel);
849 pullDownApplicationsMenu(0 /*xPos*/);
653 pullDownApplicationsMenu(0 /*xPos*/);
850 compare(aboutToShowCalledSpy.count, 1);
654 compare(aboutToShowCalledSpy.count, 1);
@@ -878,7 +682,6 @@ PanelTest {
879 var indicatorsBar = findChild(panel.applicationMenus, "indicatorsBar");
683 var indicatorsBar = findChild(panel.applicationMenus, "indicatorsBar");
881− PanelState.title = "Fake Title"
882 pullDownApplicationsMenu(0 /*xPos*/);
685 pullDownApplicationsMenu(0 /*xPos*/);
884 tryCompare(indicatorsBar, "currentItemIndex", 0);
687 tryCompare(indicatorsBar, "currentItemIndex", 0);