1 /*
2  *  Copyright (c) 2007 Boudewijn Rempt <boud@valdyas.org>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef KIS_LAYER_TESTER_H
20 #define KIS_LAYER_TESTER_H
21 
22 #include <QtTest>
23 
24 #include "kis_layer.h"
25 #include "kis_types.h"
26 #include "kis_node_visitor.h"
27 #include "kis_image.h"
28 
29 class TestLayer : public KisLayer
30 {
31 
32     Q_OBJECT
33 
34 public:
35 
TestLayer(KisImageWSP image,const QString & name,quint8 opacity)36     TestLayer(KisImageWSP image, const QString & name, quint8 opacity)
37             : KisLayer(image, name, opacity) {
38     }
39 
clone()40     KisNodeSP clone() {
41         return new TestLayer(*this);
42     }
allowAsChild(KisNodeSP)43     bool allowAsChild(KisNodeSP) const override {
44         return true;
45     }
46 
nodeType()47     virtual QString nodeType() {
48         return "TEST";
49     }
50 
original()51     KisPaintDeviceSP original() const override {
52         // This test doesn't use updateProjection so just return 0
53         return 0;
54     }
55 
paintDevice()56     KisPaintDeviceSP paintDevice() const override {
57         return 0;
58     }
59 
icon()60     QIcon icon() const override {
61         return QIcon();
62     }
63 
clone()64     KisNodeSP clone() const override {
65         return new TestLayer(image(), name(), opacity());
66     }
67 
x()68     qint32 x() const override {
69         return 0;
70     }
71 
setX(qint32)72     void setX(qint32) override {
73     }
74 
y()75     qint32 y() const override {
76         return 0;
77     }
78 
setY(qint32)79     void setY(qint32) override {
80     }
81 
extent()82     QRect extent() const override {
83         return QRect();
84     }
85 
exactBounds()86     QRect exactBounds() const override {
87         return QRect();
88     }
89 
90     using KisLayer::accept;
91 
accept(KisNodeVisitor & v)92     bool accept(KisNodeVisitor& v) override {
93         return v.visit(this);
94     }
95 
96 
97 };
98 
99 class KisLayerTest : public QObject
100 {
101     Q_OBJECT
102 
103 private Q_SLOTS:
104 
105     void testCreation();
106     void testOrdering();
107     void testMoveNode();
108     void testMoveLayer();
109     void testMasksChangeRect();
110     void testMoveLayerWithMaskThreaded();
111 };
112 
113 #endif
114 
115