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

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

Issue 8503018: Split DownloadItem into an ABC, an Impl, and a Mock. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merge Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/test/base/testing_profile.h" 6 #include "chrome/test/base/testing_profile.h"
7 #include "content/browser/download/download_create_info.h" 7 #include "content/browser/download/download_create_info.h"
8 #include "content/browser/download/download_id.h" 8 #include "content/browser/download/download_id.h"
9 #include "content/browser/download/download_id_factory.h" 9 #include "content/browser/download/download_id_factory.h"
10 #include "content/browser/download/download_item.h" 10 #include "content/browser/download/download_item.h"
11 #include "content/browser/download/download_request_handle.h"
11 #include "content/browser/download/download_status_updater.h" 12 #include "content/browser/download/download_status_updater.h"
12 #include "content/browser/download/interrupt_reasons.h" 13 #include "content/browser/download/interrupt_reasons.h"
14 #include "content/browser/download/mock_download_item.h"
13 #include "content/browser/download/mock_download_manager.h" 15 #include "content/browser/download/mock_download_manager.h"
14 #include "content/browser/download/mock_download_manager_delegate.h" 16 #include "content/browser/download/mock_download_manager_delegate.h"
15 #include "content/test/test_browser_thread.h" 17 #include "content/test/test_browser_thread.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
17 19
18 using content::BrowserThread; 20 using content::BrowserThread;
19 21
20 DownloadId::Domain kValidDownloadItemIdDomain = "valid DownloadId::Domain"; 22 DownloadId::Domain kValidDownloadItemIdDomain = "valid DownloadId::Domain";
21 23
22 class DownloadItemTest : public testing::Test { 24 class DownloadItemTest : public testing::Test {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 186
185 item->Remove(); 187 item->Remove();
186 ASSERT_TRUE(observer.CheckUpdated()); 188 ASSERT_TRUE(observer.CheckUpdated());
187 } 189 }
188 190
189 TEST_F(DownloadItemTest, NotificationAfterSetFileCheckResults) { 191 TEST_F(DownloadItemTest, NotificationAfterSetFileCheckResults) {
190 // Setting to safe should not trigger any notifications 192 // Setting to safe should not trigger any notifications
191 DownloadItem* safe_item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 193 DownloadItem* safe_item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
192 MockObserver safe_observer(safe_item); 194 MockObserver safe_observer(safe_item);
193 195
194 DownloadStateInfo state = safe_item->state_info();; 196 DownloadStateInfo state = safe_item->GetStateInfo();;
195 state.danger = DownloadStateInfo::NOT_DANGEROUS; 197 state.danger = DownloadStateInfo::NOT_DANGEROUS;
196 safe_item->SetFileCheckResults(state); 198 safe_item->SetFileCheckResults(state);
197 ASSERT_FALSE(safe_observer.CheckUpdated()); 199 ASSERT_FALSE(safe_observer.CheckUpdated());
198 200
199 // Setting to unsafe url or unsafe file should trigger notification 201 // Setting to unsafe url or unsafe file should trigger notification
200 DownloadItem* unsafeurl_item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 202 DownloadItem* unsafeurl_item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
201 MockObserver unsafeurl_observer(unsafeurl_item); 203 MockObserver unsafeurl_observer(unsafeurl_item);
202 204
203 state = unsafeurl_item->state_info();; 205 state = unsafeurl_item->GetStateInfo();;
204 state.danger = DownloadStateInfo::DANGEROUS_URL; 206 state.danger = DownloadStateInfo::DANGEROUS_URL;
205 unsafeurl_item->SetFileCheckResults(state); 207 unsafeurl_item->SetFileCheckResults(state);
206 ASSERT_TRUE(unsafeurl_observer.CheckUpdated()); 208 ASSERT_TRUE(unsafeurl_observer.CheckUpdated());
207 209
208 unsafeurl_item->DangerousDownloadValidated(); 210 unsafeurl_item->DangerousDownloadValidated();
209 ASSERT_TRUE(unsafeurl_observer.CheckUpdated()); 211 ASSERT_TRUE(unsafeurl_observer.CheckUpdated());
210 212
211 DownloadItem* unsafefile_item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 213 DownloadItem* unsafefile_item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
212 MockObserver unsafefile_observer(unsafefile_item); 214 MockObserver unsafefile_observer(unsafefile_item);
213 215
214 state = unsafefile_item->state_info();; 216 state = unsafefile_item->GetStateInfo();;
215 state.danger = DownloadStateInfo::DANGEROUS_FILE; 217 state.danger = DownloadStateInfo::DANGEROUS_FILE;
216 unsafefile_item->SetFileCheckResults(state); 218 unsafefile_item->SetFileCheckResults(state);
217 ASSERT_TRUE(unsafefile_observer.CheckUpdated()); 219 ASSERT_TRUE(unsafefile_observer.CheckUpdated());
218 220
219 unsafefile_item->DangerousDownloadValidated(); 221 unsafefile_item->DangerousDownloadValidated();
220 ASSERT_TRUE(unsafefile_observer.CheckUpdated()); 222 ASSERT_TRUE(unsafefile_observer.CheckUpdated());
221 } 223 }
222 224
223 TEST_F(DownloadItemTest, NotificationAfterOnPathDetermined) { 225 TEST_F(DownloadItemTest, NotificationAfterOnPathDetermined) {
224 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 226 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
(...skipping 16 matching lines...) Expand all
241 TEST_F(DownloadItemTest, NotificationAfterTogglePause) { 243 TEST_F(DownloadItemTest, NotificationAfterTogglePause) {
242 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 244 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
243 MockObserver observer(item); 245 MockObserver observer(item);
244 246
245 item->TogglePause(); 247 item->TogglePause();
246 ASSERT_TRUE(observer.CheckUpdated()); 248 ASSERT_TRUE(observer.CheckUpdated());
247 249
248 item->TogglePause(); 250 item->TogglePause();
249 ASSERT_TRUE(observer.CheckUpdated()); 251 ASSERT_TRUE(observer.CheckUpdated());
250 } 252 }
253
254 TEST(MockDownloadItem, Compiles) {
255 MockDownloadItem mock_item;
256 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_item_model.cc ('k') | chrome/browser/download/download_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698