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

Side by Side Diff: content/browser/browser_thread_unittest.cc

Issue 2082343002: Remove calls to deprecated MessageLoop methods in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Created 4 years, 5 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 <memory> 5 #include <memory>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/run_loop.h"
10 #include "base/sequenced_task_runner_helpers.h" 11 #include "base/sequenced_task_runner_helpers.h"
11 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
12 #include "content/browser/browser_thread_impl.h" 13 #include "content/browser/browser_thread_impl.h"
13 #include "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "testing/platform_test.h" 16 #include "testing/platform_test.h"
16 17
17 namespace content { 18 namespace content {
18 19
19 class BrowserThreadTest : public testing::Test { 20 class BrowserThreadTest : public testing::Test {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // It's kind of ugly to make this mutable - solely so we can post the Quit 70 // It's kind of ugly to make this mutable - solely so we can post the Quit
70 // Task from Release(). This should be fixed. 71 // Task from Release(). This should be fixed.
71 mutable base::MessageLoop loop_; 72 mutable base::MessageLoop loop_;
72 }; 73 };
73 74
74 TEST_F(BrowserThreadTest, PostTask) { 75 TEST_F(BrowserThreadTest, PostTask) {
75 BrowserThread::PostTask( 76 BrowserThread::PostTask(
76 BrowserThread::FILE, 77 BrowserThread::FILE,
77 FROM_HERE, 78 FROM_HERE,
78 base::Bind(&BasicFunction, base::MessageLoop::current())); 79 base::Bind(&BasicFunction, base::MessageLoop::current()));
79 base::MessageLoop::current()->Run(); 80 base::RunLoop().Run();
80 } 81 }
81 82
82 TEST_F(BrowserThreadTest, Release) { 83 TEST_F(BrowserThreadTest, Release) {
83 BrowserThread::ReleaseSoon(BrowserThread::UI, FROM_HERE, this); 84 BrowserThread::ReleaseSoon(BrowserThread::UI, FROM_HERE, this);
84 base::MessageLoop::current()->Run(); 85 base::RunLoop().Run();
85 } 86 }
86 87
87 TEST_F(BrowserThreadTest, ReleasedOnCorrectThread) { 88 TEST_F(BrowserThreadTest, ReleasedOnCorrectThread) {
88 { 89 {
89 scoped_refptr<DeletedOnFile> test( 90 scoped_refptr<DeletedOnFile> test(
90 new DeletedOnFile(base::MessageLoop::current())); 91 new DeletedOnFile(base::MessageLoop::current()));
91 } 92 }
92 base::MessageLoop::current()->Run(); 93 base::RunLoop().Run();
93 } 94 }
94 95
95 TEST_F(BrowserThreadTest, PostTaskViaTaskRunner) { 96 TEST_F(BrowserThreadTest, PostTaskViaTaskRunner) {
96 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 97 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
97 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); 98 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE);
98 task_runner->PostTask( 99 task_runner->PostTask(
99 FROM_HERE, base::Bind(&BasicFunction, base::MessageLoop::current())); 100 FROM_HERE, base::Bind(&BasicFunction, base::MessageLoop::current()));
100 base::MessageLoop::current()->Run(); 101 base::RunLoop().Run();
101 } 102 }
102 103
103 TEST_F(BrowserThreadTest, ReleaseViaTaskRunner) { 104 TEST_F(BrowserThreadTest, ReleaseViaTaskRunner) {
104 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 105 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
105 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); 106 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
106 task_runner->ReleaseSoon(FROM_HERE, this); 107 task_runner->ReleaseSoon(FROM_HERE, this);
107 base::MessageLoop::current()->Run(); 108 base::RunLoop().Run();
108 } 109 }
109 110
110 TEST_F(BrowserThreadTest, PostTaskAndReply) { 111 TEST_F(BrowserThreadTest, PostTaskAndReply) {
111 // Most of the heavy testing for PostTaskAndReply() is done inside the 112 // Most of the heavy testing for PostTaskAndReply() is done inside the
112 // task runner test. This just makes sure we get piped through at all. 113 // task runner test. This just makes sure we get piped through at all.
113 ASSERT_TRUE(BrowserThread::PostTaskAndReply( 114 ASSERT_TRUE(BrowserThread::PostTaskAndReply(
114 BrowserThread::FILE, FROM_HERE, base::Bind(&base::DoNothing), 115 BrowserThread::FILE, FROM_HERE, base::Bind(&base::DoNothing),
115 base::Bind(&base::MessageLoop::QuitWhenIdle, 116 base::Bind(&base::MessageLoop::QuitWhenIdle,
116 base::Unretained(base::MessageLoop::current()->current())))); 117 base::Unretained(base::MessageLoop::current()->current()))));
117 base::MessageLoop::current()->Run(); 118 base::RunLoop().Run();
118 } 119 }
119 120
120 } // namespace content 121 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/blob_storage/blob_url_request_job_unittest.cc ('k') | content/browser/byte_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698