OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
tapted
2013/01/16 23:56:38
nit: should this be 2013, too?
benwells
2013/01/21 11:12:18
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "apps/app_restore_service.h" | |
6 #include "apps/app_restore_service_factory.h" | |
7 #include "chrome/browser/extensions/extension_prefs.h" | |
8 #include "chrome/browser/extensions/extension_service.h" | |
9 #include "chrome/browser/extensions/extension_system.h" | |
10 #include "chrome/browser/extensions/extension_test_message_listener.h" | |
11 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | |
12 #include "chrome/common/extensions/extension.h" | |
13 #include "content/public/test/test_utils.h" | |
14 | |
15 using extensions::Extension; | |
16 using extensions::ExtensionPrefs; | |
17 using extensions::ExtensionSystem; | |
18 // TODO(benwells): Move PlatformAppBrowserTest to apps namespace in apps | |
19 // component. | |
20 using extensions::PlatformAppBrowserTest; | |
21 | |
22 namespace apps { | |
23 | |
24 // Tests that a running app is recorded in the preferences as such. | |
25 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) { | |
26 content::WindowedNotificationObserver extension_suspended( | |
27 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | |
28 content::NotificationService::AllSources()); | |
29 | |
30 const Extension* extension = LoadExtension( | |
31 test_data_dir_.AppendASCII("platform_apps/restart_test")); | |
32 ASSERT_TRUE(extension); | |
33 ExtensionService* extension_service = | |
34 ExtensionSystem::Get(browser()->profile())->extension_service(); | |
35 ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); | |
36 | |
37 // App is running. | |
38 ASSERT_TRUE(extension_prefs->IsExtensionRunning(extension->id())); | |
39 | |
40 // Wait for the extension to get suspended. | |
41 extension_suspended.Wait(); | |
42 | |
43 // App isn't running because it got suspended. | |
44 ASSERT_FALSE(extension_prefs->IsExtensionRunning(extension->id())); | |
45 | |
46 // Pretend that the app is supposed to be running. | |
47 extension_prefs->SetExtensionRunning(extension->id(), true); | |
48 | |
49 ExtensionTestMessageListener restart_listener("onRestarted", false); | |
50 apps::AppRestoreServiceFactory::GetForProfile(browser()->profile())-> | |
51 HandleStartup(true); | |
52 restart_listener.WaitUntilSatisfied(); | |
53 } | |
54 | |
55 } // apps | |
tapted
2013/01/16 23:56:38
nit: missing 'namespace' in comment
benwells
2013/01/21 11:12:18
Done.
| |
OLD | NEW |