void PowerManagementTest::testIntervalRace() { UNBLANK_SCREEN; AccelerometerSensorChannelInterface* accOne = AccelerometerSensorChannelInterface::interface("accelerometersensor"); QVERIFY2(accOne != NULL && accOne->isValid(), accOne ? accOne->errorString().toLatin1() : "Null pointer"); AccelerometerSensorChannelInterface* accTwo = AccelerometerSensorChannelInterface::interface("accelerometersensor"); QVERIFY2(accTwo != NULL && accTwo->isValid(), accTwo ? accTwo->errorString().toLatin1() : "Null pointer"); // Screen orientation keeps acc open, the 'default' may change. // Thus dynamic values. unsigned int originalInterval = readPollInterval(accPollFile); qDebug() << "original interval:" << originalInterval; QVERIFY2((originalInterval == 0 || originalInterval > 3), "Can't run the test with current poll value."); unsigned int testIntervalOne = 100; // Faster than original unsigned int testIntervalTwo = 50; // Faster than previous unsigned int testIntervalThree = 200; // Slower than previous accOne->setInterval(testIntervalOne); accOne->start(); QVERIFY(readPollInterval(accPollFile) == testIntervalOne); accTwo->setInterval(testIntervalTwo); accTwo->start(); QVERIFY(readPollInterval(accPollFile) == testIntervalTwo); accTwo->stop(); QVERIFY(readPollInterval(accPollFile) == testIntervalOne); accTwo->setInterval(testIntervalThree); accTwo->start(); QVERIFY(readPollInterval(accPollFile) == testIntervalOne); accOne->stop(); QVERIFY(readPollInterval(accPollFile) == testIntervalThree); accTwo->stop(); QVERIFY(readPollInterval(accPollFile) == originalInterval); delete accOne; delete accTwo; }
void PowerManagementTest::testIntervalStartStop() { UNBLANK_SCREEN; AccelerometerSensorChannelInterface* accOne = AccelerometerSensorChannelInterface::interface("accelerometersensor"); QVERIFY2(accOne != NULL && accOne->isValid(), accOne ? accOne->errorString().toLatin1() : "Null pointer"); // Screen orientation keeps acc open, the 'default' may change. // Thus dynamic values. unsigned int originalInterval = readPollInterval(accPollFile); unsigned int testInterval = originalInterval > 1 ? originalInterval / 2 : 100; accOne->setInterval(testInterval); QVERIFY(readPollInterval(accPollFile) == originalInterval); accOne->start(); QVERIFY(readPollInterval(accPollFile) == testInterval); accOne->stop(); QVERIFY(readPollInterval(accPollFile) == originalInterval); delete accOne; }