on xenial help sign in
Added panel title visiblity tests
a90cbc0Nick Dedekind
qml/Panel/Panel.qml+1
@@ -213,6 +213,7 @@ Item {
213
213
214 sourceComponent: MenuBar {
214 sourceComponent: MenuBar {
215 id: bar
215 id: bar
216+ objectName: "menuBar"
216 anchors.left: parent.left
217 anchors.left: parent.left
217 anchors.margins: units.gu(1)
218 anchors.margins: units.gu(1)
218 height: menuBarLoader.height
219 height: menuBarLoader.height
qml/Panel/PanelItemRow.qml+5−1
@@ -135,11 +135,12 @@ Item {
135 if (d.previousItem) {
135 if (d.previousItem) {
136 d.firstItemSwitch = false;
136 d.firstItemSwitch = false;
137 }
137 }
138− d.previousItem = currentItem;
138+ d.previousItem = currentItem;\
139 }
139 }
140
140
141 Label {
141 Label {
142 id: rowLabel
142 id: rowLabel
143+ objectName: "panelTitle"
143 anchors {
144 anchors {
144 left: parent.left
145 left: parent.left
145 leftMargin: units.gu(1)
146 leftMargin: units.gu(1)
@@ -152,14 +153,17 @@ Item {
152 font.weight: Font.Medium
153 font.weight: Font.Medium
153 color: Theme.palette.selected.backgroundText
154 color: Theme.palette.selected.backgroundText
154 opacity: showRowTitle ? 1 : 0
155 opacity: showRowTitle ? 1 : 0
156+ visible: opacity != 0
155 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
157 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
156 }
158 }
157
159
158 ListView {
160 ListView {
159 id: row
161 id: row
162+ objectName: "panelRow"
160 orientation: ListView.Horizontal
163 orientation: ListView.Horizontal
161 model: root.model
164 model: root.model
162 opacity: showRowTitle ? 0 : 1
165 opacity: showRowTitle ? 0 : 1
166+ // dont set visible on basis of opacity; otherwise width will not be calculated correctly
163 anchors {
167 anchors {
164 top: parent.top
168 top: parent.top
165 bottom: parent.bottom
169 bottom: parent.bottom
tests/qmltests/Panel/tst_Panel.qml+44−3
@@ -251,10 +251,12 @@ PanelTest {
251
251
252 function init() {
252 function init() {
253 panel.mode = "staged";
253 panel.mode = "staged";
254+ mouseEmulation.checked = true;
254 panel.fullscreenMode = false;
255 panel.fullscreenMode = false;
255 callManager.foregroundCall = null;
256 callManager.foregroundCall = null;
256
257
257− PanelState.title = ""
258+ PanelState.title = "";
259+ PanelState.decorationsVisible = false;
258
260
259 // Wait for the indicators to get into position.
261 // Wait for the indicators to get into position.
260 // (switches between normal and fullscreen modes are animated)
262 // (switches between normal and fullscreen modes are animated)
@@ -693,13 +695,11 @@ PanelTest {
693 var windowControlArea = findChild(panel, "windowControlArea");
695 var windowControlArea = findChild(panel, "windowControlArea");
694 verify(windowControlArea, "Window control area should have been created in windowed mode")
696 verify(windowControlArea, "Window control area should have been created in windowed mode")
695
697
696− var buttonsVisible = PanelState.decorationsVisible;
697 PanelState.decorationsVisible = true;
698 PanelState.decorationsVisible = true;
698 // click in very topleft corner and verify the close button got clicked too
699 // click in very topleft corner and verify the close button got clicked too
699 mouseMove(panel, 0, 0);
700 mouseMove(panel, 0, 0);
700 mouseClick(panel, 0, 0, undefined /*button*/, undefined /*modifiers*/, 100 /*short delay*/);
701 mouseClick(panel, 0, 0, undefined /*button*/, undefined /*modifiers*/, 100 /*short delay*/);
701 compare(windowControlButtonsSpy.count, 1);
702 compare(windowControlButtonsSpy.count, 1);
702− PanelState.decorationsVisible = buttonsVisible;
703 }
703 }
704
704
705 function test_hidingKeyboardIndicator_data() {
705 function test_hidingKeyboardIndicator_data() {
@@ -754,5 +754,46 @@ PanelTest {
754 tryCompareFunction(function() { return dataItem.width > 0.0; }, true);
754 tryCompareFunction(function() { return dataItem.width > 0.0; }, true);
755 }
755 }
756 }
756 }
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+ }
757 }
798 }
758}
799}
tests/qmltests/tst_Shell.qml+20
@@ -2753,5 +2753,25 @@ Rectangle {
2753 tryCompare(stage, "state", data.spreadEnabled ? "spread" : "staged");
2753 tryCompare(stage, "state", data.spreadEnabled ? "spread" : "staged");
2754 keyRelease(Qt.Key_W, Qt.MetaModifier)
2754 keyRelease(Qt.Key_W, Qt.MetaModifier)
2755 }
2755 }
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+ }
2756 }
2776 }
2757}
2777}