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 function MockUsageHandler(element) { | |
6 this.testElement = element; | |
7 } | |
8 | |
9 MockUsageHandler.prototype.fetchUsageTotal = function(origin) { | |
10 this.testElement.$.storedData_ = '1 KB'; | |
11 }; | |
Finnur
2016/01/22 15:52:15
This is purely here to facilitate discussion. I ra
Finnur
2016/01/25 11:19:16
Ignore the comment above, this code is obsolete.
| |
12 | |
5 /** @fileoverview Suite of tests for site-details. */ | 13 /** @fileoverview Suite of tests for site-details. */ |
6 cr.define('site_details', function() { | 14 cr.define('site_details', function() { |
7 function registerTests() { | 15 function registerTests() { |
8 suite('SiteDetails', function() { | 16 suite('SiteDetails', function() { |
9 /** | 17 /** |
10 * A site list element created before each test. | 18 * A site list element created before each test. |
11 * @type {SiteDetails} | 19 * @type {SiteDetails} |
12 */ | 20 */ |
13 var testElement; | 21 var testElement; |
14 | 22 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 setup(function() { | 110 setup(function() { |
103 PolymerTest.clearBody(); | 111 PolymerTest.clearBody(); |
104 testElement = document.createElement('site-details'); | 112 testElement = document.createElement('site-details'); |
105 document.body.appendChild(testElement); | 113 document.body.appendChild(testElement); |
106 }); | 114 }); |
107 | 115 |
108 test('empty state', function() { | 116 test('empty state', function() { |
109 testElement.prefs = prefsEmpty; | 117 testElement.prefs = prefsEmpty; |
110 testElement.origin = "http://www.google.com"; | 118 testElement.origin = "http://www.google.com"; |
111 | 119 |
112 // Once actual storage numbers are shown (instead of hard-coded), these | 120 assertTrue(testElement.$.usage.hidden); |
113 // two will become hidden by default. | 121 assertTrue(testElement.$.storage.hidden); |
114 assertFalse(testElement.$.usage.hidden); | |
115 assertFalse(testElement.$.storage.hidden); | |
116 | 122 |
117 // TODO(finnur): Check for the Permission heading hiding when no | 123 // TODO(finnur): Check for the Permission heading hiding when no |
118 // permissions are showing. | 124 // permissions are showing. |
119 | 125 |
120 var msg = 'No category should be showing, height'; | 126 var msg = 'No category should be showing, height'; |
121 assertEquals(0, testElement.$.camera.offsetHeight, msg); | 127 assertEquals(0, testElement.$.camera.offsetHeight, msg); |
122 assertEquals(0, testElement.$.cookies.offsetHeight, msg); | 128 assertEquals(0, testElement.$.cookies.offsetHeight, msg); |
123 assertEquals(0, testElement.$.fullscreen.offsetHeight, msg); | 129 assertEquals(0, testElement.$.fullscreen.offsetHeight, msg); |
124 assertEquals(0, testElement.$.geolocation.offsetHeight, msg); | 130 assertEquals(0, testElement.$.geolocation.offsetHeight, msg); |
125 assertEquals(0, testElement.$.javascript.offsetHeight, msg); | 131 assertEquals(0, testElement.$.javascript.offsetHeight, msg); |
126 assertEquals(0, testElement.$.mic.offsetHeight, msg); | 132 assertEquals(0, testElement.$.mic.offsetHeight, msg); |
127 assertEquals(0, testElement.$.notification.offsetHeight, msg); | 133 assertEquals(0, testElement.$.notification.offsetHeight, msg); |
128 assertEquals(0, testElement.$.popups.offsetHeight, msg); | 134 assertEquals(0, testElement.$.popups.offsetHeight, msg); |
129 }); | 135 }); |
130 | 136 |
131 test('all categories visible', function() { | 137 test('all categories visible', function() { |
132 testElement.prefs = prefs; | 138 testElement.prefs = prefs; |
133 testElement.origin = "https://foo-allow.com:443"; | 139 testElement.origin = "https://foo-allow.com:443"; |
134 | 140 |
135 var msg = 'All categories should be showing'; | 141 var msg = 'All categories should be showing'; |
136 assertNotEquals(0, testElement.$.camera.offsetHeight, msg); | 142 assertNotEquals(0, testElement.$.camera.offsetHeight, msg); |
137 assertNotEquals(0, testElement.$.cookies.offsetHeight, msg); | 143 assertNotEquals(0, testElement.$.cookies.offsetHeight, msg); |
138 assertNotEquals(0, testElement.$.fullscreen.offsetHeight, msg); | 144 assertNotEquals(0, testElement.$.fullscreen.offsetHeight, msg); |
139 assertNotEquals(0, testElement.$.geolocation.offsetHeight, msg); | 145 assertNotEquals(0, testElement.$.geolocation.offsetHeight, msg); |
140 assertNotEquals(0, testElement.$.javascript.offsetHeight, msg); | 146 assertNotEquals(0, testElement.$.javascript.offsetHeight, msg); |
141 assertNotEquals(0, testElement.$.mic.offsetHeight, msg); | 147 assertNotEquals(0, testElement.$.mic.offsetHeight, msg); |
142 assertNotEquals(0, testElement.$.notification.offsetHeight, msg); | 148 assertNotEquals(0, testElement.$.notification.offsetHeight, msg); |
143 assertNotEquals(0, testElement.$.popups.offsetHeight, msg); | 149 assertNotEquals(0, testElement.$.popups.offsetHeight, msg); |
144 }); | 150 }); |
151 | |
152 test('usage heading shows on storage available', function() { | |
153 testElement.$.usageApi = new MockUsageHandler(testElement); | |
154 testElement.prefs = prefs; | |
155 testElement.origin = "https://foo-allow.com:443"; | |
156 Polymer.dom.flush(); | |
157 | |
158 assertFalse(testElement.$.usage.hidden); | |
159 assertFalse(testElement.$.storage.hidden); | |
160 }); | |
145 }); | 161 }); |
146 } | 162 } |
147 return { | 163 return { |
148 registerTests: registerTests, | 164 registerTests: registerTests, |
149 }; | 165 }; |
150 }); | 166 }); |
OLD | NEW |