OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "apps/app_restore_service.h" | 5 #include "apps/app_restore_service.h" |
6 #include "apps/app_restore_service_factory.h" | 6 #include "apps/app_restore_service_factory.h" |
7 #include "apps/saved_files_service.h" | 7 #include "apps/saved_files_service.h" |
8 #include "chrome/browser/apps/app_browsertest_util.h" | 8 #include "chrome/browser/apps/app_browsertest_util.h" |
9 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 9 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "content/public/browser/browser_context.h" |
11 #include "content/public/browser/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
12 #include "content/public/test/test_utils.h" | 12 #include "content/public/test/test_utils.h" |
13 #include "extensions/browser/extension_prefs.h" | 13 #include "extensions/browser/extension_prefs.h" |
14 #include "extensions/browser/notification_types.h" | 14 #include "extensions/browser/notification_types.h" |
15 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
16 #include "extensions/test/extension_test_message_listener.h" | 16 #include "extensions/test/extension_test_message_listener.h" |
17 | 17 |
18 using extensions::Extension; | 18 using extensions::Extension; |
19 using extensions::ExtensionPrefs; | 19 using extensions::ExtensionPrefs; |
20 using extensions::ExtensionSystem; | 20 using extensions::ExtensionSystem; |
(...skipping 22 matching lines...) Expand all Loading... |
43 // Wait for the extension to get suspended. | 43 // Wait for the extension to get suspended. |
44 extension_suspended.Wait(); | 44 extension_suspended.Wait(); |
45 | 45 |
46 // App isn't running because it got suspended. | 46 // App isn't running because it got suspended. |
47 ASSERT_FALSE(extension_prefs->IsExtensionRunning(extension->id())); | 47 ASSERT_FALSE(extension_prefs->IsExtensionRunning(extension->id())); |
48 | 48 |
49 // Pretend that the app is supposed to be running. | 49 // Pretend that the app is supposed to be running. |
50 extension_prefs->SetExtensionRunning(extension->id(), true); | 50 extension_prefs->SetExtensionRunning(extension->id(), true); |
51 | 51 |
52 ExtensionTestMessageListener restart_listener("onRestarted", false); | 52 ExtensionTestMessageListener restart_listener("onRestarted", false); |
53 apps::AppRestoreServiceFactory::GetForProfile(browser()->profile())-> | 53 apps::AppRestoreServiceFactory::GetForBrowserContext(browser()->profile()) |
54 HandleStartup(true); | 54 ->HandleStartup(true); |
55 restart_listener.WaitUntilSatisfied(); | 55 restart_listener.WaitUntilSatisfied(); |
56 } | 56 } |
57 | 57 |
58 // Tests that apps are recorded in the preferences as active when and only when | 58 // Tests that apps are recorded in the preferences as active when and only when |
59 // they have visible windows. | 59 // they have visible windows. |
60 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ActiveAppsAreRecorded) { | 60 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ActiveAppsAreRecorded) { |
61 ExtensionTestMessageListener ready_listener("ready", true); | 61 ExtensionTestMessageListener ready_listener("ready", true); |
62 const Extension* extension = | 62 const Extension* extension = |
63 LoadExtension(test_data_dir_.AppendASCII("platform_apps/active_test")); | 63 LoadExtension(test_data_dir_.AppendASCII("platform_apps/active_test")); |
64 ASSERT_TRUE(extension); | 64 ASSERT_TRUE(extension); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 181 |
182 // Simulate a restart by populating the preferences as if the browser didn't | 182 // Simulate a restart by populating the preferences as if the browser didn't |
183 // get time to clean itself up. | 183 // get time to clean itself up. |
184 extension_prefs->SetExtensionRunning(extension->id(), true); | 184 extension_prefs->SetExtensionRunning(extension->id(), true); |
185 for (std::vector<SavedFileEntry>::const_iterator it = file_entries.begin(); | 185 for (std::vector<SavedFileEntry>::const_iterator it = file_entries.begin(); |
186 it != file_entries.end(); ++it) { | 186 it != file_entries.end(); ++it) { |
187 saved_files_service->RegisterFileEntry( | 187 saved_files_service->RegisterFileEntry( |
188 extension->id(), it->id, it->path, it->is_directory); | 188 extension->id(), it->id, it->path, it->is_directory); |
189 } | 189 } |
190 | 190 |
191 apps::AppRestoreServiceFactory::GetForProfile(browser()->profile())-> | 191 apps::AppRestoreServiceFactory::GetForBrowserContext(browser()->profile()) |
192 HandleStartup(true); | 192 ->HandleStartup(true); |
193 | 193 |
194 access_ok_listener.WaitUntilSatisfied(); | 194 access_ok_listener.WaitUntilSatisfied(); |
195 } | 195 } |
196 | 196 |
197 } // namespace apps | 197 } // namespace apps |
OLD | NEW |