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

Side by Side Diff: content/browser/download/download_item_impl_unittest.cc

Issue 10704052: Download filename determination refactor (3/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use a callback with DetermineDownloadTarget(). Created 8 years, 5 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "base/threading/thread.h" 7 #include "base/threading/thread.h"
8 #include "content/browser/download/byte_stream.h" 8 #include "content/browser/download/byte_stream.h"
9 #include "content/browser/download/download_create_info.h" 9 #include "content/browser/download/download_create_info.h"
10 #include "content/browser/download/download_file_manager.h" 10 #include "content/browser/download/download_file_manager.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 MockObserver dangerous_observer(dangerous_item); 306 MockObserver dangerous_observer(dangerous_item);
307 307
308 // Calling OnTargetPathDetermined does trigger notification if danger type 308 // Calling OnTargetPathDetermined does trigger notification if danger type
309 // anything other than NOT_DANGEROUS. 309 // anything other than NOT_DANGEROUS.
310 dangerous_item->OnTargetPathDetermined( 310 dangerous_item->OnTargetPathDetermined(
311 FilePath(kDummyPath), DownloadItem::TARGET_DISPOSITION_OVERWRITE, 311 FilePath(kDummyPath), DownloadItem::TARGET_DISPOSITION_OVERWRITE,
312 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE); 312 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE);
313 EXPECT_TRUE(dangerous_observer.CheckUpdated()); 313 EXPECT_TRUE(dangerous_observer.CheckUpdated());
314 } 314 }
315 315
316 TEST_F(DownloadItemTest, NotificationAfterOnTargetPathSelected) {
317 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
318 MockObserver observer(item);
319
320 item->OnTargetPathDetermined(
321 FilePath(kDummyPath), DownloadItem::TARGET_DISPOSITION_PROMPT,
322 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
323 item->OnTargetPathSelected(FilePath(kDummyPath));
324 EXPECT_FALSE(observer.CheckUpdated());
325 }
326
327 TEST_F(DownloadItemTest, NotificationAfterOnContentCheckCompleted) { 316 TEST_F(DownloadItemTest, NotificationAfterOnContentCheckCompleted) {
328 // Setting to NOT_DANGEROUS does not trigger a notification. 317 // Setting to NOT_DANGEROUS does not trigger a notification.
329 DownloadItem* safe_item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 318 DownloadItem* safe_item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
330 MockObserver safe_observer(safe_item); 319 MockObserver safe_observer(safe_item);
331 320
332 safe_item->OnTargetPathDetermined( 321 safe_item->OnTargetPathDetermined(
333 FilePath(kDummyPath), DownloadItem::TARGET_DISPOSITION_OVERWRITE, 322 FilePath(kDummyPath), DownloadItem::TARGET_DISPOSITION_OVERWRITE,
334 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS); 323 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
335 EXPECT_FALSE(safe_observer.CheckUpdated()); 324 EXPECT_FALSE(safe_observer.CheckUpdated());
336 safe_item->OnAllDataSaved(1, ""); 325 safe_item->OnAllDataSaved(1, "");
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); 565 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
577 566
578 EXPECT_FALSE(item->GetFileExternallyRemoved()); 567 EXPECT_FALSE(item->GetFileExternallyRemoved());
579 item->OnDownloadedFileRemoved(); 568 item->OnDownloadedFileRemoved();
580 EXPECT_TRUE(item->GetFileExternallyRemoved()); 569 EXPECT_TRUE(item->GetFileExternallyRemoved());
581 } 570 }
582 571
583 TEST(MockDownloadItem, Compiles) { 572 TEST(MockDownloadItem, Compiles) {
584 MockDownloadItem mock_item; 573 MockDownloadItem mock_item;
585 } 574 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698