コード例 #1
0
ファイル: doc_test.cpp プロジェクト: CCLinck21/qlcplus
void 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);
}
コード例 #2
0
void 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());
}
コード例 #3
0
void tst_QGraphicsObject::visible()
{
    MyGraphicsObject object;
    QSignalSpy spy(&object, SIGNAL(visibleChanged()));
    QVERIFY(object.isVisible() == true);
    object.setVisible(false);
    QCOMPARE(spy.count(), 1);

    QVERIFY(object.isVisible() == false);

    object.setVisible(false);
    QCOMPARE(spy.count(), 1);

    object.setProperty("visible", true);
    QCOMPARE(spy.count(), 2);
    QVERIFY(object.property("visible") == true);
}
コード例 #4
0
void
TestRecurrentTransaction::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);
}
コード例 #5
0
void 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();
}
コード例 #6
0
void 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);
}
コード例 #7
0
void tst_QGraphicsObject::enabled()
{
    MyGraphicsObject object;
    QSignalSpy spy(&object, SIGNAL(enabledChanged()));
    QVERIFY(object.isEnabled() == true);
    object.setEnabled(false);
    QCOMPARE(spy.count(), 1);

    QVERIFY(object.isEnabled() == false);

    object.setEnabled(false);
    QCOMPARE(spy.count(), 1);

    object.setProperty("enabled", true);
    QCOMPARE(spy.count(), 2);
    QVERIFY(object.property("enabled") == true);
}
コード例 #8
0
void
TestRecurrentTransaction::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);
}
コード例 #9
0
void 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);
}
コード例 #10
0
void 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;
}
コード例 #11
0
void 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());
}
コード例 #12
0
ファイル: cuestack_test.cpp プロジェクト: ChrisLaurie/qlcplus
void 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);
}
コード例 #13
0
void 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"));

}
void 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());
}
コード例 #15
0
void Tst_connectionagent::tst_onConnectionRequest()
{
    NetworkManager *netman = NetworkManagerFactory::createInstance();
    QString currentState = netman->state();
    if (currentState == "online") {
        NetworkService *service = netman->defaultRoute();
        service->requestDisconnect();
//        service->requestConnect();
    }
    QSignalSpy spy(&QConnectionAgent::instance(), SIGNAL(connectionRequest()));
    QConnectionAgent::instance().onConnectionRequest();

    if (currentState == "online")
        QCOMPARE(spy.count(),0);
    else
        QCOMPARE(spy.count(),0);

}
コード例 #16
0
ファイル: closure_test.cpp プロジェクト: GitAnt/Clementine
TEST(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());
}
コード例 #17
0
ファイル: tst_qdeclarativedebug.cpp プロジェクト: RS102839/qt
void 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));
}
コード例 #18
0
ファイル: tc_Connected.cpp プロジェクト: genua/anoubis
END_TEST

START_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();
}
コード例 #19
0
void 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);
    }
}
コード例 #20
0
void 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));
    }
}
コード例 #21
0
ファイル: chattest.cpp プロジェクト: schuay/sepm
void 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));
}
コード例 #22
0
void
UnitTestsFingerprintIdRequest::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" );
}
コード例 #23
0
/**
 * 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);
}
コード例 #24
0
void 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);
}
コード例 #25
0
ファイル: eventedittest.cpp プロジェクト: KDE/kdepim-addons
void 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);
}
コード例 #26
0
void 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();
}
コード例 #27
0
void 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));
}
コード例 #28
0
ファイル: eventedittest.cpp プロジェクト: KDE/kdepim-addons
void 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);
}
コード例 #29
0
ファイル: chaser_test.cpp プロジェクト: Jeija/qlcplus
void 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));
}
コード例 #30
0
void QtBitCoindRPCTest::getBalance() {

    // Get reply
    QNetworkReply * reply = _client.getBalance();

    // Spy on finished signal
    QSignalSpy spy(reply, SIGNAL(finished()));

    // Wait for it to be issued
    QVERIFY(spy.wait(5000));

    // Parse result
    double result = _client.getBalance(reply);

    // Check that a positive number of blocks is reported
    QVERIFY(result > 0);

    qDebug() << result;
}