Index: chrome/test/data/webui/settings/site_settings_category_tests.js |
diff --git a/chrome/test/data/webui/settings/site_settings_category_tests.js b/chrome/test/data/webui/settings/site_settings_category_tests.js |
index 230ca937d7c76cf28c53897f1af44a91198aad2e..01a7583aaec18da34ab5002e3a2b32898fcf9472 100644 |
--- a/chrome/test/data/webui/settings/site_settings_category_tests.js |
+++ b/chrome/test/data/webui/settings/site_settings_category_tests.js |
@@ -59,23 +59,6 @@ cr.define('site_settings_category', function() { |
document.body.appendChild(testElement); |
}); |
- /** |
- * Returns a promise that resolves once the selected item is updated. |
- * @param {function()} action is executed after the listener is set up. |
- * @return {!Promise} a Promise fulfilled when the selected item changes. |
- */ |
- function runAndResolveWhenCategoryEnabledChanged(action) { |
- return new Promise(function(resolve, reject) { |
- var handler = function() { |
- testElement.removeEventListener( |
- 'category-enabled-changed', handler); |
- resolve(); |
- }; |
- testElement.addEventListener('category-enabled-changed', handler); |
- action(); |
- }); |
- } |
- |
test('getDefaultValueForContentType API used', function() { |
testElement.category = settings.ContentSettingsTypes.GEOLOCATION; |
return browserProxy.whenCalled('getDefaultValueForContentType').then( |
@@ -86,30 +69,46 @@ cr.define('site_settings_category', function() { |
}); |
test('categoryEnabled correctly represents prefs (enabled)', function() { |
- return runAndResolveWhenCategoryEnabledChanged(function() { |
- browserProxy.setPrefs(prefsLocationEnabled); |
- testElement.category = settings.ContentSettingsTypes.GEOLOCATION; |
- }).then(function() { |
- assertTrue(testElement.categoryEnabled); |
- MockInteractions.tap(testElement.$.toggle); |
- assertFalse(testElement.categoryEnabled); |
- }); |
+ browserProxy.setPrefs(prefsLocationEnabled); |
+ testElement.category = settings.ContentSettingsTypes.GEOLOCATION; |
+ return browserProxy.whenCalled('getDefaultValueForContentType').then( |
+ function(contentType) { |
+ assertEquals( |
+ settings.ContentSettingsTypes.GEOLOCATION, contentType); |
+ assertTrue(testElement.categoryEnabled); |
+ MockInteractions.tap(testElement.$.toggle); |
+ return browserProxy.whenCalled( |
+ 'setDefaultValueForContentType').then( |
+ function(arguments) { |
+ assertEquals( |
+ settings.ContentSettingsTypes.GEOLOCATION, arguments[0]); |
+ assertEquals( |
+ settings.PermissionValues.BLOCK, arguments[1]); |
+ assertFalse(testElement.categoryEnabled); |
+ }); |
+ }); |
}); |
test('categoryEnabled correctly represents prefs (disabled)', function() { |
- // In order for the 'change' event to trigger, the value monitored needs |
- // to actually change (the event is not sent otherwise). Therefore, |
- // ensure the initial state of enabledness is opposite of what we expect |
- // it to end at. |
- testElement.categoryEnabled = true; |
- return runAndResolveWhenCategoryEnabledChanged(function() { |
- browserProxy.setPrefs(prefsLocationDisabled); |
- testElement.category = settings.ContentSettingsTypes.GEOLOCATION; |
- }).then(function() { |
- assertFalse(testElement.categoryEnabled); |
- MockInteractions.tap(testElement.$.toggle); |
- assertTrue(testElement.categoryEnabled); |
- }); |
+ browserProxy.setPrefs(prefsLocationDisabled); |
dpapad
2016/03/31 17:37:07
This test is identical to the previous one with th
Finnur
2016/04/04 13:59:24
Good catch. It got really scary, though, while I w
|
+ testElement.category = settings.ContentSettingsTypes.GEOLOCATION; |
+ return browserProxy.whenCalled('getDefaultValueForContentType').then( |
+ function(contentType) { |
+ assertEquals( |
+ settings.ContentSettingsTypes.GEOLOCATION, contentType); |
+ assertFalse(testElement.categoryEnabled); |
+ MockInteractions.tap(testElement.$.toggle); |
+ return browserProxy.whenCalled( |
+ 'setDefaultValueForContentType').then( |
+ function(arguments) { |
+ assertEquals( |
+ settings.ContentSettingsTypes.GEOLOCATION, arguments[0]); |
+ assertEquals( |
+ settings.PermissionValues.ASK, arguments[1]); |
+ assertTrue(testElement.categoryEnabled); |
+ }); |
+ }); |
+ |
}); |
test('basic category tests', function() { |