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

Side by Side Diff: chrome/browser/download/download_status_updater_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 #include "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/memory/weak_ptr.h" 6 #include "base/memory/weak_ptr.h"
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/download/download_status_updater.h" 9 #include "chrome/browser/download/download_status_updater.h"
10 #include "content/public/test/mock_download_item.h" 10 #include "content/public/test/mock_download_item.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 std::vector<content::DownloadManager::Observer*> manager_observers_; 179 std::vector<content::DownloadManager::Observer*> manager_observers_;
180 180
181 // Pointer so we can verify that destruction triggers appropriate 181 // Pointer so we can verify that destruction triggers appropriate
182 // changes. 182 // changes.
183 TestDownloadStatusUpdater *updater_; 183 TestDownloadStatusUpdater *updater_;
184 184
185 // Thread so that the DownloadManager (which is a DeleteOnUIThread 185 // Thread so that the DownloadManager (which is a DeleteOnUIThread
186 // object) can be deleted. 186 // object) can be deleted.
187 // TODO(rdsmith): This can be removed when the DownloadManager 187 // TODO(rdsmith): This can be removed when the DownloadManager
188 // is no longer required to be deleted on the UI thread. 188 // is no longer required to be deleted on the UI thread.
189 MessageLoop loop_; 189 base::MessageLoop loop_;
190 content::TestBrowserThread ui_thread_; 190 content::TestBrowserThread ui_thread_;
191 }; 191 };
192 192
193 // Test null updater. 193 // Test null updater.
194 TEST_F(DownloadStatusUpdaterTest, Basic) { 194 TEST_F(DownloadStatusUpdaterTest, Basic) {
195 float progress = -1; 195 float progress = -1;
196 int download_count = -1; 196 int download_count = -1;
197 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count)); 197 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count));
198 EXPECT_FLOAT_EQ(0.0f, progress); 198 EXPECT_FLOAT_EQ(0.0f, progress);
199 EXPECT_EQ(0, download_count); 199 EXPECT_EQ(0, download_count);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 SetItemValues(0, 0, 10, 20, false); 338 SetItemValues(0, 0, 10, 20, false);
339 SetItemValues(0, 1, 50, 60, false); 339 SetItemValues(0, 1, 50, 60, false);
340 SetItemValues(1, 0, 80, 90, false); 340 SetItemValues(1, 0, 80, 90, false);
341 341
342 float progress = -1; 342 float progress = -1;
343 int download_count = -1; 343 int download_count = -1;
344 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count)); 344 EXPECT_TRUE(updater_->GetProgress(&progress, &download_count));
345 EXPECT_FLOAT_EQ((10+50+80)/(20.0f+60+90), progress); 345 EXPECT_FLOAT_EQ((10+50+80)/(20.0f+60+90), progress);
346 EXPECT_EQ(3, download_count); 346 EXPECT_EQ(3, download_count);
347 } 347 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698