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 app; |
9 var element; | 9 var element; |
10 var toolbar; | 10 var toolbar; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 test('search term gathered correctly from toolbar', function(done) { | 45 test('search term gathered correctly from toolbar', function(done) { |
46 app.queryState_.queryingDisabled = false; | 46 app.queryState_.queryingDisabled = false; |
47 registerMessageCallback('queryHistory', this, function (info) { | 47 registerMessageCallback('queryHistory', this, function (info) { |
48 assertEquals(info[0], 'Test'); | 48 assertEquals(info[0], 'Test'); |
49 done(); | 49 done(); |
50 }); | 50 }); |
51 | 51 |
52 toolbar.$$('cr-toolbar').fire('search-changed', 'Test'); | 52 toolbar.$$('cr-toolbar').fire('search-changed', 'Test'); |
53 }); | 53 }); |
54 | 54 |
| 55 test('shortcuts to open search field', function() { |
| 56 var field = toolbar.$['main-toolbar'].getSearchField(); |
| 57 assertFalse(field.showingSearch); |
| 58 |
| 59 MockInteractions.pressAndReleaseKeyOn( |
| 60 document.body, 191, '', '/'); |
| 61 assertTrue(field.showingSearch); |
| 62 assertEquals(field.$.searchInput, field.root.activeElement); |
| 63 |
| 64 MockInteractions.pressAndReleaseKeyOn( |
| 65 field.$.searchInput, 27, '', 'Escape'); |
| 66 assertFalse(field.showingSearch, 'Pressing escape closes field.'); |
| 67 assertNotEquals(field.$.searchInput, field.root.activeElement); |
| 68 |
| 69 MockInteractions.pressAndReleaseKeyOn( |
| 70 document.body, 70, 'ctrl', 'f'); |
| 71 assertTrue(field.showingSearch); |
| 72 assertEquals(field.$.searchInput, field.root.activeElement); |
| 73 }); |
| 74 |
55 teardown(function() { | 75 teardown(function() { |
56 element.historyData_ = []; | 76 element.historyData_ = []; |
57 element.searchedTerm = ''; | 77 element.searchedTerm = ''; |
58 registerMessageCallback('queryHistory', this, undefined); | 78 registerMessageCallback('queryHistory', this, undefined); |
59 toolbar.count = 0; | 79 toolbar.count = 0; |
60 }); | 80 }); |
61 }); | 81 }); |
62 } | 82 } |
63 return { | 83 return { |
64 registerTests: registerTests | 84 registerTests: registerTests |
65 }; | 85 }; |
66 }); | 86 }); |
OLD | NEW |