@@ -27,12 +27,13 @@ Item {
2727 Carousel {
2828 anchors.fill: parent
2929 id: carousel
30− model: 40
3130
3231 property int createdDelegates: 0
3332 property int destroyedDelegates: 0
3433
3534 itemComponent: BaseCarouselDelegate {
35+ objectName: "carouselDelegate" + index
36+
3637 Rectangle {
3738 anchors.fill: parent
3839 border.color: "black"
@@ -42,6 +43,11 @@ Item {
4243 }
4344 }
4445 }
46+
47+ SignalSpy {
48+ id: spy
49+ }
50+
4551 UT.UnityTestCase {
4652 id: root
4753 name: "Carousel"
@@ -51,6 +57,8 @@ Item {
5157 property int itemCount
5258 property real tileWidth
5359
60+ property Item listView: findChild(carousel, "listView")
61+
5462 property real contentWidth: itemCount * tileWidth
5563 // following variables are copied from Carousel.qml
5664 // I'm not using the variables directly from there, as then tileWidth and others would be affected as well
@@ -60,11 +68,25 @@ Item {
6068 property real kGapEnd: kMiddleIndex * (1 - gapToEndPhase / gapToMiddlePhase)
6169 property real kXBeginningEnd: 1 / tileWidth + kMiddleIndex / gapToMiddlePhase
6270
71+ function init() {
72+ carousel.model = 40;
73+ waitForRendering(carousel)
74+ listView.positionViewAtBeginning();
75+ }
76+
77+ function cleanup() {
78+ carousel.model = 0;
79+ carousel.createdDelegates = 0;
80+ carousel.destroyedDelegates = 0;
81+ spy.target = null;
82+ spy.signalName = "";
83+ }
84+
6385 // This test needs to run first since it tests a corner case condition
6486 // to where the carousel is just being created
6587 // That is why it has a 1 in the name
6688 function test_1onlyNeededItemsCreated() {
67− tryCompare(carousel, "createdDelegates", 10);
89+ tryCompare(carousel, "createdDelegates", 9);
6890 compare(carousel.destroyedDelegates, 0);
6991 }
7092
@@ -243,5 +265,29 @@ Item {
243265 var x = carouselList.getXFromContinuousIndex(carousel.model - 1);
244266 verify(Math.abs(x - carouselList.contentX) < 1);
245267 }
268+
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");
274+
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);
281+ spy.wait();
282+
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);
289+ spy.wait();
290+ mouseRelease(carouselItem, carouselItem.width / 2, carouselItem.height / 2);
291+ }
246292 }
247293}