这篇教程C++ spy函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中spy函数的典型用法代码示例。如果您正苦于以下问题:C++ spy函数的具体用法?C++ spy怎么用?C++ spy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了spy函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: spyvoid Doc_Test::mode(){ QSignalSpy spy(m_doc, SIGNAL(modeChanged(Doc::Mode))); QCOMPARE(m_doc->mode(), Doc::Design); m_doc->setMode(Doc::Operate); QCOMPARE(spy.size(), 1); m_doc->setMode(Doc::Operate); QCOMPARE(spy.size(), 1); m_doc->setMode(Doc::Design); QCOMPARE(spy.size(), 2); m_doc->setMode(Doc::Design); QCOMPARE(spy.size(), 2); m_doc->setKiosk(true); QVERIFY(m_doc->isKiosk() == true);}
开发者ID:CCLinck21,项目名称:qlcplus,代码行数:17,
示例2: spyvoid Ut_MImToolbar::testClose(){ QSignalSpy spy(m_subject, SIGNAL(closeKeyboardRequest())); QVERIFY(spy.isValid()); toolbarData = QSharedPointer<MToolbarData>(new MToolbarData); bool ok = toolbarData->loadToolbarXml(ToolbarFileName4); QVERIFY(ok); m_subject->showToolbarWidget(toolbarData); MToolbarButton *button = qobject_cast<MToolbarButton *>(find("testbutton")); QVERIFY(button != 0); button->click(); QVERIFY(spy.count() == 1); QVERIFY(spy.first().isEmpty());}
开发者ID:dudochkin-victor,项目名称:touch-inputmethodkeyboard,代码行数:17,
示例3: QStringvoidTestRecurrentTransaction::testSetMemoNoSignal() { auto memo = QString("Dinner with friends"); auto numberOfDays = 3; auto amount = .45; auto account = std::make_shared<PublicAccount>("Test account", .0, ""); auto category = std::make_shared<com::chancho::Category>("Sushi", com::chancho::Category::Type::EXPENSE); auto transactionPtr = std::make_shared<com::chancho::Transaction>(account, amount, category); transactionPtr->memo = memo; auto recurrentPtr = std::make_shared<com::chancho::RecurrentTransaction>(transactionPtr, std::make_shared<com::chancho::RecurrentTransaction::Recurrence>(numberOfDays, QDate::currentDate())); auto qmlTransaction = std::make_shared<com::chancho::tests::PublicRecurrentTransaction>(recurrentPtr); QSignalSpy spy(qmlTransaction.get(), SIGNAL(memoChanged(QString))); qmlTransaction->setMemo(memo); QCOMPARE(spy.count(), 0);}
开发者ID:sergiusens,项目名称:chancho,代码行数:17,
示例4: identityvoid tst_IdentityInterface::identifier(){ QScopedPointer<IdentityInterface> identity(new IdentityInterface); identity->classBegin(); identity->componentComplete(); QTRY_COMPARE(identity->status(), IdentityInterface::Initialized); QCOMPARE(identity->identifier(), 0); QSignalSpy spy(identity.data(), SIGNAL(identifierChanged())); identity->setUserName(QString(QLatin1String("test-username"))); identity->setSecret(QString(QLatin1String("test-secret"))); identity->setCaption(QString(QLatin1String("test-caption"))); identity->setMethodMechanisms(QString(QLatin1String("password")), QStringList() << QString(QLatin1String("ClientLogin"))); identity->sync(); QTRY_COMPARE(spy.count(), 1); QVERIFY(identity->identifier() > 0); QScopedPointer<IdentityInterface> identityTwo(new IdentityInterface); identityTwo->classBegin(); identityTwo->componentComplete(); QTRY_COMPARE(identityTwo->status(), IdentityInterface::Initialized); QCOMPARE(identityTwo->identifier(), 0); QSignalSpy spyTwo(identityTwo.data(), SIGNAL(identifierChanged())); identityTwo->setUserName(QString(QLatin1String("test-username-two"))); identityTwo->setSecret(QString(QLatin1String("test-secret"))); identityTwo->setCaption(QString(QLatin1String("test-caption"))); identityTwo->setMethodMechanisms(QString(QLatin1String("password")), QStringList() << QString(QLatin1String("ClientLogin"))); identityTwo->sync(); QTRY_COMPARE(spyTwo.count(), 1); QVERIFY(identityTwo->identifier() > 0); // this one doesn't create a new identity, but references an existing identity QScopedPointer<IdentityInterface> identityThree(new IdentityInterface); identityThree->classBegin(); identityThree->setIdentifier(identity->identifier()); identityThree->componentComplete(); QTRY_COMPARE(identityThree->status(), IdentityInterface::Initialized); QCOMPARE(identityThree->userName(), QLatin1String("test-username")); identityThree->setIdentifier(identityTwo->identifier()); // test that you can set it after initialization. QCOMPARE(identityThree->status(), IdentityInterface::Initializing); QTRY_COMPARE(identityThree->status(), IdentityInterface::Synced); QCOMPARE(identityThree->userName(), QLatin1String("test-username-two")); // cleanup identity->remove(); identityTwo->remove();}
开发者ID:Miss09,项目名称:nemo-qml-plugin-signon,代码行数:46,
示例5: spyvoid tst_QGraphicsObject::opacity(){ MyGraphicsObject object; QSignalSpy spy(&object, SIGNAL(opacityChanged())); QVERIFY(object.opacity() == 1.); object.setOpacity(0); QCOMPARE(spy.count(), 1); QVERIFY(object.opacity() == 0.); object.setOpacity(0); QCOMPARE(spy.count(), 1); object.setProperty("opacity", .5); QCOMPARE(spy.count(), 2); QVERIFY(object.property("opacity") == .5);}
开发者ID:KDE,项目名称:android-qt,代码行数:17,
示例6: spyvoidTestRecurrentTransaction::testSetEndDate() { auto endDate = QDate::currentDate().addYears(1); auto newEndDate = endDate.addDays(1); auto amount = .45; auto account = std::make_shared<PublicAccount>("Test account", .0, ""); auto category = std::make_shared<com::chancho::Category>("Sushi", com::chancho::Category::Type::EXPENSE); auto transactionPtr = std::make_shared<com::chancho::Transaction>(account, amount, category); auto recurrentPtr = std::make_shared<com::chancho::RecurrentTransaction>(transactionPtr, std::make_shared<com::chancho::RecurrentTransaction::Recurrence>( com::chancho::RecurrentTransaction::Recurrence::Defaults::DAILY, QDate::currentDate(), endDate)); auto qmlTransaction = std::make_shared<com::chancho::tests::PublicRecurrentTransaction>(recurrentPtr); QSignalSpy spy(qmlTransaction.get(), SIGNAL(endDateChanged(QDate))); qmlTransaction->setEndDate(newEndDate); QCOMPARE(spy.count(), 1);}
开发者ID:sergiusens,项目名称:chancho,代码行数:17,
示例7: spyvoid EditorBoardTest::testCaseBoardDataMgrNew(){ KkrBoardManager kbm; QSignalSpy spy(&kbm, &KkrBoardManager::sigReset); QCOMPARE(spy.count(), 0); constexpr int cols = 4; constexpr int rows = 10; kbm.slCreate(cols, rows); QCOMPARE(spy.count(), 1); // size QCOMPARE(kbm.getNumCols(), cols); QCOMPARE(kbm.getNumRows(), rows); // defalut cell types QCOMPARE(kbm.getCellType(0, 0), CellType::CellClue); QCOMPARE(kbm.getCellType(0, rows-1), CellType::CellClue); QCOMPARE(kbm.getCellType(cols-1, 0), CellType::CellClue); QCOMPARE(kbm.getCellType(cols-1, rows-1), CellType::CellAnswer); QCOMPARE(kbm.getCellType(cols/2, rows/2), CellType::CellAnswer); // default cell clue QCOMPARE(kbm.getClueDown(0,0), CLOSED_CLUE); QCOMPARE(kbm.getClueRight(0,0), CLOSED_CLUE); QCOMPARE(kbm.getClueDown(1,0), EMPTY_CLUE); QCOMPARE(kbm.getClueRight(1,0), CLOSED_CLUE); QCOMPARE(kbm.getClueDown(0,2), CLOSED_CLUE); QCOMPARE(kbm.getClueRight(0,2), EMPTY_CLUE); // default cell value QCOMPARE(kbm.getAnswer(1,1), EMPTY_ANSWER); QCOMPARE(kbm.getAnswer(3,5), EMPTY_ANSWER); // reset constexpr int cols2 = 6; constexpr int rows2 = 13; kbm.slCreate(cols2, rows2); QCOMPARE(spy.count(), 2); // size QCOMPARE(kbm.getNumCols(), cols2); QCOMPARE(kbm.getNumRows(), rows2);}
开发者ID:hideki1234,项目名称:Kakuro,代码行数:45,
示例8: QVERIFYvoid tst_qsganimatedimage::mirror_running(){ // test where mirror is set to true after animation has started QSGView *canvas = new QSGView; canvas->show(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/hearts.qml")); QSGAnimatedImage *anim = qobject_cast<QSGAnimatedImage *>(canvas->rootObject()); QVERIFY(anim); int width = anim->property("width").toInt(); QCOMPARE(anim->currentFrame(), 0); QPixmap frame0 = canvas->renderPixmap(); anim->setCurrentFrame(1); QPixmap frame1 = canvas->renderPixmap(); anim->setCurrentFrame(0); QSignalSpy spy(anim, SIGNAL(frameChanged())); anim->setPlaying(true); QTRY_VERIFY(spy.count() == 1); spy.clear(); anim->setProperty("mirror", true); QCOMPARE(anim->currentFrame(), 1); QPixmap frame1_flipped = canvas->renderPixmap(); QTRY_VERIFY(spy.count() == 1); spy.clear(); QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first QPixmap frame0_flipped = canvas->renderPixmap(); QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved", SkipSingle); QTransform transform; transform.translate(width, 0).scale(-1, 1.0); QPixmap frame0_expected = frame0.transformed(transform); QPixmap frame1_expected = frame1.transformed(transform); QCOMPARE(frame0_flipped, frame0_expected); QCOMPARE(frame1_flipped, frame1_expected); delete canvas;}
开发者ID:yinyunqiao,项目名称:qtdeclarative,代码行数:45,
示例9: spyvoid Ut_MApplicationPage::testPageTitleChanged(){ qRegisterMetaType< QList<const char *> >("QList<const char *>"); QSignalSpy spy(m_subject->model(), SIGNAL(modified(QList<const char *>))); QString title("Title!"); m_subject->setTitle(m_subject->title()); QCOMPARE(spy.count(), 0); m_subject->setTitle(title); QCOMPARE(spy.count(), 1); QCOMPARE(m_subject->model()->title(), title); m_subject->setTitle(title); QCOMPARE(spy.count(), 1); m_subject->setTitle(QString()); QCOMPARE(spy.count(), 2); QCOMPARE(m_subject->model()->title(), QString());}
开发者ID:arcean,项目名称:libmeegotouch-framework,代码行数:18,
示例10: csvoid CueStack_Test::preRun(){ CueStack cs(m_doc); QVERIFY(cs.m_fader == NULL); QCOMPARE(cs.isStarted(), false); cs.m_elapsed = 500; QSignalSpy spy(&cs, SIGNAL(started())); cs.preRun(); QVERIFY(cs.m_fader != NULL); QCOMPARE(spy.size(), 1); QCOMPARE(cs.m_elapsed, uint(0)); QCOMPARE(cs.m_fader->intensity(), qreal(1.0)); QCOMPARE(cs.isStarted(), true); MasterTimer mt(m_doc); cs.postRun(&mt);}
开发者ID:ChrisLaurie,项目名称:qlcplus,代码行数:18,
示例11: spyvoid Tst_connectionagent::tst_onErrorReported(){ QSignalSpy spy(&QConnectionAgent::instance(), SIGNAL(errorReported(QString,QString))); QConnectionAgent::instance().onErrorReported("test_path","Test error"); QCOMPARE(spy.count(),1); QList<QVariant> arguments; arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toString(), QString("test_path")); QCOMPARE(arguments.at(1).toString(), QString("Test error")); QConnectionAgent::instance().connectToType("test"); QCOMPARE(spy.count(),1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toString(), QString("")); QCOMPARE(arguments.at(1).toString(), QString("Type not valid"));}
开发者ID:amccarthy,项目名称:connectionagent,代码行数:18,
示例12: spyvoid QtQuickSampleApplicationTest::myCalculatorViewModelSetMyResultTest(){ // Setup the test MyCalculatorViewModel model; QSignalSpy spy( &model, SIGNAL(myResultChanged()) ); // monitor for the myResultChanged() signal QCOMPARE( spy.count(), 0 ); // Expect the signal to have not been thrown yet. QCOMPARE( model.getMyResult(), 0 ); //Expect the result value to be zero by default // Test int expect( 100 ); model.setMyResult( expect ); QVERIFY2( spy.count() == 1, QString( "Expecting the myResultChanged() signal to have be emitted. actual [%1], expected [%2]").arg(spy.count()).arg(1).toStdString().c_str() ); int actual = model.getMyResult(); QVERIFY2( actual == expect, QString("Expect the result value to be [%1] but actually got [%2] instead.").arg(expect).arg(actual).toStdString().c_str());}
开发者ID:AzNBagel,项目名称:ImaginativeThinking_tutorials,代码行数:18,
示例13: TESTTEST(ClosureTest, ClosureDeletesSelf) { TestQObject sender; TestQObject receiver; _detail::ClosureBase* closure = NewClosure( &sender, SIGNAL(Emitted()), &receiver, SLOT(Invoke())); _detail::ObjectHelper* helper = closure->helper(); QSignalSpy spy(helper, SIGNAL(destroyed())); EXPECT_EQ(0, receiver.invoked()); sender.Emit(); EXPECT_EQ(1, receiver.invoked()); EXPECT_EQ(0, spy.count()); QEventLoop loop; QObject::connect(helper, SIGNAL(destroyed()), &loop, SLOT(quit())); loop.exec(); EXPECT_EQ(1, spy.count());}
开发者ID:GitAnt,项目名称:Clementine,代码行数:18,
示例14: findRootObjectvoid tst_QDeclarativeDebug::watch_property(){ QDeclarativeDebugObjectReference obj = findRootObject(); QDeclarativeDebugPropertyReference prop = findProperty(obj.properties(), "width"); QDeclarativeDebugPropertyWatch *watch; QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0); watch = unconnected->addWatch(prop, this); QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead); delete watch; delete unconnected; watch = m_dbg->addWatch(QDeclarativeDebugPropertyReference(), this); QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State)))); QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive); delete watch; watch = m_dbg->addWatch(prop, this); QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting); QCOMPARE(watch->objectDebugId(), obj.debugId()); QCOMPARE(watch->name(), prop.name()); QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant))); int origWidth = m_rootItem->property("width").toInt(); m_rootItem->setProperty("width", origWidth*2); // stateChanged() is received before valueChanged() QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State)))); QCOMPARE(watch->state(), QDeclarativeDebugWatch::Active); QCOMPARE(spy.count(), 1); m_dbg->removeWatch(watch); delete watch; // restore original value and verify spy doesn't get additional signal since watch has been removed m_rootItem->setProperty("width", origWidth); QTest::qWait(100); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).value<QByteArray>(), prop.name().toUtf8()); QCOMPARE(spy.at(0).at(1).value<QVariant>(), qVariantFromValue(origWidth*2));}
开发者ID:RS102839,项目名称:qt,代码行数:44,
示例15: START_TESTEND_TESTSTART_TEST(test_policyrequest){ wxString policy_in, policy_out; mark_point(); /* Read policy from daemon (using anoubisctl) */ policy_in = anoubisctl_dump(); fail_if(policy_in.IsEmpty(), "Failed to fetch policy from daemon"); mark_point(); /* Read policy from daemon (using JobCtrl) */ TaskEventSpy spy(jobCtrl, anTASKEVT_POLICY_REQUEST); ComPolicyRequestTask task; task.setRequestParameter(1, getuid()); mark_point(); jobCtrl->addTask(&task); mark_point(); spy.waitForInvocation(1); mark_point(); fail_unless(task.getComTaskResult() == ComTask::RESULT_SUCCESS, "Failed to receive a policy: %i/n", task.getComTaskResult()); fail_unless(task.getResultDetails() == 0, "ResultDetails: %s (%i)/n", anoubis_strerror(task.getResultDetails()), task.getResultDetails()); mark_point(); PolicyRuleSet *rs = task.getPolicy(); mark_point(); rs->toString(policy_out); mark_point(); delete rs; mark_point(); fail_unless(policy_in == policy_out, "Unexpected policy fetched/nis:/n%ls/nexpected:/n%ls", policy_out.c_str(), policy_in.c_str()); mark_point();}
开发者ID:genua,项目名称:anoubis,代码行数:43,
示例16: spyvoid tst_QNetworkAccessManager::networkAccessible(){ QNetworkAccessManager manager; qRegisterMetaType<QNetworkAccessManager::NetworkAccessibility>("QNetworkAccessManager::NetworkAccessibility"); QSignalSpy spy(&manager, SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility))); QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::UnknownAccessibility); manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible); QCOMPARE(spy.count(), 1); QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(), QNetworkAccessManager::NotAccessible); QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible); manager.setNetworkAccessible(QNetworkAccessManager::Accessible); QCOMPARE(spy.count(), 1); QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(), QNetworkAccessManager::UnknownAccessibility); QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::UnknownAccessibility); QNetworkConfigurationManager configManager; QNetworkConfiguration defaultConfig = configManager.defaultConfiguration(); if (defaultConfig.isValid()) { manager.setConfiguration(defaultConfig); QCOMPARE(spy.count(), 1); QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(), QNetworkAccessManager::Accessible); QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::Accessible); manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible); QCOMPARE(spy.count(), 1); QCOMPARE(QNetworkAccessManager::NetworkAccessibility(spy.takeFirst().at(0).toInt()), QNetworkAccessManager::NotAccessible); QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible); }}
开发者ID:KDE,项目名称:android-qt,代码行数:43,
示例17: QFETCHvoid tst_QNmeaPositionInfoSource::startUpdates_waitForValidDateTime(){ // Tests that the class does not emit an update until it receives a // sentences with a valid date *and* time. All sentences before this // should be ignored, and any sentences received after this that do // not have a date should use the known date. QFETCH(QByteArray, bytes); QFETCH(QList<QDateTime>, dateTimes); QFETCH(QList<bool>, expectHorizontalAccuracy); QFETCH(QList<bool>, expectVerticalAccuracy); QNmeaPositionInfoSource source(m_mode); source.setUserEquivalentRangeError(5.1); QNmeaPositionInfoSourceProxyFactory factory; QNmeaPositionInfoSourceProxy *proxy = static_cast<QNmeaPositionInfoSourceProxy*>(factory.createProxy(&source)); QSignalSpy spy(proxy->source(), SIGNAL(positionUpdated(QGeoPositionInfo))); proxy->source()->startUpdates(); proxy->feedBytes(bytes); QTRY_COMPARE(spy.count(), dateTimes.count()); for (int i=0; i<spy.count(); i++) { QGeoPositionInfo pInfo = spy[i][0].value<QGeoPositionInfo>(); QCOMPARE(pInfo.timestamp(), dateTimes[i]); // Generated GGA/GSA sentences have hard coded HDOP of 3.5, which corrisponds to a // horizontal accuracy of 35.7, for the user equivalent range error of 5.1 set above. QCOMPARE(pInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy), expectHorizontalAccuracy[i]); if (pInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy)) QVERIFY(qFuzzyCompare(pInfo.attribute(QGeoPositionInfo::HorizontalAccuracy), 35.7)); // Generate GSA sentences have hard coded VDOP of 4.0, which corrisponds to a vertical // accuracy of 40.8, for the user equivalent range error of 5.1 set above. QCOMPARE(pInfo.hasAttribute(QGeoPositionInfo::VerticalAccuracy), expectVerticalAccuracy[i]); if (pInfo.hasAttribute(QGeoPositionInfo::VerticalAccuracy)) QVERIFY(qFuzzyCompare(pInfo.attribute(QGeoPositionInfo::VerticalAccuracy), 40.8)); }}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:43,
示例18: QVERIFYvoid ChatTests::testLeaveChat(){ QVERIFY(chat); QSignalSpy spy(session2.data(), SIGNAL(invitationReceived(QSharedPointer<Chat>))); QVERIFY(spy.isValid()); QVERIFY(spy.isEmpty()); QSignalSpy spy4(chat.data(), SIGNAL(userJoined(QSharedPointer<const User>))); QVERIFY(spy4.isValid()); QVERIFY(spy4.isEmpty()); QSharedPointer<const User> u(new User(TEMP_SESSION_USER2, WORKING_DIR "public.pem")); chat->invite(u); waitForResult(spy); waitForResult(spy4); QList<QVariant> arguments = spy.takeFirst(); QSharedPointer<Chat> chat2 = arguments.at(0).value<QSharedPointer<Chat> >(); QSignalSpy spy2(chat.data(), SIGNAL(leaveChatCompleted(bool, QString))); QVERIFY(spy2.isValid()); QVERIFY(spy2.isEmpty()); QSignalSpy spy3(chat2.data(), SIGNAL(userLeft(QSharedPointer<const User>))); QVERIFY(spy3.isValid()); QVERIFY(spy3.isEmpty()); chat->leaveChat(); waitForResult(spy2); waitForResult(spy3); QCOMPARE(spy2.count(), 1); QList<QVariant> arguments2 = spy2.takeFirst(); QVERIFY2(arguments2.at(0) == true, arguments2.at(1).toString().toStdString().c_str()); QCOMPARE(spy3.count(), 1); QList<QVariant> arguments3 = spy3.takeFirst(); QSharedPointer<const User> u2 = arguments3.at(0).value<QSharedPointer<const User> >(); QCOMPARE(u2->getName(), QString(TEMP_SESSION_USER3));}
开发者ID:schuay,项目名称:sepm,代码行数:43,
示例19: fvoidUnitTestsFingerprintIdRequest::testValidMp3(){ MutableTrack t; t.setUrl( QUrl::fromLocalFile( "../lib/fingerprint/tests/data/05 - You Lot.mp3" ) ); t.setAlbum( "Blue Album" ); t.setArtist( "Orbital" ); t.setTitle( "You Lot" ); t.setDuration( 427 ); t.setTrackNumber( 5 ); FingerprintIdRequest f( t ); QSignalSpy spy( &f, SIGNAL(FpIDFound( QString )) ); QTest::qWait( 5000 ); QVERIFY2( spy.count() == 1, "Did not receive FpIdFound signal" ); QVERIFY( spy.takeFirst().takeFirst().toString() != "0" );}
开发者ID:weiligang512,项目名称:apue-test,代码行数:19,
示例20: temp/** * Get and set the rating of a temp file */void SemanticInfoBackEndTest::testRating(){ QTemporaryFile temp("XXXXXX.metadatabackendtest"); QVERIFY(temp.open()); QUrl url; url.setPath(temp.fileName()); SemanticInfoBackEndClient client(mBackEnd); QSignalSpy spy(mBackEnd, SIGNAL(semanticInfoRetrieved(QUrl,SemanticInfo))); mBackEnd->retrieveSemanticInfo(url); QVERIFY(waitForSignal(spy)); SemanticInfo semanticInfo = client.semanticInfoForUrl(url); QCOMPARE(semanticInfo.mRating, 0); semanticInfo.mRating = 5; mBackEnd->storeSemanticInfo(url, semanticInfo);}
开发者ID:shlomif,项目名称:gwenview,代码行数:22,
示例21: spyvoid tst_QOpenGL::aboutToBeDestroyed(){ QWindow window; window.setSurfaceType(QWindow::OpenGLSurface); window.setGeometry(0, 0, 128, 128); window.create(); QOpenGLContext *context = new QOpenGLContext; QSignalSpy spy(context, SIGNAL(aboutToBeDestroyed())); context->create(); context->makeCurrent(&window); QCOMPARE(spy.size(), 0); delete context; QCOMPARE(spy.size(), 1);}
开发者ID:SfietKonstantin,项目名称:radeon-qt5-qtbase-kms,代码行数:19,
示例22: msgvoid EventEditTest::shouldNotEmitCreateEventWhenDateIsInvalid(){ MessageViewer::EventEdit edit; KMime::Message::Ptr msg(new KMime::Message); MessageViewer::EventDateTimeWidget *startDateTime = edit.findChild<MessageViewer::EventDateTimeWidget *>(QStringLiteral("startdatetimeedit")); startDateTime->setDateTime(QDateTime()); MessageViewer::EventDateTimeWidget *endDateTime = edit.findChild<MessageViewer::EventDateTimeWidget *>(QStringLiteral("enddatetimeedit")); endDateTime->setDateTime(QDateTime()); QString subject = QStringLiteral("Test Note"); msg->subject(true)->fromUnicodeString(subject, "us-ascii"); edit.setMessage(msg); QLineEdit *eventedit = edit.findChild<QLineEdit *>(QStringLiteral("eventedit")); QSignalSpy spy(&edit, SIGNAL(createEvent(KCalCore::Event::Ptr,Akonadi::Collection))); QTest::keyClick(eventedit, Qt::Key_Enter); QCOMPARE(spy.count(), 0);}
开发者ID:KDE,项目名称:kdepim-addons,代码行数:19,
示例23: spyvoid QtBitCoindRPCTest::listAccounts() { // Get reply QNetworkReply * reply = _client.listAccounts(); // Spy on finished signal QSignalSpy spy(reply, SIGNAL(finished())); // Wait for it to be issued QVERIFY(spy.wait(5000)); // Parse result QMap<QString, double> result = _client.listAccounts(reply); // Check that a positive number of blocks is reported QVERIFY(result.size() > 0); qDebug() << result.size();}
开发者ID:JoyStream,项目名称:QtBitCoindRPC,代码行数:19,
示例24: findRootObjectvoid tst_QQmlEngineDebugService::watch_property(){ QmlDebugObjectReference obj = findRootObject(); QmlDebugPropertyReference prop = findProperty(obj.properties, "width"); bool success; QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0); unconnected->addWatch(prop, &success); QVERIFY(!success); delete unconnected; m_dbg->addWatch(QmlDebugPropertyReference(), &success); QVERIFY(success); QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result()))); QCOMPARE(m_dbg->valid(), false); quint32 id = m_dbg->addWatch(prop, &success); QVERIFY(success); QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result()))); QCOMPARE(m_dbg->valid(), true); QSignalSpy spy(m_dbg, SIGNAL(valueChanged(QByteArray,QVariant))); int origWidth = m_rootItem->property("width").toInt(); m_rootItem->setProperty("width", origWidth*2); QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(valueChanged(QByteArray,QVariant)))); QCOMPARE(spy.count(), 1); m_dbg->removeWatch(id, &success); QVERIFY(success); QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result()))); QCOMPARE(m_dbg->valid(), true); // restore original value and verify spy doesn't get additional signal since watch has been removed m_rootItem->setProperty("width", origWidth); QTest::qWait(100); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).value<QByteArray>(), prop.name.toUtf8()); QCOMPARE(spy.at(0).at(1).value<QVariant>(), qVariantFromValue(origWidth*2));}
开发者ID:ghjinlei,项目名称:qt5,代码行数:43,
示例25: QVERIFYvoid EventEditTest::shouldEmitEventWhenPressEnter(){ MessageViewer::EventEdit edit; edit.show(); // make sure the window is active so we can test for focus qApp->setActiveWindow(&edit); QTest::qWaitForWindowExposed(&edit); QVERIFY(edit.isVisible()); KMime::Message::Ptr msg(new KMime::Message); QString subject = QStringLiteral("Test Note"); msg->subject(true)->fromUnicodeString(subject, "us-ascii"); edit.setMessage(msg); QLineEdit *eventedit = edit.findChild<QLineEdit *>(QStringLiteral("eventedit")); eventedit->setFocus(); QSignalSpy spy(&edit, SIGNAL(createEvent(KCalCore::Event::Ptr,Akonadi::Collection))); QTest::keyClick(eventedit, Qt::Key_Enter); QCOMPARE(spy.count(), 1);}
开发者ID:KDE,项目名称:kdepim-addons,代码行数:19,
示例26: cvoid Chaser_Test::clear(){ Chaser c(m_doc); c.setID(50); QCOMPARE(c.steps().size(), 0); c.addStep(ChaserStep(0)); c.addStep(ChaserStep(1)); c.addStep(ChaserStep(2)); c.addStep(ChaserStep(470)); QCOMPARE(c.steps().size(), 4); QSignalSpy spy(&c, SIGNAL(changed(quint32))); c.clear(); QCOMPARE(c.steps().size(), 0); QCOMPARE(spy.size(), 1); QCOMPARE(spy.at(0).size(), 1); QCOMPARE(spy.at(0).at(0).toUInt(), quint32(50));}
开发者ID:Jeija,项目名称:qlcplus,代码行数:19,
注:本文中的spy函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ sq函数代码示例 C++ sputc函数代码示例 |