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

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

Issue 1643693003: MD History: Implement search functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch_to_be_uploaded
Patch Set: Update comments. 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
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_toolbar_test', function() { 5 cr.define('md_history.history_toolbar_test', function() {
6 // Array of test history data. 6 // Array of test history data.
7 var TEST_HISTORY_RESULTS = [ 7 var TEST_HISTORY_RESULTS = [
8 { 8 {
9 "dateRelativeDay": "Today - Wednesday, December 9, 2015", 9 "dateRelativeDay": "Today - Wednesday, December 9, 2015",
10 "title": "Google",
10 "url": "https://www.google.com" 11 "url": "https://www.google.com"
11 } 12 }
12 ]; 13 ];
13 14
14 function registerTests() { 15 function registerTests() {
15 suite('history-toolbar', function() { 16 suite('history-toolbar', function() {
16 var element; 17 var element;
17 var toolbar; 18 var toolbar;
18 19
19 suiteSetup(function() { 20 suiteSetup(function() {
20 element = $('history-card-manager'); 21 element = $('history-card-manager');
21 toolbar = $('toolbar'); 22 toolbar = $('toolbar');
22 }); 23 });
23 24
24 test('selecting checkbox causes toolbar to change', function(done) { 25 test('selecting checkbox causes toolbar to change', function(done) {
25 element.addNewResults(TEST_HISTORY_RESULTS); 26 element.addNewResults(TEST_HISTORY_RESULTS, '');
26 27
27 flush(function() { 28 flush(function() {
28 var item = element.$$('history-card').$$('history-item'); 29 var item = element.$$('history-card').$$('history-item');
29 MockInteractions.tap(item.$.checkbox); 30 MockInteractions.tap(item.$.checkbox);
30 31
31 // Ensure that when an item is selected that the count held by the 32 // Ensure that when an item is selected that the count held by the
32 // toolbar increases. 33 // toolbar increases.
33 assertEquals(1, toolbar.count); 34 assertEquals(1, toolbar.count);
34 // Ensure that the toolbar boolean states that at least one item is 35 // Ensure that the toolbar boolean states that at least one item is
35 // selected. 36 // selected.
36 assertTrue(toolbar.itemsSelected_); 37 assertTrue(toolbar.itemsSelected_);
37 38
38 MockInteractions.tap(item.$.checkbox); 39 MockInteractions.tap(item.$.checkbox);
39 40
40 // Ensure that when an item is deselected the count held by the 41 // Ensure that when an item is deselected the count held by the
41 // toolbar decreases. 42 // toolbar decreases.
42 assertEquals(0, toolbar.count); 43 assertEquals(0, toolbar.count);
43 // Ensure that the toolbar boolean states that no items are selected. 44 // Ensure that the toolbar boolean states that no items are selected.
44 assertFalse(toolbar.itemsSelected_); 45 assertFalse(toolbar.itemsSelected_);
45 46
46 done(); 47 done();
47 }); 48 });
48 }); 49 });
49 50
51 test('search term gathered correctly from toolbar', function(done) {
52 registerMessageCallback('queryHistory', this, function (info) {
53 assertEquals(info[0], 'Test');
54 done();
55 });
56
57 toolbar.onSearchTermSearch('Test');
58 });
59
60 test('search results display with correct item title', function(done) {
tsergeant 2016/02/09 04:28:53 These next few tests should be moved to history_ca
hsampson 2016/02/11 02:46:26 Done.
61 element.addNewResults(TEST_HISTORY_RESULTS, 'Google');
62
63 flush(function() {
64 var heading =
65 element.$$('history-card').$$('#date-accessed').textContent;
66 var title = element.$$('history-card').$$('history-item').$.title;
67
68 // Check that the card title displays the search term somewhere.
69 var index = heading.indexOf('Google');
70 assertTrue(index != -1);
71
72 // Check that the search term is bolded correctly in the history-item.
73 assertEquals(title.innerHTML, '<b>Google</b>');
74 done();
75 });
76 });
77
78 test('correct display message when no history available', function(done) {
79 element.addNewResults([], '');
80
81 flush(function() {
82 assertFalse(element.$['no-results'].hidden);
83 assertTrue(element.$['no-search-results'].hidden);
84 assertTrue(element.$['infinite-list'].hidden);
85
86 element.addNewResults(TEST_HISTORY_RESULTS, '');
87
88 flush(function() {
89 assertTrue(element.$['no-results'].hidden);
90 assertTrue(element.$['no-search-results'].hidden);
91 assertFalse(element.$['infinite-list'].hidden);
92 done();
93 });
94 });
95 });
96
97 test('correct display message when no search results returned',
98 function(done) {
99 element.addNewResults([], 'Test');
100
101 flush(function() {
102 assertFalse(element.$['no-search-results'].hidden);
103 assertTrue(element.$['no-results'].hidden);
104 assertTrue(element.$['infinite-list'].hidden);
105
106 element.addNewResults(TEST_HISTORY_RESULTS, '');
107
108 flush(function() {
109 assertTrue(element.$['no-results'].hidden);
110 assertTrue(element.$['no-search-results'].hidden);
111 assertFalse(element.$['infinite-list'].hidden);
112 done();
113 });
114 });
115 });
116
50 teardown(function() { 117 teardown(function() {
118 element.historyDataByDay_ = [];
51 toolbar.count = 0; 119 toolbar.count = 0;
52 }); 120 });
53 }); 121 });
54 } 122 }
55 return { 123 return {
56 registerTests: registerTests 124 registerTests: registerTests
57 }; 125 };
58 }); 126 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698