OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/test/ash_test_environment_content.h" |
| 6 |
| 7 #include "ash/test/ash_test_views_delegate.h" |
| 8 #include "ash/test/content/test_shell_content_state.h" |
| 9 #include "base/memory/ptr_util.h" |
| 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/test/test_browser_thread_bundle.h" |
| 12 #include "content/public/test/web_contents_tester.h" |
| 13 |
| 14 namespace ash { |
| 15 namespace test { |
| 16 namespace { |
| 17 |
| 18 class AshTestViewsDelegateContent : public AshTestViewsDelegate { |
| 19 public: |
| 20 AshTestViewsDelegateContent() {} |
| 21 ~AshTestViewsDelegateContent() override {} |
| 22 |
| 23 // AshTestViewsDelegate: |
| 24 content::WebContents* CreateWebContents( |
| 25 content::BrowserContext* browser_context, |
| 26 content::SiteInstance* site_instance) override { |
| 27 return content::WebContentsTester::CreateTestWebContents(browser_context, |
| 28 site_instance); |
| 29 } |
| 30 |
| 31 private: |
| 32 DISALLOW_COPY_AND_ASSIGN(AshTestViewsDelegateContent); |
| 33 }; |
| 34 |
| 35 } // namespace |
| 36 |
| 37 // static |
| 38 std::unique_ptr<AshTestEnvironment> AshTestEnvironment::Create() { |
| 39 return base::MakeUnique<AshTestEnvironmentContent>(); |
| 40 } |
| 41 |
| 42 AshTestEnvironmentContent::AshTestEnvironmentContent() |
| 43 : thread_bundle_(base::MakeUnique<content::TestBrowserThreadBundle>()) {} |
| 44 |
| 45 AshTestEnvironmentContent::~AshTestEnvironmentContent() {} |
| 46 |
| 47 void AshTestEnvironmentContent::SetUp() { |
| 48 ShellContentState* content_state = content_state_; |
| 49 if (!content_state) { |
| 50 test_shell_content_state_ = new TestShellContentState; |
| 51 content_state = test_shell_content_state_; |
| 52 } |
| 53 ShellContentState::SetInstance(content_state); |
| 54 } |
| 55 |
| 56 void AshTestEnvironmentContent::TearDown() { |
| 57 ShellContentState::DestroyInstance(); |
| 58 } |
| 59 |
| 60 base::SequencedWorkerPool* AshTestEnvironmentContent::GetBlockingPool() { |
| 61 return content::BrowserThread::GetBlockingPool(); |
| 62 } |
| 63 |
| 64 std::unique_ptr<views::ViewsDelegate> |
| 65 AshTestEnvironmentContent::CreateViewsDelegate() { |
| 66 return base::MakeUnique<AshTestViewsDelegateContent>(); |
| 67 } |
| 68 |
| 69 } // namespace test |
| 70 } // namespace ash |
OLD | NEW |