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

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

Issue 1641543002: MD History: Refactored design for displaying history information (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@second_patch
Patch Set: closure 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_card_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
6 function registerTests() { 14 function registerTests() {
7 suite('history-card', function() { 15 suite('history-item', function() {
8 var element; 16 var element;
9 17
10 suiteSetup(function() { 18 suiteSetup(function() {
11 element = document.createElement('history-card'); 19 element = $('history-list');
12 element.historyItems = [ 20 });
13 {"time": "1000000000"}, 21
14 {"time": "10000000"}, 22 setup(function() {
15 {"time": "900000"} 23 element.addNewResults(TEST_HISTORY_RESULTS);
16 ]; 24 });
17 })
18 25
19 test('basic separator insertion', function(done) { 26 test('basic separator insertion', function(done) {
20 flush(function() { 27 flush(function() {
21 // Check that the correct number of time gaps are inserted. 28 // Check that the correct numbegitr of time gaps are inserted.
22 var spacers = 29 var items =
23 Polymer.dom(element.root).querySelectorAll('#time-gap-separator'); 30 Polymer.dom(element.root).querySelectorAll('history-item');
24 assertEquals(2, spacers.length); 31
32 assertTrue(items[0].hasTimeGap);
33 assertTrue(items[1].hasTimeGap);
34 assertFalse(items[2].hasTimeGap);
35 assertTrue(items[3].hasTimeGap);
36 assertFalse(items[4].hasTimeGap);
37
25 done(); 38 done();
26 }); 39 });
27 }); 40 });
28 41
29 test('separator insertion when items change but item list length stays ' + 42 test('separator insertion after deletion', function(done) {
30 'the same', function(done) { 43 flush(function() {
31 element.set('historyItems', [{"time": "900000"}, 44 items = Polymer.dom(element.root).querySelectorAll('history-item');
32 {"time": "900000"},
33 {"time": "900000"}]);
34 45
35 flush(function() { 46 element.set('historyData.3.selected', true);
36 var items = 47 items[3].onCheckboxSelected_();
37 Polymer.dom(element.root).querySelectorAll('history-item');
38 var spacers =
39 Polymer.dom(element.root).querySelectorAll('#time-gap-separator');
40 48
41 assertEquals('900000', items[0].timestamp_); 49 element.removeDeletedHistory(1);
42 assertEquals('900000', items[1].timestamp_); 50 assertEquals(element.historyData.length, 4);
43 assertEquals('900000', items[2].timestamp_);
44 51
45 // Note that the spacers aren't actually removed, are just set to: 52 // Checks that a new time gap separator has been inserted.
46 // display: none; 53 assertTrue(element.historyData[2].needsTimeGap);
47 for (var i = 0; i < spacers.length; i++) { 54 assertTrue(items[2].hasTimeGap);
48 assertEquals(spacers[i].style.display, 'none'); 55
49 } 56 element.set('historyData.3.selected', true);
57 items[3].onCheckboxSelected_();
58 element.removeDeletedHistory(1);
59
60 // Checks time gap separator is removed.
61 assertFalse(element.historyData[2].needsTimeGap);
62 assertFalse(items[2].hasTimeGap);
50 done(); 63 done();
51 }); 64 });
52 }); 65 });
66
67 teardown(function() {
68 element.historyData = [];
69 });
53 }); 70 });
54 } 71 }
55 return { 72 return {
56 registerTests: registerTests 73 registerTests: registerTests
57 }; 74 };
58 }); 75 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/md_history/history_card_test.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