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

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

Issue 8735014: base::Bind fixes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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/serial_worker.h" 5 #include "net/dns/serial_worker.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/synchronization/lock.h" 8 #include "base/synchronization/lock.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 work_called_.Signal(); 53 work_called_.Signal();
54 } 54 }
55 55
56 void OnWorkFinished() { 56 void OnWorkFinished() {
57 EXPECT_TRUE(message_loop_ == MessageLoop::current()); 57 EXPECT_TRUE(message_loop_ == MessageLoop::current());
58 EXPECT_EQ(output_value_, input_value_); 58 EXPECT_EQ(output_value_, input_value_);
59 BreakNow("OnWorkFinished"); 59 BreakNow("OnWorkFinished");
60 } 60 }
61 61
62 protected: 62 protected:
63 friend class BreakTask; 63 void BreakCallback(std::string breakpoint) {
64 class BreakTask : public Task { 64 breakpoint_ = breakpoint;
65 public: 65 MessageLoop::current()->QuitNow();
66 BreakTask(SerialWorkerTest* test, std::string breakpoint) 66 }
67 : test_(test), breakpoint_(breakpoint) {}
68 virtual ~BreakTask() {}
69 virtual void Run() OVERRIDE {
70 test_->breakpoint_ = breakpoint_;
71 MessageLoop::current()->QuitNow();
72 }
73 private:
74 SerialWorkerTest* test_;
75 std::string breakpoint_;
76 };
77 67
78 void BreakNow(std::string b) { 68 void BreakNow(std::string b) {
79 message_loop_->PostTask(FROM_HERE, new BreakTask(this, b)); 69 message_loop_->PostTask(FROM_HERE,
70 base::Bind(&SerialWorkerTest::BreakCallback, this, b));
80 } 71 }
81 72
82 void RunUntilBreak(std::string b) { 73 void RunUntilBreak(std::string b) {
83 message_loop_->Run(); 74 message_loop_->Run();
84 ASSERT_EQ(breakpoint_, b); 75 ASSERT_EQ(breakpoint_, b);
85 } 76 }
86 77
87 SerialWorkerTest() 78 SerialWorkerTest()
88 : input_value_(0), 79 : input_value_(0),
89 output_value_(-1), 80 output_value_(-1),
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 RunUntilBreak("OnWorkFinished"); 152 RunUntilBreak("OnWorkFinished");
162 153
163 // No more tasks should remain. 154 // No more tasks should remain.
164 message_loop_->AssertIdle(); 155 message_loop_->AssertIdle();
165 } 156 }
166 157
167 } // namespace 158 } // namespace
168 159
169 } // namespace net 160 } // namespace net
170 161
OLDNEW
« no previous file with comments | « no previous file | net/dns/watching_file_reader_unittest.cc » ('j') | net/dns/watching_file_reader_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698