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/chrome_notification_types.h" | |
10 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 9 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
11 #include "chrome/browser/extensions/extension_test_message_listener.h" | 10 #include "chrome/browser/extensions/extension_test_message_listener.h" |
12 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
13 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
14 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
15 #include "extensions/browser/extension_prefs.h" | 14 #include "extensions/browser/extension_prefs.h" |
| 15 #include "extensions/browser/notification_types.h" |
16 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.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; |
21 using extensions::FileSystemChooseEntryFunction; | 21 using extensions::FileSystemChooseEntryFunction; |
22 | 22 |
23 // TODO(benwells): Move PlatformAppBrowserTest to apps namespace in apps | 23 // TODO(benwells): Move PlatformAppBrowserTest to apps namespace in apps |
24 // component. | 24 // component. |
25 using extensions::PlatformAppBrowserTest; | 25 using extensions::PlatformAppBrowserTest; |
26 | 26 |
27 namespace apps { | 27 namespace apps { |
28 | 28 |
29 // Tests that a running app is recorded in the preferences as such. | 29 // Tests that a running app is recorded in the preferences as such. |
30 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) { | 30 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) { |
31 content::WindowedNotificationObserver extension_suspended( | 31 content::WindowedNotificationObserver extension_suspended( |
32 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 32 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
33 content::NotificationService::AllSources()); | 33 content::NotificationService::AllSources()); |
34 | 34 |
35 const Extension* extension = LoadExtension( | 35 const Extension* extension = LoadExtension( |
36 test_data_dir_.AppendASCII("platform_apps/restart_test")); | 36 test_data_dir_.AppendASCII("platform_apps/restart_test")); |
37 ASSERT_TRUE(extension); | 37 ASSERT_TRUE(extension); |
38 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(browser()->profile()); | 38 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(browser()->profile()); |
39 | 39 |
40 // App is running. | 40 // App is running. |
41 ASSERT_TRUE(extension_prefs->IsExtensionRunning(extension->id())); | 41 ASSERT_TRUE(extension_prefs->IsExtensionRunning(extension->id())); |
42 | 42 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 // Close the last window and exit. | 105 // Close the last window and exit. |
106 ready_listener.Reply("closeLastWindow"); | 106 ready_listener.Reply("closeLastWindow"); |
107 ready_listener.Reset(); | 107 ready_listener.Reset(); |
108 ASSERT_TRUE(ready_listener.WaitUntilSatisfied()); | 108 ASSERT_TRUE(ready_listener.WaitUntilSatisfied()); |
109 ready_listener.Reply("exit"); | 109 ready_listener.Reply("exit"); |
110 } | 110 } |
111 | 111 |
112 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, FileAccessIsSavedToPrefs) { | 112 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, FileAccessIsSavedToPrefs) { |
113 content::WindowedNotificationObserver extension_suspended( | 113 content::WindowedNotificationObserver extension_suspended( |
114 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 114 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
115 content::NotificationService::AllSources()); | 115 content::NotificationService::AllSources()); |
116 | 116 |
117 base::ScopedTempDir temp_directory; | 117 base::ScopedTempDir temp_directory; |
118 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); | 118 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
119 base::FilePath temp_file; | 119 base::FilePath temp_file; |
120 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_directory.path(), | 120 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_directory.path(), |
121 &temp_file)); | 121 &temp_file)); |
122 | 122 |
123 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 123 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
124 &temp_file); | 124 &temp_file); |
(...skipping 19 matching lines...) Expand all Loading... |
144 | 144 |
145 // Flaky: crbug.com/269613 | 145 // Flaky: crbug.com/269613 |
146 #if defined(OS_LINUX) || defined(OS_WIN) | 146 #if defined(OS_LINUX) || defined(OS_WIN) |
147 #define MAYBE_FileAccessIsRestored DISABLED_FileAccessIsRestored | 147 #define MAYBE_FileAccessIsRestored DISABLED_FileAccessIsRestored |
148 #else | 148 #else |
149 #define MAYBE_FileAccessIsRestored FileAccessIsRestored | 149 #define MAYBE_FileAccessIsRestored FileAccessIsRestored |
150 #endif | 150 #endif |
151 | 151 |
152 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_FileAccessIsRestored) { | 152 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_FileAccessIsRestored) { |
153 content::WindowedNotificationObserver extension_suspended( | 153 content::WindowedNotificationObserver extension_suspended( |
154 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 154 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
155 content::NotificationService::AllSources()); | 155 content::NotificationService::AllSources()); |
156 | 156 |
157 base::ScopedTempDir temp_directory; | 157 base::ScopedTempDir temp_directory; |
158 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); | 158 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
159 base::FilePath temp_file; | 159 base::FilePath temp_file; |
160 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_directory.path(), | 160 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_directory.path(), |
161 &temp_file)); | 161 &temp_file)); |
162 | 162 |
163 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 163 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
164 &temp_file); | 164 &temp_file); |
(...skipping 23 matching lines...) Expand all Loading... |
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::GetForProfile(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 |