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

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

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