| 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/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "chrome/browser/download/download_extension_api.h" | 10 #include "chrome/browser/download/download_extension_api.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 const FilePath::CharType* filename; | 52 const FilePath::CharType* filename; |
| 53 | 53 |
| 54 // State for the download. Note that IN_PROGRESS downloads will be created | 54 // State for the download. Note that IN_PROGRESS downloads will be created |
| 55 // as CANCELLED. | 55 // as CANCELLED. |
| 56 DownloadItem::DownloadState state; | 56 DownloadItem::DownloadState state; |
| 57 | 57 |
| 58 // Danger type for the download. | 58 // Danger type for the download. |
| 59 content::DownloadDangerType danger_type; | 59 content::DownloadDangerType danger_type; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 virtual Browser* current_browser() { return browser(); } |
| 63 |
| 62 // InProcessBrowserTest | 64 // InProcessBrowserTest |
| 63 virtual void SetUpOnMainThread() OVERRIDE { | 65 virtual void SetUpOnMainThread() OVERRIDE { |
| 64 BrowserThread::PostTask( | 66 BrowserThread::PostTask( |
| 65 BrowserThread::IO, FROM_HERE, | 67 BrowserThread::IO, FROM_HERE, |
| 66 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); | 68 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); |
| 67 InProcessBrowserTest::SetUpOnMainThread(); | 69 InProcessBrowserTest::SetUpOnMainThread(); |
| 68 ASSERT_TRUE(CreateAndSetDownloadsDirectory(browser())); | 70 CreateAndSetDownloadsDirectory(); |
| 69 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPromptForDownload, | 71 current_browser()->profile()->GetPrefs()->SetBoolean( |
| 70 false); | 72 prefs::kPromptForDownload, false); |
| 71 GetDownloadManager()->RemoveAllDownloads(); | 73 GetDownloadManager()->RemoveAllDownloads(); |
| 72 } | 74 } |
| 73 | 75 |
| 74 DownloadManager* GetDownloadManager() { | 76 virtual DownloadManager* GetDownloadManager() { |
| 75 DownloadService* download_service = | 77 DownloadService* download_service = |
| 76 DownloadServiceFactory::GetForProfile(browser()->profile()); | 78 DownloadServiceFactory::GetForProfile(current_browser()->profile()); |
| 77 return download_service->GetDownloadManager(); | 79 return download_service->GetDownloadManager(); |
| 78 } | 80 } |
| 79 | 81 |
| 80 // Creates a set of history downloads based on the provided |history_info| | 82 // Creates a set of history downloads based on the provided |history_info| |
| 81 // array. |count| is the number of elements in |history_info|. On success, | 83 // array. |count| is the number of elements in |history_info|. On success, |
| 82 // |items| will contain |count| DownloadItems in the order that they were | 84 // |items| will contain |count| DownloadItems in the order that they were |
| 83 // specified in |history_info|. Returns true on success and false otherwise. | 85 // specified in |history_info|. Returns true on success and false otherwise. |
| 84 bool CreateHistoryDownloads(const HistoryDownloadInfo* history_info, | 86 bool CreateHistoryDownloads(const HistoryDownloadInfo* history_info, |
| 85 size_t count, | 87 size_t count, |
| 86 DownloadManager::DownloadVector* items) { | 88 DownloadManager::DownloadVector* items) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 117 return true; | 119 return true; |
| 118 } | 120 } |
| 119 | 121 |
| 120 void CreateSlowTestDownloads( | 122 void CreateSlowTestDownloads( |
| 121 size_t count, DownloadManager::DownloadVector* items) { | 123 size_t count, DownloadManager::DownloadVector* items) { |
| 122 for (size_t i = 0; i < count; ++i) { | 124 for (size_t i = 0; i < count; ++i) { |
| 123 scoped_ptr<DownloadTestObserver> observer( | 125 scoped_ptr<DownloadTestObserver> observer( |
| 124 CreateInProgressDownloadObserver(1)); | 126 CreateInProgressDownloadObserver(1)); |
| 125 GURL slow_download_url(URLRequestSlowDownloadJob::kUnknownSizeUrl); | 127 GURL slow_download_url(URLRequestSlowDownloadJob::kUnknownSizeUrl); |
| 126 ui_test_utils::NavigateToURLWithDisposition( | 128 ui_test_utils::NavigateToURLWithDisposition( |
| 127 browser(), slow_download_url, CURRENT_TAB, | 129 current_browser(), slow_download_url, CURRENT_TAB, |
| 128 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 130 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 129 observer->WaitForFinished(); | 131 observer->WaitForFinished(); |
| 130 EXPECT_EQ( | 132 EXPECT_EQ( |
| 131 1u, observer->NumDownloadsSeenInState(DownloadItem::IN_PROGRESS)); | 133 1u, observer->NumDownloadsSeenInState(DownloadItem::IN_PROGRESS)); |
| 132 // We don't expect a select file dialog. | 134 // We don't expect a select file dialog. |
| 133 CHECK(!observer->select_file_dialog_seen()); | 135 ASSERT_FALSE(observer->select_file_dialog_seen()); |
| 134 } | 136 } |
| 135 GetDownloadManager()->GetAllDownloads(FilePath(), items); | 137 GetDownloadManager()->GetAllDownloads(FilePath(), items); |
| 136 CHECK_EQ(count, items->size()); | 138 ASSERT_EQ(count, items->size()); |
| 137 } | 139 } |
| 138 | 140 |
| 139 DownloadItem* CreateSlowTestDownload() { | 141 DownloadItem* CreateSlowTestDownload() { |
| 140 scoped_ptr<DownloadTestObserver> observer( | 142 scoped_ptr<DownloadTestObserver> observer( |
| 141 CreateInProgressDownloadObserver(1)); | 143 CreateInProgressDownloadObserver(1)); |
| 142 GURL slow_download_url(URLRequestSlowDownloadJob::kUnknownSizeUrl); | 144 GURL slow_download_url(URLRequestSlowDownloadJob::kUnknownSizeUrl); |
| 143 DownloadManager* manager = GetDownloadManager(); | 145 DownloadManager* manager = GetDownloadManager(); |
| 144 | 146 |
| 145 EXPECT_EQ(0, manager->InProgressCount()); | 147 EXPECT_EQ(0, manager->InProgressCount()); |
| 146 if (manager->InProgressCount() != 0) | 148 if (manager->InProgressCount() != 0) |
| 147 return NULL; | 149 return NULL; |
| 148 | 150 |
| 149 ui_test_utils::NavigateToURLWithDisposition( | 151 ui_test_utils::NavigateToURLWithDisposition( |
| 150 browser(), slow_download_url, CURRENT_TAB, | 152 current_browser(), slow_download_url, CURRENT_TAB, |
| 151 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 153 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 152 | 154 |
| 153 observer->WaitForFinished(); | 155 observer->WaitForFinished(); |
| 154 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::IN_PROGRESS)); | 156 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::IN_PROGRESS)); |
| 155 // We don't expect a select file dialog. | 157 // We don't expect a select file dialog. |
| 156 if (observer->select_file_dialog_seen()) | 158 if (observer->select_file_dialog_seen()) |
| 157 return NULL; | 159 return NULL; |
| 158 | 160 |
| 159 DownloadManager::DownloadVector items; | 161 DownloadManager::DownloadVector items; |
| 160 manager->GetAllDownloads(FilePath(), &items); | 162 manager->GetAllDownloads(FilePath(), &items); |
| 161 | 163 |
| 162 DownloadItem* new_item = NULL; | 164 DownloadItem* new_item = NULL; |
| 163 for (DownloadManager::DownloadVector::iterator iter = items.begin(); | 165 for (DownloadManager::DownloadVector::iterator iter = items.begin(); |
| 164 iter != items.end(); ++iter) { | 166 iter != items.end(); ++iter) { |
| 165 if ((*iter)->GetState() == DownloadItem::IN_PROGRESS) { | 167 if ((*iter)->GetState() == DownloadItem::IN_PROGRESS) { |
| 166 // There should be only one IN_PROGRESS item. | 168 // There should be only one IN_PROGRESS item. |
| 167 EXPECT_EQ(NULL, new_item); | 169 EXPECT_EQ(NULL, new_item); |
| 168 new_item = *iter; | 170 new_item = *iter; |
| 169 } | 171 } |
| 170 } | 172 } |
| 171 return new_item; | 173 return new_item; |
| 172 } | 174 } |
| 173 | 175 |
| 174 void FinishPendingSlowDownloads() { | 176 void FinishPendingSlowDownloads() { |
| 175 scoped_ptr<DownloadTestObserver> observer( | 177 scoped_ptr<DownloadTestObserver> observer( |
| 176 CreateDownloadObserver(1)); | 178 CreateDownloadObserver(1)); |
| 177 GURL finish_url(URLRequestSlowDownloadJob::kFinishDownloadUrl); | 179 GURL finish_url(URLRequestSlowDownloadJob::kFinishDownloadUrl); |
| 178 ui_test_utils::NavigateToURLWithDisposition( | 180 ui_test_utils::NavigateToURLWithDisposition( |
| 179 browser(), finish_url, NEW_FOREGROUND_TAB, | 181 current_browser(), finish_url, NEW_FOREGROUND_TAB, |
| 180 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 182 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 181 observer->WaitForFinished(); | 183 observer->WaitForFinished(); |
| 182 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); | 184 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); |
| 183 } | 185 } |
| 184 | 186 |
| 185 DownloadTestObserver* CreateDownloadObserver(size_t download_count) { | 187 DownloadTestObserver* CreateDownloadObserver(size_t download_count) { |
| 186 return new DownloadTestObserverTerminal( | 188 return new DownloadTestObserverTerminal( |
| 187 GetDownloadManager(), download_count, true, | 189 GetDownloadManager(), download_count, true, |
| 188 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); | 190 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); |
| 189 } | 191 } |
| 190 | 192 |
| 191 DownloadTestObserver* CreateInProgressDownloadObserver( | 193 DownloadTestObserver* CreateInProgressDownloadObserver( |
| 192 size_t download_count) { | 194 size_t download_count) { |
| 193 return new DownloadTestObserverInProgress(GetDownloadManager(), | 195 return new DownloadTestObserverInProgress(GetDownloadManager(), |
| 194 download_count, | 196 download_count, |
| 195 true); | 197 true); |
| 196 } | 198 } |
| 197 | 199 |
| 200 extension_function_test_utils::RunFunctionFlags GetFlags() { |
| 201 return current_browser()->profile()->IsOffTheRecord() ? |
| 202 extension_function_test_utils::INCLUDE_INCOGNITO : |
| 203 extension_function_test_utils::NONE; |
| 204 } |
| 205 |
| 198 bool RunFunction(UIThreadExtensionFunction* function, | 206 bool RunFunction(UIThreadExtensionFunction* function, |
| 199 const std::string& args) { | 207 const std::string& args) { |
| 200 // extension_function_test_utils::RunFunction() does not take | 208 // extension_function_test_utils::RunFunction() does not take |
| 201 // ownership of |function|. | 209 // ownership of |function|. |
| 202 scoped_refptr<ExtensionFunction> function_owner(function); | 210 scoped_refptr<ExtensionFunction> function_owner(function); |
| 203 return extension_function_test_utils::RunFunction( | 211 return extension_function_test_utils::RunFunction( |
| 204 function, args, browser(), extension_function_test_utils::NONE); | 212 function, args, current_browser(), GetFlags()); |
| 205 } | 213 } |
| 206 | 214 |
| 207 base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, | 215 base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, |
| 208 const std::string& args) { | 216 const std::string& args) { |
| 209 return extension_function_test_utils::RunFunctionAndReturnResult( | 217 return extension_function_test_utils::RunFunctionAndReturnResult( |
| 210 function, args, browser(), extension_function_test_utils::NONE); | 218 function, args, current_browser(), GetFlags()); |
| 211 } | 219 } |
| 212 | 220 |
| 213 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, | 221 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, |
| 214 const std::string& args) { | 222 const std::string& args) { |
| 215 return extension_function_test_utils::RunFunctionAndReturnError( | 223 return extension_function_test_utils::RunFunctionAndReturnError( |
| 216 function, args, browser(), extension_function_test_utils::NONE); | 224 function, args, current_browser(), GetFlags()); |
| 217 } | 225 } |
| 218 | 226 |
| 219 bool RunFunctionAndReturnString(UIThreadExtensionFunction* function, | 227 bool RunFunctionAndReturnString(UIThreadExtensionFunction* function, |
| 220 const std::string& args, | 228 const std::string& args, |
| 221 std::string* result_string) { | 229 std::string* result_string) { |
| 222 scoped_ptr<base::Value> result(RunFunctionAndReturnResult(function, args)); | 230 scoped_ptr<base::Value> result(RunFunctionAndReturnResult(function, args)); |
| 223 EXPECT_TRUE(result.get()); | 231 EXPECT_TRUE(result.get()); |
| 224 return result.get() && result->GetAsString(result_string); | 232 return result.get() && result->GetAsString(result_string); |
| 225 } | 233 } |
| 226 | 234 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 249 &width, &height)); | 257 &width, &height)); |
| 250 EXPECT_EQ(expected_size, width); | 258 EXPECT_EQ(expected_size, width); |
| 251 EXPECT_EQ(expected_size, height); | 259 EXPECT_EQ(expected_size, height); |
| 252 } | 260 } |
| 253 | 261 |
| 254 const FilePath& downloads_directory() { | 262 const FilePath& downloads_directory() { |
| 255 return downloads_directory_.path(); | 263 return downloads_directory_.path(); |
| 256 } | 264 } |
| 257 | 265 |
| 258 private: | 266 private: |
| 259 bool CreateAndSetDownloadsDirectory(Browser* browser) { | 267 void CreateAndSetDownloadsDirectory() { |
| 260 if (!downloads_directory_.CreateUniqueTempDir()) | 268 ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir()); |
| 261 return false; | 269 current_browser()->profile()->GetPrefs()->SetFilePath( |
| 262 browser->profile()->GetPrefs()->SetFilePath( | |
| 263 prefs::kDownloadDefaultDirectory, | 270 prefs::kDownloadDefaultDirectory, |
| 264 downloads_directory_.path()); | 271 downloads_directory_.path()); |
| 265 return true; | |
| 266 } | 272 } |
| 267 | 273 |
| 268 ScopedTempDir downloads_directory_; | 274 ScopedTempDir downloads_directory_; |
| 269 }; | 275 }; |
| 270 | 276 |
| 277 class DownloadExtensionTestIncognito : public DownloadExtensionTest { |
| 278 public: |
| 279 virtual Browser* current_browser() OVERRIDE { return current_browser_; } |
| 280 |
| 281 virtual void SetUpOnMainThread() OVERRIDE { |
| 282 GoOnTheRecord(); |
| 283 DownloadExtensionTest::SetUpOnMainThread(); |
| 284 incognito_browser_ = CreateIncognitoBrowser(); |
| 285 GoOffTheRecord(); |
| 286 GetDownloadManager()->RemoveAllDownloads(); |
| 287 } |
| 288 |
| 289 void GoOnTheRecord() { current_browser_ = browser(); } |
| 290 void GoOffTheRecord() { current_browser_ = incognito_browser_; } |
| 291 |
| 292 private: |
| 293 Browser* incognito_browser_; |
| 294 Browser* current_browser_; |
| 295 }; |
| 296 |
| 271 class MockIconExtractorImpl : public DownloadFileIconExtractor { | 297 class MockIconExtractorImpl : public DownloadFileIconExtractor { |
| 272 public: | 298 public: |
| 273 MockIconExtractorImpl(const FilePath& path, IconLoader::IconSize icon_size, | 299 MockIconExtractorImpl(const FilePath& path, IconLoader::IconSize icon_size, |
| 274 const std::string& response) | 300 const std::string& response) |
| 275 : expected_path_(path), | 301 : expected_path_(path), |
| 276 expected_icon_size_(icon_size), | 302 expected_icon_size_(icon_size), |
| 277 response_(response) { | 303 response_(response) { |
| 278 } | 304 } |
| 279 virtual ~MockIconExtractorImpl() {} | 305 virtual ~MockIconExtractorImpl() {} |
| 280 | 306 |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 ASSERT_TRUE(result.get()); | 805 ASSERT_TRUE(result.get()); |
| 780 base::ListValue* result_list = NULL; | 806 base::ListValue* result_list = NULL; |
| 781 ASSERT_TRUE(result->GetAsList(&result_list)); | 807 ASSERT_TRUE(result->GetAsList(&result_list)); |
| 782 ASSERT_EQ(1UL, result_list->GetSize()); | 808 ASSERT_EQ(1UL, result_list->GetSize()); |
| 783 base::DictionaryValue* item_value = NULL; | 809 base::DictionaryValue* item_value = NULL; |
| 784 ASSERT_TRUE(result_list->GetDictionary(0, &item_value)); | 810 ASSERT_TRUE(result_list->GetDictionary(0, &item_value)); |
| 785 FilePath::StringType item_name; | 811 FilePath::StringType item_name; |
| 786 ASSERT_TRUE(item_value->GetString("filename", &item_name)); | 812 ASSERT_TRUE(item_value->GetString("filename", &item_name)); |
| 787 ASSERT_EQ(items[2]->GetFullPath().value(), item_name); | 813 ASSERT_EQ(items[2]->GetFullPath().value(), item_name); |
| 788 } | 814 } |
| 815 |
| 816 IN_PROC_BROWSER_TEST_F(DownloadExtensionTestIncognito, |
| 817 DownloadsApi_SearchIncognito) { |
| 818 scoped_ptr<base::Value> result_value; |
| 819 base::ListValue* result_list = NULL; |
| 820 base::DictionaryValue* result_dict = NULL; |
| 821 FilePath::StringType filename; |
| 822 bool is_incognito = false; |
| 823 std::string error; |
| 824 std::string on_item_arg; |
| 825 std::string off_item_arg; |
| 826 |
| 827 // Set up one on-record item and one off-record item. |
| 828 |
| 829 GoOnTheRecord(); |
| 830 DownloadItem* on_item = CreateSlowTestDownload(); |
| 831 ASSERT_TRUE(on_item); |
| 832 ASSERT_FALSE(on_item->IsOtr()); |
| 833 on_item_arg = DownloadItemIdAsArgList(on_item); |
| 834 |
| 835 GoOffTheRecord(); |
| 836 DownloadItem* off_item = CreateSlowTestDownload(); |
| 837 ASSERT_TRUE(off_item); |
| 838 ASSERT_TRUE(off_item->IsOtr()); |
| 839 ASSERT_TRUE(on_item->GetFullPath() != off_item->GetFullPath()); |
| 840 off_item_arg = DownloadItemIdAsArgList(off_item); |
| 841 |
| 842 // Extensions running in the incognito window should have access to both |
| 843 // items because the Test extension is in spanning mode. |
| 844 result_value.reset(RunFunctionAndReturnResult( |
| 845 new DownloadsSearchFunction(), "[{}]")); |
| 846 ASSERT_TRUE(result_value.get()); |
| 847 ASSERT_TRUE(result_value->GetAsList(&result_list)); |
| 848 ASSERT_EQ(2UL, result_list->GetSize()); |
| 849 ASSERT_TRUE(result_list->GetDictionary(0, &result_dict)); |
| 850 ASSERT_TRUE(result_dict->GetString("filename", &filename)); |
| 851 ASSERT_TRUE(result_dict->GetBoolean("incognito", &is_incognito)); |
| 852 EXPECT_TRUE(on_item->GetFullPath() == FilePath(filename)); |
| 853 EXPECT_FALSE(is_incognito); |
| 854 ASSERT_TRUE(result_list->GetDictionary(1, &result_dict)); |
| 855 ASSERT_TRUE(result_dict->GetString("filename", &filename)); |
| 856 ASSERT_TRUE(result_dict->GetBoolean("incognito", &is_incognito)); |
| 857 EXPECT_TRUE(off_item->GetFullPath() == FilePath(filename)); |
| 858 EXPECT_TRUE(is_incognito); |
| 859 |
| 860 // Extensions running in the on-record window should have access to the |
| 861 // on-record item. |
| 862 GoOnTheRecord(); |
| 863 result_value.reset(RunFunctionAndReturnResult( |
| 864 new DownloadsSearchFunction(), "[{}]")); |
| 865 ASSERT_TRUE(result_value.get()); |
| 866 ASSERT_TRUE(result_value->GetAsList(&result_list)); |
| 867 ASSERT_EQ(1UL, result_list->GetSize()); |
| 868 ASSERT_TRUE(result_list->GetDictionary(0, &result_dict)); |
| 869 ASSERT_TRUE(result_dict->GetString("filename", &filename)); |
| 870 EXPECT_TRUE(on_item->GetFullPath() == FilePath(filename)); |
| 871 ASSERT_TRUE(result_dict->GetBoolean("incognito", &is_incognito)); |
| 872 EXPECT_FALSE(is_incognito); |
| 873 |
| 874 // Pausing/Resuming the off-record item while on the record should return an |
| 875 // error. Cancelling "non-existent" downloads is not an error. |
| 876 error = RunFunctionAndReturnError(new DownloadsPauseFunction(), off_item_arg); |
| 877 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 878 error.c_str()); |
| 879 error = RunFunctionAndReturnError(new DownloadsResumeFunction(), |
| 880 off_item_arg); |
| 881 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 882 error.c_str()); |
| 883 |
| 884 GoOffTheRecord(); |
| 885 // Do the pause/resume/cancel test for both the on- and off-items while in the |
| 886 // off-record browser. |
| 887 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), on_item_arg)); |
| 888 EXPECT_TRUE(on_item->IsPaused()); |
| 889 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), on_item_arg)); |
| 890 EXPECT_TRUE(on_item->IsPaused()); |
| 891 EXPECT_TRUE(RunFunction(new DownloadsResumeFunction(), on_item_arg)); |
| 892 EXPECT_FALSE(on_item->IsPaused()); |
| 893 EXPECT_TRUE(RunFunction(new DownloadsResumeFunction(), on_item_arg)); |
| 894 EXPECT_FALSE(on_item->IsPaused()); |
| 895 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), on_item_arg)); |
| 896 EXPECT_TRUE(on_item->IsPaused()); |
| 897 EXPECT_TRUE(RunFunction(new DownloadsCancelFunction(), on_item_arg)); |
| 898 EXPECT_TRUE(on_item->IsCancelled()); |
| 899 EXPECT_TRUE(RunFunction(new DownloadsCancelFunction(), on_item_arg)); |
| 900 EXPECT_TRUE(on_item->IsCancelled()); |
| 901 error = RunFunctionAndReturnError(new DownloadsPauseFunction(), on_item_arg); |
| 902 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 903 error.c_str()); |
| 904 error = RunFunctionAndReturnError(new DownloadsResumeFunction(), on_item_arg); |
| 905 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 906 error.c_str()); |
| 907 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), off_item_arg)); |
| 908 EXPECT_TRUE(off_item->IsPaused()); |
| 909 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), off_item_arg)); |
| 910 EXPECT_TRUE(off_item->IsPaused()); |
| 911 EXPECT_TRUE(RunFunction(new DownloadsResumeFunction(), off_item_arg)); |
| 912 EXPECT_FALSE(off_item->IsPaused()); |
| 913 EXPECT_TRUE(RunFunction(new DownloadsResumeFunction(), off_item_arg)); |
| 914 EXPECT_FALSE(off_item->IsPaused()); |
| 915 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), off_item_arg)); |
| 916 EXPECT_TRUE(off_item->IsPaused()); |
| 917 EXPECT_TRUE(RunFunction(new DownloadsCancelFunction(), off_item_arg)); |
| 918 EXPECT_TRUE(off_item->IsCancelled()); |
| 919 EXPECT_TRUE(RunFunction(new DownloadsCancelFunction(), off_item_arg)); |
| 920 EXPECT_TRUE(off_item->IsCancelled()); |
| 921 error = RunFunctionAndReturnError(new DownloadsPauseFunction(), |
| 922 off_item_arg); |
| 923 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 924 error.c_str()); |
| 925 error = RunFunctionAndReturnError(new DownloadsResumeFunction(), |
| 926 off_item_arg); |
| 927 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 928 error.c_str()); |
| 929 } |
| OLD | NEW |