~feng-kylin/unity8/fix-lp1413791

« back to all changes in this revision

Viewing changes to tests/qmltests/Stages/tst_SessionContainer.qml

  • Committer: Michael Zanetti
  • Date: 2015-06-17 12:14:27 UTC
  • mfrom: (1595.1.214 unity8)
  • mto: (1595.1.232 unity8)
  • mto: This revision was merged to the branch mainline in revision 1608.
  • Revision ID: michael.zanetti@canonical.com-20150617121427-lgc70azrbtsanejb
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2014 Canonical Ltd.
 
2
 * Copyright 2014-2015 Canonical Ltd.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
41
41
        SessionContainer {
42
42
            id: sessionContainer
43
43
            anchors.fill: parent
44
 
            orientation: Qt.PortraitOrientation
45
44
            focus: true
46
45
            interactive: true
47
46
        }
117
116
                    session: sessionContainerLoader.item ? sessionContainerLoader.item.session : null
118
117
                }
119
118
            }
120
 
 
121
 
            Button {
122
 
                anchors { left: parent.left; right: parent.right }
123
 
                text: "Rotate device \u27F3"
124
 
                onClicked: {
125
 
                    var orientation = sessionContainerLoader.item.orientation
126
 
                    if (orientation == Qt.PortraitOrientation) {
127
 
                        orientation = Qt.LandscapeOrientation;
128
 
                    } else if (orientation == Qt.LandscapeOrientation) {
129
 
                        orientation = Qt.InvertedPortraitOrientation;
130
 
                    } else if (orientation == Qt.InvertedPortraitOrientation) {
131
 
                        orientation = Qt.InvertedLandscapeOrientation;
132
 
                    } else {
133
 
                        orientation = Qt.PortraitOrientation;
134
 
                    }
135
 
                    sessionContainerLoader.item.orientation = orientation;
136
 
                }
137
 
            }
138
119
        }
139
120
    }
140
121
 
324
305
            // wait for animation to end
325
306
            tryCompareFunction(function() { return isContainerAnimating(childContainer); }, false);
326
307
        }
327
 
 
328
 
        function test_orientationPropagatedToChildren_data() {
329
 
            return [ { tag: "count=1", count: 1 },
330
 
                     { tag: "count=4", count: 4 } ];
331
 
        }
332
 
 
333
 
        /* Test orientation changes are propagated to all children immediately */
334
 
        function test_orientationPropagatedToChildren(data) {
335
 
            sessionCheckbox.checked = true;
336
 
            var rootSessionContainer = sessionContainerLoader.item;
337
 
            compare(rootSessionContainer.childSessions.count(), 0);
338
 
 
339
 
            var i;
340
 
            var sessions = [];
341
 
            for (i = 0; i < data.count; i++) {
342
 
                var session = ApplicationTest.addChildSession(rootSessionContainer.session,
343
 
                                                              "gallery");
344
 
                session.createSurface();
345
 
                rootSessionContainer.session.addChildSession(session);
346
 
 
347
 
                // Check child SessionContainer has orientation matching the parent
348
 
                var delegate = findChild(rootSessionContainer, "childDelegate" + i);
349
 
                var childSessionContainer = findChild(delegate, "sessionContainer");
350
 
 
351
 
                tryCompare(rootSessionContainer, "orientation", childSessionContainer.orientation);
352
 
 
353
 
                sessions.push(session);
354
 
            }
355
 
 
356
 
            // Change orientation and verify all children updated
357
 
            rootSessionContainer.orientation = Qt.LandscapeOrientation;
358
 
 
359
 
            for (i = 0; i < data.count; i++) {
360
 
                var delegate = findChild(rootSessionContainer, "childDelegate" + i);
361
 
                var childSessionContainer = findChild(delegate, "sessionContainer");
362
 
 
363
 
                tryCompare(rootSessionContainer, "orientation", childSessionContainer.orientation);
364
 
            }
365
 
 
366
 
            // Clean up
367
 
            for (i = data.count-1; i >= 0; i--) {
368
 
                ApplicationTest.removeSession(sessions[i]);
369
 
            }
370
 
        }
371
308
    }
372
309
}