• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ QTRY_COMPARE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中QTRY_COMPARE函数的典型用法代码示例。如果您正苦于以下问题:C++ QTRY_COMPARE函数的具体用法?C++ QTRY_COMPARE怎么用?C++ QTRY_COMPARE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了QTRY_COMPARE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: component

void tst_qdeclarativefontloader::webFont()
{
    QString componentStr = "import Qt 4.7\nFontLoader { source: \"http://localhost:14448/tarzeau_ocr_a.ttf\" }";
    QDeclarativeComponent component(&engine);

    component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
    QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());

    QVERIFY(fontObject != 0);
    QVERIFY(fontObject->source() != QUrl(""));
    QTRY_COMPARE(fontObject->name(), QString("OCRA"));
    QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:13,代码来源:tst_qdeclarativefontloader.cpp


示例2: loadingSpy

void tst_QSampleCache::testNotCachedSample()
{
    QSampleCache cache;
    QSignalSpy loadingSpy(&cache, SIGNAL(isLoadingChanged()));

    QSample* sample = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav")));
    QVERIFY(sample);
    QTRY_COMPARE(loadingSpy.count(), 2);
    QTRY_VERIFY(!cache.isLoading());
    sample->release();

    QVERIFY(!cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav"))));
}
开发者ID:Elleo,项目名称:qtmultimedia,代码行数:13,代码来源:tst_qsamplecache.cpp


示例3: QString

void tst_qdeclarativefontloader::failLocalFont()
{
    QString componentStr = "import Qt 4.7\nFontLoader { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" }";
    QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\"").toUtf8().constData());
    QDeclarativeComponent component(&engine);
    component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
    QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());

    QVERIFY(fontObject != 0);
    QVERIFY(fontObject->source() != QUrl(""));
    QTRY_COMPARE(fontObject->name(), QString(""));
    QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error);
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:13,代码来源:tst_qdeclarativefontloader.cpp


示例4: app

void tst_QGuiApplication::focusObject()
{
    int argc = 0;
    QGuiApplication app(argc, 0);

    QObject obj1, obj2, obj3;
    const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry();

    DummyWindow window1;
    window1.resize(windowSize, windowSize);
    window1.setTitle(QStringLiteral("focusObject:window1"));
    window1.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing));
    DummyWindow window2;
    window2.resize(windowSize, windowSize);
    window2.setFramePosition(QPoint(screenGeometry.left() + 2 * spacing + windowSize, screenGeometry.top() + spacing));
    window2.setTitle(QStringLiteral("focusObject:window2"));

    window1.show();

    QSignalSpy spy(&app, SIGNAL(focusObjectChanged(QObject*)));


    // verify active window focus propagates to qguiapplication
    window1.requestActivate();
    QVERIFY(QTest::qWaitForWindowActive(&window1));
    QCOMPARE(app.focusWindow(), &window1);

    window1.setFocusObject(&obj1);
    QCOMPARE(app.focusObject(), &obj1);
    QCOMPARE(spy.count(), 1);

    spy.clear();
    window1.setFocusObject(&obj2);
    QCOMPARE(app.focusObject(), &obj2);
    QCOMPARE(spy.count(), 1);

    spy.clear();
    window2.setFocusObject(&obj3);
    QCOMPARE(app.focusObject(), &obj2); // not yet changed
    window2.show();
    QVERIFY(QTest::qWaitForWindowExposed(&window2));
    QTRY_COMPARE(app.focusWindow(), &window2);
    QCOMPARE(app.focusObject(), &obj3);
    QCOMPARE(spy.count(), 1);

    // focus change on unfocused window does not show
    spy.clear();
    window1.setFocusObject(&obj1);
    QCOMPARE(spy.count(), 0);
    QCOMPARE(app.focusObject(), &obj3);
}
开发者ID:cedrus,项目名称:qt,代码行数:51,代码来源:tst_qguiapplication.cpp


示例5: QFETCH

void tst_QItemDelegate::decoration()
{
    Q_CHECK_PAINTEVENTS

    QFETCH(int, type);
    QFETCH(QSize, size);
    QFETCH(QSize, expected);

    QTableWidget table(1, 1);
    TestItemDelegate delegate;
    table.setItemDelegate(&delegate);
    table.show();
    QApplication::setActiveWindow(&table);
    QVERIFY(QTest::qWaitForWindowActive(&table));

    QVariant value;
    switch ((QVariant::Type)type) {
    case QVariant::Pixmap: {
        QPixmap pm(size);
        pm.fill(Qt::black);
        value = pm;
        break;
    }
    case QVariant::Image: {
        QImage img(size, QImage::Format_Mono);
        memset(img.bits(), 0, img.byteCount());
        value = img;
        break;
    }
    case QVariant::Icon: {
        QPixmap pm(size);
        pm.fill(Qt::black);
        value = QIcon(pm);
        break;
    }
    case QVariant::Color:
        value = QColor(Qt::green);
        break;
    default:
        break;
    }

    QTableWidgetItem *item = new QTableWidgetItem;
    item->setData(Qt::DecorationRole, value);
    table.setItem(0, 0, item);
    item->setSelected(true);

    QApplication::processEvents();

    QTRY_COMPARE(delegate.decorationRect.size(), expected);
}
开发者ID:crobertd,项目名称:qtbase,代码行数:51,代码来源:tst_qitemdelegate.cpp


示例6: QTRY_COMPARE

void tst_QScreen::orientationChange()
{
    qRegisterMetaType<Qt::ScreenOrientation>("Qt::ScreenOrientation");

    QScreen *screen = QGuiApplication::primaryScreen();

    screen->setOrientationUpdateMask(Qt::LandscapeOrientation | Qt::PortraitOrientation);

    QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation);
    QWindowSystemInterface::flushWindowSystemEvents();
    QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation);

    QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::PortraitOrientation);
    QWindowSystemInterface::flushWindowSystemEvents();
    QTRY_COMPARE(screen->orientation(), Qt::PortraitOrientation);

    QSignalSpy spy(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)));

    QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedLandscapeOrientation);
    QWindowSystemInterface::flushWindowSystemEvents();
    QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedPortraitOrientation);
    QWindowSystemInterface::flushWindowSystemEvents();
    QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation);
    QWindowSystemInterface::flushWindowSystemEvents();

    QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation);
    QCOMPARE(spy.count(), 1);

    spy.clear();
    QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedLandscapeOrientation);
    QWindowSystemInterface::flushWindowSystemEvents();
    QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation);
    QCOMPARE(spy.count(), 0);

    screen->setOrientationUpdateMask(screen->orientationUpdateMask() | Qt::InvertedLandscapeOrientation);
    QTRY_COMPARE(screen->orientation(), Qt::InvertedLandscapeOrientation);
    QCOMPARE(spy.count(), 1);
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:38,代码来源:tst_qscreen.cpp


示例7: QFETCH

void tst_QNmeaPositionInfoSource::beginWithBufferedData()
{
    // In SimulationMode, data stored in the QIODevice is read when
    // startUpdates() or requestUpdate() is called.
    // In RealTimeMode, all existing data in the QIODevice is ignored -
    // only new data will be read.

    QFETCH(QList<QDateTime>, dateTimes);
    QFETCH(UpdateTriggerMethod, trigger);

    QByteArray bytes;
    for (int i=0; i<dateTimes.count(); i++)
        bytes += QLocationTestUtils::createRmcSentence(dateTimes[i]).toLatin1();
    QBuffer buffer;
    buffer.setData(bytes);

    QNmeaPositionInfoSource source(m_mode);
    QSignalSpy spy(&source, SIGNAL(positionUpdated(QGeoPositionInfo)));
    source.setDevice(&buffer);

    if (trigger == StartUpdatesMethod)
        source.startUpdates();
    else if (trigger == RequestUpdatesMethod)
        source.requestUpdate();

    if (m_mode == QNmeaPositionInfoSource::RealTimeMode) {
        QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 0, 300);
    } else {
        if (trigger == StartUpdatesMethod) {
            QTRY_COMPARE(spy.count(), dateTimes.count());
            for (int i=0; i<dateTimes.count(); i++)
                QCOMPARE(spy.at(i).at(0).value<QGeoPositionInfo>().timestamp(), dateTimes[i]);
        } else if (trigger == RequestUpdatesMethod) {
            QTRY_COMPARE(spy.count(), 1);
            QCOMPARE(spy.at(0).at(0).value<QGeoPositionInfo>().timestamp(), dateTimes.first());
        }
    }
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:38,代码来源:tst_qnmeapositioninfosource.cpp


示例8: QFETCH

void tst_QWaveDecoder::file()
{
    QFETCH(QString, file);
    QFETCH(tst_QWaveDecoder::Corruption, corruption);
    QFETCH(int, channels);
    QFETCH(int, samplesize);
    QFETCH(int, samplerate);
    QFETCH(QAudioFormat::Endian, byteorder);

    QFile stream;
    stream.setFileName(file);
    stream.open(QIODevice::ReadOnly);

    QVERIFY(stream.isOpen());

    QWaveDecoder waveDecoder(&stream);
    QSignalSpy validFormatSpy(&waveDecoder, SIGNAL(formatKnown()));
    QSignalSpy parsingErrorSpy(&waveDecoder, SIGNAL(parsingError()));

    if (corruption == NotAWav) {
        QSKIP("Not all failures detected correctly yet");
        QTRY_COMPARE(parsingErrorSpy.count(), 1);
        QCOMPARE(validFormatSpy.count(), 0);
    } else if (corruption == NoSampleData) {
        QTRY_COMPARE(validFormatSpy.count(), 1);
        QCOMPARE(parsingErrorSpy.count(), 0);
        QVERIFY(waveDecoder.audioFormat().isValid());
        QVERIFY(waveDecoder.size() == 0);
        QVERIFY(waveDecoder.duration() == 0);
    } else if (corruption == FormatDescriptor) {
        QTRY_COMPARE(parsingErrorSpy.count(), 1);
        QCOMPARE(validFormatSpy.count(), 0);
    } else if (corruption == FormatString) {
        QTRY_COMPARE(parsingErrorSpy.count(), 1);
        QCOMPARE(validFormatSpy.count(), 0);
        QVERIFY(!waveDecoder.audioFormat().isValid());
    } else if (corruption == DataDescriptor) {
        QTRY_COMPARE(parsingErrorSpy.count(), 1);
        QCOMPARE(validFormatSpy.count(), 0);
        QVERIFY(waveDecoder.size() == 0);
    } else if (corruption == None) {
        QTRY_COMPARE(validFormatSpy.count(), 1);
        QCOMPARE(parsingErrorSpy.count(), 0);
        QVERIFY(waveDecoder.audioFormat().isValid());
        QVERIFY(waveDecoder.size() > 0);
        QVERIFY(waveDecoder.duration() == 250);
        QAudioFormat format = waveDecoder.audioFormat();
        QVERIFY(format.isValid());
        QVERIFY(format.channelCount() == channels);
        QVERIFY(format.sampleSize() == samplesize);
        QVERIFY(format.sampleRate() == samplerate);
        if (format.sampleSize() != 8) {
            QVERIFY(format.byteOrder() == byteorder);
        }
    }

    stream.close();
}
开发者ID:Elleo,项目名称:qtmultimedia,代码行数:58,代码来源:tst_qwavedecoder.cpp


示例9: events

void tst_QTimer::livelock()
{
    /*
      New timers created in timer event handlers should not be sent
      until the next iteration of the eventloop.  Note: this test
      depends on the fact that we send posted events before timer
      events (since new posted events are not sent until the next
      iteration of the eventloop either).
    */
    QFETCH(int, interval);
    LiveLockTester tester(interval);
    QTest::qWait(180); // we have to use wait here, since we're testing timers with a non-zero timeout
    QTRY_COMPARE(tester.timeoutsForFirst, 1);
    QCOMPARE(tester.timeoutsForExtra, 0);
    QTRY_COMPARE(tester.timeoutsForSecond, 1);
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
	if (QSysInfo::WindowsVersion < QSysInfo::WV_XP)
		QEXPECT_FAIL("non-zero timer", "Multimedia timers are not available on Windows 2000", Continue);
#elif defined(Q_OS_WINCE)
	QEXPECT_FAIL("non-zero timer", "Windows CE devices often too slow", Continue);
#endif
    QVERIFY(tester.postEventAtRightTime);
}
开发者ID:maxxant,项目名称:qt,代码行数:23,代码来源:tst_qtimer.cpp


示例10: dummy

void FlameGraphViewTest::testContextMenu()
{
    int targetWidth = 0;
    int targetHeight = 0;
    {
        QMenu testMenu;
        testMenu.addActions(QmlProfilerTool::profilerContextMenuActions());
        testMenu.addSeparator();
        testMenu.show();
        QTest::qWaitForWindowExposed(testMenu.window());
        targetWidth = testMenu.width() / 2;
        int prevHeight = testMenu.height();
        QAction dummy(QString("target"), this);
        testMenu.addAction(&dummy);
        targetHeight = (testMenu.height() + prevHeight) / 2;
    }

    QTimer timer;
    timer.setInterval(50);
    timer.start();

    connect(&timer, &QTimer::timeout, this, [&]() {
        auto activePopup = qApp->activePopupWidget();
        if (!activePopup || !activePopup->windowHandle()->isExposed())
            return;
        QTest::mouseMove(activePopup, QPoint(targetWidth, targetHeight));
        QTest::mouseClick(activePopup, Qt::LeftButton, Qt::NoModifier,
                          QPoint(targetWidth, targetHeight));

        if (!manager.isRestrictedToRange()) {
            // click somewhere else to remove the menu and return to outer function
            QTest::mouseClick(qApp->activePopupWidget(), Qt::LeftButton, Qt::NoModifier,
                              QPoint(500, 500));
        }
    });

    QTest::mouseMove(&view, QPoint(250, 250));
    QSignalSpy spy(&view, SIGNAL(showFullRange()));

    QContextMenuEvent event(QContextMenuEvent::Mouse, QPoint(250, 250));
    QVERIFY(qApp->notify(&view, &event));
    QCOMPARE(spy.count(), 0);

    manager.restrictToRange(1, 10);

    QVERIFY(qApp->notify(&view, &event));

    if (spy.count() != 1)
        QTRY_COMPARE(spy.count(), 1);
}
开发者ID:daodaoliang,项目名称:qt-creator,代码行数:50,代码来源:flamegraphview_test.cpp


示例11: QFETCH

void tst_QColumnView::parentCurrentIndex()
{
    QFETCH(int, firstRow);
    QFETCH(int, secondRow);

    ColumnView view;
    TreeModel model;
    view.setModel(&model);
    view.show();

    QModelIndex first;
    QModelIndex second;
    QModelIndex third;
    first = model.index(0, 0, QModelIndex());
    second = model.index(firstRow, 0, first);
    third = model.index(0, 0, second);
    QVERIFY(first.isValid());
    QVERIFY(second.isValid());
    QVERIFY(third.isValid());
    view.setCurrentIndex(third);
    QTest::qWait(ANIMATION_DELAY);
    QCOMPARE(view.createdColumns[0]->currentIndex(), first);
    QCOMPARE(view.createdColumns[1]->currentIndex(), second);
    QCOMPARE(view.createdColumns[2]->currentIndex(), third);

    first = model.index(0, 0, QModelIndex());
    second = model.index(secondRow, 0, first);
    third = model.index(0, 0, second);
    QVERIFY(first.isValid());
    QVERIFY(second.isValid());
    QVERIFY(third.isValid());
    view.setCurrentIndex(third);
    QTest::qWait(ANIMATION_DELAY);
    QTRY_COMPARE(view.createdColumns[0]->currentIndex(), first);
    QTRY_COMPARE(view.createdColumns[1]->currentIndex(), second);
    QTRY_COMPARE(view.createdColumns[2]->currentIndex(), third);
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:37,代码来源:tst_qcolumnview.cpp


示例12: QQuickView

void tst_qquickspritesequence::test_framerateAdvance()
{
    QQuickView *window = new QQuickView(0);

    window->setSource(testFileUrl("advance.qml"));
    window->show();
    QVERIFY(QTest::qWaitForWindowExposed(window));

    QVERIFY(window->rootObject());
    QQuickSpriteSequence* sprite = window->rootObject()->findChild<QQuickSpriteSequence*>("sprite");
    QVERIFY(sprite);

    QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState"));
    delete window;
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:15,代码来源:tst_qquickspritesequence.cpp


示例13: QSKIP

void tst_QCameraBackend::testExposureMode()
{
#if !defined(Q_WS_MAEMO_6)
    QSKIP("Capture exposure parameters are supported only on mobile platforms");
#endif

    QCamera camera;
    QCameraExposure *exposure = camera.exposure();

#ifdef Q_WS_MAEMO_6
    QEXPECT_FAIL("", "Camerabin reports Manual exposure instead of Auto", Continue);
#endif
    QCOMPARE(exposure->exposureMode(), QCameraExposure::ExposureAuto);

    // Night
    exposure->setExposureMode(QCameraExposure::ExposureNight);
    QCOMPARE(exposure->exposureMode(), QCameraExposure::ExposureNight);
    camera.start();
    QTRY_COMPARE(camera.status(), QCamera::ActiveStatus);
    QCOMPARE(exposure->exposureMode(), QCameraExposure::ExposureNight);

    camera.unload();
    QTRY_COMPARE(camera.status(), QCamera::UnloadedStatus);

#ifdef Q_WS_MAEMO_6
    //resource policy doesn't work correctly when resource is released and immediately requested again.
    QTest::qWait(250);
#endif

    // Auto
    exposure->setExposureMode(QCameraExposure::ExposureAuto);
    QCOMPARE(exposure->exposureMode(), QCameraExposure::ExposureAuto);
    camera.start();
    QTRY_COMPARE(camera.status(), QCamera::ActiveStatus);
    QCOMPARE(exposure->exposureMode(), QCameraExposure::ExposureAuto);
}
开发者ID:Elleo,项目名称:qtmultimedia,代码行数:36,代码来源:tst_qcamerabackend.cpp


示例14: testQOfonoNetworkOperator

    void testQOfonoNetworkOperator()
    {
        QSignalSpy scanFinished(m, SIGNAL(scanFinished()));
        QSignalSpy networkOperatorsChanged(m, SIGNAL(networkOperatorsChanged(QStringList)));
        m->scan();
        QTRY_COMPARE(scanFinished.count(), 1);
        scanFinished.takeFirst();
        QTRY_COMPARE(networkOperatorsChanged.count(), 1);
        QStringList opIdList = networkOperatorsChanged.takeFirst().at(0).toStringList();
        QVERIFY(opIdList.count() > 0);

        int op1 = -1;
        int op2 = -1;
        QList<QOfonoNetworkOperator *> opList;
        foreach(QString opId, opIdList)
        {
            QOfonoNetworkOperator *op = new QOfonoNetworkOperator(this);
            op->setOperatorPath(opId);
            opList << op;
            if (op1 == -1 && op->status() == "current")
                op1 = opIdList.indexOf(opId);
            if (op2 == -1 && op->status() == "available")
                op2 = opIdList.indexOf(opId);
        }
开发者ID:amccarthy,项目名称:libqofono,代码行数:24,代码来源:tst_qofononetworkoperator.cpp


示例15: c

//QTBUG-18362
void tst_qdeclarativebehaviors::delayedRegistration()
{
    QDeclarativeEngine engine;

    QDeclarativeComponent c(&engine, SRCDIR "/data/delayedRegistration.qml");
    QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
    QVERIFY(rect != 0);

    QDeclarativeItem *innerRect = rect->property("myItem").value<QDeclarativeItem*>();
    QVERIFY(innerRect != 0);

    QCOMPARE(innerRect->property("x").toInt(), int(0));

    QTRY_COMPARE(innerRect->property("x").toInt(), int(100));
}
开发者ID:Blizzard,项目名称:qt4,代码行数:16,代码来源:tst_qdeclarativebehaviors.cpp


示例16: QFETCH

void tst_QKeySequenceEdit::testKeys()
{
    QFETCH(Qt::Key, key);
    QFETCH(Qt::KeyboardModifiers, modifiers);
    QFETCH(QKeySequence, keySequence);
    QKeySequenceEdit edit;

    QSignalSpy spy(&edit, SIGNAL(editingFinished()));
    QTest::keyPress(&edit, key, modifiers);
    QTest::keyRelease(&edit, key, modifiers);

    QCOMPARE(spy.count(), 0);
    QCOMPARE(edit.keySequence(), keySequence);
    QTRY_COMPARE(spy.count(), 1);
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:15,代码来源:tst_qkeysequenceedit.cpp


示例17: triggerAction

void TestGui::testDatabaseSettings()
{
    triggerAction("actionChangeDatabaseSettings");
    QWidget* dbSettingsWidget = m_dbWidget->findChild<QWidget*>("databaseSettingsWidget");
    QSpinBox* transformRoundsSpinBox = dbSettingsWidget->findChild<QSpinBox*>("transformRoundsSpinBox");
    transformRoundsSpinBox->setValue(100);
    QTest::keyClick(transformRoundsSpinBox, Qt::Key_Enter);
    // wait for modified timer
    QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save*"));
    QCOMPARE(m_db->transformRounds(), Q_UINT64_C(100));

    triggerAction("actionDatabaseSave");
    QCOMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save"));

    checkDatabase();
}
开发者ID:debfx,项目名称:keepassx,代码行数:16,代码来源:TestGui.cpp


示例18: dynamicPropertyAnimation

 void dynamicPropertyAnimation(const QByteArray & propertyName, T toValue)
 {
     QQuickView view(testFileUrl("MyItem.qml"));
     QQuickItem * item = qobject_cast<QQuickItem *>(view.rootObject());
     QVERIFY(item);
     QQmlProperty testProp(item, propertyName);
     QPropertyAnimation animation(item, propertyName, this);
     animation.setEndValue(toValue);
     QVERIFY(animation.targetObject() == item);
     QVERIFY(animation.propertyName() == propertyName);
     QVERIFY(animation.endValue().value<T>() == toValue);
     animation.start();
     QVERIFY(animation.state() == QAbstractAnimation::Running);
     QTest::qWait(animation.duration());
     QTRY_COMPARE(testProp.read().value<T>(), toValue);
 }
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:16,代码来源:tst_qquickdynamicpropertyanimation.cpp


示例19: QAction

void tst_QMenu::overrideMenuAction()
{
	//test the override menu action by first creating an action to which we set its menu
	QMainWindow w;

	QAction *aFileMenu = new QAction("&File", &w);
	w.menuBar()->addAction(aFileMenu);

	QMenu *m = new QMenu(&w);
	QAction *menuaction = m->menuAction();
	connect(m, SIGNAL(triggered(QAction*)), SLOT(onActivated(QAction*)));
	aFileMenu->setMenu(m); //this sets the override menu action for the QMenu
    QCOMPARE(m->menuAction(), aFileMenu);

#ifdef Q_WS_MAC
    QSKIP("On Mac, we need to create native key events to test menu action activation", SkipAll);
#elif defined(Q_OS_WINCE)
    QSKIP("On Windows CE, we need to create native key events to test menu action activation", SkipAll);
#elif defined(Q_OS_SYMBIAN)
    QSKIP("On Symbian OS, we need to create native key events to test menu action activation", SkipAll);
#endif

    QAction *aQuit = new QAction("Quit", &w);
	aQuit->setShortcut(QKeySequence("Ctrl+X"));
	m->addAction(aQuit);

	w.show();
    QApplication::setActiveWindow(&w);
    w.setFocus();
    QTest::qWaitForWindowShown(&w);
    QTRY_VERIFY(w.hasFocus());

	//test of the action inside the menu
	QTest::keyClick(&w, Qt::Key_X, Qt::ControlModifier);
    QTRY_COMPARE(activated, aQuit);

	//test if the menu still pops out
	QTest::keyClick(&w, Qt::Key_F, Qt::AltModifier);
    QTRY_VERIFY(m->isVisible());

	delete aFileMenu;

	//after the deletion of the override menu action,
	//the menu should have its default menu action back
	QCOMPARE(m->menuAction(), menuaction);

}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:47,代码来源:tst_qmenu.cpp


示例20: QVERIFY

void TestCntActions::phonenumberCallSupport()
{
    QContact contact;
    
    //Add phonenumber to contact
    QContactPhoneNumber number;
    number.setSubTypes(QContactPhoneNumber::SubTypeMobile);
    number.setNumber("555111222");
    contact.saveDetail(&number);
    m_manager->saveContact(&contact);
    
    //verify that the contact has a phonenumber
    QList<QContactPhoneNumber> numberList = contact.details<QContactPhoneNumber>();
    QVERIFY(numberList.count() >  0);
    
    //get the actions
    QList<QContactActionDescriptor> actionDescriptors = contact.availableActions();
    QStringList actions;
    for (int i = 0;i < actionDescriptors.count();i++)
    {
        QString action = actionDescriptors.at(i).actionName();
        actions << action;
    }
    
    //verify that it includes the actiosn
    QVERIFY(actions.contains("call", Qt::CaseInsensitive));
    
    //verify that the action works
    QList<QContactActionDescriptor> callActionDescriptors = QContactAction::actionDescriptors("call", "symbian");
    QVERIFY(callActionDescriptors.count() == 1);
    QContactAction *callAction = QContactAction::action(callActionDescriptors.at(0));
    QVERIFY(callAction != 0);
    QContactAction::State state = callAction->state();
    QVERIFY(state != QContactAction::InactiveState);
    QVERIFY(callAction->isDetailSupported(numberList.at(0)) == true);
    QList<QContactDetail> supportedDetails = callAction->supportedDetails(contact);
    QVERIFY(supportedDetails.count() != 0);
    QVariantMap variantMap = callAction->metaData();
    QVERIFY(variantMap.count() == 0);
    variantMap = callAction->results();
    QVERIFY(variantMap.count() == 0);
    QSignalSpy spyCallAction(callAction, SIGNAL(stateChanged(QContactAction::State)));
    callAction->invokeAction(contact, numberList.at(0));
    callAction->invokeAction(contact);
    QTRY_COMPARE(spyCallAction.count(), 2); // make sure the signal was emitted exactly one time
    delete callAction;
}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:47,代码来源:mt_cntactions.cpp



注:本文中的QTRY_COMPARE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ QTSCRIPT_IS_GENERATED_FUNCTION函数代码示例发布时间:2022-05-30
下一篇:
C++ QTEST_ASSERT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap