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 "content/public/test/content_test_suite_base.h" | 5 #include "content/public/test/content_test_suite_base.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/test/test_suite.h" | 10 #include "base/test/test_suite.h" |
| 11 #include "base/threading/sequenced_worker_pool.h" |
| 12 #include "content/browser/browser_thread_impl.h" |
11 #include "content/common/url_schemes.h" | 13 #include "content/common/url_schemes.h" |
12 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
13 #include "content/public/common/content_paths.h" | 15 #include "content/public/common/content_paths.h" |
14 #include "media/base/media.h" | 16 #include "media/base/media.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "ui/base/ui_base_paths.h" | 18 #include "ui/base/ui_base_paths.h" |
16 #include "ui/compositor/compositor_setup.h" | 19 #include "ui/compositor/compositor_setup.h" |
17 | 20 |
18 namespace content { | 21 namespace content { |
19 | 22 |
| 23 namespace { |
| 24 class ContentTestSuiteListener : public testing::EmptyTestEventListener { |
| 25 public: |
| 26 ContentTestSuiteListener() { |
| 27 } |
| 28 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { |
| 29 BrowserThreadImpl::FlushThreadPoolForTesting(); |
| 30 } |
| 31 DISALLOW_COPY_AND_ASSIGN(ContentTestSuiteListener); |
| 32 }; |
| 33 } // namespace |
| 34 |
20 ContentTestSuiteBase::ContentTestSuiteBase(int argc, char** argv) | 35 ContentTestSuiteBase::ContentTestSuiteBase(int argc, char** argv) |
21 : base::TestSuite(argc, argv), | 36 : base::TestSuite(argc, argv), |
22 external_libraries_enabled_(true) { | 37 external_libraries_enabled_(true) { |
23 } | 38 } |
24 | 39 |
25 void ContentTestSuiteBase::Initialize() { | 40 void ContentTestSuiteBase::Initialize() { |
26 base::TestSuite::Initialize(); | 41 base::TestSuite::Initialize(); |
27 | 42 |
28 if (external_libraries_enabled_) | 43 if (external_libraries_enabled_) |
29 media::InitializeMediaLibraryForTesting(); | 44 media::InitializeMediaLibraryForTesting(); |
30 | 45 |
31 scoped_ptr<ContentClient> client_for_init(CreateClientForInitialization()); | 46 scoped_ptr<ContentClient> client_for_init(CreateClientForInitialization()); |
32 SetContentClient(client_for_init.get()); | 47 SetContentClient(client_for_init.get()); |
33 RegisterContentSchemes(false); | 48 RegisterContentSchemes(false); |
34 SetContentClient(NULL); | 49 SetContentClient(NULL); |
35 | 50 |
36 RegisterPathProvider(); | 51 RegisterPathProvider(); |
37 ui::RegisterPathProvider(); | 52 ui::RegisterPathProvider(); |
38 | 53 |
39 // Mock out the compositor on platforms that use it. | 54 // Mock out the compositor on platforms that use it. |
40 ui::SetupTestCompositor(); | 55 ui::SetupTestCompositor(); |
| 56 |
| 57 testing::TestEventListeners& listeners = |
| 58 testing::UnitTest::GetInstance()->listeners(); |
| 59 listeners.Append(new ContentTestSuiteListener); |
41 } | 60 } |
42 | 61 |
43 } // namespace content | 62 } // namespace content |
OLD | NEW |