OLD | NEW |
---|---|
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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 class BrowserThreadTest : public testing::Test { | 22 class BrowserThreadTest : public testing::Test { |
23 public: | 23 public: |
24 void Release() const { | 24 void Release() const { |
25 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 25 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
26 loop_.task_runner()->PostTask(FROM_HERE, | 26 loop_.task_runner()->PostTask(FROM_HERE, |
27 base::MessageLoop::QuitWhenIdleClosure()); | 27 base::MessageLoop::QuitWhenIdleClosure()); |
28 } | 28 } |
29 | 29 |
30 void StopUIThread() { ui_thread_->Stop(); } | 30 void StopUIThread() { ui_thread_->Stop(); } |
31 | 31 |
32 ~BrowserThreadTest() override { | |
33 ui_thread_ = nullptr; | |
jam
2017/03/02 01:07:04
nit: put it in Teardown to match Setup, i.e. move
| |
34 file_thread_ = nullptr; | |
35 BrowserThreadImpl::ResetGlobalsForTesting(BrowserThread::UI); | |
36 BrowserThreadImpl::ResetGlobalsForTesting(BrowserThread::FILE); | |
37 } | |
38 | |
32 protected: | 39 protected: |
33 void SetUp() override { | 40 void SetUp() override { |
34 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI)); | 41 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI)); |
35 file_thread_.reset(new BrowserThreadImpl(BrowserThread::FILE)); | 42 file_thread_.reset(new BrowserThreadImpl(BrowserThread::FILE)); |
36 ui_thread_->Start(); | 43 ui_thread_->Start(); |
37 file_thread_->Start(); | 44 file_thread_->Start(); |
38 } | 45 } |
39 | 46 |
40 void TearDown() override { | 47 void TearDown() override { |
41 StopUIThread(); | 48 StopUIThread(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 UIThreadDestructionObserver observer(&did_shutdown, loop.QuitClosure()); | 173 UIThreadDestructionObserver observer(&did_shutdown, loop.QuitClosure()); |
167 base::ThreadTaskRunnerHandle::Get()->PostTask( | 174 base::ThreadTaskRunnerHandle::Get()->PostTask( |
168 FROM_HERE, | 175 FROM_HERE, |
169 base::Bind(&BrowserThreadTest::StopUIThread, base::Unretained(this))); | 176 base::Bind(&BrowserThreadTest::StopUIThread, base::Unretained(this))); |
170 loop.Run(); | 177 loop.Run(); |
171 | 178 |
172 EXPECT_TRUE(did_shutdown); | 179 EXPECT_TRUE(did_shutdown); |
173 } | 180 } |
174 | 181 |
175 } // namespace content | 182 } // namespace content |
OLD | NEW |