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

Side by Side Diff: base/files/file_path_watcher_browsertest.cc

Issue 18383003: Move DeleteAfterReboot and Move to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « base/file_util_win.cc ('k') | base/files/file_util_proxy_unittest.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/files/file_path_watcher.h" 5 #include "base/files/file_path_watcher.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <aclapi.h> 9 #include <aclapi.h>
10 #elif defined(OS_POSIX) 10 #elif defined(OS_POSIX)
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // Verify that moving the file into place is caught. 254 // Verify that moving the file into place is caught.
255 TEST_F(FilePathWatcherTest, MovedFile) { 255 TEST_F(FilePathWatcherTest, MovedFile) {
256 FilePath source_file(temp_dir_.path().AppendASCII("source")); 256 FilePath source_file(temp_dir_.path().AppendASCII("source"));
257 ASSERT_TRUE(WriteFile(source_file, "content")); 257 ASSERT_TRUE(WriteFile(source_file, "content"));
258 258
259 FilePathWatcher watcher; 259 FilePathWatcher watcher;
260 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); 260 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
261 ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false)); 261 ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false));
262 262
263 // Now make sure we get notified if the file is modified. 263 // Now make sure we get notified if the file is modified.
264 ASSERT_TRUE(file_util::Move(source_file, test_file())); 264 ASSERT_TRUE(base::Move(source_file, test_file()));
265 ASSERT_TRUE(WaitForEvents()); 265 ASSERT_TRUE(WaitForEvents());
266 DeleteDelegateOnFileThread(delegate.release()); 266 DeleteDelegateOnFileThread(delegate.release());
267 } 267 }
268 268
269 TEST_F(FilePathWatcherTest, DeletedFile) { 269 TEST_F(FilePathWatcherTest, DeletedFile) {
270 ASSERT_TRUE(WriteFile(test_file(), "content")); 270 ASSERT_TRUE(WriteFile(test_file(), "content"));
271 271
272 FilePathWatcher watcher; 272 FilePathWatcher watcher;
273 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); 273 scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
274 ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false)); 274 ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false));
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 ASSERT_TRUE(SetupWatch(subdir, &subdir_watcher, subdir_delegate.get(), 489 ASSERT_TRUE(SetupWatch(subdir, &subdir_watcher, subdir_delegate.get(),
490 false)); 490 false));
491 491
492 // Setup a directory hierarchy. 492 // Setup a directory hierarchy.
493 ASSERT_TRUE(file_util::CreateDirectory(subdir)); 493 ASSERT_TRUE(file_util::CreateDirectory(subdir));
494 ASSERT_TRUE(WriteFile(file, "content")); 494 ASSERT_TRUE(WriteFile(file, "content"));
495 VLOG(1) << "Waiting for file creation"; 495 VLOG(1) << "Waiting for file creation";
496 ASSERT_TRUE(WaitForEvents()); 496 ASSERT_TRUE(WaitForEvents());
497 497
498 // Move the parent directory. 498 // Move the parent directory.
499 file_util::Move(dir, dest); 499 base::Move(dir, dest);
500 VLOG(1) << "Waiting for directory move"; 500 VLOG(1) << "Waiting for directory move";
501 ASSERT_TRUE(WaitForEvents()); 501 ASSERT_TRUE(WaitForEvents());
502 DeleteDelegateOnFileThread(file_delegate.release()); 502 DeleteDelegateOnFileThread(file_delegate.release());
503 DeleteDelegateOnFileThread(subdir_delegate.release()); 503 DeleteDelegateOnFileThread(subdir_delegate.release());
504 } 504 }
505 505
506 #if defined(OS_WIN) 506 #if defined(OS_WIN)
507 TEST_F(FilePathWatcherTest, RecursiveWatch) { 507 TEST_F(FilePathWatcherTest, RecursiveWatch) {
508 FilePathWatcher watcher; 508 FilePathWatcher watcher;
509 FilePath dir(temp_dir_.path().AppendASCII("dir")); 509 FilePath dir(temp_dir_.path().AppendASCII("dir"));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 ASSERT_TRUE(file_util::CreateDirectory(source_subdir)); 581 ASSERT_TRUE(file_util::CreateDirectory(source_subdir));
582 ASSERT_TRUE(WriteFile(source_file, "content")); 582 ASSERT_TRUE(WriteFile(source_file, "content"));
583 583
584 scoped_ptr<TestDelegate> file_delegate(new TestDelegate(collector())); 584 scoped_ptr<TestDelegate> file_delegate(new TestDelegate(collector()));
585 ASSERT_TRUE(SetupWatch(dest_file, &file_watcher, file_delegate.get(), false)); 585 ASSERT_TRUE(SetupWatch(dest_file, &file_watcher, file_delegate.get(), false));
586 scoped_ptr<TestDelegate> subdir_delegate(new TestDelegate(collector())); 586 scoped_ptr<TestDelegate> subdir_delegate(new TestDelegate(collector()));
587 ASSERT_TRUE(SetupWatch(dest_subdir, &subdir_watcher, subdir_delegate.get(), 587 ASSERT_TRUE(SetupWatch(dest_subdir, &subdir_watcher, subdir_delegate.get(),
588 false)); 588 false));
589 589
590 // Move the directory into place, s.t. the watched file appears. 590 // Move the directory into place, s.t. the watched file appears.
591 ASSERT_TRUE(file_util::Move(source_dir, dest_dir)); 591 ASSERT_TRUE(base::Move(source_dir, dest_dir));
592 ASSERT_TRUE(WaitForEvents()); 592 ASSERT_TRUE(WaitForEvents());
593 DeleteDelegateOnFileThread(file_delegate.release()); 593 DeleteDelegateOnFileThread(file_delegate.release());
594 DeleteDelegateOnFileThread(subdir_delegate.release()); 594 DeleteDelegateOnFileThread(subdir_delegate.release());
595 } 595 }
596 596
597 #if !defined(OS_LINUX) 597 #if !defined(OS_LINUX)
598 // Linux implementation of FilePathWatcher doesn't catch attribute changes. 598 // Linux implementation of FilePathWatcher doesn't catch attribute changes.
599 // http://crbug.com/78043 599 // http://crbug.com/78043
600 600
601 // Verify that changing attributes on a file is caught 601 // Verify that changing attributes on a file is caught
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false)); 906 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, false));
907 ASSERT_TRUE(WaitForEvents()); 907 ASSERT_TRUE(WaitForEvents());
908 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true)); 908 ASSERT_TRUE(ChangeFilePermissions(test_dir1, Execute, true));
909 DeleteDelegateOnFileThread(delegate.release()); 909 DeleteDelegateOnFileThread(delegate.release());
910 } 910 }
911 911
912 #endif // OS_MACOSX 912 #endif // OS_MACOSX
913 } // namespace 913 } // namespace
914 914
915 } // namespace base 915 } // namespace base
OLDNEW
« no previous file with comments | « base/file_util_win.cc ('k') | base/files/file_util_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698