| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "apps/launcher.h" | 9 #include "apps/launcher.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 extensions::ResultCatcher catcher; | 224 extensions::ResultCatcher catcher; |
| 225 | 225 |
| 226 base::FilePath extension_path = test_data_dir_.AppendASCII(extension_name); | 226 base::FilePath extension_path = test_data_dir_.AppendASCII(extension_name); |
| 227 const extensions::Extension* extension = | 227 const extensions::Extension* extension = |
| 228 LoadExtensionWithFlags(extension_path, ExtensionBrowserTest::kFlagNone); | 228 LoadExtensionWithFlags(extension_path, ExtensionBrowserTest::kFlagNone); |
| 229 if (!extension) { | 229 if (!extension) { |
| 230 message_ = "Failed to load extension."; | 230 message_ = "Failed to load extension."; |
| 231 return false; | 231 return false; |
| 232 } | 232 } |
| 233 | 233 |
| 234 AppLaunchParams params(browser()->profile(), extension, | 234 AppLaunchParams params( |
| 235 extensions::LAUNCH_CONTAINER_NONE, NEW_WINDOW, | 235 browser()->profile(), extension, extensions::LAUNCH_CONTAINER_NONE, |
| 236 extensions::SOURCE_TEST); | 236 WindowOpenDisposition::NEW_WINDOW, extensions::SOURCE_TEST); |
| 237 params.command_line = command_line; | 237 params.command_line = command_line; |
| 238 params.current_directory = test_data_dir_; | 238 params.current_directory = test_data_dir_; |
| 239 OpenApplication(params); | 239 OpenApplication(params); |
| 240 | 240 |
| 241 if (!catcher.GetNextResult()) { | 241 if (!catcher.GetNextResult()) { |
| 242 message_ = catcher.message(); | 242 message_ = catcher.message(); |
| 243 return false; | 243 return false; |
| 244 } | 244 } |
| 245 | 245 |
| 246 return true; | 246 return true; |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 | 873 |
| 874 if (test_flags & RELAUNCH) { | 874 if (test_flags & RELAUNCH) { |
| 875 // Close the AppWindow, and ensure it is gone. | 875 // Close the AppWindow, and ensure it is gone. |
| 876 CloseAppWindow(window); | 876 CloseAppWindow(window); |
| 877 ASSERT_FALSE(GetFirstAppWindow()); | 877 ASSERT_FALSE(GetFirstAppWindow()); |
| 878 | 878 |
| 879 // Relaunch the app and get a new AppWindow. | 879 // Relaunch the app and get a new AppWindow. |
| 880 content::WindowedNotificationObserver app_loaded_observer( | 880 content::WindowedNotificationObserver app_loaded_observer( |
| 881 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 881 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 882 content::NotificationService::AllSources()); | 882 content::NotificationService::AllSources()); |
| 883 OpenApplication(AppLaunchParams(browser()->profile(), extension, | 883 OpenApplication(AppLaunchParams( |
| 884 LAUNCH_CONTAINER_NONE, NEW_WINDOW, | 884 browser()->profile(), extension, LAUNCH_CONTAINER_NONE, |
| 885 extensions::SOURCE_TEST)); | 885 WindowOpenDisposition::NEW_WINDOW, extensions::SOURCE_TEST)); |
| 886 app_loaded_observer.Wait(); | 886 app_loaded_observer.Wait(); |
| 887 window = GetFirstAppWindow(); | 887 window = GetFirstAppWindow(); |
| 888 ASSERT_TRUE(window); | 888 ASSERT_TRUE(window); |
| 889 | 889 |
| 890 // DevTools should have reopened with the relaunch. | 890 // DevTools should have reopened with the relaunch. |
| 891 web_contents = window->web_contents(); | 891 web_contents = window->web_contents(); |
| 892 ASSERT_TRUE(web_contents); | 892 ASSERT_TRUE(web_contents); |
| 893 ASSERT_TRUE(DevToolsAgentHost::HasFor(web_contents)); | 893 ASSERT_TRUE(DevToolsAgentHost::HasFor(web_contents)); |
| 894 } | 894 } |
| 895 } | 895 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 content::NotificationService::AllSources()); | 1004 content::NotificationService::AllSources()); |
| 1005 | 1005 |
| 1006 const Extension* extension = LoadExtensionAsComponent( | 1006 const Extension* extension = LoadExtensionAsComponent( |
| 1007 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component")); | 1007 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component")); |
| 1008 ASSERT_TRUE(extension); | 1008 ASSERT_TRUE(extension); |
| 1009 | 1009 |
| 1010 app_loaded_observer.Wait(); | 1010 app_loaded_observer.Wait(); |
| 1011 ASSERT_TRUE(should_install.seen()); | 1011 ASSERT_TRUE(should_install.seen()); |
| 1012 | 1012 |
| 1013 ExtensionTestMessageListener launched_listener("Launched", false); | 1013 ExtensionTestMessageListener launched_listener("Launched", false); |
| 1014 OpenApplication(AppLaunchParams(browser()->profile(), extension, | 1014 OpenApplication(AppLaunchParams( |
| 1015 LAUNCH_CONTAINER_NONE, NEW_WINDOW, | 1015 browser()->profile(), extension, LAUNCH_CONTAINER_NONE, |
| 1016 extensions::SOURCE_TEST)); | 1016 WindowOpenDisposition::NEW_WINDOW, extensions::SOURCE_TEST)); |
| 1017 | 1017 |
| 1018 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 1018 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 // Component App Test 2 of 3: ensure an installed component app can be launched | 1021 // Component App Test 2 of 3: ensure an installed component app can be launched |
| 1022 // on a subsequent browser start, without requiring any install/upgrade logic | 1022 // on a subsequent browser start, without requiring any install/upgrade logic |
| 1023 // to be run, then perform setup for step 3. | 1023 // to be run, then perform setup for step 3. |
| 1024 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, | 1024 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, |
| 1025 PRE_ComponentAppBackgroundPage) { | 1025 PRE_ComponentAppBackgroundPage) { |
| 1026 // Since the component app is now installed, re-adding it in the same profile | 1026 // Since the component app is now installed, re-adding it in the same profile |
| 1027 // should not cause it to be re-installed. Instead, we wait for the OnLaunched | 1027 // should not cause it to be re-installed. Instead, we wait for the OnLaunched |
| 1028 // in a different observer (which would timeout if not the app was not | 1028 // in a different observer (which would timeout if not the app was not |
| 1029 // previously installed properly) and then check this observer to make sure it | 1029 // previously installed properly) and then check this observer to make sure it |
| 1030 // never saw the NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED event. | 1030 // never saw the NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED event. |
| 1031 CheckExtensionInstalledObserver should_not_install(browser()->profile()); | 1031 CheckExtensionInstalledObserver should_not_install(browser()->profile()); |
| 1032 const Extension* extension = LoadExtensionAsComponent( | 1032 const Extension* extension = LoadExtensionAsComponent( |
| 1033 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component")); | 1033 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component")); |
| 1034 ASSERT_TRUE(extension); | 1034 ASSERT_TRUE(extension); |
| 1035 | 1035 |
| 1036 ExtensionTestMessageListener launched_listener("Launched", false); | 1036 ExtensionTestMessageListener launched_listener("Launched", false); |
| 1037 OpenApplication(AppLaunchParams(browser()->profile(), extension, | 1037 OpenApplication(AppLaunchParams( |
| 1038 LAUNCH_CONTAINER_NONE, NEW_WINDOW, | 1038 browser()->profile(), extension, LAUNCH_CONTAINER_NONE, |
| 1039 extensions::SOURCE_TEST)); | 1039 WindowOpenDisposition::NEW_WINDOW, extensions::SOURCE_TEST)); |
| 1040 | 1040 |
| 1041 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 1041 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| 1042 ASSERT_FALSE(should_not_install.seen()); | 1042 ASSERT_FALSE(should_not_install.seen()); |
| 1043 | 1043 |
| 1044 // Simulate a "downgrade" from version 2 in the test manifest.json to 1. | 1044 // Simulate a "downgrade" from version 2 in the test manifest.json to 1. |
| 1045 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(browser()->profile()); | 1045 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(browser()->profile()); |
| 1046 | 1046 |
| 1047 // Clear the registered events to ensure they are updated. | 1047 // Clear the registered events to ensure they are updated. |
| 1048 extensions::EventRouter::Get(browser()->profile()) | 1048 extensions::EventRouter::Get(browser()->profile()) |
| 1049 ->SetRegisteredEvents(extension->id(), std::set<std::string>()); | 1049 ->SetRegisteredEvents(extension->id(), std::set<std::string>()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1065 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 1065 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 1066 content::NotificationService::AllSources()); | 1066 content::NotificationService::AllSources()); |
| 1067 | 1067 |
| 1068 const Extension* extension = LoadExtensionAsComponent( | 1068 const Extension* extension = LoadExtensionAsComponent( |
| 1069 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component")); | 1069 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component")); |
| 1070 ASSERT_TRUE(extension); | 1070 ASSERT_TRUE(extension); |
| 1071 app_loaded_observer.Wait(); | 1071 app_loaded_observer.Wait(); |
| 1072 ASSERT_TRUE(should_install.seen()); | 1072 ASSERT_TRUE(should_install.seen()); |
| 1073 | 1073 |
| 1074 ExtensionTestMessageListener launched_listener("Launched", false); | 1074 ExtensionTestMessageListener launched_listener("Launched", false); |
| 1075 OpenApplication(AppLaunchParams(browser()->profile(), extension, | 1075 OpenApplication(AppLaunchParams( |
| 1076 LAUNCH_CONTAINER_NONE, NEW_WINDOW, | 1076 browser()->profile(), extension, LAUNCH_CONTAINER_NONE, |
| 1077 extensions::SOURCE_TEST)); | 1077 WindowOpenDisposition::NEW_WINDOW, extensions::SOURCE_TEST)); |
| 1078 | 1078 |
| 1079 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 1079 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| 1080 } | 1080 } |
| 1081 | 1081 |
| 1082 // Disabled due to flakiness. http://crbug.com/468609 | 1082 // Disabled due to flakiness. http://crbug.com/468609 |
| 1083 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, | 1083 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, |
| 1084 DISABLED_ComponentExtensionRuntimeReload) { | 1084 DISABLED_ComponentExtensionRuntimeReload) { |
| 1085 // Ensure that we wait until the background page is run (to register the | 1085 // Ensure that we wait until the background page is run (to register the |
| 1086 // OnLaunched listener) before trying to open the application. This is similar | 1086 // OnLaunched listener) before trying to open the application. This is similar |
| 1087 // to LoadAndLaunchPlatformApp, but we want to load as a component extension. | 1087 // to LoadAndLaunchPlatformApp, but we want to load as a component extension. |
| 1088 content::WindowedNotificationObserver app_loaded_observer( | 1088 content::WindowedNotificationObserver app_loaded_observer( |
| 1089 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 1089 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 1090 content::NotificationService::AllSources()); | 1090 content::NotificationService::AllSources()); |
| 1091 | 1091 |
| 1092 const Extension* extension = LoadExtensionAsComponent( | 1092 const Extension* extension = LoadExtensionAsComponent( |
| 1093 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component")); | 1093 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component")); |
| 1094 ASSERT_TRUE(extension); | 1094 ASSERT_TRUE(extension); |
| 1095 | 1095 |
| 1096 app_loaded_observer.Wait(); | 1096 app_loaded_observer.Wait(); |
| 1097 | 1097 |
| 1098 { | 1098 { |
| 1099 ExtensionTestMessageListener launched_listener("Launched", false); | 1099 ExtensionTestMessageListener launched_listener("Launched", false); |
| 1100 OpenApplication(AppLaunchParams(browser()->profile(), extension, | 1100 OpenApplication(AppLaunchParams( |
| 1101 LAUNCH_CONTAINER_NONE, NEW_WINDOW, | 1101 browser()->profile(), extension, LAUNCH_CONTAINER_NONE, |
| 1102 extensions::SOURCE_TEST)); | 1102 WindowOpenDisposition::NEW_WINDOW, extensions::SOURCE_TEST)); |
| 1103 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 1103 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| 1104 } | 1104 } |
| 1105 | 1105 |
| 1106 { | 1106 { |
| 1107 ExtensionTestMessageListener launched_listener("Launched", false); | 1107 ExtensionTestMessageListener launched_listener("Launched", false); |
| 1108 ASSERT_TRUE(ExecuteScriptInBackgroundPageNoWait( | 1108 ASSERT_TRUE(ExecuteScriptInBackgroundPageNoWait( |
| 1109 extension->id(), | 1109 extension->id(), |
| 1110 // NoWait actually waits for a domAutomationController.send() which is | 1110 // NoWait actually waits for a domAutomationController.send() which is |
| 1111 // implicitly append to the script. Since reload() restarts the | 1111 // implicitly append to the script. Since reload() restarts the |
| 1112 // extension, the send after reload may not get executed. To get around | 1112 // extension, the send after reload may not get executed. To get around |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 file_manager->id(), app_runtime::OnLaunched::kEventName)) { | 1237 file_manager->id(), app_runtime::OnLaunched::kEventName)) { |
| 1238 content::RunAllPendingInMessageLoop(); | 1238 content::RunAllPendingInMessageLoop(); |
| 1239 } | 1239 } |
| 1240 | 1240 |
| 1241 // Listen for new app windows so we see the file manager app launch itself. | 1241 // Listen for new app windows so we see the file manager app launch itself. |
| 1242 AppWindowRegistry* registry = AppWindowRegistry::Get(incognito_profile); | 1242 AppWindowRegistry* registry = AppWindowRegistry::Get(incognito_profile); |
| 1243 ASSERT_TRUE(registry != NULL); | 1243 ASSERT_TRUE(registry != NULL); |
| 1244 registry->AddObserver(this); | 1244 registry->AddObserver(this); |
| 1245 | 1245 |
| 1246 OpenApplication(CreateAppLaunchParamsUserContainer( | 1246 OpenApplication(CreateAppLaunchParamsUserContainer( |
| 1247 incognito_profile, file_manager, NEW_FOREGROUND_TAB, | 1247 incognito_profile, file_manager, |
| 1248 extensions::SOURCE_TEST)); | 1248 WindowOpenDisposition::NEW_FOREGROUND_TAB, extensions::SOURCE_TEST)); |
| 1249 | 1249 |
| 1250 while (!base::ContainsKey(opener_app_ids_, file_manager->id())) { | 1250 while (!base::ContainsKey(opener_app_ids_, file_manager->id())) { |
| 1251 content::RunAllPendingInMessageLoop(); | 1251 content::RunAllPendingInMessageLoop(); |
| 1252 } | 1252 } |
| 1253 } | 1253 } |
| 1254 | 1254 |
| 1255 class RestartDeviceTest : public PlatformAppBrowserTest { | 1255 class RestartDeviceTest : public PlatformAppBrowserTest { |
| 1256 public: | 1256 public: |
| 1257 RestartDeviceTest() | 1257 RestartDeviceTest() |
| 1258 : power_manager_client_(NULL), | 1258 : power_manager_client_(NULL), |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1385 // https://crbug.com/620194. | 1385 // https://crbug.com/620194. |
| 1386 #define MAYBE_AppWindowIframe DISABLED_AppWindowIframe | 1386 #define MAYBE_AppWindowIframe DISABLED_AppWindowIframe |
| 1387 // Sends chrome.test.sendMessage from chrome.app.window.create's callback. | 1387 // Sends chrome.test.sendMessage from chrome.app.window.create's callback. |
| 1388 // The app window also adds an <iframe> to the page during window.onload. | 1388 // The app window also adds an <iframe> to the page during window.onload. |
| 1389 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_AppWindowIframe) { | 1389 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_AppWindowIframe) { |
| 1390 LoadAndLaunchPlatformApp("app_window_send_message", | 1390 LoadAndLaunchPlatformApp("app_window_send_message", |
| 1391 "APP_WINDOW_CREATE_CALLBACK"); | 1391 "APP_WINDOW_CREATE_CALLBACK"); |
| 1392 } | 1392 } |
| 1393 | 1393 |
| 1394 } // namespace extensions | 1394 } // namespace extensions |
| OLD | NEW |