| 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/test/content_test_suite.h" | 5 #include "content/test/content_test_suite.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/browser/mock_content_browser_client.h" | 8 #include "content/browser/mock_content_browser_client.h" |
| 9 #include "content/public/common/content_paths.h" | |
| 10 #include "content/public/common/url_constants.h" | |
| 11 #include "content/test/test_content_client.h" | 9 #include "content/test/test_content_client.h" |
| 12 #include "content/test/test_content_client_initializer.h" | 10 #include "content/test/test_content_client_initializer.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/base/ui_base_paths.h" | |
| 15 | 12 |
| 16 #if defined(USE_AURA) | 13 #if defined(USE_AURA) |
| 17 #include "ui/aura/test/test_aura_initializer.h" | 14 #include "ui/aura/test/test_aura_initializer.h" |
| 18 #endif | 15 #endif |
| 19 | 16 |
| 20 #if defined(OS_MACOSX) | 17 #if defined(OS_MACOSX) |
| 21 #include "base/mac/scoped_nsautorelease_pool.h" | 18 #include "base/mac/scoped_nsautorelease_pool.h" |
| 22 #endif | 19 #endif |
| 23 #include "ui/compositor/compositor_setup.h" | |
| 24 | |
| 25 | 20 |
| 26 namespace { | 21 namespace { |
| 27 | 22 |
| 28 class TestInitializationListener : public testing::EmptyTestEventListener { | 23 class TestInitializationListener : public testing::EmptyTestEventListener { |
| 29 public: | 24 public: |
| 30 TestInitializationListener() : test_content_client_initializer_(NULL) { | 25 TestInitializationListener() : test_content_client_initializer_(NULL) { |
| 31 } | 26 } |
| 32 | 27 |
| 33 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { | 28 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { |
| 34 test_content_client_initializer_ = | 29 test_content_client_initializer_ = |
| 35 new content::TestContentClientInitializer(); | 30 new content::TestContentClientInitializer(); |
| 36 } | 31 } |
| 37 | 32 |
| 38 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { | 33 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { |
| 39 delete test_content_client_initializer_; | 34 delete test_content_client_initializer_; |
| 40 } | 35 } |
| 41 | 36 |
| 42 private: | 37 private: |
| 43 content::TestContentClientInitializer* test_content_client_initializer_; | 38 content::TestContentClientInitializer* test_content_client_initializer_; |
| 44 | 39 |
| 45 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener); | 40 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener); |
| 46 }; | 41 }; |
| 47 | 42 |
| 48 } // namespace | 43 } // namespace |
| 49 | 44 |
| 45 namespace content { |
| 46 |
| 50 ContentTestSuite::ContentTestSuite(int argc, char** argv) | 47 ContentTestSuite::ContentTestSuite(int argc, char** argv) |
| 51 : base::TestSuite(argc, argv) { | 48 : ContentTestSuiteBase(argc, argv) { |
| 52 #if defined(USE_AURA) | 49 #if defined(USE_AURA) |
| 53 aura_initializer_.reset(new aura::test::TestAuraInitializer); | 50 aura_initializer_.reset(new aura::test::TestAuraInitializer); |
| 54 #endif | 51 #endif |
| 55 } | 52 } |
| 56 | 53 |
| 57 ContentTestSuite::~ContentTestSuite() { | 54 ContentTestSuite::~ContentTestSuite() { |
| 58 } | 55 } |
| 59 | 56 |
| 60 void ContentTestSuite::Initialize() { | 57 void ContentTestSuite::Initialize() { |
| 61 #if defined(OS_MACOSX) | 58 #if defined(OS_MACOSX) |
| 62 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 59 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
| 63 #endif | 60 #endif |
| 64 | 61 |
| 65 base::TestSuite::Initialize(); | 62 ContentTestSuiteBase::Initialize(); |
| 66 | |
| 67 TestContentClient client_for_init; | |
| 68 content::SetContentClient(&client_for_init); | |
| 69 content::RegisterContentSchemes(false); | |
| 70 content::SetContentClient(NULL); | |
| 71 | |
| 72 content::RegisterPathProvider(); | |
| 73 ui::RegisterPathProvider(); | |
| 74 | |
| 75 // Mock out the compositor on platforms that use it. | |
| 76 ui::SetupTestCompositor(); | |
| 77 | 63 |
| 78 testing::TestEventListeners& listeners = | 64 testing::TestEventListeners& listeners = |
| 79 testing::UnitTest::GetInstance()->listeners(); | 65 testing::UnitTest::GetInstance()->listeners(); |
| 80 listeners.Append(new TestInitializationListener); | 66 listeners.Append(new TestInitializationListener); |
| 81 } | 67 } |
| 82 | 68 |
| 69 ContentClient* ContentTestSuite::CreateClientForInitialization() { |
| 70 return new TestContentClient(); |
| 71 } |
| 72 |
| 73 } // namespace content |
| OLD | NEW |