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 |
| 206 // extension_function_test_utils::RunFunction*() only uses browser for its |
| 207 // profile(), so pass it the on-record browser so that it always uses the |
| 208 // on-record profile. |
| 209 |
198 bool RunFunction(UIThreadExtensionFunction* function, | 210 bool RunFunction(UIThreadExtensionFunction* function, |
199 const std::string& args) { | 211 const std::string& args) { |
200 // extension_function_test_utils::RunFunction() does not take | 212 // extension_function_test_utils::RunFunction() does not take |
201 // ownership of |function|. | 213 // ownership of |function|. |
202 scoped_refptr<ExtensionFunction> function_owner(function); | 214 scoped_refptr<ExtensionFunction> function_owner(function); |
203 return extension_function_test_utils::RunFunction( | 215 return extension_function_test_utils::RunFunction( |
204 function, args, browser(), extension_function_test_utils::NONE); | 216 function, args, browser(), GetFlags()); |
205 } | 217 } |
206 | 218 |
207 base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, | 219 base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, |
208 const std::string& args) { | 220 const std::string& args) { |
209 return extension_function_test_utils::RunFunctionAndReturnResult( | 221 return extension_function_test_utils::RunFunctionAndReturnResult( |
210 function, args, browser(), extension_function_test_utils::NONE); | 222 function, args, browser(), GetFlags()); |
211 } | 223 } |
212 | 224 |
213 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, | 225 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, |
214 const std::string& args) { | 226 const std::string& args) { |
215 return extension_function_test_utils::RunFunctionAndReturnError( | 227 return extension_function_test_utils::RunFunctionAndReturnError( |
216 function, args, browser(), extension_function_test_utils::NONE); | 228 function, args, browser(), GetFlags()); |
217 } | 229 } |
218 | 230 |
219 bool RunFunctionAndReturnString(UIThreadExtensionFunction* function, | 231 bool RunFunctionAndReturnString(UIThreadExtensionFunction* function, |
220 const std::string& args, | 232 const std::string& args, |
221 std::string* result_string) { | 233 std::string* result_string) { |
222 scoped_ptr<base::Value> result(RunFunctionAndReturnResult(function, args)); | 234 scoped_ptr<base::Value> result(RunFunctionAndReturnResult(function, args)); |
223 EXPECT_TRUE(result.get()); | 235 EXPECT_TRUE(result.get()); |
224 return result.get() && result->GetAsString(result_string); | 236 return result.get() && result->GetAsString(result_string); |
225 } | 237 } |
226 | 238 |
(...skipping 22 matching lines...) Expand all Loading... |
249 &width, &height)); | 261 &width, &height)); |
250 EXPECT_EQ(expected_size, width); | 262 EXPECT_EQ(expected_size, width); |
251 EXPECT_EQ(expected_size, height); | 263 EXPECT_EQ(expected_size, height); |
252 } | 264 } |
253 | 265 |
254 const FilePath& downloads_directory() { | 266 const FilePath& downloads_directory() { |
255 return downloads_directory_.path(); | 267 return downloads_directory_.path(); |
256 } | 268 } |
257 | 269 |
258 private: | 270 private: |
259 bool CreateAndSetDownloadsDirectory(Browser* browser) { | 271 void CreateAndSetDownloadsDirectory() { |
260 if (!downloads_directory_.CreateUniqueTempDir()) | 272 ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir()); |
261 return false; | 273 current_browser()->profile()->GetPrefs()->SetFilePath( |
262 browser->profile()->GetPrefs()->SetFilePath( | |
263 prefs::kDownloadDefaultDirectory, | 274 prefs::kDownloadDefaultDirectory, |
264 downloads_directory_.path()); | 275 downloads_directory_.path()); |
265 return true; | |
266 } | 276 } |
267 | 277 |
268 ScopedTempDir downloads_directory_; | 278 ScopedTempDir downloads_directory_; |
269 }; | 279 }; |
270 | 280 |
| 281 class DownloadExtensionTestIncognito : public DownloadExtensionTest { |
| 282 public: |
| 283 virtual Browser* current_browser() OVERRIDE { return current_browser_; } |
| 284 |
| 285 virtual void SetUpOnMainThread() OVERRIDE { |
| 286 GoOnTheRecord(); |
| 287 DownloadExtensionTest::SetUpOnMainThread(); |
| 288 incognito_browser_ = CreateIncognitoBrowser(); |
| 289 GoOffTheRecord(); |
| 290 GetDownloadManager()->RemoveAllDownloads(); |
| 291 } |
| 292 |
| 293 void GoOnTheRecord() { current_browser_ = browser(); } |
| 294 void GoOffTheRecord() { current_browser_ = incognito_browser_; } |
| 295 |
| 296 private: |
| 297 Browser* incognito_browser_; |
| 298 Browser* current_browser_; |
| 299 }; |
| 300 |
271 class MockIconExtractorImpl : public DownloadFileIconExtractor { | 301 class MockIconExtractorImpl : public DownloadFileIconExtractor { |
272 public: | 302 public: |
273 MockIconExtractorImpl(const FilePath& path, IconLoader::IconSize icon_size, | 303 MockIconExtractorImpl(const FilePath& path, IconLoader::IconSize icon_size, |
274 const std::string& response) | 304 const std::string& response) |
275 : expected_path_(path), | 305 : expected_path_(path), |
276 expected_icon_size_(icon_size), | 306 expected_icon_size_(icon_size), |
277 response_(response) { | 307 response_(response) { |
278 } | 308 } |
279 virtual ~MockIconExtractorImpl() {} | 309 virtual ~MockIconExtractorImpl() {} |
280 | 310 |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 ASSERT_TRUE(result.get()); | 809 ASSERT_TRUE(result.get()); |
780 base::ListValue* result_list = NULL; | 810 base::ListValue* result_list = NULL; |
781 ASSERT_TRUE(result->GetAsList(&result_list)); | 811 ASSERT_TRUE(result->GetAsList(&result_list)); |
782 ASSERT_EQ(1UL, result_list->GetSize()); | 812 ASSERT_EQ(1UL, result_list->GetSize()); |
783 base::DictionaryValue* item_value = NULL; | 813 base::DictionaryValue* item_value = NULL; |
784 ASSERT_TRUE(result_list->GetDictionary(0, &item_value)); | 814 ASSERT_TRUE(result_list->GetDictionary(0, &item_value)); |
785 FilePath::StringType item_name; | 815 FilePath::StringType item_name; |
786 ASSERT_TRUE(item_value->GetString("filename", &item_name)); | 816 ASSERT_TRUE(item_value->GetString("filename", &item_name)); |
787 ASSERT_EQ(items[2]->GetFullPath().value(), item_name); | 817 ASSERT_EQ(items[2]->GetFullPath().value(), item_name); |
788 } | 818 } |
| 819 |
| 820 IN_PROC_BROWSER_TEST_F(DownloadExtensionTestIncognito, |
| 821 DownloadsApi_SearchIncognito) { |
| 822 scoped_ptr<base::Value> result_value; |
| 823 base::ListValue* result_list = NULL; |
| 824 base::DictionaryValue* result_dict = NULL; |
| 825 FilePath::StringType filename; |
| 826 bool is_incognito = false; |
| 827 std::string error; |
| 828 std::string on_item_arg; |
| 829 std::string off_item_arg; |
| 830 std::string result_string; |
| 831 |
| 832 // Set up one on-record item and one off-record item. |
| 833 |
| 834 GoOnTheRecord(); |
| 835 DownloadItem* on_item = CreateSlowTestDownload(); |
| 836 ASSERT_TRUE(on_item); |
| 837 ASSERT_FALSE(on_item->IsOtr()); |
| 838 on_item_arg = DownloadItemIdAsArgList(on_item); |
| 839 |
| 840 GoOffTheRecord(); |
| 841 DownloadItem* off_item = CreateSlowTestDownload(); |
| 842 ASSERT_TRUE(off_item); |
| 843 ASSERT_TRUE(off_item->IsOtr()); |
| 844 ASSERT_TRUE(on_item->GetFullPath() != off_item->GetFullPath()); |
| 845 off_item_arg = DownloadItemIdAsArgList(off_item); |
| 846 |
| 847 // Extensions running in the incognito window should have access to both |
| 848 // items because the Test extension is in spanning mode. |
| 849 result_value.reset(RunFunctionAndReturnResult( |
| 850 new DownloadsSearchFunction(), "[{}]")); |
| 851 ASSERT_TRUE(result_value.get()); |
| 852 ASSERT_TRUE(result_value->GetAsList(&result_list)); |
| 853 ASSERT_EQ(2UL, result_list->GetSize()); |
| 854 ASSERT_TRUE(result_list->GetDictionary(0, &result_dict)); |
| 855 ASSERT_TRUE(result_dict->GetString("filename", &filename)); |
| 856 ASSERT_TRUE(result_dict->GetBoolean("incognito", &is_incognito)); |
| 857 EXPECT_TRUE(on_item->GetFullPath() == FilePath(filename)); |
| 858 EXPECT_FALSE(is_incognito); |
| 859 ASSERT_TRUE(result_list->GetDictionary(1, &result_dict)); |
| 860 ASSERT_TRUE(result_dict->GetString("filename", &filename)); |
| 861 ASSERT_TRUE(result_dict->GetBoolean("incognito", &is_incognito)); |
| 862 EXPECT_TRUE(off_item->GetFullPath() == FilePath(filename)); |
| 863 EXPECT_TRUE(is_incognito); |
| 864 |
| 865 // Extensions running in the on-record window should have access only to the |
| 866 // on-record item. |
| 867 GoOnTheRecord(); |
| 868 result_value.reset(RunFunctionAndReturnResult( |
| 869 new DownloadsSearchFunction(), "[{}]")); |
| 870 ASSERT_TRUE(result_value.get()); |
| 871 ASSERT_TRUE(result_value->GetAsList(&result_list)); |
| 872 ASSERT_EQ(1UL, result_list->GetSize()); |
| 873 ASSERT_TRUE(result_list->GetDictionary(0, &result_dict)); |
| 874 ASSERT_TRUE(result_dict->GetString("filename", &filename)); |
| 875 EXPECT_TRUE(on_item->GetFullPath() == FilePath(filename)); |
| 876 ASSERT_TRUE(result_dict->GetBoolean("incognito", &is_incognito)); |
| 877 EXPECT_FALSE(is_incognito); |
| 878 |
| 879 // Pausing/Resuming the off-record item while on the record should return an |
| 880 // error. Cancelling "non-existent" downloads is not an error. |
| 881 error = RunFunctionAndReturnError(new DownloadsPauseFunction(), off_item_arg); |
| 882 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 883 error.c_str()); |
| 884 error = RunFunctionAndReturnError(new DownloadsResumeFunction(), |
| 885 off_item_arg); |
| 886 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 887 error.c_str()); |
| 888 error = RunFunctionAndReturnError( |
| 889 new DownloadsGetFileIconFunction(), |
| 890 base::StringPrintf("[%d, {}]", off_item->GetId())); |
| 891 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 892 error.c_str()); |
| 893 |
| 894 // TODO(benjhayden): Test incognito_split_mode() extension. |
| 895 // TODO(benjhayden): Test download(), onCreated, onChanged, onErased. |
| 896 |
| 897 GoOffTheRecord(); |
| 898 |
| 899 // Do the FileIcon test for both the on- and off-items while off the record. |
| 900 // NOTE(benjhayden): This does not include the FileIcon test from history, |
| 901 // just active downloads. This shouldn't be a problem. |
| 902 EXPECT_TRUE(RunFunctionAndReturnString( |
| 903 new DownloadsGetFileIconFunction(), |
| 904 base::StringPrintf("[%d, {}]", on_item->GetId()), &result_string)); |
| 905 EXPECT_TRUE(RunFunctionAndReturnString( |
| 906 new DownloadsGetFileIconFunction(), |
| 907 base::StringPrintf("[%d, {}]", off_item->GetId()), &result_string)); |
| 908 |
| 909 // Do the pause/resume/cancel test for both the on- and off-items while off |
| 910 // the record. |
| 911 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), on_item_arg)); |
| 912 EXPECT_TRUE(on_item->IsPaused()); |
| 913 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), on_item_arg)); |
| 914 EXPECT_TRUE(on_item->IsPaused()); |
| 915 EXPECT_TRUE(RunFunction(new DownloadsResumeFunction(), on_item_arg)); |
| 916 EXPECT_FALSE(on_item->IsPaused()); |
| 917 EXPECT_TRUE(RunFunction(new DownloadsResumeFunction(), on_item_arg)); |
| 918 EXPECT_FALSE(on_item->IsPaused()); |
| 919 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), on_item_arg)); |
| 920 EXPECT_TRUE(on_item->IsPaused()); |
| 921 EXPECT_TRUE(RunFunction(new DownloadsCancelFunction(), on_item_arg)); |
| 922 EXPECT_TRUE(on_item->IsCancelled()); |
| 923 EXPECT_TRUE(RunFunction(new DownloadsCancelFunction(), on_item_arg)); |
| 924 EXPECT_TRUE(on_item->IsCancelled()); |
| 925 error = RunFunctionAndReturnError(new DownloadsPauseFunction(), on_item_arg); |
| 926 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 927 error.c_str()); |
| 928 error = RunFunctionAndReturnError(new DownloadsResumeFunction(), on_item_arg); |
| 929 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 930 error.c_str()); |
| 931 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), off_item_arg)); |
| 932 EXPECT_TRUE(off_item->IsPaused()); |
| 933 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), off_item_arg)); |
| 934 EXPECT_TRUE(off_item->IsPaused()); |
| 935 EXPECT_TRUE(RunFunction(new DownloadsResumeFunction(), off_item_arg)); |
| 936 EXPECT_FALSE(off_item->IsPaused()); |
| 937 EXPECT_TRUE(RunFunction(new DownloadsResumeFunction(), off_item_arg)); |
| 938 EXPECT_FALSE(off_item->IsPaused()); |
| 939 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), off_item_arg)); |
| 940 EXPECT_TRUE(off_item->IsPaused()); |
| 941 EXPECT_TRUE(RunFunction(new DownloadsCancelFunction(), off_item_arg)); |
| 942 EXPECT_TRUE(off_item->IsCancelled()); |
| 943 EXPECT_TRUE(RunFunction(new DownloadsCancelFunction(), off_item_arg)); |
| 944 EXPECT_TRUE(off_item->IsCancelled()); |
| 945 error = RunFunctionAndReturnError(new DownloadsPauseFunction(), |
| 946 off_item_arg); |
| 947 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 948 error.c_str()); |
| 949 error = RunFunctionAndReturnError(new DownloadsResumeFunction(), |
| 950 off_item_arg); |
| 951 EXPECT_STREQ(download_extension_errors::kInvalidOperationError, |
| 952 error.c_str()); |
| 953 } |
OLD | NEW |