Fix some compiler warnings in tests

- Signedness of integer comparison
- Unused parameters and variables
- Ignored return values of QTest::qWaitForWindowExposed() (nodiscard)
- float to int conversions

Change-Id: Ibece620d3c980a5af3b7717486c841d8072ed8af
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Friedemann Kleint 2019-07-12 13:17:02 +02:00
parent 392521048c
commit 83f8d886ce
11 changed files with 25 additions and 22 deletions

View File

@ -428,7 +428,7 @@ void tst_qqmlconnections::noAcceleratedGlobalLookup()
QVERIFY(c.isReady());
QScopedPointer<QObject> object(c.create());
const QVariant val = object->property("testEnum");
QCOMPARE(val.type(), QMetaType::Int);
QCOMPARE(val.type(), int(QMetaType::Int));
QCOMPARE(val.toInt(), int(Proxy::EnumValue));
}

View File

@ -99,7 +99,7 @@ public:
qmlRegisterModule(uri, 1, 0);
}
void initializeEngine(QQmlEngine *engine, const char *uri) override
void initializeEngine(QQmlEngine *, const char *) override
{
initializeEngineEntered.lock();
leavingInitializeEngine.lock();

View File

@ -385,9 +385,10 @@ bool tst_drawingmodes::isRunningOnRhi() const
decided = true;
QQuickView dummy;
dummy.show();
QTest::qWaitForWindowExposed(&dummy);
QSGRendererInterface::GraphicsApi api = dummy.rendererInterface()->graphicsApi();
retval = QSGRendererInterface::isApiRhiBased(api);
if (QTest::qWaitForWindowExposed(&dummy)) {
QSGRendererInterface::GraphicsApi api = dummy.rendererInterface()->graphicsApi();
retval = QSGRendererInterface::isApiRhiBased(api);
}
dummy.hide();
}
return retval;

View File

@ -136,7 +136,6 @@ void tst_MptaInterop::touchDrag()
// TODO touchesThenPinch_data with press/release sequences somehow: vectors of touchpoint IDs? or a string representation?
void tst_MptaInterop::touchesThenPinch()
{
const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
QScopedPointer<QQuickView> windowPtr;
createView(windowPtr, "pinchDragMPTA.qml");
QQuickView * window = windowPtr.data();

View File

@ -338,7 +338,7 @@ void tst_QQuickAccessible::basicPropertiesTest()
QCOMPARE(text2->rect().y(), item->rect().y() + 40);
QCOMPARE(text2->role(), QAccessible::StaticText);
QCOMPARE(item->indexOfChild(text2), 1);
QCOMPARE(text2->state().editable, 0);
QCOMPARE(text2->state().editable, 0u);
QCOMPARE(text2->state().readOnly, 1);
QCOMPARE(iface->indexOfChild(text2), -1);

View File

@ -59,6 +59,8 @@ int main(int argc, char **argv)
component.setData(qmltemplate, current);
window.setContent(current, &component, component.create());
window.show();
QTest::qWaitForWindowActive(&window);
if (!QTest::qWaitForWindowActive(&window))
return EXIT_FAILURE;
}
return 0;
}

View File

@ -1107,7 +1107,7 @@ class MyInterceptor : public QQmlAbstractUrlInterceptor
{
public:
MyInterceptor(QUrl url) : QQmlAbstractUrlInterceptor(), m_url(url) {}
QUrl intercept(const QUrl &url, QQmlAbstractUrlInterceptor::DataType type)
QUrl intercept(const QUrl &url, QQmlAbstractUrlInterceptor::DataType)
{
if (url.scheme() == "interceptthis")
return m_url;

View File

@ -669,7 +669,7 @@ public:
emit finished();
}
QQuickTextureFactory *textureFactory() const
QQuickTextureFactory *textureFactory() const override
{
QImage image(50, 50, QImage::Format_RGB32);
auto texture = QQuickTextureFactory::textureFactoryForImage(image);
@ -696,7 +696,7 @@ public:
~WaitingAsyncProvider() {}
QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize)
QQuickImageResponse *requestImageResponse(const QString & /* id */, const QSize & /* requestedSize */)
{
auto response = new WaitingAsyncImageResponse(m_providerRemovedMutex, m_providerRemovedCond, m_providerRemoved, m_imageRequestedMutex, m_imageRequestedCondition, m_imageRequested);
pool.start(response);

View File

@ -50,7 +50,6 @@
using namespace QQuickViewTestUtil;
using namespace QQuickVisualTestUtil;
static const char* kTableViewPropName = "tableView";
static const char* kDelegateObjectName = "tableViewDelegate";
static const char *kDelegatesCreatedCountProp = "delegatesCreatedCount";
static const char *kModelDataBindingProp = "modelDataBinding";

View File

@ -49,8 +49,7 @@ public:
view.setResizeMode(QQuickView::SizeViewToRootObject);
view.setSource(testFileUrl(fileName));
view.setVisible(true);
QTest::qWaitForWindowExposed(&view);
return view.grabWindow();
return QTest::qWaitForWindowExposed(&view) ? view.grabWindow() : QImage();
}
//It is important for platforms that only are able to show fullscreen windows
@ -225,6 +224,7 @@ void tst_rendernode::renderOrder()
QSKIP("Render nodes not yet supported with QRhi");
QImage fb = runTest("RenderOrder.qml");
QVERIFY(!fb.isNull());
const qreal scaleFactor = QGuiApplication::primaryScreen()->devicePixelRatio();
QCOMPARE(fb.width(), qRound(200 * scaleFactor));
@ -257,6 +257,7 @@ void tst_rendernode::messUpState()
QSKIP("Render nodes not yet supported with QRhi");
QImage fb = runTest("MessUpState.qml");
QVERIFY(!fb.isNull());
int x1 = 0;
int x2 = fb.width() / 2;
int x3 = fb.width() - 1;
@ -318,7 +319,7 @@ void tst_rendernode::matrix()
qmlRegisterType<StateRecordingRenderNodeItem>("RenderNode", 1, 0, "StateRecorder");
StateRecordingRenderNode::matrices.clear();
runTest("matrix.qml");
QVERIFY(!runTest("matrix.qml").isNull());
QMatrix4x4 noRotateOffset;
noRotateOffset.translate(20, 20);
@ -371,9 +372,10 @@ bool tst_rendernode::isRunningOnRhi() const
decided = true;
QQuickView dummy;
dummy.show();
QTest::qWaitForWindowExposed(&dummy);
QSGRendererInterface::GraphicsApi api = dummy.rendererInterface()->graphicsApi();
retval = QSGRendererInterface::isApiRhiBased(api);
if (QTest::qWaitForWindowExposed(&dummy)) {
QSGRendererInterface::GraphicsApi api = dummy.rendererInterface()->graphicsApi();
retval = QSGRendererInterface::isApiRhiBased(api);
}
dummy.hide();
}
return retval;

View File

@ -75,8 +75,8 @@ public:
delete node;
node = new QSGNode;
const int w = width();
const int h = height();
const int w = int(width());
const int h = int(height());
QQuickWindow *win = window();
for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) {
@ -569,8 +569,8 @@ bool tst_SceneGraph::isRunningOnOpenGLDirectly()
decided = true;
QQuickView dummy;
dummy.show();
QTest::qWaitForWindowExposed(&dummy);
retval = dummy.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL;
if (QTest::qWaitForWindowExposed(&dummy))
retval = dummy.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL;
dummy.hide();
}
return retval;