Index: components/test/run_all_unittests.cc |
diff --git a/components/test/run_all_unittests.cc b/components/test/run_all_unittests.cc |
index 2c8d29c6d00885e8e8c27f74a105e94cb5c96fa4..49032baee6411b2c512362f8b0039e6fa14c4cfc 100644 |
--- a/components/test/run_all_unittests.cc |
+++ b/components/test/run_all_unittests.cc |
@@ -2,8 +2,46 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "base/memory/scoped_ptr.h" |
#include "base/test/test_suite.h" |
+#include "content/public/test/test_content_client_initializer.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+#include "ui/compositor/compositor_setup.h" |
+ |
+namespace components { |
+ |
+class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { |
+ public: |
+ ComponentsUnitTestEventListener() {} |
+ virtual ~ComponentsUnitTestEventListener() {} |
+ |
+ virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { |
+ content_initializer_.reset(new content::TestContentClientInitializer()); |
+ } |
+ |
+ virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { |
+ content_initializer_.reset(); |
+ } |
+ |
+ private: |
+ scoped_ptr<content::TestContentClientInitializer> content_initializer_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ComponentsUnitTestEventListener); |
+}; |
+ |
+} // namespace components |
int main(int argc, char** argv) { |
- return base::TestSuite(argc, argv).Run(); |
+ base::TestSuite test_suite(argc, argv); |
+ |
+ // Mock out the compositor on platforms that use it. |
+ ui::SetupTestCompositor(); |
+ |
+ // The listener will set up common test environment for all components unit |
+ // tests. |
+ testing::TestEventListeners& listeners = |
+ testing::UnitTest::GetInstance()->listeners(); |
+ listeners.Append(new components::ComponentsUnitTestEventListener()); |
+ |
+ return test_suite.Run(); |
} |