OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // downloads api test | 5 // downloads api test |
6 // browser_tests.exe --gtest_filter=DownloadsApiTest.Downloads | 6 // browser_tests.exe --gtest_filter=DownloadsApiTest.Downloads |
7 | 7 |
8 chrome.test.getConfig(function(testConfig) { | 8 chrome.test.getConfig(function(testConfig) { |
9 function getURL(path) { | 9 function getURL(path) { |
10 return "http://localhost:" + testConfig.testServer.port + "/" + path; | 10 return "http://localhost:" + testConfig.testServer.port + "/" + path; |
(...skipping 12 matching lines...) Expand all Loading... |
23 chrome.test.fail("Failed to throw exception (" + | 23 chrome.test.fail("Failed to throw exception (" + |
24 expected_message + ")"); | 24 expected_message + ")"); |
25 }); | 25 }); |
26 } catch (exception) { | 26 } catch (exception) { |
27 chrome.test.assertEq(expected_message, exception.message); | 27 chrome.test.assertEq(expected_message, exception.message); |
28 chrome.test.succeed(); | 28 chrome.test.succeed(); |
29 } | 29 } |
30 } | 30 } |
31 | 31 |
32 chrome.test.runTests([ | 32 chrome.test.runTests([ |
| 33 // TODO(benjhayden): Uncomment after 8060042. |
| 34 // function downloadOnChanged() { |
| 35 // function myListener(delta) { |
| 36 // if (delta.state && delta.state.new == 'complete') { |
| 37 // chrome.experimental.downloads.onChanged.removeListener(myListener); |
| 38 // chrome.test.succeed(); |
| 39 // } |
| 40 // } |
| 41 // chrome.experimental.downloads.onChanged.addListener(myListener); |
| 42 // chrome.experimental.downloads.download( |
| 43 // {"url": getURL("slow?0")}, |
| 44 // function(id) { |
| 45 // chrome.test.assertEq(getNextId(), id); |
| 46 // }); |
| 47 // }, |
33 function downloadFilename() { | 48 function downloadFilename() { |
34 chrome.experimental.downloads.download( | 49 chrome.experimental.downloads.download( |
35 {"url": getURL("pass"), "filename": "pass"}, | 50 {"url": getURL("pass"), "filename": "pass"}, |
36 chrome.test.callbackPass(function(id) { | 51 chrome.test.callbackPass(function(id) { |
37 chrome.test.assertEq(getNextId(), id); | 52 chrome.test.assertEq(getNextId(), id); |
38 })); | 53 })); |
39 // TODO(benjhayden): Test the filename using onChanged. | 54 // TODO(benjhayden): Test the filename using onChanged. |
40 }, | 55 }, |
41 function downloadSubDirectoryFilename() { | 56 function downloadSubDirectoryFilename() { |
42 chrome.experimental.downloads.download( | 57 chrome.experimental.downloads.download( |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 }, | 121 }, |
107 function downloadInvalidHeader() { | 122 function downloadInvalidHeader() { |
108 chrome.experimental.downloads.download( | 123 chrome.experimental.downloads.download( |
109 {"url": getURL("pass"), | 124 {"url": getURL("pass"), |
110 "headers": [{"name": "Cookie", "value": "fake"}]}, | 125 "headers": [{"name": "Cookie", "value": "fake"}]}, |
111 chrome.test.callbackFail("I'm afraid I can't do that.")); | 126 chrome.test.callbackFail("I'm afraid I can't do that.")); |
112 // TODO(benjhayden): Give a better error message. | 127 // TODO(benjhayden): Give a better error message. |
113 } | 128 } |
114 ]); | 129 ]); |
115 }); | 130 }); |
OLD | NEW |