File indexing completed on 2024-12-22 04:10:19
0001 /* 0002 * SPDX-FileCopyrightText: 2007 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KIS_LAYER_TESTER_H 0008 #define KIS_LAYER_TESTER_H 0009 0010 #include <simpletest.h> 0011 0012 #include "kis_layer.h" 0013 #include "kis_types.h" 0014 #include "kis_node_visitor.h" 0015 #include "kis_image.h" 0016 #include "kis_default_bounds.h" 0017 0018 class TestLayer : public KisLayer 0019 { 0020 0021 Q_OBJECT 0022 0023 public: 0024 0025 TestLayer(KisImageWSP image, const QString & name, quint8 opacity) 0026 : KisLayer(image, name, opacity) { 0027 m_original = new KisPaintDevice(this, image->colorSpace(), new KisDefaultBounds(image)); 0028 } 0029 0030 KisNodeSP clone() { 0031 return new TestLayer(*this); 0032 } 0033 bool allowAsChild(KisNodeSP) const override { 0034 return true; 0035 } 0036 0037 virtual QString nodeType() { 0038 return "TEST"; 0039 } 0040 0041 KisPaintDeviceSP original() const override { 0042 return m_original; 0043 } 0044 0045 KisPaintDeviceSP paintDevice() const override { 0046 return 0; 0047 } 0048 0049 QIcon icon() const override { 0050 return QIcon(); 0051 } 0052 0053 KisNodeSP clone() const override { 0054 return new TestLayer(image(), name(), opacity()); 0055 } 0056 0057 qint32 x() const override { 0058 return 0; 0059 } 0060 0061 void setX(qint32) override { 0062 } 0063 0064 qint32 y() const override { 0065 return 0; 0066 } 0067 0068 void setY(qint32) override { 0069 } 0070 0071 QRect extent() const override { 0072 return QRect(); 0073 } 0074 0075 QRect exactBounds() const override { 0076 return QRect(); 0077 } 0078 0079 using KisLayer::accept; 0080 0081 bool accept(KisNodeVisitor& v) override { 0082 return v.visit(this); 0083 } 0084 0085 private: 0086 KisPaintDeviceSP m_original; 0087 }; 0088 0089 class KisLayerTest : public QObject 0090 { 0091 Q_OBJECT 0092 0093 private Q_SLOTS: 0094 0095 void testCreation(); 0096 void testOrdering(); 0097 void testMoveNode(); 0098 void testMoveLayer(); 0099 void testMasksChangeRect(); 0100 void testMoveLayerWithMaskThreaded(); 0101 }; 0102 0103 #endif 0104