void Doctor::attendPatient() { // if (travellingToResident) { //This is here so that it will compile. Get rid of when uncommenting goToNode() if (goToNode("Resident0")) { travellingToResident = false; treating = true; first = true; } return; } else if (treating) { //Send message to patient to rise health stats if (first) { requestLock("Doctor"); first = false; } if (haveLock) { //Treat resident if (!(healthLevel >= 99)) { doResponse("health"); counterHealthTimes++; if (counterHealthTimes > 35){ goHome = true; treating = false; homeVisit = false; } } else { goHome = true; treating = false; homeVisit = false; } } else if (deniedLock) { if (otherUnlocked) { requestLock("Doctor"); deniedLock = false; otherUnlocked = false; } } } }
void LogindTest::testLogindPresent() { QTest::qWait(100); FakeLogind fakeLogind; QScopedPointer<LogindIntegration> logindIntegration(new LogindIntegration(QDBusConnection::sessionBus(), this)); QSignalSpy connectedSpy(logindIntegration.data(), SIGNAL(connectedChanged())); QVERIFY(connectedSpy.wait()); QVERIFY(logindIntegration->isConnected()); QSignalSpy lockSpy(logindIntegration.data(), SIGNAL(requestLock())); fakeLogind.lock(); QVERIFY(lockSpy.wait()); QCOMPARE(lockSpy.count(), 1); }
void LogindTest::testLockUnlock() { QScopedPointer<LogindIntegration> logindIntegration(new LogindIntegration(QDBusConnection::sessionBus(), this)); QSignalSpy lockSpy(logindIntegration.data(), SIGNAL(requestLock())); QSignalSpy unlockSpy(logindIntegration.data(), SIGNAL(requestUnlock())); QSignalSpy connectedSpy(logindIntegration.data(), SIGNAL(connectedChanged())); FakeLogind fakeLogind; // need to wait till we got the pending reply QVERIFY(connectedSpy.wait()); QVERIFY(logindIntegration->isConnected()); fakeLogind.lock(); QVERIFY(lockSpy.wait()); fakeLogind.lock(); QVERIFY(lockSpy.wait()); QCOMPARE(lockSpy.count(), 2); fakeLogind.unlock(); QVERIFY(unlockSpy.wait()); QCOMPARE(unlockSpy.count(), 1); }