@@ -27,12 +27,13 @@ Item {
27 Carousel {
27 Carousel {
28 anchors.fill: parent
28 anchors.fill: parent
29 id: carousel
29 id: carousel
32 property int createdDelegates: 0
31 property int createdDelegates: 0
33 property int destroyedDelegates: 0
32 property int destroyedDelegates: 0
35 itemComponent: BaseCarouselDelegate {
34 itemComponent: BaseCarouselDelegate {
35+ objectName: "carouselDelegate" + index
36 Rectangle {
37 Rectangle {
37 anchors.fill: parent
38 anchors.fill: parent
38 border.color: "black"
39 border.color: "black"
@@ -42,6 +43,11 @@ Item {
45 UT.UnityTestCase {
51 UT.UnityTestCase {
47 name: "Carousel"
53 name: "Carousel"
@@ -51,6 +57,8 @@ Item {
51 property int itemCount
57 property int itemCount
52 property real tileWidth
58 property real tileWidth
60+ property Item listView: findChild(carousel, "listView")
54 property real contentWidth: itemCount * tileWidth
62 property real contentWidth: itemCount * tileWidth
55 // following variables are copied from Carousel.qml
63 // following variables are copied from Carousel.qml
56 // I'm not using the variables directly from there, as then tileWidth and others would be affected as well
64 // I'm not using the variables directly from there, as then tileWidth and others would be affected as well
@@ -60,11 +68,25 @@ Item {
60 property real kGapEnd: kMiddleIndex * (1 - gapToEndPhase / gapToMiddlePhase)
68 property real kGapEnd: kMiddleIndex * (1 - gapToEndPhase / gapToMiddlePhase)
61 property real kXBeginningEnd: 1 / tileWidth + kMiddleIndex / gapToMiddlePhase
69 property real kXBeginningEnd: 1 / tileWidth + kMiddleIndex / gapToMiddlePhase
73+ waitForRendering(carousel)
74+ listView.positionViewAtBeginning();
79+ carousel.createdDelegates = 0;
80+ carousel.destroyedDelegates = 0;
63 // This test needs to run first since it tests a corner case condition
85 // This test needs to run first since it tests a corner case condition
64 // to where the carousel is just being created
86 // to where the carousel is just being created
65 // That is why it has a 1 in the name
87 // That is why it has a 1 in the name
66 function test_1onlyNeededItemsCreated() {
88 function test_1onlyNeededItemsCreated() {
67− tryCompare(carousel, "createdDelegates", 10);
89+ tryCompare(carousel, "createdDelegates", 9);
68 compare(carousel.destroyedDelegates, 0);
90 compare(carousel.destroyedDelegates, 0);
@@ -243,5 +265,29 @@ Item {
243 var x = carouselList.getXFromContinuousIndex(carousel.model - 1);
265 var x = carouselList.getXFromContinuousIndex(carousel.model - 1);
244 verify(Math.abs(x - carouselList.contentX) < 1);
266 verify(Math.abs(x - carouselList.contentX) < 1);
269+ function test_activate() {
270+ var carouselList = findChild(carousel, "listView");
271+ tryCompareFunction(function() { return findChild(carouselList, "carouselDelegate3") ? true : false; }, true);
272+ var carouselItem = findChild(carousel, "carouselDelegate3")
273+ verify(carouselItem, "Could not find delegate");
275+ spy.signalName = "clicked";
276+ spy.target = carouselItem;
277+ mouseClick(carouselItem, carouselItem.width / 2, carouselItem.height / 2);
278+ tryCompare(carouselList, "moving", false);
279+ tryCompare(carouselItem, "explicitlyScaled", true);
280+ mouseClick(carouselItem, carouselItem.width / 2, carouselItem.height / 2);
283+ spy.signalName = "pressAndHold";
284+ spy.target = carouselItem;
285+ mouseClick(carouselItem, carouselItem.width / 2, carouselItem.height / 2);
286+ tryCompare(carouselList, "moving", false);
287+ tryCompare(carouselItem, "explicitlyScaled", true);
288+ mousePress(carouselItem, carouselItem.width / 2, carouselItem.height / 2);
290+ mouseRelease(carouselItem, carouselItem.width / 2, carouselItem.height / 2);