~jbicha/unity-2d/fix-launcher-quicklist-naming-lp949636

« back to all changes in this revision

Viewing changes to libunity-2d-private/tests/imageutilitiestest.cpp

. Fixes: . Approved by .

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file is part of unity-2d
3
 
 *
4
 
 * Copyright 2012 Canonical Ltd.
5
 
 *
6
 
 * Authors:
7
 
 * - Gerry Boland <gerry.boland@canonical.com>
8
 
 *
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.
12
 
 *
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.
17
 
 *
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/>.
20
 
 */
21
 
 
22
 
// Local
23
 
#include <unitytestmacro.h>
24
 
#include <debug_p.h>
25
 
#include <imageutilities.h>
26
 
#include <config.h>
27
 
 
28
 
const int threshold = 0.001;
29
 
 
30
 
class ImageUtilitiesTest : public QObject
31
 
{
32
 
    Q_OBJECT
33
 
private Q_SLOTS:
34
 
    void initTestCase()
35
 
    {
36
 
    }
37
 
 
38
 
    void testAverageColorComputed0()
39
 
    {
40
 
        ImageUtilities imageUtil;
41
 
        QUrl image("file:" + unity2dDirectory() + "/libunity-2d-private/tests/verification/JardinPolar_by_CarmenGloria_Gonzalez.jpg");
42
 
        QColor color;
43
 
 
44
 
        imageUtil.setSource(image);
45
 
        color = imageUtil.averageColor();
46
 
 
47
 
        QCOMPARE(color.red(), 80);
48
 
        QCOMPARE(color.green(), 194);
49
 
        QCOMPARE(color.blue(), 230);
50
 
    }
51
 
 
52
 
    void testAverageColorComputed1()
53
 
    {
54
 
        ImageUtilities imageUtil;
55
 
        QUrl image("file:" + unity2dDirectory() + "/libunity-2d-private/tests/verification/Langelinie_Alle_by_SirPecanGum.jpg");
56
 
        QColor color;
57
 
 
58
 
        imageUtil.setSource(image);
59
 
        color = imageUtil.averageColor();
60
 
        QCOMPARE(color.red(), 230);
61
 
        QCOMPARE(color.green(), 126);
62
 
        QCOMPARE(color.blue(), 80);
63
 
    }
64
 
 
65
 
    void testAverageColorComputed2()
66
 
    {
67
 
        ImageUtilities imageUtil;
68
 
        QUrl image("file:" + unity2dDirectory() + "/libunity-2d-private/tests/verification/The_Grass_aint_Greener_by_fix_pena.jpg");
69
 
        QColor color;
70
 
 
71
 
        imageUtil.setSource(image);
72
 
        color = imageUtil.averageColor();
73
 
 
74
 
        QCOMPARE(color.red(), 218);
75
 
        QCOMPARE(color.green(), 230);
76
 
        QCOMPARE(color.blue(), 80);
77
 
    }
78
 
 
79
 
    void testAverageColorComputed3()
80
 
    {
81
 
        ImageUtilities imageUtil;
82
 
        QUrl image("file:" + unity2dDirectory() + "/libunity-2d-private/tests/verification/warty-final-ubuntu.png");
83
 
        QColor color;
84
 
 
85
 
        imageUtil.setSource(image);
86
 
        color = imageUtil.averageColor();
87
 
 
88
 
        QCOMPARE(color.red(), 230);
89
 
        QCOMPARE(color.green(), 80);
90
 
        QCOMPARE(color.blue(), 137);
91
 
    }
92
 
};
93
 
 
94
 
UAPP_TEST_MAIN(ImageUtilitiesTest)
95
 
 
96
 
#include "imageutilitiestest.moc"
97