tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   588 
   588 
   589     // current item should be third item
   589     // current item should be third item
   590     QCOMPARE(gridview->currentIndex(), 35);
   590     QCOMPARE(gridview->currentIndex(), 35);
   591     QCOMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 35));
   591     QCOMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 35));
   592     QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
   592     QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
   593     QCOMPARE(gridview->contentY(), 399.0);
   593     QCOMPARE(gridview->contentY(), 400.0);
   594 
   594 
   595     gridview->moveCurrentIndexRight();
   595     gridview->moveCurrentIndexRight();
   596     QCOMPARE(gridview->currentIndex(), 36);
   596     QCOMPARE(gridview->currentIndex(), 36);
   597     gridview->moveCurrentIndexDown();
   597     gridview->moveCurrentIndexDown();
   598     QCOMPARE(gridview->currentIndex(), 39);
   598     QCOMPARE(gridview->currentIndex(), 39);
   627     QCOMPARE(gridview->currentIndex(), 0);
   627     QCOMPARE(gridview->currentIndex(), 0);
   628 
   628 
   629     gridview->moveCurrentIndexLeft();
   629     gridview->moveCurrentIndexLeft();
   630     QCOMPARE(gridview->currentIndex(), model.count()-1);
   630     QCOMPARE(gridview->currentIndex(), model.count()-1);
   631 
   631 
   632     QTRY_COMPARE(gridview->contentY(), 879.0);
   632     QTRY_COMPARE(gridview->contentY(), 880.0);
   633 
   633 
   634     gridview->moveCurrentIndexRight();
   634     gridview->moveCurrentIndexRight();
   635     QCOMPARE(gridview->currentIndex(), 0);
   635     QCOMPARE(gridview->currentIndex(), 0);
   636 
   636 
   637     QTRY_COMPARE(gridview->contentY(), 0.0);
   637     QTRY_COMPARE(gridview->contentY(), 0.0);
   652 
   652 
   653     QTest::keyClick(canvas, Qt::Key_Up);
   653     QTest::keyClick(canvas, Qt::Key_Up);
   654     QCOMPARE(gridview->currentIndex(), 0);
   654     QCOMPARE(gridview->currentIndex(), 0);
   655 
   655 
   656     gridview->setFlow(QDeclarativeGridView::TopToBottom);
   656     gridview->setFlow(QDeclarativeGridView::TopToBottom);
       
   657 
       
   658     qApp->setActiveWindow(canvas);
       
   659 #ifdef Q_WS_X11
       
   660     // to be safe and avoid failing setFocus with window managers
       
   661     qt_x11_wait_for_window_manager(canvas);
       
   662 #endif
       
   663     QTRY_VERIFY(canvas->hasFocus());
       
   664     QTRY_VERIFY(canvas->scene()->hasFocus());
       
   665     qApp->processEvents();
   657 
   666 
   658     QTest::keyClick(canvas, Qt::Key_Right);
   667     QTest::keyClick(canvas, Qt::Key_Right);
   659     QCOMPARE(gridview->currentIndex(), 5);
   668     QCOMPARE(gridview->currentIndex(), 5);
   660 
   669 
   661     QTest::keyClick(canvas, Qt::Key_Left);
   670     QTest::keyClick(canvas, Qt::Key_Left);