Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/browser/download/download_extension_test.cc

Issue 9425014: Fix most of the downloads api in incognito profiles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
198 bool RunFunction(UIThreadExtensionFunction* function, 200 bool RunFunction(UIThreadExtensionFunction* function,
199 const std::string& args) { 201 const std::string& args) {
200 // extension_function_test_utils::RunFunction() does not take 202 // extension_function_test_utils::RunFunction() does not take
201 // ownership of |function|. 203 // ownership of |function|.
202 scoped_refptr<ExtensionFunction> function_owner(function); 204 scoped_refptr<ExtensionFunction> function_owner(function);
203 return extension_function_test_utils::RunFunction( 205 return extension_function_test_utils::RunFunction(
204 function, args, browser(), extension_function_test_utils::NONE); 206 function, args, current_browser(), extension_function_test_utils::NONE);
205 } 207 }
206 208
207 base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, 209 base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function,
208 const std::string& args) { 210 const std::string& args) {
209 return extension_function_test_utils::RunFunctionAndReturnResult( 211 return extension_function_test_utils::RunFunctionAndReturnResult(
210 function, args, browser(), extension_function_test_utils::NONE); 212 function, args, current_browser(), extension_function_test_utils::NONE);
211 } 213 }
212 214
213 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, 215 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
214 const std::string& args) { 216 const std::string& args) {
215 return extension_function_test_utils::RunFunctionAndReturnError( 217 return extension_function_test_utils::RunFunctionAndReturnError(
216 function, args, browser(), extension_function_test_utils::NONE); 218 function, args, current_browser(), extension_function_test_utils::NONE);
217 } 219 }
218 220
219 bool RunFunctionAndReturnString(UIThreadExtensionFunction* function, 221 bool RunFunctionAndReturnString(UIThreadExtensionFunction* function,
220 const std::string& args, 222 const std::string& args,
221 std::string* result_string) { 223 std::string* result_string) {
222 scoped_ptr<base::Value> result(RunFunctionAndReturnResult(function, args)); 224 scoped_ptr<base::Value> result(RunFunctionAndReturnResult(function, args));
223 EXPECT_TRUE(result.get()); 225 EXPECT_TRUE(result.get());
224 return result.get() && result->GetAsString(result_string); 226 return result.get() && result->GetAsString(result_string);
225 } 227 }
226 228
(...skipping 22 matching lines...) Expand all
249 &width, &height)); 251 &width, &height));
250 EXPECT_EQ(expected_size, width); 252 EXPECT_EQ(expected_size, width);
251 EXPECT_EQ(expected_size, height); 253 EXPECT_EQ(expected_size, height);
252 } 254 }
253 255
254 const FilePath& downloads_directory() { 256 const FilePath& downloads_directory() {
255 return downloads_directory_.path(); 257 return downloads_directory_.path();
256 } 258 }
257 259
258 private: 260 private:
259 bool CreateAndSetDownloadsDirectory(Browser* browser) { 261 void CreateAndSetDownloadsDirectory() {
260 if (!downloads_directory_.CreateUniqueTempDir()) 262 ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir());
261 return false; 263 current_browser()->profile()->GetPrefs()->SetFilePath(
262 browser->profile()->GetPrefs()->SetFilePath(
263 prefs::kDownloadDefaultDirectory, 264 prefs::kDownloadDefaultDirectory,
264 downloads_directory_.path()); 265 downloads_directory_.path());
265 return true;
266 } 266 }
267 267
268 ScopedTempDir downloads_directory_; 268 ScopedTempDir downloads_directory_;
269 }; 269 };
270 270
271 class DownloadExtensionTestIncognito : public DownloadExtensionTest {
272 public:
273 virtual Browser* current_browser() OVERRIDE { return current_browser_; }
274
275 virtual void SetUpOnMainThread() OVERRIDE {
276 GoOnTheRecord();
277 DownloadExtensionTest::SetUpOnMainThread();
278 incognito_browser_ = CreateIncognitoBrowser();
279 GoOffTheRecord();
280 GetDownloadManager()->RemoveAllDownloads();
281 }
282
283 void GoOnTheRecord() { current_browser_ = browser(); }
284 void GoOffTheRecord() { current_browser_ = incognito_browser_; }
285
286 private:
287 Browser* incognito_browser_;
288 Browser* current_browser_;
289 };
290
271 class MockIconExtractorImpl : public DownloadFileIconExtractor { 291 class MockIconExtractorImpl : public DownloadFileIconExtractor {
272 public: 292 public:
273 MockIconExtractorImpl(const FilePath& path, IconLoader::IconSize icon_size, 293 MockIconExtractorImpl(const FilePath& path, IconLoader::IconSize icon_size,
274 const std::string& response) 294 const std::string& response)
275 : expected_path_(path), 295 : expected_path_(path),
276 expected_icon_size_(icon_size), 296 expected_icon_size_(icon_size),
277 response_(response) { 297 response_(response) {
278 } 298 }
279 virtual ~MockIconExtractorImpl() {} 299 virtual ~MockIconExtractorImpl() {}
280 300
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 ASSERT_TRUE(result.get()); 799 ASSERT_TRUE(result.get());
780 base::ListValue* result_list = NULL; 800 base::ListValue* result_list = NULL;
781 ASSERT_TRUE(result->GetAsList(&result_list)); 801 ASSERT_TRUE(result->GetAsList(&result_list));
782 ASSERT_EQ(1UL, result_list->GetSize()); 802 ASSERT_EQ(1UL, result_list->GetSize());
783 base::DictionaryValue* item_value = NULL; 803 base::DictionaryValue* item_value = NULL;
784 ASSERT_TRUE(result_list->GetDictionary(0, &item_value)); 804 ASSERT_TRUE(result_list->GetDictionary(0, &item_value));
785 FilePath::StringType item_name; 805 FilePath::StringType item_name;
786 ASSERT_TRUE(item_value->GetString("filename", &item_name)); 806 ASSERT_TRUE(item_value->GetString("filename", &item_name));
787 ASSERT_EQ(items[2]->GetFullPath().value(), item_name); 807 ASSERT_EQ(items[2]->GetFullPath().value(), item_name);
788 } 808 }
809
810 IN_PROC_BROWSER_TEST_F(DownloadExtensionTestIncognito,
811 DownloadsApi_SearchIncognito) {
812 scoped_ptr<base::Value> result_value;
813 base::ListValue* result_list = NULL;
814 base::DictionaryValue* result_dict = NULL;
815 FilePath::StringType filename;
816 bool is_incognito = false;
817 std::string error;
818 std::string on_item_arg;
819 std::string off_item_arg;
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 on_item_arg = DownloadItemIdAsArgList(on_item);
828
829 GoOffTheRecord();
830 DownloadItem* off_item = CreateSlowTestDownload();
831 ASSERT_TRUE(off_item);
832 ASSERT_TRUE(off_item->IsOtr());
833 ASSERT_TRUE(on_item->GetFullPath() != off_item->GetFullPath());
834 off_item_arg = DownloadItemIdAsArgList(off_item);
835
836 // Extensions running in the incognito window should have access to the
837 // incognito items. The 'incognito:only' filter should filter out the
838 // on-record item.
839 result_value.reset(RunFunctionAndReturnResult(
840 new DownloadsSearchFunction(), "[{\"incognito\": \"only\"}]"));
841 ASSERT_TRUE(result_value.get());
842 ASSERT_TRUE(result_value->GetAsList(&result_list));
843 ASSERT_EQ(1UL, result_list->GetSize());
844 ASSERT_TRUE(result_list->GetDictionary(0, &result_dict));
845 ASSERT_TRUE(result_dict->GetString("filename", &filename));
846 EXPECT_TRUE(off_item->GetFullPath() == FilePath(filename));
847 ASSERT_TRUE(result_dict->GetBoolean("incognito", &is_incognito));
848 EXPECT_TRUE(is_incognito);
849
850 // Extensions running in the incognito window should also have access to the
851 // on-record items. The 'incognito:none' filter should filter out the
852 // off-record items.
853 result_value.reset(RunFunctionAndReturnResult(
854 new DownloadsSearchFunction(), "[{\"incognito\": \"none\"}]"));
855 ASSERT_TRUE(result_value.get());
856 ASSERT_TRUE(result_value->GetAsList(&result_list));
857 ASSERT_EQ(1UL, result_list->GetSize());
858 ASSERT_TRUE(result_list->GetDictionary(0, &result_dict));
859 ASSERT_TRUE(result_dict->GetString("filename", &filename));
860 EXPECT_TRUE(on_item->GetFullPath() == FilePath(filename));
861 ASSERT_TRUE(result_dict->GetBoolean("incognito", &is_incognito));
862 EXPECT_FALSE(is_incognito);
863
864 // Extensions running in the on-record window should not have access to the
865 // incognito items. Filtering out on-record items should leave zero items.
866 GoOnTheRecord();
867 result_value.reset(RunFunctionAndReturnResult(
868 new DownloadsSearchFunction(), "[{\"incognito\": \"only\"}]"));
869 ASSERT_TRUE(result_value.get());
870 ASSERT_TRUE(result_value->GetAsList(&result_list));
871 EXPECT_EQ(0UL, result_list->GetSize());
872
873 // Extensions running in the on-record window should still have access to the
874 // on-record items. The 'incognito:none' filter should have no effect in
875 // on-record windows.
876 result_value.reset(RunFunctionAndReturnResult(
877 new DownloadsSearchFunction(), "[{\"incognito\": \"none\"}]"));
878 ASSERT_TRUE(result_value.get());
879 ASSERT_TRUE(result_value->GetAsList(&result_list));
880 ASSERT_EQ(1UL, result_list->GetSize());
881 ASSERT_TRUE(result_list->GetDictionary(0, &result_dict));
882 ASSERT_TRUE(result_dict->GetString("filename", &filename));
883 EXPECT_TRUE(on_item->GetFullPath() == FilePath(filename));
884 ASSERT_TRUE(result_dict->GetBoolean("incognito", &is_incognito));
885 EXPECT_FALSE(is_incognito);
886
887 // Pausing/Resuming the off-record item while on the record should return an
888 // error. Cancelling "non-existent" downloads is not an error.
889 error = RunFunctionAndReturnError(new DownloadsPauseFunction(), off_item_arg);
890 EXPECT_STREQ(download_extension_errors::kInvalidOperationError,
891 error.c_str());
892 error = RunFunctionAndReturnError(new DownloadsResumeFunction(),
893 off_item_arg);
894 EXPECT_STREQ(download_extension_errors::kInvalidOperationError,
895 error.c_str());
896
897 GoOffTheRecord();
898 // Do the pause/resume/cancel test for both the on- and off-items while in the
899 // off-record browser.
900 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), on_item_arg));
901 EXPECT_TRUE(on_item->IsPaused());
902 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), on_item_arg));
903 EXPECT_TRUE(on_item->IsPaused());
904 EXPECT_TRUE(RunFunction(new DownloadsResumeFunction(), on_item_arg));
905 EXPECT_FALSE(on_item->IsPaused());
906 EXPECT_TRUE(RunFunction(new DownloadsResumeFunction(), on_item_arg));
907 EXPECT_FALSE(on_item->IsPaused());
908 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), on_item_arg));
909 EXPECT_TRUE(on_item->IsPaused());
910 EXPECT_TRUE(RunFunction(new DownloadsCancelFunction(), on_item_arg));
911 EXPECT_TRUE(on_item->IsCancelled());
912 EXPECT_TRUE(RunFunction(new DownloadsCancelFunction(), on_item_arg));
913 EXPECT_TRUE(on_item->IsCancelled());
914 error = RunFunctionAndReturnError(new DownloadsPauseFunction(), on_item_arg);
915 EXPECT_STREQ(download_extension_errors::kInvalidOperationError,
916 error.c_str());
917 error = RunFunctionAndReturnError(new DownloadsResumeFunction(), on_item_arg);
918 EXPECT_STREQ(download_extension_errors::kInvalidOperationError,
919 error.c_str());
920 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), off_item_arg));
921 EXPECT_TRUE(off_item->IsPaused());
922 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), off_item_arg));
923 EXPECT_TRUE(off_item->IsPaused());
924 EXPECT_TRUE(RunFunction(new DownloadsResumeFunction(), off_item_arg));
925 EXPECT_FALSE(off_item->IsPaused());
926 EXPECT_TRUE(RunFunction(new DownloadsResumeFunction(), off_item_arg));
927 EXPECT_FALSE(off_item->IsPaused());
928 EXPECT_TRUE(RunFunction(new DownloadsPauseFunction(), off_item_arg));
929 EXPECT_TRUE(off_item->IsPaused());
930 EXPECT_TRUE(RunFunction(new DownloadsCancelFunction(), off_item_arg));
931 EXPECT_TRUE(off_item->IsCancelled());
932 EXPECT_TRUE(RunFunction(new DownloadsCancelFunction(), off_item_arg));
933 EXPECT_TRUE(off_item->IsCancelled());
934 error = RunFunctionAndReturnError(new DownloadsPauseFunction(),
935 off_item_arg);
936 EXPECT_STREQ(download_extension_errors::kInvalidOperationError,
937 error.c_str());
938 error = RunFunctionAndReturnError(new DownloadsResumeFunction(),
939 off_item_arg);
940 EXPECT_STREQ(download_extension_errors::kInvalidOperationError,
941 error.c_str());
942 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698