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/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 | 930 |
931 // Tests that an app calling chrome.runtime.reload will reload the app and | 931 // Tests that an app calling chrome.runtime.reload will reload the app and |
932 // relaunch it if it was running. | 932 // relaunch it if it was running. |
933 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) { | 933 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) { |
934 ExtensionTestMessageListener launched_listener("Launched", true); | 934 ExtensionTestMessageListener launched_listener("Launched", true); |
935 const Extension* extension = | 935 const Extension* extension = |
936 LoadAndLaunchPlatformApp("reload", &launched_listener); | 936 LoadAndLaunchPlatformApp("reload", &launched_listener); |
937 ASSERT_TRUE(extension); | 937 ASSERT_TRUE(extension); |
938 ASSERT_TRUE(GetFirstAppWindow()); | 938 ASSERT_TRUE(GetFirstAppWindow()); |
939 | 939 |
940 // Now tell the app to reload itself | 940 // Now tell the app to reload itself. |
941 ExtensionTestMessageListener launched_listener2("Launched", false); | 941 ExtensionTestMessageListener launched_listener2("Launched", false); |
942 launched_listener.Reply("reload"); | 942 launched_listener.Reply("reload"); |
943 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied()); | 943 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied()); |
944 ASSERT_TRUE(GetFirstAppWindow()); | 944 ASSERT_TRUE(GetFirstAppWindow()); |
945 } | 945 } |
946 | 946 |
| 947 // Tests that reloading a component app loads its (lazy) background page. |
| 948 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, |
| 949 ComponentReloadLoadsLazyBackgroundPage) { |
| 950 ExtensionTestMessageListener launched_listener("Launched", true); |
| 951 const Extension* component_app = LoadExtensionAsComponentWithManifest( |
| 952 test_data_dir_.AppendASCII("platform_apps") |
| 953 .AppendASCII("component_reload"), |
| 954 FILE_PATH_LITERAL("manifest.json")); |
| 955 ASSERT_TRUE(component_app); |
| 956 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| 957 |
| 958 // Now tell the app to reload itself. |
| 959 ExtensionTestMessageListener launched_listener2("Launched", false); |
| 960 launched_listener.Reply("reload"); |
| 961 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied()); |
| 962 } |
| 963 |
947 namespace { | 964 namespace { |
948 | 965 |
949 // Utility class to ensure extension installation does or does not occur in | 966 // Utility class to ensure extension installation does or does not occur in |
950 // certain scenarios. | 967 // certain scenarios. |
951 class CheckExtensionInstalledObserver | 968 class CheckExtensionInstalledObserver |
952 : public extensions::ExtensionRegistryObserver { | 969 : public extensions::ExtensionRegistryObserver { |
953 public: | 970 public: |
954 explicit CheckExtensionInstalledObserver(Profile* profile) | 971 explicit CheckExtensionInstalledObserver(Profile* profile) |
955 : seen_(false), registry_(extensions::ExtensionRegistry::Get(profile)) { | 972 : seen_(false), registry_(extensions::ExtensionRegistry::Get(profile)) { |
956 registry_->AddObserver(this); | 973 registry_->AddObserver(this); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 } | 1382 } |
1366 | 1383 |
1367 // Sends chrome.test.sendMessage from chrome.app.window.create's callback. | 1384 // Sends chrome.test.sendMessage from chrome.app.window.create's callback. |
1368 // The app window also adds an <iframe> to the page during window.onload. | 1385 // The app window also adds an <iframe> to the page during window.onload. |
1369 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWindowIframe) { | 1386 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWindowIframe) { |
1370 LoadAndLaunchPlatformApp("app_window_send_message", | 1387 LoadAndLaunchPlatformApp("app_window_send_message", |
1371 "APP_WINDOW_CREATE_CALLBACK"); | 1388 "APP_WINDOW_CREATE_CALLBACK"); |
1372 } | 1389 } |
1373 | 1390 |
1374 } // namespace extensions | 1391 } // namespace extensions |
OLD | NEW |