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

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: Hide cards that haven't been rerendered from previous chrome.send(). Created 4 years, 11 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() { 25 test('selecting checkbox causes toolbar to change', function() {
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 }); 47 });
47 48
49 test('search term gathered correctly from toolbar', function(done) {
tsergeant 2016/02/02 02:57:36 So many tests \o/
50 registerMessageCallback('queryHistory', this, function (info) {
51 assertEquals(info[0], 'Test');
52 done();
53 });
54
55 toolbar.onSearchTermSearch('Test');
56 });
57
58 test('search results display with correct title', function(done) {
59 element.addNewResults(TEST_HISTORY_RESULTS, 'Google');
60
61 flush(function() {
62 var heading = element.$$('history-card').$$('#date-accessed');
63 var title = element.$$('history-card').$$('history-item').$['title'];
64
65 assertEquals(heading.textContent,
tsergeant 2016/02/02 02:57:36 This feels kinda brittle -- you're testing the pre
hsampson 2016/02/03 02:37:59 Done. Yup that's way better.
66 '\n Found 1 search result for \'Google\'.\n ');
67 assertEquals(title.innerHTML, '<b>Google</b>');
68 done();
69 });
70 });
71
72 test('correct display message when no history available', function(done) {
73 element.addNewResults([], '');
74
75 flush(function() {
76 assertEquals(element.$$('#no-results').textContent,
77 'No history entries found.');
78 done();
79 })
80 });
81
82 test('correct display message when no search results returned',
83 function(done) {
84 element.addNewResults([], 'Test');
85
86 flush(function() {
87 assertEquals(element.$$('#no-results').textContent,
88 'No search results found.');
89 done();
90 })
91 });
92
48 teardown(function() { 93 teardown(function() {
94 element.historyDataByDay_ = [];
49 toolbar.count = 0; 95 toolbar.count = 0;
50 }); 96 });
51 }); 97 });
52 } 98 }
53 return { 99 return {
54 registerTests: registerTests 100 registerTests: registerTests
55 }; 101 };
56 }); 102 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698