OLD | NEW |
1 // Copyright 2015 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 /** @fileoverview Suite of tests for site-settings-category. */ | 5 /** @fileoverview Suite of tests for category-default-setting. */ |
6 cr.define('site_settings_category', function() { | 6 cr.define('category_default_setting', function() { |
7 function registerTests() { | 7 function registerTests() { |
8 suite('SiteSettingsCategory', function() { | 8 suite('CategoryDefaultSetting', function() { |
9 /** | 9 /** |
10 * A site settings category created before each test. | 10 * A site settings category created before each test. |
11 * @type {SiteSettingsCategory} | 11 * @type {SiteSettingsCategory} |
12 */ | 12 */ |
13 var testElement; | 13 var testElement; |
14 | 14 |
15 /** | 15 /** |
16 * The mock proxy object to use during test. | 16 * The mock proxy object to use during test. |
17 * @type {TestSiteSettingsPrefsBrowserProxy} | 17 * @type {TestSiteSettingsPrefsBrowserProxy} |
18 */ | 18 */ |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 }, | 73 }, |
74 }, | 74 }, |
75 exceptions: { | 75 exceptions: { |
76 cookies: [], | 76 cookies: [], |
77 }, | 77 }, |
78 }; | 78 }; |
79 | 79 |
80 // Import necessary html before running suite. | 80 // Import necessary html before running suite. |
81 suiteSetup(function() { | 81 suiteSetup(function() { |
82 return PolymerTest.importHtml( | 82 return PolymerTest.importHtml( |
83 'chrome://md-settings/site_settings/site_settings_category.html'); | 83 'chrome://md-settings/site_settings/category_default_setting.html'); |
84 }); | 84 }); |
85 | 85 |
86 // Initialize a site-settings-category before each test. | 86 // Initialize a site-settings-category before each test. |
87 setup(function() { | 87 setup(function() { |
88 browserProxy = new TestSiteSettingsPrefsBrowserProxy(); | 88 browserProxy = new TestSiteSettingsPrefsBrowserProxy(); |
89 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy; | 89 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy; |
90 PolymerTest.clearBody(); | 90 PolymerTest.clearBody(); |
91 testElement = document.createElement('site-settings-category'); | 91 testElement = document.createElement('category-default-setting'); |
| 92 testElement.subOptionLabel = "test label"; |
92 document.body.appendChild(testElement); | 93 document.body.appendChild(testElement); |
93 }); | 94 }); |
94 | 95 |
95 test('getDefaultValueForContentType API used', function() { | 96 test('getDefaultValueForContentType API used', function() { |
96 testElement.category = settings.ContentSettingsTypes.GEOLOCATION; | 97 testElement.category = settings.ContentSettingsTypes.GEOLOCATION; |
97 return browserProxy.whenCalled('getDefaultValueForContentType').then( | 98 return browserProxy.whenCalled('getDefaultValueForContentType').then( |
98 function(contentType) { | 99 function(contentType) { |
99 assertEquals( | 100 assertEquals( |
100 settings.ContentSettingsTypes.GEOLOCATION, contentType); | 101 settings.ContentSettingsTypes.GEOLOCATION, contentType); |
101 }); | 102 }); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 function testTristateCategory(prefs, category, thirdState, | 180 function testTristateCategory(prefs, category, thirdState, |
180 secondaryToggleId) { | 181 secondaryToggleId) { |
181 browserProxy.setPrefs(prefs); | 182 browserProxy.setPrefs(prefs); |
182 | 183 |
183 testElement.category = category; | 184 testElement.category = category; |
184 var secondaryToggle = null; | 185 var secondaryToggle = null; |
185 | 186 |
186 return browserProxy.whenCalled('getDefaultValueForContentType').then( | 187 return browserProxy.whenCalled('getDefaultValueForContentType').then( |
187 function(contentType) { | 188 function(contentType) { |
188 Polymer.dom.flush(); | 189 Polymer.dom.flush(); |
189 | |
190 secondaryToggle = testElement.$$(secondaryToggleId); | 190 secondaryToggle = testElement.$$(secondaryToggleId); |
191 assertTrue(!!secondaryToggle); | 191 assertTrue(!!secondaryToggle); |
192 | 192 |
193 assertEquals(category, contentType); | 193 assertEquals(category, contentType); |
194 assertTrue(testElement.categoryEnabled); | 194 assertTrue(testElement.categoryEnabled); |
195 assertFalse(secondaryToggle.disabled); | 195 assertFalse(secondaryToggle.disabled); |
196 assertTrue(secondaryToggle.checked); | 196 assertTrue(secondaryToggle.checked); |
197 | 197 |
198 MockInteractions.tap(testElement.$.toggle); | 198 MockInteractions.tap(testElement.$.toggle); |
199 return browserProxy.whenCalled('setDefaultValueForContentType'); | 199 return browserProxy.whenCalled('setDefaultValueForContentType'); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 assertEquals(thirdState, args[1]); | 271 assertEquals(thirdState, args[1]); |
272 assertTrue(testElement.categoryEnabled); | 272 assertTrue(testElement.categoryEnabled); |
273 assertFalse(secondaryToggle.disabled); | 273 assertFalse(secondaryToggle.disabled); |
274 assertTrue(secondaryToggle.checked); | 274 assertTrue(secondaryToggle.checked); |
275 }); | 275 }); |
276 } | 276 } |
277 | 277 |
278 test('test special tri-state Flash category', function() { | 278 test('test special tri-state Flash category', function() { |
279 return testTristateCategory( | 279 return testTristateCategory( |
280 prefsFlashDetect, settings.ContentSettingsTypes.PLUGINS, | 280 prefsFlashDetect, settings.ContentSettingsTypes.PLUGINS, |
281 settings.PermissionValues.IMPORTANT_CONTENT, '#flashAskToggle'); | 281 settings.PermissionValues.IMPORTANT_CONTENT, '#subOptionToggle'); |
282 }); | 282 }); |
283 | 283 |
284 test('test special tri-state Cookies category', function() { | 284 test('test special tri-state Cookies category', function() { |
285 return testTristateCategory( | 285 return testTristateCategory( |
286 prefsCookesSessionOnly, settings.ContentSettingsTypes.COOKIES, | 286 prefsCookesSessionOnly, settings.ContentSettingsTypes.COOKIES, |
287 settings.PermissionValues.SESSION_ONLY, '#sessionOnlyToggle'); | 287 settings.PermissionValues.SESSION_ONLY, '#subOptionToggle'); |
288 }); | 288 }); |
289 }); | 289 }); |
290 } | 290 } |
291 | 291 |
292 return { | 292 return { |
293 registerTests: registerTests, | 293 registerTests: registerTests, |
294 }; | 294 }; |
295 }); | 295 }); |
OLD | NEW |