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 // Browser test for basic Chrome OS file manager functionality: | 5 // Browser test for basic Chrome OS file manager functionality: |
6 // - The file list is updated when a file is added externally to the Downloads | 6 // - The file list is updated when a file is added externally to the Downloads |
7 // folder. | 7 // folder. |
8 // - Selecting a file and copy-pasting it with the keyboard copies the file. | 8 // - Selecting a file and copy-pasting it with the keyboard copies the file. |
9 // - Selecting a file and pressing delete deletes it. | 9 // - Selecting a file and pressing delete deletes it. |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/files/file_path_watcher.h" | 17 #include "base/files/file_path_watcher.h" |
18 #include "base/platform_file.h" | 18 #include "base/platform_file.h" |
19 #include "base/threading/platform_thread.h" | 19 #include "base/threading/platform_thread.h" |
20 #include "base/time.h" | 20 #include "base/time.h" |
21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 22 #include "chrome/browser/chromeos/drive/drive_file_system.h" |
| 23 #include "chrome/browser/chromeos/drive/drive_system_service.h" |
22 #include "chrome/browser/extensions/component_loader.h" | 24 #include "chrome/browser/extensions/component_loader.h" |
23 #include "chrome/browser/extensions/extension_apitest.h" | 25 #include "chrome/browser/extensions/extension_apitest.h" |
24 #include "chrome/browser/extensions/extension_service.h" | 26 #include "chrome/browser/extensions/extension_service.h" |
25 #include "chrome/browser/extensions/extension_test_message_listener.h" | 27 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 28 #include "chrome/browser/google_apis/fake_drive_service.h" |
| 29 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
| 30 #include "chrome/browser/google_apis/test_util.h" |
26 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/ui/browser_window.h" | 32 #include "chrome/browser/ui/browser_window.h" |
28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 33 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
29 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
30 #include "chrome/common/extensions/extension.h" | 35 #include "chrome/common/extensions/extension.h" |
31 #include "chrome/test/base/ui_test_utils.h" | 36 #include "chrome/test/base/ui_test_utils.h" |
32 #include "chromeos/chromeos_switches.h" | 37 #include "chromeos/chromeos_switches.h" |
33 #include "content/public/browser/browser_context.h" | 38 #include "content/public/browser/browser_context.h" |
34 #include "content/public/browser/render_view_host.h" | 39 #include "content/public/browser/render_view_host.h" |
35 #include "net/base/escape.h" | 40 #include "net/base/escape.h" |
36 #include "webkit/fileapi/external_mount_points.h" | 41 #include "webkit/fileapi/external_mount_points.h" |
37 | 42 |
38 namespace { | 43 namespace { |
39 | 44 |
40 const char kFileManagerExtensionId[] = "hhaomjibdihmijegdhdafkllkbggdgoj"; | 45 const char kFileManagerExtensionId[] = "hhaomjibdihmijegdhdafkllkbggdgoj"; |
41 | 46 |
42 const char kKeyboardTestFileName[] = "world.mpeg"; | 47 const char kKeyboardTestFileName[] = "world.mpeg"; |
43 const int64 kKeyboardTestFileSize = 1000; | 48 const int64 kKeyboardTestFileSize = 1000; |
44 const char kKeyboardTestFileCopyName[] = "world (1).mpeg"; | 49 const char kKeyboardTestFileCopyName[] = "world (1).mpeg"; |
45 | 50 |
| 51 struct TestFileInfo { |
| 52 const char* base_name; |
| 53 int64 file_size; |
| 54 const char* last_modified_time_as_string; |
| 55 } kTestFiles[] = { |
| 56 { "hello.txt", 123, "4 Sep 1998 12:34:56" }, |
| 57 { "My Desktop Background.png", 1024, "18 Jan 2038 01:02:03" }, |
| 58 { kKeyboardTestFileName, kKeyboardTestFileSize, "4 July 2012 10:35:00" }, |
| 59 }; |
| 60 |
| 61 struct TestDirectoryInfo { |
| 62 const char* base_name; |
| 63 const char* last_modified_time_as_string; |
| 64 } kTestDirectories[] = { |
| 65 { "photos", "1 Jan 1980 23:59:59" }, |
| 66 // Files starting with . are filtered out in |
| 67 // file_manager/js/directory_contents.js, so this should not be shown. |
| 68 { ".warez", "26 Oct 1985 13:39" }, |
| 69 }; |
| 70 |
46 // The base test class. Used by FileManagerBrowserLocalTest and | 71 // The base test class. Used by FileManagerBrowserLocalTest and |
47 // FileManagerBrowserDriveTest. | 72 // FileManagerBrowserDriveTest. |
48 // TODO(satorux): Add the latter: crbug.com/224534. | 73 // TODO(satorux): Add the latter: crbug.com/224534. |
49 class FileManagerBrowserTestBase : public ExtensionApiTest { | 74 class FileManagerBrowserTestBase : public ExtensionApiTest { |
50 protected: | 75 protected: |
51 // Loads the file manager extension, navigating it to |directory_path| for | 76 // Loads the file manager extension, navigating it to |directory_path| for |
52 // testing, and waits for it to finish initializing. This is invoked at the | 77 // testing, and waits for it to finish initializing. This is invoked at the |
53 // start of each test (it crashes if run in SetUp). | 78 // start of each test (it crashes if run in SetUp). |
54 void StartFileManager(const std::string& directory_path); | 79 void StartFileManager(const std::string& directory_path); |
55 | 80 |
56 // Loads our testing extension and sends it a string identifying the current | 81 // Loads our testing extension and sends it a string identifying the current |
57 // test. | 82 // test. |
58 void StartTest(const std::string& test_name); | 83 void StartTest(const std::string& test_name); |
| 84 |
| 85 // Creates test files and directories. |
| 86 void CreateTestFilesAndDirectories(); |
| 87 |
| 88 // Creates a file with the given |name|, |length|, and |modification_time|. |
| 89 virtual void CreateTestFile(const std::string& name, |
| 90 int64 length, |
| 91 const std::string& modification_time) = 0; |
| 92 |
| 93 // Creates an empty directory with the given |name| and |modification_time|. |
| 94 virtual void CreateTestDirectory( |
| 95 const std::string& name, |
| 96 const std::string& modification_time) = 0; |
| 97 |
| 98 // Runs the file display test, shared by sub classes. |
| 99 void DoTestFileDisplay(); |
59 }; | 100 }; |
60 | 101 |
61 void FileManagerBrowserTestBase::StartFileManager( | 102 void FileManagerBrowserTestBase::StartFileManager( |
62 const std::string& directory_path) { | 103 const std::string& directory_path) { |
63 std::string file_manager_url = | 104 std::string file_manager_url = |
64 (std::string("chrome-extension://") + | 105 (std::string("chrome-extension://") + |
65 kFileManagerExtensionId + | 106 kFileManagerExtensionId + |
66 "/main.html#" + | 107 "/main.html#" + |
67 net::EscapeQueryParamValue(directory_path, false /* use_plus */)); | 108 net::EscapeQueryParamValue(directory_path, false /* use_plus */)); |
68 | 109 |
69 ui_test_utils::NavigateToURL(browser(), GURL(file_manager_url)); | 110 ui_test_utils::NavigateToURL(browser(), GURL(file_manager_url)); |
70 | 111 |
71 // This is sent by the file manager when it's finished initializing. | 112 // This is sent by the file manager when it's finished initializing. |
72 ExtensionTestMessageListener listener("worker-initialized", false); | 113 ExtensionTestMessageListener listener("worker-initialized", false); |
73 ASSERT_TRUE(listener.WaitUntilSatisfied()); | 114 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
74 } | 115 } |
75 | 116 |
76 void FileManagerBrowserTestBase::StartTest(const std::string& test_name) { | 117 void FileManagerBrowserTestBase::StartTest(const std::string& test_name) { |
77 base::FilePath path = test_data_dir_.AppendASCII("file_manager_browsertest"); | 118 base::FilePath path = test_data_dir_.AppendASCII("file_manager_browsertest"); |
78 const extensions::Extension* extension = LoadExtensionAsComponent(path); | 119 const extensions::Extension* extension = LoadExtensionAsComponent(path); |
79 ASSERT_TRUE(extension); | 120 ASSERT_TRUE(extension); |
80 | 121 |
81 ExtensionTestMessageListener listener("which test", true); | 122 ExtensionTestMessageListener listener("which test", true); |
82 ASSERT_TRUE(listener.WaitUntilSatisfied()); | 123 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
83 listener.Reply(test_name); | 124 listener.Reply(test_name); |
84 } | 125 } |
85 | 126 |
| 127 void FileManagerBrowserTestBase::CreateTestFilesAndDirectories() { |
| 128 for (size_t i = 0; i < arraysize(kTestFiles); ++i) { |
| 129 CreateTestFile(kTestFiles[i].base_name, |
| 130 kTestFiles[i].file_size, |
| 131 kTestFiles[i].last_modified_time_as_string); |
| 132 } |
| 133 for (size_t i = 0; i < arraysize(kTestDirectories); ++i) { |
| 134 CreateTestDirectory(kTestDirectories[i].base_name, |
| 135 kTestDirectories[i].last_modified_time_as_string); |
| 136 } |
| 137 } |
| 138 |
| 139 void FileManagerBrowserTestBase::DoTestFileDisplay() { |
| 140 ResultCatcher catcher; |
| 141 |
| 142 StartTest("file display"); |
| 143 |
| 144 ExtensionTestMessageListener listener("initial check done", true); |
| 145 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
| 146 CreateTestFile("newly added file.mp3", 2000, "4 Sep 1998 00:00:00"); |
| 147 listener.Reply("file added"); |
| 148 |
| 149 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 150 } |
| 151 |
86 // The boolean parameter, retrieved by GetParam(), is true if testing in the | 152 // The boolean parameter, retrieved by GetParam(), is true if testing in the |
87 // guest mode. See SetUpCommandLine() below for details. | 153 // guest mode. See SetUpCommandLine() below for details. |
88 class FileManagerBrowserLocalTest : public FileManagerBrowserTestBase, | 154 class FileManagerBrowserLocalTest : public FileManagerBrowserTestBase, |
89 public ::testing::WithParamInterface<bool> { | 155 public ::testing::WithParamInterface<bool> { |
90 public: | 156 public: |
91 virtual void SetUp() OVERRIDE { | 157 virtual void SetUp() OVERRIDE { |
92 extensions::ComponentLoader::EnableBackgroundExtensionsForTesting(); | 158 extensions::ComponentLoader::EnableBackgroundExtensionsForTesting(); |
93 | 159 |
94 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); | 160 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); |
95 downloads_path_ = tmp_dir_.path().Append("Downloads"); | 161 downloads_path_ = tmp_dir_.path().Append("Downloads"); |
96 ASSERT_TRUE(file_util::CreateDirectory(downloads_path_)); | 162 ASSERT_TRUE(file_util::CreateDirectory(downloads_path_)); |
97 | 163 |
98 CreateTestFile("hello.txt", 123, "4 Sep 1998 12:34:56"); | 164 CreateTestFilesAndDirectories(); |
99 CreateTestFile("My Desktop Background.png", 1024, "18 Jan 2038 01:02:03"); | |
100 CreateTestFile(kKeyboardTestFileName, kKeyboardTestFileSize, | |
101 "4 July 2012 10:35:00"); | |
102 CreateTestDirectory("photos", "1 Jan 1980 23:59:59"); | |
103 // Files starting with . are filtered out in | |
104 // file_manager/js/directory_contents.js, so this should not be shown. | |
105 CreateTestDirectory(".warez", "26 Oct 1985 13:39"); | |
106 | 165 |
107 ExtensionApiTest::SetUp(); | 166 ExtensionApiTest::SetUp(); |
108 } | 167 } |
109 | 168 |
110 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 169 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
111 bool in_guest_mode = GetParam(); | 170 bool in_guest_mode = GetParam(); |
112 if (in_guest_mode) { | 171 if (in_guest_mode) { |
113 command_line->AppendSwitch(chromeos::switches::kGuestSession); | 172 command_line->AppendSwitch(chromeos::switches::kGuestSession); |
114 command_line->AppendSwitch(switches::kIncognito); | 173 command_line->AppendSwitch(switches::kIncognito); |
115 } | 174 } |
116 ExtensionApiTest::SetUpCommandLine(command_line); | 175 ExtensionApiTest::SetUpCommandLine(command_line); |
117 } | 176 } |
118 | 177 |
119 protected: | 178 protected: |
120 // Creates a file with the given |name|, |length|, and |modification_time|. | 179 // FileManagerBrowserTestBase overrides. |
121 void CreateTestFile(const std::string& name, | 180 virtual void CreateTestFile(const std::string& name, |
122 int length, | 181 int64 length, |
123 const std::string& modification_time); | 182 const std::string& modification_time) OVERRIDE; |
124 | 183 virtual void CreateTestDirectory( |
125 // Creates an empty directory with the given |name| and |modification_time|. | 184 const std::string& name, |
126 void CreateTestDirectory(const std::string& name, | 185 const std::string& modification_time) OVERRIDE; |
127 const std::string& modification_time); | |
128 | 186 |
129 // Add a mount point to the fake Downloads directory. Should be called | 187 // Add a mount point to the fake Downloads directory. Should be called |
130 // before StartFileManager(). | 188 // before StartFileManager(). |
131 void AddMountPointToFakeDownloads(); | 189 void AddMountPointToFakeDownloads(); |
132 | 190 |
133 // Path to the fake Downloads directory used in the test. | 191 // Path to the fake Downloads directory used in the test. |
134 base::FilePath downloads_path_; | 192 base::FilePath downloads_path_; |
135 | 193 |
136 private: | 194 private: |
137 base::ScopedTempDir tmp_dir_; | 195 base::ScopedTempDir tmp_dir_; |
138 }; | 196 }; |
139 | 197 |
140 INSTANTIATE_TEST_CASE_P(InGuestMode, | 198 INSTANTIATE_TEST_CASE_P(InGuestMode, |
141 FileManagerBrowserLocalTest, | 199 FileManagerBrowserLocalTest, |
142 ::testing::Values(true)); | 200 ::testing::Values(true)); |
143 | 201 |
144 INSTANTIATE_TEST_CASE_P(InNonGuestMode, | 202 INSTANTIATE_TEST_CASE_P(InNonGuestMode, |
145 FileManagerBrowserLocalTest, | 203 FileManagerBrowserLocalTest, |
146 ::testing::Values(false)); | 204 ::testing::Values(false)); |
147 | 205 |
148 void FileManagerBrowserLocalTest::CreateTestFile( | 206 void FileManagerBrowserLocalTest::CreateTestFile( |
149 const std::string& name, | 207 const std::string& name, |
150 int length, | 208 int64 length, |
151 const std::string& modification_time) { | 209 const std::string& modification_time) { |
152 ASSERT_GE(length, 0); | 210 ASSERT_GE(length, 0); |
153 base::FilePath path = downloads_path_.AppendASCII(name); | 211 base::FilePath path = downloads_path_.AppendASCII(name); |
154 int flags = base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_WRITE; | 212 int flags = base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_WRITE; |
155 bool created = false; | 213 bool created = false; |
156 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; | 214 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; |
157 base::PlatformFile file = base::CreatePlatformFile(path, flags, | 215 base::PlatformFile file = base::CreatePlatformFile(path, flags, |
158 &created, &error); | 216 &created, &error); |
159 ASSERT_TRUE(created); | 217 ASSERT_TRUE(created); |
160 ASSERT_FALSE(error) << error; | 218 ASSERT_FALSE(error) << error; |
(...skipping 16 matching lines...) Expand all Loading... |
177 | 235 |
178 void FileManagerBrowserLocalTest::AddMountPointToFakeDownloads() { | 236 void FileManagerBrowserLocalTest::AddMountPointToFakeDownloads() { |
179 // Install our fake Downloads mount point first. | 237 // Install our fake Downloads mount point first. |
180 fileapi::ExternalMountPoints* mount_points = | 238 fileapi::ExternalMountPoints* mount_points = |
181 content::BrowserContext::GetMountPoints(profile()); | 239 content::BrowserContext::GetMountPoints(profile()); |
182 ASSERT_TRUE(mount_points->RevokeFileSystem("Downloads")); | 240 ASSERT_TRUE(mount_points->RevokeFileSystem("Downloads")); |
183 ASSERT_TRUE(mount_points->RegisterFileSystem( | 241 ASSERT_TRUE(mount_points->RegisterFileSystem( |
184 "Downloads", fileapi::kFileSystemTypeNativeLocal, downloads_path_)); | 242 "Downloads", fileapi::kFileSystemTypeNativeLocal, downloads_path_)); |
185 } | 243 } |
186 | 244 |
| 245 class FileManagerBrowserDriveTest : public FileManagerBrowserTestBase { |
| 246 public: |
| 247 FileManagerBrowserDriveTest() |
| 248 : fake_drive_service_(NULL), |
| 249 system_service_(NULL) { |
| 250 } |
| 251 |
| 252 virtual void SetUp() OVERRIDE { |
| 253 extensions::ComponentLoader::EnableBackgroundExtensionsForTesting(); |
| 254 |
| 255 ASSERT_TRUE(test_cache_root_.CreateUniqueTempDir()); |
| 256 |
| 257 drive::DriveSystemServiceFactory::SetFactoryForTest( |
| 258 base::Bind(&FileManagerBrowserDriveTest::CreateDriveSystemService, |
| 259 base::Unretained(this))); |
| 260 |
| 261 ExtensionApiTest::SetUp(); |
| 262 } |
| 263 |
| 264 protected: |
| 265 // FileManagerBrowserTestBase overrides. |
| 266 virtual void CreateTestFile(const std::string& name, |
| 267 int64 length, |
| 268 const std::string& modification_time) OVERRIDE; |
| 269 virtual void CreateTestDirectory( |
| 270 const std::string& name, |
| 271 const std::string& modification_time) OVERRIDE; |
| 272 |
| 273 // Notifies DriveFileSystem that the contents in FakeDriveService are |
| 274 // changed, hence the new contents should be fetched. |
| 275 void CheckForUpdates(); |
| 276 |
| 277 // DriveSystemService factory function for this test. |
| 278 drive::DriveSystemService* CreateDriveSystemService(Profile* profile); |
| 279 |
| 280 base::ScopedTempDir test_cache_root_; |
| 281 google_apis::FakeDriveService* fake_drive_service_; |
| 282 drive::DriveSystemService* system_service_; |
| 283 }; |
| 284 |
| 285 void FileManagerBrowserDriveTest::CreateTestFile( |
| 286 const std::string& name, |
| 287 int64 length, |
| 288 const std::string& modification_time) { |
| 289 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; |
| 290 scoped_ptr<google_apis::ResourceEntry> resource_entry; |
| 291 fake_drive_service_->AddNewFile( |
| 292 "text/plain", |
| 293 length, |
| 294 fake_drive_service_->GetRootResourceId(), |
| 295 name, |
| 296 google_apis::test_util::CreateCopyResultCallback(&error, |
| 297 &resource_entry)); |
| 298 MessageLoop::current()->RunUntilIdle(); |
| 299 ASSERT_EQ(google_apis::HTTP_CREATED, error); |
| 300 ASSERT_TRUE(resource_entry); |
| 301 |
| 302 base::Time time; |
| 303 ASSERT_TRUE(base::Time::FromString(modification_time.c_str(), &time)); |
| 304 fake_drive_service_->SetLastModifiedTime( |
| 305 resource_entry->resource_id(), |
| 306 time, |
| 307 google_apis::test_util::CreateCopyResultCallback(&error, |
| 308 &resource_entry)); |
| 309 MessageLoop::current()->RunUntilIdle(); |
| 310 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); |
| 311 ASSERT_TRUE(resource_entry); |
| 312 |
| 313 CheckForUpdates(); |
| 314 } |
| 315 |
| 316 void FileManagerBrowserDriveTest::CreateTestDirectory( |
| 317 const std::string& name, |
| 318 const std::string& modification_time) { |
| 319 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; |
| 320 scoped_ptr<google_apis::ResourceEntry> resource_entry; |
| 321 fake_drive_service_->AddNewDirectory( |
| 322 fake_drive_service_->GetRootResourceId(), |
| 323 name, |
| 324 google_apis::test_util::CreateCopyResultCallback(&error, |
| 325 &resource_entry)); |
| 326 MessageLoop::current()->RunUntilIdle(); |
| 327 ASSERT_EQ(google_apis::HTTP_CREATED, error); |
| 328 ASSERT_TRUE(resource_entry); |
| 329 |
| 330 base::Time time; |
| 331 ASSERT_TRUE(base::Time::FromString(modification_time.c_str(), &time)); |
| 332 fake_drive_service_->SetLastModifiedTime( |
| 333 resource_entry->resource_id(), |
| 334 time, |
| 335 google_apis::test_util::CreateCopyResultCallback(&error, |
| 336 &resource_entry)); |
| 337 MessageLoop::current()->RunUntilIdle(); |
| 338 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); |
| 339 ASSERT_TRUE(resource_entry); |
| 340 |
| 341 CheckForUpdates(); |
| 342 } |
| 343 |
| 344 void FileManagerBrowserDriveTest::CheckForUpdates() { |
| 345 if (system_service_ && system_service_->file_system()) { |
| 346 system_service_->file_system()->CheckForUpdates(); |
| 347 } |
| 348 } |
| 349 |
| 350 drive::DriveSystemService* |
| 351 FileManagerBrowserDriveTest::CreateDriveSystemService(Profile* profile) { |
| 352 fake_drive_service_ = new google_apis::FakeDriveService; |
| 353 fake_drive_service_->LoadResourceListForWapi( |
| 354 "chromeos/gdata/empty_feed.json"); |
| 355 fake_drive_service_->LoadAccountMetadataForWapi( |
| 356 "chromeos/gdata/account_metadata.json"); |
| 357 fake_drive_service_->LoadAppListForDriveApi("chromeos/drive/applist.json"); |
| 358 |
| 359 // Create test files and directories inside the fake drive service. |
| 360 CreateTestFilesAndDirectories(); |
| 361 |
| 362 system_service_ = new drive::DriveSystemService(profile, |
| 363 fake_drive_service_, |
| 364 test_cache_root_.path(), |
| 365 NULL); |
| 366 |
| 367 return system_service_; |
| 368 } |
| 369 |
187 // Monitors changes to a single file until the supplied condition callback | 370 // Monitors changes to a single file until the supplied condition callback |
188 // returns true. Usage: | 371 // returns true. Usage: |
189 // TestFilePathWatcher watcher(path_to_file, MyConditionCallback); | 372 // TestFilePathWatcher watcher(path_to_file, MyConditionCallback); |
190 // watcher.StartAndWaitUntilReady(); | 373 // watcher.StartAndWaitUntilReady(); |
191 // ... trigger filesystem modification ... | 374 // ... trigger filesystem modification ... |
192 // watcher.RunMessageLoopUntilConditionSatisfied(); | 375 // watcher.RunMessageLoopUntilConditionSatisfied(); |
193 class TestFilePathWatcher { | 376 class TestFilePathWatcher { |
194 public: | 377 public: |
195 typedef base::Callback<bool(const base::FilePath& file_path)> | 378 typedef base::Callback<bool(const base::FilePath& file_path)> |
196 ConditionCallback; | 379 ConditionCallback; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 473 |
291 // Returns true if a file is not present at |path|. | 474 // Returns true if a file is not present at |path|. |
292 bool FileNotPresent(const base::FilePath& path) { | 475 bool FileNotPresent(const base::FilePath& path) { |
293 return !file_util::PathExists(path); | 476 return !file_util::PathExists(path); |
294 }; | 477 }; |
295 | 478 |
296 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestFileDisplay) { | 479 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestFileDisplay) { |
297 AddMountPointToFakeDownloads(); | 480 AddMountPointToFakeDownloads(); |
298 StartFileManager("/Downloads"); | 481 StartFileManager("/Downloads"); |
299 | 482 |
300 ResultCatcher catcher; | 483 DoTestFileDisplay(); |
301 | |
302 StartTest("file display"); | |
303 | |
304 ExtensionTestMessageListener listener("initial check done", true); | |
305 ASSERT_TRUE(listener.WaitUntilSatisfied()); | |
306 CreateTestFile("newly added file.mp3", 2000, "4 Sep 1998 00:00:00"); | |
307 listener.Reply("file added"); | |
308 | |
309 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | |
310 } | 484 } |
311 | 485 |
312 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestKeyboardCopy) { | 486 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestKeyboardCopy) { |
313 AddMountPointToFakeDownloads(); | 487 AddMountPointToFakeDownloads(); |
314 StartFileManager("/Downloads"); | 488 StartFileManager("/Downloads"); |
315 | 489 |
316 base::FilePath copy_path = | 490 base::FilePath copy_path = |
317 downloads_path_.AppendASCII(kKeyboardTestFileCopyName); | 491 downloads_path_.AppendASCII(kKeyboardTestFileCopyName); |
318 ASSERT_FALSE(file_util::PathExists(copy_path)); | 492 ASSERT_FALSE(file_util::PathExists(copy_path)); |
319 | 493 |
(...skipping 23 matching lines...) Expand all Loading... |
343 | 517 |
344 ResultCatcher catcher; | 518 ResultCatcher catcher; |
345 StartTest("keyboard delete"); | 519 StartTest("keyboard delete"); |
346 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 520 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
347 | 521 |
348 TestFilePathWatcher watcher(delete_path, | 522 TestFilePathWatcher watcher(delete_path, |
349 base::Bind(FileNotPresent)); | 523 base::Bind(FileNotPresent)); |
350 ASSERT_TRUE(watcher.RunMessageLoopUntilConditionSatisfied()); | 524 ASSERT_TRUE(watcher.RunMessageLoopUntilConditionSatisfied()); |
351 } | 525 } |
352 | 526 |
| 527 IN_PROC_BROWSER_TEST_F(FileManagerBrowserDriveTest, TestFileDisplay) { |
| 528 StartFileManager("/drive/root"); |
| 529 |
| 530 DoTestFileDisplay(); |
| 531 } |
| 532 |
353 } // namespace | 533 } // namespace |
OLD | NEW |