Chromium Code Reviews| Index: base/files/file_path_watcher_unittest.cc |
| diff --git a/base/files/file_path_watcher_unittest.cc b/base/files/file_path_watcher_unittest.cc |
| index bc7e6307c86297533c9ea0373b41c96faf1675cd..f7c35ae176e0d86f1df70709ef9c5d2dc10054f4 100644 |
| --- a/base/files/file_path_watcher_unittest.cc |
| +++ b/base/files/file_path_watcher_unittest.cc |
| @@ -31,6 +31,10 @@ |
| #include "base/threading/thread.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +#if defined(OS_ANDROID) |
| +#include "base/android/path_utils.h" |
| +#endif // defined(OS_ANDROID) |
| + |
| namespace base { |
| namespace { |
| @@ -150,7 +154,17 @@ class FilePathWatcherTest : public testing::Test { |
| // Create a separate file thread in order to test proper thread usage. |
| base::Thread::Options options(MessageLoop::TYPE_IO, 0); |
| ASSERT_TRUE(file_thread_.StartWithOptions(options)); |
| +#if defined(OS_ANDROID) |
| + // Watching files is only permitted when all parent directories are |
| + // accessible, which is not the case for the default temp directory |
| + // on Android which is under /data/data. Use /sdcard instead. |
| + // TODO(pauljensen): Remove this when crbug.com/475568 is fixed. |
| + FilePath parent_dir; |
| + ASSERT_TRUE(android::GetExternalStorageDirectory(&parent_dir)); |
| + ASSERT_TRUE(temp_dir_.CreateUniqueTempDirUnderPath(parent_dir)); |
| +#else // defined(OS_ANDROID) |
| ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| +#endif // defined(OS_ANDROID) |
| collector_ = new NotificationCollector(); |
| } |
| @@ -526,9 +540,13 @@ TEST_F(FilePathWatcherTest, RecursiveWatch) { |
| ASSERT_TRUE(WriteFile(child_dir_file1, "content")); |
| ASSERT_TRUE(WaitForEvents()); |
| +// Apps cannot change file attributes on Android in /sdcard. |
| +// TODO(pauljensen): Re-enable when crbug.com/475568 is fixed. |
|
Mattias Nissler (ping if slow)
2015/04/13 13:06:07
It seems that the referenced bug doesn't cover the
pauljensen
2015/04/13 13:27:04
Done.
|
| +#if !defined(OS_ANDROID) |
| // Modify "$dir/subdir/subdir_child_dir/child_dir_file1" attributes. |
| ASSERT_TRUE(base::MakeFileUnreadable(child_dir_file1)); |
| ASSERT_TRUE(WaitForEvents()); |
| +#endif |
| // Delete "$dir/subdir/subdir_file1". |
| ASSERT_TRUE(base::DeleteFile(subdir_file1, false)); |
| @@ -541,6 +559,11 @@ TEST_F(FilePathWatcherTest, RecursiveWatch) { |
| } |
| #if defined(OS_POSIX) |
| +#if defined(OS_ANDROID) |
| +// Apps cannot create symlinks on Android in /sdcard. |
| +// TODO(pauljensen): Re-enable when crbug.com/475568 is fixed. |
|
Mattias Nissler (ping if slow)
2015/04/13 13:06:07
ditto re scope of the referenced bug and intended
pauljensen
2015/04/13 13:27:04
Done.
|
| +#define RecursiveWithSymLink DISABLED_RecursiveWithSymLink |
| +#endif // defined(OS_ANDROID) |
| TEST_F(FilePathWatcherTest, RecursiveWithSymLink) { |
| if (!FilePathWatcher::RecursiveWatchAvailable()) |
| return; |
| @@ -610,6 +633,11 @@ TEST_F(FilePathWatcherTest, MoveChild) { |
| } |
| // Verify that changing attributes on a file is caught |
| +#if defined(OS_ANDROID) |
| +// Apps don't have permission to change permissions on Android in /sdcard. |
| +// TODO(pauljensen): Re-enable when crbug.com/475568 is fixed. |
|
Mattias Nissler (ping if slow)
2015/04/13 13:06:07
ditto
pauljensen
2015/04/13 13:27:04
Done.
|
| +#define FileAttributesChanged DISABLED_FileAttributesChanged |
| +#endif // defined(OS_ANDROID |
| TEST_F(FilePathWatcherTest, FileAttributesChanged) { |
| ASSERT_TRUE(WriteFile(test_file(), "content")); |
| FilePathWatcher watcher; |