本文整理汇总了C++中QTRY_COMPARE函数的典型用法代码示例。如果您正苦于以下问题:C++ QTRY_COMPARE函数的具体用法?C++ QTRY_COMPARE怎么用?C++ QTRY_COMPARE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QTRY_COMPARE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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"))));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
}
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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));
}