void ChangeRouterPasswordOp::startConfigOut() { connect(&m_timer1, SIGNAL(timeout()), SLOT(onTimeout1())); m_timer1.setSingleShot(true); m_timer1.start(5000); m_bean->m_soapCore->setWrappedMode(false); m_op = m_bean->m_soapCore->invoke(QLatin1String("DeviceConfig"), QLatin1String("ConfigurationFinished"), QLatin1String("NewStatus"), QLatin1String("ChangesApplied")); connect(m_op, SIGNAL(finished()), SLOT(onConfigOutFinished())); }
TEST(GTestTimer, TestClearTimeout) { GTestTimerOnTimeout::clearClearCount(); GTestTimerOnTimeout::Ptr onTimeout1(new GTestTimerOnTimeout()); Value id1 = setTimeout(onTimeout1, 1000); onTimeout1->setId(id1); GTestTimerOnTimeout::Ptr onTimeout2(new GTestTimerOnTimeout()); Value id2 = setTimeout(onTimeout2, 100); onTimeout2->setId(id1); node::run(); ASSERT_EQ(1, GTestTimerOnTimeout::getClearCount()); }
void ChangeRouterWifiPasswordOp::onSetWLANFinished() { AsyncOp *op = m_op; m_op->deleteLater(); m_op = NULL; if (isAborted()) { return; } int result = op->result(); LOG_DEBUG(QString::fromUtf8("onSetWLANFinished %1").arg(result)); if (result != NoError) { return notifyFinished(result); } QVariant varResponseCode = op->value("responseCode"); if (!varResponseCode.isValid()) { return notifyFinished(UnknownError); } bool ok; int responseCode = varResponseCode.toInt(&ok); if (!ok) { return notifyFinished(UnknownError); } if (responseCode != 0) { return notifyFinished(UnknownError); } if (m_configFinish) { m_op = m_bean->m_soapCore->invoke(QLatin1String("DeviceConfig"), QLatin1String("ConfigurationFinished"), QLatin1String("NewStatus"), QLatin1String("ChangesApplied")); connect(m_op, SIGNAL(finished()), SLOT(onCommitFinished())); connect(&m_timer1, SIGNAL(timeout()), SLOT(onTimeout1())); m_timer1.setSingleShot(true); m_timer1.start(8000); } else { notifyFinished(NoError); } }
TEST(GTestTimer, TestSetTimeout) { GTestTimerOnTimeout::Ptr onTimeout1(new GTestTimerOnTimeout()); Value id1 = setTimeout(onTimeout1, 100); onTimeout1->setId(id1); GTestTimerOnTimeout::Ptr onTimeout2(new GTestTimerOnTimeout()); Value id2 = setTimeout(onTimeout2, 75); onTimeout2->setId(id2); GTestTimerOnTimeout::Ptr onTimeout3(new GTestTimerOnTimeout()); Value id3 = setTimeout(onTimeout3, 100); onTimeout3->setId(id3); node::run(); ASSERT_EQ(3, GTestTimerOnTimeout::getClearCount()); }