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

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

Issue 10915180: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r166419 Created 8 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) 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/file_path.h" 5 #include "base/file_path.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/observer_list.h" 8 #include "base/observer_list.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 EXPECT_CALL(*download_manager_, GetAllDownloads(_)).WillRepeatedly(Return()); 296 EXPECT_CALL(*download_manager_, GetAllDownloads(_)).WillRepeatedly(Return());
297 EXPECT_CALL(*download_manager_, AddObserver(_)).WillRepeatedly(Return()); 297 EXPECT_CALL(*download_manager_, AddObserver(_)).WillRepeatedly(Return());
298 EXPECT_CALL(*download_manager_, RemoveObserver(_)).WillRepeatedly(Return()); 298 EXPECT_CALL(*download_manager_, RemoveObserver(_)).WillRepeatedly(Return());
299 } 299 }
300 300
301 void ChromeDownloadManagerDelegateTest::SetUp() { 301 void ChromeDownloadManagerDelegateTest::SetUp() {
302 ChromeRenderViewHostTestHarness::SetUp(); 302 ChromeRenderViewHostTestHarness::SetUp();
303 303
304 CHECK(profile()); 304 CHECK(profile());
305 delegate_ = new TestChromeDownloadManagerDelegate(profile()); 305 delegate_ = new TestChromeDownloadManagerDelegate(profile());
306 EXPECT_CALL(*download_manager_.get(), GetAllDownloads(_))
307 .WillRepeatedly(Return());
308 EXPECT_CALL(*download_manager_.get(), AddObserver(_))
309 .WillRepeatedly(Return());
306 delegate_->SetDownloadManager(download_manager_.get()); 310 delegate_->SetDownloadManager(download_manager_.get());
307 pref_service_ = profile()->GetTestingPrefService(); 311 pref_service_ = profile()->GetTestingPrefService();
308 web_contents()->SetDelegate(&web_contents_delegate_); 312 web_contents()->SetDelegate(&web_contents_delegate_);
309 313
310 ASSERT_TRUE(test_download_dir_.CreateUniqueTempDir()); 314 ASSERT_TRUE(test_download_dir_.CreateUniqueTempDir());
311 SetDefaultDownloadPath(test_download_dir_.path()); 315 SetDefaultDownloadPath(test_download_dir_.path());
312 } 316 }
313 317
314 void ChromeDownloadManagerDelegateTest::TearDown() { 318 void ChromeDownloadManagerDelegateTest::TearDown() {
315 message_loop_.RunAllPending(); 319 message_loop_.RunAllPending();
316 delegate_->Shutdown(); 320 delegate_->Shutdown();
317 ChromeRenderViewHostTestHarness::TearDown(); 321 ChromeRenderViewHostTestHarness::TearDown();
318 } 322 }
319 323
320 void ChromeDownloadManagerDelegateTest::VerifyAndClearExpectations() { 324 void ChromeDownloadManagerDelegateTest::VerifyAndClearExpectations() {
321 ::testing::Mock::VerifyAndClearExpectations(delegate_); 325 ::testing::Mock::VerifyAndClearExpectations(delegate_);
322 ::testing::Mock::VerifyAndClearExpectations(download_manager_); 326 ::testing::Mock::VerifyAndClearExpectations(download_manager_);
323 EXPECT_CALL(*download_manager_, RemoveObserver(_)).WillRepeatedly(Return()); 327 EXPECT_CALL(*download_manager_, RemoveObserver(_)).WillRepeatedly(Return());
324 EXPECT_CALL(*download_manager_, GetAllDownloads(_)) 328 EXPECT_CALL(*download_manager_, GetAllDownloads(_))
325 .WillRepeatedly(Return()); 329 .WillRepeatedly(Return());
326 } 330 }
327 331
328 content::MockDownloadItem* 332 content::MockDownloadItem*
329 ChromeDownloadManagerDelegateTest::CreateActiveDownloadItem(int32 id) { 333 ChromeDownloadManagerDelegateTest::CreateActiveDownloadItem(int32 id) {
330 content::MockDownloadItem* item = 334 content::MockDownloadItem* item =
331 new ::testing::NiceMock<content::MockDownloadItem>(); 335 new ::testing::NiceMock<content::MockDownloadItem>();
336 EXPECT_CALL(*item, GetState())
337 .WillRepeatedly(Return(DownloadItem::IN_PROGRESS));
338 EXPECT_CALL(*item, AddObserver(_))
339 .WillRepeatedly(Return());
340 EXPECT_CALL(*item, RemoveObserver(_))
341 .WillRepeatedly(Return());
332 ON_CALL(*item, GetFullPath()) 342 ON_CALL(*item, GetFullPath())
333 .WillByDefault(ReturnRefOfCopy(FilePath())); 343 .WillByDefault(ReturnRefOfCopy(FilePath()));
334 ON_CALL(*item, GetHash()) 344 ON_CALL(*item, GetHash())
335 .WillByDefault(ReturnRefOfCopy(std::string())); 345 .WillByDefault(ReturnRefOfCopy(std::string()));
336 ON_CALL(*item, GetReferrerUrl()) 346 ON_CALL(*item, GetReferrerUrl())
337 .WillByDefault(ReturnRefOfCopy(GURL())); 347 .WillByDefault(ReturnRefOfCopy(GURL()));
338 ON_CALL(*item, GetTransitionType()) 348 ON_CALL(*item, GetTransitionType())
339 .WillByDefault(Return(content::PAGE_TRANSITION_LINK)); 349 .WillByDefault(Return(content::PAGE_TRANSITION_LINK));
340 ON_CALL(*item, HasUserGesture()) 350 ON_CALL(*item, HasUserGesture())
341 .WillByDefault(Return(false)); 351 .WillByDefault(Return(false));
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 956
947 RunTestCases(kWebIntentsTestCases, arraysize(kWebIntentsTestCases)); 957 RunTestCases(kWebIntentsTestCases, arraysize(kWebIntentsTestCases));
948 } 958 }
949 #endif 959 #endif
950 960
951 // TODO(asanka): Add more tests. 961 // TODO(asanka): Add more tests.
952 // * Default download path is not writable. 962 // * Default download path is not writable.
953 // * Download path doesn't exist. 963 // * Download path doesn't exist.
954 // * IsDangerousFile(). 964 // * IsDangerousFile().
955 // * Filename generation. 965 // * Filename generation.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698