OLD | NEW |
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_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 11 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
12 #include "chrome/browser/download/download_prefs.h" | 12 #include "chrome/browser/download/download_prefs.h" |
13 #include "chrome/browser/download/download_target_info.h" | 13 #include "chrome/browser/download/download_target_info.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
16 #include "chrome/test/base/testing_pref_service_syncable.h" | 16 #include "chrome/test/base/testing_pref_service_syncable.h" |
17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
18 #include "content/public/browser/download_interrupt_reasons.h" | 18 #include "content/public/browser/download_interrupt_reasons.h" |
19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
20 #include "content/public/browser/web_contents_delegate.h" | 20 #include "content/public/browser/web_contents_delegate.h" |
21 #include "content/public/test/mock_download_item.h" | 21 #include "content/public/test/mock_download_item.h" |
22 #include "content/public/test/mock_download_manager.h" | 22 #include "content/public/test/mock_download_manager.h" |
23 #include "content/public/test/test_browser_thread.h" | |
24 #include "content/public/test/test_renderer_host.h" | 23 #include "content/public/test/test_renderer_host.h" |
25 #include "content/public/test/web_contents_tester.h" | 24 #include "content/public/test/web_contents_tester.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
28 | 27 |
29 using ::testing::AtMost; | 28 using ::testing::AtMost; |
30 using ::testing::Invoke; | 29 using ::testing::Invoke; |
31 using ::testing::Ref; | 30 using ::testing::Ref; |
32 using ::testing::Return; | 31 using ::testing::Return; |
33 using ::testing::ReturnPointee; | 32 using ::testing::ReturnPointee; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 114 } |
116 | 115 |
117 MOCK_METHOD3( | 116 MOCK_METHOD3( |
118 MockPromptUserForDownloadPath, | 117 MockPromptUserForDownloadPath, |
119 base::FilePath( | 118 base::FilePath( |
120 content::DownloadItem*, | 119 content::DownloadItem*, |
121 const base::FilePath&, | 120 const base::FilePath&, |
122 const DownloadTargetDeterminerDelegate::FileSelectedCallback&)); | 121 const DownloadTargetDeterminerDelegate::FileSelectedCallback&)); |
123 }; | 122 }; |
124 | 123 |
125 class ChromeDownloadManagerDelegateTest : | 124 class ChromeDownloadManagerDelegateTest |
126 public ChromeRenderViewHostTestHarness { | 125 : public ChromeRenderViewHostTestHarness { |
127 public: | 126 public: |
128 ChromeDownloadManagerDelegateTest(); | 127 ChromeDownloadManagerDelegateTest(); |
129 | 128 |
130 // ::testing::Test | 129 // ::testing::Test |
131 virtual void SetUp() OVERRIDE; | 130 virtual void SetUp() OVERRIDE; |
132 virtual void TearDown() OVERRIDE; | 131 virtual void TearDown() OVERRIDE; |
133 | 132 |
134 // Verifies and clears test expectations for |delegate_| and | 133 // Verifies and clears test expectations for |delegate_| and |
135 // |download_manager_|. | 134 // |download_manager_|. |
136 void VerifyAndClearExpectations(); | 135 void VerifyAndClearExpectations(); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 CreateActiveDownloadItem(1)); | 392 CreateActiveDownloadItem(1)); |
394 EXPECT_CALL(*download_item, GetTargetFilePath()) | 393 EXPECT_CALL(*download_item, GetTargetFilePath()) |
395 .WillRepeatedly(ReturnRef(existing_path)); | 394 .WillRepeatedly(ReturnRef(existing_path)); |
396 EXPECT_TRUE(CheckForFileExistence(download_item.get())); | 395 EXPECT_TRUE(CheckForFileExistence(download_item.get())); |
397 | 396 |
398 download_item.reset(CreateActiveDownloadItem(1)); | 397 download_item.reset(CreateActiveDownloadItem(1)); |
399 EXPECT_CALL(*download_item, GetTargetFilePath()) | 398 EXPECT_CALL(*download_item, GetTargetFilePath()) |
400 .WillRepeatedly(ReturnRef(non_existent_path)); | 399 .WillRepeatedly(ReturnRef(non_existent_path)); |
401 EXPECT_FALSE(CheckForFileExistence(download_item.get())); | 400 EXPECT_FALSE(CheckForFileExistence(download_item.get())); |
402 } | 401 } |
OLD | NEW |