| Index: base/directory_watcher_unittest.cc
|
| ===================================================================
|
| --- base/directory_watcher_unittest.cc (revision 6529)
|
| +++ base/directory_watcher_unittest.cc (working copy)
|
| @@ -6,17 +6,13 @@
|
|
|
| #include <fstream>
|
|
|
| -#include "build/build_config.h"
|
| -
|
| #include "base/file_path.h"
|
| #include "base/file_util.h"
|
| #include "base/logging.h"
|
| #include "base/message_loop.h"
|
| #include "base/path_service.h"
|
| +#include "base/platform_thread.h"
|
| #include "base/string_util.h"
|
| -#if defined(OS_WIN)
|
| -#include "base/win_util.h"
|
| -#endif
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| // For tests where we wait a bit to verify nothing happened
|
| @@ -43,6 +39,7 @@
|
| }
|
|
|
| virtual void OnDirectoryChanged(const FilePath& path) {
|
| + EXPECT_EQ(path.value(), test_dir_.value());
|
| ++directory_mods_;
|
| if (directory_mods_ == quit_mod_count_)
|
| MessageLoop::current()->Quit();
|
| @@ -93,6 +90,16 @@
|
| LoopUntilModsEqual(2);
|
| }
|
|
|
| +TEST_F(DirectoryWatcherTest, NewDir) {
|
| + DirectoryWatcher watcher;
|
| + ASSERT_TRUE(watcher.Watch(test_dir_, this));
|
| +
|
| + FilePath subdir(FILE_PATH_LITERAL("SubDir"));
|
| + ASSERT_TRUE(file_util::CreateDirectory(test_dir_.Append(subdir)));
|
| +
|
| + LoopUntilModsEqual(1);
|
| +}
|
| +
|
| // Verify that modifying a file is caught.
|
| TEST_F(DirectoryWatcherTest, ModifiedFile) {
|
| DirectoryWatcher watcher;
|
| @@ -130,18 +137,18 @@
|
|
|
| // Verify that modifications to a subdirectory isn't noticed.
|
| TEST_F(DirectoryWatcherTest, SubDir) {
|
| -#if defined(OS_WIN)
|
| - // Temporarily disabling test on Vista, see
|
| - // http://code.google.com/p/chromium/issues/detail?id=5072
|
| - // TODO: Enable this test, quickly.
|
| - if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA)
|
| - return;
|
| -#endif
|
| + DirectoryWatcher watcher;
|
| + ASSERT_TRUE(watcher.Watch(test_dir_, this));
|
| +
|
| FilePath subdir(FILE_PATH_LITERAL("SubDir"));
|
| ASSERT_TRUE(file_util::CreateDirectory(test_dir_.Append(subdir)));
|
|
|
| - DirectoryWatcher watcher;
|
| - ASSERT_TRUE(watcher.Watch(test_dir_, this));
|
| + LoopUntilModsEqual(1);
|
| +
|
| + // Wait to make sure we also clear some late notifications.
|
| + PlatformThread::Sleep(2 * kWaitForEventTime);
|
| + directory_mods_ = 0;
|
| +
|
| // Write a file to the subdir.
|
| FilePath test_path = subdir.Append(FILE_PATH_LITERAL("test_file"));
|
| WriteTestDirFile(test_path.value(), "some content");
|
|
|