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