File indexing completed on 2024-12-22 04:12:52
0001 0002 /* 0003 * SPDX-FileCopyrightText: 2007 Boudewijn Rempt <boud@kde.org> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "kis_node_model_test.h" 0009 0010 #include <simpletest.h> 0011 #include <kis_debug.h> 0012 0013 #include "KisDocument.h" 0014 #include "KisPart.h" 0015 #include "kis_node_model.h" 0016 #include "kis_name_server.h" 0017 #include "flake/kis_shape_controller.h" 0018 0019 #include <testui.h> 0020 #include <testutil.h> 0021 0022 0023 #include "modeltest.h" 0024 0025 void KisNodeModelTest::init() 0026 { 0027 m_doc = KisPart::instance()->createDocument(); 0028 0029 m_nameServer = new KisNameServer(); 0030 m_shapeController = new KisShapeController(m_nameServer, m_doc->undoStack()); 0031 m_nodeModel = new KisNodeModel(0); 0032 0033 initBase(); 0034 0035 m_doc->setCurrentImage(m_image); 0036 } 0037 0038 void KisNodeModelTest::cleanup() 0039 { 0040 cleanupBase(); 0041 0042 delete m_nodeModel; 0043 delete m_shapeController; 0044 delete m_nameServer; 0045 delete m_doc; 0046 } 0047 0048 void KisNodeModelTest::testSetImage() 0049 { 0050 constructImage(); 0051 m_shapeController->setImage(m_image); 0052 m_nodeModel->setDummiesFacade(m_shapeController, m_image, 0, 0, 0); 0053 new ModelTest(m_nodeModel, this); 0054 } 0055 0056 void KisNodeModelTest::testAddNode() 0057 { 0058 m_shapeController->setImage(m_image); 0059 m_nodeModel->setDummiesFacade(m_shapeController, m_image, 0, 0, 0); 0060 new ModelTest(m_nodeModel, this); 0061 0062 constructImage(); 0063 0064 } 0065 0066 void KisNodeModelTest::testRemoveAllNodes() 0067 { 0068 constructImage(); 0069 m_shapeController->setImage(m_image); 0070 m_nodeModel->setDummiesFacade(m_shapeController, m_image, 0, 0, 0); 0071 new ModelTest(m_nodeModel, this); 0072 0073 m_image->removeNode(m_layer4); 0074 m_image->removeNode(m_layer3); 0075 m_image->removeNode(m_layer2); 0076 m_image->removeNode(m_layer1); 0077 } 0078 0079 void KisNodeModelTest::testRemoveIncludingRoot() 0080 { 0081 constructImage(); 0082 m_shapeController->setImage(m_image); 0083 m_nodeModel->setDummiesFacade(m_shapeController, m_image, 0, 0, 0); 0084 new ModelTest(m_nodeModel, this); 0085 0086 m_image->removeNode(m_layer4); 0087 m_image->removeNode(m_layer3); 0088 m_image->removeNode(m_layer2); 0089 m_image->removeNode(m_layer1); 0090 m_image->removeNode(m_image->root()); 0091 0092 0093 } 0094 0095 void KisNodeModelTest::testSubstituteRootNode() 0096 { 0097 constructImage(); 0098 m_shapeController->setImage(m_image); 0099 m_nodeModel->setDummiesFacade(m_shapeController, m_image, 0, 0, 0); 0100 new ModelTest(m_nodeModel, this); 0101 0102 m_image->flatten(0); 0103 } 0104 0105 KISTEST_MAIN(KisNodeModelTest)