summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSergey Dubitskiy <sergey.dubitskiy@nokia.com>2012-06-19 11:56:26 +1000
committerQt by Nokia <qt-info@nokia.com>2012-06-22 05:41:42 +0200
commit8a31f9fed164eb9cab57bd75ed1c0c99d9b73854 (patch)
tree96995e6c961c4824025857d932fb59215eb00e55 /tests
parent32823026cbbffe059c540711dda51488c8049238 (diff)
(Partial) Work done on Coverity report.
Only partial because Coverity report is no longer accessible. Change-Id: Id7e1171bd9ab3c3900eaa771c04a8df2a1d7dabe Reviewed-by: Sarah Jane Smith <sarah.j.smith@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/threed/load_model/tst_load_model.cpp2
-rw-r--r--tests/auto/threed/qglmaterialcollection/tst_qglmaterialcollection.cpp70
-rw-r--r--tests/auto/threed/qgraphicstransform3d/tst_qgraphicstransform3d.cpp24
-rw-r--r--tests/shared/compareimage.cpp3
4 files changed, 51 insertions, 48 deletions
diff --git a/tests/auto/threed/load_model/tst_load_model.cpp b/tests/auto/threed/load_model/tst_load_model.cpp
index 02a261d80..240099578 100644
--- a/tests/auto/threed/load_model/tst_load_model.cpp
+++ b/tests/auto/threed/load_model/tst_load_model.cpp
@@ -220,10 +220,12 @@ void tst_LoadModel::create()
int r, g, b;
if (!materialName.isEmpty())
{
+ Q_ASSERT(foundMaterial);
foundMaterial->material()->diffuseColor().getRgb(&r, &g, &b);
QCOMPARE(materialDiffuse, qRgb(r, g, b));
}
+ Q_ASSERT(foundGeometry);
QGeometryData data = foundGeometry->geometry();
QVERIFY(data.count() > 0);
diff --git a/tests/auto/threed/qglmaterialcollection/tst_qglmaterialcollection.cpp b/tests/auto/threed/qglmaterialcollection/tst_qglmaterialcollection.cpp
index f41fe5626..1473f8ca9 100644
--- a/tests/auto/threed/qglmaterialcollection/tst_qglmaterialcollection.cpp
+++ b/tests/auto/threed/qglmaterialcollection/tst_qglmaterialcollection.cpp
@@ -94,47 +94,47 @@ void tst_QGLMaterialCollection::simple()
// Also acts as a torture test for the underlying data structures.
void tst_QGLMaterialCollection::addMaterial()
{
- QGLMaterialCollection *coll = new QGLMaterialCollection();
-
const int Size = 2048;
+ {
+ QScopedPointer<QGLMaterialCollection> coll( new QGLMaterialCollection() );
+ QScopedArrayPointer<QGLMaterial*> materials( new QGLMaterial* [Size] );
+ for (int index = 0; index < Size; ++index) {
+ QGLMaterial *mat = new QGLMaterial();
+ mat->setObjectName(QString::number(index));
+ connect(mat, SIGNAL(destroyed()), this, SLOT(materialDestroyed()));
+ materials[index] = mat;
+ QCOMPARE(coll->addMaterial(mat), index);
+ }
+ QCOMPARE(coll->size(), Size);
+ QVERIFY(!coll->isEmpty());
+
+ for (int index = 0; index < Size; ++index) {
+ QString name = QString::number(index);
+ QVERIFY(coll->material(index) == materials[index]);
+ QVERIFY(coll->material(name) == materials[index]);
+ QVERIFY(coll->contains(materials[index]));
+ QVERIFY(coll->contains(name));
+ QCOMPARE(coll->indexOf(materials[index]), index);
+ QCOMPARE(coll->indexOf(name), index);
+ QCOMPARE(coll->materialName(index), name);
+ }
- QGLMaterial **materials = new QGLMaterial *[Size];
- for (int index = 0; index < Size; ++index) {
QGLMaterial *mat = new QGLMaterial();
- mat->setObjectName(QString::number(index));
- connect(mat, SIGNAL(destroyed()), this, SLOT(materialDestroyed()));
- materials[index] = mat;
- QCOMPARE(coll->addMaterial(mat), index);
- }
- QCOMPARE(coll->size(), Size);
- QVERIFY(!coll->isEmpty());
- for (int index = 0; index < Size; ++index) {
- QString name = QString::number(index);
- QVERIFY(coll->material(index) == materials[index]);
- QVERIFY(coll->material(name) == materials[index]);
- QVERIFY(coll->contains(materials[index]));
- QVERIFY(coll->contains(name));
- QCOMPARE(coll->indexOf(materials[index]), index);
- QCOMPARE(coll->indexOf(name), index);
- QCOMPARE(coll->materialName(index), name);
- }
+ QVERIFY(!coll->material(-1));
+ QVERIFY(!coll->material(coll->size()));
+ QVERIFY(!coll->contains(0));
+ QVERIFY(!coll->contains(mat));
+ QVERIFY(!coll->contains(QLatin1String("foo")));
+ QCOMPARE(coll->indexOf(0), -1);
+ QCOMPARE(coll->indexOf(mat), -1);
+ QCOMPARE(coll->indexOf(QLatin1String("foo")), -1);
- QGLMaterial *mat = new QGLMaterial();
+ delete mat;
- QVERIFY(!coll->material(-1));
- QVERIFY(!coll->material(coll->size()));
- QVERIFY(!coll->contains(0));
- QVERIFY(!coll->contains(mat));
- QVERIFY(!coll->contains(QLatin1String("foo")));
- QCOMPARE(coll->indexOf(0), -1);
- QCOMPARE(coll->indexOf(mat), -1);
- QCOMPARE(coll->indexOf(QLatin1String("foo")), -1);
-
- delete mat;
-
- destroyCount = 0;
- delete coll;
+ destroyCount = 0;
+ // coll goes out of scope here; all materials will be destroyed.
+ }
QCOMPARE(destroyCount, Size);
}
diff --git a/tests/auto/threed/qgraphicstransform3d/tst_qgraphicstransform3d.cpp b/tests/auto/threed/qgraphicstransform3d/tst_qgraphicstransform3d.cpp
index 7c9837d14..30016f69d 100644
--- a/tests/auto/threed/qgraphicstransform3d/tst_qgraphicstransform3d.cpp
+++ b/tests/auto/threed/qgraphicstransform3d/tst_qgraphicstransform3d.cpp
@@ -112,15 +112,15 @@ void tst_QGraphicsTransform3D::rotation3D()
m2.translate(-1, -2, -3);
QVERIFY(isSameMatrix(m1, m2));
- QGraphicsRotation3D *rot2 = qobject_cast<QGraphicsRotation3D *>
- (rot1.clone(this));
+ QQuickQGraphicsTransform3D *transform2 = rot1.clone(this);
+ QGraphicsRotation3D *rot2 = qobject_cast<QGraphicsRotation3D *>(transform2);
QVERIFY(rot2 != 0);
QVERIFY(rot2 != &rot1);
QVERIFY(rot2->parent() == this);
QVERIFY(rot2->origin() == rot1.origin());
QVERIFY(rot2->axis() == rot1.axis());
QVERIFY(rot2->angle() == rot1.angle());
- delete rot2;
+ delete transform2;
}
void tst_QGraphicsTransform3D::scale3D()
@@ -167,14 +167,14 @@ void tst_QGraphicsTransform3D::scale3D()
QVERIFY(scale1.origin() == QVector3D(1, 2, 3));
QCOMPARE(spy1.size(), 1);
- QGraphicsScale3D *scale2 = qobject_cast<QGraphicsScale3D *>
- (scale1.clone(this));
+ QQuickQGraphicsTransform3D *transform2 = scale1.clone(this);
+ QGraphicsScale3D *scale2 = qobject_cast<QGraphicsScale3D *>(transform2);
QVERIFY(scale2 != 0);
QVERIFY(scale2 != &scale1);
QVERIFY(scale2->parent() == this);
QVERIFY(scale2->origin() == scale1.origin());
QVERIFY(scale2->scale() == scale1.scale());
- delete scale2;
+ delete transform2;
}
void tst_QGraphicsTransform3D::translation3D()
@@ -210,14 +210,14 @@ void tst_QGraphicsTransform3D::translation3D()
m2.translate(QVector3D(8, -12, 1));
QVERIFY(isSameMatrix(m1, m2));
- QGraphicsTranslation3D *translate2 = qobject_cast<QGraphicsTranslation3D *>
- (translate1.clone(this));
+ QQuickQGraphicsTransform3D *transform2 = translate1.clone(this);
+ QGraphicsTranslation3D *translate2 = qobject_cast<QGraphicsTranslation3D *>(transform2);
QVERIFY(translate2 != 0);
QVERIFY(translate2 != &translate1);
QVERIFY(translate2->parent() == this);
QVERIFY(translate2->translate() == translate1.translate());
QVERIFY(translate2->progress() == translate1.progress());
- delete translate2;
+ delete transform2;
}
void tst_QGraphicsTransform3D::billboard()
@@ -266,13 +266,13 @@ void tst_QGraphicsTransform3D::billboard()
billboard1.applyTo(&m6);
QVERIFY(m6 == m4);
- QGraphicsBillboardTransform *billboard2 = qobject_cast<QGraphicsBillboardTransform *>
- (billboard1.clone(this));
+ QQuickQGraphicsTransform3D *transform2 = billboard1.clone(this);
+ QGraphicsBillboardTransform *billboard2 = qobject_cast<QGraphicsBillboardTransform *>(transform2);
QVERIFY(billboard2 != 0);
QVERIFY(billboard2 != &billboard1);
QVERIFY(billboard2->parent() == this);
QVERIFY(billboard2->preserveUpVector() == billboard1.preserveUpVector());
- delete billboard2;
+ delete transform2;
}
QTEST_APPLESS_MAIN(tst_QGraphicsTransform3D)
diff --git a/tests/shared/compareimage.cpp b/tests/shared/compareimage.cpp
index 3bb41cb4b..d8e9319d1 100644
--- a/tests/shared/compareimage.cpp
+++ b/tests/shared/compareimage.cpp
@@ -113,8 +113,9 @@ float qProportionDifferentRGBPixels(const QImage& img1, const QImage& img2, int
qDebug() << "Sum of absolute differences was:"<< sumDiff;
qDebug() << "Average difference per pixel was:" << (float)sumDiff/(float)pixelcount;
#endif
+ Q_ASSERT(pixelcount>0);
return (float)result/(float)pixelcount;
-};
+}