Commit 3a0a84f9 authored by Julian Helfferich's avatar Julian Helfferich 💬
Browse files

Move definition of TestingKBlocksWin to .cpp file

This requires that the cpp file is compiled into a new KBlocksTesting
library against which the KBlocksWin test is linked.
parent fcb0babd
......@@ -26,6 +26,6 @@ ecm_add_test(
ecm_add_test(
test_KBlocksWin.cpp
TEST_NAME KBlocksWin
LINK_LIBRARIES Qt5::Test KBlocksCore
LINK_LIBRARIES Qt5::Test KBlocksCore KBlocksTesting
NAME_PREFIX "UnitTest-"
)
......@@ -61,3 +61,5 @@ target_link_libraries(KBlocksCore
KF5::I18n
Qt5::Svg
)
add_subdirectory(Testing)
set(testing_SRCS
TestingKBlocksWin.cpp
)
add_library(KBlocksTesting STATIC ${testing_SRCS})
target_link_libraries(KBlocksTesting
KBlocksCore
)
/******************************************************************************
* KBlocks, a falling blocks game by KDE *
* Copyright (C) 2010-2021 Julian Helfferich <julian.helfferich@mailbox.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
******************************************************************************/
#include "TestingKBlocksWin.h"
TestingKBlocksWin::TestingKBlocksWin(GameLogicInterface *p, KBlocksPlayManager *pM, int capacity, int gamecount)
: KBlocksWin(p, pM, capacity, gamecount)
{
}
void TestingKBlocksWin::callStopGame()
{
KBlocksWin::stopGame();
}
void TestingKBlocksWin::replaceScene(SceneInterface *newScene)
{
disconnect(
mpKBPlayer, &KBlocksKeyboardPlayer::blockMoved,
mpGameScene, &SceneInterface::playMoveSound
);
disconnect(
mpKBPlayer, &KBlocksKeyboardPlayer::blockDropped,
mpGameScene, &SceneInterface::playDropSound
);
delete mpGameScene;
mpGameScene = newScene;
connect(
mpKBPlayer, &KBlocksKeyboardPlayer::blockMoved,
mpGameScene, &SceneInterface::playMoveSound
);
connect(
mpKBPlayer, &KBlocksKeyboardPlayer::blockDropped,
mpGameScene, &SceneInterface::playDropSound
);
mpGameView->setScene(mpGameScene);
}
......@@ -20,34 +20,11 @@ class KBlocksPlayManager;
class TestingKBlocksWin : private KBlocksWin
{
public:
TestingKBlocksWin(GameLogicInterface *p, KBlocksPlayManager *pM, int capacity, int gamecount)
: KBlocksWin(p, pM, capacity, gamecount)
{
}
TestingKBlocksWin(GameLogicInterface *p, KBlocksPlayManager *pM, int capacity, int gamecount);
virtual ~TestingKBlocksWin() = default;
void callStopGame() { KBlocksWin::stopGame(); }
void replaceScene(SceneInterface *newScene) {
disconnect(
mpKBPlayer, &KBlocksKeyboardPlayer::blockMoved,
mpGameScene, &SceneInterface::playMoveSound
);
disconnect(
mpKBPlayer, &KBlocksKeyboardPlayer::blockDropped,
mpGameScene, &SceneInterface::playDropSound
);
delete mpGameScene;
mpGameScene = newScene;
connect(
mpKBPlayer, &KBlocksKeyboardPlayer::blockMoved,
mpGameScene, &SceneInterface::playMoveSound
);
connect(
mpKBPlayer, &KBlocksKeyboardPlayer::blockDropped,
mpGameScene, &SceneInterface::playDropSound
);
mpGameView->setScene(mpGameScene);
}
void callStopGame();
void replaceScene(SceneInterface *newScene);
};
#endif // TESTINGKBLOCKSWIN_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment