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

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

Issue 1974713002: [MD History] Unify query state in history-app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@secondary_toolbar
Patch Set: address comments Created 4 years, 7 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_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-list']; 13 element = $('history-app').$['history-list'];
14 TEST_HISTORY_RESULTS = [ 14 TEST_HISTORY_RESULTS = [
15 createHistoryEntry('2016-03-16 10:00', 'http://www.google.com'), 15 createHistoryEntry('2016-03-16 10:00', 'http://www.google.com'),
16 createHistoryEntry('2016-03-16 9:00', 'http://www.example.com'), 16 createHistoryEntry('2016-03-16 9:00', 'http://www.example.com'),
17 createHistoryEntry('2016-03-16 7:01', 'http://www.badssl.com'), 17 createHistoryEntry('2016-03-16 7:01', 'http://www.badssl.com'),
18 createHistoryEntry('2016-03-16 7:00', 'http://www.website.com'), 18 createHistoryEntry('2016-03-16 7:00', 'http://www.website.com'),
19 createHistoryEntry('2016-03-16 4:00', 'http://www.website.com'), 19 createHistoryEntry('2016-03-16 4:00', 'http://www.website.com'),
20 createHistoryEntry('2016-03-15 11:00', 'http://www.example.com'), 20 createHistoryEntry('2016-03-15 11:00', 'http://www.example.com'),
21 ]; 21 ];
22 22
23 SEARCH_HISTORY_RESULTS = [ 23 SEARCH_HISTORY_RESULTS = [
24 createSearchEntry('2016-03-16', "http://www.google.com"), 24 createSearchEntry('2016-03-16', "http://www.google.com"),
25 createSearchEntry('2016-03-14', "http://calendar.google.com"), 25 createSearchEntry('2016-03-14 11:00', "http://calendar.google.com"),
26 createSearchEntry('2016-03-14', "http://mail.google.com") 26 createSearchEntry('2016-03-14 10:00', "http://mail.google.com")
27 ]; 27 ];
28 }); 28 });
29 29
30 test('basic separator insertion', function(done) { 30 test('basic separator insertion', function(done) {
31 element.addNewResults(TEST_HISTORY_RESULTS, ''); 31 element.addNewResults(TEST_HISTORY_RESULTS);
32 flush(function() { 32 flush(function() {
33 // Check that the correct number of time gaps are inserted. 33 // Check that the correct number of time gaps are inserted.
34 var items = 34 var items =
35 Polymer.dom(element.root).querySelectorAll('history-item'); 35 Polymer.dom(element.root).querySelectorAll('history-item');
36 36
37 assertTrue(items[0].hasTimeGap); 37 assertTrue(items[0].hasTimeGap);
38 assertTrue(items[1].hasTimeGap); 38 assertTrue(items[1].hasTimeGap);
39 assertFalse(items[2].hasTimeGap); 39 assertFalse(items[2].hasTimeGap);
40 assertTrue(items[3].hasTimeGap); 40 assertTrue(items[3].hasTimeGap);
41 assertFalse(items[4].hasTimeGap); 41 assertFalse(items[4].hasTimeGap);
42 assertFalse(items[5].hasTimeGap); 42 assertFalse(items[5].hasTimeGap);
43 43
44 done(); 44 done();
45 }); 45 });
46 }); 46 });
47 47
48 test('separator insertion for search', function(done) { 48 test('separator insertion for search', function(done) {
49 element.addNewResults(SEARCH_HISTORY_RESULTS, 'search'); 49 element.addNewResults(SEARCH_HISTORY_RESULTS);
50 element.searchedTerm = 'search';
50 flush(function() { 51 flush(function() {
51 var items = 52 var items =
52 Polymer.dom(element.root).querySelectorAll('history-item'); 53 Polymer.dom(element.root).querySelectorAll('history-item');
53 54
54 assertTrue(items[0].hasTimeGap); 55 assertTrue(items[0].hasTimeGap);
55 assertFalse(items[1].hasTimeGap); 56 assertFalse(items[1].hasTimeGap);
56 assertFalse(items[2].hasTimeGap); 57 assertFalse(items[2].hasTimeGap);
57 58
58 done(); 59 done();
59 }); 60 });
60 }); 61 });
61 62
62 test('separator insertion after deletion', function(done) { 63 test('separator insertion after deletion', function(done) {
63 element.addNewResults(TEST_HISTORY_RESULTS, ''); 64 element.addNewResults(TEST_HISTORY_RESULTS);
64 flush(function() { 65 flush(function() {
65 var items = 66 var items =
66 Polymer.dom(element.root).querySelectorAll('history-item'); 67 Polymer.dom(element.root).querySelectorAll('history-item');
67 68
68 element.removeDeletedHistory_([element.historyData[3]]); 69 element.removeDeletedHistory_([element.historyData[3]]);
69 assertEquals(5, element.historyData.length); 70 assertEquals(5, element.historyData.length);
70 71
71 // Checks that a new time gap separator has been inserted. 72 // Checks that a new time gap separator has been inserted.
72 assertTrue(items[2].hasTimeGap); 73 assertTrue(items[2].hasTimeGap);
73 74
74 element.removeDeletedHistory_([element.historyData[3]]); 75 element.removeDeletedHistory_([element.historyData[3]]);
75 76
76 // Checks time gap separator is removed. 77 // Checks time gap separator is removed.
77 assertFalse(items[2].hasTimeGap); 78 assertFalse(items[2].hasTimeGap);
78 done(); 79 done();
79 }); 80 });
80 }); 81 });
81 82
82 teardown(function() { 83 teardown(function() {
83 element.historyData = []; 84 element.historyData = [];
85 element.searchedTerm = '';
84 }); 86 });
85 }); 87 });
86 } 88 }
87 return { 89 return {
88 registerTests: registerTests 90 registerTests: registerTests
89 }; 91 };
90 }); 92 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/history_toolbar.js ('k') | chrome/test/data/webui/md_history/history_list_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698