Chromium Code Reviews| Index: chrome/test/data/webui/md_history/history_item_test.js |
| diff --git a/chrome/test/data/webui/md_history/history_card_test.js b/chrome/test/data/webui/md_history/history_item_test.js |
| similarity index 31% |
| rename from chrome/test/data/webui/md_history/history_card_test.js |
| rename to chrome/test/data/webui/md_history/history_item_test.js |
| index af661a256bd892e47f5a605f7b1556f6f939eb77..5712658a37528bba85c227ef0d5bcb61eec8b74f 100644 |
| --- a/chrome/test/data/webui/md_history/history_card_test.js |
| +++ b/chrome/test/data/webui/md_history/history_item_test.js |
| @@ -2,54 +2,63 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -cr.define('md_history.history_card_test', function() { |
| +cr.define('md_history.history_item_test', function() { |
| + var TEST_HISTORY_RESULTS = [ |
| + {"time": "1000000000"}, |
| + {"time": "100000000"}, |
| + {"time": "9000020"}, |
| + {"time": "9000000"}, |
| + {"time": "1"} |
| + ]; |
| + |
| function registerTests() { |
| - suite('history-card', function() { |
| + suite('history-item', function() { |
| var element; |
| suiteSetup(function() { |
| - element = document.createElement('history-card'); |
| - element.historyItems = [ |
| - {"time": "1000000000"}, |
| - {"time": "10000000"}, |
| - {"time": "900000"} |
| - ]; |
| - }) |
| + element = $('history-list'); |
| + }); |
| + |
| + setup(function() { |
| + element.addNewResults(TEST_HISTORY_RESULTS); |
| + }); |
| test('basic separator insertion', function(done) { |
| flush(function() { |
| // Check that the correct number of time gaps are inserted. |
| - var spacers = |
| - Polymer.dom(element.root).querySelectorAll('#time-gap-separator'); |
| - assertEquals(2, spacers.length); |
| + var items = |
| + Polymer.dom(element.root).querySelectorAll('history-item'); |
| + |
| + assertTrue(items[0].hasTimeGap); |
| + assertTrue(items[1].hasTimeGap); |
| + assertFalse(items[2].hasTimeGap); |
| + assertTrue(items[3].hasTimeGap); |
| + assertFalse(items[4].hasTimeGap); |
| + |
| done(); |
| }); |
| }); |
| - test('separator insertion when items change but item list length stays ' + |
| - 'the same', function(done) { |
| - element.set('historyItems', [{"time": "900000"}, |
| - {"time": "900000"}, |
| - {"time": "900000"}]); |
| - |
| + test('separator insertion after deletion', function(done) { |
|
tsergeant
2016/02/12 03:05:52
I think this test probably belongs in history_list
yingran
2016/02/12 03:30:32
Done.
Uhhh... i'm gunna leave it where it is for
|
| flush(function() { |
| - var items = |
| - Polymer.dom(element.root).querySelectorAll('history-item'); |
| - var spacers = |
| - Polymer.dom(element.root).querySelectorAll('#time-gap-separator'); |
| - |
| - assertEquals('900000', items[0].timestamp_); |
| - assertEquals('900000', items[1].timestamp_); |
| - assertEquals('900000', items[2].timestamp_); |
| - |
| - // Note that the spacers aren't actually removed, are just set to: |
| - // display: none; |
| - for (var i = 0; i < spacers.length; i++) { |
| - assertEquals(spacers[i].style.display, 'none'); |
| - } |
| + items = Polymer.dom(element.root).querySelectorAll('history-item'); |
| + |
| + element.set('historyData.3.selected', true); |
| + items[3].onCheckboxSelected_(); |
| + |
| + element.removeDeletedHistory(1); |
| + assertEquals(element.historyData.length, 4); |
| + |
| + // Checks that a new time gap separator has been inserted. |
| + assertTrue(element.historyData[2].needsTimeGap); |
| + assertTrue(items[2].hasTimeGap); |
| done(); |
| }); |
| }); |
| + |
| + teardown(function() { |
| + element.historyData = []; |
| + }); |
| }); |
| } |
| return { |