| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** @const */ var TOTAL_RESULT_COUNT = 25; | 5 /** @const */ var TOTAL_RESULT_COUNT = 25; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Test C++ fixture for downloads WebUI testing. | 8 * Test C++ fixture for downloads WebUI testing. |
| 9 * @constructor | 9 * @constructor |
| 10 * @extends {testing.Test} | 10 * @extends {testing.Test} |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 * in the preLoad, because it requires the global Download object to have | 45 * in the preLoad, because it requires the global Download object to have |
| 46 * been created by the page. | 46 * been created by the page. |
| 47 * @override | 47 * @override |
| 48 */ | 48 */ |
| 49 setUp: function() { | 49 setUp: function() { |
| 50 // The entries will begin at 1:00 AM on Sept 2, 2008, and will be spaced | 50 // The entries will begin at 1:00 AM on Sept 2, 2008, and will be spaced |
| 51 // two minutes apart. | 51 // two minutes apart. |
| 52 var timestamp = new Date(2008, 9, 2, 1, 0).getTime(); | 52 var timestamp = new Date(2008, 9, 2, 1, 0).getTime(); |
| 53 var list = []; | 53 var list = []; |
| 54 for (var i = 0; i < TOTAL_RESULT_COUNT; ++i) { | 54 for (var i = 0; i < TOTAL_RESULT_COUNT; ++i) { |
| 55 list.push(this.createDownload_(i, timestamp)); | 55 list.push(this.createDownload(i, timestamp)); |
| 56 timestamp += 2 * 60 * 1000; // Next visit is two minutes later. | 56 timestamp += 2 * 60 * 1000; // Next visit is two minutes later. |
| 57 } | 57 } |
| 58 downloads.Manager.updateAll(list); | 58 downloads.Manager.updateAll(list); |
| 59 expectEquals(downloads.Manager.size(), TOTAL_RESULT_COUNT); | 59 expectEquals(downloads.Manager.size(), TOTAL_RESULT_COUNT); |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * Creates a download object to be passed to the page, following the expected | 63 * Creates a download object to be passed to the page, following the expected |
| 64 * backend format (see downloads_dom_handler.cc). | 64 * backend format (see downloads_dom_handler.cc). |
| 65 * @param {number} A unique ID for the download. | 65 * @param {number} A unique ID for the download. |
| 66 * @param {number} The time the download purportedly started. | 66 * @param {number} The time the download purportedly started. |
| 67 * @return {!Object} A fake download object. | 67 * @return {!Object} A fake download object. |
| 68 * @private | |
| 69 */ | 68 */ |
| 70 createDownload_: function(id, timestamp) { | 69 createDownload: function(id, timestamp) { |
| 71 return { | 70 return { |
| 72 id: id, | 71 id: id, |
| 73 started: timestamp, | 72 started: timestamp, |
| 74 otr: false, | 73 otr: false, |
| 75 state: downloads.Item.States.COMPLETE, | 74 state: downloads.Item.States.COMPLETE, |
| 76 retry: false, | 75 retry: false, |
| 77 file_path: '/path/to/file', | 76 file_path: '/path/to/file', |
| 78 file_url: 'http://google.com/' + timestamp, | 77 file_url: 'http://google.com/' + timestamp, |
| 79 file_name: 'download_' + timestamp, | 78 file_name: 'download_' + timestamp, |
| 80 url: 'http://google.com/' + timestamp, | 79 url: 'http://google.com/' + timestamp, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // "Clear all" should only be showing when deletions are allowed. | 115 // "Clear all" should only be showing when deletions are allowed. |
| 117 expectEquals(!visible, $('clear-all').hidden); | 116 expectEquals(!visible, $('clear-all').hidden); |
| 118 | 117 |
| 119 // "Remove from list" links should only exist when deletions are allowed. | 118 // "Remove from list" links should only exist when deletions are allowed. |
| 120 var query = '#downloads-display .safe .remove'; | 119 var query = '#downloads-display .safe .remove'; |
| 121 if (!visible) | 120 if (!visible) |
| 122 query += '[hidden]'; | 121 query += '[hidden]'; |
| 123 expectEquals(TOTAL_RESULT_COUNT, document.querySelectorAll(query).length); | 122 expectEquals(TOTAL_RESULT_COUNT, document.querySelectorAll(query).length); |
| 124 }, | 123 }, |
| 125 }; | 124 }; |
| OLD | NEW |