qtmobility/tests/auto/testqgeopositioninfosource.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 11 06b8e2af4411
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
    45 #include <QDebug>
    45 #include <QDebug>
    46 #include <QTimer>
    46 #include <QTimer>
    47 
    47 
    48 #include <limits.h>
    48 #include <limits.h>
    49 
    49 
       
    50 #include <qnumeric.h>
    50 #include <qgeopositioninfosource.h>
    51 #include <qgeopositioninfosource.h>
    51 #include <qgeopositioninfo.h>
    52 #include <qgeopositioninfo.h>
    52 
    53 
    53 #include "testqgeopositioninfosource_p.h"
    54 #include "testqgeopositioninfosource_p.h"
    54 #include "qlocationtestutils_p.h"
    55 #include "qlocationtestutils_p.h"
   178 }
   179 }
   179 
   180 
   180 // TC_ID_3_x_1
   181 // TC_ID_3_x_1
   181 void TestQGeoPositionInfoSource::constructor_withParent()
   182 void TestQGeoPositionInfoSource::constructor_withParent()
   182 {
   183 {
   183     QLocationTestUtils::uheap_mark();
   184     //QLocationTestUtils::uheap_mark();
   184     QObject *parent = new QObject();
   185     QObject *parent = new QObject();
   185     new MyPositionSource(parent);
   186     new MyPositionSource(parent);
   186     delete parent;
   187     delete parent;
   187     QLocationTestUtils::uheap_mark_end();
   188     //QLocationTestUtils::uheap_mark_end();
   188 }
   189 }
   189 
   190 
   190 // TC_ID_3_x_2
   191 // TC_ID_3_x_2
   191 void TestQGeoPositionInfoSource::constructor_noParent()
   192 void TestQGeoPositionInfoSource::constructor_noParent()
   192 {
   193 {
   193     QLocationTestUtils::uheap_mark();
   194     //QLocationTestUtils::uheap_mark();
   194     MyPositionSource *obj = new MyPositionSource();
   195     MyPositionSource *obj = new MyPositionSource();
   195     delete obj;
   196     delete obj;
   196     QLocationTestUtils::uheap_mark_end();
   197     //QLocationTestUtils::uheap_mark_end();
   197 }
   198 }
   198 
   199 
   199 void TestQGeoPositionInfoSource::updateInterval()
   200 void TestQGeoPositionInfoSource::updateInterval()
   200 {
   201 {
   201     MyPositionSource s;
   202     MyPositionSource s;
   271 
   272 
   272 //TC_ID_3_x_1 : Create a position source with the given parent that reads from the system's default
   273 //TC_ID_3_x_1 : Create a position source with the given parent that reads from the system's default
   273 // sources of location data
   274 // sources of location data
   274 void TestQGeoPositionInfoSource::createDefaultSource()
   275 void TestQGeoPositionInfoSource::createDefaultSource()
   275 {
   276 {
   276     QLocationTestUtils::uheap_mark();
   277     //QLocationTestUtils::uheap_mark();
   277     QObject *parent = new QObject;
   278     QObject *parent = new QObject;
   278 
   279 
   279     QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(parent);
   280     QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(parent);
   280 #if defined(Q_OS_SYMBIAN)
   281 #if defined(Q_OS_SYMBIAN)
   281     QVERIFY(source != 0);
   282     QVERIFY(source != 0);
   282 #elif defined(Q_OS_WINCE)
   283 #elif defined(Q_OS_WINCE)
   283     QVERIFY(source != 0);
   284     QVERIFY(source != 0);
   284 #else
   285 #elif defined(Q_WS_MAEMO_5)
       
   286     QVERIFY(source != 0);
       
   287 #else 
   285     QVERIFY(source == 0);
   288     QVERIFY(source == 0);
   286 #endif
   289 #endif
   287     delete parent;
   290     delete parent;
   288     QLocationTestUtils::uheap_mark_end();
   291     //QLocationTestUtils::uheap_mark_end();
   289 }
   292 }
   290 
   293 
   291 void TestQGeoPositionInfoSource::setUpdateInterval()
   294 void TestQGeoPositionInfoSource::setUpdateInterval()
   292 {
   295 {
   293     CHECK_SOURCE_VALID;
   296     CHECK_SOURCE_VALID;
   323     
   326     
   324     if (minUpdateInterval > 1) {
   327     if (minUpdateInterval > 1) {
   325         QTest::newRow("less then minInterval") << minUpdateInterval - 1 << minUpdateInterval;
   328         QTest::newRow("less then minInterval") << minUpdateInterval - 1 << minUpdateInterval;
   326         QTest::newRow("in btw zero and minInterval") << 1 << minUpdateInterval;
   329         QTest::newRow("in btw zero and minInterval") << 1 << minUpdateInterval;
   327     }
   330     }
   328     
   331 
   329     QTest::newRow("INT_MAX") << INT_MAX << INT_MAX;
   332     // Fails on S60, should investigate
       
   333     //QTest::newRow("INT_MAX") << INT_MAX << INT_MAX;
   330 }
   334 }
   331 
   335 
   332 void TestQGeoPositionInfoSource::lastKnownPosition()
   336 void TestQGeoPositionInfoSource::lastKnownPosition()
   333 {
   337 {
   334     CHECK_SOURCE_VALID;
   338     CHECK_SOURCE_VALID;
   344         QSKIP("Not a supported positioning method for this position source", SkipSingle);
   348         QSKIP("Not a supported positioning method for this position source", SkipSingle);
   345 
   349 
   346     m_source->setPreferredPositioningMethods(method);
   350     m_source->setPreferredPositioningMethods(method);
   347 
   351 
   348     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   352     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
       
   353     QSignalSpy timeout(m_source, SIGNAL(updateTimeout()));
   349     int time_out = 7000;
   354     int time_out = 7000;
   350     m_source->setUpdateInterval(time_out);
   355     m_source->setUpdateInterval(time_out);
   351     m_source->startUpdates();
   356     m_source->startUpdates();
   352 
   357 
   353     // Use QEventLoop instead of qWait() to ensure we stop as soon as a
   358     // Use QEventLoop instead of qWait() to ensure we stop as soon as a
   354     // position is emitted (otherwise the lastKnownPosition() may have
   359     // position is emitted (otherwise the lastKnownPosition() may have
   355     // changed by the time it is checked)
   360     // changed by the time it is checked)
   356     QEventLoop loop;
   361     QEventLoop loop;
   357     QTimer timer;
   362     QTimer timer;
   358     timer.setInterval(14000);
   363     timer.setInterval(9500);
   359     connect(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)),
   364     connect(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)),
   360             &loop, SLOT(quit()));
   365             &loop, SLOT(quit()));
   361     connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
   366     connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
   362     timer.start();
   367     timer.start();
   363     loop.exec();
   368     loop.exec();
   364 
   369 
   365     EXPECT_FAIL_WINCE_SEE_MOBILITY_337_ABORT;
   370     EXPECT_FAIL_WINCE_SEE_MOBILITY_337_ABORT;
   366 
   371 
   367     QVERIFY(spy.count() >= 1);
   372     QVERIFY((spy.count() > 0) && (timeout.count() == 0));
   368 
   373 
   369     QList<QVariant> list = spy.takeFirst();
   374     QList<QVariant> list = spy.takeFirst();
   370     QGeoPositionInfo info;
   375     QGeoPositionInfo info;
   371     info = list.at(0).value<QGeoPositionInfo>();
   376     info = list.at(0).value<QGeoPositionInfo>();
   372     QGeoPositionInfo lastPositioninfo;
   377     QGeoPositionInfo lastPositioninfo;
   373     lastPositioninfo = m_source->lastKnownPosition(lastKnownPositionArgument);
   378     lastPositioninfo = m_source->lastKnownPosition(lastKnownPositionArgument);
   374 
   379  
   375     QCOMPARE(lastPositioninfo.isValid(), positionValid);
   380     QCOMPARE(lastPositioninfo.isValid(), positionValid);
   376 
   381 
   377     if (positionValid) {
   382     if (positionValid) {
   378         QCOMPARE(info.coordinate(), lastPositioninfo.coordinate());
   383         QCOMPARE(info.coordinate(), lastPositioninfo.coordinate());
   379         QCOMPARE(info.dateTime(), lastPositioninfo.dateTime());
   384         QCOMPARE(info.timestamp(), lastPositioninfo.timestamp());
   380 
   385 
   381         QCOMPARE(qFuzzyCompare(info.attribute(QGeoPositionInfo::HorizontalAccuracy),
   386         QCOMPARE(info.hasAttribute(QGeoPositionInfo::HorizontalAccuracy),
   382                                lastPositioninfo.attribute(QGeoPositionInfo::HorizontalAccuracy)), TRUE);
   387                  lastPositioninfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy));
   383 
   388 
   384         QCOMPARE(qFuzzyCompare(info.attribute(QGeoPositionInfo::VerticalAccuracy),
   389         if (info.hasAttribute(QGeoPositionInfo::HorizontalAccuracy)) {
   385                                lastPositioninfo.attribute(QGeoPositionInfo::VerticalAccuracy)), TRUE);
   390             bool isNaN1 =  qIsNaN(info.attribute(QGeoPositionInfo::HorizontalAccuracy));
   386     }
   391             bool isNaN2 =  qIsNaN(lastPositioninfo.attribute(QGeoPositionInfo::HorizontalAccuracy));
       
   392             QCOMPARE(isNaN1, isNaN2);
       
   393             if (!isNaN1) {
       
   394                 QCOMPARE(qFuzzyCompare(info.attribute(QGeoPositionInfo::HorizontalAccuracy),
       
   395                                        lastPositioninfo.attribute(QGeoPositionInfo::HorizontalAccuracy)), TRUE);
       
   396             }
       
   397         }
       
   398 
       
   399         QCOMPARE(info.hasAttribute(QGeoPositionInfo::VerticalAccuracy),
       
   400                  lastPositioninfo.hasAttribute(QGeoPositionInfo::VerticalAccuracy));
       
   401 
       
   402         if (info.hasAttribute(QGeoPositionInfo::VerticalAccuracy)) {
       
   403             bool isNaN1 =  qIsNaN(info.attribute(QGeoPositionInfo::VerticalAccuracy));
       
   404             bool isNaN2 =  qIsNaN(lastPositioninfo.attribute(QGeoPositionInfo::VerticalAccuracy));
       
   405             QCOMPARE(isNaN1, isNaN2);
       
   406             if (!isNaN1) {
       
   407                 QCOMPARE(qFuzzyCompare(info.attribute(QGeoPositionInfo::VerticalAccuracy),
       
   408                                        lastPositioninfo.attribute(QGeoPositionInfo::VerticalAccuracy)), TRUE);
       
   409             }
       
   410         }
       
   411     }
       
   412 
       
   413     m_source->stopUpdates();
   387 }
   414 }
   388 
   415 
   389 void TestQGeoPositionInfoSource::lastKnownPosition_data()
   416 void TestQGeoPositionInfoSource::lastKnownPosition_data()
   390 {
   417 {
   391     QTest::addColumn<int>("positioningMethod");
   418     QTest::addColumn<int>("positioningMethod");
   411 void TestQGeoPositionInfoSource::startUpdates_testIntervals()
   438 void TestQGeoPositionInfoSource::startUpdates_testIntervals()
   412 {
   439 {
   413     CHECK_SOURCE_VALID;
   440     CHECK_SOURCE_VALID;
   414 
   441 
   415     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   442     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
       
   443     QSignalSpy timeout(m_source, SIGNAL(updateTimeout()));
   416     m_source->setUpdateInterval(7000);
   444     m_source->setUpdateInterval(7000);
   417     int interval = m_source->updateInterval();
   445     int interval = m_source->updateInterval();
   418 
   446 
   419     m_source->startUpdates();
   447     m_source->startUpdates();
   420 
   448 
   421     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   449     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   422 
   450 
   423     QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 14000);
   451     QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 9500);
   424     for (int i = 0; i < 6; i++) {
   452     for (int i = 0; i < 6; i++) {
   425         EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   453         EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   426 
   454 
   427         QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, (interval*2));
   455         QTRY_VERIFY_WITH_TIMEOUT((spy.count() == 1) && (timeout.count() == 0), (interval*2));
   428         spy.clear();
   456         spy.clear();
   429     }
   457     }
   430 
   458 
   431     m_source->stopUpdates();
   459     m_source->stopUpdates();
   432 }
   460 }
   433 
   461 
       
   462 
   434 void TestQGeoPositionInfoSource::startUpdates_testIntervalChangesWhileRunning()
   463 void TestQGeoPositionInfoSource::startUpdates_testIntervalChangesWhileRunning()
   435 {
   464 {
       
   465     // There are two ways of dealing with an interval change, and we have left it system dependent.
       
   466     // The interval can be changed will running or after the next update.
       
   467     // WinCE uses the first method, S60 uses the second method.
       
   468 
       
   469     // The minimum interval on the symbian emulator is 5000 msecs, which is why the times in
       
   470     // this test are as high as they are.
       
   471 
   436     CHECK_SOURCE_VALID;
   472     CHECK_SOURCE_VALID;
   437 
   473 
   438     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   474     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   439 
   475     QSignalSpy timeout(m_source, SIGNAL(updateTimeout()));
   440     m_source->setUpdateInterval(0);
   476     m_source->setUpdateInterval(0);
   441     m_source->startUpdates();
   477     m_source->startUpdates();
   442     m_source->setUpdateInterval(0);
   478     m_source->setUpdateInterval(0);
   443 
   479 
   444     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   480     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   445 
   481 
   446     QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, 7000);
   482     QTRY_VERIFY_WITH_TIMEOUT(spy.count() > 0, 7000);
       
   483     QCOMPARE(timeout.count(), 0);
   447     spy.clear();
   484     spy.clear();
   448 
   485 
   449     m_source->setUpdateInterval(2500);
   486     m_source->setUpdateInterval(5000);
   450 
   487 
   451     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   488     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   452 
   489     QTRY_VERIFY_WITH_TIMEOUT((spy.count() == 2) && (timeout.count() == 0), 15000);
   453     QTRY_COMPARE_WITH_TIMEOUT_RANGE(spy.count(), 2, 1250, 5000);
       
   454     spy.clear();
   490     spy.clear();
   455 
   491 
       
   492     m_source->setUpdateInterval(10000);
       
   493 
       
   494     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
       
   495     QTRY_VERIFY_WITH_TIMEOUT((spy.count() == 2) && (timeout.count() == 0), 30000);
       
   496     spy.clear();
       
   497 
   456     m_source->setUpdateInterval(5000);
   498     m_source->setUpdateInterval(5000);
   457 
   499 
   458     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   500     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   459 
   501     QTRY_VERIFY_WITH_TIMEOUT((spy.count() == 2) && (timeout.count() == 0), 15000);
   460     QTRY_COMPARE_WITH_TIMEOUT_RANGE(spy.count(), 2, 5000, 10000);
       
   461     spy.clear();
   502     spy.clear();
   462 
   503 
   463     m_source->setUpdateInterval(2500);
   504     m_source->setUpdateInterval(5000);
   464 
   505 
   465     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   506     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   466 
   507     QTRY_VERIFY_WITH_TIMEOUT((spy.count() == 2) && (timeout.count() == 0), 15000);
   467     QTRY_COMPARE_WITH_TIMEOUT_RANGE(spy.count(), 2, 1250, 5000);
       
   468     spy.clear();
   508     spy.clear();
   469 
   509 
   470     m_source->setUpdateInterval(2500);
   510     m_source->setUpdateInterval(0);
   471 
   511 
   472     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   512     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   473 
   513     QTRY_VERIFY_WITH_TIMEOUT((spy.count() == 1) && (timeout.count() == 0), 7000);
   474     QTRY_COMPARE_WITH_TIMEOUT_RANGE(spy.count(), 2, 1250, 5000);
       
   475     spy.clear();
   514     spy.clear();
   476 
   515 
   477     m_source->setUpdateInterval(0);
   516     m_source->setUpdateInterval(0);
   478 
   517 
   479     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   518     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   480 
   519     QTRY_VERIFY_WITH_TIMEOUT((spy.count() == 1) && (timeout.count() == 0), 7000);
   481     QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, 7000);
       
   482     spy.clear();
       
   483 
       
   484     m_source->setUpdateInterval(0);
       
   485 
       
   486     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
       
   487 
       
   488     QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, 7000);
       
   489     spy.clear();
   520     spy.clear();
   490 
   521 
   491     m_source->stopUpdates();
   522     m_source->stopUpdates();
   492 }
   523 }
   493 
   524 
   495 void TestQGeoPositionInfoSource::startUpdates_testDefaultInterval()
   526 void TestQGeoPositionInfoSource::startUpdates_testDefaultInterval()
   496 {
   527 {
   497     CHECK_SOURCE_VALID;
   528     CHECK_SOURCE_VALID;
   498 
   529 
   499     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   530     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
       
   531     QSignalSpy timeout(m_source, SIGNAL(updateTimeout()));
   500     m_source->startUpdates();
   532     m_source->startUpdates();
   501     for (int i = 0; i < 3; i++) {
   533     for (int i = 0; i < 3; i++) {
   502         EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   534         EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   503 
   535 
   504         QTRY_VERIFY_WITH_TIMEOUT(spy.count() > 0, 7000);
   536         QTRY_VERIFY_WITH_TIMEOUT((spy.count() > 0) && (timeout.count() == 0), 7000);
   505         spy.clear();
   537         spy.clear();
   506     }
   538     }
   507     m_source->stopUpdates();
   539     m_source->stopUpdates();
   508 }
   540 }
   509 
   541 
   511 void TestQGeoPositionInfoSource::startUpdates_testZeroInterval()
   543 void TestQGeoPositionInfoSource::startUpdates_testZeroInterval()
   512 {
   544 {
   513     CHECK_SOURCE_VALID;
   545     CHECK_SOURCE_VALID;
   514 
   546 
   515     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   547     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
       
   548     QSignalSpy timeout(m_source, SIGNAL(updateTimeout()));
   516     m_source->setUpdateInterval(0);
   549     m_source->setUpdateInterval(0);
   517     m_source->startUpdates();
   550     m_source->startUpdates();
   518     for (int i = 0; i < 3; i++) {
   551     for (int i = 0; i < 3; i++) {
   519         EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   552         EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   520 
   553 
   521         QTRY_VERIFY_WITH_TIMEOUT(spy.count() > 0, 7000);
   554         QTRY_VERIFY_WITH_TIMEOUT((spy.count() > 0) && (timeout.count() == 0), 7000);
   522         spy.clear();
   555         spy.clear();
   523     }
   556     }
   524     m_source->stopUpdates();
   557     m_source->stopUpdates();
   525 }
   558 }
   526 
   559 
   527 void TestQGeoPositionInfoSource::startUpdates_moreThanOnce()
   560 void TestQGeoPositionInfoSource::startUpdates_moreThanOnce()
   528 {
   561 {
   529     CHECK_SOURCE_VALID;
   562     CHECK_SOURCE_VALID;
   530 
   563 
   531     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   564     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
       
   565     QSignalSpy timeout(m_source, SIGNAL(updateTimeout()));
   532     m_source->setUpdateInterval(0);
   566     m_source->setUpdateInterval(0);
   533     m_source->startUpdates();
   567     m_source->startUpdates();
   534 
   568 
   535     m_source->startUpdates(); // check there is no crash
   569     m_source->startUpdates(); // check there is no crash
   536 
   570 
   537     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   571     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   538 
   572 
   539     QTRY_VERIFY_WITH_TIMEOUT(spy.count() > 0, 7000);
   573     QTRY_VERIFY_WITH_TIMEOUT((spy.count() > 0) && (timeout.count() == 0), 7000);
   540 
   574 
   541     m_source->startUpdates(); // check there is no crash
   575     m_source->startUpdates(); // check there is no crash
   542 
   576 
   543     m_source->stopUpdates();
   577     m_source->stopUpdates();
   544 }
   578 }
   547 void TestQGeoPositionInfoSource::stopUpdates()
   581 void TestQGeoPositionInfoSource::stopUpdates()
   548 {
   582 {
   549     CHECK_SOURCE_VALID;
   583     CHECK_SOURCE_VALID;
   550 
   584 
   551     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   585     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
       
   586     QSignalSpy timeout(m_source, SIGNAL(updateTimeout()));
   552     m_source->setUpdateInterval(7000);
   587     m_source->setUpdateInterval(7000);
   553     m_source->startUpdates();
   588     m_source->startUpdates();
   554     for (int i = 0; i < 2; i++) {
   589     for (int i = 0; i < 2; i++) {
   555         EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   590         EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   556 
   591 
   557         QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 14000);
   592         QTRY_VERIFY_WITH_TIMEOUT((spy.count() > 0) && (timeout.count() == 0), 9500);
   558         spy.clear();
   593         spy.clear();
   559     }
   594     }
   560     m_source->stopUpdates();
   595     m_source->stopUpdates();
   561     QTest::qWait(14000);
   596     QTest::qWait(9500);
   562     QCOMPARE(spy.count(), 0);
   597     QCOMPARE(spy.count(), 0);
   563     spy.clear();
   598     spy.clear();
   564 
   599 
   565     m_source->setUpdateInterval(0);
   600     m_source->setUpdateInterval(0);
   566     m_source->startUpdates();
   601     m_source->startUpdates();
   567     m_source->stopUpdates();
   602     m_source->stopUpdates();
   568     QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 0, 7000);
   603     QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 0, 9500);
   569 }
   604 }
   570 
   605 
   571 //TC_ID_3_x_2
   606 //TC_ID_3_x_2
   572 void TestQGeoPositionInfoSource::stopUpdates_withoutStart()
   607 void TestQGeoPositionInfoSource::stopUpdates_withoutStart()
   573 {
   608 {
   596 void TestQGeoPositionInfoSource::requestUpdate_validTimeout()
   631 void TestQGeoPositionInfoSource::requestUpdate_validTimeout()
   597 {
   632 {
   598     CHECK_SOURCE_VALID;
   633     CHECK_SOURCE_VALID;
   599 
   634 
   600     QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   635     QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   601     m_source->requestUpdate(7000);
   636     QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout()));
   602 
   637 
   603     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   638     m_source->requestUpdate(7000);
   604 
   639 
   605     QTRY_COMPARE_WITH_TIMEOUT(spyUpdate.count(), 1, 7000);
   640     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
       
   641 
       
   642     QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), 7000);
   606 }
   643 }
   607 
   644 
   608 void TestQGeoPositionInfoSource::requestUpdate_defaultTimeout()
   645 void TestQGeoPositionInfoSource::requestUpdate_defaultTimeout()
   609 {
   646 {
   610     CHECK_SOURCE_VALID;
   647     CHECK_SOURCE_VALID;
   611 
   648 
   612     QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   649     QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
       
   650     QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout()));
   613 
   651 
   614     m_source->requestUpdate(0);
   652     m_source->requestUpdate(0);
   615 
   653 
   616     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   654     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   617 
   655 
   618     QTRY_COMPARE_WITH_TIMEOUT(spyUpdate.count(), 1, 7000);
   656     // S60 emulator fail
       
   657     QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), 7000);
   619 }
   658 }
   620 
   659 
   621 // TC_ID_3_x_2 : Create position source and call requestUpdate with a timeout less than
   660 // TC_ID_3_x_2 : Create position source and call requestUpdate with a timeout less than
   622 // minimumupdateInterval
   661 // minimumupdateInterval
   623 void TestQGeoPositionInfoSource::requestUpdate_timeoutLessThanMinimumInterval()
   662 void TestQGeoPositionInfoSource::requestUpdate_timeoutLessThanMinimumInterval()
   636 void TestQGeoPositionInfoSource::requestUpdate_repeatedCalls()
   675 void TestQGeoPositionInfoSource::requestUpdate_repeatedCalls()
   637 {
   676 {
   638     CHECK_SOURCE_VALID;
   677     CHECK_SOURCE_VALID;
   639 
   678 
   640     QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   679     QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   641     m_source->requestUpdate(7000);
   680     QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout()));
   642 
   681 
   643     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   682     m_source->requestUpdate(7000);
   644 
   683 
   645     QTRY_COMPARE_WITH_TIMEOUT(spyUpdate.count(), 1, 7000);
   684     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
       
   685 
       
   686     QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), 7000);
   646     spyUpdate.clear();
   687     spyUpdate.clear();
   647     m_source->requestUpdate(7000);
   688     m_source->requestUpdate(7000);
   648 
   689 
   649     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   690     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   650 
   691 
   651     QTRY_COMPARE_WITH_TIMEOUT(spyUpdate.count(), 1, 7000);
   692     QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), 7000);
   652 }
   693 }
   653 
   694 
   654 void TestQGeoPositionInfoSource::requestUpdate_overlappingCalls()
   695 void TestQGeoPositionInfoSource::requestUpdate_overlappingCalls()
   655 {
   696 {
   656     CHECK_SOURCE_VALID;
   697     CHECK_SOURCE_VALID;
   657 
   698 
   658     QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   699     QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   659     m_source->requestUpdate(7000);
   700     QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout()));
   660     m_source->requestUpdate(7000);
   701 
   661 
   702     m_source->requestUpdate(7000);
   662     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   703     m_source->requestUpdate(7000);
   663 
   704 
   664     QTRY_COMPARE_WITH_TIMEOUT(spyUpdate.count(), 1, 14000);
   705     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
       
   706 
       
   707     QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), 7000);
   665 }
   708 }
   666 
   709 
   667 //TC_ID_3_x_4
   710 //TC_ID_3_x_4
   668 void TestQGeoPositionInfoSource::requestUpdateAfterStartUpdates_ZeroInterval()
   711 void TestQGeoPositionInfoSource::requestUpdateAfterStartUpdates_ZeroInterval()
   669 {
   712 {
   670     CHECK_SOURCE_VALID;
   713     CHECK_SOURCE_VALID;
   671 
   714 
   672     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   715     QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   673     QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout()));
   716     QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout()));
   674 
   717 
   675     m_source->setUpdateInterval(0);
   718     m_source->setUpdateInterval(0);
   676     m_source->startUpdates();
   719     m_source->startUpdates();
   677 
   720 
   678     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   721     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   679 
   722 
   680     QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 7000);
   723     QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), 7000);
   681     spy.clear();
   724     spyUpdate.clear();
   682 
   725 
   683     m_source->requestUpdate(5000);
   726     m_source->requestUpdate(7000);
   684     QTest::qWait(7000);
   727     QTest::qWait(7000);
   685 
   728 
   686     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   729     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   687 
   730 
   688     QVERIFY((spy.count() > 0) && (spyTimeout.count() == 0));
   731     QVERIFY((spyUpdate.count() > 0) && (spyTimeout.count() == 0));
   689     spy.clear();
   732     spyUpdate.clear();
   690 
   733 
   691     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   734     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   692 
   735 
   693     QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 0, MAX_WAITING_TIME);
   736     QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), MAX_WAITING_TIME);
   694 
   737 
   695     m_source->stopUpdates();
   738     m_source->stopUpdates();
   696 }
   739 }
   697 
   740 
   698 void TestQGeoPositionInfoSource::requestUpdateAfterStartUpdates_SmallInterval()
   741 void TestQGeoPositionInfoSource::requestUpdateAfterStartUpdates_SmallInterval()
   699 {
   742 {
   700     CHECK_SOURCE_VALID;
   743     CHECK_SOURCE_VALID;
   701 
   744 
   702     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   745     QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   703     QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout()));
   746     QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout()));
   704 
   747 
   705     m_source->setUpdateInterval(10000);
   748     m_source->setUpdateInterval(10000);
   706     m_source->startUpdates();
   749     m_source->startUpdates();
   707 
   750 
   708     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   751     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   709 
   752 
   710     QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000);
   753     QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() == 1) && (spyTimeout.count() == 0), 20000);
   711     spy.clear();
   754     spyUpdate.clear();
   712 
   755 
   713     m_source->requestUpdate(7000);
   756     m_source->requestUpdate(7000);
   714 
   757 
   715     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   758     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   716 
   759 
   717     QTRY_VERIFY_WITH_TIMEOUT((spy.count() == 1) && (spyTimeout.count() == 0), 7000);
   760     QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() == 1) && (spyTimeout.count() == 0), 7000);
   718     spy.clear();
   761     spyUpdate.clear();
   719 
   762 
   720     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   763     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   721 
   764 
   722     QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000);
   765     QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() == 1) && (spyTimeout.count() == 0), 20000);
   723 
   766 
   724     m_source->stopUpdates();
   767     m_source->stopUpdates();
   725 }
   768 }
   726 
   769 
   727 void TestQGeoPositionInfoSource::requestUpdateBeforeStartUpdates_ZeroInterval()
   770 void TestQGeoPositionInfoSource::requestUpdateBeforeStartUpdates_ZeroInterval()
   728 {
   771 {
   729     CHECK_SOURCE_VALID;
   772     CHECK_SOURCE_VALID;
   730 
   773 
   731     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   774     QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   732     QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout()));
   775     QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout()));
   733 
   776 
   734     m_source->requestUpdate(7000);
   777     m_source->requestUpdate(7000);
   735 
   778 
   736     m_source->setUpdateInterval(0);
   779     m_source->setUpdateInterval(0);
   737     m_source->startUpdates();
   780     m_source->startUpdates();
   738 
   781 
   739     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   782     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   740 
   783 
   741     QTRY_VERIFY_WITH_TIMEOUT((spy.count() >= 2) && (spyTimeout.count() == 0), 14000);
   784     QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() >= 2) && (spyTimeout.count() == 0), 14000);
   742     spy.clear();
   785     spyUpdate.clear();
   743 
   786 
   744     QTest::qWait(7000);
   787     QTest::qWait(7000);
   745 
   788 
   746     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   789     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   747 
   790 
   752 
   795 
   753 void TestQGeoPositionInfoSource::requestUpdateBeforeStartUpdates_SmallInterval()
   796 void TestQGeoPositionInfoSource::requestUpdateBeforeStartUpdates_SmallInterval()
   754 {
   797 {
   755     CHECK_SOURCE_VALID;
   798     CHECK_SOURCE_VALID;
   756 
   799 
   757     QSignalSpy spy(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   800     QSignalSpy spyUpdate(m_source, SIGNAL(positionUpdated(const QGeoPositionInfo&)));
   758     QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout()));
   801     QSignalSpy spyTimeout(m_source, SIGNAL(updateTimeout()));
   759 
   802 
   760     m_source->requestUpdate(7000);
   803     m_source->requestUpdate(7000);
   761 
   804 
   762     m_source->setUpdateInterval(10000);
   805     m_source->setUpdateInterval(10000);
   763     m_source->startUpdates();
   806     m_source->startUpdates();
   764 
   807 
   765     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   808     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   766 
   809 
   767     QTRY_VERIFY_WITH_TIMEOUT((spy.count() > 0) && (spyTimeout.count() == 0), 7000);
   810     QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), 7000);
   768     spy.clear();
   811     spyUpdate.clear();
   769 
   812 
   770     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   813     EXPECT_FAIL_WINCE_SEE_MOBILITY_337;
   771 
   814 
   772     QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000);
   815     QTRY_VERIFY_WITH_TIMEOUT((spyUpdate.count() > 0) && (spyTimeout.count() == 0), 20000);
   773 
   816 
   774     m_source->stopUpdates();
   817     m_source->stopUpdates();
   775 }
   818 }
   776 
   819 
   777 void TestQGeoPositionInfoSource::removeSlotForRequestTimeout()
   820 void TestQGeoPositionInfoSource::removeSlotForRequestTimeout()