summaryrefslogtreecommitdiffstats
path: root/base/directory_watcher_unittest.cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-03 10:43:17 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-03 10:43:17 +0000
commit5b6dc77fd4c72985aec5197cb4e03e763aff631f (patch)
tree4fdc430f814d604202d329bc41fb3cde9deb941c /base/directory_watcher_unittest.cc
parenta730335f3dfc06d91741790f79fc30463fb18dfe (diff)
downloadchromium_src-5b6dc77fd4c72985aec5197cb4e03e763aff631f.zip
chromium_src-5b6dc77fd4c72985aec5197cb4e03e763aff631f.tar.gz
chromium_src-5b6dc77fd4c72985aec5197cb4e03e763aff631f.tar.bz2
Reverting 7537. DirectoryWatcherTest.SubDir was passing on my XP box, but fails on the buildbot.
TBR=maruel Review URL: http://codereview.chromium.org/17048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7538 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/directory_watcher_unittest.cc')
-rw-r--r--base/directory_watcher_unittest.cc37
1 files changed, 15 insertions, 22 deletions
diff --git a/base/directory_watcher_unittest.cc b/base/directory_watcher_unittest.cc
index 27947ff..39f64bb 100644
--- a/base/directory_watcher_unittest.cc
+++ b/base/directory_watcher_unittest.cc
@@ -6,13 +6,17 @@
#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
@@ -39,7 +43,6 @@ class DirectoryWatcherTest : public testing::Test,
}
virtual void OnDirectoryChanged(const FilePath& path) {
- EXPECT_EQ(path.value(), test_dir_.value());
++directory_mods_;
if (directory_mods_ == quit_mod_count_)
MessageLoop::current()->Quit();
@@ -54,7 +57,6 @@ class DirectoryWatcherTest : public testing::Test,
// Write |content| to a file under the test directory.
void WriteTestDirFile(const FilePath::StringType& filename,
const std::string& content) {
- EXPECT_FALSE(FilePath(filename).IsAbsolute());
FilePath path = test_dir_.Append(filename);
std::ofstream file;
@@ -128,30 +130,21 @@ TEST_F(DirectoryWatcherTest, Unregister) {
// Verify that modifications to a subdirectory isn't noticed.
TEST_F(DirectoryWatcherTest, SubDir) {
- FilePath subdir(FILE_PATH_LITERAL("SubDir"));
- ASSERT_TRUE(file_util::CreateDirectory(test_dir_.Append(subdir)));
-
- // Create a file in the subdir.
- FilePath test_path = subdir.Append(FILE_PATH_LITERAL("test_file"));
- WriteTestDirFile(test_path.value(), "some content");
-
#if defined(OS_WIN)
- // We will flush the write buffer now to ensure it won't interfere
- // with the notifications.
- FilePath full_path(test_dir_.Append(test_path));
- HANDLE file_handle = CreateFile(full_path.value().c_str(),
- GENERIC_READ | GENERIC_WRITE,
- 0, NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL, NULL);
- ASSERT_TRUE(file_handle != INVALID_HANDLE_VALUE);
- ASSERT_TRUE(FlushFileBuffers(file_handle));
- CloseHandle(file_handle);
+ // 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
+ FilePath subdir(FILE_PATH_LITERAL("SubDir"));
+ ASSERT_TRUE(file_util::CreateDirectory(test_dir_.Append(subdir)));
DirectoryWatcher watcher;
ASSERT_TRUE(watcher.Watch(test_dir_, this));
-
- WriteTestDirFile(test_path.value(), "changed content");
+ // Write a file to the subdir.
+ FilePath test_path = subdir.Append(FILE_PATH_LITERAL("test_file"));
+ WriteTestDirFile(test_path.value(), "some content");
// We won't get a notification, so we just wait around a bit to verify
// that notification doesn't come.