summaryrefslogtreecommitdiffstats
path: root/tests/auto/qsystemdeviceinfo/tst_qsystemdeviceinfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qsystemdeviceinfo/tst_qsystemdeviceinfo.cpp')
-rw-r--r--tests/auto/qsystemdeviceinfo/tst_qsystemdeviceinfo.cpp520
1 files changed, 480 insertions, 40 deletions
diff --git a/tests/auto/qsystemdeviceinfo/tst_qsystemdeviceinfo.cpp b/tests/auto/qsystemdeviceinfo/tst_qsystemdeviceinfo.cpp
index b3947ffcc7..201d3de119 100644
--- a/tests/auto/qsystemdeviceinfo/tst_qsystemdeviceinfo.cpp
+++ b/tests/auto/qsystemdeviceinfo/tst_qsystemdeviceinfo.cpp
@@ -45,6 +45,10 @@
#include "qsysteminfo.h"
#include "../qsysteminfotestcommon.h"
+#ifdef TESTR
+#include "qsysteminfo_simulator_p.h"
+#endif
+
QTM_USE_NAMESPACE
Q_DECLARE_METATYPE(QSystemDeviceInfo::BatteryStatus);
Q_DECLARE_METATYPE(QSystemDeviceInfo::PowerState);
@@ -53,6 +57,71 @@ Q_DECLARE_METATYPE(QSystemDeviceInfo::Profile);
Q_DECLARE_METATYPE(QSystemDeviceInfo::SimStatus);
Q_DECLARE_METATYPE(QSystemDeviceInfo::KeyboardTypeFlags);
+Q_DECLARE_METATYPE(QSystemDeviceInfo::LockTypeFlags);
+
+/**
+ * Starts an event loop that runs until the given signal is received.
+ * Optionally the event loop can return earlier on a timeout.
+ *
+ * \return \p true if the requested signal was received
+ * \p false on timeout
+ */
+
+#ifdef TESTR
+
+static bool waitForSignal(QObject *obj, const char *signal, int timeout = 0)
+{
+ QEventLoop loop;
+ QObject::connect(obj, signal, &loop, SLOT(quit()));
+ QTimer timer;
+ QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
+ if (timeout > 0) {
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.setSingleShot(true);
+ timer.start(timeout);
+ }
+ loop.exec();
+ return timeoutSpy.isEmpty();
+}
+
+class ChangeDeviceThread : public QThread
+{
+public:
+ void run()
+ {
+ QMutexLocker locker(&mutex);
+ SystemInfoConnection si;
+ QSystemDeviceInfoPrivate *d = si.deviceInfoPrivate();
+ d->setBatteryLevel(batteryLevel);
+ d->setCurrentPowerState(powerState);
+ d->setCurrentProfile(profile);
+ d->setBluetoothPower(btPower);
+ d->setWirelessKeyboardConnected(keyboardConnected);
+ d->setKeyboardFlippedOpen(flip);
+ d->setDeviceLocked(locked);
+ d->setTypeOfLock(lockType);
+
+ d->setMessageRingtoneVolume(messageRingtoneVolume);
+ d->setVoiceRingtoneVolume(voiceRingtoneVolume);
+ d->setVibrationActive(vibrationActive);
+
+ this->exit();
+ }
+
+ QMutex mutex;
+ QSystemDeviceInfo::PowerState powerState;
+ QSystemDeviceInfo::Profile profile;
+ int batteryLevel;
+ bool btPower;
+ bool keyboardConnected;
+ bool flip;
+ bool locked;
+ QSystemDeviceInfo::LockTypeFlags lockType;
+ int messageRingtoneVolume;
+ int voiceRingtoneVolume;
+ int vibrationActive;
+};
+#endif
class tst_QSystemDeviceInfo : public QObject
{
@@ -86,20 +155,62 @@ private slots:
void tst_keyboardType();
void tst_isWirelessKeyboardConnected();
- void tst_isKeyboardFlipOpen();
+ void tst_isKeyboardFlippedOpen();
void tst_keypadLightOn();
- void tst_uniqueID();
+ void tst_uniqueDeviceID();
void tst_lockStatus();
void tst_activeProfileDetails();
+
+#ifdef TESTR
+ void tst_batteryLevelChanged_data();
+ void tst_batteryLevelChanged();
+
+ void tst_batteryStatusChanged_data();
+ void tst_batteryStatusChanged();
+
+ void tst_powerStateChanged_data();
+ void tst_powerStateChanged();
+
+ void tst_currentProfileChanged_data();
+ void tst_currentProfileChanged();
+
+ void tst_bluetoothStateChanged();
+
+ void tst_wirelessKeyboardConnected();
+ void tst_keyboardFlipped();
+ void tst_deviceLocked();
+
+ void tst_lockTypeChanged_data();
+ void tst_lockTypeChanged();
+
+
+ void batteryLevelChanged(int level);
+ void batteryStatusChanged(QSystemDeviceInfo::BatteryStatus batteryStatus);
+ void powerStateChanged(QSystemDeviceInfo::PowerState powerState);
+ void currentProfileChanged(QSystemDeviceInfo::Profile currentProfile);
+ void bluetoothStateChanged(bool on);
+
+ void wirelessKeyboardConnected(bool connected);
+ void keyboardFlipped(bool open);
+ void deviceLocked(bool isLocked);
+ void lockStatusChanged(QSystemDeviceInfo::LockTypeFlags);
+#endif
+
+private:
+
+#ifdef TESTR
+ int curBatLevel;
+ QSystemDeviceInfo::PowerState curPowerState;
+ QSystemDeviceInfo::Profile curProfile;
+ bool btpower;
+ bool keyboardConnect;
+ bool keyFLip;
+ bool deviceLock;
+ QSystemDeviceInfo::LockTypeFlags lockType;
+ bool lockTypeOn;
+#endif
};
-/*
-signal todo:
-// void profileChanged(QSystemDeviceInfo::Profile);
- void batteryLevelChanged(QSystemDeviceInfo::BatteryLevel);
- void batteryLevelCritical(qint32);
- void powerStateChanged(QSystemDeviceInfo::PowerState);
- */
void tst_QSystemDeviceInfo::initTestCase()
{
@@ -128,7 +239,9 @@ void tst_QSystemDeviceInfo::tst_imei()
QSystemDeviceInfo di;
QString imeiStr =di.imei();
QVERIFY(!imeiStr.isEmpty() || imeiStr.isEmpty());
-
+#ifdef TESTR
+ QVERIFY(imeiStr == "12-345678-901234-5");
+#endif
}
void tst_QSystemDeviceInfo::tst_imsi()
@@ -137,6 +250,9 @@ void tst_QSystemDeviceInfo::tst_imsi()
QString imsiStr = di.imsi();
QVERIFY(!imsiStr.isEmpty() || imsiStr.isEmpty());
+#ifdef TESTR
+ QVERIFY(imsiStr == "12345679012345");
+#endif
}
void tst_QSystemDeviceInfo::tst_manufacturer()
@@ -145,6 +261,9 @@ void tst_QSystemDeviceInfo::tst_manufacturer()
QString manu = di.manufacturer();
QVERIFY(!manu.isEmpty() || manu.isEmpty());
+#ifdef TESTR
+ QVERIFY(manu == "simulator manufacturer");
+#endif
}
void tst_QSystemDeviceInfo::tst_model()
@@ -153,6 +272,9 @@ void tst_QSystemDeviceInfo::tst_model()
QString model = di.model();
QVERIFY(!model.isEmpty() || model.isEmpty());
+#ifdef TESTR
+ QVERIFY(model == "simulator model");
+#endif
}
void tst_QSystemDeviceInfo::tst_productName()
@@ -161,20 +283,18 @@ void tst_QSystemDeviceInfo::tst_productName()
QString product = di.productName();
QVERIFY(!product.isEmpty() | product.isEmpty());
+#ifdef TESTR
+ QVERIFY(product == "simulator product name");
+#endif
}
void tst_QSystemDeviceInfo::tst_batteryLevel()
{
QSystemDeviceInfo di;
QVERIFY(di.batteryLevel() > -1);
-
-// until we simulate this, or wait the signalspy to olong, this will always fail
-// if(di.currentPowerState() == QSystemDeviceInfo::WallPowerChargingBattery) {
-// QSignalSpy batSpy(&di, SIGNAL(batteryLevelChanged(int)));
-// QVERIFY(!batSpy.isEmpty());
-// int level = batSpy.first().at(0).toInt();
-// QVERIFY( level > -1 || level < 101);
-// }
+#ifdef TESTR
+ QVERIFY(di.batteryLevel() == 84);
+#endif
}
void tst_QSystemDeviceInfo::tst_batteryStatus()
@@ -190,18 +310,6 @@ void tst_QSystemDeviceInfo::tst_batteryStatus()
} else if(level > 40) {
QVERIFY(di.batteryStatus() == QSystemDeviceInfo::BatteryNormal);
}
-
- // until we simulate this, or wait the signalspy to olong, this will always fail
-// if(di.currentPowerState() == QSystemDeviceInfo::WallPowerChargingBattery) {
-// QSignalSpy batSpy(&di, SIGNAL(batteryStatusChanged(QSystemDeviceInfo::BatteryStatus)));
-// QVERIFY(!batSpy.isEmpty());
-// QSystemDeviceInfo::BatteryStatus status = qvariant_cast<QSystemDeviceInfo::BatteryStatus>(batSpy.first().at(0));
-// QVERIFY( status == QSystemDeviceInfo::NoBatteryLevel
-// || status == QSystemDeviceInfo::BatteryCritical
-// || status == QSystemDeviceInfo::BatteryVeryLow
-// || status == QSystemDeviceInfo::BatteryLow
-// || status == QSystemDeviceInfo::BatteryNormal);
-// }
}
void tst_QSystemDeviceInfo::tst_currentProfile()
@@ -216,6 +324,9 @@ void tst_QSystemDeviceInfo::tst_currentProfile()
|| profile == QSystemDeviceInfo::OfflineProfile
|| profile == QSystemDeviceInfo::PowersaveProfile
|| profile == QSystemDeviceInfo::CustomProfile);
+#ifdef TESTR
+ QVERIFY(di.currentProfile() == QSystemDeviceInfo::NormalProfile);
+#endif
}
void tst_QSystemDeviceInfo::tst_simStatus()
@@ -223,7 +334,9 @@ void tst_QSystemDeviceInfo::tst_simStatus()
QSystemDeviceInfo di;
bool simStat = di.simStatus();
QVERIFY(simStat == true || simStat == false);
-
+#ifdef TESTR
+ QVERIFY(di.simStatus() == QSystemDeviceInfo::SimNotAvailable);
+#endif
}
void tst_QSystemDeviceInfo::tst_isDeviceLocked()
@@ -231,6 +344,9 @@ void tst_QSystemDeviceInfo::tst_isDeviceLocked()
QSystemDeviceInfo di;
bool devLock = di.isDeviceLocked();
QVERIFY(devLock == true || devLock == false);
+#ifdef TESTR
+ QVERIFY(!di.isDeviceLocked());
+#endif
}
void tst_QSystemDeviceInfo::tst_currentPowerState()
@@ -241,6 +357,9 @@ void tst_QSystemDeviceInfo::tst_currentPowerState()
|| state == QSystemDeviceInfo::BatteryPower
|| state == QSystemDeviceInfo::WallPower
|| state == QSystemDeviceInfo::WallPowerChargingBattery);
+#ifdef TESTR
+ QVERIFY(di.currentPowerState() == QSystemDeviceInfo::WallPower);
+#endif
}
void tst_QSystemDeviceInfo::tst_currentThermalState()
@@ -257,15 +376,18 @@ void tst_QSystemDeviceInfo::tst_currentThermalState()
void tst_QSystemDeviceInfo::tst_currentBluetoothPowerState()
{
QSystemDeviceInfo di;
- bool state = di.currentPowerState();
+ bool state = di.currentBluetoothPowerState();
QVERIFY(state || !state);
+#ifdef TESTR
+ QVERIFY(!di.currentBluetoothPowerState());
+#endif
}
void tst_QSystemDeviceInfo::tst_keyboardType()
{
QSystemDeviceInfo di;
- QSystemDeviceInfo::KeyboardTypeFlags flags = di.keyboardTypes();
+ QSystemDeviceInfo::KeyboardTypeFlags flags = di.keyboardTypes();
QVERIFY( (flags && QSystemDeviceInfo::UnknownKeyboard == QSystemDeviceInfo::UnknownKeyboard)
|| (flags && QSystemDeviceInfo::SoftwareKeyboard == QSystemDeviceInfo::SoftwareKeyboard)
@@ -283,11 +405,11 @@ void tst_QSystemDeviceInfo::tst_keyboardType()
void tst_QSystemDeviceInfo::tst_isWirelessKeyboardConnected()
{
QSystemDeviceInfo di;
- bool on = di.isWirelessKeyboardConnected();
- QVERIFY(on || !on);
+ bool on = di.isWirelessKeyboardConnected();
+ QVERIFY(on || !on);
}
-void tst_QSystemDeviceInfo::tst_isKeyboardFlipOpen()
+void tst_QSystemDeviceInfo::tst_isKeyboardFlippedOpen()
{
QSystemDeviceInfo di;
bool on = di.isKeyboardFlippedOpen();
@@ -305,7 +427,7 @@ void tst_QSystemDeviceInfo::tst_keypadLightOn()
}
-void tst_QSystemDeviceInfo::tst_uniqueID()
+void tst_QSystemDeviceInfo::tst_uniqueDeviceID()
{
QSystemDeviceInfo di;
QByteArray id = di.uniqueDeviceID();
@@ -317,12 +439,330 @@ void tst_QSystemDeviceInfo::tst_lockStatus()
QSystemDeviceInfo di;
QSystemDeviceInfo::LockTypeFlags lock = di.lockStatus();
if (di.isDeviceLocked()) {
- QVERIFY((lock & QSystemDeviceInfo::PinLocked)
- || (lock & QSystemDeviceInfo::TouchAndKeyboardLocked)
- || (lock & QSystemDeviceInfo::UnknownLock));
+ QVERIFY((lock == QSystemDeviceInfo::PinLocked)
+ || (lock == QSystemDeviceInfo::TouchAndKeyboardLocked));
+ } else {
+ QVERIFY(lock == QSystemDeviceInfo::UnknownLock);
+ }
+}
+
+#ifdef TESTR
+void tst_QSystemDeviceInfo::tst_batteryLevelChanged_data()
+{
+ QTest::addColumn<int>("batLevel");
+
+ QTest::newRow("1c") << 1;//critical
+ QTest::newRow("4c") << 4;//very low
+ QTest::newRow("11c") << 11;//low
+ QTest::newRow("41c") << 41;//normal
+ QTest::newRow("40d") << 40;//low
+ QTest::newRow("10d") << 10;//very low
+ QTest::newRow("3d") << 3;//critical
+}
+
+void tst_QSystemDeviceInfo::tst_batteryLevelChanged()
+{
+ QSystemDeviceInfo di;
+ QFETCH(int, batLevel);
+
+ connect(&di,SIGNAL(batteryLevelChanged(int)),
+ this,SLOT(batteryLevelChanged(int)));
+
+ ChangeDeviceThread *changeDevThread = new ChangeDeviceThread();
+ changeDevThread->batteryLevel = batLevel;
+ changeDevThread->start();
+
+ QSignalSpy errorSpy(&di, SIGNAL(batteryLevelChanged(int)));
+ QVERIFY(::waitForSignal(&di, SIGNAL(batteryLevelChanged(int)), 10 * 1000));
+
+ QVERIFY(errorSpy.count() == 1);
+
+ curBatLevel = batLevel;
+}
+
+void tst_QSystemDeviceInfo::tst_batteryStatusChanged_data()
+{
+ SystemInfoConnection si;
+ QSystemDeviceInfoPrivate *d = si.deviceInfoPrivate();
+ d->setInitialData();
+ tst_batteryLevelChanged_data();
+}
+
+void tst_QSystemDeviceInfo::tst_batteryStatusChanged()
+{
+ QSystemDeviceInfo di;
+
+ SystemInfoConnection si;
+
+ QFETCH(int, batLevel);
+
+ connect(&di,SIGNAL(batteryStatusChanged(QSystemDeviceInfo::BatteryStatus)),
+ this,SLOT(batteryStatusChanged(QSystemDeviceInfo::BatteryStatus)));
+
+ ChangeDeviceThread *changeDevThread = new ChangeDeviceThread();
+ changeDevThread->batteryLevel = batLevel;
+ changeDevThread->start();
+
+ QSignalSpy errorSpy(&di, SIGNAL(batteryStatusChanged(QSystemDeviceInfo::BatteryStatus)));
+ QVERIFY(::waitForSignal(&di, SIGNAL(batteryStatusChanged(QSystemDeviceInfo::BatteryStatus)), 10 * 1000));
+
+ QVERIFY(errorSpy.count() == 1);
+
+ curBatLevel = batLevel;
+}
+
+void tst_QSystemDeviceInfo::tst_powerStateChanged_data()
+{
+ QTest::addColumn<QSystemDeviceInfo::PowerState>("powerstate");
+
+ QTest::newRow("BatteryPower") << QSystemDeviceInfo::BatteryPower;
+ QTest::newRow("WallPower") << QSystemDeviceInfo::WallPower;
+ QTest::newRow("WallPowerChargingBattery") << QSystemDeviceInfo::WallPowerChargingBattery;
+ QTest::newRow("UnknownPower") << QSystemDeviceInfo::UnknownPower;
+}
+
+void tst_QSystemDeviceInfo::tst_powerStateChanged()
+{
+ QSystemDeviceInfo di;
+
+ SystemInfoConnection si;
+
+ QFETCH(QSystemDeviceInfo::PowerState, powerstate);
+
+ connect(&di,SIGNAL(powerStateChanged(QSystemDeviceInfo::PowerState)),
+ this,SLOT(powerStateChanged(QSystemDeviceInfo::PowerState)));
+
+ ChangeDeviceThread *changeDevThread = new ChangeDeviceThread();
+ changeDevThread->powerState = curPowerState = powerstate;
+ changeDevThread->start();
+
+ QSignalSpy errorSpy(&di, SIGNAL(powerStateChanged(QSystemDeviceInfo::PowerState)));
+ QVERIFY(::waitForSignal(&di, SIGNAL(powerStateChanged(QSystemDeviceInfo::PowerState)), 10 * 1000));
+
+ QVERIFY(errorSpy.count() == 1);
+
+}
+
+void tst_QSystemDeviceInfo::tst_currentProfileChanged_data()
+{
+ QTest::addColumn<QSystemDeviceInfo::Profile>("profile");
+
+ QTest::newRow("SilentProfile") << QSystemDeviceInfo::SilentProfile;
+ QTest::newRow("NormalProfile") << QSystemDeviceInfo::NormalProfile;
+ QTest::newRow("LoudProfile") << QSystemDeviceInfo::LoudProfile;
+ QTest::newRow("VibProfile") << QSystemDeviceInfo::VibProfile;
+ QTest::newRow("OfflineProfile") << QSystemDeviceInfo::OfflineProfile;
+ QTest::newRow("PowersaveProfile") << QSystemDeviceInfo::PowersaveProfile;
+ QTest::newRow("CustomProfile") << QSystemDeviceInfo::CustomProfile;
+ QTest::newRow("UnknownProfile") << QSystemDeviceInfo::UnknownProfile;
+
+}
+
+void tst_QSystemDeviceInfo::tst_currentProfileChanged()
+{
+ QSystemDeviceInfo di;
+
+ SystemInfoConnection si;
+ QFETCH(QSystemDeviceInfo::Profile, profile);
+
+ connect(&di,SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)),
+ this,SLOT(currentProfileChanged(QSystemDeviceInfo::Profile)));
+
+ ChangeDeviceThread *changeDevThread = new ChangeDeviceThread();
+ changeDevThread->profile = curProfile = profile;
+ changeDevThread->start();
+
+ QSignalSpy errorSpy(&di, SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)));
+ QVERIFY(::waitForSignal(&di, SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)), 10 * 1000));
+
+ QVERIFY(errorSpy.count() == 1);
+}
+
+void tst_QSystemDeviceInfo::tst_bluetoothStateChanged()
+{
+ QSystemDeviceInfo di;
+
+ SystemInfoConnection si;
+ ChangeDeviceThread *changeDevThread = new ChangeDeviceThread();
+
+ connect(&di,SIGNAL(bluetoothStateChanged(bool)),
+ this,SLOT(bluetoothStateChanged(bool)));
+
+ changeDevThread->btPower = btpower = true;
+ changeDevThread->start();
+
+ QSignalSpy errorSpy(&di, SIGNAL(bluetoothStateChanged(bool)));
+ QVERIFY(::waitForSignal(&di, SIGNAL(bluetoothStateChanged(bool)), 10 * 1000));
+
+ QVERIFY(errorSpy.count() == 1);
+
+ changeDevThread->btPower = btpower = false;
+ changeDevThread->start();
+
+}
+
+
+void tst_QSystemDeviceInfo::tst_wirelessKeyboardConnected()
+{
+ QSystemDeviceInfo di;
+
+ SystemInfoConnection si;
+ ChangeDeviceThread *changeDevThread = new ChangeDeviceThread();
+
+ connect(&di,SIGNAL(wirelessKeyboardConnected(bool)),
+ this,SLOT(wirelessKeyboardConnected(bool)));
+
+ changeDevThread->keyboardConnected = keyboardConnect = true;
+ changeDevThread->start();
+
+ QSignalSpy errorSpy(&di, SIGNAL(wirelessKeyboardConnected(bool)));
+ QVERIFY(::waitForSignal(&di, SIGNAL(wirelessKeyboardConnected(bool)), 10 * 1000));
+
+ QVERIFY(errorSpy.count() == 1);
+
+ changeDevThread->keyboardConnected = keyboardConnect = false;
+ changeDevThread->start();
+
+}
+
+void tst_QSystemDeviceInfo::tst_keyboardFlipped()
+{
+ QSystemDeviceInfo di;
+
+ SystemInfoConnection si;
+ ChangeDeviceThread *changeDevThread = new ChangeDeviceThread();
+
+ connect(&di,SIGNAL(keyboardFlipped(bool)),
+ this,SLOT(keyboardFlipped(bool)));
+
+ changeDevThread->flip = keyFLip = true;
+ changeDevThread->start();
+
+ QSignalSpy errorSpy(&di, SIGNAL(keyboardFlipped(bool)));
+ QVERIFY(::waitForSignal(&di, SIGNAL(keyboardFlipped(bool)), 10 * 1000));
+
+ QVERIFY(errorSpy.count() == 1);
+
+ changeDevThread->flip = keyFLip = false;
+ changeDevThread->start();
+
+
+}
+
+void tst_QSystemDeviceInfo::tst_deviceLocked()
+{
+ QSystemDeviceInfo di;
+
+ SystemInfoConnection si;
+ ChangeDeviceThread *changeDevThread = new ChangeDeviceThread();
+
+ connect(&di,SIGNAL(deviceLocked(bool)),
+ this,SLOT(deviceLocked(bool)));
+
+ changeDevThread->locked = deviceLock = true;
+ changeDevThread->start();
+
+ QSignalSpy errorSpy(&di, SIGNAL(deviceLocked(bool)));
+ QVERIFY(::waitForSignal(&di, SIGNAL(deviceLocked(bool)), 10 * 1000));
+
+ QVERIFY(errorSpy.count() == 1);
+
+ changeDevThread->locked = deviceLock = false;
+ changeDevThread->start();
+
+
+}
+
+void tst_QSystemDeviceInfo::tst_lockTypeChanged_data()
+{
+// QTest::addColumn<QSystemDeviceInfo::LockTypeFlags>("locktype");
+
+// QTest::newRow("PinLocked") << QSystemDeviceInfo::PinLocked;
+// QTest::newRow("TouchAndKeyboardLocked") << QSystemDeviceInfo::TouchAndKeyboardLocked;
+// QTest::newRow("UnknownLock") << QSystemDeviceInfo::UnknownLock;
+}
+
+void tst_QSystemDeviceInfo::tst_lockTypeChanged()
+{
+// QSystemDeviceInfo di;
+
+// SystemInfoConnection si;
+// QFETCH(QSystemDeviceInfo::LockTypeFlags, locktype);
+
+// connect(&di,SIGNAL(lockStatusChanged(QSystemDeviceInfo::LockTypeFlags)),
+// this,SLOT(lockStatusChanged(QSystemDeviceInfo::LockTypeFlags)));
+
+// ChangeDeviceThread *changeDevThread = new ChangeDeviceThread();
+// changeDevThread->lockType = lockType = locktype;
+// changeDevThread->start();
+
+// QSignalSpy errorSpy(&di, SIGNAL(lockStatusChanged(QSystemDeviceInfo::LockTypeFlags)));
+// QVERIFY(::waitForSignal(&di, SIGNAL(lockStatusChanged(QSystemDeviceInfo::LockTypeFlags)), 10 * 1000));
+
+// QVERIFY(errorSpy.count() == 1);
+
+// changeDevThread->start();
+}
+
+void tst_QSystemDeviceInfo::batteryLevelChanged(int level)
+{
+ QVERIFY(level != curBatLevel);
+}
+
+void tst_QSystemDeviceInfo::batteryStatusChanged(QSystemDeviceInfo::BatteryStatus batteryStatus)
+{
+ QSystemDeviceInfo di;
+ int level = di.batteryLevel();
+ if (level == -1)
+ QVERIFY(batteryStatus ==QSystemDeviceInfo::NoBatteryLevel);
+ if (level < 4) {
+ QVERIFY(batteryStatus == QSystemDeviceInfo::BatteryCritical);
+ } else if (level < 11) {
+ QVERIFY(batteryStatus == QSystemDeviceInfo::BatteryVeryLow);
+ } else if (level < 41) {
+ QVERIFY(batteryStatus == QSystemDeviceInfo::BatteryLow);
+ } else if (level > 40) {
+ QVERIFY(batteryStatus == QSystemDeviceInfo::BatteryNormal);
}
}
+void tst_QSystemDeviceInfo::powerStateChanged(QSystemDeviceInfo::PowerState powerState)
+{
+ QVERIFY(powerState == curPowerState);
+}
+
+void tst_QSystemDeviceInfo::currentProfileChanged(QSystemDeviceInfo::Profile currentProfile)
+{
+ QVERIFY(currentProfile == curProfile);
+}
+
+void tst_QSystemDeviceInfo::bluetoothStateChanged(bool on)
+{
+ QVERIFY(on == btpower);
+}
+
+void tst_QSystemDeviceInfo::wirelessKeyboardConnected(bool connected)
+{
+ QVERIFY(connected == keyboardConnect);
+}
+
+void tst_QSystemDeviceInfo::keyboardFlipped(bool open)
+{
+ QVERIFY(open == keyFLip);
+}
+
+void tst_QSystemDeviceInfo::deviceLocked(bool isLocked)
+{
+ QVERIFY(isLocked == deviceLock);
+}
+
+void tst_QSystemDeviceInfo::lockStatusChanged(QSystemDeviceInfo::LockTypeFlags type)
+{
+ QVERIFY(type == lockType);
+}
+
+#endif
+
void tst_QSystemDeviceInfo::tst_activeProfileDetails()
{
QSystemDeviceInfo di;