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/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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "chrome/browser/download/save_package_file_picker.h" | 46 #include "chrome/browser/download/save_package_file_picker.h" |
47 #endif | 47 #endif |
48 | 48 |
49 using content::BrowserContext; | 49 using content::BrowserContext; |
50 using content::BrowserThread; | 50 using content::BrowserThread; |
51 using content::DownloadItem; | 51 using content::DownloadItem; |
52 using content::DownloadManager; | 52 using content::DownloadManager; |
53 using content::DownloadPersistentStoreInfo; | 53 using content::DownloadPersistentStoreInfo; |
54 using content::WebContents; | 54 using content::WebContents; |
55 | 55 |
56 namespace { | 56 const FilePath::CharType kTestDir[] = FILE_PATH_LITERAL("save_page"); |
57 | 57 |
58 static const FilePath::CharType* kTestDir = FILE_PATH_LITERAL("save_page"); | 58 const char kAppendedExtension[] = |
59 | |
60 static const char* kAppendedExtension = | |
61 #if defined(OS_WIN) | 59 #if defined(OS_WIN) |
62 ".htm"; | 60 ".htm"; |
63 #else | 61 #else |
64 ".html"; | 62 ".html"; |
65 #endif | 63 #endif |
66 | 64 |
67 void NullFunction() { | |
68 } | |
69 | |
70 } // namespace | |
71 | |
72 // Loosely based on logic in DownloadTestObserver. | 65 // Loosely based on logic in DownloadTestObserver. |
73 class DownloadItemCreatedObserver : public DownloadManager::Observer { | 66 class DownloadItemCreatedObserver : public DownloadManager::Observer { |
74 public: | 67 public: |
75 explicit DownloadItemCreatedObserver(DownloadManager* manager) | 68 explicit DownloadItemCreatedObserver(DownloadManager* manager) |
76 : waiting_(false), manager_(manager) { | 69 : waiting_(false), manager_(manager) { |
77 manager->AddObserver(this); | 70 manager->AddObserver(this); |
78 } | 71 } |
79 | 72 |
80 ~DownloadItemCreatedObserver() { | 73 ~DownloadItemCreatedObserver() { |
81 if (manager_) | 74 if (manager_) |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 content::NotificationService::AllSources()); | 639 content::NotificationService::AllSources()); |
647 chrome::SavePage(browser()); | 640 chrome::SavePage(browser()); |
648 observer.Wait(); | 641 observer.Wait(); |
649 CheckDownloadHistory(url, full_file_name, -1, DownloadItem::COMPLETE); | 642 CheckDownloadHistory(url, full_file_name, -1, DownloadItem::COMPLETE); |
650 | 643 |
651 EXPECT_TRUE(file_util::PathExists(full_file_name)); | 644 EXPECT_TRUE(file_util::PathExists(full_file_name)); |
652 int64 actual_file_size = -1; | 645 int64 actual_file_size = -1; |
653 EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size)); | 646 EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size)); |
654 EXPECT_LE(kFileSizeMin, actual_file_size); | 647 EXPECT_LE(kFileSizeMin, actual_file_size); |
655 } | 648 } |
OLD | NEW |