@@ -0,0 +1,154 @@
2+ * Copyright 2014 Canonical Ltd.
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
6+ * the Free Software Foundation; version 3.
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+import Unity.Test 0.1 as UT
21+import "../../../qml/Stages"
22+import Ubuntu.Components 0.1
23+import Unity.Application 0.1
32+ id: fakeSurfaceComponent
39+ anchors.margins: units.gu(2)
45+ fontSizeMode: Text.Fit
46+ minimumPixelSize: 10; font.pixelSize: 200
47+ verticalAlignment: Text.AlignVCenter
54+ property int type: MirSurfaceItem.Normal
55+ property int state: MirSurfaceItem.Restored
56+ property string name: "Fake Surface"
57+ property Item parentSurface: null
58+ property list<Item> childSurfaces
59+ function release() {}
65+ id: tempSurfaceHolder
69+ id: surfaceContainerComponent
75+ id: surfaceContainerLoader
78+ topMargin: fullscreenCheckbox.checked ? 0 : units.gu(3) + units.dp(2)
79+ bottom: parent.bottom
83+ sourceComponent: surfaceContainerComponent
90+ bottom: parent.bottom
91+ left: surfaceContainerLoader.right
96+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
99+ anchors { left: parent.left; right: parent.right }
101+ id: surfaceCheckbox; checked: false;
103+ if (surfaceContainerLoader.status !== Loader.Ready)
107+ var fakeSurface = fakeSurfaceComponent.createObject(tempSurfaceHolder);
108+ surfaceContainerLoader.item.surface = fakeSurface;
110+ var fakeSurface = surfaceContainerLoader.item.surface;
111+ surfaceContainerLoader.item.surface = null;
112+ fakeSurface.parent = null;
113+ fakeSurface.destroy();
117+ Label { text: "surface" }
120+ anchors { left: parent.left; right: parent.right }
121+ CheckBox {id: fullscreenCheckbox; checked: true; }
122+ Label { text: "fullscreen" }
129+ name: "SurfaceContainer"
132+ function cleanup() {
133+ // reload our test subject to get it in a fresh state once again
134+ surfaceContainerLoader.active = false;
135+ surfaceCheckbox.checked = false;
136+ surfaceContainerLoader.active = true;
140+ Add a first surface. Then remove it. Then add a second surface.
141+ That second surface should be properly sized.
143+ Regression test for https://bugs.launchpad.net/ubuntu/+source/qtmir/+bug/1359819
145+ function test_resetSurfaceGetsProperlySized() {
146+ surfaceCheckbox.checked = true;
147+ surfaceCheckbox.checked = false;
148+ surfaceCheckbox.checked = true;
149+ var fakeSurface = surfaceContainerLoader.item.surface;
150+ compare(fakeSurface.width, surfaceContainerLoader.item.width);
151+ compare(fakeSurface.height, surfaceContainerLoader.item.height);