Chromium Code Reviews| 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('settings_search_page', function() { | 5 cr.define('settings_search_page', function() { |
| 6 function generateSearchEngineInfo() { | 6 function generateSearchEngineInfo() { |
| 7 var searchEngines0 = settings_search.createSampleSearchEngine( | 7 var searchEngines0 = settings_search.createSampleSearchEngine( |
| 8 true, false, false); | 8 true, false, false); |
| 9 searchEngines0.default = true; | 9 searchEngines0.default = true; |
| 10 var searchEngines1 = settings_search.createSampleSearchEngine( | 10 var searchEngines1 = settings_search.createSampleSearchEngine( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 Polymer.dom.flush(); | 66 Polymer.dom.flush(); |
| 67 assertEquals(2, selectElement.selectedIndex); | 67 assertEquals(2, selectElement.selectedIndex); |
| 68 | 68 |
| 69 browserProxy.whenCalled('setDefaultSearchEngine').then(function() { | 69 browserProxy.whenCalled('setDefaultSearchEngine').then(function() { |
| 70 // Since the change happened in a different tab, there should be no | 70 // Since the change happened in a different tab, there should be no |
| 71 // new call to |setDefaultSearchEngine|. | 71 // new call to |setDefaultSearchEngine|. |
| 72 assertNotReached('Should not call setDefaultSearchEngine again'); | 72 assertNotReached('Should not call setDefaultSearchEngine again'); |
| 73 }); | 73 }); |
| 74 }); | 74 }); |
| 75 }); | 75 }); |
| 76 | |
| 77 // Tests the UI when Hotword 'alwaysOn' is true. | |
| 78 test('HotwordAlwaysOn', function() { | |
| 79 return browserProxy.whenCalled('getHotwordInfo').then(function() { | |
| 80 Polymer.dom.flush(); | |
| 81 assertTrue(page.hotwordInfo_.allowed); | |
| 82 assertTrue(page.hotwordInfo_.alwaysOn); | |
| 83 assertFalse(page.hotwordInfo_.enabled); | |
| 84 assertFalse(browserProxy.hotwordSearchEnabled); | |
| 85 assertFalse(page.hotwordSearchEnablePref_.value); | |
| 86 | |
| 87 var checkbox = page.$$('#hotwordSearchEnable'); | |
| 88 assertTrue(!!checkbox); | |
| 89 assertFalse(checkbox.checked); | |
| 90 checkbox.checked = true; | |
| 91 // TODO(stevenjb): Investigate why 'MockInteractions.tap(checkbox)' | |
| 92 // does not fire a 'change' event. | |
| 93 checkbox.dispatchEvent(new CustomEvent('change')); | |
| 94 Polymer.dom.flush(); | |
| 95 return browserProxy.whenCalled('setHotwordSearchEnabled'); | |
| 96 }).then(function() { | |
| 97 assertTrue(browserProxy.hotwordSearchEnabled); | |
| 98 }); | |
| 99 }); | |
| 100 | |
| 101 // Tests the UI when Hotword 'alwaysOn' is false. | |
| 102 test('HotwordNotAlwaysOn', function() { | |
| 103 return browserProxy.whenCalled('getHotwordInfo').then(function() { | |
| 104 browserProxy.setHotwordInfo({ | |
| 105 allowed: true, | |
| 106 enabled: false, | |
| 107 alwaysOn: false, | |
| 108 errorMessage: '', | |
| 109 userName: '', | |
| 110 historyEnabled: false, | |
| 111 }); | |
| 112 Polymer.dom.flush(); | |
| 113 assertTrue(page.hotwordInfo_.allowed); | |
| 114 assertFalse(page.hotwordInfo_.alwaysOn); | |
| 115 assertFalse(page.hotwordInfo_.enabled); | |
| 116 | |
| 117 var checkbox = page.$$('#hotwordSearchEnable'); | |
| 118 assertTrue(!!checkbox); | |
| 119 assertFalse(checkbox.checked); | |
| 120 checkbox.checked = true; | |
| 121 // TODO(stevenjb): Investigate why 'MockInteractions.tap(checkbox)' | |
| 122 // does not fire a 'change' event. | |
|
michaelpg
2016/11/27 22:25:37
o_O There are some mock events that fire async, bu
stevenjb
2016/11/28 20:53:37
Yes, the checkbox is enabled. I'm not sure how to
| |
| 123 checkbox.dispatchEvent(new CustomEvent('change')); | |
| 124 Polymer.dom.flush(); | |
| 125 return browserProxy.whenCalled('setHotwordSearchEnabled'); | |
| 126 }).then(function() { | |
| 127 assertTrue(browserProxy.hotwordSearchEnabled); | |
| 128 }); | |
| 129 }); | |
| 76 }); | 130 }); |
| 77 } | 131 } |
| 78 | 132 |
| 79 return { | 133 return { |
| 80 registerTests: registerTests, | 134 registerTests: registerTests, |
| 81 }; | 135 }; |
| 82 }); | 136 }); |
| OLD | NEW |