OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/test/test_suite.h" | 6 #include "base/test/test_suite.h" |
7 #include "content/public/test/test_content_client_initializer.h" | 7 #include "content/public/test/test_content_client_initializer.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/compositor/compositor_setup.h" |
9 | 10 |
10 namespace components { | 11 namespace components { |
11 | 12 |
12 class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { | 13 class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { |
13 public: | 14 public: |
14 ComponentsUnitTestEventListener() {} | 15 ComponentsUnitTestEventListener() {} |
15 virtual ~ComponentsUnitTestEventListener() {} | 16 virtual ~ComponentsUnitTestEventListener() {} |
16 | 17 |
17 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { | 18 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { |
18 content_initializer_.reset(new content::TestContentClientInitializer()); | 19 content_initializer_.reset(new content::TestContentClientInitializer()); |
19 } | 20 } |
20 | 21 |
21 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { | 22 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { |
22 content_initializer_.reset(); | 23 content_initializer_.reset(); |
23 } | 24 } |
24 | 25 |
25 private: | 26 private: |
26 scoped_ptr<content::TestContentClientInitializer> content_initializer_; | 27 scoped_ptr<content::TestContentClientInitializer> content_initializer_; |
27 | 28 |
28 DISALLOW_COPY_AND_ASSIGN(ComponentsUnitTestEventListener); | 29 DISALLOW_COPY_AND_ASSIGN(ComponentsUnitTestEventListener); |
29 }; | 30 }; |
30 | 31 |
31 } // namespace components | 32 } // namespace components |
32 | 33 |
33 int main(int argc, char** argv) { | 34 int main(int argc, char** argv) { |
34 base::TestSuite test_suite(argc, argv); | 35 base::TestSuite test_suite(argc, argv); |
35 | 36 |
| 37 // Mock out the compositor on platforms that use it. |
| 38 ui::SetupTestCompositor(); |
| 39 |
36 // The listener will set up common test environment for all components unit | 40 // The listener will set up common test environment for all components unit |
37 // tests. | 41 // tests. |
38 testing::TestEventListeners& listeners = | 42 testing::TestEventListeners& listeners = |
39 testing::UnitTest::GetInstance()->listeners(); | 43 testing::UnitTest::GetInstance()->listeners(); |
40 listeners.Append(new components::ComponentsUnitTestEventListener()); | 44 listeners.Append(new components::ComponentsUnitTestEventListener()); |
41 | 45 |
42 return test_suite.Run(); | 46 return test_suite.Run(); |
43 } | 47 } |
OLD | NEW |