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

Side by Side Diff: chrome/test/data/webui/md_history/history_item_test.js

Issue 2503983002: MD History: Focus item checkbox when selecting/deselecting on click (Closed)
Patch Set: Add a test Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/resources/md_history/history_item.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 cr.define('md_history.history_item_test', function() { 5 cr.define('md_history.history_item_test', function() {
6 function registerTests() { 6 function registerTests() {
7 suite('history-item', function() { 7 var TEST_HISTORY_RESULTS = [
8 createHistoryEntry('2016-03-16 10:00', 'http://www.google.com'),
9 createHistoryEntry('2016-03-16 9:00', 'http://www.example.com'),
10 createHistoryEntry('2016-03-16 7:01', 'http://www.badssl.com'),
11 createHistoryEntry('2016-03-16 7:00', 'http://www.website.com'),
12 createHistoryEntry('2016-03-16 4:00', 'http://www.website.com'),
13 createHistoryEntry('2016-03-15 11:00', 'http://www.example.com'),
14 ];
15
16 var SEARCH_HISTORY_RESULTS = [
17 createSearchEntry('2016-03-16', "http://www.google.com"),
18 createSearchEntry('2016-03-14 11:00', "http://calendar.google.com"),
19 createSearchEntry('2016-03-14 10:00', "http://mail.google.com")
20 ];
21
22 suite('<history-item> unit test', function() {
23 var item;
24
25 setup(function() {
26 item = document.createElement('history-item');
27 item.item = TEST_HISTORY_RESULTS[0];
28 replaceBody(item);
29 });
30
31 test('click targets for selection', function() {
32 var selectionCount = 0;
33 item.addEventListener('history-checkbox-select', function() {
34 selectionCount++;
35 });
36
37 // Checkbox should trigger selection.
38 MockInteractions.tap(item.$.checkbox);
39 assertEquals(1, selectionCount);
40
41 // Non-interactive text should trigger selection.
42 MockInteractions.tap(item.$['time-accessed']);
43 assertEquals(2, selectionCount);
44
45 // Menu button should not trigger selection.
46 MockInteractions.tap(item.$['menu-button']);
47 assertEquals(2, selectionCount);
48 });
49
50 test('refocus checkbox on click', function() {
51 return PolymerTest.flushTasks().then(function() {
52 item.$['menu-button'].focus();
53 assertEquals(item.$['menu-button'], item.root.activeElement);
54
55 MockInteractions.tap(item.$['time-accessed']);
56 assertEquals(item.$['checkbox'], item.root.activeElement);
57 });
58 });
59 });
60
61 suite('<history-item> integration test', function() {
8 var element; 62 var element;
9 var TEST_HISTORY_RESULTS;
10 var SEARCH_HISTORY_RESULTS;
11
12 suiteSetup(function() {
13 TEST_HISTORY_RESULTS = [
14 createHistoryEntry('2016-03-16 10:00', 'http://www.google.com'),
15 createHistoryEntry('2016-03-16 9:00', 'http://www.example.com'),
16 createHistoryEntry('2016-03-16 7:01', 'http://www.badssl.com'),
17 createHistoryEntry('2016-03-16 7:00', 'http://www.website.com'),
18 createHistoryEntry('2016-03-16 4:00', 'http://www.website.com'),
19 createHistoryEntry('2016-03-15 11:00', 'http://www.example.com'),
20 ];
21
22 SEARCH_HISTORY_RESULTS = [
23 createSearchEntry('2016-03-16', "http://www.google.com"),
24 createSearchEntry('2016-03-14 11:00', "http://calendar.google.com"),
25 createSearchEntry('2016-03-14 10:00', "http://mail.google.com")
26 ];
27 });
28 63
29 setup(function() { 64 setup(function() {
30 element = replaceApp().$['history'].$['infinite-list']; 65 element = replaceApp().$['history'].$['infinite-list'];
31 }); 66 });
32 67
33 test('basic separator insertion', function() { 68 test('basic separator insertion', function() {
34 element.addNewResults(TEST_HISTORY_RESULTS); 69 element.addNewResults(TEST_HISTORY_RESULTS);
35 return PolymerTest.flushTasks().then(function() { 70 return PolymerTest.flushTasks().then(function() {
36 // Check that the correct number of time gaps are inserted. 71 // Check that the correct number of time gaps are inserted.
37 var items = 72 var items =
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 items[1].$$('#bookmark-star').focus(); 127 items[1].$$('#bookmark-star').focus();
93 MockInteractions.tap(items[1].$$('#bookmark-star')); 128 MockInteractions.tap(items[1].$$('#bookmark-star'));
94 129
95 // Check that focus is shifted to overflow menu icon. 130 // Check that focus is shifted to overflow menu icon.
96 assertEquals(items[1].root.activeElement, items[1].$['menu-button']); 131 assertEquals(items[1].root.activeElement, items[1].$['menu-button']);
97 // Check that all items matching this url are unstarred. 132 // Check that all items matching this url are unstarred.
98 assertEquals(element.historyData_[1].starred, false); 133 assertEquals(element.historyData_[1].starred, false);
99 assertEquals(element.historyData_[5].starred, false); 134 assertEquals(element.historyData_[5].starred, false);
100 }); 135 });
101 }); 136 });
102
103 test('click targets for selection', function() {
104 var item = document.createElement('history-item');
105 var selectionCount = 0;
106 item.item = TEST_HISTORY_RESULTS[0];
107 item.addEventListener('history-checkbox-select', function() {
108 selectionCount++;
109 });
110
111 replaceBody(item);
112
113 // Checkbox should trigger selection.
114 MockInteractions.tap(item.$.checkbox);
115 assertEquals(1, selectionCount);
116
117 // Non-interactive text should trigger selection.
118 MockInteractions.tap(item.$['time-accessed']);
119 assertEquals(2, selectionCount);
120
121 // Menu button should not trigger selection.
122 MockInteractions.tap(item.$['menu-button']);
123 assertEquals(2, selectionCount);
124 });
125 }); 137 });
126 } 138 }
127 return { 139 return {
128 registerTests: registerTests 140 registerTests: registerTests
129 }; 141 };
130 }); 142 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/history_item.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698