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 app; |
8 var element; | 9 var element; |
9 var toolbar; | 10 var toolbar; |
10 var TEST_HISTORY_RESULTS; | 11 var TEST_HISTORY_RESULTS; |
11 | 12 |
12 suiteSetup(function() { | 13 suiteSetup(function() { |
13 element = $('history-app').$['history-list']; | 14 app = $('history-app'); |
14 toolbar = $('history-app').$['toolbar']; | 15 element = app.$['history-list']; |
| 16 toolbar = app.$['toolbar']; |
15 TEST_HISTORY_RESULTS = | 17 TEST_HISTORY_RESULTS = |
16 [createHistoryEntry('2016-03-15', 'https://google.com')]; | 18 [createHistoryEntry('2016-03-15', 'https://google.com')]; |
17 }); | 19 }); |
18 | 20 |
19 test('selecting checkbox causes toolbar to change', function(done) { | 21 test('selecting checkbox causes toolbar to change', function(done) { |
20 element.addNewResults(TEST_HISTORY_RESULTS); | 22 element.addNewResults(TEST_HISTORY_RESULTS); |
21 | 23 |
22 flush(function() { | 24 flush(function() { |
23 var item = element.$$('history-item'); | 25 var item = element.$$('history-item'); |
24 MockInteractions.tap(item.$.checkbox); | 26 MockInteractions.tap(item.$.checkbox); |
(...skipping 11 matching lines...) Expand all Loading... |
36 // toolbar decreases. | 38 // toolbar decreases. |
37 assertEquals(0, toolbar.count); | 39 assertEquals(0, toolbar.count); |
38 // Ensure that the toolbar boolean states that no items are selected. | 40 // Ensure that the toolbar boolean states that no items are selected. |
39 assertFalse(toolbar.itemsSelected_); | 41 assertFalse(toolbar.itemsSelected_); |
40 | 42 |
41 done(); | 43 done(); |
42 }); | 44 }); |
43 }); | 45 }); |
44 | 46 |
45 test('search term gathered correctly from toolbar', function(done) { | 47 test('search term gathered correctly from toolbar', function(done) { |
| 48 app.queryingDisabled_ = false; |
46 registerMessageCallback('queryHistory', this, function (info) { | 49 registerMessageCallback('queryHistory', this, function (info) { |
47 assertEquals(info[0], 'Test'); | 50 assertEquals(info[0], 'Test'); |
48 done(); | 51 done(); |
49 }); | 52 }); |
50 | 53 |
51 toolbar.onSearch('Test'); | 54 toolbar.onSearch('Test'); |
52 }); | 55 }); |
53 | 56 |
54 test('more from this site sends and sets correct data', function(done) { | 57 test('more from this site sends and sets correct data', function(done) { |
| 58 app.queryingDisabled_ = false; |
55 registerMessageCallback('queryHistory', this, function (info) { | 59 registerMessageCallback('queryHistory', this, function (info) { |
56 assertEquals('example.com', info[0]); | 60 assertEquals('example.com', info[0]); |
57 flush(function() { | 61 flush(function() { |
58 assertEquals(toolbar.$$('#search-input').$$('#search-input').value, | 62 assertEquals(toolbar.$$('#search-input').$$('#search-input').value, |
59 'example.com'); | 63 'example.com'); |
60 done(); | 64 done(); |
61 }); | 65 }); |
62 }); | 66 }); |
63 | 67 |
64 element.$.sharedMenu.itemData = {domain: 'example.com'}; | 68 element.$.sharedMenu.itemData = {domain: 'example.com'}; |
65 MockInteractions.tap(element.$.menuMoreButton); | 69 MockInteractions.tap(element.$.menuMoreButton); |
66 }); | 70 }); |
67 | 71 |
68 teardown(function() { | 72 teardown(function() { |
69 element.historyData_ = []; | 73 element.historyData_ = []; |
70 element.searchedTerm = ''; | 74 element.searchedTerm = ''; |
71 registerMessageCallback('queryHistory', this, undefined); | 75 registerMessageCallback('queryHistory', this, undefined); |
72 toolbar.count = 0; | 76 toolbar.count = 0; |
73 }); | 77 }); |
74 }); | 78 }); |
75 } | 79 } |
76 return { | 80 return { |
77 registerTests: registerTests | 81 registerTests: registerTests |
78 }; | 82 }; |
79 }); | 83 }); |
OLD | NEW |