File indexing completed on 2024-12-22 04:10:17
0001 /* 0002 * SPDX-FileCopyrightText: 2011 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kis_image_signal_router_test.h" 0008 0009 #include <simpletest.h> 0010 0011 0012 inline void KisImageSignalRouterTest::checkNotification(KisImageSignalType notification, const char *signal) 0013 { 0014 QSignalSpy *spy = new QSignalSpy(m_image.data(), signal); 0015 QCOMPARE(spy->count(), 0); 0016 m_image->signalRouter()->emitNotification(notification); 0017 QCOMPARE(spy->count(), 1); 0018 delete spy; 0019 } 0020 0021 #define checkComplexSignal(method, signal) \ 0022 { \ 0023 QSignalSpy *spy = new QSignalSpy(m_image.data(), signal); \ 0024 QCOMPARE(spy->count(), 0); \ 0025 m_image->signalRouter()->method; \ 0026 QCOMPARE(spy->count(), 1); \ 0027 delete spy; \ 0028 } 0029 0030 void KisImageSignalRouterTest::init() 0031 { 0032 initBase(); 0033 constructImage(); 0034 } 0035 0036 void KisImageSignalRouterTest::cleanup() 0037 { 0038 cleanupBase(); 0039 } 0040 0041 void KisImageSignalRouterTest::testSignalForwarding() 0042 { 0043 0044 checkNotification(LayersChangedSignal, SIGNAL(sigLayersChangedAsync())); 0045 checkNotification(SizeChangedSignal, SIGNAL(sigSizeChanged(QPointF,QPointF))); 0046 checkNotification(ComplexSizeChangedSignal(), SIGNAL(sigSizeChanged(QPointF,QPointF))); 0047 // These cannot be checked because KoColorProfile and KoColorSpace are not registered metatypes, 0048 // and cannot be registered as metatypes because they are abstract classes. 0049 // checkNotification(ProfileChangedSignal, SIGNAL(sigProfileChanged(const KoColorProfile*))); 0050 // checkNotification(ColorSpaceChangedSignal, SIGNAL(sigColorSpaceChanged(const KoColorSpace*))); 0051 checkNotification(ResolutionChangedSignal, SIGNAL(sigResolutionChanged(double,double))); 0052 0053 checkComplexSignal(emitNodeChanged(m_layer1.data()), SIGNAL(sigNodeChanged(KisNodeSP))); 0054 checkComplexSignal(emitNodeHasBeenAdded(m_layer3.data(),0), SIGNAL(sigNodeAddedAsync(KisNodeSP))); 0055 checkComplexSignal(emitAboutToRemoveANode(m_layer3.data(),0), SIGNAL(sigRemoveNodeAsync(KisNodeSP))); 0056 } 0057 0058 SIMPLE_TEST_MAIN(KisImageSignalRouterTest)