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