Index: base/test/nslog_test_event_listener.h |
diff --git a/base/test/nslog_test_event_listener.h b/base/test/nslog_test_event_listener.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..91411f04c594f2564d5896f09ed8af73f31b62c1 |
--- /dev/null |
+++ b/base/test/nslog_test_event_listener.h |
@@ -0,0 +1,48 @@ |
+// Copyright 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef BASE_TEST_NSLOG_TEST_EVENT_LISTENER_H_ |
+#define BASE_TEST_NSLOG_TEST_EVENT_LISTENER_H_ |
+ |
+#include "base/compiler_specific.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+@class NSString; |
+ |
+// This class implements the TestEventListener interface so that output is |
+// formatted like the PrettyUnitTestResultPrinter in gtest.cc, but writes to |
+// NSLog instead of stdout (because, as of iOS 6, the app's stdout no longer |
+// writes to the console log). |
+class NSLogTestEventListener : public testing::TestEventListener { |
+ public: |
+ NSLogTestEventListener(); |
+ |
+ // TestEventListener overrides. |
+ virtual void OnTestProgramStart(const testing::UnitTest&) OVERRIDE; |
+ virtual void OnTestIterationStart( |
+ const testing::UnitTest& unit_test, |
+ int iteration) OVERRIDE; |
+ virtual void OnEnvironmentsSetUpStart( |
+ const testing::UnitTest& unit_test) OVERRIDE; |
+ virtual void OnEnvironmentsSetUpEnd(const testing::UnitTest&) OVERRIDE; |
+ virtual void OnTestCaseStart(const testing::TestCase& test_case) OVERRIDE; |
+ virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE; |
+ virtual void OnTestPartResult(const testing::TestPartResult& result) OVERRIDE; |
+ virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE; |
+ virtual void OnTestCaseEnd(const testing::TestCase& test_case) OVERRIDE; |
+ virtual void OnEnvironmentsTearDownStart( |
+ const testing::UnitTest& unit_test) OVERRIDE; |
+ virtual void OnEnvironmentsTearDownEnd(const testing::UnitTest&) OVERRIDE; |
+ virtual void OnTestIterationEnd( |
+ const testing::UnitTest& unit_test, |
+ int iteration) OVERRIDE; |
+ virtual void OnTestProgramEnd(const testing::UnitTest&) OVERRIDE; |
+ |
+ private: |
+ static NSString* PrintFailedTests(const testing::UnitTest& unit_test); |
+ static NSString* PrintFullTestCommentIfPresent( |
+ const testing::TestInfo& test_info); |
+}; |
+ |
+#endif // BASE_TEST_NSLOG_TEST_EVENT_LISTENER_H_ |