File indexing completed on 2024-04-21 04:02:04
0001 /****************************************************************************** 0002 * KBlocks, a falling blocks game by KDE * 0003 * SPDX-FileCopyrightText: 2009-2021 Julian Helfferich <julian.helfferich@mailbox.org> * 0004 * * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 ******************************************************************************/ 0007 #include <QTest> 0008 0009 #include "KBlocksGameLogic.h" 0010 #include "KBlocksWin.h" 0011 #include "Testing/MockGameLogic.h" 0012 #include "Testing/MockGraphics.h" 0013 #include "Testing/MockScene.h" 0014 #include "Testing/MockSound.h" 0015 #include "Testing/TestingKBlocksWin.h" 0016 0017 class testKBlocksWin : public QObject 0018 { 0019 Q_OBJECT 0020 private Q_SLOTS: 0021 void callStopGameBeforeSingleGamesAreDeleted(); 0022 }; 0023 0024 void testKBlocksWin::callStopGameBeforeSingleGamesAreDeleted() 0025 { 0026 /** 0027 * The KBlocksItemGroups which are part of KBlocksScene contain a 0028 * pointer to the single game(s). Thus, KBlocksScene should not 0029 * be used after the single games have been deleted. This is in 0030 * particular true for the stopGame() method which processes the 0031 * final game action items. 0032 */ 0033 MockGameLogic logic; 0034 MockGraphics graphics; 0035 MockSound sound; 0036 TestingKBlocksWin win(&logic, &graphics, &sound, nullptr, nullptr, 0, 0); 0037 MockScene *scene = new MockScene(&logic); 0038 win.replaceScene(scene); 0039 win.callStopGame(); 0040 QVERIFY(!scene->singleGameDeletedWhenStopGameCalled); 0041 } 0042 0043 QTEST_MAIN(testKBlocksWin) 0044 0045 #include "test_KBlocksWin.moc"