| 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 site-details. */ | 5 /** @fileoverview Suite of tests for site-details. */ |
| 6 suite('SiteDetails', function() { | 6 suite('SiteDetails', function() { |
| 7 /** | 7 /** |
| 8 * A site list element created before each test. | 8 * A site list element created before each test. |
| 9 * @type {SiteDetails} | 9 * @type {SiteDetails} |
| 10 */ | 10 */ |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 // Initialize a site-details before each test. | 109 // Initialize a site-details before each test. |
| 110 setup(function() { | 110 setup(function() { |
| 111 browserProxy = new TestSiteSettingsPrefsBrowserProxy(); | 111 browserProxy = new TestSiteSettingsPrefsBrowserProxy(); |
| 112 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy; | 112 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy; |
| 113 PolymerTest.clearBody(); | 113 PolymerTest.clearBody(); |
| 114 testElement = document.createElement('site-details'); | 114 testElement = document.createElement('site-details'); |
| 115 document.body.appendChild(testElement); | 115 document.body.appendChild(testElement); |
| 116 }); | 116 }); |
| 117 | 117 |
| 118 test('empty state', function() { | |
| 119 var category = settings.ContentSettingsTypes.NOTIFICATIONS; | |
| 120 var site = { | |
| 121 origin: 'http://www.google.com', | |
| 122 displayName: 'http://www.google.com', | |
| 123 embeddingOrigin: '', | |
| 124 }; | |
| 125 browserProxy.setPrefs(prefsEmpty); | |
| 126 testElement.category = category; | |
| 127 testElement.site = site | |
| 128 | |
| 129 // expect usage to not be rendered | |
| 130 assertFalse(!!testElement.$$('#usage')); | |
| 131 | |
| 132 // TODO(finnur): Check for the Permission heading hiding when no | |
| 133 // permissions are showing. | |
| 134 | |
| 135 var msg = 'No category should be showing, height'; | |
| 136 assertEquals(0, testElement.$.camera.offsetHeight, msg); | |
| 137 assertEquals(0, testElement.$.cookies.offsetHeight, msg); | |
| 138 assertEquals(0, testElement.$.geolocation.offsetHeight, msg); | |
| 139 assertEquals(0, testElement.$.javascript.offsetHeight, msg); | |
| 140 assertEquals(0, testElement.$.mic.offsetHeight, msg); | |
| 141 assertEquals(0, testElement.$.notification.offsetHeight, msg); | |
| 142 assertEquals(0, testElement.$.popups.offsetHeight, msg); | |
| 143 }); | |
| 144 | |
| 145 test('all categories visible', function() { | |
| 146 var category = settings.ContentSettingsTypes.NOTIFICATIONS; | |
| 147 var site = { | |
| 148 origin: 'https://foo-allow.com:443', | |
| 149 displayName: 'https://foo-allow.com:443', | |
| 150 embeddingOrigin: '', | |
| 151 }; | |
| 152 | |
| 153 browserProxy.setPrefs(prefs); | |
| 154 testElement.category = category; | |
| 155 testElement.site = site; | |
| 156 | |
| 157 var msg = 'All categories should be showing'; | |
| 158 assertFalse(testElement.$.camera.hidden, msg); | |
| 159 assertFalse(testElement.$.cookies.hidden, msg); | |
| 160 assertFalse(testElement.$.geolocation.hidden, msg); | |
| 161 assertFalse(testElement.$.javascript.hidden, msg); | |
| 162 assertFalse(testElement.$.mic.hidden, msg); | |
| 163 assertFalse(testElement.$.notification.hidden, msg); | |
| 164 assertFalse(testElement.$.popups.hidden, msg); | |
| 165 }); | |
| 166 | |
| 167 test('usage heading shows on storage available', function() { | 118 test('usage heading shows on storage available', function() { |
| 168 // Remove the current website-usage-private-api element. | 119 // Remove the current website-usage-private-api element. |
| 169 var parent = testElement.$.usageApi.parentNode; | 120 var parent = testElement.$.usageApi.parentNode; |
| 170 testElement.$.usageApi.remove(); | 121 testElement.$.usageApi.remove(); |
| 171 | 122 |
| 172 // Replace it with a mock version. | 123 // Replace it with a mock version. |
| 173 Polymer({ | 124 Polymer({ |
| 174 is: 'mock-website-usage-private-api', | 125 is: 'mock-website-usage-private-api', |
| 175 | 126 |
| 176 fetchUsageTotal: function(origin) { | 127 fetchUsageTotal: function(origin) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 187 displayName: 'https://foo-allow.com:443', | 138 displayName: 'https://foo-allow.com:443', |
| 188 embeddingOrigin: '', | 139 embeddingOrigin: '', |
| 189 }; | 140 }; |
| 190 | 141 |
| 191 Polymer.dom.flush(); | 142 Polymer.dom.flush(); |
| 192 | 143 |
| 193 // expect usage to be rendered | 144 // expect usage to be rendered |
| 194 assertTrue(!!testElement.$$('#usage')); | 145 assertTrue(!!testElement.$$('#usage')); |
| 195 }); | 146 }); |
| 196 }); | 147 }); |
| OLD | NEW |