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

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

Issue 8468020: Propagate the SafeBrowsing download protection verdict to the DownloadItem. (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"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 item->Remove(); 185 item->Remove();
186 ASSERT_TRUE(observer.CheckUpdated()); 186 ASSERT_TRUE(observer.CheckUpdated());
187 } 187 }
188 188
189 TEST_F(DownloadItemTest, NotificationAfterSetFileCheckResults) { 189 TEST_F(DownloadItemTest, NotificationAfterSetFileCheckResults) {
190 // Setting to safe should not trigger any notifications 190 // Setting to safe should not trigger any notifications
191 DownloadItem* safe_item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 191 DownloadItem* safe_item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
192 MockObserver safe_observer(safe_item); 192 MockObserver safe_observer(safe_item);
193 193
194 DownloadStateInfo state = safe_item->state_info();; 194 DownloadStateInfo state = safe_item->state_info();;
195 state.is_dangerous_file = false; 195 state.danger = DownloadStateInfo::NOT_DANGEROUS;
196 state.is_dangerous_url = false;
197 safe_item->SetFileCheckResults(state); 196 safe_item->SetFileCheckResults(state);
198 ASSERT_FALSE(safe_observer.CheckUpdated()); 197 ASSERT_FALSE(safe_observer.CheckUpdated());
199 198
200 // Setting to unsafe url or unsafe file should trigger notification 199 // Setting to unsafe url or unsafe file should trigger notification
201 DownloadItem* unsafeurl_item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 200 DownloadItem* unsafeurl_item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
202 MockObserver unsafeurl_observer(unsafeurl_item); 201 MockObserver unsafeurl_observer(unsafeurl_item);
203 202
204 state = unsafeurl_item->state_info();; 203 state = unsafeurl_item->state_info();;
205 state.is_dangerous_file = false; 204 state.danger = DownloadStateInfo::DANGEROUS_URL;
206 state.is_dangerous_url = true;
207 unsafeurl_item->SetFileCheckResults(state); 205 unsafeurl_item->SetFileCheckResults(state);
208 ASSERT_TRUE(unsafeurl_observer.CheckUpdated()); 206 ASSERT_TRUE(unsafeurl_observer.CheckUpdated());
209 207
210 unsafeurl_item->DangerousDownloadValidated(); 208 unsafeurl_item->DangerousDownloadValidated();
211 ASSERT_TRUE(unsafeurl_observer.CheckUpdated()); 209 ASSERT_TRUE(unsafeurl_observer.CheckUpdated());
212 210
213 DownloadItem* unsafefile_item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 211 DownloadItem* unsafefile_item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
214 MockObserver unsafefile_observer(unsafefile_item); 212 MockObserver unsafefile_observer(unsafefile_item);
215 213
216 state = unsafefile_item->state_info();; 214 state = unsafefile_item->state_info();;
217 state.is_dangerous_file = true; 215 state.danger = DownloadStateInfo::DANGEROUS_FILE;
218 state.is_dangerous_url = false;
219 unsafefile_item->SetFileCheckResults(state); 216 unsafefile_item->SetFileCheckResults(state);
220 ASSERT_TRUE(unsafefile_observer.CheckUpdated()); 217 ASSERT_TRUE(unsafefile_observer.CheckUpdated());
221 218
222 unsafefile_item->DangerousDownloadValidated(); 219 unsafefile_item->DangerousDownloadValidated();
223 ASSERT_TRUE(unsafefile_observer.CheckUpdated()); 220 ASSERT_TRUE(unsafefile_observer.CheckUpdated());
224 } 221 }
225 222
226 TEST_F(DownloadItemTest, NotificationAfterOnPathDetermined) { 223 TEST_F(DownloadItemTest, NotificationAfterOnPathDetermined) {
227 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 224 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
228 MockObserver observer(item); 225 MockObserver observer(item);
(...skipping 15 matching lines...) Expand all
244 TEST_F(DownloadItemTest, NotificationAfterTogglePause) { 241 TEST_F(DownloadItemTest, NotificationAfterTogglePause) {
245 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 242 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
246 MockObserver observer(item); 243 MockObserver observer(item);
247 244
248 item->TogglePause(); 245 item->TogglePause();
249 ASSERT_TRUE(observer.CheckUpdated()); 246 ASSERT_TRUE(observer.CheckUpdated());
250 247
251 item->TogglePause(); 248 item->TogglePause();
252 ASSERT_TRUE(observer.CheckUpdated()); 249 ASSERT_TRUE(observer.CheckUpdated());
253 } 250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698