本文整理汇总了C++中QVERIFY函数的典型用法代码示例。如果您正苦于以下问题:C++ QVERIFY函数的具体用法?C++ QVERIFY怎么用?C++ QVERIFY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QVERIFY函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ChooseEditorDelegate
void tst_QItemDelegate::dateAndTimeEditorTest2()
{
// prepare createeditor
FastEditItemView w;
QStandardItemModel s;
s.setRowCount(2);
s.setColumnCount(1);
w.setModel(&s);
ChooseEditorDelegate *d = new ChooseEditorDelegate(&w);
w.setItemDelegate(d);
const QTime time1(3, 13, 37);
const QDate date1(2013, 3, 7);
QPointer<QTimeEdit> timeEdit;
QPointer<QDateEdit> dateEdit;
QPointer<QDateTimeEdit> dateTimeEdit;
// Do some checks
// a. Open time editor on empty cell + write QTime data
const QModelIndex i1 = s.index(0, 0);
timeEdit = new QTimeEdit();
d->setNextOpenEditor(timeEdit);
QCOMPARE(w.fastEdit(i1), timeEdit.data());
timeEdit->setTime(time1);
d->setModelData(timeEdit, &s, i1);
QCOMPARE(s.data(i1).type(), QVariant::Time); // ensure that we wrote a time variant.
QCOMPARE(s.data(i1).toTime(), time1); // ensure that it is the correct time.
w.doCloseEditor(timeEdit);
QVERIFY(d->currentEditor() == 0); // should happen at doCloseEditor. We only test this once.
// b. Test that automatic edit of a QTime value is QTimeEdit (and not QDateTimeEdit)
QWidget *editor = w.fastEdit(i1);
timeEdit = qobject_cast<QTimeEdit*>(editor);
QVERIFY(timeEdit);
QCOMPARE(timeEdit->time(), time1);
w.doCloseEditor(timeEdit);
const QTime time2(4, 14, 37);
const QDate date2(2014, 4, 7);
const QDateTime datetime1(date1, time1);
const QDateTime datetime2(date2, time2);
// c. Test that the automatic open of an QDateTime is QDateTimeEdit + value check + set check
s.setData(i1, datetime2);
editor = w.fastEdit(i1);
timeEdit = qobject_cast<QTimeEdit*>(editor);
QVERIFY(timeEdit == 0);
dateEdit = qobject_cast<QDateEdit*>(editor);
QVERIFY(dateEdit == 0);
dateTimeEdit = qobject_cast<QDateTimeEdit*>(editor);
QVERIFY(dateTimeEdit);
QCOMPARE(dateTimeEdit->dateTime(), datetime2);
dateTimeEdit->setDateTime(datetime1);
d->setModelData(dateTimeEdit, &s, i1);
QCOMPARE(s.data(i1).type(), QVariant::DateTime); // ensure that we wrote a datetime variant.
QCOMPARE(s.data(i1).toDateTime(), datetime1);
w.doCloseEditor(dateTimeEdit);
// d. Open date editor on empty cell + write QDate data (similar to a)
const QModelIndex i2 = s.index(1, 0);
dateEdit = new QDateEdit();
d->setNextOpenEditor(dateEdit);
QCOMPARE(w.fastEdit(i2), dateEdit.data());
dateEdit->setDate(date1);
d->setModelData(dateEdit, &s, i2);
QCOMPARE(s.data(i2).type(), QVariant::Date); // ensure that we wrote a time variant.
QCOMPARE(s.data(i2).toDate(), date1); // ensure that it is the correct date.
w.doCloseEditor(dateEdit);
// e. Test that the default editor editor (QDateEdit) on a QDate (index i2) (similar to b)
editor = w.fastEdit(i2);
dateEdit = qobject_cast<QDateEdit*>(editor);
QVERIFY(dateEdit);
QCOMPARE(dateEdit->date(), date1);
w.doCloseEditor(dateEdit);
}
开发者ID:crobertd,项目名称:qtbase,代码行数:76,代码来源:tst_qitemdelegate.cpp
示例2: app
void tst_QGuiApplication::focusObject()
{
int argc = 0;
QGuiApplication app(argc, 0);
if (qApp->platformName().toLower() == QLatin1String("wayland"))
QSKIP("Wayland: This fails. Figure out why.");
QObject obj1, obj2, obj3;
const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry();
DummyWindow window1;
#if defined(Q_OS_QNX)
window1.setSurfaceType(QSurface::OpenGLSurface);
#endif
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();
#if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store
// and then post the window in order for screen to show the window
QOpenGLContext context;
context.create();
context.makeCurrent(&window1);
QTest::qWaitForWindowExposed(&window1); // Buffer swap only succeeds with exposed window
context.swapBuffers(&window1);
#endif
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:oneywang,项目名称:qtbase,代码行数:66,代码来源:tst_qguiapplication.cpp
示例3: pool
void tst_QMallocPool::testShared()
{
const unsigned int poolLength = 1024 * 1024;
char *poolBase = new char[poolLength];
for (unsigned int i = 0; i < poolLength; ++i)
poolBase[i] = 'X';
QMallocPool pool(poolBase, poolLength, QMallocPool::NewShared);
QMallocPool pool2(poolBase, poolLength, QMallocPool::Shared);
QVERIFY(pool.isValid());
QVERIFY(pool2.isValid());
void *alloc;
// test malloc
alloc = pool.malloc(1024);
QVERIFY(alloc != 0);
QVERIFY(pool.size_of(alloc) >= 1024);
QVERIFY(pool.size_of(alloc) == pool2.size_of(alloc));
pool.free(alloc);
// test malloc of poolLength, should fail.
alloc = pool.malloc(poolLength);
QVERIFY(alloc == 0);
// test malloc of poolLength + 1, should fail.
alloc = pool.malloc(poolLength + 1);
QVERIFY(alloc == 0);
// test calloc
alloc = pool.calloc(1024, sizeof(char));
QVERIFY(alloc != 0);
QVERIFY(pool.size_of(alloc) >= 1024);
QVERIFY(pool.size_of(alloc) == pool2.size_of(alloc));
for (int i = 0; i < 1024; ++i)
QVERIFY(reinterpret_cast<char *>(alloc)[i] == '\0');
pool.free(alloc);
// test realloc
alloc = pool.malloc(1024);
QVERIFY(alloc != 0);
QVERIFY(pool.size_of(alloc) >= 1024);
QVERIFY(pool.size_of(alloc) == pool2.size_of(alloc));
alloc = pool.realloc(alloc, 2048);
QVERIFY(alloc != 0);
QVERIFY(pool.size_of(alloc) >= 2048);
QVERIFY(pool.size_of(alloc) == pool2.size_of(alloc));
pool.free(alloc);
delete[] poolBase;
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:52,代码来源:tst_qmallocpool.cpp
示例4: QVERIFY
void ut_metadata::testCityIptc()
{
QVERIFY(iptc->isValid());
QCOMPARE(iptc->entry(QuillMetadata::Tag_City).toString(),
QString("Tapiola"));
}
开发者ID:martinjones,项目名称:quillmetadata,代码行数:6,代码来源:ut_metadata.cpp
示例5: out
void TestCsvParser::testSeparator()
{
parser->setFieldSeparator('\t');
QTextStream out(file.data());
out << "\t\t2\r\t2\t3\n"
<< "A\t\tB\"\n"
<< " \t\t\n";
QVERIFY(parser->parse(file.data()));
t = parser->getCsvTable();
QVERIFY(t.size() == 4);
QVERIFY(t.at(0).at(0) == "");
QVERIFY(t.at(0).at(1) == "");
QVERIFY(t.at(0).at(2) == "2");
QVERIFY(t.at(1).at(0) == "");
QVERIFY(t.at(1).at(1) == "2");
QVERIFY(t.at(1).at(2) == "3");
QVERIFY(t.at(2).at(0) == "A");
QVERIFY(t.at(2).at(1) == "");
QVERIFY(t.at(2).at(2) == "B\"");
QVERIFY(t.at(3).at(0) == " ");
QVERIFY(t.at(3).at(1) == "");
QVERIFY(t.at(3).at(2) == "");
}
开发者ID:droidmonkey,项目名称:keepassx_http,代码行数:23,代码来源:TestCsvParser.cpp
示例6: QVERIFY
void TestCsvParser::testEmptyFile()
{
QVERIFY(parser->parse(file.data()));
t = parser->getCsvTable();
QVERIFY(t.size() == 0);
}
开发者ID:droidmonkey,项目名称:keepassx_http,代码行数:6,代码来源:TestCsvParser.cpp
示例7: QVERIFY
void TestGrayscaleFilter::testGetName() {
QVERIFY(filter_.getName()==Model::GrayscaleFilter::FILTERNAME);
}
开发者ID:SuppenGeist,项目名称:pse-ws1516-videoencoder-ta,代码行数:3,代码来源:testgrayscalefilter.cpp
示例8: QVERIFY
void MasterTimer_Test::registerUnregisterDMXSource()
{
MasterTimer* mt = m_doc->masterTimer();
QVERIFY(mt->m_dmxSourceList.size() == 0);
DMXSource_Stub s1;
/* Normal registration */
mt->registerDMXSource(&s1, "a1");
QVERIFY(mt->m_dmxSourceList.size() == 1);
QVERIFY(mt->m_dmxSourceList.at(0) == &s1);
/* No double additions */
mt->registerDMXSource(&s1, "s1");
QVERIFY(mt->m_dmxSourceList.size() == 1);
QVERIFY(mt->m_dmxSourceList.at(0) == &s1);
DMXSource_Stub s2;
/* Normal registration of another source */
mt->registerDMXSource(&s2, "s2");
QVERIFY(mt->m_dmxSourceList.size() == 2);
QVERIFY(mt->m_dmxSourceList.at(0) == &s1);
QVERIFY(mt->m_dmxSourceList.at(1) == &s2);
/* No double additions */
mt->registerDMXSource(&s2, "s2");
QVERIFY(mt->m_dmxSourceList.size() == 2);
QVERIFY(mt->m_dmxSourceList.at(0) == &s1);
QVERIFY(mt->m_dmxSourceList.at(1) == &s2);
/* No double additions */
mt->registerDMXSource(&s1, "s1");
QVERIFY(mt->m_dmxSourceList.size() == 2);
QVERIFY(mt->m_dmxSourceList.at(0) == &s1);
QVERIFY(mt->m_dmxSourceList.at(1) == &s2);
/* Removal of a source */
mt->unregisterDMXSource(&s1);
QVERIFY(mt->m_dmxSourceList.size() == 1);
QVERIFY(mt->m_dmxSourceList.at(0) == &s2);
/* No double removals */
mt->unregisterDMXSource(&s1);
QVERIFY(mt->m_dmxSourceList.size() == 1);
QVERIFY(mt->m_dmxSourceList.at(0) == &s2);
/* Removal of the last source */
mt->unregisterDMXSource(&s2);
QVERIFY(mt->m_dmxSourceList.size() == 0);
}
开发者ID:PML369,项目名称:qlcplus,代码行数:49,代码来源:mastertimer_test.cpp
示例9: component
void tst_QQuickAccessible::quickAttachedProperties()
{
{
QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import QtQuick 2.0\nItem {\n"
"}", QUrl());
QObject *object = component.create();
QVERIFY(object != 0);
QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
QCOMPARE(attachedObject, static_cast<QObject*>(0));
delete object;
}
// Attached property
{
QObject parent;
QQuickAccessibleAttached *attachedObj = new QQuickAccessibleAttached(&parent);
attachedObj->name();
QVariant pp = attachedObj->property("name");
QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import QtQuick 2.0\nItem {\n"
"Accessible.role: Accessible.Button\n"
"}", QUrl());
QObject *object = component.create();
QVERIFY(object != 0);
QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
QVERIFY(attachedObject);
if (attachedObject) {
QVariant p = attachedObject->property("role");
QCOMPARE(p.isNull(), false);
QCOMPARE(p.toInt(), int(QAccessible::PushButton));
p = attachedObject->property("name");
QCOMPARE(p.isNull(), true);
p = attachedObject->property("description");
QCOMPARE(p.isNull(), true);
}
delete object;
}
// Attached property
{
QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import QtQuick 2.0\nItem {\n"
"Accessible.role: Accessible.Button\n"
"Accessible.name: \"Donald\"\n"
"Accessible.description: \"Duck\"\n"
"}", QUrl());
QObject *object = component.create();
QVERIFY(object != 0);
QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
QVERIFY(attachedObject);
if (attachedObject) {
QVariant p = attachedObject->property("role");
QCOMPARE(p.isNull(), false);
QCOMPARE(p.toInt(), int(QAccessible::PushButton));
p = attachedObject->property("name");
QCOMPARE(p.isNull(), false);
QCOMPARE(p.toString(), QLatin1String("Donald"));
p = attachedObject->property("description");
QCOMPARE(p.isNull(), false);
QCOMPARE(p.toString(), QLatin1String("Duck"));
}
delete object;
}
QTestAccessibility::clearEvents();
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:74,代码来源:tst_qquickaccessible.cpp
示例10: window
void tst_QQuickAccessible::checkableTest()
{
QScopedPointer<QQuickView> window(new QQuickView());
window->setSource(testFileUrl("checkbuttons.qml"));
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window.data()));
QQuickItem *contentItem = window->contentItem();
QVERIFY(contentItem);
QQuickItem *rootItem = contentItem->childItems().first();
QVERIFY(rootItem);
// the window becomes active
QAccessible::State activatedChange;
activatedChange.active = true;
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(window.data());
QVERIFY(iface);
QAccessibleInterface *root = iface->child(0);
QAccessibleInterface *button1 = root->child(0);
QCOMPARE(button1->role(), QAccessible::Button);
QVERIFY(!(button1->state().checked));
QVERIFY(!(button1->state().checkable));
QVERIFY(button1->state().focusable);
QVERIFY(!button1->state().focused);
QTestAccessibility::clearEvents();
// set properties
QQuickItem *button1item = qobject_cast<QQuickItem*>(rootItem->childItems().at(0));
QVERIFY(button1item);
QCOMPARE(button1item->objectName(), QLatin1String("button1"));
button1item->forceActiveFocus();
QVERIFY(button1->state().focusable);
QVERIFY(button1->state().focused);
QAccessibleEvent focusEvent(button1item, QAccessible::Focus);
QVERIFY_EVENT(&focusEvent);
QAccessibleInterface *button2 = root->child(1);
QVERIFY(!(button2->state().checked));
QVERIFY(button2->state().checkable);
QQuickItem *button2item = qobject_cast<QQuickItem*>(rootItem->childItems().at(1));
QVERIFY(button2item);
QCOMPARE(button2item->objectName(), QLatin1String("button2"));
QAccessibleInterface *button3 = root->child(2);
QVERIFY(button3->state().checked);
QVERIFY(button3->state().checkable);
QAccessibleInterface *checkBox1 = root->child(3);
QCOMPARE(checkBox1->role(), QAccessible::CheckBox);
QVERIFY(checkBox1->state().checked);
QVERIFY(checkBox1->state().checkable);
QQuickItem *checkbox1item = qobject_cast<QQuickItem*>(rootItem->childItems().at(3));
QVERIFY(checkbox1item);
QCOMPARE(checkbox1item->objectName(), QLatin1String("checkbox1"));
checkbox1item->setProperty("checked", false);
QVERIFY(!checkBox1->state().checked);
QAccessible::State checkState;
checkState.checked = true;
QAccessibleStateChangeEvent checkChanged(checkbox1item, checkState);
QVERIFY_EVENT(&checkChanged);
checkbox1item->setProperty("checked", true);
QVERIFY(checkBox1->state().checked);
QVERIFY_EVENT(&checkChanged);
QAccessibleInterface *checkBox2 = root->child(4);
QVERIFY(!(checkBox2->state().checked));
QVERIFY(checkBox2->state().checkable);
QTestAccessibility::clearEvents();
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:78,代码来源:tst_qquickaccessible.cpp
示例11: QVERIFY
void TestEnum::state()
{
QVERIFY(COLOR::info().findByValue(COLOR::RED)->state() == QtnEnumValueStateNone);
QVERIFY(COLOR::info().findByValue(COLOR::BLUE)->state() == (QtnEnumValueStateHidden | QtnEnumValueStateObsolete));
}
开发者ID:gray-z,项目名称:QtnProperty,代码行数:5,代码来源:TestEnum.cpp
示例12: QVERIFY
void tst_QGuiApplication::cleanup()
{
QVERIFY(QGuiApplication::allWindows().isEmpty());
}
开发者ID:oneywang,项目名称:qtbase,代码行数:4,代码来源:tst_qguiapplication.cpp
示例13: QVERIFY
void tst_QMallocPool::testConstructor()
{
{
QMallocPool invalidPool;
QVERIFY(!invalidPool.isValid());
}
{
QMallocPool invalidPool(0, 0, QMallocPool::NewShared);
QVERIFY(!invalidPool.isValid());
}
{
QMallocPool invalidPool(0, 0, QMallocPool::Shared);
QVERIFY(!invalidPool.isValid());
}
{
const unsigned int poolLength = 1024 * 1024;
char *poolBase = new char[poolLength];
for (unsigned int i = 0; i < poolLength; ++i)
poolBase[i] = 'X';
QMallocPool pool(poolBase, poolLength, QMallocPool::Owned);
QVERIFY(pool.isValid());
void *alloc;
// test malloc
alloc = pool.malloc(1024);
QVERIFY(alloc != 0);
QVERIFY(pool.size_of(alloc) >= 1024);
QVERIFY(pool.memoryStatistics().inuseBytes >= 1024);
pool.free(alloc);
QVERIFY(pool.memoryStatistics().inuseBytes == 0);
// test malloc of poolLength, should fail.
alloc = pool.malloc(poolLength);
QVERIFY(alloc == 0);
QVERIFY(pool.memoryStatistics().inuseBytes == 0);
// test malloc of poolLength + 1, should fail.
alloc = pool.malloc(poolLength + 1);
QVERIFY(alloc == 0);
QVERIFY(pool.memoryStatistics().inuseBytes == 0);
// test calloc
alloc = pool.calloc(1024, sizeof(char));
QVERIFY(alloc != 0);
QVERIFY(pool.size_of(alloc) >= 1024);
QVERIFY(pool.memoryStatistics().inuseBytes >= 1024);
for (int i = 0; i < 1024; ++i)
QVERIFY(reinterpret_cast<char *>(alloc)[i] == '\0');
pool.free(alloc);
QVERIFY(pool.memoryStatistics().inuseBytes == 0);
// test realloc
alloc = pool.malloc(1024);
QVERIFY(alloc != 0);
QVERIFY(pool.size_of(alloc) >= 1024);
QVERIFY(pool.memoryStatistics().inuseBytes >= 1024);
alloc = pool.realloc(alloc, 2048);
QVERIFY(alloc != 0);
QVERIFY(pool.size_of(alloc) >= 2048);
QVERIFY(pool.memoryStatistics().inuseBytes >= 2048);
pool.free(alloc);
QVERIFY(pool.memoryStatistics().inuseBytes == 0);
delete[] poolBase;
}
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:72,代码来源:tst_qmallocpool.cpp
示例14: QFETCH
void tst_QItemDelegate::dateTimeEditor()
{
QFETCH(QTime, time);
QFETCH(QDate, date);
QTableWidgetItem *item1 = new QTableWidgetItem;
item1->setData(Qt::DisplayRole, time);
QTableWidgetItem *item2 = new QTableWidgetItem;
item2->setData(Qt::DisplayRole, date);
QTableWidgetItem *item3 = new QTableWidgetItem;
item3->setData(Qt::DisplayRole, QDateTime(date, time));
QTableWidget widget(1, 3);
widget.setItem(0, 0, item1);
widget.setItem(0, 1, item2);
widget.setItem(0, 2, item3);
widget.show();
widget.editItem(item1);
QTestEventLoop::instance().enterLoop(1);
QTimeEdit *timeEditor = qFindChild<QTimeEdit *>(widget.viewport());
QVERIFY(timeEditor);
QCOMPARE(timeEditor->time(), time);
// The data must actually be different in order for the model
// to be updated.
timeEditor->setTime(time.addSecs(60));
widget.clearFocus();
qApp->setActiveWindow(&widget);
widget.setFocus();
widget.editItem(item2);
QTestEventLoop::instance().enterLoop(1);
QDateEdit *dateEditor = qFindChild<QDateEdit *>(widget.viewport());
QVERIFY(dateEditor);
QCOMPARE(dateEditor->date(), date);
dateEditor->setDate(date.addDays(60));
widget.clearFocus();
widget.setFocus();
widget.editItem(item3);
QTestEventLoop::instance().enterLoop(1);
QList<QDateTimeEdit *> dateTimeEditors = widget.findChildren<QDateTimeEdit *>();
QDateTimeEdit *dateTimeEditor = 0;
foreach(dateTimeEditor, dateTimeEditors)
if (dateTimeEditor->metaObject()->className() == QLatin1String("QDateTimeEdit"))
break;
QVERIFY(dateTimeEditor);
QCOMPARE(dateTimeEditor->date(), date);
QCOMPARE(dateTimeEditor->time(), time);
dateTimeEditor->setTime(time.addSecs(600));
widget.clearFocus();
QVERIFY(item1->data(Qt::EditRole).userType() == QMetaType::QTime);
QVERIFY(item2->data(Qt::EditRole).userType() == QMetaType::QDate);
QVERIFY(item3->data(Qt::EditRole).userType() == QMetaType::QDateTime);
}
开发者ID:crobertd,项目名称:qtbase,代码行数:64,代码来源:tst_qitemdelegate.cpp
注:本文中的QVERIFY函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论