20 #include <gtest/gtest.h>
21 #include <gmock/gmock.h>
24 #include "MockPlayerInstanceAAMP.h"
28 using ::testing::Return;
29 using ::testing::AtLeast;
45 void TearDown()
override
47 delete g_mockPlayerInstanceAAMP;
48 g_mockPlayerInstanceAAMP =
nullptr;
58 char cmd1[] =
"set ccStyle 1";
59 char cmd2[] =
"set ccStyle 2";
60 char cmd3[] =
"set ccStyle 3";
62 EXPECT_CALL(*g_mockPlayerInstanceAAMP, SetTextStyle(CC_OPTION_1)).Times(1);
63 mSet->execute(cmd1, g_mockPlayerInstanceAAMP);
65 EXPECT_CALL(*g_mockPlayerInstanceAAMP, SetTextStyle(CC_OPTION_2)).Times(1);
66 mSet->execute(cmd2, g_mockPlayerInstanceAAMP);
68 EXPECT_CALL(*g_mockPlayerInstanceAAMP, SetTextStyle(CC_OPTION_3)).Times(1);
69 mSet->execute(cmd3, g_mockPlayerInstanceAAMP);
75 char cmd1[] =
"set 45 1";
77 EXPECT_CALL(*g_mockPlayerInstanceAAMP, SetTextStyle(CC_OPTION_1)).Times(1);
78 mSet->execute(cmd1, g_mockPlayerInstanceAAMP);
84 char cmd[] =
"set ccStyle ";
86 EXPECT_CALL(*g_mockPlayerInstanceAAMP, SetTextStyle(_)).Times(0);
87 mSet->execute(cmd, g_mockPlayerInstanceAAMP);
93 char cmd0[] =
"set ccStyle 0";
94 char cmd4[] =
"set ccStyle 4";
96 EXPECT_CALL(*g_mockPlayerInstanceAAMP, SetTextStyle(_)).Times(0);
97 mSet->execute(cmd0, g_mockPlayerInstanceAAMP);
99 EXPECT_CALL(*g_mockPlayerInstanceAAMP, SetTextStyle(_)).Times(0);
100 mSet->execute(cmd4, g_mockPlayerInstanceAAMP);
107 const char json_file[] =
"test_json_file";
108 char cmd[] =
"set ccStyle test_json_file";
109 const char json[] =
"{ \"penSize\":\"small\" }";
111 std::ifstream ifs(json_file, std::ifstream::in);
112 ASSERT_FALSE(ifs.good());
115 std::ofstream of(json_file, std::ofstream::out);
116 ASSERT_TRUE(of.is_open());
118 of << json << std::endl;
122 EXPECT_CALL(*g_mockPlayerInstanceAAMP, SetTextStyle(json)).Times(1);
123 mSet->execute(cmd, g_mockPlayerInstanceAAMP);
126 ASSERT_FALSE(std::remove(json_file));
132 TEST_F(
ExecuteTests, Set_CCStyle_FileStartingWithNumber)
134 const char json_file[] =
"1test_json_file";
135 char cmd[] =
"set ccStyle 1test_json_file";
136 const char json[] =
"{ \"penSize\":\"small\" }";
138 std::ifstream ifs(json_file, std::ifstream::in);
139 ASSERT_FALSE(ifs.good());
142 std::ofstream of(json_file, std::ofstream::out);
143 ASSERT_TRUE(of.is_open());
145 of << json << std::endl;
149 EXPECT_CALL(*g_mockPlayerInstanceAAMP, SetTextStyle(json)).Times(1);
150 mSet->execute(cmd, g_mockPlayerInstanceAAMP);
153 ASSERT_FALSE(std::remove(json_file));
159 char cmd[] =
"set ccStyle MissingFile";
161 EXPECT_CALL(*g_mockPlayerInstanceAAMP, SetTextStyle(_)).Times(0);
162 mSet->execute(cmd, g_mockPlayerInstanceAAMP);
166 TEST_F(
ExecuteTests, Set_CCStyle_FilenameExceedsMaxLength)
168 char cmd [255] =
"set ccStyle ";
172 for (i = strlen(cmd); i <
sizeof(cmd) - 1; i++)
174 cmd[i] =
'A' + (i % 26);
178 EXPECT_CALL(*g_mockPlayerInstanceAAMP, SetTextStyle(_)).Times(0);
179 mSet->execute(cmd, g_mockPlayerInstanceAAMP);