Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
| 6 * TestFixture for testing the formatting of settings pages. | 6 * TestFixture for testing the formatting of settings pages. |
| 7 * @extends {testing.Test} | 7 * @extends {testing.Test} |
| 8 * @constructor | 8 * @constructor |
| 9 */ | 9 */ |
| 10 function SettingsFormatWebUITest() {} | 10 function SettingsFormatWebUITest() {} |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * Map of rule exemptions grouped by test. | 13 * Map of rule exemptions grouped by test. |
| 14 * @const | 14 * @const |
| 15 */ | 15 */ |
| 16 SettingsFormatWebUITest.Filters = { | 16 SettingsFormatWebUITest.Filters = { |
| 17 /** | 17 /** |
| 18 * Exemption for checkboxes that do not require an id or pref property. | 18 * Exemption for checkboxes that do not require an id or pref property. |
| 19 * Input methods use inputMethodId instead of id for unique identification. | 19 * Input methods use inputMethodId instead of id for unique identification. |
| 20 */ | 20 */ |
| 21 'pref': ['language-options-input-method-template', | 21 'pref': ['language-options-input-method-template', |
| 22 'language-options-input-method-list'] | 22 'language-options-input-method-list'], |
| 23 /** | |
| 24 * Exemption for checkboxes or radio buttons that do not require the class | |
| 25 * 'checkbox' or 'radio'. | |
| 26 * The About overlay comes from the About page and uses a different style. | |
| 27 */ | |
| 28 'style': ['channel-change-page-beta-option', | |
| 29 'channel-change-page-dev-option', | |
| 30 'channel-change-page-stable-option'], | |
|
Dan Beam
2014/08/13 17:03:18
eh, just change the CSS like you did
michaelpg
2014/08/13 20:17:51
Done.
| |
| 23 }; | 31 }; |
| 24 | 32 |
| 25 /** | 33 /** |
| 26 * Collection of error messages. | 34 * Collection of error messages. |
| 27 * @const | 35 * @const |
| 28 */ | 36 */ |
| 29 SettingsFormatWebUITest.Messages = { | 37 SettingsFormatWebUITest.Messages = { |
| 30 MISSING_CHECK_WRAPPER: 'Element $1 should be enclosed in <div class="$2">', | 38 MISSING_CHECK_WRAPPER: 'Element $1 should be enclosed in <div class="$2">', |
| 31 MISSING_ID_OR_PREF: 'Missing id or pref preoperty for checkbox $1.', | 39 MISSING_ID_OR_PREF: 'Missing id or pref preoperty for checkbox $1.', |
| 32 MISSING_RADIO_BUTTON_NAME: 'Radio button $1 is missing the name property', | 40 MISSING_RADIO_BUTTON_NAME: 'Radio button $1 is missing the name property', |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 * Ensure that radio and checkbox buttons have consistent layout. | 124 * Ensure that radio and checkbox buttons have consistent layout. |
| 117 */ | 125 */ |
| 118 TEST_F('SettingsFormatWebUITest', 'RadioCheckboxStyleCheck', function() { | 126 TEST_F('SettingsFormatWebUITest', 'RadioCheckboxStyleCheck', function() { |
| 119 var settings = $('settings'); | 127 var settings = $('settings'); |
| 120 assertTrue(settings != null, 'Unable to access settings'); | 128 assertTrue(settings != null, 'Unable to access settings'); |
| 121 var query = 'input[type=checkbox], input[type=radio]'; | 129 var query = 'input[type=checkbox], input[type=radio]'; |
| 122 var elements = document.querySelectorAll(query); | 130 var elements = document.querySelectorAll(query); |
| 123 assertTrue(elements.length > 0); | 131 assertTrue(elements.length > 0); |
| 124 for (var i = 0; i < elements.length; i++) { | 132 for (var i = 0; i < elements.length; i++) { |
| 125 var element = elements[i]; | 133 var element = elements[i]; |
| 126 if (!findAncestorByClass(element, element.type)) | 134 if (!this.isExempt(element, SettingsFormatWebUITest.Filters['style']) && |
| 135 !findAncestorByClass(element, element.type)) { | |
| 127 this.fail('MISSING_CHECK_WRAPPER', element, element.type); | 136 this.fail('MISSING_CHECK_WRAPPER', element, element.type); |
| 137 } | |
| 128 } | 138 } |
| 129 }); | 139 }); |
| 130 | 140 |
| 131 /** | 141 /** |
| 132 * Each checkbox requires an id or pref property. | 142 * Each checkbox requires an id or pref property. |
| 133 */ | 143 */ |
| 134 TEST_F('SettingsFormatWebUITest', 'CheckboxIdOrPrefCheck', function() { | 144 TEST_F('SettingsFormatWebUITest', 'CheckboxIdOrPrefCheck', function() { |
| 135 var query = 'input[type=checkbox]:not([pref]):not([id])'; | 145 var query = 'input[type=checkbox]:not([pref]):not([id])'; |
| 136 var elements = document.querySelectorAll(query); | 146 var elements = document.querySelectorAll(query); |
| 137 for (var i = 0; i < elements.length; i++) { | 147 for (var i = 0; i < elements.length; i++) { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 148 var elements = document.querySelectorAll('input[type=radio]'); | 158 var elements = document.querySelectorAll('input[type=radio]'); |
| 149 for (var i = 0; i < elements.length; i++) { | 159 for (var i = 0; i < elements.length; i++) { |
| 150 var element = elements[i]; | 160 var element = elements[i]; |
| 151 if (!element.name) | 161 if (!element.name) |
| 152 this.fail('MISSING_RADIO_BUTTON_NAME', element); | 162 this.fail('MISSING_RADIO_BUTTON_NAME', element); |
| 153 | 163 |
| 154 if (!element.getAttribute('value')) | 164 if (!element.getAttribute('value')) |
| 155 this.fail('MISSING_RADIO_BUTTON_VALUE', element); | 165 this.fail('MISSING_RADIO_BUTTON_VALUE', element); |
| 156 } | 166 } |
| 157 }); | 167 }); |
| OLD | NEW |