on xenial help sign in
Added panel title visiblity tests
commita90cbc0f7abd7656f9b250a3980d1ad494dc2cd1 authorNick Dedekind <nick.dedekind@canonical.com> dateMon 9 Jan 2017, 14:10 (10 years ago) parent94ee999
4 files changed+70−4
qml/Panel/Panel.qml+1 qml/Panel/PanelItemRow.qml+5−1 tests/qmltests/Panel/tst_Panel.qml+44−3 tests/qmltests/tst_Shell.qml+20
qml/Panel/Panel.qml+1
@@ -213,6 +213,7 @@ Item {
213213
214214 sourceComponent: MenuBar {
215215 id: bar
216+ objectName: "menuBar"
216217 anchors.left: parent.left
217218 anchors.margins: units.gu(1)
218219 height: menuBarLoader.height
qml/Panel/PanelItemRow.qml+5−1
@@ -135,11 +135,12 @@ Item {
135135 if (d.previousItem) {
136136 d.firstItemSwitch = false;
137137 }
138− d.previousItem = currentItem;
138+ d.previousItem = currentItem;\
139139 }
140140
141141 Label {
142142 id: rowLabel
143+ objectName: "panelTitle"
143144 anchors {
144145 left: parent.left
145146 leftMargin: units.gu(1)
@@ -152,14 +153,17 @@ Item {
152153 font.weight: Font.Medium
153154 color: Theme.palette.selected.backgroundText
154155 opacity: showRowTitle ? 1 : 0
156+ visible: opacity != 0
155157 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
156158 }
157159
158160 ListView {
159161 id: row
162+ objectName: "panelRow"
160163 orientation: ListView.Horizontal
161164 model: root.model
162165 opacity: showRowTitle ? 0 : 1
166+ // dont set visible on basis of opacity; otherwise width will not be calculated correctly
163167 anchors {
164168 top: parent.top
165169 bottom: parent.bottom
tests/qmltests/Panel/tst_Panel.qml+44−3
@@ -251,10 +251,12 @@ PanelTest {
251251
252252 function init() {
253253 panel.mode = "staged";
254+ mouseEmulation.checked = true;
254255 panel.fullscreenMode = false;
255256 callManager.foregroundCall = null;
256257
257− PanelState.title = ""
258+ PanelState.title = "";
259+ PanelState.decorationsVisible = false;
258260
259261 // Wait for the indicators to get into position.
260262 // (switches between normal and fullscreen modes are animated)
@@ -693,13 +695,11 @@ PanelTest {
693695 var windowControlArea = findChild(panel, "windowControlArea");
694696 verify(windowControlArea, "Window control area should have been created in windowed mode")
695697
696− var buttonsVisible = PanelState.decorationsVisible;
697698 PanelState.decorationsVisible = true;
698699 // click in very topleft corner and verify the close button got clicked too
699700 mouseMove(panel, 0, 0);
700701 mouseClick(panel, 0, 0, undefined /*button*/, undefined /*modifiers*/, 100 /*short delay*/);
701702 compare(windowControlButtonsSpy.count, 1);
702− PanelState.decorationsVisible = buttonsVisible;
703703 }
704704
705705 function test_hidingKeyboardIndicator_data() {
@@ -754,5 +754,46 @@ PanelTest {
754754 tryCompareFunction(function() { return dataItem.width > 0.0; }, true);
755755 }
756756 }
757+
758+ function test_stagedApplicationMenuBarShowOnMouseHover() {
759+ PanelState.title = "Fake Title";
760+ panel.mode = "staged";
761+ mouseEmulation.checked = false;
762+
763+ var appTitle = findChild(panel.applicationMenus, "panelTitle"); verify(appTitle);
764+ var appMenuRow = findChild(panel.applicationMenus, "panelRow"); verify(appMenuRow);
765+ var appMenuBar = findChild(panel, "menuBar"); verify(appMenuBar);
766+
767+ tryCompare(appTitle, "visible", true, undefined, "App title should be visible");
768+ tryCompare(appMenuBar, "visible", false, undefined, "App menu bar should not be visible");
769+
770+ mouseMove(panel, panel.width/2, panel.panelHeight);
771+
772+ tryCompare(appTitle, "visible", false, undefined, "App title should not be visible on mouse hover");
773+ tryCompare(appMenuBar, "visible", true, undefined, "App menu bar should be visible on mouse hover");
774+ }
775+
776+ function test_windowedApplicationMenuShowOnMouseHoverWhenDecorationsShown() {
777+ PanelState.title = "Fake Title";
778+ panel.mode = "windowed";
779+ mouseEmulation.checked = false;
780+
781+ var appTitle = findChild(panel.applicationMenus, "panelTitle"); verify(appTitle);
782+ var appMenuRow = findChild(panel.applicationMenus, "panelRow"); verify(appMenuRow);
783+ var appMenuBar = findChild(panel, "menuBar"); verify(appMenuBar);
784+
785+ tryCompare(appTitle, "visible", true, undefined, "App title should be visible");
786+ tryCompare(appMenuBar, "visible", false, undefined, "App menu bar should not be visible");
787+
788+ mouseMove(panel, panel.width/2, panel.panelHeight);
789+
790+ tryCompare(appTitle, "visible", true, undefined, "App title should still be visible on mouse hover when panel decorations are not visible");
791+ tryCompare(appMenuBar, "visible", false, undefined, "App menu bar should be visible on mouse hover when panel decorations are not visible");
792+
793+ PanelState.decorationsVisible = true;
794+
795+ tryCompare(appTitle, "visible", false, undefined, "App title should still be visible on mouse hover when panel decorations are visible");
796+ tryCompare(appMenuBar, "visible", true, undefined, "App menu bar should be visible on mouse hover when panel decorations not visible");
797+ }
757798 }
758799}
tests/qmltests/tst_Shell.qml+20
@@ -2753,5 +2753,25 @@ Rectangle {
27532753 tryCompare(stage, "state", data.spreadEnabled ? "spread" : "staged");
27542754 keyRelease(Qt.Key_W, Qt.MetaModifier)
27552755 }
2756+
2757+ function test_panelTitleShowsWhenGreeterNotShown_data() {
2758+ return [
2759+ {tag: "phone" },
2760+ {tag: "tablet" },
2761+ {tag: "desktop" }
2762+ ]
2763+ }
2764+
2765+ function test_panelTitleShowsWhenGreeterNotShown(data) {
2766+ loadShell(data.tag);
2767+
2768+ var panel = findChild(shell, "panel"); verify(panel);
2769+ var panelTitle = findChild(panel.applicationMenus, "panelTitle"); verify(panelTitle);
2770+ compare(panelTitle.visible, false, "Panel title should not be visible when greeter is shown");
2771+
2772+ swipeAwayGreeter();
2773+
2774+ tryCompare(panelTitle, "visible", true, undefined, "Panel title should be visible when greeter not shown");
2775+ }
27562776 }
27572777}