diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 18:37:42 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 18:37:42 +0000 |
commit | bead9cc5d8507fc4da6c66c09858bfae3daeea73 (patch) | |
tree | 8211104dd75698242cb11316582843834180cf24 /base/directory_watcher_unittest.cc | |
parent | a1660b5032541493766509f4e2835abc81541564 (diff) | |
download | chromium_src-bead9cc5d8507fc4da6c66c09858bfae3daeea73.zip chromium_src-bead9cc5d8507fc4da6c66c09858bfae3daeea73.tar.gz chromium_src-bead9cc5d8507fc4da6c66c09858bfae3daeea73.tar.bz2 |
[GTTF] Make DirectoryWatcher tests faster by about 15 seconds.
TEST=Covered by base_unittests.
BUG=none
Review URL: http://codereview.chromium.org/371062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31451 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/directory_watcher_unittest.cc')
-rw-r--r-- | base/directory_watcher_unittest.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/base/directory_watcher_unittest.cc b/base/directory_watcher_unittest.cc index 31a0dc4..9d4c9f6 100644 --- a/base/directory_watcher_unittest.cc +++ b/base/directory_watcher_unittest.cc @@ -22,7 +22,7 @@ namespace { // For tests where we wait a bit to verify nothing happened -const int kWaitForEventTime = 1000; +const int kWaitForEventTime = 500; class DirectoryWatcherTest : public testing::Test { public: @@ -86,7 +86,10 @@ class DirectoryWatcherTest : public testing::Test { // Check that we get at least the expected number of notified delegates. if (expected_notified_delegates_ - notified_delegates_ > 0) loop_.Run(); + EXPECT_EQ(expected_notified_delegates_, notified_delegates_); + } + void VerifyNoExtraNotifications() { // Check that we get no more than the expected number of notified delegates. loop_.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask, kWaitForEventTime); @@ -208,6 +211,7 @@ TEST_F(DirectoryWatcherTest, Unregister) { SetExpectedNumberOfNotifiedDelegates(0); ASSERT_TRUE(WriteTestFile(test_dir_.AppendASCII("test_file"), "content")); VerifyExpectedNumberOfNotifiedDelegates(); + VerifyNoExtraNotifications(); } TEST_F(DirectoryWatcherTest, SubDirRecursive) { @@ -249,6 +253,7 @@ TEST_F(DirectoryWatcherTest, SubDirNonRecursive) { SetExpectedNumberOfNotifiedDelegates(0); ASSERT_TRUE(WriteTestFile(subdir.AppendASCII("test_file"), "other content")); VerifyExpectedNumberOfNotifiedDelegates(); + VerifyNoExtraNotifications(); } namespace { @@ -307,14 +312,12 @@ TEST_F(DirectoryWatcherTest, MultipleWatchersSingleFile) { } TEST_F(DirectoryWatcherTest, MultipleWatchersDifferentFiles) { - const int kNumberOfWatchers = 5; + const int kNumberOfWatchers = 3; DirectoryWatcher watchers[kNumberOfWatchers]; TestDelegate delegates[kNumberOfWatchers] = { TestDelegate(this), TestDelegate(this), TestDelegate(this), - TestDelegate(this), - TestDelegate(this) }; FilePath subdirs[kNumberOfWatchers]; for (int i = 0; i < kNumberOfWatchers; i++) { @@ -333,6 +336,7 @@ TEST_F(DirectoryWatcherTest, MultipleWatchersDifferentFiles) { SetExpectedNumberOfNotifiedDelegates(1); ASSERT_TRUE(WriteTestFile(subdirs[i].AppendASCII("test_file"), "content")); VerifyExpectedNumberOfNotifiedDelegates(); + VerifyNoExtraNotifications(); loop_.RunAllPending(); } @@ -390,6 +394,7 @@ TEST_F(DirectoryWatcherTest, MoveFileAcrossWatches) { ASSERT_TRUE(WriteTestFile(subdir1.AppendASCII("file"), "some content")); SyncIfPOSIX(); VerifyExpectedNumberOfNotifiedDelegates(); + VerifyNoExtraNotifications(); delegate1.reset(); delegate2.reset(); @@ -405,6 +410,7 @@ TEST_F(DirectoryWatcherTest, MoveFileAcrossWatches) { SetExpectedNumberOfNotifiedDelegates(1); ASSERT_TRUE(WriteTestFile(subdir2.AppendASCII("file"), "other content")); VerifyExpectedNumberOfNotifiedDelegates(); + VerifyNoExtraNotifications(); } #endif // defined(OS_WIN) || defined(OS_MACOSX) |