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

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

Issue 2409063003: MD History: Select items when tapping anywhere inside the item (Closed)
Patch Set: Remove <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 suite('history-item', function() {
8 var element; 8 var element;
9 var TEST_HISTORY_RESULTS; 9 var TEST_HISTORY_RESULTS;
10 var SEARCH_HISTORY_RESULTS; 10 var SEARCH_HISTORY_RESULTS;
11 11
12 suiteSetup(function() { 12 suiteSetup(function() {
13 element = $('history-app').$['history'].$['infinite-list'];
14 TEST_HISTORY_RESULTS = [ 13 TEST_HISTORY_RESULTS = [
15 createHistoryEntry('2016-03-16 10:00', 'http://www.google.com'), 14 createHistoryEntry('2016-03-16 10:00', 'http://www.google.com'),
16 createHistoryEntry('2016-03-16 9:00', 'http://www.example.com'), 15 createHistoryEntry('2016-03-16 9:00', 'http://www.example.com'),
17 createHistoryEntry('2016-03-16 7:01', 'http://www.badssl.com'), 16 createHistoryEntry('2016-03-16 7:01', 'http://www.badssl.com'),
18 createHistoryEntry('2016-03-16 7:00', 'http://www.website.com'), 17 createHistoryEntry('2016-03-16 7:00', 'http://www.website.com'),
19 createHistoryEntry('2016-03-16 4:00', 'http://www.website.com'), 18 createHistoryEntry('2016-03-16 4:00', 'http://www.website.com'),
20 createHistoryEntry('2016-03-15 11:00', 'http://www.example.com'), 19 createHistoryEntry('2016-03-15 11:00', 'http://www.example.com'),
21 ]; 20 ];
22 21
23 SEARCH_HISTORY_RESULTS = [ 22 SEARCH_HISTORY_RESULTS = [
24 createSearchEntry('2016-03-16', "http://www.google.com"), 23 createSearchEntry('2016-03-16', "http://www.google.com"),
25 createSearchEntry('2016-03-14 11:00', "http://calendar.google.com"), 24 createSearchEntry('2016-03-14 11:00', "http://calendar.google.com"),
26 createSearchEntry('2016-03-14 10:00', "http://mail.google.com") 25 createSearchEntry('2016-03-14 10:00', "http://mail.google.com")
27 ]; 26 ];
28 }); 27 });
29 28
29 setup(function() {
30 element = replaceApp().$['history'].$['infinite-list'];
31 });
32
30 test('basic separator insertion', function() { 33 test('basic separator insertion', function() {
31 element.addNewResults(TEST_HISTORY_RESULTS); 34 element.addNewResults(TEST_HISTORY_RESULTS);
32 return PolymerTest.flushTasks().then(function() { 35 return PolymerTest.flushTasks().then(function() {
33 // Check that the correct number of time gaps are inserted. 36 // Check that the correct number of time gaps are inserted.
34 var items = 37 var items =
35 Polymer.dom(element.root).querySelectorAll('history-item'); 38 Polymer.dom(element.root).querySelectorAll('history-item');
36 39
37 assertTrue(items[0].hasTimeGap); 40 assertTrue(items[0].hasTimeGap);
38 assertTrue(items[1].hasTimeGap); 41 assertTrue(items[1].hasTimeGap);
39 assertFalse(items[2].hasTimeGap); 42 assertFalse(items[2].hasTimeGap);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 MockInteractions.tap(items[1].$$('#bookmark-star')); 93 MockInteractions.tap(items[1].$$('#bookmark-star'));
91 94
92 // Check that focus is shifted to overflow menu icon. 95 // Check that focus is shifted to overflow menu icon.
93 assertEquals(items[1].root.activeElement, items[1].$['menu-button']); 96 assertEquals(items[1].root.activeElement, items[1].$['menu-button']);
94 // Check that all items matching this url are unstarred. 97 // Check that all items matching this url are unstarred.
95 assertEquals(element.historyData_[1].starred, false); 98 assertEquals(element.historyData_[1].starred, false);
96 assertEquals(element.historyData_[5].starred, false); 99 assertEquals(element.historyData_[5].starred, false);
97 }); 100 });
98 }); 101 });
99 102
100 teardown(function() { 103 test('click targets for selection', function() {
101 element.historyData_ = []; 104 var item = document.createElement('history-item');
102 element.searchedTerm = ''; 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);
103 }); 124 });
104 }); 125 });
105 } 126 }
106 return { 127 return {
107 registerTests: registerTests 128 registerTests: registerTests
108 }; 129 };
109 }); 130 });
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