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); }
void Ut_LockScreenWithPadlockView::testDraggableIconMovement() { QFETCH(int, layoutDirection); QSKIP("This test method currently fails", SkipSingle); QSignalSpy unlockSpy(m_subject, SIGNAL(unlocked())); m_subject->lockScreenHeader->setLayoutDirection((Qt::LayoutDirection)layoutDirection); m_subject->lockScreenHeader->setPreferredSize(100, 10); // send three mouse events that ultimately will send the unlocked signal from the window. QGraphicsSceneMouseEvent *pressEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMousePress); pressEvent->setPos(QPointF(layoutDirection == Qt::LeftToRight ? m_subject->lockScreenHeader->preferredWidth() : 0, m_subject->lockScreenHeader->pos().y())); QGraphicsSceneMouseEvent *moveEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseMove); moveEvent->setPos(QPointF(400, 240)); QGraphicsSceneMouseEvent *moveEventNotActive = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseMove); moveEventNotActive->setPos(QPointF(400, 0)); QGraphicsSceneMouseEvent *releaseEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseRelease); // sending a press event the place where it should activate the draggable icon. m_subject->mousePressEvent(pressEvent); QTest::qWait(50); QCoreApplication::processEvents(); QCOMPARE(m_subject->dragAndDropState, (int)LockScreenWithPadlockView::STATE_MOVING); QVERIFY(nameOfLastFeedback == "start-dragndrop"); checkOverlayPos(pressEvent->pos()); QVERIFY(m_subject->dragAndDropIcon != 0); QCOMPARE(m_subject->dragAndDropOverlay.widget(), static_cast<MWidget*>(m_subject->dragAndDropIcon)); QCOMPARE(gAppearSceneWindowList.count(), 1); QCOMPARE(gAppearSceneWindowList.at(0), &m_subject->dragAndDropOverlay); QCOMPARE(m_subject->dragAndDropIcon->objectName(), QString("LockScreenDnDIcon")); QVERIFY(m_subject->dragAndDropOverlay.isVisible()); QCOMPARE(m_subject->lockScreenHeader->objectName(), QString("LockLiftArea")); QVERIFY(gUnlockAreaStub->stubLastCallTo("setEnabled").parameter<bool>(0)); // move the mouse right into the middle of the screen m_subject->mouseMoveEvent(moveEvent); QCOMPARE(m_subject->dragAndDropState, (int)LockScreenWithPadlockView::STATE_MOVING_ACTIVE); QVERIFY(nameOfLastFeedback == "enter-dragndrop-dropzone"); checkOverlayPos(moveEvent->pos()); QCOMPARE(m_subject->dragAndDropIcon->objectName(), QString("LockScreenDnDIconActive")); QVERIFY(gUnlockAreaStub->stubLastCallTo("setActive").parameter<bool>(0)); // move back to some non-active place m_subject->mouseMoveEvent(moveEventNotActive); QCOMPARE(m_subject->dragAndDropState, (int)LockScreenWithPadlockView::STATE_MOVING); QVERIFY(nameOfLastFeedback == "exit-dragndrop-dropzone"); QCOMPARE(m_subject->dragAndDropIcon->objectName(), QString("LockScreenDnDIcon")); QVERIFY(!gUnlockAreaStub->stubLastCallTo("setActive").parameter<bool>(0)); // again move to active area m_subject->mouseMoveEvent(moveEvent); QCOMPARE(m_subject->dragAndDropState, (int)LockScreenWithPadlockView::STATE_MOVING_ACTIVE); QVERIFY(nameOfLastFeedback == "enter-dragndrop-dropzone"); QVERIFY(gUnlockAreaStub->stubLastCallTo("setActive").parameter<bool>(0)); // when the mouse is released, the unlocked signal should be sent m_subject->mouseReleaseEvent(releaseEvent); QCOMPARE(unlockSpy.count(), 1); QVERIFY(nameOfLastFeedback == "release-inside-dragndrop-dropzone"); QCOMPARE(m_subject->dragAndDropIcon->objectName(), QString("LockScreenDnDIcon")); QVERIFY(!m_subject->dragAndDropOverlay.isVisible()); QCOMPARE(m_subject->lockScreenHeader->objectName(), QString("LockLiftAreaWithPadlock")); QVERIFY(!gUnlockAreaStub->stubLastCallTo("setEnabled").parameter<bool>(0)); }