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

Side by Side Diff: chromeos/process_proxy/process_proxy_unittest.cc

Issue 1396083003: Don't use base::MessageLoop::{Quit,QuitClosure} in ash/, chromeos/, device/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <gtest/gtest.h> 5 #include <gtest/gtest.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 for (size_t i = 0; i < output.length(); i++) { 72 for (size_t i = 0; i < output.length(); i++) {
73 // The character output[i] should be next in at least one of the lines we 73 // The character output[i] should be next in at least one of the lines we
74 // are testing. 74 // are testing.
75 valid = (ProcessReceivedCharacter(output[i], 0) || 75 valid = (ProcessReceivedCharacter(output[i], 0) ||
76 ProcessReceivedCharacter(output[i], 1)); 76 ProcessReceivedCharacter(output[i], 1));
77 EXPECT_TRUE(valid) << "Received: " << output; 77 EXPECT_TRUE(valid) << "Received: " << output;
78 } 78 }
79 79
80 if (!valid || TestSucceeded()) { 80 if (!valid || TestSucceeded()) {
81 base::ThreadTaskRunnerHandle::Get()->PostTask( 81 base::ThreadTaskRunnerHandle::Get()->PostTask(
82 FROM_HERE, base::MessageLoop::QuitClosure()); 82 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
83 } 83 }
84 } 84 }
85 85
86 void StartRegistryTest(ProcessProxyRegistry* registry) override { 86 void StartRegistryTest(ProcessProxyRegistry* registry) override {
87 for (int i = 0; i < kTestLineNum; i++) { 87 for (int i = 0; i < kTestLineNum; i++) {
88 EXPECT_TRUE(registry->SendInput(pid_, kTestLineToSend)); 88 EXPECT_TRUE(registry->SendInput(pid_, kTestLineToSend));
89 } 89 }
90 } 90 }
91 91
92 private: 92 private:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 output_received_ = true; 135 output_received_ = true;
136 EXPECT_EQ(type, "stdout"); 136 EXPECT_EQ(type, "stdout");
137 EXPECT_EQ(output, "p"); 137 EXPECT_EQ(output, "p");
138 base::Process process = 138 base::Process process =
139 base::Process::DeprecatedGetProcessFromHandle(pid_); 139 base::Process::DeprecatedGetProcessFromHandle(pid_);
140 process.Terminate(0, true); 140 process.Terminate(0, true);
141 return; 141 return;
142 } 142 }
143 EXPECT_EQ("exit", type); 143 EXPECT_EQ("exit", type);
144 base::ThreadTaskRunnerHandle::Get()->PostTask( 144 base::ThreadTaskRunnerHandle::Get()->PostTask(
145 FROM_HERE, base::MessageLoop::QuitClosure()); 145 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
146 } 146 }
147 147
148 void StartRegistryTest(ProcessProxyRegistry* registry) override { 148 void StartRegistryTest(ProcessProxyRegistry* registry) override {
149 EXPECT_TRUE(registry->SendInput(pid_, "p")); 149 EXPECT_TRUE(registry->SendInput(pid_, "p"));
150 } 150 }
151 151
152 private: 152 private:
153 bool output_received_; 153 bool output_received_;
154 }; 154 };
155 155
156 class SigIntTestRunner : public TestRunner { 156 class SigIntTestRunner : public TestRunner {
157 public: 157 public:
158 ~SigIntTestRunner() override {} 158 ~SigIntTestRunner() override {}
159 159
160 void SetupExpectations(pid_t pid) override { pid_ = pid; } 160 void SetupExpectations(pid_t pid) override { pid_ = pid; }
161 161
162 void OnSomeRead(pid_t pid, 162 void OnSomeRead(pid_t pid,
163 const std::string& type, 163 const std::string& type,
164 const std::string& output) override { 164 const std::string& output) override {
165 EXPECT_EQ(pid_, pid); 165 EXPECT_EQ(pid_, pid);
166 // We may receive ^C on stdout, but we don't care about that, as long as we 166 // We may receive ^C on stdout, but we don't care about that, as long as we
167 // eventually received exit event. 167 // eventually received exit event.
168 if (type == "exit") { 168 if (type == "exit") {
169 base::ThreadTaskRunnerHandle::Get()->PostTask( 169 base::ThreadTaskRunnerHandle::Get()->PostTask(
170 FROM_HERE, base::MessageLoop::QuitClosure()); 170 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
171 } 171 }
172 } 172 }
173 173
174 void StartRegistryTest(ProcessProxyRegistry* registry) override { 174 void StartRegistryTest(ProcessProxyRegistry* registry) override {
175 // Send SingInt and verify the process exited. 175 // Send SingInt and verify the process exited.
176 EXPECT_TRUE(registry->SendInput(pid_, "\003")); 176 EXPECT_TRUE(registry->SendInput(pid_, "\003"));
177 } 177 }
178 }; 178 };
179 179
180 } // namespace 180 } // namespace
(...skipping 23 matching lines...) Expand all
204 EXPECT_NE(base::TERMINATION_STATUS_STILL_RUNNING, status); 204 EXPECT_NE(base::TERMINATION_STATUS_STILL_RUNNING, status);
205 if (status == base::TERMINATION_STATUS_STILL_RUNNING) { 205 if (status == base::TERMINATION_STATUS_STILL_RUNNING) {
206 base::Process process = 206 base::Process process =
207 base::Process::DeprecatedGetProcessFromHandle(pid_); 207 base::Process::DeprecatedGetProcessFromHandle(pid_);
208 process.Terminate(0, true); 208 process.Terminate(0, true);
209 } 209 }
210 210
211 registry_->ShutDown(); 211 registry_->ShutDown();
212 212
213 base::ThreadTaskRunnerHandle::Get()->PostTask( 213 base::ThreadTaskRunnerHandle::Get()->PostTask(
214 FROM_HERE, base::MessageLoop::QuitClosure()); 214 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
215 } 215 }
216 216
217 void RunTest() { 217 void RunTest() {
218 base::ThreadTaskRunnerHandle::Get()->PostTask( 218 base::ThreadTaskRunnerHandle::Get()->PostTask(
219 FROM_HERE, base::Bind(&ProcessProxyTest::InitRegistryTest, 219 FROM_HERE, base::Bind(&ProcessProxyTest::InitRegistryTest,
220 base::Unretained(this))); 220 base::Unretained(this)));
221 221
222 // Wait until all data from output watcher is received (QuitTask will be 222 // Wait until all data from output watcher is received (QuitTask will be
223 // fired on watcher thread). 223 // fired on watcher thread).
224 base::MessageLoop::current()->Run(); 224 base::MessageLoop::current()->Run();
(...skipping 29 matching lines...) Expand all
254 } 254 }
255 255
256 // Test verifies that \003 message send to process is processed as SigInt. 256 // Test verifies that \003 message send to process is processed as SigInt.
257 // Timing out on the waterfall: http://crbug.com/115064 257 // Timing out on the waterfall: http://crbug.com/115064
258 TEST_F(ProcessProxyTest, DISABLED_SigInt) { 258 TEST_F(ProcessProxyTest, DISABLED_SigInt) {
259 test_runner_.reset(new SigIntTestRunner()); 259 test_runner_.reset(new SigIntTestRunner());
260 RunTest(); 260 RunTest();
261 } 261 }
262 262
263 } // namespace chromeos 263 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/login/auth/mock_url_fetchers.cc ('k') | device/bluetooth/bluetooth_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698