| 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; |
| 11 var TEST_HISTORY_RESULTS; | 11 var TEST_HISTORY_RESULTS; |
| 12 | 12 |
| 13 suiteSetup(function() { | 13 suiteSetup(function() { |
| 14 TEST_HISTORY_RESULTS = | 14 TEST_HISTORY_RESULTS = |
| 15 [createHistoryEntry('2016-03-15', 'https://google.com')]; | 15 [createHistoryEntry('2016-03-15', 'https://google.com')]; |
| 16 }); | 16 }); |
| 17 | 17 |
| 18 setup(function() { | 18 setup(function() { |
| 19 app = replaceApp(); | 19 app = replaceApp(); |
| 20 element = app.$['history'].$['infinite-list']; | 20 element = app.$['history'].$['infinite-list']; |
| 21 toolbar = app.$['toolbar']; | 21 toolbar = app.$['toolbar']; |
| 22 return flush(); | 22 return PolymerTest.flushTasks(); |
| 23 }); | 23 }); |
| 24 | 24 |
| 25 test('selecting checkbox causes toolbar to change', function() { | 25 test('selecting checkbox causes toolbar to change', function() { |
| 26 element.addNewResults(TEST_HISTORY_RESULTS); | 26 element.addNewResults(TEST_HISTORY_RESULTS); |
| 27 | 27 |
| 28 return flush().then(function() { | 28 return PolymerTest.flushTasks().then(function() { |
| 29 var item = element.$$('history-item'); | 29 var item = element.$$('history-item'); |
| 30 MockInteractions.tap(item.$.checkbox); | 30 MockInteractions.tap(item.$.checkbox); |
| 31 | 31 |
| 32 // 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 |
| 33 // toolbar increases. | 33 // toolbar increases. |
| 34 assertEquals(1, toolbar.count); | 34 assertEquals(1, toolbar.count); |
| 35 // 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 |
| 36 // selected. | 36 // selected. |
| 37 assertTrue(toolbar.itemsSelected_); | 37 assertTrue(toolbar.itemsSelected_); |
| 38 | 38 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 app = replaceApp(); | 120 app = replaceApp(); |
| 121 | 121 |
| 122 element = app.$['history'].$['infinite-list']; | 122 element = app.$['history'].$['infinite-list']; |
| 123 toolbar = app.$['toolbar']; | 123 toolbar = app.$['toolbar']; |
| 124 }); | 124 }); |
| 125 | 125 |
| 126 test('search bar is focused on load in wide mode', function() { | 126 test('search bar is focused on load in wide mode', function() { |
| 127 toolbar.$['main-toolbar'].narrow_ = false; | 127 toolbar.$['main-toolbar'].narrow_ = false; |
| 128 | 128 |
| 129 historyResult(createHistoryInfo(), []); | 129 historyResult(createHistoryInfo(), []); |
| 130 return flush().then(() => { | 130 return PolymerTest.flushTasks().then(() => { |
| 131 // Ensure the search bar is focused on load. | 131 // Ensure the search bar is focused on load. |
| 132 assertTrue( | 132 assertTrue( |
| 133 app.$.toolbar.$['main-toolbar'] | 133 app.$.toolbar.$['main-toolbar'] |
| 134 .getSearchField() | 134 .getSearchField() |
| 135 .isSearchFocused()); | 135 .isSearchFocused()); |
| 136 }); | 136 }); |
| 137 }); | 137 }); |
| 138 | 138 |
| 139 test('search bar is not focused on load in narrow mode', function() { | 139 test('search bar is not focused on load in narrow mode', function() { |
| 140 toolbar.$['main-toolbar'].narrow_ = true; | 140 toolbar.$['main-toolbar'].narrow_ = true; |
| 141 | 141 |
| 142 historyResult(createHistoryInfo(), []); | 142 historyResult(createHistoryInfo(), []); |
| 143 return flush().then(() => { | 143 return PolymerTest.flushTasks().then(() => { |
| 144 // Ensure the search bar is focused on load. | 144 // Ensure the search bar is focused on load. |
| 145 assertFalse( | 145 assertFalse( |
| 146 $('history-app') | 146 $('history-app') |
| 147 .$.toolbar.$['main-toolbar'] | 147 .$.toolbar.$['main-toolbar'] |
| 148 .getSearchField() | 148 .getSearchField() |
| 149 .isSearchFocused()); | 149 .isSearchFocused()); |
| 150 }); | 150 }); |
| 151 }); | 151 }); |
| 152 }); | 152 }); |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 return { | 155 return { |
| 156 registerTests: registerTests | 156 registerTests: registerTests |
| 157 }; | 157 }; |
| 158 }); | 158 }); |
| OLD | NEW |