on xenial help sign in
Split panel
commitb2c705956b3cd6c91ec6535bb8a48572d14ed694 authorNick Dedekind <nicholas.dedekind@gmail.com> dateWed 7 May 2014, 14:59 (12 years ago) parentc423228
8 files changed+353−248
qml/Panel/ActiveCallHint.qml+2−17 qml/Panel/IndicatorRow.qml+1−1 qml/Panel/Indicators.qml+20−37 qml/Panel/Panel.qml+171−135 qml/Shell.qml−7 tests/qmltests/Panel/tst_Indicators.qml+10−21 tests/qmltests/Panel/tst_Panel.qml+120−30 tests/utils/modules/Unity/Test/UnityTestCase.qml+29
qml/Panel/ActiveCallHint.qml+2−17
@@ -23,27 +23,18 @@ import "../Components"
2323Item {
2424 id: callHint
2525
26− property bool active: true//callManager.hasCalls && ApplicationManager.focusedApplicationId !== "dialer-app"
26+ property bool active: callManager.hasCalls && ApplicationManager.focusedApplicationId !== "dialer-app"
2727 readonly property QtObject contactWatcher: _contactWatcher
2828 property int alternateLabelInterval: 4000
2929 property color color: Qt.rgba(0.1, 0.6, 0.1, 1.0)
3030 property color colorFlash: Qt.lighter(color)
31− readonly property alias mouseArea: __mouseArea
3231
3332 Component.onCompleted: {
3433 telepathyHelper.registerChannelObserver("unity8");
3534 }
3635
3736 function activate() {
38− console.log("PLOP")
39−// ApplicationManager.requestFocusApplication("dialer-app");
40− }
41−
42− Timer {
43− running: true
44− interval: 4000
45− repeat: true
46− onTriggered: active = !active
37+ ApplicationManager.requestFocusApplication("dialer-app");
4738 }
4839
4940 Rectangle {
@@ -239,12 +230,6 @@ Item {
239230 }
240231 }
241232
242− // eater
243− MouseArea {
244− id: __mouseArea
245− anchors.fill: parent
246− }
247−
248233 Telephony.ContactWatcher {
249234 id: _contactWatcher
250235 objectName: "contactWatcher"
qml/Panel/IndicatorRow.qml+1−1
@@ -36,7 +36,7 @@ Item {
3636
3737 function setDefaultItem() {
3838 // The leftmost indicator
39− setCurrentItem(0);
39+ setCurrentItemIndex(0);
4040 }
4141
4242 function setCurrentItemIndex(index) {
qml/Panel/Indicators.qml+20−37
@@ -28,7 +28,6 @@ Showable {
2828
2929 property real openedHeight: units.gu(71)
3030 property int panelHeight: units.gu(3)
31− property bool pinnedMode: true //should be set true if indicators menu can cover whole screen
3231 property alias overFlowWidth: indicatorRow.overFlowWidth
3332 property alias showAll: indicatorRow.showAll
3433 // TODO: This should be sourced by device type (eg "desktop", "tablet", "phone"...)
@@ -38,13 +37,13 @@ Showable {
3837 readonly property int lockThreshold: openedHeight / 2
3938 property bool fullyOpened: height == openedHeight
4039 property bool partiallyOpened: height > panelHeight && !fullyOpened
41− property real visualBottom: Math.max(y+height, y+indicatorRow.y+indicatorRow.height)
4240 property bool contentEnabled: true
4341 property bool initalizeItem: true
4442 readonly property alias content: menuContent
4543 property real unitProgress: (height - panelHeight) / (openedHeight - panelHeight)
4644 property bool enableHint: true
47− property real hintAreaHeightOffset: 0
45+ property real showHintBottomMargin: 0
46+ property real showHintHeightOffset: 0
4847
4948 signal showTapped(point position)
5049
@@ -53,13 +52,6 @@ Showable {
5352 showAnimation: StandardAnimation {
5453 property: "height"
5554 to: openedHeight
56−
57− // Re-size if we've changed the openHeight while shown.
58− onToChanged: {
59− if (indicators.shown) {
60− height = openedHeight;
61− }
62− }
6355 }
6456
6557 hideAnimation: StandardAnimation {
@@ -69,16 +61,24 @@ Showable {
6961 easing.type: Easing.OutCubic
7062 }
7163
64+ onOpenedHeightChanged: {
65+ if (showAnimation.running) {
66+ showAnimation.restart();
67+ } else if (indicators.shown) {
68+ height = openedHeight;
69+ }
70+ }
71+
7272 height: panelHeight
73− onHeightChanged: updateRevealProgressState(indicators.height - panelHeight, true)
73+ onHeightChanged: updateRevealProgressState(indicators.height - panelHeight - showHintBottomMargin, true)
7474
7575 function updateRevealProgressState(revealProgress, enableRelease) {
7676 if (!showAnimation.running && !hideAnimation.running) {
7777 if (revealProgress === 0) {
7878 indicators.state = "initial";
79− } else if (revealProgress > 0 && revealProgress <= hintValue) {
79+ } else if (enableHint && revealProgress > 0 && revealProgress <= hintValue) {
8080 indicators.state = "hint";
81− } else if (revealProgress > hintValue && revealProgress < lockThreshold) {
81+ } else if ((!enableHint || revealProgress > hintValue) && revealProgress < lockThreshold) {
8282 indicators.state = "reveal";
8383 } else if (revealProgress >= lockThreshold && lockThreshold > 0) {
8484 indicators.state = "locked";
@@ -173,17 +173,6 @@ Showable {
173173 }
174174 }
175175
176− VerticalThinDivider {
177− anchors {
178− top: indicators.top
179− topMargin: panelHeight
180− bottom: handle.bottom
181− right: indicators.left
182− }
183− width: units.dp(2)
184− source: "graphics/VerticalDivider.png"
185− }
186−
187176 VisibleIndicators {
188177 id: visibleIndicators
189178 }
@@ -247,10 +236,6 @@ Showable {
247236 }
248237 }
249238
250− PanelBackground {
251− anchors.fill: indicatorRow
252− }
253−
254239 IndicatorRow {
255240 id: indicatorRow
256241 objectName: "indicatorRow"
@@ -358,17 +343,17 @@ Showable {
358343 id: showDragHandle
359344 anchors.bottom: parent.bottom
360345 // go beyond parent so that it stays reachable, at the top of the screen.
361− anchors.bottomMargin: pinnedMode ? 0 : -panelHeight
346+ anchors.bottomMargin: showHintBottomMargin
362347 anchors.left: parent.left
363348 anchors.right: parent.right
364− height: panelHeight + hintAreaHeightOffset
349+ height: panelHeight + showHintHeightOffset
365350 direction: Direction.Downwards
366351 enabled: !indicators.shown && indicators.available
367− hintDisplacement: enableHint && pinnedMode ? indicators.hintValue : 0
352+ hintDisplacement: enableHint ? indicators.hintValue : 0
368353 autoCompleteDragThreshold: maxTotalDragDistance / 2
369354 stretch: true
370355 maxTotalDragDistance: openedHeight - panelHeight
371− distanceThreshold: pinnedMode ? 0 : units.gu(3)
356+ distanceThreshold: panelHeight
372357
373358 onStatusChanged: {
374359 if (status === DirectionalDragArea.Recognized) {
@@ -376,8 +361,9 @@ Showable {
376361 }
377362 }
378363
379− onTapped: showTapped(Qt.point(x + touchX, y + touchY))
364+ onTapped: showTapped(Qt.point(touchSceneX, touchSceneY));
380365 }
366+
381367 DragHandle {
382368 id: hideDragHandle
383369 anchors.fill: handle
@@ -400,10 +386,6 @@ Showable {
400386 },
401387 State {
402388 name: "hint"
403− PropertyChanges {
404− target: indicatorRow;
405− y: pinnedMode ? 0 : panelHeight
406− }
407389 StateChangeScript {
408390 script: {
409391 if (d.activeDragHandle) {
@@ -436,5 +418,6 @@ Showable {
436418 Component.onCompleted: initialise();
437419 function initialise() {
438420 visibleIndicators.load(profile);
421+ indicatorRow.setDefaultItem();
439422 }
440423}
qml/Panel/Panel.qml+171−135
@@ -18,11 +18,13 @@ import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import Unity.Application 0.1
2020import "../Components"
21+import "../Components/ListItems"
2122
2223Item {
2324 id: root
24− readonly property real panelHeight: indicatorArea.y + indicatorArea.indicatorHeight
25− property alias indicators: indicatorsMenu
25+ readonly property real panelHeight: nonIndicatorArea.y + nonIndicatorArea.height
26+ property alias indicators: __indicators
27+ property alias callHint: __callHint
2628 property bool fullscreenMode: false
2729 property bool searchVisible: true
2830
@@ -33,7 +35,7 @@ Item {
3335 hideTimer.interval = delay;
3436 hideTimer.start();
3537 } else {
36− indicatorsMenu.hide();
38+ indicators.hide();
3739 }
3840 }
3941
@@ -41,124 +43,122 @@ Item {
4143 id: hideTimer
4244 running: false
4345 onTriggered: {
44− indicatorsMenu.hide();
46+ indicators.hide();
4547 }
4648 }
4749
4850 Connections {
49− target: indicatorsMenu
51+ target: indicators
5052 onShownChanged: hideTimer.stop()
5153 }
5254
53− PanelBackground {
54− id: callHintBackground
55− anchors.fill: callHint
56− }
57−
58− ActiveCallHint {
59− id: callHint
60−
55+ Rectangle {
56+ id: darkenedArea
57+ property real darkenedOpacity: 0.6
6158 anchors {
6259 left: parent.left
6360 right: parent.right
61+ top: nonIndicatorArea.bottom
62+ bottom: parent.bottom
6463 }
65− height: units.gu(3)
66− y: -height
64+ color: "black"
65+ opacity: indicators.unitProgress * darkenedOpacity
6766
68− states: [
69− State {
70− name: "active"
71− when: callHint.active
72− PropertyChanges { target: callHint; y: 0 }
73− PropertyChanges { target: search.mouseArea; anchors.topMargin: -callHint.height/3 }
74− }
75− ]
76− Behavior on y { StandardAnimation { id: callHintYAnimation } }
77−
78− mouseArea.onClicked: callHint.activate();
79−
80− Rectangle {
81− anchors.fill: callHint.mouseArea
82− color: Qt.rgba(0,1,0,0.5)
67+ MouseArea {
68+ anchors.fill: parent
69+ enabled: indicators.shown
70+ onClicked: if (indicators.fullyOpened) indicators.hide();
8371 }
8472 }
8573
74+ PanelBackground {
75+ anchors.fill: nonIndicatorArea
76+ }
77+
8678 Item {
87− id: indicatorArea
79+ id: nonIndicatorArea
8880 objectName: "indicatorArea"
89− z: 1
90−
91− readonly property real indicatorHeight: indicatorsMenu.panelHeight + leftSeparatorLine.height
9281
9382 anchors {
83+ top: callHint.bottom
9484 left: parent.left
9585 right: parent.right
9686 }
97− height: root.height - indicatorArea.y
98−
99− Behavior on y {
100− enabled: !callHintYAnimation.running
101− StandardAnimation {}
102− }
103−
104− PanelBackground {
105− id: panelBackground
106− anchors {
107− top: parent.top
108− left: parent.left
109− right: parent.right
110− }
111− height: indicatorsMenu.panelHeight
112− }
87+ height: d.indicatorHeight
11388
11489 PanelSeparatorLine {
11590 id: leftSeparatorLine
11691 anchors {
117− top: panelBackground.bottom
92+ bottom: parent.bottom
11893 left: parent.left
119− right: indicatorsMenu.left
94+ right: parent.right
12095 }
121− saturation: 1 - indicatorsMenu.unitProgress
96+ saturation: 1 - indicators.unitProgress
12297 }
12398
124− Rectangle {
125− id: darkenedArea
126− property real darkenedOpacity: 0.6
99+ MouseArea {
100+ id: nonIndicatorMouseArea
101+ enabled: callHint.active
127102 anchors {
103+ top: parent.top
128104 left: parent.left
129105 right: parent.right
130− top: leftSeparatorLine.bottom
131− bottom: parent.bottom
132106 }
133− color: "black"
134− opacity: indicatorsMenu.unitProgress * darkenedOpacity
107+ height: indicators.panelHeight/2
108+ onClicked: callHint.activate();
109+ }
110+ }
135111
136− MouseArea {
137− anchors.fill: parent
138− enabled: indicatorsMenu.shown
139− onClicked: if (indicatorsMenu.fullyOpened) indicatorsMenu.hide();
140− }
112+ // eater
113+ MouseArea {
114+ anchors.fill: callHint
115+ onClicked: callHint.activate()
116+ }
117+
118+ Item {
119+ id: indicatorArea
120+ objectName: "indicatorArea"
121+
122+ anchors {
123+ top: callHint.bottom
124+ right: parent.right
125+ bottom: parent.bottom
141126 }
127+ width: indicators.width
142128
143− MouseArea {
144− id: indicatorAreaClick
145− enabled: callHint.active
129+ Behavior on anchors.topMargin { StandardAnimation {} }
130+
131+ BorderImage {
132+ id: dropShadow
146133 anchors {
147− top: parent.top
148− left: search.right
149− right: indicatorsMenu.right
134+ fill: indicators
135+ leftMargin: -units.gu(1)
136+ bottomMargin: -units.gu(1)
150137 }
151− height: indicatorsMenu.panelHeight/2
152− onClicked: callHint.activate();
138+ visible: indicators.height > indicators.panelHeight
139+ source: "graphics/rectangular_dropshadow.sci"
140+ }
141+
142+ VerticalThinDivider {
143+ id: indicatorDividor
144+ anchors {
145+ top: indicators.top
146+ bottom: indicators.bottom
147+ right: indicators.left
153148
154− Rectangle {
155− anchors.fill: indicatorAreaClick
156− color: Qt.rgba(0,1,0,0.5)
149+ topMargin: nonIndicatorArea.anchors.topMargin + indicators.panelHeight
157150 }
151+
152+ width: units.dp(2)
153+ source: "graphics/VerticalDivider.png"
154+ }
155+
156+ PanelBackground {
157+ anchors.fill: indicators
158158 }
159159
160160 Indicators {
161− id: indicatorsMenu
161+ id: __indicators
162162 objectName: "indicators"
163163
164164 anchors {
@@ -169,92 +169,128 @@ Item {
169169 width: (root.width > units.gu(60)) ? units.gu(40) : root.width
170170 shown: false
171171 panelHeight: units.gu(3)
172− openedHeight: parent.height
173− pinnedMode: !fullscreenMode
174− enableHint: !callHint.active
175− overFlowWidth: search.state=="hidden" ? parent.width : parent.width - search.width
176− hintAreaHeightOffset: callHint.active ? callHint.height : 0
172+ openedHeight: root.height - (callHint.y + callHint.height)
173+ overFlowWidth: search.state=="hidden" ? root.width : root.width - search.width
174+
175+ enableHint: !callHint.active && !fullscreenMode
176+ showHintBottomMargin: fullscreenMode ? -panelHeight : 0
177+ showHintHeightOffset: callHint.active ? callHint.height : 0
177178
178179 onShowTapped: {
179− if (callHint.active && position.y < y + indicatorsMenu.panelHeight/2) {
180− callHint.activate();
180+ if (callHint.active) {
181+ var callHintScenePosition = callHint.mapToItem(null, callHint.x, callHint.y);
182+ var indicatorScenePosition = mapToItem(null, x, y);
183+
184+ // tapped on callHint
185+ if (position.y > callHintScenePosition.y && position.y <= callHintScenePosition.y + callHint.height) {
186+ callHint.activate();
187+ // tapped on top half of indicator
188+ } else if (!fullscreenMode && position.y > indicatorScenePosition.y && position.y < indicatorScenePosition.y + panelHeight/2) {
189+ callHint.activate();
190+ }
181191 }
182192 }
183−
184− Rectangle {
185− anchors.fill: indicatorsMenu
186− color: Qt.rgba(1,1,0,0.5)
187− }
188193 }
189194
190195 PanelSeparatorLine {
191196 id: indicatorsSeparatorLine
192197 visible: true
193198 anchors {
194− left: indicatorsMenu.left
195− right: indicatorsMenu.right
196− }
197− y: indicatorsMenu.visualBottom
198− }
199−
200− BorderImage {
201− id: dropShadow
202− anchors {
203− top: indicators.top
204− bottom: indicatorsSeparatorLine.bottom
205− left: indicators.left
199+ top: indicators.bottom
200+ left: indicatorDividor.left
206201 right: indicators.right
207− margins: -units.gu(1)
208202 }
209− visible: indicatorsMenu.height > indicatorsMenu.panelHeight
210− source: "graphics/rectangular_dropshadow.sci"
211203 }
204+ }
212205
213− SearchIndicator {
214− id: search
215− objectName: "search"
216− enabled: root.searchVisible
206+ SearchIndicator {
207+ id: search
208+ objectName: "search"
209+ enabled: root.searchVisible
217210
218− state: {
219− if (parent.width < indicatorsMenu.width + width) {
220− if (indicatorsMenu.state != "initial") {
221− return "hidden";
222− }
211+ state: {
212+ if (parent.width < indicators.width + width) {
213+ if (indicators.state != "initial") {
214+ return "hidden";
223215 }
224− if (root.searchVisible && !indicatorsMenu.showAll) {
225− return "visible";
226− }
227− return "hidden";
228216 }
229−
230− anchors {
231− top: parent.top
232− left: parent.left
217+ if (root.searchVisible && !indicators.showAll) {
218+ return "visible";
233219 }
234− height: panelBackground.height
220+ return "hidden";
221+ }
235222
236− mouseArea {
237− onClicked: root.searchClicked()
238− }
239− Rectangle {
240− anchors.fill: search.mouseArea
241− color: Qt.rgba(1,0,0,0.5)
242− }
223+ anchors {
224+ top: nonIndicatorArea.top
225+ bottom: nonIndicatorArea.bottom
226+ left: nonIndicatorArea.left
243227 }
228+
229+ mouseArea {
230+ onClicked: root.searchClicked()
231+ }
232+ }
233+
234+ ActiveCallHint {
235+ id: __callHint
236+ anchors {
237+ left: parent.left
238+ right: parent.right
239+ }
240+ height: units.gu(3)
241+ y: -height
242+
243+ states: [
244+ State {
245+ name: "active"
246+ when: callHint.active
247+ PropertyChanges { target: callHint; y: 0 }
248+ PropertyChanges { target: search.mouseArea; anchors.topMargin: -callHint.height/3 }
249+ }
250+ ]
251+ Behavior on y { StandardAnimation {} }
252+ }
253+
254+ QtObject {
255+ id: d
256+ readonly property real indicatorHeight: indicators.panelHeight + leftSeparatorLine.height
244257 }
245258
246259 states: [
247260 State {
248− name: "in" //fully opaque and visible at top edge of screen
261+ name: "onscreen" //fully opaque and visible at top edge of screen
249262 when: !fullscreenMode
250− PropertyChanges { target: indicatorArea; y: callHint.y + callHint.height }
251− PropertyChanges { target: callHint; z: 0 }
252263 },
253264 State {
254− name: "out" //pushed off screen
265+ name: "offscreen" //pushed off screen
255266 when: fullscreenMode
256− PropertyChanges { target: indicatorArea; y: callHint.y + callHint.height - indicatorHeight }
257− PropertyChanges { target: callHint; z: 2 }
267+ PropertyChanges { target: nonIndicatorArea; anchors.topMargin: -d.indicatorHeight }
268+ PropertyChanges { target: indicatorArea; anchors.topMargin: indicators.state === "initial" ? -d.indicatorHeight : 0 }
269+ }
270+ ]
271+
272+ transitions: [
273+ Transition {
274+ to: "onscreen"
275+ SequentialAnimation {
276+ ParallelAnimation {
277+ StandardAnimation { target: nonIndicatorArea; property: "anchors.topMargin" }
278+ StandardAnimation { target: indicatorArea; property: "anchors.topMargin" }
279+ }
280+ PropertyAction { target: search; property: "z"; value: 2 }
281+ PropertyAction { target: indicatorArea; property: "z"; value: 2 }
282+ }
283+ },
284+ Transition {
285+ to: "offscreen"
286+ SequentialAnimation {
287+ PropertyAction { target: search; property: "z"; value: 0 }
288+ PropertyAction { target: indicatorArea; property: "z"; value: 0 }
289+ ParallelAnimation {
290+ StandardAnimation { target: nonIndicatorArea; property: "anchors.topMargin" }
291+ StandardAnimation { target: indicatorArea; property: "anchors.topMargin" }
292+ }
293+ }
258294 }
259295 ]
260296}
qml/Shell.qml−7
@@ -461,13 +461,6 @@ FocusScope {
461461 panel.hideIndicatorMenu(delay);
462462 }
463463
464− Timer {
465− running: true
466− interval: 7000
467− repeat: true
468− onTriggered: {panel.fullscreenMode = !panel.fullscreenMode }
469− }
470−
471464 Item {
472465 id: overlay
473466
tests/qmltests/Panel/tst_Indicators.qml+10−21
@@ -17,6 +17,7 @@
1717import QtQuick 2.0
1818import QtTest 1.0
1919import Unity.Test 0.1 as UT
20+import Ubuntu.Components 0.1 as UC
2021import ".."
2122import "../../../qml/Panel"
2223import "../../../qml/Components"
@@ -45,13 +46,12 @@ Item {
4546 shown: false
4647 profile: "test1"
4748
48− openedHeight: parent.height - click_me.height
49+ openedHeight: parent.height - button.height
4950 }
5051
51− // Just a rect for clicking to open the indicators.
52− Rectangle {
53− id: click_me
54− color: "red"
52+ UC.Button {
53+ id: button
54+ text: indicators.shown ? "Hide" : "Show"
5555 anchors {
5656 bottom: shell.bottom
5757 left: parent.left
@@ -59,22 +59,11 @@ Item {
5959 }
6060 height: 50
6161
62− Text {
63− text: "Click Me"
64− horizontalAlignment: Text.AlignHCenter
65− verticalAlignment: Text.AlignVCenter
66− anchors.fill: parent
67−
68− MouseArea {
69− anchors.fill: parent
70−
71− onClicked: {
72− if (!indicators.shown) {
73− indicators.show();
74− } else {
75− indicators.hide();
76− }
77− }
62+ onClicked: {
63+ if (!indicators.shown) {
64+ indicators.show();
65+ } else {
66+ indicators.hide();
7867 }
7968 }
8069 }
tests/qmltests/Panel/tst_Panel.qml+120−30
@@ -17,6 +17,7 @@
1717import QtQuick 2.0
1818import QtTest 1.0
1919import Unity.Test 0.1 as UT
20+import Ubuntu.Components 0.1 as UC
2021import Ubuntu.Telephony 0.1 as Telephony
2122import ".."
2223import "../../../qml/Panel"
@@ -40,13 +41,81 @@ Item {
4041
4142 Panel {
4243 id: panel
43− anchors.fill: parent
44+ anchors {
45+ left: parent.left
46+ right: parent.right
47+ }
48+ height: parent.height - row.height
4449 fullscreenMode: false
4550
4651 indicators {
4752 profile: "test1"
4853 panelHeight: units.gu(5)
4954 }
55+ callHint {
56+ height: units.gu(4)
57+ }
58+
59+ onSearchClicked: console.log("Search Clicked")
60+
61+ property real panelAndSeparatorHeight: panel.indicators.panelHeight + units.dp(2)
62+ }
63+
64+
65+ Row {
66+ id: row
67+ anchors {
68+ bottom: shell.bottom
69+ left: parent.left
70+ right: parent.right
71+ }
72+ height: 50
73+
74+ UC.Button {
75+ text: panel.indicators.shown ? "Hide" : "Show"
76+ anchors {
77+ top: parent.top
78+ bottom: parent.bottom
79+ }
80+ width: parent.width/3
81+
82+ onClicked: {
83+ if (panel.indicators.shown) {
84+ panel.indicators.hide();
85+ } else {
86+ panel.indicators.show();
87+ }
88+ }
89+ }
90+
91+ UC.Button {
92+ text: panel.fullscreenMode ? "Maximize" : "FullScreen"
93+ anchors {
94+ top: parent.top
95+ bottom: parent.bottom
96+ }
97+ width: parent.width/3
98+
99+ onClicked: panel.fullscreenMode = !panel.fullscreenMode
100+ }
101+
102+ UC.Button {
103+ text: callManager.hasCalls ? "Called" : "No Calls"
104+ anchors {
105+ top: parent.top
106+ bottom: parent.bottom
107+ }
108+ width: parent.width/3
109+
110+ onClicked: {
111+ if (callManager.hasCalls) {
112+ callManager.foregroundCall = null;
113+ callManager.backgroundCall = null;
114+ } else {
115+ callManager.foregroundCall = phoneCall;
116+ }
117+ }
118+ }
50119 }
51120
52121 Telephony.CallEntry {
@@ -60,12 +129,18 @@ Item {
60129
61130 function init() {
62131 panel.indicators.initialise();
132+ panel.fullscreenMode = false;
63133
64134 searchClicked = false;
65135 panel.indicators.hide();
136+ // Wait for animation to complete
66137 tryCompare(panel.indicators.hideAnimation, "running", false);
67− tryCompare(panel.indicators, "state", "initial");
68138 callManager.foregroundCall = null;
139+
140+ // Wait for the indicators to get into position.
141+ // (switches between normal and fullscreen modes are animated)
142+ var indicatorArea = findChild(panel, "indicatorArea");
143+ tryCompare(indicatorArea, "y", 0);
69144 }
70145
71146 function get_indicator_item(index) {
@@ -88,27 +163,22 @@ Item {
88163 // Pressing on the indicator panel should activate the indicator hints
89164 // and expose a portion of the conent.
90165 function test_hint() {
91− panel.fullscreenMode = false;
92− // Wait for the indicators to get into position.
93− // (switches between normal and fullscreen modes are animated)
94− tryCompare(panel.indicators, "y", 0);
95−
96166 var indicatorItemCoord = get_indicator_item_position(0);
97167
98− touchPress(panel, indicatorItemCoord.x, panel.panelHeight / 2);
168+ touchPress(panel, indicatorItemCoord.x, panel.indicators.panelHeight / 2);
99169
100170 // hint animation should be run, meaning that indicators will move downwards
101171 // by hintValue pixels without any drag taking place
102− tryCompare(panel.indicators, "height",
103− panel.indicators.panelHeight + panel.indicators.hintValue);
172+ tryCompareFunction2(function() { return panel.indicators.height },
173+ function() { return panel.indicators.panelHeight + panel.indicators.hintValue });
104174 tryCompare(panel.indicators, "partiallyOpened", true);
105175 tryCompare(panel.indicators, "fullyOpened", false);
106176
107− touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
177+ touchRelease(panel, indicatorItemCoord.x, panel.indicators.panelHeight/2);
108178 }
109179
110180 // Pressing on the top edge of the screen should have no effect if the panel
111− // is hidden (!pinned), which is the case when a fullscreen app is being shown
181+ // is hidden (fullscreen), which is the case when a fullscreen app is being shown
112182 function test_noHintOnFullscreenMode() {
113183 panel.fullscreenMode = true;
114184 // Wait for the indicators to get into position.
@@ -118,17 +188,38 @@ Item {
118188
119189 var indicatorItemCoord = get_indicator_item_position(0);
120190
121− touchPress(panel, indicatorItemCoord.x, panel.panelHeight / 2);
191+ touchPress(panel, indicatorItemCoord.x, panel.indicators.panelHeight / 2);
192+
193+ // Give some time for a hint animation to change things, if any
194+ wait(500);
195+
196+ // no hint animation when fullscreen
197+ compare(panel.indicators.partiallyOpened, false,
198+ "Indicator should not be partially opened when panel is pressed in" +
199+ " fullscreenmode");
200+ compare(panel.indicators.fullyOpened, false, "Indicator should not be partially" +
201+ " opened when panel is pressed in fullscreenmode");
202+
203+ touchRelease(panel, indicatorItemCoord.x, panel.panelHeight/2);
204+ }
205+
206+ // Pressing on the top edge of the indicator should have no effect if the panel
207+ // has an active call
208+ function test_noHintOnActiveCall() {
209+ callManager.foregroundCall = phoneCall;
210+ // Wait for the indicators to get into position.
211+ // (switches between normal and fullscreen modes are animated)
212+ var indicatorArea = findChild(panel, "indicatorArea");
213+ tryCompare(indicatorArea, "y", panel.callHint.height);
214+
215+ var indicatorItemCoord = get_indicator_item_position(0);
216+
217+ touchPress(panel, indicatorItemCoord.x, panel.callHint.height + panel.indicators.panelHeight / 2);
122218
123219 // Give some time for a hint animation to change things, if any
124220 wait(500);
125221
126222 // no hint animation when fullscreen
127− compare(indicatorArea.y, -panel.panelHeight);
128− var indicatorRow = findChild(panel.indicators, "indicatorRow");
129− verify(indicatorRow !== null);
130− compare(indicatorRow.y, 0);
131− compare(panel.indicators.height, panel.indicators.panelHeight);
132223 compare(panel.indicators.partiallyOpened, false,
133224 "Indicator should not be partially opened when panel is pressed in" +
134225 " fullscreenmode");
@@ -143,15 +234,15 @@ Item {
143234 { tag: "pinned", fullscreenFlag: false, alreadyOpen: false, call: null,
144235 indicatorY: function() { return 0 } },
145236 { tag: "fullscreen", fullscreenFlag: true, alreadyOpen: false, call: null,
146− indicatorY: function() {return -panel.panelHeight } },
237+ indicatorY: function() {return -panel.panelAndSeparatorHeight } },
147238 { tag: "pinned-alreadyOpen", fullscreenFlag: false, alreadyOpen: true, call: null,
148239 indicatorY: function() { return 0 } },
149240 { tag: "fullscreen-alreadyOpen", fullscreenFlag: true, alreadyOpen: true, call: null,
150− indicatorY: function() {return -panel.panelHeight } },
241+ indicatorY: function() {return -panel.panelAndSeparatorHeight } },
151242 { tag: "pinned-callActive", fullscreenFlag: false, alreadyOpen: false, call: phoneCall,
152− indicatorY: function() { return units.gu(3) } },
243+ indicatorY: function() { return panel.callHint.height } },
153244 { tag: "fullscreen-callActive", fullscreenFlag: true, alreadyOpen: false, call: phoneCall,
154− indicatorY: function() {return units.gu(3) - (panel.panelHeight - units.gu(3)) } }
245+ indicatorY: function() { return panel.callHint.height - panel.panelAndSeparatorHeight } }
155246 ];
156247 }
157248
@@ -160,7 +251,6 @@ Item {
160251 // expose more of the panel, binding it to the selected indicator and opening it's menu.
161252 function test_drag_show(data) {
162253 panel.fullscreenMode = data.fullscreenFlag;
163−
164254 callManager.foregroundCall = data.call;
165255
166256 if (data.alreadyOpen) {
@@ -179,7 +269,7 @@ Item {
179269
180270 // Wait for the indicators to get into position.
181271 // (switches between normal and fullscreen modes are animated)
182− tryCompare(indicatorArea, "y", data.indicatorY());
272+ tryCompareFunction2(function() { return indicatorArea.y } , data.indicatorY);
183273
184274 // do this for each indicator item
185275 for (var i = 0; i < indicatorRow.row.count; i++) {
@@ -193,11 +283,11 @@ Item {
193283 var indicatorItemCoord = get_indicator_item_position(i);
194284
195285 touchPress(panel,
196− indicatorItemCoord.x, panel.panelHeight / 2);
286+ indicatorItemCoord.x, panel.indicators.panelHeight / 2);
197287
198288 // 1) Drag the mouse down
199289 touchFlick(panel,
200− indicatorItemCoord.x, panel.panelHeight / 2,
290+ indicatorItemCoord.x, panel.indicators.panelHeight / 2,
201291 indicatorItemCoord.x, panel.height,
202292 false /* beginTouch */, false /* endTouch */);
203293
@@ -266,19 +356,19 @@ Item {
266356 var indicatorItemCoordNext = get_indicator_item_position(indicatorRow.row.count - 1);
267357
268358 touchPress(panel,
269− indicatorItemCoordFirst.x, panel.panelHeight / 2);
359+ indicatorItemCoordFirst.x, panel.indicators.panelHeight / 2);
270360
271361 // 1) Drag the mouse down to hint a bit
272362 touchFlick(panel,
273− indicatorItemCoordFirst.x, panel.panelHeight / 2,
274− indicatorItemCoordFirst.x, panel.panelHeight * 2,
363+ indicatorItemCoordFirst.x, panel.indicators.panelHeight / 2,
364+ indicatorItemCoordFirst.x, panel.indicators.panelHeight * 2,
275365 false /* beginTouch */, false /* endTouch */);
276366
277367 tryCompare(indicatorRow, "currentItem", indicatorItemFirst)
278368
279369 // 1) Flick mouse down to bottom
280370 touchFlick(panel,
281− indicatorItemCoordFirst.x, panel.panelHeight * 2,
371+ indicatorItemCoordFirst.x, panel.indicators.panelHeight * 2,
282372 indicatorItemCoordNext.x, panel.height,
283373 false /* beginTouch */, true /* endTouch */,
284374 units.gu(10) /* speed */, 30 /* iterations */); // more samples needed for accurate velocity
tests/utils/modules/Unity/Test/UnityTestCase.qml+29
@@ -202,6 +202,35 @@ TestCase {
202202 }
203203 }
204204
205+ // Keeps executing a given parameter-less function until it returns the given
206+ // expected result or the timemout is reached (in which case a test failure
207+ // is generated)
208+ function tryCompareFunction2(func, expectedResultFunc) {
209+ var timeSpent = 0
210+ var timeout = 5000
211+ var success = false
212+ var actualResult
213+ var expectedResult
214+ while (timeSpent < timeout && !success) {
215+ actualResult = func()
216+ expectedResult = expectedResultFunc()
217+ success = qtest_compareInternal(actualResult, expectedResult)
218+ if (success === false) {
219+ wait(50)
220+ timeSpent += 50
221+ }
222+ }
223+
224+ var act = qtest_results.stringify(actualResult)
225+ var exp = qtest_results.stringify(expectedResult)
226+ if (!qtest_results.compare(success,
227+ "function returned unexpected result",
228+ act, exp,
229+ util.callerFile(), util.callerLine())) {
230+ throw new Error("QtQuickTest::fail")
231+ }
232+ }
233+
205234 function touchEvent() {
206235 return UT.Util.touchEvent()
207236 }