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

Side by Side Diff: chrome/browser/ui/webui/downloads_ui_browsertest_base.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 2014 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 /** @const */ var TOTAL_RESULT_COUNT = 25;
6
7 /**
8 * Test C++ fixture for downloads WebUI testing.
9 * @constructor
10 * @extends {testing.Test}
11 */
12 function DownloadsUIBrowserTest() {}
13
14 /**
15 * Base fixture for Downloads WebUI testing.
16 * @extends {testing.Test}
17 * @constructor
18 */
19 function BaseDownloadsWebUITest() {}
20
21 BaseDownloadsWebUITest.prototype = {
22 __proto__: testing.Test.prototype,
23
24 /**
25 * Browse to the downloads page & call our preLoad().
26 */
27 browsePreload: 'chrome://downloads/',
28
29 /** @override */
30 typedefCppFixture: 'DownloadsUIBrowserTest',
31
32 /** @override */
33 testGenPreamble: function() {
34 GEN(' SetDeleteAllowed(true);');
35 },
36
37 /** @override */
38 runAccessibilityChecks: true,
39
40 /** @override */
41 accessibilityIssuesAreErrors: true,
42
43 /**
44 * Sends TOTAL_RESULT_COUNT fake downloads to the page. This can't be called
45 * in the preLoad, because it requires the global Download object to have
46 * been created by the page.
47 * @override
48 */
49 setUp: function() {
50 testing.Test.prototype.setUp.call(this);
51
52 this.createdDownloads = [];
53
54 // The entries will begin at 1:00 AM on Sept 2, 2008, and will be spaced
55 // two minutes apart.
56 var timestamp = new Date(2008, 9, 2, 1, 0).getTime();
57 for (var i = 0; i < TOTAL_RESULT_COUNT; ++i) {
58 this.createDownload(i, timestamp);
59 timestamp += 2 * 60 * 1000; // Next visit is two minutes later.
60 }
61 downloads.Manager.updateAll(this.createdDownloads);
62 expectEquals(downloads.Manager.size(), TOTAL_RESULT_COUNT);
63
64 this.updateAccessibilityAuditConfig();
65 },
66
67 /**
68 * Disables failing accessibility audits. This should be removed when all
69 * audit issues have been resolved.
70 */
71 updateAccessibilityAuditConfig: function() {
72 // Enable when failure is resolved.
73 // AX_TEXT_01: http://crbug.com/559217
74 this.accessibilityAuditConfig.ignoreSelectors(
75 'controlsWithoutLabel',
76 '#term');
77
78 // Enable when failure is resolved.
79 // AX_FOCUS_03: http://crbug.com/559219
80 this.accessibilityAuditConfig.ignoreSelectors(
81 'tabIndexGreaterThanZero',
82 '#term');
83 },
84
85 /**
86 * Creates a download object to be passed to the page, following the expected
87 * backend format (see downloads_dom_handler.cc).
88 * @param {number} id A unique ID for the download.
89 * @param {number} timestamp The time the download purportedly started.
90 * @return {!Object} A fake download object.
91 */
92 createDownload: function(id, timestamp) {
93 this.createdDownloads.unshift({
94 id: id,
95 started: timestamp,
96 otr: false,
97 state: downloads.States.COMPLETE,
98 retry: false,
99 file_path: '/path/to/file',
100 file_url: 'http://google.com/' + timestamp,
101 file_name: 'download_' + timestamp,
102 url: 'http://google.com/' + timestamp,
103 file_externally_removed: false,
104 danger_type: downloads.DangerType.NOT_DANGEROUS,
105 last_reason_text: '',
106 since_string: 'today',
107 date_string: 'today',
108 percent: 100,
109 progress_status_text: 'done',
110 received: 128,
111 });
112 return this.createdDownloads[0];
113 },
114
115 /**
116 * Creates a dangerous download object. See downloads_dom_handler.cc.
117 * @param {number} id The ID of the download.
118 * @param {number} timestamp The time this download started.
119 * @return {!Object} A fake, dangerous download object.
120 */
121 createDangerousDownload: function(id, timestamp) {
122 this.createdDownloads.unshift({
123 id: id,
124 started: timestamp,
125 otr: false,
126 state: downloads.States.DANGEROUS,
127 retry: false,
128 file_path: '/oh/noes.jpg.exe',
129 file_url: 'http://evil.com/cute/kittens' + timestamp,
130 file_name: 'evil.' + timestamp + '.jar',
131 file_url: 'http://evil.com/cute/kittens' + timestamp,
132 file_externally_removed: false,
133 danger_type: downloads.DangerType.DANGEROUS_FILE,
134 last_reason_text: '',
135 since_string: 'today',
136 date_string: 'today',
137 percent: 0,
138 progress_status_text: '',
139 received: 128,
140 });
141 return this.createdDownloads[0];
142 },
143
144 /**
145 * Simulates getting no results from C++.
146 */
147 sendEmptyList: function() {
148 downloads.Manager.updateAll([]);
149 assertEquals(0, downloads.Manager.size());
150 },
151
152 /**
153 * Check that |element| is showing and contains |text|.
154 * @param {Element} element
155 * @param {string} text
156 */
157 checkShowing: function(element, text) {
158 expectFalse(element.hidden);
159 expectNotEquals(-1, element.textContent.indexOf(text));
160 },
161
162 /**
163 * Asserts the correctness of the state of the UI elements that delete the
164 * download history.
165 * @param {boolean} visible True if download deletion UI should be visible.
166 */
167 expectDeleteControlsVisible: function(visible) {
168 // "Clear all" should only be showing when deletions are allowed.
169 expectEquals(!visible, $('clear-all').hidden);
170
171 // "Remove from list" links should only exist when deletions are allowed.
172 var query = '#downloads-display .safe .remove';
173 if (!visible)
174 query += '[hidden]';
175 expectEquals(TOTAL_RESULT_COUNT, document.querySelectorAll(query).length);
176 },
177 };
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/downloads_ui_browsertest.js ('k') | chrome/browser/ui/webui/downloads_ui_supervised_browsertest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698