@@ -61,6 +61,44 @@ TEST(EngineTest, Fps)
6161 ASSERT_EQ (engine.fps (), 60.25 );
6262}
6363
64+ TEST (EngineTest, KeyState)
65+ {
66+ Engine engine;
67+ ASSERT_FALSE (engine.keyPressed (" a" ));
68+ ASSERT_FALSE (engine.keyPressed (" b" ));
69+ ASSERT_FALSE (engine.keyPressed (" up arrow" ));
70+
71+ engine.setKeyState (" a" , true );
72+ ASSERT_TRUE (engine.keyPressed (" a" ));
73+ ASSERT_FALSE (engine.keyPressed (" b" ));
74+ ASSERT_FALSE (engine.keyPressed (" up arrow" ));
75+
76+ engine.setKeyState (" up arrow" , true );
77+ ASSERT_TRUE (engine.keyPressed (" a" ));
78+ ASSERT_FALSE (engine.keyPressed (" b" ));
79+ ASSERT_TRUE (engine.keyPressed (" up arrow" ));
80+
81+ engine.setKeyState (" b" , true );
82+ ASSERT_TRUE (engine.keyPressed (" a" ));
83+ ASSERT_TRUE (engine.keyPressed (" b" ));
84+ ASSERT_TRUE (engine.keyPressed (" up arrow" ));
85+
86+ engine.setKeyState (" a" , false );
87+ ASSERT_FALSE (engine.keyPressed (" a" ));
88+ ASSERT_TRUE (engine.keyPressed (" b" ));
89+ ASSERT_TRUE (engine.keyPressed (" up arrow" ));
90+
91+ engine.setKeyState (" up arrow" , false );
92+ ASSERT_FALSE (engine.keyPressed (" a" ));
93+ ASSERT_TRUE (engine.keyPressed (" b" ));
94+ ASSERT_FALSE (engine.keyPressed (" up arrow" ));
95+
96+ engine.setKeyState (" b" , false );
97+ ASSERT_FALSE (engine.keyPressed (" a" ));
98+ ASSERT_FALSE (engine.keyPressed (" b" ));
99+ ASSERT_FALSE (engine.keyPressed (" up arrow" ));
100+ }
101+
64102TEST (EngineTest, MouseX)
65103{
66104 Engine engine;
0 commit comments