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 // Disable everything on windows only. http://crbug.com/306144 | 5 // Disable everything on windows only. http://crbug.com/306144 |
6 #ifndef OS_WIN | 6 #ifndef OS_WIN |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 if (!WaitFor(api::OnCreated::kEventName, on_created_event)) | 359 if (!WaitFor(api::OnCreated::kEventName, on_created_event)) |
360 return false; | 360 return false; |
361 // Now, onCreated is always fired before interruption. | 361 // Now, onCreated is always fired before interruption. |
362 return WaitFor(api::OnChanged::kEventName, | 362 return WaitFor(api::OnChanged::kEventName, |
363 base::StringPrintf("[{\"id\": %d," | 363 base::StringPrintf("[{\"id\": %d," |
364 " \"error\": {\"current\": \"%s\"}," | 364 " \"error\": {\"current\": \"%s\"}," |
365 " \"state\": {" | 365 " \"state\": {" |
366 " \"previous\": \"in_progress\"," | 366 " \"previous\": \"in_progress\"," |
367 " \"current\": \"interrupted\"}}]", | 367 " \"current\": \"interrupted\"}}]", |
368 item->GetId(), | 368 item->GetId(), |
369 content::InterruptReasonDebugString( | 369 content::DownloadInterruptReasonToString( |
370 expected_error).c_str())); | 370 expected_error).c_str())); |
371 } | 371 } |
372 | 372 |
373 void ClearEvents() { | 373 void ClearEvents() { |
374 events_listener_->ClearEvents(); | 374 events_listener_->ClearEvents(); |
375 } | 375 } |
376 | 376 |
377 std::string GetExtensionURL() { | 377 std::string GetExtensionURL() { |
378 return extension_->url().spec(); | 378 return extension_->url().spec(); |
379 } | 379 } |
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 }; | 1672 }; |
1673 | 1673 |
1674 for (size_t index = 0; index < arraysize(kInvalidURLs); ++index) { | 1674 for (size_t index = 0; index < arraysize(kInvalidURLs); ++index) { |
1675 EXPECT_STREQ(errors::kInvalidURL, | 1675 EXPECT_STREQ(errors::kInvalidURL, |
1676 RunFunctionAndReturnError(new DownloadsDownloadFunction(), | 1676 RunFunctionAndReturnError(new DownloadsDownloadFunction(), |
1677 base::StringPrintf( | 1677 base::StringPrintf( |
1678 "[{\"url\": \"%s\"}]", kInvalidURLs[index])).c_str()) | 1678 "[{\"url\": \"%s\"}]", kInvalidURLs[index])).c_str()) |
1679 << kInvalidURLs[index]; | 1679 << kInvalidURLs[index]; |
1680 } | 1680 } |
1681 | 1681 |
1682 EXPECT_STREQ("net::ERR_ACCESS_DENIED", RunFunctionAndReturnError( | 1682 EXPECT_STREQ("NETWORK_INVALID_REQUEST", RunFunctionAndReturnError( |
1683 new DownloadsDownloadFunction(), | 1683 new DownloadsDownloadFunction(), |
1684 "[{\"url\": \"javascript:document.write(\\\"hello\\\");\"}]").c_str()); | 1684 "[{\"url\": \"javascript:document.write(\\\"hello\\\");\"}]").c_str()); |
1685 EXPECT_STREQ("net::ERR_ACCESS_DENIED", RunFunctionAndReturnError( | 1685 EXPECT_STREQ("NETWORK_INVALID_REQUEST", RunFunctionAndReturnError( |
1686 new DownloadsDownloadFunction(), | 1686 new DownloadsDownloadFunction(), |
1687 "[{\"url\": \"javascript:return false;\"}]").c_str()); | 1687 "[{\"url\": \"javascript:return false;\"}]").c_str()); |
1688 EXPECT_STREQ("net::ERR_NOT_IMPLEMENTED", RunFunctionAndReturnError( | 1688 EXPECT_STREQ("NETWORK_FAILED", RunFunctionAndReturnError( |
1689 new DownloadsDownloadFunction(), | 1689 new DownloadsDownloadFunction(), |
1690 "[{\"url\": \"ftp://example.com/example.txt\"}]").c_str()); | 1690 "[{\"url\": \"ftp://example.com/example.txt\"}]").c_str()); |
1691 } | 1691 } |
1692 | 1692 |
1693 // TODO(benjhayden): Set up a test ftp server, add ftp://localhost* to | 1693 // TODO(benjhayden): Set up a test ftp server, add ftp://localhost* to |
1694 // permissions, test downloading from ftp. | 1694 // permissions, test downloading from ftp. |
1695 | 1695 |
1696 // Valid URLs plus fragments are still valid URLs. | 1696 // Valid URLs plus fragments are still valid URLs. |
1697 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 1697 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
1698 DownloadExtensionTest_Download_URLFragment) { | 1698 DownloadExtensionTest_Download_URLFragment) { |
(...skipping 1932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3631 EXPECT_EQ("suggester", winner_id); | 3631 EXPECT_EQ("suggester", winner_id); |
3632 EXPECT_EQ(FILE_PATH_LITERAL("b"), filename.value()); | 3632 EXPECT_EQ(FILE_PATH_LITERAL("b"), filename.value()); |
3633 EXPECT_EQ(api::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); | 3633 EXPECT_EQ(api::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); |
3634 EXPECT_FALSE(warnings.empty()); | 3634 EXPECT_FALSE(warnings.empty()); |
3635 EXPECT_EQ(extensions::ExtensionWarning::kDownloadFilenameConflict, | 3635 EXPECT_EQ(extensions::ExtensionWarning::kDownloadFilenameConflict, |
3636 warnings.begin()->warning_type()); | 3636 warnings.begin()->warning_type()); |
3637 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); | 3637 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); |
3638 } | 3638 } |
3639 | 3639 |
3640 #endif // http://crbug.com/3061144 | 3640 #endif // http://crbug.com/3061144 |
OLD | NEW |