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

Side by Side Diff: net/dns/watching_file_reader_unittest.cc

Issue 8735014: base::Bind fixes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed compile issues Created 9 years 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 | « net/dns/serial_worker_unittest.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/dns/watching_file_reader.h" 5 #include "net/dns/watching_file_reader.h"
6 6
7 #include "base/bind.h"
7 #include "base/message_loop.h" 8 #include "base/message_loop.h"
8 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
9 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace net { 13 namespace net {
13 14
14 namespace { 15 namespace {
15 16
16 class WatchingFileReaderTest : public testing::Test { 17 class WatchingFileReaderTest : public testing::Test {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 BreakNow("OnWatch"); 99 BreakNow("OnWatch");
99 return !fail_on_watch_; 100 return !fail_on_watch_;
100 } 101 }
101 102
102 void OnWork() { 103 void OnWork() {
103 EXPECT_TRUE(message_loop_ == MessageLoop::current()); 104 EXPECT_TRUE(message_loop_ == MessageLoop::current());
104 BreakNow("OnWork"); 105 BreakNow("OnWork");
105 } 106 }
106 107
107 protected: 108 protected:
108 friend class BreakTask; 109 void BreakCallback(std::string breakpoint) {
109 class BreakTask : public Task { 110 breakpoint_ = breakpoint;
110 public: 111 MessageLoop::current()->QuitNow();
111 BreakTask(WatchingFileReaderTest* test, std::string breakpoint) 112 }
112 : test_(test), breakpoint_(breakpoint) {}
113 virtual ~BreakTask() {}
114 virtual void Run() OVERRIDE {
115 test_->breakpoint_ = breakpoint_;
116 MessageLoop::current()->QuitNow();
117 }
118 private:
119 WatchingFileReaderTest* test_;
120 std::string breakpoint_;
121 };
122 113
123 void BreakNow(std::string b) { 114 void BreakNow(std::string b) {
124 message_loop_->PostTask(FROM_HERE, new BreakTask(this, b)); 115 message_loop_->PostTask(FROM_HERE,
116 base::Bind(&WatchingFileReaderTest::BreakCallback,
117 base::Unretained(this), b));
125 } 118 }
126 119
127 void RunUntilBreak(std::string b) { 120 void RunUntilBreak(std::string b) {
128 message_loop_->Run(); 121 message_loop_->Run();
129 ASSERT_EQ(breakpoint_, b); 122 ASSERT_EQ(breakpoint_, b);
130 } 123 }
131 124
132 WatchingFileReaderTest() 125 WatchingFileReaderTest()
133 : watcher_shim_(NULL), 126 : watcher_shim_(NULL),
134 fail_on_watch_(false), 127 fail_on_watch_(false),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 watcher_shim_->PathChanged(); 159 watcher_shim_->PathChanged();
167 RunUntilBreak("OnWork"); 160 RunUntilBreak("OnWork");
168 161
169 message_loop_->AssertIdle(); 162 message_loop_->AssertIdle();
170 } 163 }
171 164
172 } // namespace 165 } // namespace
173 166
174 } // namespace net 167 } // namespace net
175 168
OLDNEW
« no previous file with comments | « net/dns/serial_worker_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698