OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "apps/test/app_shell_test.h" | 5 #include "apps/shell/test/shell_test.h" |
6 | 6 |
7 #include "apps/shell/browser/shell_content_browser_client.h" | 7 #include "apps/shell/browser/shell_content_browser_client.h" |
| 8 #include "apps/shell/browser/shell_desktop_controller.h" |
8 #include "apps/shell/browser/shell_extension_system.h" | 9 #include "apps/shell/browser/shell_extension_system.h" |
| 10 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "content/public/common/content_switches.h" |
11 #include "extensions/browser/extension_system.h" | 14 #include "extensions/browser/extension_system.h" |
12 | 15 |
13 namespace apps { | 16 namespace apps { |
14 | 17 |
15 AppShellTest::AppShellTest() | 18 AppShellTest::AppShellTest() |
16 : browser_context_(NULL), extension_system_(NULL) {} | 19 : browser_context_(NULL), extension_system_(NULL) {} |
17 | 20 |
18 AppShellTest::~AppShellTest() {} | 21 AppShellTest::~AppShellTest() {} |
19 | 22 |
| 23 void AppShellTest::SetUp() { |
| 24 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 25 command_line->AppendSwitchASCII(switches::kTestType, "appshell"); |
| 26 content::BrowserTestBase::SetUp(); |
| 27 } |
| 28 |
20 void AppShellTest::SetUpOnMainThread() { | 29 void AppShellTest::SetUpOnMainThread() { |
21 browser_context_ = ShellContentBrowserClient::Get()->GetBrowserContext(); | 30 browser_context_ = ShellContentBrowserClient::Get()->GetBrowserContext(); |
22 | 31 |
23 extension_system_ = static_cast<extensions::ShellExtensionSystem*>( | 32 extension_system_ = static_cast<extensions::ShellExtensionSystem*>( |
24 extensions::ExtensionSystem::Get(browser_context_)); | 33 extensions::ExtensionSystem::Get(browser_context_)); |
25 } | 34 } |
26 | 35 |
27 void AppShellTest::RunTestOnMainThreadLoop() { | 36 void AppShellTest::RunTestOnMainThreadLoop() { |
28 // Pump startup related events. | |
29 base::MessageLoopForUI::current()->RunUntilIdle(); | 37 base::MessageLoopForUI::current()->RunUntilIdle(); |
30 | 38 |
31 SetUpOnMainThread(); | 39 SetUpOnMainThread(); |
32 | 40 |
33 RunTestOnMainThread(); | 41 RunTestOnMainThread(); |
34 | 42 |
35 TearDownOnMainThread(); | 43 TearDownOnMainThread(); |
| 44 |
| 45 // Clean up the app window. |
| 46 ShellDesktopController::instance()->CloseAppWindow(); |
36 } | 47 } |
37 | 48 |
38 bool AppShellTest::LoadAndLaunchApp(const base::FilePath& app_dir) { | 49 bool AppShellTest::LoadAndLaunchApp(const base::FilePath& app_dir) { |
39 return extension_system_->LoadAndLaunchApp(app_dir); | 50 return extension_system_->LoadAndLaunchApp(app_dir); |
40 } | 51 } |
41 | 52 |
42 } // namespace apps | 53 } // namespace apps |
OLD | NEW |