Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: apps/app_restore_service_browsertest.cc

Issue 2951003002: SavedFilesService interface in //extensions (Closed)
Patch Set: cleanup Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « apps/app_restore_service.cc ('k') | apps/browser_context_keyed_service_factories.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_impl.h"
8 #include "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 #include "chrome/browser/apps/app_browsertest_util.h" 9 #include "chrome/browser/apps/app_browsertest_util.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 "content/public/browser/browser_context.h" 11 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/notification_service.h" 12 #include "content/public/browser/notification_service.h"
13 #include "content/public/test/test_utils.h" 13 #include "content/public/test/test_utils.h"
14 #include "extensions/browser/api/file_system/saved_files_service.h"
14 #include "extensions/browser/extension_prefs.h" 15 #include "extensions/browser/extension_prefs.h"
15 #include "extensions/browser/notification_types.h" 16 #include "extensions/browser/notification_types.h"
16 #include "extensions/common/extension.h" 17 #include "extensions/common/extension.h"
17 #include "extensions/test/extension_test_message_listener.h" 18 #include "extensions/test/extension_test_message_listener.h"
18 19
19 using extensions::Extension; 20 using extensions::Extension;
20 using extensions::ExtensionPrefs; 21 using extensions::ExtensionPrefs;
21 using extensions::ExtensionSystem; 22 using extensions::ExtensionSystem;
22 using extensions::FileSystemChooseEntryFunction; 23 using extensions::FileSystemChooseEntryFunction;
24 using extensions::SavedFilesService;
23 25
24 // TODO(benwells): Move PlatformAppBrowserTest to apps namespace in apps 26 // TODO(benwells): Move PlatformAppBrowserTest to apps namespace in apps
25 // component. 27 // component.
26 using extensions::PlatformAppBrowserTest; 28 using extensions::PlatformAppBrowserTest;
27 29
28 namespace apps { 30 namespace apps {
29 31
30 // Tests that a running app is recorded in the preferences as such. 32 // Tests that a running app is recorded in the preferences as such.
31 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) { 33 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) {
32 content::WindowedNotificationObserver extension_suspended( 34 content::WindowedNotificationObserver extension_suspended(
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 126
125 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( 127 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
126 &temp_file); 128 &temp_file);
127 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( 129 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest(
128 "temp", temp_directory.GetPath()); 130 "temp", temp_directory.GetPath());
129 131
130 const Extension* extension = LoadAndLaunchPlatformApp( 132 const Extension* extension = LoadAndLaunchPlatformApp(
131 "file_access_saved_to_prefs_test", "fileWritten"); 133 "file_access_saved_to_prefs_test", "fileWritten");
132 ASSERT_TRUE(extension); 134 ASSERT_TRUE(extension);
133 135
134 SavedFilesService* saved_files_service = SavedFilesService::Get(profile()); 136 SavedFilesServiceImpl* saved_files_service =
benwells 2017/06/22 07:56:09 Hmmm ... getting an Impl class like this looks a b
michaelpg 2017/06/23 20:44:04 Done. It does make the change tighter, thanks. I a
137 SavedFilesServiceImpl::Get(profile());
135 138
136 std::vector<SavedFileEntry> file_entries = 139 std::vector<SavedFilesService::Entry> file_entries =
137 saved_files_service->GetAllFileEntries(extension->id()); 140 saved_files_service->GetAllFileEntries(extension->id());
138 // One for the read-only file entry and one for the writable file entry. 141 // One for the read-only file entry and one for the writable file entry.
139 ASSERT_EQ(2u, file_entries.size()); 142 ASSERT_EQ(2u, file_entries.size());
140 143
141 extension_suspended.Wait(); 144 extension_suspended.Wait();
142 file_entries = saved_files_service->GetAllFileEntries(extension->id()); 145 file_entries = saved_files_service->GetAllFileEntries(extension->id());
143 // File entries should be cleared when the extension is suspended. 146 // File entries should be cleared when the extension is suspended.
144 ASSERT_TRUE(file_entries.empty()); 147 ASSERT_TRUE(file_entries.empty());
145 } 148 }
146 149
(...skipping 23 matching lines...) Expand all
170 173
171 ExtensionTestMessageListener access_ok_listener( 174 ExtensionTestMessageListener access_ok_listener(
172 "restartedFileAccessOK", false); 175 "restartedFileAccessOK", false);
173 176
174 const Extension* extension = 177 const Extension* extension =
175 LoadAndLaunchPlatformApp("file_access_restored_test", "fileWritten"); 178 LoadAndLaunchPlatformApp("file_access_restored_test", "fileWritten");
176 ASSERT_TRUE(extension); 179 ASSERT_TRUE(extension);
177 180
178 ExtensionPrefs* extension_prefs = 181 ExtensionPrefs* extension_prefs =
179 ExtensionPrefs::Get(browser()->profile()); 182 ExtensionPrefs::Get(browser()->profile());
180 SavedFilesService* saved_files_service = SavedFilesService::Get(profile()); 183 SavedFilesServiceImpl* saved_files_service =
181 std::vector<SavedFileEntry> file_entries = 184 SavedFilesServiceImpl::Get(profile());
185 std::vector<SavedFilesService::Entry> file_entries =
182 saved_files_service->GetAllFileEntries(extension->id()); 186 saved_files_service->GetAllFileEntries(extension->id());
183 extension_suspended.Wait(); 187 extension_suspended.Wait();
184 188
185 // Simulate a restart by populating the preferences as if the browser didn't 189 // Simulate a restart by populating the preferences as if the browser didn't
186 // get time to clean itself up. 190 // get time to clean itself up.
187 extension_prefs->SetExtensionRunning(extension->id(), true); 191 extension_prefs->SetExtensionRunning(extension->id(), true);
188 for (std::vector<SavedFileEntry>::const_iterator it = file_entries.begin(); 192 for (std::vector<SavedFilesService::Entry>::const_iterator it =
193 file_entries.begin();
189 it != file_entries.end(); ++it) { 194 it != file_entries.end(); ++it) {
190 saved_files_service->RegisterFileEntry( 195 saved_files_service->RegisterFileEntry(
191 extension->id(), it->id, it->path, it->is_directory); 196 extension->id(), it->id, it->path, it->is_directory);
192 } 197 }
193 198
194 apps::AppRestoreServiceFactory::GetForBrowserContext(browser()->profile()) 199 apps::AppRestoreServiceFactory::GetForBrowserContext(browser()->profile())
195 ->HandleStartup(true); 200 ->HandleStartup(true);
196 201
197 access_ok_listener.WaitUntilSatisfied(); 202 access_ok_listener.WaitUntilSatisfied();
198 } 203 }
199 204
200 } // namespace apps 205 } // namespace apps
OLDNEW
« no previous file with comments | « apps/app_restore_service.cc ('k') | apps/browser_context_keyed_service_factories.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698