| 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 "chrome/browser/extensions/platform_app_browsertest_util.h" | 5 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/extensions/api/tabs/tabs_api.h" | 9 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
| 10 #include "chrome/browser/extensions/extension_function_test_utils.h" | 10 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 11 #include "chrome/browser/extensions/shell_window_registry.h" | 11 #include "chrome/browser/extensions/shell_window_registry.h" |
| 12 #include "chrome/browser/ui/apps/chrome_shell_window_delegate.h" |
| 12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/extensions/application_launch.h" | 14 #include "chrome/browser/ui/extensions/application_launch.h" |
| 14 #include "chrome/browser/ui/extensions/native_app_window.h" | 15 #include "chrome/browser/ui/extensions/native_app_window.h" |
| 15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 16 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/test/test_utils.h" | 18 #include "content/public/test/test_utils.h" |
| 18 | 19 |
| 20 using apps::ShellWindow; |
| 19 using content::WebContents; | 21 using content::WebContents; |
| 20 | 22 |
| 21 namespace utils = extension_function_test_utils; | 23 namespace utils = extension_function_test_utils; |
| 22 | 24 |
| 23 namespace extensions { | 25 namespace extensions { |
| 24 | 26 |
| 25 PlatformAppBrowserTest::PlatformAppBrowserTest() { | 27 PlatformAppBrowserTest::PlatformAppBrowserTest() { |
| 26 ShellWindow::DisableExternalOpenForTesting(); | 28 chrome::ChromeShellWindowDelegate::DisableExternalOpenForTesting(); |
| 27 } | 29 } |
| 28 | 30 |
| 29 void PlatformAppBrowserTest::SetUpCommandLine(CommandLine* command_line) { | 31 void PlatformAppBrowserTest::SetUpCommandLine(CommandLine* command_line) { |
| 30 // Skips ExtensionApiTest::SetUpCommandLine. | 32 // Skips ExtensionApiTest::SetUpCommandLine. |
| 31 ExtensionBrowserTest::SetUpCommandLine(command_line); | 33 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 32 | 34 |
| 33 // Make event pages get suspended quicker. | 35 // Make event pages get suspended quicker. |
| 34 command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1"); | 36 command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1"); |
| 35 command_line->AppendSwitchASCII(switches::kEventPageSuspendingTime, "1"); | 37 command_line->AppendSwitchASCII(switches::kEventPageSuspendingTime, "1"); |
| 36 } | 38 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 141 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 140 base::FilePath test_doc(test_data_dir_.AppendASCII(test_file)); | 142 base::FilePath test_doc(test_data_dir_.AppendASCII(test_file)); |
| 141 test_doc = test_doc.NormalizePathSeparators(); | 143 test_doc = test_doc.NormalizePathSeparators(); |
| 142 command_line->AppendArgPath(test_doc); | 144 command_line->AppendArgPath(test_doc); |
| 143 } | 145 } |
| 144 | 146 |
| 145 ShellWindow* PlatformAppBrowserTest::CreateShellWindow( | 147 ShellWindow* PlatformAppBrowserTest::CreateShellWindow( |
| 146 const Extension* extension) { | 148 const Extension* extension) { |
| 147 ShellWindow::CreateParams params; | 149 ShellWindow::CreateParams params; |
| 148 return ShellWindow::Create( | 150 return ShellWindow::Create( |
| 149 browser()->profile(), extension, GURL(std::string()), params); | 151 browser()->profile(), new chrome::ChromeShellWindowDelegate(), |
| 152 extension, GURL(std::string()), params); |
| 150 } | 153 } |
| 151 | 154 |
| 152 ShellWindow* PlatformAppBrowserTest::CreateShellWindowFromParams( | 155 ShellWindow* PlatformAppBrowserTest::CreateShellWindowFromParams( |
| 153 const Extension* extension, const ShellWindow::CreateParams& params) { | 156 const Extension* extension, const ShellWindow::CreateParams& params) { |
| 154 return ShellWindow::Create( | 157 return ShellWindow::Create( |
| 155 browser()->profile(), extension, GURL(std::string()), params); | 158 browser()->profile(), new chrome::ChromeShellWindowDelegate(), |
| 159 extension, GURL(std::string()), params); |
| 156 } | 160 } |
| 157 | 161 |
| 158 void PlatformAppBrowserTest::CloseShellWindow(ShellWindow* window) { | 162 void PlatformAppBrowserTest::CloseShellWindow(ShellWindow* window) { |
| 159 content::WindowedNotificationObserver destroyed_observer( | 163 content::WindowedNotificationObserver destroyed_observer( |
| 160 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 164 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 161 content::NotificationService::AllSources()); | 165 content::NotificationService::AllSources()); |
| 162 window->GetBaseWindow()->Close(); | 166 window->GetBaseWindow()->Close(); |
| 163 destroyed_observer.Wait(); | 167 destroyed_observer.Wait(); |
| 164 } | 168 } |
| 165 | 169 |
| 166 void ExperimentalPlatformAppBrowserTest::SetUpCommandLine( | 170 void ExperimentalPlatformAppBrowserTest::SetUpCommandLine( |
| 167 CommandLine* command_line) { | 171 CommandLine* command_line) { |
| 168 PlatformAppBrowserTest::SetUpCommandLine(command_line); | 172 PlatformAppBrowserTest::SetUpCommandLine(command_line); |
| 169 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | 173 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
| 170 } | 174 } |
| 171 | 175 |
| 172 } // namespace extensions | 176 } // namespace extensions |
| OLD | NEW |