| OLD | NEW |
| 1 // Copyright 2013 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 GEN('#include "chrome/browser/ui/webui/downloads_ui_browsertest.h"'); | |
| 6 | |
| 7 /** @const */ var TOTAL_RESULT_COUNT = 25; | 5 /** @const */ var TOTAL_RESULT_COUNT = 25; |
| 8 | 6 |
| 9 /** | 7 /** |
| 10 * Test C++ fixture for downloads WebUI testing. | 8 * Test C++ fixture for downloads WebUI testing. |
| 11 * @constructor | 9 * @constructor |
| 12 * @extends {testing.Test} | 10 * @extends {testing.Test} |
| 13 */ | 11 */ |
| 14 function DownloadsUIBrowserTest() {} | 12 function DownloadsUIBrowserTest() {} |
| 15 | 13 |
| 16 /** | 14 /** |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } else { | 125 } else { |
| 128 expectEquals(expectControlsHidden, disabledElements[0].hidden); | 126 expectEquals(expectControlsHidden, disabledElements[0].hidden); |
| 129 } | 127 } |
| 130 | 128 |
| 131 // The model is updated synchronously, even though the actual | 129 // The model is updated synchronously, even though the actual |
| 132 // back-end removal (tested elsewhere) is asynchronous. | 130 // back-end removal (tested elsewhere) is asynchronous. |
| 133 clearAll(); | 131 clearAll(); |
| 134 expectEquals(allowDelete ? 0 : TOTAL_RESULT_COUNT, downloads.size()); | 132 expectEquals(allowDelete ? 0 : TOTAL_RESULT_COUNT, downloads.size()); |
| 135 }, | 133 }, |
| 136 }; | 134 }; |
| 137 | |
| 138 // Test UI when removing entries is allowed. | |
| 139 TEST_F('BaseDownloadsWebUITest', 'DeleteAllowed', function() { | |
| 140 this.testHelper(true, false); | |
| 141 // TODO(pamg): Mock out the back-end calls, so we can also test removing a | |
| 142 // single item. | |
| 143 testDone(); | |
| 144 }); | |
| 145 | |
| 146 // Test that clicking <a href=#> doesn't actually go to #. | |
| 147 TEST_F('BaseDownloadsWebUITest', 'PoundLinkClicksDontChangeUrl', function() { | |
| 148 assertEquals(this.browsePreload, document.location.href); | |
| 149 document.querySelector('.clear-all-link').click(); | |
| 150 assertEquals(this.browsePreload, document.location.href); | |
| 151 testDone(); | |
| 152 }); | |
| 153 | |
| 154 /** | |
| 155 * Fixture for Downloads WebUI testing when deletions are prohibited. | |
| 156 * @extends {BaseDownloadsWebUITest} | |
| 157 * @constructor | |
| 158 */ | |
| 159 function DownloadsWebUIDeleteProhibitedTest() {} | |
| 160 | |
| 161 DownloadsWebUIDeleteProhibitedTest.prototype = { | |
| 162 __proto__: BaseDownloadsWebUITest.prototype, | |
| 163 | |
| 164 /** @override */ | |
| 165 testGenPreamble: function() { | |
| 166 GEN(' SetDeleteAllowed(false);'); | |
| 167 }, | |
| 168 }; | |
| 169 | |
| 170 // Test UI when removing entries is prohibited. | |
| 171 TEST_F('DownloadsWebUIDeleteProhibitedTest', 'DeleteProhibited', function() { | |
| 172 this.testHelper(false, false); | |
| 173 // TODO(pamg): Mock out the back-end calls, so we can also test removing a | |
| 174 // single item. | |
| 175 testDone(); | |
| 176 }); | |
| 177 | |
| 178 /** | |
| 179 * Fixture for Downloads WebUI testing for a supervised user. | |
| 180 * @extends {BaseDownloadsWebUITest} | |
| 181 * @constructor | |
| 182 */ | |
| 183 function DownloadsWebUIForSupervisedUsersTest() {} | |
| 184 | |
| 185 DownloadsWebUIForSupervisedUsersTest.prototype = { | |
| 186 __proto__: BaseDownloadsWebUITest.prototype, | |
| 187 | |
| 188 /** @override */ | |
| 189 typedefCppFixture: 'DownloadsWebUIForSupervisedUsersTest', | |
| 190 }; | |
| 191 | |
| 192 // Test UI for supervised users, removing entries should be disabled | |
| 193 // and removal controls should be hidden. | |
| 194 TEST_F('DownloadsWebUIForSupervisedUsersTest', 'SupervisedUsers', function() { | |
| 195 this.testHelper(false, true); | |
| 196 testDone(); | |
| 197 }); | |
| OLD | NEW |