本文整理汇总了C++中QVERIFY2函数的典型用法代码示例。如果您正苦于以下问题:C++ QVERIFY2函数的具体用法?C++ QVERIFY2怎么用?C++ QVERIFY2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QVERIFY2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QCOMPARE
void QtQuickSampleApplicationTest::myCalculatorViewModelOperationTest()
{
// Setup the test
MyCalculatorViewModelTest model;
QCOMPARE( model.getOperation(), 0 ); //Expect the operation to be 'None' by default
MyCalculatorViewModel::MyCalculator_Operation expect( MyCalculatorViewModel::MyCalculator_Operation::MyCalculator_Operation_Addition );
model.injectOperation( expect );
// Test - we're actually testing both the set and get method here, not as isolated as I would like but ok for what it is.
int actual = model.getOperation();
QVERIFY2( actual == (int)expect,
QString("Expect the result value to be [%1] but actually got [%2] instead.").arg(expect).arg(actual).toStdString().c_str());
}
示例2: QVERIFY
void ctkMTAttrPasswordTestSuite::testAttributeTypePassword1()
{
ctkMetaTypeInformationPtr mti = mts->getMetaTypeInformation(plugin);
ctkObjectClassDefinitionPtr ocd = mti->getObjectClassDefinition("org.commontk.metatype.tests.attrpwd");
QVERIFY(ocd);
QList<ctkAttributeDefinitionPtr> ads = ocd->getAttributeDefinitions(ctkObjectClassDefinition::ALL);
for (int i = 0; i < ads.size(); i++)
{
if (ads[i]->getID() == "password1")
{
QVERIFY2(ctkAttributeDefinition::PASSWORD == ads[i]->getType(),
"Attribute type is not PASSWORD");
}
}
}
示例3: QSKIP
void tst_QDirModel::unreadable()
{
#ifndef Q_OS_UNIX
QSKIP("Test not implemented on non-Unixes");
#else
// Create an empty file which has no read permissions (file will be removed by cleanup()).
QFile unreadableFile(QDir::currentPath() + "qtest_unreadable");
QVERIFY2(unreadableFile.open(QIODevice::WriteOnly | QIODevice::Text), qPrintable(unreadableFile.errorString()));
unreadableFile.close();
QVERIFY(unreadableFile.exists());
QVERIFY2(unreadableFile.setPermissions(QFile::WriteOwner), qPrintable(unreadableFile.errorString()));
// Check that we can't make a valid model index from an unreadable file.
QDirModel model;
QModelIndex index = model.index(QDir::currentPath() + "/qtest_unreadable");
QVERIFY(!index.isValid());
// Check that unreadable files are not treated like hidden files.
QDirModel model2;
model2.setFilter(model2.filter() | QDir::Hidden);
index = model2.index(QDir::currentPath() + "/qtest_unreadable");
QVERIFY(!index.isValid());
#endif
}
示例4: QVERIFY2
void ctkEAScenario3EventConsumer::runTest()
{
asynchMessages = 0;
synchMessages = 0;
/* create the hashtable to put properties in */
ctkDictionary props;
/* put service.pid property in hashtable */
props.insert(ctkEventConstants::EVENT_TOPIC, topicsToConsume);
/* register the service */
serviceRegistration = context->registerService<ctkEventHandler>(this, props);
QVERIFY2(serviceRegistration, "service registration should not be null");
}
示例5: name
void ZippedBufferTests::basictTest()
{
QString name("toto.txt");
QByteArray data;
data.reserve(2);
data[0] = 'a';
data[1] = 'b';
ZippedBuffer zbw(name, data);
QTemporaryFile file;
QVERIFY2(file.open(), "Cannot create file");
QDataStream stream(&file);
zbw.write(stream);
file.close();
{
QFile read_file(file.fileName());
QDataStream read_stream(&read_file);
ZippedBuffer zbr;
QVERIFY2(read_file.open(QIODevice::ReadOnly), "Cannot read file");
zbr.read(read_stream);
QVERIFY2(zbw.get_filename() == zbr.get_filename(), "Filename not equal");
QVERIFY2(zbw.get_data() == zbr.get_data(), "Data not equal");
}
}
示例6: QFETCH
void tst_QLibrary::fileName()
{
QFETCH( QString, libName);
QFETCH( QString, expectedFilename);
QLibrary lib(libName);
bool ok = lib.load();
QVERIFY2(ok, qPrintable(lib.errorString()));
#if defined(Q_OS_WIN)
QCOMPARE(lib.fileName().toLower(), expectedFilename.toLower());
#else
QCOMPARE(lib.fileName(), expectedFilename);
#endif
QVERIFY(lib.unload());
}
示例7: QCOMPARE
void tst_QPauseAnimationJob::pauseResume()
{
TestablePauseAnimation animation;
animation.setDuration(400);
animation.start();
QCOMPARE(animation.state(), QAbstractAnimationJob::Running);
QTest::qWait(200);
animation.pause();
QCOMPARE(animation.state(), QAbstractAnimationJob::Paused);
animation.start();
QTest::qWait(300);
QTRY_VERIFY(animation.state() == QAbstractAnimationJob::Stopped);
QVERIFY2(animation.m_updateCurrentTimeCount >= 3,
QByteArrayLiteral("animation.m_updateCurrentTimeCount=") + QByteArray::number(animation.m_updateCurrentTimeCount));
}
示例8: locker
void ThreadedTestHTTPServer::run()
{
TestHTTPServer server;
{
QMutexLocker locker(&m_mutex);
QVERIFY2(server.listen(), qPrintable(server.errorString()));
m_port = server.port();
for (QHash<QString, TestHTTPServer::Mode>::ConstIterator i = m_dirs.constBegin();
i != m_dirs.constEnd(); ++i) {
server.serveDirectory(i.key(), i.value());
}
m_condition.wakeAll();
}
exec();
}
示例9: qDebug
void uiLoader::createBaseline()
{
// can't use ftpUploadFile() here
qDebug() << " ========== Uploading baseline of only the latest test values ";
QFtp ftp;
ftp.connectToHost( ftpHost );
ftp.login( ftpUser, ftpPass );
ftp.cd( ftpBaseDir );
QDir dir( output );
// Upload all the latest test results to the FTP server's baseline directory.
QHashIterator<QString, QString> i(enginesToTest);
while ( i.hasNext() ) {
i.next();
dir.cd( i.key() );
ftp.cd( i.key() + ".baseline" );
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
dir.setNameFilters( QStringList() << "*.png" );
QFileInfoList list = dir.entryInfoList();
dir.cd( ".." );
for (int n = 0; n < list.size(); n++) {
QFileInfo fileInfo = list.at( n );
QFile file( QString( output ) + "/" + i.key() + "/" + fileInfo.fileName() );
errorMsg = "could not open file " + fileInfo.fileName();
QVERIFY2( file.open(QIODevice::ReadOnly), qPrintable(errorMsg));
QByteArray fileData = file.readAll();
file.close();
ftp.put( fileData, fileInfo.fileName(), QFtp::Binary );
qDebug() << "\t(I) Uploading:" << fileInfo.fileName() << "with file size" << fileData.size();
}
ftp.cd( ".." );
}
ftp.close();
while ( ftp.hasPendingCommands() )
QCoreApplication::instance()->processEvents();
}
示例10: QSKIP
void tst_QWinJumpList::testRecent()
{
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10)
QSKIP("QTBUG-48751: Recent items do not work on Windows 10", Continue);
QScopedPointer<QWinJumpList> jumplist(new QWinJumpList);
QWinJumpListCategory *recent1 = jumplist->recent();
QVERIFY(recent1);
QVERIFY(!recent1->isVisible());
QVERIFY(recent1->title().isEmpty());
recent1->clear();
QVERIFY(recent1->isEmpty());
recent1->addItem(0);
QVERIFY(recent1->isEmpty());
recent1->setVisible(true);
QVERIFY(recent1->isVisible());
recent1->addLink(QStringLiteral("tst_QWinJumpList"), QCoreApplication::applicationFilePath());
QTest::ignoreMessage(QtWarningMsg, "QWinJumpListCategory::addItem(): only tasks/custom categories support separators.");
recent1->addSeparator();
QTest::ignoreMessage(QtWarningMsg, "QWinJumpListCategory::addItem(): only tasks/custom categories support destinations.");
recent1->addDestination(QCoreApplication::applicationDirPath());
// cleanup the first jumplist instance and give the system a little time to update.
// then test that another jumplist instance loads up the recent item(s) added above
jumplist.reset();
QTest::qWait(100);
jumplist.reset(new QWinJumpList);
QWinJumpListCategory *recent2 = jumplist->recent();
QVERIFY(recent2);
QCOMPARE(recent2->count(), 1);
QWinJumpListItem* item = recent2->items().value(0);
QVERIFY(item);
const QString itemPath = item->filePath();
const QString applicationFilePath = QCoreApplication::applicationFilePath();
QVERIFY2(!itemPath.compare(applicationFilePath, Qt::CaseInsensitive),
msgFileNameMismatch(itemPath, applicationFilePath));
QEXPECT_FAIL("", "QWinJumpListItem::title not supported for recent items", Continue);
QCOMPARE(item->title(), QStringLiteral("tst_QWinJumpList"));
recent2->clear();
QVERIFY(recent2->isEmpty());
}
示例11: while
void Test_Bone::testResolveDirection()
{
Bone bone;
bone.setLength(2.0);
bone.mPos[1]->setX(1.5f);
int sanity = 0;
while(!bone.resolve()) {
QVERIFY2(sanity < 100, "Bone never resolved.");
sanity++;
}
// QVERIFY2(bone.mPos[1]->x() > 1.99, "bone is facing wrong way");
}
示例12: QLatin1String
void KWalletExecuter::pamRead(const QString &value) const
{
QDBusMessage msg =
QDBusMessage::createMethodCall("org.kde.kwalletd", "/modules/kwalletd", "org.kde.KWallet", "readPassword");
QVariantList args;
args << m_handler
<< QLatin1String("Passwords")
<< QLatin1String("foo")
<< QLatin1String("buh");
msg.setArguments(args);
const QDBusMessage reply = QDBusConnection::sessionBus().call(msg);
QVERIFY2(reply.type() != QDBusMessage::ErrorMessage, reply.errorMessage().toLocal8Bit());
const QString password = reply.arguments().first().toString();
QCOMPARE(password, value);
}
示例13: testForceThemeForTests
void testForceThemeForTests()
{
auto forcedName = QStringLiteral("kitten");
auto resolvedCurrent = KIconTheme::current();
QVERIFY2(KIconTheme::current() != forcedName,
"current theme initially expected to not be mangled");
// Force a specific theme.
KIconTheme::forceThemeForTests(forcedName);
QCOMPARE(KIconTheme::current(), forcedName);
// Reset override.
KIconTheme::forceThemeForTests(QString());
QCOMPARE(KIconTheme::current(), resolvedCurrent);
// And then override again to make sure we still can.
KIconTheme::forceThemeForTests(forcedName);
QCOMPARE(KIconTheme::current(), forcedName);
}
示例14: connect
void tst_QTimer::remainingTime()
{
TimerHelper helper;
QTimer timer;
connect(&timer, SIGNAL(timeout()), &helper, SLOT(timeout()));
timer.start(200);
QCOMPARE(helper.count, 0);
QTest::qWait(50);
QCOMPARE(helper.count, 0);
int remainingTime = timer.remainingTime();
QVERIFY2(qAbs(remainingTime - 150) < 50, qPrintable(QString::number(remainingTime)));
}
示例15: QNativeMouseMoveEvent
void tst_MacNativeEvents::testMouseMoveLocation()
{
QWidget w;
w.setMouseTracking(true);
w.show();
QPoint p = w.geometry().center();
NativeEventList native;
native.append(new QNativeMouseMoveEvent(p, Qt::NoModifier));
ExpectedEventList expected(&w);
expected.append(new QMouseEvent(QEvent::MouseMove, w.mapFromGlobal(p), p, Qt::NoButton, Qt::NoButton, Qt::NoModifier));
native.play();
QVERIFY2(expected.waitForAllEvents(), "the test did not receive all expected events!");
}