| 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/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 FILE_PATH_LITERAL("forced-foo.txt") | 1779 FILE_PATH_LITERAL("forced-foo.txt") |
| 1780 }, | 1780 }, |
| 1781 }; | 1781 }; |
| 1782 | 1782 |
| 1783 // The test assumes that .crx files have a danger level of | 1783 // The test assumes that .crx files have a danger level of |
| 1784 // ALLOW_ON_USER_GESTURE. | 1784 // ALLOW_ON_USER_GESTURE. |
| 1785 ASSERT_EQ(download_util::ALLOW_ON_USER_GESTURE, | 1785 ASSERT_EQ(download_util::ALLOW_ON_USER_GESTURE, |
| 1786 download_util::GetFileDangerLevel( | 1786 download_util::GetFileDangerLevel( |
| 1787 base::FilePath(FILE_PATH_LITERAL("foo.crx")))); | 1787 base::FilePath(FILE_PATH_LITERAL("foo.crx")))); |
| 1788 | 1788 |
| 1789 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kIntermediateNameTestCases); ++i) { | 1789 for (size_t i = 0; i < arraysize(kIntermediateNameTestCases); ++i) { |
| 1790 SCOPED_TRACE(testing::Message() << "Running test case " << i); | 1790 SCOPED_TRACE(testing::Message() << "Running test case " << i); |
| 1791 const IntermediateNameTestCase& test_case = kIntermediateNameTestCases[i]; | 1791 const IntermediateNameTestCase& test_case = kIntermediateNameTestCases[i]; |
| 1792 scoped_ptr<content::MockDownloadItem> item( | 1792 scoped_ptr<content::MockDownloadItem> item( |
| 1793 CreateActiveDownloadItem(i, test_case.general)); | 1793 CreateActiveDownloadItem(i, test_case.general)); |
| 1794 | 1794 |
| 1795 ON_CALL(*item.get(), GetLastReason()) | 1795 ON_CALL(*item.get(), GetLastReason()) |
| 1796 .WillByDefault(Return( | 1796 .WillByDefault(Return( |
| 1797 content::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED)); | 1797 content::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED)); |
| 1798 ON_CALL(*item.get(), GetFullPath()) | 1798 ON_CALL(*item.get(), GetFullPath()) |
| 1799 .WillByDefault(ReturnRefOfCopy( | 1799 .WillByDefault(ReturnRefOfCopy( |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 }, | 1902 }, |
| 1903 "" | 1903 "" |
| 1904 }, | 1904 }, |
| 1905 }; | 1905 }; |
| 1906 | 1906 |
| 1907 ON_CALL(*delegate(), GetFileMimeType( | 1907 ON_CALL(*delegate(), GetFileMimeType( |
| 1908 GetPathInDownloadDir(FILE_PATH_LITERAL("foo.png")), _)) | 1908 GetPathInDownloadDir(FILE_PATH_LITERAL("foo.png")), _)) |
| 1909 .WillByDefault(WithArg<1>( | 1909 .WillByDefault(WithArg<1>( |
| 1910 ScheduleCallback("image/png"))); | 1910 ScheduleCallback("image/png"))); |
| 1911 | 1911 |
| 1912 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kMIMETypeTestCases); ++i) { | 1912 for (size_t i = 0; i < arraysize(kMIMETypeTestCases); ++i) { |
| 1913 SCOPED_TRACE(testing::Message() << "Running test case " << i); | 1913 SCOPED_TRACE(testing::Message() << "Running test case " << i); |
| 1914 const MIMETypeTestCase& test_case = kMIMETypeTestCases[i]; | 1914 const MIMETypeTestCase& test_case = kMIMETypeTestCases[i]; |
| 1915 scoped_ptr<content::MockDownloadItem> item( | 1915 scoped_ptr<content::MockDownloadItem> item( |
| 1916 CreateActiveDownloadItem(i, test_case.general)); | 1916 CreateActiveDownloadItem(i, test_case.general)); |
| 1917 scoped_ptr<DownloadTargetInfo> target_info = | 1917 scoped_ptr<DownloadTargetInfo> target_info = |
| 1918 RunDownloadTargetDeterminer(GetPathInDownloadDir(kInitialPath), | 1918 RunDownloadTargetDeterminer(GetPathInDownloadDir(kInitialPath), |
| 1919 item.get()); | 1919 item.get()); |
| 1920 EXPECT_EQ(test_case.expected_mime_type, target_info->mime_type); | 1920 EXPECT_EQ(test_case.expected_mime_type, target_info->mime_type); |
| 1921 } | 1921 } |
| 1922 } | 1922 } |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(npapi_plugin.path())) | 2179 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(npapi_plugin.path())) |
| 2180 .WillRepeatedly(Return(true)); | 2180 .WillRepeatedly(Return(true)); |
| 2181 | 2181 |
| 2182 target_info = RunDownloadTargetDeterminer( | 2182 target_info = RunDownloadTargetDeterminer( |
| 2183 GetPathInDownloadDir(kInitialPath), item.get()); | 2183 GetPathInDownloadDir(kInitialPath), item.get()); |
| 2184 EXPECT_FALSE(target_info->is_filetype_handled_safely); | 2184 EXPECT_FALSE(target_info->is_filetype_handled_safely); |
| 2185 } | 2185 } |
| 2186 #endif // defined(ENABLE_PLUGINS) | 2186 #endif // defined(ENABLE_PLUGINS) |
| 2187 | 2187 |
| 2188 } // namespace | 2188 } // namespace |
| OLD | NEW |