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

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

Issue 1018543005: downloads: fix Resume/Pause focus regression. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests Created 5 years, 9 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
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();
14 }); 13 });
15 14
16 TEST_F('BaseDownloadsWebUITest', 'NoResultsHiddenWhenDownloads', function() { 15 TEST_F('BaseDownloadsWebUITest', 'NoResultsHiddenWhenDownloads', function() {
17 assertNotEquals(0, downloads.Manager.size()); 16 assertNotEquals(0, downloads.Manager.size());
18 expectFalse($('downloads-display').hidden); 17 expectFalse($('downloads-display').hidden);
19 expectTrue($('no-downloads-or-results').hidden); 18 expectTrue($('no-downloads-or-results').hidden);
20 }); 19 });
21 20
22 TEST_F('BaseDownloadsWebUITest', 'NoSearchResultsShown', function() { 21 TEST_F('BaseDownloadsWebUITest', 'NoSearchResultsShown', function() {
23 expectFalse($('downloads-display').hidden); 22 expectFalse($('downloads-display').hidden);
(...skipping 12 matching lines...) Expand all
36 var noResults = $('no-downloads-or-results'); 35 var noResults = $('no-downloads-or-results');
37 expectTrue(noResults.hidden); 36 expectTrue(noResults.hidden);
38 37
39 $('clear-all').click(); 38 $('clear-all').click();
40 this.sendEmptyList(); 39 this.sendEmptyList();
41 40
42 expectTrue($('downloads-display').hidden); 41 expectTrue($('downloads-display').hidden);
43 this.checkShowing(noResults, loadTimeData.getString('no_downloads')); 42 this.checkShowing(noResults, loadTimeData.getString('no_downloads'));
44 }); 43 });
45 44
45 TEST_F('BaseDownloadsWebUITest', 'PauseResumeFocus', function() {
46 var manager = downloads.Manager.getInstance();
47 assertGE(manager.size(), 0);
48
49 var lastId = manager.items_.slice(-1)[0].view.id_;
50 var freshData = this.createDownload(lastId, Date.now());
51 freshData.state = downloads.Item.States.IN_PROGRESS;
52 freshData.resume = false;
53 downloads.Manager.updateItem(freshData);
54
55 var node = manager.idMap_[lastId].view.node;
56 var pause = node.querySelector('.pause');
57 var resume = node.querySelector('.resume');
58
59 expectFalse(pause.hidden);
60 expectTrue(resume.hidden);
61 // Move the focus to "Pause" then pretend the download was resumed. The focus
62 // should move to the equivalent button ("Resume" in this case).
63 pause.focus();
64 assertEquals(document.activeElement, pause);
65
66 freshData.state = downloads.Item.States.PAUSED;
67 freshData.resume = true;
68 downloads.Manager.updateItem(freshData);
69
70 expectTrue(pause.hidden);
71 expectFalse(resume.hidden);
72 expectEquals(document.activeElement, resume);
73 });
74
46 /** 75 /**
47 * @constructor 76 * @constructor
48 * @extends {BaseDownloadsWebUITest} 77 * @extends {BaseDownloadsWebUITest}
49 */ 78 */
50 function EmptyDownloadsWebUITest() {} 79 function EmptyDownloadsWebUITest() {}
51 80
52 EmptyDownloadsWebUITest.prototype = { 81 EmptyDownloadsWebUITest.prototype = {
53 __proto__: BaseDownloadsWebUITest.prototype, 82 __proto__: BaseDownloadsWebUITest.prototype,
54 83
55 /** @override */ 84 /** @override */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 testGenPreamble: function() { 117 testGenPreamble: function() {
89 GEN(' SetDeleteAllowed(false);'); 118 GEN(' SetDeleteAllowed(false);');
90 }, 119 },
91 }; 120 };
92 121
93 // Test UI when removing entries is prohibited. 122 // Test UI when removing entries is prohibited.
94 TEST_F('DownloadsWebUIDeleteProhibitedTest', 'DeleteProhibited', function() { 123 TEST_F('DownloadsWebUIDeleteProhibitedTest', 'DeleteProhibited', function() {
95 this.expectDeleteControlsVisible(false); 124 this.expectDeleteControlsVisible(false);
96 // TODO(pamg): Mock out the back-end calls, so we can also test removing a 125 // TODO(pamg): Mock out the back-end calls, so we can also test removing a
97 // single item. 126 // single item.
98 testDone();
99 }); 127 });
100 128
101 TEST_F('DownloadsWebUIDeleteProhibitedTest', 'ClearLeavesSearch', function() { 129 TEST_F('DownloadsWebUIDeleteProhibitedTest', 'ClearLeavesSearch', function() {
102 downloads.Manager.setSearchText('muhahaha'); 130 downloads.Manager.setSearchText('muhahaha');
103 $('clear-all').click(); 131 $('clear-all').click();
104 expectGE(downloads.Manager.getInstance().searchText_.length, 0); 132 expectGE(downloads.Manager.getInstance().searchText_.length, 0);
105 }); 133 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/downloads/manager.js ('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