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(['downloads_ui_browsertest_base.js']); | 5 GEN_INCLUDE(['downloads_ui_browsertest_base.js']); |
6 GEN('#include "chrome/browser/ui/webui/downloads_ui_browsertest.h"'); | 6 GEN('#include "chrome/browser/ui/webui/downloads_ui_browsertest.h"'); |
7 | 7 |
8 // Test UI when removing entries is allowed. | 8 // Test UI when removing entries is allowed. |
9 TEST_F('BaseDownloadsWebUITest', 'DeleteAllowed', function() { | 9 TEST_F('BaseDownloadsWebUITest', 'DeleteAllowed', function() { |
10 this.expectDeleteControlsVisible(true); | 10 this.expectDeleteControlsVisible(true); |
11 // TODO(pamg): Mock out the back-end calls, so we can also test removing a | 11 // TODO(pamg): Mock out the back-end calls, so we can also test removing a |
12 // single item. | 12 // single item. |
13 testDone(); | 13 testDone(); |
14 }); | 14 }); |
15 | 15 |
16 TEST_F('BaseDownloadsWebUITest', 'NoResultsHiddenWhenDownloads', function() { | 16 TEST_F('BaseDownloadsWebUITest', 'NoResultsHiddenWhenDownloads', function() { |
17 assertNotEquals(0, downloads.size()); | 17 assertNotEquals(0, downloads.Manager.size()); |
18 expectFalse($('downloads-display').hidden); | 18 expectFalse($('downloads-display').hidden); |
19 expectTrue($('no-downloads-or-results').hidden); | 19 expectTrue($('no-downloads-or-results').hidden); |
20 }); | 20 }); |
21 | 21 |
22 TEST_F('BaseDownloadsWebUITest', 'NoSearchResultsShown', function() { | 22 TEST_F('BaseDownloadsWebUITest', 'NoSearchResultsShown', function() { |
23 expectFalse($('downloads-display').hidden); | 23 expectFalse($('downloads-display').hidden); |
24 var noResults = $('no-downloads-or-results'); | 24 var noResults = $('no-downloads-or-results'); |
25 expectTrue(noResults.hidden); | 25 expectTrue(noResults.hidden); |
26 | 26 |
27 setSearch('just try to search for me!'); | 27 downloads.Manager.setSearchText('just try to search for me!'); |
28 this.sendEmptyList(); | 28 this.sendEmptyList(); |
29 | 29 |
30 expectTrue($('downloads-display').hidden); | 30 expectTrue($('downloads-display').hidden); |
31 this.checkShowing(noResults, loadTimeData.getString('no_search_results')); | 31 this.checkShowing(noResults, loadTimeData.getString('no_search_results')); |
32 }); | 32 }); |
33 | 33 |
34 TEST_F('BaseDownloadsWebUITest', 'NoDownloadsAfterClearAll', function() { | 34 TEST_F('BaseDownloadsWebUITest', 'NoDownloadsAfterClearAll', function() { |
35 expectFalse($('downloads-display').hidden); | 35 expectFalse($('downloads-display').hidden); |
36 var noResults = $('no-downloads-or-results'); | 36 var noResults = $('no-downloads-or-results'); |
37 expectTrue(noResults.hidden); | 37 expectTrue(noResults.hidden); |
38 | 38 |
39 clearAll(); | 39 $('clear-all').click(); |
40 this.sendEmptyList(); | 40 this.sendEmptyList(); |
41 | 41 |
42 expectTrue($('downloads-display').hidden); | 42 expectTrue($('downloads-display').hidden); |
43 this.checkShowing(noResults, loadTimeData.getString('no_downloads')); | 43 this.checkShowing(noResults, loadTimeData.getString('no_downloads')); |
44 }); | 44 }); |
45 | 45 |
46 /** | 46 /** |
47 * @constructor | 47 * @constructor |
48 * @extends {BaseDownloadsWebUITest} | 48 * @extends {BaseDownloadsWebUITest} |
49 */ | 49 */ |
50 function EmptyDownloadsWebUITest() {} | 50 function EmptyDownloadsWebUITest() {} |
51 | 51 |
52 EmptyDownloadsWebUITest.prototype = { | 52 EmptyDownloadsWebUITest.prototype = { |
53 __proto__: BaseDownloadsWebUITest.prototype, | 53 __proto__: BaseDownloadsWebUITest.prototype, |
54 | 54 |
55 /** @override */ | 55 /** @override */ |
56 setUp: function() { | 56 setUp: function() { |
57 // Doesn't create any fake downloads. | 57 // Doesn't create any fake downloads. |
58 assertEquals(0, downloads.size()); | 58 assertEquals(0, downloads.Manager.size()); |
59 }, | 59 }, |
60 }; | 60 }; |
61 | 61 |
62 TEST_F('EmptyDownloadsWebUITest', 'NoDownloadsMessageShowing', function() { | 62 TEST_F('EmptyDownloadsWebUITest', 'NoDownloadsMessageShowing', function() { |
63 expectTrue($('downloads-display').hidden); | 63 expectTrue($('downloads-display').hidden); |
64 var noResults = $('no-downloads-or-results'); | 64 var noResults = $('no-downloads-or-results'); |
65 this.checkShowing(noResults, loadTimeData.getString('no_downloads')); | 65 this.checkShowing(noResults, loadTimeData.getString('no_downloads')); |
66 }); | 66 }); |
67 | 67 |
68 TEST_F('EmptyDownloadsWebUITest', 'NoSearchResultsWithNoDownloads', function() { | 68 TEST_F('EmptyDownloadsWebUITest', 'NoSearchResultsWithNoDownloads', function() { |
69 setSearch('bananas'); | 69 downloads.Manager.setSearchText('bananas'); |
70 this.sendEmptyList(); | 70 this.sendEmptyList(); |
71 | 71 |
72 expectTrue($('downloads-display').hidden); | 72 expectTrue($('downloads-display').hidden); |
73 var noResults = $('no-downloads-or-results'); | 73 var noResults = $('no-downloads-or-results'); |
74 this.checkShowing(noResults, loadTimeData.getString('no_search_results')); | 74 this.checkShowing(noResults, loadTimeData.getString('no_search_results')); |
75 }); | 75 }); |
76 | 76 |
77 /** | 77 /** |
78 * Fixture for Downloads WebUI testing when deletions are prohibited. | 78 * Fixture for Downloads WebUI testing when deletions are prohibited. |
79 * @extends {BaseDownloadsWebUITest} | 79 * @extends {BaseDownloadsWebUITest} |
(...skipping 10 matching lines...) Expand all Loading... |
90 }, | 90 }, |
91 }; | 91 }; |
92 | 92 |
93 // Test UI when removing entries is prohibited. | 93 // Test UI when removing entries is prohibited. |
94 TEST_F('DownloadsWebUIDeleteProhibitedTest', 'DeleteProhibited', function() { | 94 TEST_F('DownloadsWebUIDeleteProhibitedTest', 'DeleteProhibited', function() { |
95 this.expectDeleteControlsVisible(false); | 95 this.expectDeleteControlsVisible(false); |
96 // TODO(pamg): Mock out the back-end calls, so we can also test removing a | 96 // TODO(pamg): Mock out the back-end calls, so we can also test removing a |
97 // single item. | 97 // single item. |
98 testDone(); | 98 testDone(); |
99 }); | 99 }); |
| 100 |
| 101 TEST_F('DownloadsWebUIDeleteProhibitedTest', 'ClearLeavesSearch', function() { |
| 102 downloads.Manager.setSearchText('muhahaha'); |
| 103 $('clear-all').click(); |
| 104 expectGE(downloads.Manager.getInstance().searchText_.length, 0); |
| 105 }); |
OLD | NEW |