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" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/extensions/extension_test_message_listener.h" | 12 #include "chrome/browser/extensions/extension_test_message_listener.h" |
13 #include "chrome/browser/extensions/extension_util.h" | 13 #include "chrome/browser/extensions/extension_util.h" |
14 #include "chrome/browser/notifications/desktop_notification_service.h" | 14 #include "chrome/browser/notifications/desktop_notification_service.h" |
15 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 15 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
16 #include "chrome/common/extensions/api/alarms.h" | 16 #include "chrome/common/extensions/api/alarms.h" |
17 #include "content/public/test/browser_test.h" | 17 #include "content/public/test/browser_test.h" |
18 #include "content/public/test/test_utils.h" | 18 #include "content/public/test/test_utils.h" |
19 #include "extensions/browser/event_router.h" | 19 #include "extensions/browser/event_router.h" |
20 #include "extensions/browser/extension_prefs.h" | 20 #include "extensions/browser/extension_prefs.h" |
21 #include "extensions/browser/extension_system.h" | 21 #include "extensions/browser/extension_system.h" |
| 22 #include "extensions/browser/extension_util.h" |
22 #include "extensions/browser/process_manager.h" | 23 #include "extensions/browser/process_manager.h" |
23 #include "extensions/common/switches.h" | 24 #include "extensions/common/switches.h" |
24 #include "ui/message_center/message_center.h" | 25 #include "ui/message_center/message_center.h" |
25 #include "ui/message_center/notifier_settings.h" | 26 #include "ui/message_center/notifier_settings.h" |
26 | 27 |
27 using extensions::Event; | 28 using extensions::Event; |
28 using extensions::EventRouter; | 29 using extensions::EventRouter; |
29 using extensions::Extension; | 30 using extensions::Extension; |
30 using extensions::ExtensionInfo; | 31 using extensions::ExtensionInfo; |
31 using extensions::ExtensionPrefs; | 32 using extensions::ExtensionPrefs; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // Verify that messages are not received while the app is inactive. | 241 // Verify that messages are not received while the app is inactive. |
241 LoadAndLaunchPlatformApp("ephemeral_apps/messaging_sender_fail"); | 242 LoadAndLaunchPlatformApp("ephemeral_apps/messaging_sender_fail"); |
242 EXPECT_TRUE(result_catcher.GetNextResult()); | 243 EXPECT_TRUE(result_catcher.GetNextResult()); |
243 } | 244 } |
244 | 245 |
245 // Verify that an updated ephemeral app will still have its ephemeral flag | 246 // Verify that an updated ephemeral app will still have its ephemeral flag |
246 // enabled. | 247 // enabled. |
247 IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, UpdateEphemeralApp) { | 248 IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, UpdateEphemeralApp) { |
248 const Extension* app_v1 = InstallEphemeralApp(kMessagingReceiverApp); | 249 const Extension* app_v1 = InstallEphemeralApp(kMessagingReceiverApp); |
249 ASSERT_TRUE(app_v1); | 250 ASSERT_TRUE(app_v1); |
250 ASSERT_TRUE(app_v1->is_ephemeral()); | 251 ASSERT_TRUE(extensions::util::IsEphemeralApp(app_v1->id(), profile())); |
251 std::string app_id = app_v1->id(); | 252 std::string app_id = app_v1->id(); |
252 base::Version app_original_version = *app_v1->version(); | 253 base::Version app_original_version = *app_v1->version(); |
253 app_v1 = NULL; // The extension object will be destroyed during update. | 254 app_v1 = NULL; // The extension object will be destroyed during update. |
254 | 255 |
255 // Pack version 2 of the app. | 256 // Pack version 2 of the app. |
256 base::ScopedTempDir temp_dir; | 257 base::ScopedTempDir temp_dir; |
257 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 258 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
258 | 259 |
259 base::FilePath crx_path = temp_dir.path().AppendASCII("temp.crx"); | 260 base::FilePath crx_path = temp_dir.path().AppendASCII("temp.crx"); |
260 if (!base::DeleteFile(crx_path, false)) { | 261 if (!base::DeleteFile(crx_path, false)) { |
(...skipping 16 matching lines...) Expand all Loading... |
277 content::Source<extensions::CrxInstaller>(crx_installer)); | 278 content::Source<extensions::CrxInstaller>(crx_installer)); |
278 ExtensionService* service = | 279 ExtensionService* service = |
279 ExtensionSystem::Get(browser()->profile())->extension_service(); | 280 ExtensionSystem::Get(browser()->profile())->extension_service(); |
280 EXPECT_TRUE(service->UpdateExtension(app_id, app_v2_path, true, | 281 EXPECT_TRUE(service->UpdateExtension(app_id, app_v2_path, true, |
281 &crx_installer)); | 282 &crx_installer)); |
282 windowed_observer.Wait(); | 283 windowed_observer.Wait(); |
283 | 284 |
284 const Extension* app_v2 = service->GetExtensionById(app_id, false); | 285 const Extension* app_v2 = service->GetExtensionById(app_id, false); |
285 ASSERT_TRUE(app_v2); | 286 ASSERT_TRUE(app_v2); |
286 EXPECT_TRUE(app_v2->version()->CompareTo(app_original_version) > 0); | 287 EXPECT_TRUE(app_v2->version()->CompareTo(app_original_version) > 0); |
287 EXPECT_TRUE(app_v2->is_ephemeral()); | 288 EXPECT_TRUE(extensions::util::IsEphemeralApp(app_v2->id(), profile())); |
288 } | 289 } |
289 | 290 |
290 // Verify that if notifications have been disabled for an ephemeral app, it will | 291 // Verify that if notifications have been disabled for an ephemeral app, it will |
291 // remain disabled even after being evicted from the cache. | 292 // remain disabled even after being evicted from the cache. |
292 IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, StickyNotificationSettings) { | 293 IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, StickyNotificationSettings) { |
293 const Extension* app = InstallEphemeralApp(kNotificationsTestApp); | 294 const Extension* app = InstallEphemeralApp(kNotificationsTestApp); |
294 ASSERT_TRUE(app); | 295 ASSERT_TRUE(app); |
295 | 296 |
296 // Disable notifications for this app. | 297 // Disable notifications for this app. |
297 DesktopNotificationService* notification_service = | 298 DesktopNotificationService* notification_service = |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 503 |
503 // The garbage collected app should no longer be in the preferences. | 504 // The garbage collected app should no longer be in the preferences. |
504 extensions_info = prefs->GetEvictedEphemeralAppsInfo(); | 505 extensions_info = prefs->GetEvictedEphemeralAppsInfo(); |
505 EXPECT_TRUE(IsAppInExtensionsInfo(*extensions_info, retain_app_id)); | 506 EXPECT_TRUE(IsAppInExtensionsInfo(*extensions_info, retain_app_id)); |
506 ASSERT_FALSE(IsAppInExtensionsInfo(*extensions_info, evict_app_id)); | 507 ASSERT_FALSE(IsAppInExtensionsInfo(*extensions_info, evict_app_id)); |
507 | 508 |
508 // Reinstall the app and verify that all data has been reset. | 509 // Reinstall the app and verify that all data has been reset. |
509 evict_app = InstallEphemeralApp(kRetainDataApp); | 510 evict_app = InstallEphemeralApp(kRetainDataApp); |
510 ASSERT_TRUE(LaunchAppAndRunTest(evict_app, "DataReset")) << message_; | 511 ASSERT_TRUE(LaunchAppAndRunTest(evict_app, "DataReset")) << message_; |
511 } | 512 } |
OLD | NEW |