OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/download/download_commands.h" | 5 #include "chrome/browser/download/download_commands.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
| 9 #include "base/strings/stringprintf.h" |
9 #include "content/public/test/mock_download_item.h" | 10 #include "content/public/test/mock_download_item.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 | 13 |
13 using content::DownloadItem; | 14 using content::DownloadItem; |
14 using ::testing::Mock; | 15 using ::testing::Mock; |
15 using ::testing::NiceMock; | 16 using ::testing::NiceMock; |
16 using ::testing::Return; | 17 using ::testing::Return; |
17 using ::testing::ReturnRefOfCopy; | 18 using ::testing::ReturnRefOfCopy; |
18 using ::testing::_; | 19 using ::testing::_; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // Pause. | 148 // Pause. |
148 EXPECT_CALL(item(), Pause()).Times(1); | 149 EXPECT_CALL(item(), Pause()).Times(1); |
149 commands().ExecuteCommand(DownloadCommands::PAUSE); | 150 commands().ExecuteCommand(DownloadCommands::PAUSE); |
150 } | 151 } |
151 | 152 |
152 TEST_F(DownloadCommandsTest, DoResume) { | 153 TEST_F(DownloadCommandsTest, DoResume) { |
153 // Resume. | 154 // Resume. |
154 EXPECT_CALL(item(), Resume()).Times(1); | 155 EXPECT_CALL(item(), Resume()).Times(1); |
155 commands().ExecuteCommand(DownloadCommands::RESUME); | 156 commands().ExecuteCommand(DownloadCommands::RESUME); |
156 } | 157 } |
| 158 |
| 159 TEST_F(DownloadCommandsTest, |
| 160 GetLearnMoreURLForInterruptedDownload_ContainsContext) { |
| 161 EXPECT_CALL(item(), GetLastReason()) |
| 162 .WillOnce( |
| 163 Return(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED)); |
| 164 GURL learn_more_url = commands().GetLearnMoreURLForInterruptedDownload(); |
| 165 std::string name_value_pair = base::StringPrintf( |
| 166 "ctx=%d", content::DOWNLOAD_INTERRUPT_REASON_NETWORK_DISCONNECTED); |
| 167 EXPECT_LT(0u, learn_more_url.query().find(name_value_pair)) |
| 168 << learn_more_url.spec(); |
| 169 } |
OLD | NEW |