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 cr.define('site_details', function() { | 6 cr.define('site_details', function() { |
7 function registerTests() { | 7 function registerTests() { |
8 suite('SiteDetails', function() { | 8 suite('SiteDetails', function() { |
9 /** | 9 /** |
10 * A site list element created before each test. | 10 * A site list element created before each test. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 setup(function() { | 102 setup(function() { |
103 PolymerTest.clearBody(); | 103 PolymerTest.clearBody(); |
104 testElement = document.createElement('site-details'); | 104 testElement = document.createElement('site-details'); |
105 document.body.appendChild(testElement); | 105 document.body.appendChild(testElement); |
106 }); | 106 }); |
107 | 107 |
108 test('empty state', function() { | 108 test('empty state', function() { |
109 testElement.prefs = prefsEmpty; | 109 testElement.prefs = prefsEmpty; |
110 testElement.origin = "http://www.google.com"; | 110 testElement.origin = "http://www.google.com"; |
111 | 111 |
112 // Once actual storage numbers are shown (instead of hard-coded), these | 112 assertTrue(testElement.$.usage.hidden); |
113 // two will become hidden by default. | 113 assertTrue(testElement.$.storage.hidden); |
114 assertFalse(testElement.$.usage.hidden); | |
115 assertFalse(testElement.$.storage.hidden); | |
116 | 114 |
117 // TODO(finnur): Check for the Permission heading hiding when no | 115 // TODO(finnur): Check for the Permission heading hiding when no |
118 // permissions are showing. | 116 // permissions are showing. |
119 | 117 |
120 var msg = 'No category should be showing, height'; | 118 var msg = 'No category should be showing, height'; |
121 assertEquals(0, testElement.$.camera.offsetHeight, msg); | 119 assertEquals(0, testElement.$.camera.offsetHeight, msg); |
122 assertEquals(0, testElement.$.cookies.offsetHeight, msg); | 120 assertEquals(0, testElement.$.cookies.offsetHeight, msg); |
123 assertEquals(0, testElement.$.fullscreen.offsetHeight, msg); | 121 assertEquals(0, testElement.$.fullscreen.offsetHeight, msg); |
124 assertEquals(0, testElement.$.geolocation.offsetHeight, msg); | 122 assertEquals(0, testElement.$.geolocation.offsetHeight, msg); |
125 assertEquals(0, testElement.$.javascript.offsetHeight, msg); | 123 assertEquals(0, testElement.$.javascript.offsetHeight, msg); |
126 assertEquals(0, testElement.$.mic.offsetHeight, msg); | 124 assertEquals(0, testElement.$.mic.offsetHeight, msg); |
127 assertEquals(0, testElement.$.notification.offsetHeight, msg); | 125 assertEquals(0, testElement.$.notification.offsetHeight, msg); |
128 assertEquals(0, testElement.$.popups.offsetHeight, msg); | 126 assertEquals(0, testElement.$.popups.offsetHeight, msg); |
129 }); | 127 }); |
130 | 128 |
131 test('all categories visible', function() { | 129 test('all categories visible', function() { |
132 testElement.prefs = prefs; | 130 testElement.prefs = prefs; |
133 testElement.origin = "https://foo-allow.com:443"; | 131 testElement.origin = "https://foo-allow.com:443"; |
134 | 132 |
135 var msg = 'All categories should be showing'; | 133 var msg = 'All categories should be showing'; |
136 assertNotEquals(0, testElement.$.camera.offsetHeight, msg); | 134 assertNotEquals(0, testElement.$.camera.offsetHeight, msg); |
137 assertNotEquals(0, testElement.$.cookies.offsetHeight, msg); | 135 assertNotEquals(0, testElement.$.cookies.offsetHeight, msg); |
138 assertNotEquals(0, testElement.$.fullscreen.offsetHeight, msg); | 136 assertNotEquals(0, testElement.$.fullscreen.offsetHeight, msg); |
139 assertNotEquals(0, testElement.$.geolocation.offsetHeight, msg); | 137 assertNotEquals(0, testElement.$.geolocation.offsetHeight, msg); |
140 assertNotEquals(0, testElement.$.javascript.offsetHeight, msg); | 138 assertNotEquals(0, testElement.$.javascript.offsetHeight, msg); |
141 assertNotEquals(0, testElement.$.mic.offsetHeight, msg); | 139 assertNotEquals(0, testElement.$.mic.offsetHeight, msg); |
142 assertNotEquals(0, testElement.$.notification.offsetHeight, msg); | 140 assertNotEquals(0, testElement.$.notification.offsetHeight, msg); |
143 assertNotEquals(0, testElement.$.popups.offsetHeight, msg); | 141 assertNotEquals(0, testElement.$.popups.offsetHeight, msg); |
144 }); | 142 }); |
143 | |
144 test('usage heading shows on storage available', function() { | |
145 // Remove the current website-usage-private-api element. | |
146 var parent = testElement.$.usageApi.parentNode; | |
michaelpg
2016/01/25 18:33:54
see Element.prototype.remove
Finnur
2016/01/26 15:54:54
Done.
michaelpg
2016/01/27 06:37:46
Sorry, that was silly of me: i meant that the node
Finnur
2016/01/27 10:27:26
Done.
| |
147 Polymer.dom(parent).removeChild(testElement.$.usageApi); | |
148 | |
149 // Replace it with a mock version. | |
150 Polymer({ | |
151 is:"mock-website-usage-private-api", | |
michaelpg
2016/01/25 18:33:54
use single quotes in JS, here & below
michaelpg
2016/01/25 18:33:54
space
Finnur
2016/01/26 15:54:54
Done. Here & below & above. :)
| |
152 fetchUsageTotal: function(origin) { | |
153 testElement.storedData_ = '1 KB'; | |
154 }, | |
155 }); | |
156 var api = document.createElement("mock-website-usage-private-api"); | |
157 testElement.$['usageApi'] = api; | |
michaelpg
2016/01/25 18:33:54
$.usageApi
Finnur
2016/01/26 15:54:54
Done.
| |
158 Polymer.dom(parent).appendChild(api); | |
159 | |
160 testElement.prefs = prefs; | |
161 testElement.origin = "https://foo-allow.com:443"; | |
162 | |
163 assertFalse(testElement.$.usage.hidden); | |
164 assertFalse(testElement.$.storage.hidden); | |
165 }); | |
145 }); | 166 }); |
146 } | 167 } |
147 return { | 168 return { |
148 registerTests: registerTests, | 169 registerTests: registerTests, |
149 }; | 170 }; |
150 }); | 171 }); |
OLD | NEW |