@@ -1,5 +1,5 @@
2− * Copyright 2014 Canonical Ltd.
2+ * Copyright 2014-2015 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import QtTest 1.0
18import QtTest 1.0
19−import Unity.Test 0.1 as UT
19+import Unity.Test 0.1
20import ".."
20import ".."
21import "../../../qml/Stages"
21import "../../../qml/Stages"
22import Ubuntu.Components 0.1
22import Ubuntu.Components 0.1
@@ -32,6 +32,8 @@ Rectangle {
32 id: surfaceContainerComponent
32 id: surfaceContainerComponent
33 SurfaceContainer {
33 SurfaceContainer {
34 anchors.fill: parent
34 anchors.fill: parent
35+ orientation: Qt.PortraitOrientation
36+ interactive: interactiveCheckbox.checked
@@ -85,6 +87,12 @@ Rectangle {
85 CheckBox {id: fullscreenCheckbox; checked: true; }
87 CheckBox {id: fullscreenCheckbox; checked: true; }
86 Label { text: "fullscreen" }
88 Label { text: "fullscreen" }
91+ anchors { left: parent.left; right: parent.right }
92+ CheckBox {id: interactiveCheckbox; checked: true; }
93+ Label { text: "interactive" }
95+ MouseTouchEmulationCheckbox {}
@@ -94,7 +102,7 @@ Rectangle {
94 signalName: "surfaceDestroyed"
102 signalName: "surfaceDestroyed"
97− UT.UnityTestCase {
105+ UnityTestCase {
98 id: testCase
106 id: testCase
99 name: "SurfaceContainer"
107 name: "SurfaceContainer"
100 when: windowShown
108 when: windowShown
@@ -110,6 +118,8 @@ Rectangle {
111 tryCompare(surfaceContainerLoader.item, "surface", null);
119 tryCompare(surfaceContainerLoader.item, "surface", null);
112 surfaceSpy.clear();
120 surfaceSpy.clear();
122+ interactiveCheckbox.checked = true;
@@ -145,14 +155,13 @@ Rectangle {
145 surfaceContainer.surface.touchPressCount = 0;
155 surfaceContainer.surface.touchPressCount = 0;
146 surfaceContainer.surface.touchReleaseCount = 0;
156 surfaceContainer.surface.touchReleaseCount = 0;
148− surfaceContainer.interactive = true;
149 tap(surfaceContainer, surfaceContainer.width / 2, surfaceContainer.height / 2);
158 tap(surfaceContainer, surfaceContainer.width / 2, surfaceContainer.height / 2);
151 // surface got touches as the surfaceContainer is interactive
160 // surface got touches as the surfaceContainer is interactive
152 compare(surfaceContainer.surface.touchPressCount, 1)
161 compare(surfaceContainer.surface.touchPressCount, 1)
153 compare(surfaceContainer.surface.touchReleaseCount, 1);
162 compare(surfaceContainer.surface.touchReleaseCount, 1);
155− surfaceContainer.interactive = false;
164+ interactiveCheckbox.checked = false;
156 tap(surfaceContainer, surfaceContainer.width / 2, surfaceContainer.height / 2);
165 tap(surfaceContainer, surfaceContainer.width / 2, surfaceContainer.height / 2);
158 // surface shouldn't get the touches from the second tap as the surfaceContainer
167 // surface shouldn't get the touches from the second tap as the surfaceContainer
@@ -160,5 +169,23 @@ Rectangle {
160 compare(surfaceContainer.surface.touchPressCount, 1)
169 compare(surfaceContainer.surface.touchPressCount, 1)
161 compare(surfaceContainer.surface.touchReleaseCount, 1);
170 compare(surfaceContainer.surface.touchReleaseCount, 1);
173+ function test_surfaceGetsActiveFocusOnMousePress() {
174+ surfaceCheckbox.checked = true;
175+ verify(surfaceContainer.surface !== null);
177+ compare(surfaceContainer.surface.activeFocus, false);
178+ mouseClick(surfaceContainer);
179+ compare(surfaceContainer.surface.activeFocus, true);
182+ function test_surfaceGetsActiveFocusOnTap() {
183+ surfaceCheckbox.checked = true;
184+ verify(surfaceContainer.surface !== null);
186+ compare(surfaceContainer.surface.activeFocus, false);
187+ tap(surfaceContainer);
188+ compare(surfaceContainer.surface.activeFocus, true);