| 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/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "chrome/browser/extensions/api/tabs/tabs.h" | 9 #include "chrome/browser/extensions/api/tabs/tabs.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/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/extensions/application_launch.h" | 13 #include "chrome/browser/ui/extensions/application_launch.h" |
| 14 #include "chrome/browser/ui/extensions/shell_window.h" | 14 #include "chrome/browser/ui/extensions/shell_window.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/test/base/ui_test_utils.h" | |
| 17 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/test/test_utils.h" |
| 18 | 18 |
| 19 using content::WebContents; | 19 using content::WebContents; |
| 20 using extensions::Extension; | 20 using extensions::Extension; |
| 21 | 21 |
| 22 namespace utils = extension_function_test_utils; | 22 namespace utils = extension_function_test_utils; |
| 23 | 23 |
| 24 void PlatformAppBrowserTest::SetUpCommandLine( | 24 void PlatformAppBrowserTest::SetUpCommandLine( |
| 25 CommandLine* command_line) { | 25 CommandLine* command_line) { |
| 26 ExtensionBrowserTest::SetUpCommandLine(command_line); | 26 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 27 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | 27 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
| 28 } | 28 } |
| 29 | 29 |
| 30 const Extension* PlatformAppBrowserTest::LoadAndLaunchPlatformApp( | 30 const Extension* PlatformAppBrowserTest::LoadAndLaunchPlatformApp( |
| 31 const char* name) { | 31 const char* name) { |
| 32 ui_test_utils::WindowedNotificationObserver app_loaded_observer( | 32 content::WindowedNotificationObserver app_loaded_observer( |
| 33 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 33 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 34 content::NotificationService::AllSources()); | 34 content::NotificationService::AllSources()); |
| 35 | 35 |
| 36 const Extension* extension = LoadExtension( | 36 const Extension* extension = LoadExtension( |
| 37 test_data_dir_.AppendASCII("platform_apps").AppendASCII(name)); | 37 test_data_dir_.AppendASCII("platform_apps").AppendASCII(name)); |
| 38 EXPECT_TRUE(extension); | 38 EXPECT_TRUE(extension); |
| 39 | 39 |
| 40 application_launch::OpenApplication(application_launch::LaunchParams( | 40 application_launch::OpenApplication(application_launch::LaunchParams( |
| 41 browser()->profile(), extension, extension_misc::LAUNCH_NONE, | 41 browser()->profile(), extension, extension_misc::LAUNCH_NONE, |
| 42 NEW_WINDOW)); | 42 NEW_WINDOW)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 ShellWindow* PlatformAppBrowserTest::CreateShellWindow( | 106 ShellWindow* PlatformAppBrowserTest::CreateShellWindow( |
| 107 const Extension* extension) { | 107 const Extension* extension) { |
| 108 ShellWindow::CreateParams params; | 108 ShellWindow::CreateParams params; |
| 109 return ShellWindow::Create( | 109 return ShellWindow::Create( |
| 110 browser()->profile(), extension, GURL(""), params); | 110 browser()->profile(), extension, GURL(""), params); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void PlatformAppBrowserTest::CloseShellWindow(ShellWindow* window) { | 113 void PlatformAppBrowserTest::CloseShellWindow(ShellWindow* window) { |
| 114 ui_test_utils::WindowedNotificationObserver destroyed_observer( | 114 content::WindowedNotificationObserver destroyed_observer( |
| 115 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 115 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 116 content::NotificationService::AllSources()); | 116 content::NotificationService::AllSources()); |
| 117 window->Close(); | 117 window->Close(); |
| 118 destroyed_observer.Wait(); | 118 destroyed_observer.Wait(); |
| 119 } | 119 } |
| OLD | NEW |