Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: chrome/test/data/webui/settings/settings_toggle_button_tests.js

Issue 2681373002: MD Settings: Fix the Network Prediction toggle box. (Closed)
Patch Set: fix comment Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 assertTrue(testElement.checked); 87 assertTrue(testElement.checked);
88 88
89 testElement.removeAttribute('checked'); 89 testElement.removeAttribute('checked');
90 assertFalse(testElement.checked); 90 assertFalse(testElement.checked);
91 assertEquals(0, prefNum.value); 91 assertEquals(0, prefNum.value);
92 92
93 testElement.setAttribute('checked', ''); 93 testElement.setAttribute('checked', '');
94 assertTrue(testElement.checked); 94 assertTrue(testElement.checked);
95 assertEquals(1, prefNum.value); 95 assertEquals(1, prefNum.value);
96 }); 96 });
97
98 test('numerical pref with custom values', function() {
99 var prefNum = {
100 key: 'test',
101 type: chrome.settingsPrivate.PrefType.NUMBER,
102 value: 1
103 };
104
105 testElement.numericUncheckedValue = 1;
106 testElement.numericCheckedValue = 4;
107
108 testElement.set('pref', prefNum);
109 assertFalse(testElement.checked);
110
111 testElement.setAttribute('checked', '');
112 assertTrue(testElement.checked);
113 assertEquals(4, prefNum.value);
114
115 testElement.removeAttribute('checked');
116 assertFalse(testElement.checked);
117 assertEquals(1, prefNum.value);
118 });
119
120 test('numerical pref with unknown inital value', function() {
121 prefNum = {
122 key: 'test',
123 type: chrome.settingsPrivate.PrefType.NUMBER,
124 value: 2
125 };
126
127 testElement.numericUncheckedValue = 1;
128 testElement.numericCheckedValue = 4;
129
130 testElement.set('pref', prefNum);
131
132 // Unknown value should still count as checked.
133 assertTrue(testElement.checked);
134
135 // The control should not clobber an existing unknown value.
136 assertEquals(2, prefNum.value);
137
138 // Unchecking should still send the unchecked value to prefs.
139 testElement.removeAttribute('checked');
140 assertFalse(testElement.checked);
141 assertEquals(1, prefNum.value);
142
143 // Checking should still send the checked value to prefs.
144 testElement.setAttribute('checked', '');
145 assertTrue(testElement.checked);
146 assertEquals(4, prefNum.value);
147 });
97 }); 148 });
98 } 149 }
99 150
100 return { 151 return {
101 registerTests: registerTests, 152 registerTests: registerTests,
102 }; 153 };
103 }); 154 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698