| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 EXPECT_TRUE(download_item->GetOpened()); | 872 EXPECT_TRUE(download_item->GetOpened()); |
| 873 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, | 873 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, |
| 874 base::StringPrintf("[{\"id\": %d," | 874 base::StringPrintf("[{\"id\": %d," |
| 875 " \"opened\": {" | 875 " \"opened\": {" |
| 876 " \"previous\": false," | 876 " \"previous\": false," |
| 877 " \"current\": true}}]", | 877 " \"current\": true}}]", |
| 878 download_item->GetId()))); | 878 download_item->GetId()))); |
| 879 } | 879 } |
| 880 | 880 |
| 881 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 881 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
| 882 DownloadExtensionTest_PauseResumeCancel) { | 882 DownloadExtensionTest_PauseResumeCancelErase) { |
| 883 DownloadItem* download_item = CreateSlowTestDownload(); | 883 DownloadItem* download_item = CreateSlowTestDownload(); |
| 884 ASSERT_TRUE(download_item); | 884 ASSERT_TRUE(download_item); |
| 885 | 885 |
| 886 // Call pause(). It should succeed and the download should be paused on | 886 // Call pause(). It should succeed and the download should be paused on |
| 887 // return. | 887 // return. |
| 888 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), | 888 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), |
| 889 DownloadItemIdAsArgList(download_item))); | 889 DownloadItemIdAsArgList(download_item))); |
| 890 EXPECT_TRUE(download_item->IsPaused()); | 890 EXPECT_TRUE(download_item->IsPaused()); |
| 891 | 891 |
| 892 // Calling pause() twice shouldn't be an error. | 892 // Calling pause() twice shouldn't be an error. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 error = RunFunctionAndReturnError( | 935 error = RunFunctionAndReturnError( |
| 936 new DownloadsPauseFunction(), "[-42]"); | 936 new DownloadsPauseFunction(), "[-42]"); |
| 937 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, | 937 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 938 error.c_str()); | 938 error.c_str()); |
| 939 | 939 |
| 940 // Calling resume on a non-existent download yields kInvalidOperationError | 940 // Calling resume on a non-existent download yields kInvalidOperationError |
| 941 error = RunFunctionAndReturnError( | 941 error = RunFunctionAndReturnError( |
| 942 new DownloadsResumeFunction(), "[-42]"); | 942 new DownloadsResumeFunction(), "[-42]"); |
| 943 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, | 943 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 944 error.c_str()); | 944 error.c_str()); |
| 945 |
| 946 EXPECT_TRUE(RunFunction( |
| 947 new DownloadsEraseFunction(), |
| 948 base::StringPrintf("[{\"id\": %d}]", download_item->GetId()))); |
| 949 download_item = NULL; |
| 950 DownloadManager::DownloadVector items; |
| 951 GetCurrentManager()->GetAllDownloads(&items); |
| 952 EXPECT_EQ(0UL, items.size()); |
| 945 } | 953 } |
| 946 | 954 |
| 947 scoped_refptr<UIThreadExtensionFunction> MockedGetFileIconFunction( | 955 scoped_refptr<UIThreadExtensionFunction> MockedGetFileIconFunction( |
| 948 const FilePath& expected_path, | 956 const FilePath& expected_path, |
| 949 IconLoader::IconSize icon_size, | 957 IconLoader::IconSize icon_size, |
| 950 const std::string& response) { | 958 const std::string& response) { |
| 951 scoped_refptr<DownloadsGetFileIconFunction> function( | 959 scoped_refptr<DownloadsGetFileIconFunction> function( |
| 952 new DownloadsGetFileIconFunction()); | 960 new DownloadsGetFileIconFunction()); |
| 953 function->SetIconExtractorForTesting(new MockIconExtractorImpl( | 961 function->SetIconExtractorForTesting(new MockIconExtractorImpl( |
| 954 expected_path, icon_size, response)); | 962 expected_path, icon_size, response)); |
| (...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2135 " \"state\": {" | 2143 " \"state\": {" |
| 2136 " \"previous\": \"in_progress\"," | 2144 " \"previous\": \"in_progress\"," |
| 2137 " \"current\": \"complete\"}}]", | 2145 " \"current\": \"complete\"}}]", |
| 2138 result_id, | 2146 result_id, |
| 2139 GetFilename("on_record.txt.crdownload").c_str(), | 2147 GetFilename("on_record.txt.crdownload").c_str(), |
| 2140 GetFilename("on_record.txt").c_str()))); | 2148 GetFilename("on_record.txt").c_str()))); |
| 2141 std::string disk_data; | 2149 std::string disk_data; |
| 2142 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data)); | 2150 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data)); |
| 2143 EXPECT_STREQ(kPayloadData, disk_data.c_str()); | 2151 EXPECT_STREQ(kPayloadData, disk_data.c_str()); |
| 2144 } | 2152 } |
| OLD | NEW |