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 function registerTests() { | 6 function registerTests() { |
7 suite('history-toolbar', function() { | 7 suite('history-toolbar', function() { |
8 var element; | 8 var element; |
9 var toolbar; | 9 var toolbar; |
10 var TEST_HISTORY_RESULTS; | 10 var TEST_HISTORY_RESULTS; |
11 | 11 |
12 suiteSetup(function() { | 12 suiteSetup(function() { |
13 element = $('history-app').$['history-list']; | 13 element = $('history-app').$['history-list']; |
14 toolbar = $('history-app').$['toolbar']; | 14 toolbar = $('history-app').$['toolbar']; |
15 TEST_HISTORY_RESULTS = | 15 TEST_HISTORY_RESULTS = |
16 [createHistoryEntry('2016-03-15', 'https://google.com')]; | 16 [createHistoryEntry('2016-03-15', 'https://google.com')]; |
17 }); | 17 }); |
18 | 18 |
19 test('selecting checkbox causes toolbar to change', function(done) { | 19 test('selecting checkbox causes toolbar to change', function(done) { |
20 element.addNewResults(TEST_HISTORY_RESULTS, ''); | 20 element.addNewResults(TEST_HISTORY_RESULTS); |
21 | 21 |
22 flush(function() { | 22 flush(function() { |
23 var item = element.$$('history-item'); | 23 var item = element.$$('history-item'); |
24 MockInteractions.tap(item.$.checkbox); | 24 MockInteractions.tap(item.$.checkbox); |
25 | 25 |
26 // Ensure that when an item is selected that the count held by the | 26 // Ensure that when an item is selected that the count held by the |
27 // toolbar increases. | 27 // toolbar increases. |
28 assertEquals(1, toolbar.count); | 28 assertEquals(1, toolbar.count); |
29 // Ensure that the toolbar boolean states that at least one item is | 29 // Ensure that the toolbar boolean states that at least one item is |
30 // selected. | 30 // selected. |
(...skipping 15 matching lines...) Expand all Loading... |
46 registerMessageCallback('queryHistory', this, function (info) { | 46 registerMessageCallback('queryHistory', this, function (info) { |
47 assertEquals(info[0], 'Test'); | 47 assertEquals(info[0], 'Test'); |
48 done(); | 48 done(); |
49 }); | 49 }); |
50 | 50 |
51 toolbar.onSearch('Test'); | 51 toolbar.onSearch('Test'); |
52 }); | 52 }); |
53 | 53 |
54 test('more from this site sends and sets correct data', function(done) { | 54 test('more from this site sends and sets correct data', function(done) { |
55 registerMessageCallback('queryHistory', this, function (info) { | 55 registerMessageCallback('queryHistory', this, function (info) { |
56 assertEquals(info[0], 'example.com'); | 56 assertEquals('example.com', info[0]); |
57 flush(function() { | 57 flush(function() { |
58 assertEquals(toolbar.$$('#search-input').$$('#search-input').value, | 58 assertEquals(toolbar.$$('#search-input').$$('#search-input').value, |
59 'example.com'); | 59 'example.com'); |
60 done(); | 60 done(); |
61 }); | 61 }); |
62 }); | 62 }); |
63 | 63 |
64 element.$.sharedMenu.itemData = {domain: 'example.com'}; | 64 element.$.sharedMenu.itemData = {domain: 'example.com'}; |
65 MockInteractions.tap(element.$.menuMoreButton); | 65 MockInteractions.tap(element.$.menuMoreButton); |
66 }); | 66 }); |
67 | 67 |
68 teardown(function() { | 68 teardown(function() { |
69 element.historyData = []; | 69 element.historyData = []; |
| 70 element.searchedTerm = ''; |
70 registerMessageCallback('queryHistory', this, undefined); | 71 registerMessageCallback('queryHistory', this, undefined); |
71 toolbar.count = 0; | 72 toolbar.count = 0; |
72 }); | 73 }); |
73 }); | 74 }); |
74 } | 75 } |
75 return { | 76 return { |
76 registerTests: registerTests | 77 registerTests: registerTests |
77 }; | 78 }; |
78 }); | 79 }); |
OLD | NEW |