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

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

Issue 3869003: Const-ify RefCountedThreadSafe::AddRef and Release. (Closed)
Patch Set: actually remove the cast Created 10 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
« no previous file with comments | « chrome/browser/browser_thread.h ('k') | chrome/browser/chrome_plugin_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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/message_loop_proxy.h" 6 #include "base/message_loop_proxy.h"
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "chrome/browser/browser_thread.h" 8 #include "chrome/browser/browser_thread.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h" 10 #include "testing/platform_test.h"
11 11
12 class BrowserThreadTest : public testing::Test { 12 class BrowserThreadTest : public testing::Test {
13 public: 13 public:
14 void Release() { 14 void Release() const {
15 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 15 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
16 loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask); 16 loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask);
17 } 17 }
18 18
19 protected: 19 protected:
20 virtual void SetUp() { 20 virtual void SetUp() {
21 ui_thread_.reset(new BrowserThread(BrowserThread::UI)); 21 ui_thread_.reset(new BrowserThread(BrowserThread::UI));
22 file_thread_.reset(new BrowserThread(BrowserThread::FILE)); 22 file_thread_.reset(new BrowserThread(BrowserThread::FILE));
23 ui_thread_->Start(); 23 ui_thread_->Start();
24 file_thread_->Start(); 24 file_thread_->Start();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 NeverDeleted, BrowserThread::DeleteOnWebKitThread> { 70 NeverDeleted, BrowserThread::DeleteOnWebKitThread> {
71 public: 71 public:
72 ~NeverDeleted() { 72 ~NeverDeleted() {
73 CHECK(false); 73 CHECK(false);
74 } 74 }
75 }; 75 };
76 76
77 private: 77 private:
78 scoped_ptr<BrowserThread> ui_thread_; 78 scoped_ptr<BrowserThread> ui_thread_;
79 scoped_ptr<BrowserThread> file_thread_; 79 scoped_ptr<BrowserThread> file_thread_;
80 MessageLoop loop_; 80 mutable MessageLoop loop_;
81 }; 81 };
82 82
83 TEST_F(BrowserThreadTest, PostTask) { 83 TEST_F(BrowserThreadTest, PostTask) {
84 BrowserThread::PostTask( 84 BrowserThread::PostTask(
85 BrowserThread::FILE, FROM_HERE, 85 BrowserThread::FILE, FROM_HERE,
86 NewRunnableFunction(&BasicFunction, MessageLoop::current())); 86 NewRunnableFunction(&BasicFunction, MessageLoop::current()));
87 MessageLoop::current()->Run(); 87 MessageLoop::current()->Run();
88 } 88 }
89 89
90 TEST_F(BrowserThreadTest, Release) { 90 TEST_F(BrowserThreadTest, Release) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 io_thread->Start(); 155 io_thread->Start();
156 } 156 }
157 bool deleted = false; 157 bool deleted = false;
158 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = 158 scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
159 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 159 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
160 bool ret = message_loop_proxy->PostTask(FROM_HERE, new DummyTask(&deleted)); 160 bool ret = message_loop_proxy->PostTask(FROM_HERE, new DummyTask(&deleted));
161 EXPECT_FALSE(ret); 161 EXPECT_FALSE(ret);
162 EXPECT_TRUE(deleted); 162 EXPECT_TRUE(deleted);
163 } 163 }
164 164
OLDNEW
« no previous file with comments | « chrome/browser/browser_thread.h ('k') | chrome/browser/chrome_plugin_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698