Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: chrome/browser/ui/webui/downloads_ui_browsertest.js

Issue 1710083005: Remove old downloads UI; Material Design version is now the default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove testing/ Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 GEN_INCLUDE(['downloads_ui_browsertest_base.js']);
6 GEN('#include "chrome/browser/ui/webui/downloads_ui_browsertest.h"');
7
8 // Test UI when removing entries is allowed.
9 TEST_F('BaseDownloadsWebUITest', 'DeleteAllowed', function() {
10 this.expectDeleteControlsVisible(true);
11 // TODO(pamg): Mock out the back-end calls, so we can also test removing a
12 // single item.
13 });
14
15 TEST_F('BaseDownloadsWebUITest', 'NoResultsHiddenWhenDownloads', function() {
16 assertNotEquals(0, downloads.Manager.size());
17 expectFalse($('downloads-display').hidden);
18 expectTrue($('no-downloads-or-results').hidden);
19 });
20
21 TEST_F('BaseDownloadsWebUITest', 'NoSearchResultsShown', function() {
22 expectFalse($('downloads-display').hidden);
23 var noResults = $('no-downloads-or-results');
24 expectTrue(noResults.hidden);
25
26 downloads.Manager.setSearchText('just try to search for me!');
27 this.sendEmptyList();
28
29 expectTrue($('downloads-display').hidden);
30 this.checkShowing(noResults, loadTimeData.getString('noSearchResults'));
31 });
32
33 TEST_F('BaseDownloadsWebUITest', 'NoDownloadsAfterClearAll', function() {
34 expectFalse($('downloads-display').hidden);
35 var noResults = $('no-downloads-or-results');
36 expectTrue(noResults.hidden);
37
38 $('clear-all').click();
39 this.sendEmptyList();
40
41 expectTrue($('downloads-display').hidden);
42 this.checkShowing(noResults, loadTimeData.getString('noDownloads'));
43 });
44
45 TEST_F('BaseDownloadsWebUITest', 'PauseResumeFocus', function() {
46 assertGE(downloads.Manager.size(), 0);
47
48 var freshestDownload = this.createdDownloads[0];
49 freshestDownload.state = downloads.States.IN_PROGRESS;
50 freshestDownload.resume = false;
51 downloads.Manager.updateItem(freshestDownload);
52
53 var manager = downloads.Manager.getInstance();
54 var node = manager.idMap_[freshestDownload.id].node;
55 var pause = node.querySelector('.pause');
56 var resume = node.querySelector('.resume');
57
58 expectFalse(pause.hidden);
59 expectTrue(resume.hidden);
60 // Move the focus to "Pause" then pretend the download was resumed. The focus
61 // should move to the equivalent button ("Resume" in this case).
62 pause.focus();
63 assertEquals(document.activeElement, pause);
64
65 freshestDownload.state = downloads.States.PAUSED;
66 freshestDownload.resume = true;
67 downloads.Manager.updateItem(freshestDownload);
68
69 expectTrue(pause.hidden);
70 expectFalse(resume.hidden);
71 expectEquals(document.activeElement, resume);
72 });
73
74 TEST_F('BaseDownloadsWebUITest', 'DatesCollapse', function() {
75 function datesShowing() {
76 var displayDiv = $('downloads-display');
77 return displayDiv.querySelectorAll('.date-container:not([hidden])').length;
78 }
79
80 var numDownloads = downloads.Manager.size();
81 assertGE(numDownloads, 2);
82
83 expectEquals(1, datesShowing());
84
85 var freshestId = this.createdDownloads[0].id;
86 this.createDangerousDownload(freshestId + 1, Date.now());
87 downloads.Manager.updateAll(this.createdDownloads);
88
89 expectEquals(numDownloads + 1, downloads.Manager.size());
90 expectEquals(1, datesShowing());
91
92 var firstContainer = document.querySelector('.date-container');
93 assertFalse(firstContainer.hidden);
94 expectGT(firstContainer.querySelector('.since').textContent.trim().length, 0);
95 expectGT(firstContainer.querySelector('.date').textContent.trim().length, 0);
96 });
97
98 TEST_F('BaseDownloadsWebUITest', 'EmptyProgressStatusText', function() {
99 this.createdDownloads[0].state = downloads.States.PAUSED;
100 this.createdDownloads[0].progress_status_text = '';
101 downloads.Manager.updateItem(this.createdDownloads[0]); // Might assert().
102 });
103
104 TEST_F('BaseDownloadsWebUITest', 'EmptyLastStatusText', function() {
105 this.createdDownloads[0].state = downloads.States.INTERRUPTED;
106 this.createdDownloads[0].last_reason_text = '';
107 downloads.Manager.updateItem(this.createdDownloads[0]); // Might assert().
108 });
109
110 /**
111 * @constructor
112 * @extends {BaseDownloadsWebUITest}
113 */
114 function EmptyDownloadsWebUITest() {}
115
116 EmptyDownloadsWebUITest.prototype = {
117 __proto__: BaseDownloadsWebUITest.prototype,
118
119 /** @override */
120 setUp: function() {
121 // Doesn't create any fake downloads.
122 assertEquals(0, downloads.Manager.size());
123
124 this.updateAccessibilityAuditConfig();
125 },
126 };
127
128 TEST_F('EmptyDownloadsWebUITest', 'NoDownloadsMessageShowing', function() {
129 expectTrue($('downloads-display').hidden);
130 var noResults = $('no-downloads-or-results');
131 this.checkShowing(noResults, loadTimeData.getString('noDownloads'));
132 });
133
134 TEST_F('EmptyDownloadsWebUITest', 'NoSearchResultsWithNoDownloads', function() {
135 downloads.Manager.setSearchText('bananas');
136 this.sendEmptyList();
137
138 expectTrue($('downloads-display').hidden);
139 var noResults = $('no-downloads-or-results');
140 this.checkShowing(noResults, loadTimeData.getString('noSearchResults'));
141 });
142
143 /**
144 * Fixture for Downloads WebUI testing when deletions are prohibited.
145 * @extends {BaseDownloadsWebUITest}
146 * @constructor
147 */
148 function DownloadsWebUIDeleteProhibitedTest() {}
149
150 DownloadsWebUIDeleteProhibitedTest.prototype = {
151 __proto__: BaseDownloadsWebUITest.prototype,
152
153 /** @override */
154 testGenPreamble: function() {
155 GEN(' SetDeleteAllowed(false);');
156 },
157 };
158
159 // Test UI when removing entries is prohibited.
160 TEST_F('DownloadsWebUIDeleteProhibitedTest', 'DeleteProhibited', function() {
161 this.expectDeleteControlsVisible(false);
162 // TODO(pamg): Mock out the back-end calls, so we can also test removing a
163 // single item.
164 });
165
166 TEST_F('DownloadsWebUIDeleteProhibitedTest', 'ClearLeavesSearch', function() {
167 downloads.Manager.setSearchText('muhahaha');
168 $('clear-all').click();
169 expectGE(downloads.Manager.getInstance().searchText_.length, 0);
170 });
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/downloads_ui_browsertest.cc ('k') | chrome/browser/ui/webui/downloads_ui_browsertest_base.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698