on xenial help sign in
app menu tests
commitbc6847bcaf78064161222d8a24b116ebbc01efb4 authorNick Dedekind <nick.dedekind@canonical.com> dateMon 28 Nov 2016, 16:32 (10 years ago) parentcd56007
6 files changed+127−80
qml/ApplicationMenus/ApplicationMenuItemFactory.qml+2−2 qml/Components/DragHandle.qml+1 qml/Panel/Panel.qml+10−9 qml/Rotation/RotationStates.qml+2−2 qml/Shell.qml+1−1 tests/qmltests/Panel/tst_Panel.qml+111−66
qml/ApplicationMenus/ApplicationMenuItemFactory.qml+2−2
@@ -19,7 +19,6 @@ import Ubuntu.Settings.Menus 0.1 as Menus
1919import Ubuntu.Settings.Components 0.1
2020import QMenuModel 0.1
2121import Utils 0.1 as Utils
22−import Ubuntu.Components.ListItems 1.3 as ListItems
2322import Ubuntu.Components 1.3
2423
2524Object {
@@ -114,7 +113,8 @@ Object {
114113 Component {
115114 id: applicationMenuSeparator;
116115
117− ListItems.Divider {
116+ Menus.SeparatorMenu {
117+ objectName: "separatorMenu"
118118 }
119119 }
120120
qml/Components/DragHandle.qml+1
@@ -67,6 +67,7 @@ SwipeArea {
6767 SmoothedAnimation {
6868 id: hintingAnimation
6969 target: hintingAnimation
70+ objectName: "hintingAnimation"
7071 property: "targetValue"
7172 duration: 150
7273 velocity: -1
qml/Panel/Panel.qml+10−9
@@ -35,7 +35,7 @@ import "Indicators"
3535
3636Item {
3737 id: root
38− readonly property real panelHeight: indicatorArea.y + minimizedPanelHeight
38+ readonly property real panelHeight: panelArea.y + minimizedPanelHeight
3939
4040 property real minimizedPanelHeight: units.gu(3)
4141 property real expandedPanelHeight: units.gu(7)
@@ -45,7 +45,7 @@ Item {
4545 property alias applicationMenus: __applicationMenus
4646 property alias indicators: __indicators
4747 property bool fullscreenMode: false
48− property real indicatorAreaShowProgress: 1.0
48+ property real panelAreaShowProgress: 1.0
4949 property bool locked: false
5050 property bool greeterShown: false
5151
@@ -77,14 +77,14 @@ Item {
7777 }
7878
7979 Item {
80− id: indicatorArea
81− objectName: "indicatorArea"
80+ id: panelArea
81+ objectName: "panelArea"
8282
8383 anchors.fill: parent
8484
8585 transform: Translate {
8686 y: indicators.state === "initial"
87− ? (1.0 - indicatorAreaShowProgress) * - minimizedPanelHeight
87+ ? (1.0 - panelAreaShowProgress) * - minimizedPanelHeight
8888 : 0
8989 }
9090
@@ -239,6 +239,7 @@ Item {
239239 rowItemDelegate: ActionItem {
240240 id: actionItem
241241 property int ownIndex: index
242+ objectName: "appMenuItem"+index
242243
243244 width: _title.width + units.gu(2)
244245 height: parent.height
@@ -377,7 +378,7 @@ Item {
377378 name: "onscreen" //fully opaque and visible at top edge of screen
378379 when: !fullscreenMode
379380 PropertyChanges {
380− target: indicatorArea;
381+ target: panelArea;
381382 anchors.topMargin: 0
382383 opacity: 1;
383384 }
@@ -386,7 +387,7 @@ Item {
386387 name: "offscreen" //pushed off screen
387388 when: fullscreenMode
388389 PropertyChanges {
389− target: indicatorArea;
390+ target: panelArea;
390391 anchors.topMargin: {
391392 if (indicators.state !== "initial") return 0;
392393 if (applicationMenus.state !== "initial") return 0;
@@ -408,11 +409,11 @@ Item {
408409 transitions: [
409410 Transition {
410411 to: "onscreen"
411− UbuntuNumberAnimation { target: indicatorArea; properties: "anchors.topMargin,opacity" }
412+ UbuntuNumberAnimation { target: panelArea; properties: "anchors.topMargin,opacity" }
412413 },
413414 Transition {
414415 to: "offscreen"
415− UbuntuNumberAnimation { target: indicatorArea; properties: "anchors.topMargin,opacity" }
416+ UbuntuNumberAnimation { target: panelArea; properties: "anchors.topMargin,opacity" }
416417 }
417418 ]
418419}
qml/Rotation/RotationStates.qml+2−2
@@ -273,13 +273,13 @@ StateGroup {
273273 } }
274274 NumberAnimation {
275275 duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing
276− target: root.shell; property: "indicatorAreaShowProgress"
276+ target: root.shell; property: "panelAreaShowProgress"
277277 from: 1.0; to: 0.0
278278 }
279279 ImmediateRotationAction { info: d; shell: root.shell }
280280 NumberAnimation {
281281 duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing
282− target: root.shell; property: "indicatorAreaShowProgress"
282+ target: root.shell; property: "panelAreaShowProgress"
283283 from: 0.0; to: 1.0
284284 }
285285 ScriptAction { script: {
qml/Shell.qml+1−1
@@ -57,7 +57,7 @@ StyledItem {
5757 property Orientations orientations
5858 property real nativeWidth
5959 property real nativeHeight
60− property alias indicatorAreaShowProgress: panel.indicatorAreaShowProgress
60+ property alias panelAreaShowProgress: panel.panelAreaShowProgress
6161 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
6262 property string mode: "full-greeter"
6363 property alias oskEnabled: inputMethod.enabled
tests/qmltests/Panel/tst_Panel.qml+111−66
@@ -262,8 +262,8 @@ PanelTest {
262262
263263 // Wait for the indicators to get into position.
264264 // (switches between normal and fullscreen modes are animated)
265− var indicatorArea = findChild(panel, "indicatorArea");
266− tryCompare(indicatorArea, "y", 0);
265+ var panelArea = findChild(panel, "panelArea");
266+ tryCompare(panelArea, "y", 0);
267267
268268 backgroundPressedSpy.clear();
269269 compare(backgroundPressedSpy.valid, true);
@@ -298,16 +298,12 @@ PanelTest {
298298 tryCompare(panel.applicationMenus, "fullyOpened", true);
299299 }
300300
301− function test_drag_show_data() {
301+ function test_drag_indicator_item_down_shows_menu_data() {
302302 return [
303− { tag: "pinned", fullscreen: false, call: null,
304− indicatorY: 0 },
305− { tag: "fullscreen", fullscreen: true, call: null,
306− indicatorY: -panel.indicators.minimizedPanelHeight },
307− { tag: "pinned-callActive", fullscreen: false, call: phoneCall,
308− indicatorY: 0},
309− { tag: "fullscreen-callActive", fullscreen: true, call: phoneCall,
310− indicatorY: -panel.indicators.minimizedPanelHeight }
303+ { tag: "pinned", fullscreen: false, call: null, y: 0 },
304+ { tag: "fullscreen", fullscreen: true, call: null, y: -panel.minimizedPanelHeight },
305+ { tag: "pinned-callActive", fullscreen: false, call: phoneCall, y: 0},
306+ { tag: "fullscreen-callActive", fullscreen: true, call: phoneCall, y: -panel.minimizedPanelHeight }
311307 ];
312308 }
313309
@@ -315,7 +311,7 @@ PanelTest {
315311 // indicators, first by running the hint animation, then after dragging down will
316312 // expose more of the panel, binding it to the selected indicator and opening it's menu.
317313 // Tested from first Y pixel to check for swipe from offscreen.
318− function test_drag_show(data) {
314+ function test_drag_indicator_item_down_shows_menu(data) {
319315 panel.fullscreenMode = data.fullscreen;
320316 callManager.foregroundCall = data.call;
321317
@@ -325,12 +321,12 @@ PanelTest {
325321 var menuContent = findChild(panel.indicators, "menuContent");
326322 verify(menuContent !== null);
327323
328− var indicatorArea = findChild(panel, "indicatorArea");
329− verify(indicatorArea !== null);
324+ var panelArea = findChild(panel, "panelArea");
325+ verify(panelArea !== null);
330326
331327 // Wait for the indicators to get into position.
332328 // (switches between normal and fullscreen modes are animated)
333− tryCompareFunction(function() { return indicatorArea.y }, data.indicatorY);
329+ tryCompareFunction(function() { return panelArea.y }, data.y);
334330
335331 for (var i = 0; i < root.originalModelData.length; i++) {
336332 var indicatorItem = get_indicator_item(i);
@@ -360,95 +356,144 @@ PanelTest {
360356 }
361357 }
362358
363− function test_drag_hide_data() {
359+ function test_drag_panel_handle_up_hides_menu_data() {
364360 return [
365− { tag: "pinned", fullscreen: false, call: null,
366− indicatorY: 0 },
367− { tag: "fullscreen", fullscreen: true, call: null,
368− indicatorY: -panel.indicators.minimizedPanelHeight },
369− { tag: "pinned-callActive", fullscreen: false, call: phoneCall,
370− indicatorY: 0},
371− { tag: "fullscreen-callActive", fullscreen: true, call: phoneCall,
372− indicatorY: -panel.indicators.minimizedPanelHeight }
361+ { tag: "indicators-pinned", section: panel.indicators, fullscreen: false, call: null },
362+ { tag: "indicators-fullscreen", section: panel.indicators, fullscreen: true, call: null },
363+ { tag: "indicators-pinned-callActive", section: panel.indicators, fullscreen: false, call: phoneCall },
364+ { tag: "indicators-fullscreen-callActive", section: panel.indicators, fullscreen: true, call: phoneCall },
365+ { tag: "appMenus-pinned", section: panel.applicationMenus, fullscreen: false, call: null },
366+ { tag: "appMenus-fullscreen", section: panel.applicationMenus, fullscreen: true, call: null },
367+ { tag: "appMenus-pinned-callActive", section: panel.applicationMenus, fullscreen: false, call: phoneCall },
368+ { tag: "appMenus-fullscreen-callActive", section: panel.applicationMenus, fullscreen: true, call: phoneCall }
373369 ];
374370 }
375371
376372 // Dragging the shown indicators up from bottom of panel will hide the indicators
377373 // Tested from last Y pixel to check for swipe from offscreen.
378− function test_drag_hide(data) {
374+ function test_drag_panel_handle_up_hides_menu(data) {
379375 panel.fullscreenMode = data.fullscreen;
380376 callManager.foregroundCall = data.call;
381377
382− var panelRow = findChild(panel.indicators, "panelItemRow");
378+ var panelRow = findChild(data.section, "panelItemRow");
383379 verify(panelRow !== null);
384380
385− var menuContent = findChild(panel.indicators, "menuContent");
386− verify(menuContent !== null);
387−
388− var indicatorArea = findChild(panel, "indicatorArea");
389− verify(indicatorArea !== null);
381+ var panelArea = findChild(panel, "panelArea");
382+ verify(panelArea !== null);
390383
391384 // Wait for the indicators to get into position.
392385 // (switches between normal and fullscreen modes are animated)
393− tryCompareFunction(function() { return indicatorArea.y }, data.indicatorY);
386+ tryCompareFunction(function() { return panelArea.y }, data.fullscreen ? -panel.minimizedPanelHeight : 0);
394387
395− panel.indicators.show();
396− tryCompare(panel.indicators.showAnimation, "running", false);
397− tryCompare(panel.indicators, "unitProgress", 1);
388+ data.section.show();
389+ tryCompare(data.section.showAnimation, "running", false);
390+ tryCompare(data.section, "unitProgress", 1);
398391
399− touchFlick(panel.indicators,
400− panel.indicators.width / 2, panel.height,
401− panel.indicators.width / 2, 0,
392+ touchFlick(data.section,
393+ data.section.width / 2, panel.height,
394+ data.section.width / 2, 0,
402395 true /* beginTouch */, false /* endTouch */, units.gu(5), 15);
403396
404397 // Indicators height should follow the drag, and therefore increase accordingly.
405398 // They should be at least half-way through the screen
406399 tryCompareFunction(
407− function() {return panel.indicators.height <= panel.height * 0.5},
400+ function() {return data.section.height <= panel.height * 0.5},
408401 true);
409402
410− touchRelease(panel.indicators, panel.indicators.width / 2, 0);
403+ touchRelease(data.section, data.section.width / 2, 0);
411404
412− tryCompare(panel.indicators.hideAnimation, "running", true);
413− tryCompare(panel.indicators.hideAnimation, "running", false);
414− tryCompare(panel.indicators, "state", "initial");
405+ tryCompare(data.section.hideAnimation, "running", true);
406+ tryCompare(data.section.hideAnimation, "running", false);
407+ tryCompare(data.section, "state", "initial");
415408 }
416409
417410 function test_hint_data() {
418411 return [
419− { tag: "normal", fullscreen: false, call: null, hintExpected: true},
420− { tag: "fullscreen", fullscreen: true, call: null, hintExpected: false},
421− { tag: "call hint", fullscreen: false, call: phoneCall, hintExpected: false},
412+ { tag: "indicators-normal", section: panel.indicators, fullscreen: false, call: null, hintExpected: true},
413+ { tag: "indicators-fullscreen", section: panel.indicators, fullscreen: true, call: null, hintExpected: false},
414+ { tag: "indicators-callActive", section: panel.indicators, fullscreen: false, call: phoneCall, hintExpected: false},
415+ { tag: "appMenus-normal", section: panel.applicationMenus, fullscreen: false, call: null, hintExpected: true},
416+ { tag: "appMenus-fullscreen", section: panel.applicationMenus, fullscreen: true, call: null, hintExpected: false},
417+ { tag: "appMenus-callActive", section: panel.applicationMenus, fullscreen: false, call: phoneCall, hintExpected: false},
422418 ];
423419 }
424420
425421 function test_hint(data) {
422+ PanelState.title = "Fake Title"
426423 panel.fullscreenMode = data.fullscreen;
427424 callManager.foregroundCall = data.call;
428425
429426 if (data.fullscreen) {
430427 // Wait for the indicators to get into position.
431428 // (switches between normal and fullscreen modes are animated)
432− var indicatorArea = findChild(panel, "indicatorArea");
433− tryCompare(indicatorArea, "y", -panel.panelHeight);
429+ var panelArea = findChild(panel, "panelArea");
430+ tryCompare(panelArea, "y", -panel.minimizedPanelHeight);
434431 }
435432
436− var indicatorItem = get_indicator_item(0);
437− var mappedPosition = root.mapFromItem(indicatorItem, indicatorItem.width / 2, indicatorItem.height / 2);
433+ var mappedPosition = root.mapFromItem(data.section,
434+ data.section.barWidth / 2, data.section.minimizedPanelHeight / 2);
438435
439− touchPress(panel, mappedPosition.x, panel.indicators.minimizedPanelHeight / 2);
436+ touchPress(panel, mappedPosition.x, panel.minimizedPanelHeight / 2);
440437
441− // Give some time for a hint animation to change things, if any
442− wait(500);
438+ var showDragHandle = findChild(data.section, "showDragHandle")
439+ var hintingAnimation = findInvisibleChild(showDragHandle, "hintingAnimation");
440+ verify(hintingAnimation);
441+
442+ compare(hintingAnimation.running, data.hintExpected)
443+ tryCompare(hintingAnimation, "running", false); // wait till animation completes
443444
444445 // no hint animation when fullscreen
445− compare(panel.indicators.fullyClosed, !data.hintExpected, "Indicator should be fully closed");
446− compare(panel.indicators.partiallyOpened, data.hintExpected, "Indicator should be partialy opened");
447− compare(panel.indicators.fullyOpened, false, "Indicator should not be fully opened");
446+ compare(data.section.partiallyOpened, data.hintExpected, "Indicator should be partialy opened");
447+ compare(data.section.fullyOpened, false, "Indicator should not be fully opened");
448448
449449 touchRelease(panel, mappedPosition.x, panel.minimizedPanelHeight / 2);
450450 }
451451
452+ function test_drag_applicationMenu_down_shows_menu_data() {
453+ return [
454+ { tag: "normal", fullscreen: false, call: null, hintExpected: true},
455+ { tag: "fullscreen", fullscreen: true, call: null, hintExpected: false},
456+ { tag: "callActive", fullscreen: false, call: phoneCall, hintExpected: false}
457+ ];
458+ }
459+
460+ // Dragging the application menu will gradually expose the
461+ // menus, first by running the hint animation, then after dragging down will
462+ // expose more of the panel. Releasing the touch will complete the show.
463+ function test_drag_applicationMenu_down_shows_menu(data) {
464+ PanelState.title = "Fake Title";
465+ panel.fullscreenMode = data.fullscreen;
466+ callManager.foregroundCall = data.call;
467+
468+ var panelRow = findChild(panel.indicators, "panelItemRow");
469+ verify(panelRow !== null);
470+
471+ var menuContent = findChild(panel.indicators, "menuContent");
472+ verify(menuContent !== null);
473+
474+ var panelArea = findChild(panel, "panelArea");
475+ verify(panelArea !== null);
476+
477+ // Wait for the indicators to get into position.
478+ // (switches between normal and fullscreen modes are animated)
479+ tryCompareFunction(function() { return panelArea.y }, data.fullscreen ? -panel.minimizedPanelHeight : 0);
480+
481+ touchFlick(panel,
482+ units.gu(1), 0,
483+ units.gu(1), panel.height,
484+ true /* beginTouch */, false /* endTouch */, units.gu(5), 15);
485+
486+ // Indicators height should follow the drag, and therefore increase accordingly.
487+ // They should be at least half-way through the screen
488+ tryCompareFunction(
489+ function() {return panel.applicationMenus.height >= panel.height * 0.5},
490+ true);
491+
492+ touchRelease(panel, units.gu(1), panel.height);
493+
494+ tryCompare(panel.applicationMenus, "fullyOpened", true)
495+ }
496+
452497 /* Checks that no input reaches items behind the indicator bar.
453498 Ie., the indicator bar should eat all input events that hit it.
454499 */
@@ -457,7 +502,7 @@ PanelTest {
457502 // that it doesn't have a "weak spot" from where taps pass through.
458503 var numTaps = 5;
459504 var stepLength = (panel.width / (numTaps + 1));
460− var tapY = panel.indicators.minimizedPanelHeight / 2;
505+ var tapY = panel.minimizedPanelHeight / 2;
461506 for (var i = 1; i <= numTaps; ++i) {
462507 tap(panel, stepLength * i, tapY);
463508 tryCompare(panel.indicators, "fullyClosed", true);
@@ -469,8 +514,8 @@ PanelTest {
469514 // The center of the area not covered by the indicators menu
470515 // Ie, the visible darkened area behind the menu
471516 var touchPosX = (panel.width - panel.indicators.width) / 2
472− var touchPosY = panel.indicators.minimizedPanelHeight +
473− ((panel.height - panel.indicators.minimizedPanelHeight) / 2)
517+ var touchPosY = panel.minimizedPanelHeight +
518+ ((panel.height - panel.minimizedPanelHeight) / 2)
474519
475520 // input goes through while the indicators menu is closed
476521 tryCompare(panel.indicators, "fullyClosed", true);
@@ -512,8 +557,8 @@ PanelTest {
512557 // The center of the area not covered by the indicators menu
513558 // Ie, the visible darkened area behind the menu
514559 var touchPosX = panel.applicationMenus.width + (panel.width - panel.applicationMenus.width) / 2
515− var touchPosY = panel.applicationMenus.minimizedPanelHeight +
516− ((panel.height - panel.applicationMenus.minimizedPanelHeight) / 2)
560+ var touchPosY = panel.minimizedPanelHeight +
561+ ((panel.height - panel.minimizedPanelHeight) / 2)
517562
518563 // input goes through while the indicators menu is closed
519564 tryCompare(panel.applicationMenus, "fullyClosed", true);
@@ -557,12 +602,12 @@ PanelTest {
557602 panel.
558603 */
559604 function test_tapNearTopEdgeWithPanelInFullscreenMode() {
560− var indicatorArea = findChild(panel, "indicatorArea");
561− verify(indicatorArea);
605+ var panelArea = findChild(panel, "panelArea");
606+ verify(panelArea);
562607
563608 panel.fullscreenMode = true;
564609 // wait until if finishes hiding itself
565− tryCompare(indicatorArea, "y", -panel.minimizedPanelHeight);
610+ tryCompare(panelArea, "y", -panel.minimizedPanelHeight);
566611
567612 compare(panel.indicators.shown, false);
568613 verify(panel.indicators.fullyClosed);
@@ -591,7 +636,7 @@ PanelTest {
591636
592637 mouseClick(panel.indicators,
593638 panel.indicators.width / 2,
594− panel.indicators.minimizedPanelHeight / 2);
639+ panel.minimizedPanelHeight / 2);
595640
596641 compare(panel.indicators.shown, false);
597642 verify(panel.indicators.fullyClosed);
@@ -603,7 +648,7 @@ PanelTest {
603648
604649 mouseClick(panel.indicators,
605650 panel.indicators.width / 2,
606− panel.indicators.minimizedPanelHeight / 2);
651+ panel.minimizedPanelHeight / 2);
607652
608653 compare(panel.indicators.shown, true);
609654 tryCompare(panel.indicators, "fullyOpened", true);