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_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 SavePackageFinishedObserver observer( | 782 SavePackageFinishedObserver observer( |
783 content::BrowserContext::GetDownloadManager(browser()->profile()), | 783 content::BrowserContext::GetDownloadManager(browser()->profile()), |
784 loop_runner->QuitClosure()); | 784 loop_runner->QuitClosure()); |
785 chrome::SavePage(browser()); | 785 chrome::SavePage(browser()); |
786 loop_runner->Run(); | 786 loop_runner->Run(); |
787 ASSERT_TRUE(VerifySavePackageExpectations(browser(), url)); | 787 ASSERT_TRUE(VerifySavePackageExpectations(browser(), url)); |
788 persisted.WaitForPersisted(); | 788 persisted.WaitForPersisted(); |
789 | 789 |
790 ASSERT_TRUE(base::PathExists(full_file_name)); | 790 ASSERT_TRUE(base::PathExists(full_file_name)); |
791 int64 actual_file_size = -1; | 791 int64 actual_file_size = -1; |
792 EXPECT_TRUE(file_util::GetFileSize(full_file_name, &actual_file_size)); | 792 EXPECT_TRUE(base::GetFileSize(full_file_name, &actual_file_size)); |
793 EXPECT_LE(kFileSizeMin, actual_file_size); | 793 EXPECT_LE(kFileSizeMin, actual_file_size); |
794 } | 794 } |
795 | 795 |
796 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SavePageBrowserTest_NonMHTML) { | 796 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SavePageBrowserTest_NonMHTML) { |
797 SavePackageFilePicker::SetShouldPromptUser(false); | 797 SavePackageFilePicker::SetShouldPromptUser(false); |
798 GURL url("data:text/plain,foo"); | 798 GURL url("data:text/plain,foo"); |
799 ui_test_utils::NavigateToURL(browser(), url); | 799 ui_test_utils::NavigateToURL(browser(), url); |
800 scoped_refptr<content::MessageLoopRunner> loop_runner( | 800 scoped_refptr<content::MessageLoopRunner> loop_runner( |
801 new content::MessageLoopRunner); | 801 new content::MessageLoopRunner); |
802 SavePackageFinishedObserver observer( | 802 SavePackageFinishedObserver observer( |
803 content::BrowserContext::GetDownloadManager(browser()->profile()), | 803 content::BrowserContext::GetDownloadManager(browser()->profile()), |
804 loop_runner->QuitClosure()); | 804 loop_runner->QuitClosure()); |
805 chrome::SavePage(browser()); | 805 chrome::SavePage(browser()); |
806 loop_runner->Run(); | 806 loop_runner->Run(); |
807 base::FilePath download_dir = DownloadPrefs::FromDownloadManager( | 807 base::FilePath download_dir = DownloadPrefs::FromDownloadManager( |
808 GetDownloadManager())->DownloadPath(); | 808 GetDownloadManager())->DownloadPath(); |
809 base::FilePath filename = download_dir.AppendASCII("dataurl.txt"); | 809 base::FilePath filename = download_dir.AppendASCII("dataurl.txt"); |
810 ASSERT_TRUE(base::PathExists(filename)); | 810 ASSERT_TRUE(base::PathExists(filename)); |
811 std::string contents; | 811 std::string contents; |
812 EXPECT_TRUE(base::ReadFileToString(filename, &contents)); | 812 EXPECT_TRUE(base::ReadFileToString(filename, &contents)); |
813 EXPECT_EQ("foo", contents); | 813 EXPECT_EQ("foo", contents); |
814 } | 814 } |
815 | 815 |
816 } // namespace | 816 } // namespace |
817 | 817 |
OLD | NEW |