| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 GEN('#include "chrome/browser/ui/webui/downloads_ui_browsertest.h"'); | 5 GEN('#include "chrome/browser/ui/webui/downloads_ui_browsertest.h"'); |
| 6 | 6 |
| 7 /** @const */ var TOTAL_RESULT_COUNT = 25; | 7 /** @const */ var TOTAL_RESULT_COUNT = 25; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Test C++ fixture for downloads WebUI testing. | 10 * Test C++ fixture for downloads WebUI testing. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 for (var i = 0; i < TOTAL_RESULT_COUNT; ++i) { | 49 for (var i = 0; i < TOTAL_RESULT_COUNT; ++i) { |
| 50 downloads.updated(this.createDownload_(i, timestamp)); | 50 downloads.updated(this.createDownload_(i, timestamp)); |
| 51 timestamp += 2 * 60 * 1000; // Next visit is two minutes later. | 51 timestamp += 2 * 60 * 1000; // Next visit is two minutes later. |
| 52 } | 52 } |
| 53 expectEquals(downloads.size(), TOTAL_RESULT_COUNT); | 53 expectEquals(downloads.size(), TOTAL_RESULT_COUNT); |
| 54 }, | 54 }, |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Creates a download object to be passed to the page, following the expected | 57 * Creates a download object to be passed to the page, following the expected |
| 58 * backend format (see downloads_dom_handler.cc). | 58 * backend format (see downloads_dom_handler.cc). |
| 59 * @param {Number} A unique ID for the download. | 59 * @param {number} A unique ID for the download. |
| 60 * @param {Number} The time the download purportedly started. | 60 * @param {number} The time the download purportedly started. |
| 61 * @return {!Object} A fake download object. |
| 62 * @private |
| 61 */ | 63 */ |
| 62 createDownload_: function(id, timestamp) { | 64 createDownload_: function(id, timestamp) { |
| 63 var download = {}; | 65 return { |
| 64 download.id = id; | 66 id: id, |
| 65 download.started = timestamp; | 67 started: timestamp, |
| 66 download.otr = false; | 68 otr: false, |
| 67 download.state = Download.States.COMPLETE; | 69 state: Download.States.COMPLETE, |
| 68 download.retry = false; | 70 retry: false, |
| 69 download.file_path = '/path/to/file'; | 71 file_path: '/path/to/file', |
| 70 download.file_url = 'http://google.com/' + timestamp; | 72 file_url: 'http://google.com/' + timestamp, |
| 71 download.file_name = 'download_' + timestamp; | 73 file_name: 'download_' + timestamp, |
| 72 download.url = 'http://google.com/' + timestamp; | 74 url: 'http://google.com/' + timestamp, |
| 73 download.file_externally_removed = false; | 75 file_externally_removed: false, |
| 74 download.danger_type = Download.DangerType.NOT_DANGEROUS; | 76 danger_type: Download.DangerType.NOT_DANGEROUS, |
| 75 download.last_reason_text = ''; | 77 last_reason_text: '', |
| 76 download.since_string = 'today'; | 78 since_string: 'today', |
| 77 download.date_string = 'today'; | 79 date_string: 'today', |
| 78 download.percent = 100; | 80 percent: 100, |
| 79 download.progress_status_text = 'done'; | 81 progress_status_text: 'done', |
| 80 download.received = 128; | 82 received: 128, |
| 81 | 83 }; |
| 82 return download; | |
| 83 }, | 84 }, |
| 84 | 85 |
| 85 /** | 86 /** |
| 86 * Asserts the correctness of the state of the UI elements | 87 * Asserts the correctness of the state of the UI elements |
| 87 * that delete the download history. | 88 * that delete the download history. |
| 88 * @param {boolean} allowDelete True if download history deletion is | 89 * @param {boolean} allowDelete True if download history deletion is |
| 89 * allowed and false otherwise. | 90 * allowed and false otherwise. |
| 90 * @param {boolean} expectControlsHidden True if the controls to delete | 91 * @param {boolean} expectControlsHidden True if the controls to delete |
| 91 * download history are expected to be hidden and false otherwise. | 92 * download history are expected to be hidden and false otherwise. |
| 92 */ | 93 */ |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 /** @override */ | 174 /** @override */ |
| 174 typedefCppFixture: 'DownloadsWebUIForSupervisedUsersTest', | 175 typedefCppFixture: 'DownloadsWebUIForSupervisedUsersTest', |
| 175 }; | 176 }; |
| 176 | 177 |
| 177 // Test UI for supervised users, removing entries should be disabled | 178 // Test UI for supervised users, removing entries should be disabled |
| 178 // and removal controls should be hidden. | 179 // and removal controls should be hidden. |
| 179 TEST_F('DownloadsWebUIForSupervisedUsersTest', 'SupervisedUsers', function() { | 180 TEST_F('DownloadsWebUIForSupervisedUsersTest', 'SupervisedUsers', function() { |
| 180 this.testHelper(false, true); | 181 this.testHelper(false, true); |
| 181 testDone(); | 182 testDone(); |
| 182 }); | 183 }); |
| OLD | NEW |