@@ -44,6 +44,20 @@ BOOST_FIXTURE_TEST_CASE(CanToggleCheatModeOnAndOffRepeatedly, CheatsFixture)
4444 BOOST_TEST_REQUIRE (cheats.isCheatModeOn () == false );
4545}
4646
47+ BOOST_FIXTURE_TEST_CASE (TurningCheatModeOffDisablesAllCheats, CheatsFixture)
48+ {
49+ cheats.toggleCheatMode ();
50+ cheats.toggleAllVisible ();
51+ BOOST_TEST_REQUIRE (cheats.isAllVisible () == true );
52+ cheats.toggleAllBuildingsEnabled ();
53+ BOOST_TEST_REQUIRE (cheats.areAllBuildingsEnabled () == true );
54+ cheats.toggleCheatMode ();
55+ BOOST_TEST_REQUIRE (cheats.isAllVisible () == false );
56+ BOOST_TEST_REQUIRE (cheats.areAllBuildingsEnabled () == false );
57+ // testing toggleHumanAIPlayer would require GameClient::state==Loaded, which is guaranteed in code (because Cheats
58+ // only exist after the game is loaded) but is not the case in tests - skipping
59+ }
60+
4761namespace {
4862MOCK_BASE_CLASS (MockGameInterface, GameInterface)
4963{
@@ -65,11 +79,11 @@ MOCK_BASE_CLASS(MockGameInterface, GameInterface)
6579};
6680} // namespace
6781
68- BOOST_FIXTURE_TEST_CASE (CanToggleAllVisible_IfCheatModeIsOn_ButOnlyDisableAllVisible_IfCheatModeIsNotOn , CheatsFixture)
82+ BOOST_FIXTURE_TEST_CASE (CanToggleAllVisible_IfCheatModeIsOn , CheatsFixture)
6983{
7084 MockGameInterface mgi;
7185 MOCK_EXPECT (mgi.GI_GetCheats ).returns (std::ref (gameDesktop.GI_GetCheats ()));
72- MOCK_EXPECT (mgi.GI_UpdateMapVisibility ).exactly (4 ); // because the actual toggling should occur 4 times
86+ MOCK_EXPECT (mgi.GI_UpdateMapVisibility ).exactly (3 ); // how many toggles should actually occur
7387 world.SetGameInterface (&mgi);
7488
7589 MapPoint farawayPos = p1HQPos;
@@ -88,17 +102,23 @@ BOOST_FIXTURE_TEST_CASE(CanToggleAllVisible_IfCheatModeIsOn_ButOnlyDisableAllVis
88102 BOOST_TEST_REQUIRE ((viewer.GetVisibility (farawayPos) == Visibility::Visible) == true );
89103
90104 cheats.toggleAllVisible ();
91- // now not visible
92105 BOOST_TEST_REQUIRE ((viewer.GetVisibility (farawayPos) == Visibility::Visible) == false );
93-
94106 cheats.toggleAllVisible ();
95- // visible again
96107 BOOST_TEST_REQUIRE ((viewer.GetVisibility (farawayPos) == Visibility::Visible) == true );
108+ }
97109
110+ BOOST_FIXTURE_TEST_CASE (CanToggleAllBuildingsEnabled_IfCheatModeIsOn, CheatsFixture)
111+ {
112+ BOOST_TEST_REQUIRE (cheats.areAllBuildingsEnabled () == false );
113+ cheats.toggleAllBuildingsEnabled ();
114+ BOOST_TEST_REQUIRE (cheats.areAllBuildingsEnabled () == false );
98115 cheats.toggleCheatMode ();
99- cheats.toggleAllVisible ();
100- // again not visible, despite cheat mode being off
101- BOOST_TEST_REQUIRE ((viewer.GetVisibility (farawayPos) == Visibility::Visible) == false );
116+ cheats.toggleAllBuildingsEnabled ();
117+ BOOST_TEST_REQUIRE (cheats.areAllBuildingsEnabled () == true );
118+ cheats.toggleAllBuildingsEnabled ();
119+ BOOST_TEST_REQUIRE (cheats.areAllBuildingsEnabled () == false );
120+ cheats.toggleAllBuildingsEnabled ();
121+ BOOST_TEST_REQUIRE (cheats.areAllBuildingsEnabled () == true );
102122}
103123
104124BOOST_AUTO_TEST_SUITE_END ()
0 commit comments