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

Side by Side Diff: chrome/browser/extensions/api/system_info_storage/storage_info_provider_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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 | Annotate | Revision Log
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 // StorageInfoProvider unit tests. 5 // StorageInfoProvider unit tests.
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "chrome/browser/extensions/api/system_info_storage/storage_info_provide r.h" 9 #include "chrome/browser/extensions/api/system_info_storage/storage_info_provide r.h"
10 #include "chrome/browser/storage_monitor/test_storage_monitor.h" 10 #include "chrome/browser/storage_monitor/test_storage_monitor.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 void TestStorageInfoProvider::OnCheckWatchedStoragesFinishedForTesting() { 166 void TestStorageInfoProvider::OnCheckWatchedStoragesFinishedForTesting() {
167 ++checking_times_; 167 ++checking_times_;
168 if (checking_times_ < kCheckTimes) 168 if (checking_times_ < kCheckTimes)
169 return; 169 return;
170 checking_times_ = 0; 170 checking_times_ = 0;
171 // Once the number of checking times reaches up to kCheckTimes, we need to 171 // Once the number of checking times reaches up to kCheckTimes, we need to
172 // quit the message loop to given UI thread a chance to verify the results. 172 // quit the message loop to given UI thread a chance to verify the results.
173 // Note the QuitClosure is actually bound to QuitCurrentWhenIdle, it means 173 // Note the QuitClosure is actually bound to QuitCurrentWhenIdle, it means
174 // that the UI thread wil continue to process pending messages util idle. 174 // that the UI thread wil continue to process pending messages util idle.
175 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 175 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
176 MessageLoop::QuitClosure()); 176 base::MessageLoop::QuitClosure());
177 } 177 }
178 178
179 class StorageInfoProviderTest : public testing::Test { 179 class StorageInfoProviderTest : public testing::Test {
180 public: 180 public:
181 StorageInfoProviderTest(); 181 StorageInfoProviderTest();
182 virtual ~StorageInfoProviderTest(); 182 virtual ~StorageInfoProviderTest();
183 183
184 protected: 184 protected:
185 virtual void SetUp() OVERRIDE; 185 virtual void SetUp() OVERRIDE;
186 virtual void TearDown() OVERRIDE; 186 virtual void TearDown() OVERRIDE;
187 187
188 // Run message loop and flush blocking pool to make sure there is no pending 188 // Run message loop and flush blocking pool to make sure there is no pending
189 // tasks on blocking pool. 189 // tasks on blocking pool.
190 static void RunLoopAndFlushBlockingPool(); 190 static void RunLoopAndFlushBlockingPool();
191 static void RunAllPendingAndFlushBlockingPool(); 191 static void RunAllPendingAndFlushBlockingPool();
192 192
193 MessageLoop message_loop_; 193 base::MessageLoop message_loop_;
194 content::TestBrowserThread ui_thread_; 194 content::TestBrowserThread ui_thread_;
195 scoped_refptr<TestStorageInfoProvider> storage_info_provider_; 195 scoped_refptr<TestStorageInfoProvider> storage_info_provider_;
196 scoped_ptr<TestStorageMonitor> storage_test_notifications_; 196 scoped_ptr<TestStorageMonitor> storage_test_notifications_;
197 }; 197 };
198 198
199 StorageInfoProviderTest::StorageInfoProviderTest() 199 StorageInfoProviderTest::StorageInfoProviderTest()
200 : message_loop_(MessageLoop::TYPE_UI), 200 : message_loop_(base::MessageLoop::TYPE_UI),
201 ui_thread_(BrowserThread::UI, &message_loop_) { 201 ui_thread_(BrowserThread::UI, &message_loop_) {
202 } 202 }
203 203
204 StorageInfoProviderTest::~StorageInfoProviderTest() { 204 StorageInfoProviderTest::~StorageInfoProviderTest() {
205 } 205 }
206 206
207 void StorageInfoProviderTest::SetUp() { 207 void StorageInfoProviderTest::SetUp() {
208 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 208 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
209 storage_test_notifications_.reset(new TestStorageMonitor); 209 storage_test_notifications_.reset(new TestStorageMonitor);
210 storage_info_provider_= new TestStorageInfoProvider(); 210 storage_info_provider_= new TestStorageInfoProvider();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 MockStorageObserver mock_observer; 323 MockStorageObserver mock_observer;
324 storage_info_provider_->AddObserver(&mock_observer); 324 storage_info_provider_->AddObserver(&mock_observer);
325 storage_info_provider_->StartWatching(invalid_id); 325 storage_info_provider_->StartWatching(invalid_id);
326 EXPECT_CALL(mock_observer, 326 EXPECT_CALL(mock_observer,
327 OnStorageFreeSpaceChanged(invalid_id, _, _)).Times(0); 327 OnStorageFreeSpaceChanged(invalid_id, _, _)).Times(0);
328 RunAllPendingAndFlushBlockingPool(); 328 RunAllPendingAndFlushBlockingPool();
329 storage_info_provider_->RemoveObserver(&mock_observer); 329 storage_info_provider_->RemoveObserver(&mock_observer);
330 } 330 }
331 331
332 } // namespace extensions 332 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698