40 using ::testing::Environment;
42 using ::testing::Test;
44 using ::testing::TestEventListener;
45 using ::testing::TestInfo;
46 using ::testing::TestPartResult;
47 using ::testing::UnitTest;
68 <<
"(" << iteration <<
")";
112 <<
"(" << iteration <<
")";
113 g_events->push_back(message.
GetString());
131 g_events->push_back(
"Environment::SetUp");
135 g_events->push_back(
"Environment::TearDown");
142 g_events->push_back(
"ListenerTest::SetUpTestCase");
146 g_events->push_back(
"ListenerTest::TearDownTestCase");
150 g_events->push_back(
"ListenerTest::SetUp");
154 g_events->push_back(
"ListenerTest::TearDown");
161 g_events->push_back(
"ListenerTest::* Test Body");
166 g_events->push_back(
"ListenerTest::* Test Body");
174 using ::testing::internal::EnvironmentInvocationCatcher;
175 using ::testing::internal::EventRecordingListener;
178 const char*
const* expected_data,
179 size_t expected_data_size) {
180 const size_t actual_size = data.size();
183 EXPECT_EQ(expected_data_size, actual_size);
186 const size_t shorter_size = expected_data_size <= actual_size ?
187 expected_data_size : actual_size;
189 for (; i < shorter_size; ++
i) {
191 <<
"at position " <<
i;
195 for (; i < actual_size; ++
i) {
196 printf(
" Actual event #%lu: %s\n",
197 static_cast<unsigned long>(i), data[i].c_str());
201 int main(
int argc,
char **argv) {
202 std::vector<std::string>
events;
206 UnitTest::GetInstance()->listeners().Append(
207 new EventRecordingListener(
"1st"));
208 UnitTest::GetInstance()->listeners().Append(
209 new EventRecordingListener(
"2nd"));
214 <<
"AddGlobalTestEnvironment should not generate any events itself.";
219 const char*
const expected_events[] = {
220 "1st.OnTestProgramStart",
221 "2nd.OnTestProgramStart",
222 "1st.OnTestIterationStart(0)",
223 "2nd.OnTestIterationStart(0)",
224 "1st.OnEnvironmentsSetUpStart",
225 "2nd.OnEnvironmentsSetUpStart",
226 "Environment::SetUp",
227 "2nd.OnEnvironmentsSetUpEnd",
228 "1st.OnEnvironmentsSetUpEnd",
229 "1st.OnTestCaseStart",
230 "2nd.OnTestCaseStart",
231 "ListenerTest::SetUpTestCase",
234 "ListenerTest::SetUp",
235 "ListenerTest::* Test Body",
236 "1st.OnTestPartResult",
237 "2nd.OnTestPartResult",
238 "ListenerTest::TearDown",
243 "ListenerTest::SetUp",
244 "ListenerTest::* Test Body",
245 "1st.OnTestPartResult",
246 "2nd.OnTestPartResult",
247 "ListenerTest::TearDown",
250 "ListenerTest::TearDownTestCase",
253 "1st.OnEnvironmentsTearDownStart",
254 "2nd.OnEnvironmentsTearDownStart",
255 "Environment::TearDown",
256 "2nd.OnEnvironmentsTearDownEnd",
257 "1st.OnEnvironmentsTearDownEnd",
258 "2nd.OnTestIterationEnd(0)",
259 "1st.OnTestIterationEnd(0)",
260 "1st.OnTestIterationStart(1)",
261 "2nd.OnTestIterationStart(1)",
262 "1st.OnEnvironmentsSetUpStart",
263 "2nd.OnEnvironmentsSetUpStart",
264 "Environment::SetUp",
265 "2nd.OnEnvironmentsSetUpEnd",
266 "1st.OnEnvironmentsSetUpEnd",
267 "1st.OnTestCaseStart",
268 "2nd.OnTestCaseStart",
269 "ListenerTest::SetUpTestCase",
272 "ListenerTest::SetUp",
273 "ListenerTest::* Test Body",
274 "1st.OnTestPartResult",
275 "2nd.OnTestPartResult",
276 "ListenerTest::TearDown",
281 "ListenerTest::SetUp",
282 "ListenerTest::* Test Body",
283 "1st.OnTestPartResult",
284 "2nd.OnTestPartResult",
285 "ListenerTest::TearDown",
288 "ListenerTest::TearDownTestCase",
291 "1st.OnEnvironmentsTearDownStart",
292 "2nd.OnEnvironmentsTearDownStart",
293 "Environment::TearDown",
294 "2nd.OnEnvironmentsTearDownEnd",
295 "1st.OnEnvironmentsTearDownEnd",
296 "2nd.OnTestIterationEnd(1)",
297 "1st.OnTestIterationEnd(1)",
298 "2nd.OnTestProgramEnd",
299 "1st.OnTestProgramEnd"
303 sizeof(expected_events)/
sizeof(expected_events[0]));
307 if (UnitTest::GetInstance()->Failed())