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

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

Powered by Google App Engine
This is Rietveld 408576698