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

Unified Diff: apps/app_restore_service_browsertest.cc

Issue 12391006: Give an app the file entries it had back on restart. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compile (chromium style) Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « apps/app_restore_service.cc ('k') | chrome/browser/extensions/api/app_runtime/app_runtime_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/app_restore_service_browsertest.cc
diff --git a/apps/app_restore_service_browsertest.cc b/apps/app_restore_service_browsertest.cc
index 3eaf3ff213f5e3cfab9a5f933def33422bad0396..f17cc64c1211521118d85668d229e7c12212cb52 100644
--- a/apps/app_restore_service_browsertest.cc
+++ b/apps/app_restore_service_browsertest.cc
@@ -98,4 +98,52 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, FileAccessIsSavedToPrefs) {
ASSERT_TRUE(file_entries.empty());
}
+IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, FileAccessIsRestored) {
+ content::WindowedNotificationObserver extension_suspended(
+ chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
+ content::NotificationService::AllSources());
+
+ base::ScopedTempDir temp_directory;
+ ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
+ base::FilePath temp_file;
+ ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_directory.path(),
+ &temp_file));
+
+ FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
+ &temp_file);
+
+ ExtensionTestMessageListener file_written_listener("fileWritten", false);
+ ExtensionTestMessageListener access_ok_listener(
+ "restartedFileAccessOK", false);
+
+ const Extension* extension =
+ LoadAndLaunchPlatformApp("file_access_restored_test");
+ ASSERT_TRUE(extension);
+ file_written_listener.WaitUntilSatisfied();
+
+ ExtensionService* extension_service =
+ ExtensionSystem::Get(browser()->profile())->extension_service();
+ ExtensionPrefs* extension_prefs = extension_service->extension_prefs();
+
+ // Record the file entries in prefs because when the app gets suspended it
+ // will have them all cleared.
+ std::vector<SavedFileEntry> file_entries;
+ extension_prefs->GetSavedFileEntries(extension->id(), &file_entries);
+ extension_suspended.Wait();
+
+ // Simulate a restart by populating the preferences as if the browser didn't
+ // get time to clean itself up.
+ extension_prefs->SetExtensionRunning(extension->id(), true);
+ for (std::vector<SavedFileEntry>::const_iterator it = file_entries.begin();
+ it != file_entries.end(); ++it) {
+ extension_prefs->AddSavedFileEntry(
+ extension->id(), it->id, it->path, it->writable);
+ }
+
+ apps::AppRestoreServiceFactory::GetForProfile(browser()->profile())->
+ HandleStartup(true);
+
+ access_ok_listener.WaitUntilSatisfied();
+}
+
} // namespace apps
« no previous file with comments | « apps/app_restore_service.cc ('k') | chrome/browser/extensions/api/app_runtime/app_runtime_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698