2
* This file is part of unity-2d
4
* Copyright 2012 Canonical Ltd.
7
* - Gerry Boland <gerry.boland@canonical.com>
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; version 3.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
#include <unitytestmacro.h>
25
#include <imageutilities.h>
28
const int threshold = 0.001;
30
class ImageUtilitiesTest : public QObject
38
void testAverageColorComputed0()
40
ImageUtilities imageUtil;
41
QUrl image("file:" + unity2dDirectory() + "/libunity-2d-private/tests/verification/JardinPolar_by_CarmenGloria_Gonzalez.jpg");
44
imageUtil.setSource(image);
45
color = imageUtil.averageColor();
47
QCOMPARE(color.red(), 80);
48
QCOMPARE(color.green(), 194);
49
QCOMPARE(color.blue(), 230);
52
void testAverageColorComputed1()
54
ImageUtilities imageUtil;
55
QUrl image("file:" + unity2dDirectory() + "/libunity-2d-private/tests/verification/Langelinie_Alle_by_SirPecanGum.jpg");
58
imageUtil.setSource(image);
59
color = imageUtil.averageColor();
60
QCOMPARE(color.red(), 230);
61
QCOMPARE(color.green(), 126);
62
QCOMPARE(color.blue(), 80);
65
void testAverageColorComputed2()
67
ImageUtilities imageUtil;
68
QUrl image("file:" + unity2dDirectory() + "/libunity-2d-private/tests/verification/The_Grass_aint_Greener_by_fix_pena.jpg");
71
imageUtil.setSource(image);
72
color = imageUtil.averageColor();
74
QCOMPARE(color.red(), 218);
75
QCOMPARE(color.green(), 230);
76
QCOMPARE(color.blue(), 80);
79
void testAverageColorComputed3()
81
ImageUtilities imageUtil;
82
QUrl image("file:" + unity2dDirectory() + "/libunity-2d-private/tests/verification/warty-final-ubuntu.png");
85
imageUtil.setSource(image);
86
color = imageUtil.averageColor();
88
QCOMPARE(color.red(), 230);
89
QCOMPARE(color.green(), 80);
90
QCOMPARE(color.blue(), 137);
94
UAPP_TEST_MAIN(ImageUtilitiesTest)
96
#include "imageutilitiestest.moc"