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/saved_files_service.h" | 5 #include "apps/saved_files_service.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "chrome/browser/apps/app_browsertest_util.h" | 8 #include "chrome/browser/apps/app_browsertest_util.h" |
9 #include "chrome/browser/apps/ephemeral_app_service.h" | 9 #include "chrome/browser/apps/ephemeral_app_service.h" |
10 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 10 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // Verify that ephemeral apps can be launched and receive system events when | 197 // Verify that ephemeral apps can be launched and receive system events when |
198 // they are running. Once they are inactive they should not receive system | 198 // they are running. Once they are inactive they should not receive system |
199 // events. | 199 // events. |
200 IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, EventDispatchWhenLaunched) { | 200 IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, EventDispatchWhenLaunched) { |
201 const Extension* extension = | 201 const Extension* extension = |
202 InstallAndLaunchEphemeralApp(kDispatchEventTestApp); | 202 InstallAndLaunchEphemeralApp(kDispatchEventTestApp); |
203 ASSERT_TRUE(extension); | 203 ASSERT_TRUE(extension); |
204 | 204 |
205 // Send a fake alarm event to the app and verify that a response is | 205 // Send a fake alarm event to the app and verify that a response is |
206 // received. | 206 // received. |
207 EventRouter* event_router = | 207 EventRouter* event_router = EventRouter::Get(browser()->profile()); |
208 ExtensionSystem::Get(browser()->profile())->event_router(); | |
209 ASSERT_TRUE(event_router); | 208 ASSERT_TRUE(event_router); |
210 | 209 |
211 ExtensionTestMessageListener alarm_received_listener("alarm_received", false); | 210 ExtensionTestMessageListener alarm_received_listener("alarm_received", false); |
212 DispatchAlarmEvent(event_router, extension->id()); | 211 DispatchAlarmEvent(event_router, extension->id()); |
213 ASSERT_TRUE(alarm_received_listener.WaitUntilSatisfied()); | 212 ASSERT_TRUE(alarm_received_listener.WaitUntilSatisfied()); |
214 | 213 |
215 CloseApp(extension->id()); | 214 CloseApp(extension->id()); |
216 | 215 |
217 // The app needs to be launched once in order to have the onAlarm() event | 216 // The app needs to be launched once in order to have the onAlarm() event |
218 // registered. | 217 // registered. |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 | 502 |
504 // The garbage collected app should no longer be in the preferences. | 503 // The garbage collected app should no longer be in the preferences. |
505 extensions_info = prefs->GetEvictedEphemeralAppsInfo(); | 504 extensions_info = prefs->GetEvictedEphemeralAppsInfo(); |
506 EXPECT_TRUE(IsAppInExtensionsInfo(*extensions_info, retain_app_id)); | 505 EXPECT_TRUE(IsAppInExtensionsInfo(*extensions_info, retain_app_id)); |
507 ASSERT_FALSE(IsAppInExtensionsInfo(*extensions_info, evict_app_id)); | 506 ASSERT_FALSE(IsAppInExtensionsInfo(*extensions_info, evict_app_id)); |
508 | 507 |
509 // Reinstall the app and verify that all data has been reset. | 508 // Reinstall the app and verify that all data has been reset. |
510 evict_app = InstallEphemeralApp(kRetainDataApp); | 509 evict_app = InstallEphemeralApp(kRetainDataApp); |
511 ASSERT_TRUE(LaunchAppAndRunTest(evict_app, "DataReset")) << message_; | 510 ASSERT_TRUE(LaunchAppAndRunTest(evict_app, "DataReset")) << message_; |
512 } | 511 } |
OLD | NEW |