| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** @fileoverview Suite of tests for settings-toggle-button. */ | 5 /** @fileoverview Suite of tests for settings-toggle-button. */ |
| 6 cr.define('settings_toggle_button', function() { | 6 cr.define('settings_toggle_button', function() { |
| 7 function registerTests() { | 7 function registerTests() { |
| 8 suite('SettingsToggleButton', function() { | 8 suite('SettingsToggleButton', function() { |
| 9 /** | 9 /** |
| 10 * Toggle button created before each test. | 10 * Toggle button created before each test. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 assertEquals(1, prefNum.value); | 103 assertEquals(1, prefNum.value); |
| 104 }); | 104 }); |
| 105 | 105 |
| 106 test('numerical pref with custom values', function() { | 106 test('numerical pref with custom values', function() { |
| 107 var prefNum = { | 107 var prefNum = { |
| 108 key: 'test', | 108 key: 'test', |
| 109 type: chrome.settingsPrivate.PrefType.NUMBER, | 109 type: chrome.settingsPrivate.PrefType.NUMBER, |
| 110 value: 5 | 110 value: 5 |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 testElement._setNumericUncheckedValue(5); | 113 testElement.numericUncheckedValue = 5; |
| 114 | 114 |
| 115 testElement.set('pref', prefNum); | 115 testElement.set('pref', prefNum); |
| 116 assertFalse(testElement.checked); | 116 assertFalse(testElement.checked); |
| 117 | 117 |
| 118 MockInteractions.tap(testElement.$.control); | 118 MockInteractions.tap(testElement.$.control); |
| 119 assertTrue(testElement.checked); | 119 assertTrue(testElement.checked); |
| 120 assertEquals(1, prefNum.value); | 120 assertEquals(1, prefNum.value); |
| 121 | 121 |
| 122 MockInteractions.tap(testElement.$.control); | 122 MockInteractions.tap(testElement.$.control); |
| 123 assertFalse(testElement.checked); | 123 assertFalse(testElement.checked); |
| 124 assertEquals(5, prefNum.value); | 124 assertEquals(5, prefNum.value); |
| 125 }); | 125 }); |
| 126 | 126 |
| 127 test('numerical pref with unknown inital value', function() { | 127 test('numerical pref with unknown inital value', function() { |
| 128 prefNum = { | 128 prefNum = { |
| 129 key: 'test', | 129 key: 'test', |
| 130 type: chrome.settingsPrivate.PrefType.NUMBER, | 130 type: chrome.settingsPrivate.PrefType.NUMBER, |
| 131 value: 3 | 131 value: 3 |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 testElement._setNumericUncheckedValue(5); | 134 testElement.numericUncheckedValue = 5; |
| 135 | 135 |
| 136 testElement.set('pref', prefNum); | 136 testElement.set('pref', prefNum); |
| 137 | 137 |
| 138 // Unknown value should still count as checked. | 138 // Unknown value should still count as checked. |
| 139 assertTrue(testElement.checked); | 139 assertTrue(testElement.checked); |
| 140 | 140 |
| 141 // The control should not clobber an existing unknown value. | 141 // The control should not clobber an existing unknown value. |
| 142 assertEquals(3, prefNum.value); | 142 assertEquals(3, prefNum.value); |
| 143 | 143 |
| 144 // Unchecking should still send the unchecked value to prefs. | 144 // Unchecking should still send the unchecked value to prefs. |
| 145 MockInteractions.tap(testElement.$.control); | 145 MockInteractions.tap(testElement.$.control); |
| 146 assertFalse(testElement.checked); | 146 assertFalse(testElement.checked); |
| 147 assertEquals(5, prefNum.value); | 147 assertEquals(5, prefNum.value); |
| 148 | 148 |
| 149 // Checking should still send the normal checked value to prefs. | 149 // Checking should still send the normal checked value to prefs. |
| 150 MockInteractions.tap(testElement.$.control); | 150 MockInteractions.tap(testElement.$.control); |
| 151 assertTrue(testElement.checked); | 151 assertTrue(testElement.checked); |
| 152 assertEquals(1, prefNum.value); | 152 assertEquals(1, prefNum.value); |
| 153 }); | 153 }); |
| 154 }); | 154 }); |
| 155 } | 155 } |
| 156 | 156 |
| 157 return { | 157 return { |
| 158 registerTests: registerTests, | 158 registerTests: registerTests, |
| 159 }; | 159 }; |
| 160 }); | 160 }); |
| OLD | NEW |