@@ -21,7 +21,7 @@ import Unity.Test 0.1 as UT
2121
2222Rectangle {
2323 id: root
24− width: units.gu(60)
24+ width: units.gu(80)
2525 height: units.gu(80)
2626 color: "lightgrey"
2727
@@ -44,13 +44,62 @@ Rectangle {
4444 }
4545
4646 UT.UnityTestCase {
47+ id: testCase
4748 name: "PreviewImageGalleryTest"
4849 when: windowShown
4950
51+ property Item slideShow: findChild(imageGallery.rootItem, "slideShow")
52+ property Item slideShowCloseButton: findChild(slideShow, "slideShowCloseButton")
53+ property Item slideShowListView: findChild(slideShow, "slideShowListView")
54+
55+ function cleanup() {
56+ imageGallery.widgetData = sourcesModel1;
57+ slideShow.visible = false;
58+ }
59+
5060 function test_changeEmptyModel() {
5161 imageGallery.widgetData = sourcesModel0;
5262 var placeholderScreenshot = findChild(imageGallery, "placeholderScreenshot");
5363 compare(placeholderScreenshot.visible, true);
5464 }
65+
66+ function test_slideShowOpenClose() {
67+ var image0 = findChild(imageGallery, "previewImage0");
68+ mouseClick(image0, image0.width / 2, image0.height / 2);
69+ tryCompare(slideShow, "visible", true);
70+ tryCompare(slideShow, "scale", 1.0);
71+ tryCompare(slideShowCloseButton, "visible", true);
72+ mouseClick(slideShowCloseButton, slideShowCloseButton.width / 2, slideShowCloseButton.height / 2);
73+ tryCompare(slideShow, "visible", false);
74+ }
75+
76+ function test_slideShowShowHideHeader() {
77+ var image0 = findChild(imageGallery, "previewImage0");
78+ mouseClick(image0, image0.width / 2, image0.height / 2);
79+ tryCompare(slideShow, "visible", true);
80+ tryCompare(slideShow, "scale", 1.0);
81+ tryCompare(slideShowCloseButton, "visible", true);
82+ mouseClick(slideShow, slideShow.width / 2, slideShow.height / 2);
83+ tryCompare(slideShowCloseButton, "visible", false);
84+ mouseClick(slideShow, slideShow.width / 2, slideShow.height / 2);
85+ tryCompare(slideShowCloseButton, "visible", true);
86+ }
87+
88+ function test_slideShowOpenCorrectImage_data() {
89+ return [
90+ { tag: "Image 0", index: 0 },
91+ { tag: "Image 1", index: 1 },
92+ { tag: "Image 2", index: 2 },
93+ ];
94+ }
95+
96+ function test_slideShowOpenCorrectImage(data) {
97+ var image = findChild(imageGallery, "previewImage" + data.index);
98+ mouseClick(image, image.width / 2, image.height / 2);
99+ tryCompare(slideShow, "visible", true);
100+ tryCompare(slideShow, "scale", 1.0);
101+ tryCompare(slideShowListView, "currentIndex", data.index);
102+ verify(image.source === slideShowListView.currentItem.source);
103+ }
55104 }
56105}