| OLD | NEW |
| 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-list'); | 21 element = $('history-list'); |
| 21 toolbar = $('toolbar'); | 22 toolbar = $('toolbar'); |
| 22 }); | 23 }); |
| 23 | 24 |
| 24 test('selecting checkbox causes toolbar to change', function(done) { | 25 test('selecting checkbox causes toolbar to change', function(done) { |
| 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-item'); | 29 var item = element.$$('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 done(); | 47 done(); |
| 47 }); | 48 }); |
| 48 }); | 49 }); |
| 49 | 50 |
| 51 test('search term gathered correctly from toolbar', function(done) { |
| 52 registerMessageCallback('queryHistory', this, function (info) { |
| 53 assertEquals(info[0], 'Test'); |
| 54 done(); |
| 55 }); |
| 56 |
| 57 toolbar.onSearchTermSearch('Test'); |
| 58 }); |
| 59 |
| 50 teardown(function() { | 60 teardown(function() { |
| 61 element.historyDataByDay_ = []; |
| 51 toolbar.count = 0; | 62 toolbar.count = 0; |
| 52 }); | 63 }); |
| 53 }); | 64 }); |
| 54 } | 65 } |
| 55 return { | 66 return { |
| 56 registerTests: registerTests | 67 registerTests: registerTests |
| 57 }; | 68 }; |
| 58 }); | 69 }); |
| OLD | NEW |