| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/browser/mock_content_browser_client.h" | 9 #include "content/browser/mock_content_browser_client.h" |
| 10 #include "content/common/content_paths.h" | 10 #include "content/common/content_paths.h" |
| 11 #include "content/common/notification_service.h" | 11 #include "content/browser/notification_service_impl.h" |
| 12 #include "content/public/common/content_client.h" | 12 #include "content/public/common/content_client.h" |
| 13 #include "content/test/test_content_client.h" | 13 #include "content/test/test_content_client.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/base/ui_base_paths.h" | 15 #include "ui/base/ui_base_paths.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 class TestContentClientInitializer : public testing::EmptyTestEventListener { | 19 class TestContentClientInitializer : public testing::EmptyTestEventListener { |
| 20 public: | 20 public: |
| 21 TestContentClientInitializer() { | 21 TestContentClientInitializer() { |
| 22 } | 22 } |
| 23 | 23 |
| 24 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { | 24 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { |
| 25 notification_service_.reset(new NotificationService()); | 25 notification_service_.reset(new NotificationServiceImpl()); |
| 26 | 26 |
| 27 DCHECK(!content::GetContentClient()); | 27 DCHECK(!content::GetContentClient()); |
| 28 content_client_.reset(new TestContentClient); | 28 content_client_.reset(new TestContentClient); |
| 29 content::SetContentClient(content_client_.get()); | 29 content::SetContentClient(content_client_.get()); |
| 30 | 30 |
| 31 content_browser_client_.reset(new content::MockContentBrowserClient()); | 31 content_browser_client_.reset(new content::MockContentBrowserClient()); |
| 32 content_client_->set_browser(content_browser_client_.get()); | 32 content_client_->set_browser(content_browser_client_.get()); |
| 33 } | 33 } |
| 34 | 34 |
| 35 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { | 35 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { |
| 36 notification_service_.reset(); | 36 notification_service_.reset(); |
| 37 | 37 |
| 38 DCHECK_EQ(content_client_.get(), content::GetContentClient()); | 38 DCHECK_EQ(content_client_.get(), content::GetContentClient()); |
| 39 content::SetContentClient(NULL); | 39 content::SetContentClient(NULL); |
| 40 content_client_.reset(); | 40 content_client_.reset(); |
| 41 | 41 |
| 42 content_browser_client_.reset(); | 42 content_browser_client_.reset(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 scoped_ptr<NotificationService> notification_service_; | 46 scoped_ptr<NotificationServiceImpl> notification_service_; |
| 47 scoped_ptr<content::ContentClient> content_client_; | 47 scoped_ptr<content::ContentClient> content_client_; |
| 48 scoped_ptr<content::ContentBrowserClient> content_browser_client_; | 48 scoped_ptr<content::ContentBrowserClient> content_browser_client_; |
| 49 | 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(TestContentClientInitializer); | 50 DISALLOW_COPY_AND_ASSIGN(TestContentClientInitializer); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 } // namespace | 53 } // namespace |
| 54 | 54 |
| 55 ContentTestSuite::ContentTestSuite(int argc, char** argv) | 55 ContentTestSuite::ContentTestSuite(int argc, char** argv) |
| 56 : base::TestSuite(argc, argv) { | 56 : base::TestSuite(argc, argv) { |
| 57 } | 57 } |
| 58 | 58 |
| 59 ContentTestSuite::~ContentTestSuite() { | 59 ContentTestSuite::~ContentTestSuite() { |
| 60 } | 60 } |
| 61 | 61 |
| 62 void ContentTestSuite::Initialize() { | 62 void ContentTestSuite::Initialize() { |
| 63 base::TestSuite::Initialize(); | 63 base::TestSuite::Initialize(); |
| 64 | 64 |
| 65 content::RegisterPathProvider(); | 65 content::RegisterPathProvider(); |
| 66 ui::RegisterPathProvider(); | 66 ui::RegisterPathProvider(); |
| 67 | 67 |
| 68 testing::TestEventListeners& listeners = | 68 testing::TestEventListeners& listeners = |
| 69 testing::UnitTest::GetInstance()->listeners(); | 69 testing::UnitTest::GetInstance()->listeners(); |
| 70 listeners.Append(new TestContentClientInitializer); | 70 listeners.Append(new TestContentClientInitializer); |
| 71 } | 71 } |
| OLD | NEW |