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

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

Issue 2832223004: interrupt and resume download with CONTENT_LENGTH_MISMATCH errors (Closed)
Patch Set: fix tests Created 3 years, 7 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
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 "chrome/browser/download/download_item_model.h" 5 #include "chrome/browser/download/download_item_model.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, 166 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT,
167 "Failed - No file"}, 167 "Failed - No file"},
168 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED, 168 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED,
169 "Failed - Needs authorization"}, 169 "Failed - Needs authorization"},
170 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_CERT_PROBLEM, 170 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_CERT_PROBLEM,
171 "Failed - Bad certificate"}, 171 "Failed - Bad certificate"},
172 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_FORBIDDEN, 172 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_FORBIDDEN,
173 "Failed - Forbidden"}, 173 "Failed - Forbidden"},
174 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNREACHABLE, 174 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNREACHABLE,
175 "Failed - Server unreachable"}, 175 "Failed - Server unreachable"},
176 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_CONTENT_LENGTH_MISMATCH,
177 "Failed - File incomplete"},
176 {content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED, "Canceled"}, 178 {content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED, "Canceled"},
177 {content::DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN, "Failed - Shutdown"}, 179 {content::DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN, "Failed - Shutdown"},
178 {content::DOWNLOAD_INTERRUPT_REASON_CRASH, "Failed - Crash"}, 180 {content::DOWNLOAD_INTERRUPT_REASON_CRASH, "Failed - Crash"},
179 }; 181 };
180 static_assert(kInterruptReasonCount == arraysize(kTestCases), 182 static_assert(kInterruptReasonCount == arraysize(kTestCases),
181 "interrupt reason mismatch"); 183 "interrupt reason mismatch");
182 184
183 SetupDownloadItemDefaults(); 185 SetupDownloadItemDefaults();
184 for (unsigned i = 0; i < arraysize(kTestCases); ++i) { 186 for (unsigned i = 0; i < arraysize(kTestCases); ++i) {
185 const TestCase& test_case = kTestCases[i]; 187 const TestCase& test_case = kTestCases[i];
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, 244 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT,
243 "foo.bar\nNo file"}, 245 "foo.bar\nNo file"},
244 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED, 246 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED,
245 "foo.bar\nNeeds authorization"}, 247 "foo.bar\nNeeds authorization"},
246 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_CERT_PROBLEM, 248 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_CERT_PROBLEM,
247 "foo.bar\nBad certificate"}, 249 "foo.bar\nBad certificate"},
248 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_FORBIDDEN, 250 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_FORBIDDEN,
249 "foo.bar\nForbidden"}, 251 "foo.bar\nForbidden"},
250 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNREACHABLE, 252 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNREACHABLE,
251 "foo.bar\nServer unreachable"}, 253 "foo.bar\nServer unreachable"},
254 {content::DOWNLOAD_INTERRUPT_REASON_SERVER_CONTENT_LENGTH_MISMATCH,
255 "foo.bar\nFile incomplete"},
252 {content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED, "foo.bar"}, 256 {content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED, "foo.bar"},
253 {content::DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN, "foo.bar\nShutdown"}, 257 {content::DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN, "foo.bar\nShutdown"},
254 {content::DOWNLOAD_INTERRUPT_REASON_CRASH, "foo.bar\nCrash"}, 258 {content::DOWNLOAD_INTERRUPT_REASON_CRASH, "foo.bar\nCrash"},
255 }; 259 };
256 static_assert(kInterruptReasonCount == arraysize(kTestCases), 260 static_assert(kInterruptReasonCount == arraysize(kTestCases),
257 "interrupt reason mismatch"); 261 "interrupt reason mismatch");
258 262
259 // Large tooltip width. Should be large enough to accommodate the entire 263 // Large tooltip width. Should be large enough to accommodate the entire
260 // tooltip without truncation. 264 // tooltip without truncation.
261 const int kLargeTooltipWidth = 1000; 265 const int kLargeTooltipWidth = 1000;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 EXPECT_CALL(item(), GetAutoOpened()) 474 EXPECT_CALL(item(), GetAutoOpened())
471 .WillRepeatedly(Return(test_case.auto_opened)); 475 .WillRepeatedly(Return(test_case.auto_opened));
472 476
473 EXPECT_EQ(test_case.expected_result, 477 EXPECT_EQ(test_case.expected_result,
474 model().ShouldRemoveFromShelfWhenComplete()) 478 model().ShouldRemoveFromShelfWhenComplete())
475 << "Test case: " << i; 479 << "Test case: " << i;
476 Mock::VerifyAndClearExpectations(&item()); 480 Mock::VerifyAndClearExpectations(&item());
477 Mock::VerifyAndClearExpectations(&model()); 481 Mock::VerifyAndClearExpectations(&model());
478 } 482 }
479 } 483 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_item_model.cc ('k') | chrome/common/extensions/api/downloads.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698