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

Side by Side Diff: remoting/base/auto_thread_unittest.cc

Issue 1394803004: Don't use base::MessageLoop::{Quit,QuitClosure} in remoting/ (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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/scoped_native_library.h" 8 #include "base/scoped_native_library.h"
9 #include "remoting/base/auto_thread.h" 9 #include "remoting/base/auto_thread.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 public: 60 public:
61 AutoThreadTest() : message_loop_quit_correctly_(false) { 61 AutoThreadTest() : message_loop_quit_correctly_(false) {
62 } 62 }
63 63
64 void RunMessageLoop() { 64 void RunMessageLoop() {
65 // Release |main_task_runner_|, then run |message_loop_| until other 65 // Release |main_task_runner_|, then run |message_loop_| until other
66 // references created in tests are gone. We also post a delayed quit 66 // references created in tests are gone. We also post a delayed quit
67 // task to |message_loop_| so the test will not hang on failure. 67 // task to |message_loop_| so the test will not hang on failure.
68 main_task_runner_ = NULL; 68 main_task_runner_ = NULL;
69 message_loop_.PostDelayedTask(FROM_HERE, 69 message_loop_.PostDelayedTask(FROM_HERE,
70 base::MessageLoop::QuitClosure(), 70 base::MessageLoop::QuitWhenIdleClosure(),
71 base::TimeDelta::FromSeconds(5)); 71 base::TimeDelta::FromSeconds(5));
72 message_loop_.Run(); 72 message_loop_.Run();
73 } 73 }
74 74
75 void SetUp() override { 75 void SetUp() override {
76 main_task_runner_ = new AutoThreadTaskRunner( 76 main_task_runner_ = new AutoThreadTaskRunner(
77 message_loop_.task_runner(), 77 message_loop_.task_runner(),
78 base::Bind(&AutoThreadTest::QuitMainMessageLoop, 78 base::Bind(&AutoThreadTest::QuitMainMessageLoop,
79 base::Unretained(this))); 79 base::Unretained(this)));
80 } 80 }
81 81
82 void TearDown() override { 82 void TearDown() override {
83 // Verify that |message_loop_| was quit by the AutoThreadTaskRunner. 83 // Verify that |message_loop_| was quit by the AutoThreadTaskRunner.
84 EXPECT_TRUE(message_loop_quit_correctly_); 84 EXPECT_TRUE(message_loop_quit_correctly_);
85 } 85 }
86 86
87 protected: 87 protected:
88 void QuitMainMessageLoop() { 88 void QuitMainMessageLoop() {
89 message_loop_quit_correctly_ = true; 89 message_loop_quit_correctly_ = true;
90 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); 90 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
91 } 91 }
92 92
93 base::MessageLoop message_loop_; 93 base::MessageLoop message_loop_;
94 bool message_loop_quit_correctly_; 94 bool message_loop_quit_correctly_;
95 scoped_refptr<AutoThreadTaskRunner> main_task_runner_; 95 scoped_refptr<AutoThreadTaskRunner> main_task_runner_;
96 }; 96 };
97 97
98 TEST_F(AutoThreadTest, StartAndStop) { 98 TEST_F(AutoThreadTest, StartAndStop) {
99 // Create an AutoThread joined by our MessageLoop. 99 // Create an AutoThread joined by our MessageLoop.
100 scoped_refptr<base::TaskRunner> task_runner = 100 scoped_refptr<base::TaskRunner> task_runner =
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // Whether the thread is the "main" STA apartment depends upon previous 192 // Whether the thread is the "main" STA apartment depends upon previous
193 // COM activity in this test process, so allow both types here. 193 // COM activity in this test process, so allow both types here.
194 EXPECT_TRUE(apt_type == APTTYPE_MAINSTA || apt_type == APTTYPE_STA); 194 EXPECT_TRUE(apt_type == APTTYPE_MAINSTA || apt_type == APTTYPE_STA);
195 } else { 195 } else {
196 EXPECT_EQ(E_NOTIMPL, hresult); 196 EXPECT_EQ(E_NOTIMPL, hresult);
197 } 197 }
198 } 198 }
199 #endif // defined(OS_WIN) 199 #endif // defined(OS_WIN)
200 200
201 } // namespace remoting 201 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/auto_thread_task_runner_unittest.cc ('k') | remoting/client/client_status_logger_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698