|
1 | 1 | #include <scratchcpp/stage.h> |
| 2 | +#include <stagehandlermock.h> |
2 | 3 |
|
3 | | -#include "teststageinterface.h" |
4 | 4 | #include "../common.h" |
5 | 5 |
|
6 | | -#define INIT_STAGE() stage.setInterface(&stageInterface); |
7 | | - |
8 | 6 | using namespace libscratchcpp; |
9 | 7 |
|
10 | | -Stage stage; |
11 | | -TestStageInterface stageInterface; |
12 | | - |
13 | | -TEST(IStageHandlerTest, Sprite) |
| 8 | +class IStageHandlerTest : public testing::Test |
14 | 9 | { |
15 | | - INIT_STAGE(); |
16 | | - ASSERT_EQ(stageInterface.stage, &stage); |
17 | | -} |
18 | | - |
19 | | -TEST(IStageHandlerTest, Tempo) |
| 10 | + public: |
| 11 | + void SetUp() override |
| 12 | + { |
| 13 | + EXPECT_CALL(m_handler, onStageChanged(&m_stage)).Times(1); |
| 14 | + m_stage.setInterface(&m_handler); |
| 15 | + } |
| 16 | + |
| 17 | + Stage m_stage; |
| 18 | + StageHandlerMock m_handler; |
| 19 | +}; |
| 20 | + |
| 21 | +TEST_F(IStageHandlerTest, Tempo) |
20 | 22 | { |
21 | | - INIT_STAGE(); |
22 | | - stage.setTempo(120); |
23 | | - ASSERT_EQ(stageInterface.tempo, 120); |
24 | | - stage.setTempo(55); |
25 | | - ASSERT_EQ(stage.tempo(), 55); |
| 23 | + EXPECT_CALL(m_handler, onTempoChanged(120)).Times(1); |
| 24 | + m_stage.setTempo(120); |
26 | 25 | } |
27 | 26 |
|
28 | | -TEST(IStageHandlerTest, VideoState) |
| 27 | +TEST_F(IStageHandlerTest, VideoState) |
29 | 28 | { |
30 | | - INIT_STAGE(); |
31 | | - stage.setVideoState(Stage::VideoState::On); |
32 | | - ASSERT_EQ(stageInterface.videoState, Stage::VideoState::On); |
33 | | - stage.setVideoState(Stage::VideoState::OnFlipped); |
34 | | - ASSERT_EQ(stageInterface.videoState, Stage::VideoState::OnFlipped); |
| 29 | + EXPECT_CALL(m_handler, onVideoStateChanged(Stage::VideoState::On)).Times(1); |
| 30 | + m_stage.setVideoState(Stage::VideoState::On); |
| 31 | + |
| 32 | + EXPECT_CALL(m_handler, onVideoStateChanged(Stage::VideoState::OnFlipped)).Times(1); |
| 33 | + m_stage.setVideoState(Stage::VideoState::OnFlipped); |
35 | 34 | } |
36 | 35 |
|
37 | | -TEST(IStageHandlerTest, CostumeData) |
| 36 | +TEST_F(IStageHandlerTest, CostumeData) |
38 | 37 | { |
39 | | - INIT_STAGE(); |
40 | | - // TODO: Add tests for costume data |
| 38 | + // TODO: Add test for costume data |
| 39 | + // EXPECT_CALL(m_handler, onCostumeChanged(...)).Times(1); |
41 | 40 | } |
0 commit comments