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

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

Issue 10392082: Fix SavePageAsMHTMLBrowserTest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 DownloadPersistentStoreInfoMatch(const GURL& url, 149 DownloadPersistentStoreInfoMatch(const GURL& url,
150 const FilePath& path, 150 const FilePath& path,
151 int64 num_files) 151 int64 num_files)
152 : url_(url), 152 : url_(url),
153 path_(path), 153 path_(path),
154 num_files_(num_files) { 154 num_files_(num_files) {
155 } 155 }
156 156
157 bool operator() (const DownloadPersistentStoreInfo& info) const { 157 bool operator() (const DownloadPersistentStoreInfo& info) const {
158 return info.url == url_ && 158 return ((info.url == url_) &&
Randy Smith (Not in Mondays) 2012/05/14 17:55:19 My personal feeling is that parens around the == i
benjhayden 2012/05/14 19:27:37 My personal feeling is that ungrouped conditions a
159 info.path == path_ && 159 (info.path == path_) &&
160 // For save packages, received bytes is actually the number of files. 160 // For non-MHTML save packages, received_bytes is actually the
161 info.received_bytes == num_files_ && 161 // number of files.
Randy Smith (Not in Mondays) 2012/05/14 17:55:19 Instead of just putting in an off switch, can you
benjhayden 2012/05/14 19:27:37 Renaming the variable won't fix the problem. The p
162 info.total_bytes == 0 && 162 ((num_files_ < 0) ||
163 info.state == DownloadItem::COMPLETE; 163 (info.received_bytes == num_files_)) &&
164 (info.total_bytes == 0) &&
165 (info.state == DownloadItem::COMPLETE));
164 } 166 }
165 167
166 GURL url_; 168 GURL url_;
167 FilePath path_; 169 FilePath path_;
168 int64 num_files_; 170 int64 num_files_;
169 }; 171 };
170 172
171 void CheckDownloadHistory(const GURL& url, 173 void CheckDownloadHistory(const GURL& url,
172 const FilePath& path, 174 const FilePath& path,
173 int64 num_files) { 175 int64 num_files) {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 command_line->AppendSwitch(switches::kSavePageAsMHTML); 383 command_line->AppendSwitch(switches::kSavePageAsMHTML);
382 } 384 }
383 385
384 private: 386 private:
385 DISALLOW_COPY_AND_ASSIGN(SavePageAsMHTMLBrowserTest); 387 DISALLOW_COPY_AND_ASSIGN(SavePageAsMHTMLBrowserTest);
386 }; 388 };
387 389
388 SavePageAsMHTMLBrowserTest::~SavePageAsMHTMLBrowserTest() { 390 SavePageAsMHTMLBrowserTest::~SavePageAsMHTMLBrowserTest() {
389 } 391 }
390 392
391 // Bug 127527: This test fails when the day of the month is >9. 393 IN_PROC_BROWSER_TEST_F(SavePageAsMHTMLBrowserTest, SavePageAsMHTML) {
392 IN_PROC_BROWSER_TEST_F(SavePageAsMHTMLBrowserTest, DISABLED_SavePageAsMHTML) {
393 static const int64 kFileSize = 2759;
394 GURL url = NavigateToMockURL("b"); 394 GURL url = NavigateToMockURL("b");
395 FilePath download_dir = DownloadPrefs::FromDownloadManager( 395 FilePath download_dir = DownloadPrefs::FromDownloadManager(
396 GetDownloadManager())->download_path(); 396 GetDownloadManager())->download_path();
397 FilePath full_file_name = download_dir.AppendASCII(std::string( 397 FilePath full_file_name = download_dir.AppendASCII(std::string(
398 "Test page for saving page feature.mhtml")); 398 "Test page for saving page feature.mhtml"));
399 #if defined(OS_CHROMEOS) 399 #if defined(OS_CHROMEOS)
400 SavePackageFilePickerChromeOS::SetShouldPromptUser(false); 400 SavePackageFilePickerChromeOS::SetShouldPromptUser(false);
401 #else 401 #else
402 SavePackageFilePicker::SetShouldPromptUser(false); 402 SavePackageFilePicker::SetShouldPromptUser(false);
403 #endif 403 #endif
404 ui_test_utils::WindowedNotificationObserver observer( 404 ui_test_utils::WindowedNotificationObserver observer(
405 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, 405 content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
406 content::NotificationService::AllSources()); 406 content::NotificationService::AllSources());
407 browser()->SavePage(); 407 browser()->SavePage();
408 observer.Wait(); 408 observer.Wait();
409 CheckDownloadHistory(url, full_file_name, kFileSize); 409 CheckDownloadHistory(url, full_file_name, -1);
410 410
411 EXPECT_TRUE(file_util::PathExists(full_file_name)); 411 EXPECT_TRUE(file_util::PathExists(full_file_name));
412 int64 actual_file_size = -1; 412 int64 actual_file_size = -1;
413 EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size)); 413 EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size));
414 EXPECT_EQ(kFileSize, actual_file_size); 414 EXPECT_LE(2758, actual_file_size);
Randy Smith (Not in Mondays) 2012/05/14 17:55:19 I dislike this type of naked constant. Is there s
benjhayden 2012/05/14 19:27:37 Done.
415 } 415 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698