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

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

Issue 2314853004: Remove calls to deprecated MessageLoop methods in chromeos. (Closed)
Patch Set: Created 4 years, 3 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 #include <stddef.h> 6 #include <stddef.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/process/kill.h" 13 #include "base/process/kill.h"
14 #include "base/process/process.h" 14 #include "base/process/process.h"
15 #include "base/run_loop.h"
15 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
16 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
17 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
18 #include "chromeos/process_proxy/process_proxy_registry.h" 19 #include "chromeos/process_proxy/process_proxy_registry.h"
19 20
20 namespace chromeos { 21 namespace chromeos {
21 22
22 namespace { 23 namespace {
23 24
24 // The test line must have all distinct characters. 25 // The test line must have all distinct characters.
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 201 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
201 } 202 }
202 203
203 void RunTest() { 204 void RunTest() {
204 base::ThreadTaskRunnerHandle::Get()->PostTask( 205 base::ThreadTaskRunnerHandle::Get()->PostTask(
205 FROM_HERE, base::Bind(&ProcessProxyTest::InitRegistryTest, 206 FROM_HERE, base::Bind(&ProcessProxyTest::InitRegistryTest,
206 base::Unretained(this))); 207 base::Unretained(this)));
207 208
208 // Wait until all data from output watcher is received (QuitTask will be 209 // Wait until all data from output watcher is received (QuitTask will be
209 // fired on watcher thread). 210 // fired on watcher thread).
210 base::MessageLoop::current()->Run(); 211 base::RunLoop().Run();
211 212
212 base::ThreadTaskRunnerHandle::Get()->PostTask( 213 base::ThreadTaskRunnerHandle::Get()->PostTask(
213 FROM_HERE, 214 FROM_HERE,
214 base::Bind(&ProcessProxyTest::EndRegistryTest, base::Unretained(this))); 215 base::Bind(&ProcessProxyTest::EndRegistryTest, base::Unretained(this)));
215 216
216 // Wait until we clean up the process proxy. 217 // Wait until we clean up the process proxy.
217 base::MessageLoop::current()->Run(); 218 base::RunLoop().Run();
218 } 219 }
219 220
220 std::unique_ptr<TestRunner> test_runner_; 221 std::unique_ptr<TestRunner> test_runner_;
221 222
222 private: 223 private:
223 ProcessProxyRegistry* registry_; 224 ProcessProxyRegistry* registry_;
224 int terminal_id_; 225 int terminal_id_;
225 226
226 base::MessageLoop message_loop_; 227 base::MessageLoop message_loop_;
227 }; 228 };
228 229
229 // Test will open new process that will run cat command, and verify data we 230 // Test will open new process that will run cat command, and verify data we
230 // write to process gets echoed back. 231 // write to process gets echoed back.
231 TEST_F(ProcessProxyTest, RegistryTest) { 232 TEST_F(ProcessProxyTest, RegistryTest) {
232 test_runner_.reset(new RegistryTestRunner()); 233 test_runner_.reset(new RegistryTestRunner());
233 RunTest(); 234 RunTest();
234 } 235 }
235 236
236 // Open new process, then kill it. Verifiy that we detect when the process dies. 237 // Open new process, then kill it. Verifiy that we detect when the process dies.
237 TEST_F(ProcessProxyTest, RegistryNotifiedOnProcessExit) { 238 TEST_F(ProcessProxyTest, RegistryNotifiedOnProcessExit) {
238 test_runner_.reset(new RegistryNotifiedOnProcessExitTestRunner()); 239 test_runner_.reset(new RegistryNotifiedOnProcessExitTestRunner());
239 RunTest(); 240 RunTest();
240 } 241 }
241 242
242 } // namespace chromeos 243 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698