| OLD | NEW |
| 1 // Copyright 2016 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 suite('metrics reporting', function() { | 5 suite('metrics reporting', function() { |
| 6 /** @type {settings.TestPrivacyPageBrowserProxy} */ | 6 /** @type {settings.TestPrivacyPageBrowserProxy} */ |
| 7 var testBrowserProxy; | 7 var testBrowserProxy; |
| 8 | 8 |
| 9 /** @type {SettingsPrivacyPageElement} */ | 9 /** @type {SettingsPrivacyPageElement} */ |
| 10 var page; | 10 var page; |
| 11 | 11 |
| 12 setup(function() { | 12 setup(function() { |
| 13 testBrowserProxy = new TestPrivacyPageBrowserProxy(); | 13 testBrowserProxy = new TestPrivacyPageBrowserProxy(); |
| 14 settings.PrivacyPageBrowserProxyImpl.instance_ = testBrowserProxy; | 14 settings.PrivacyPageBrowserProxyImpl.instance_ = testBrowserProxy; |
| 15 PolymerTest.clearBody(); | 15 PolymerTest.clearBody(); |
| 16 page = document.createElement('settings-privacy-page'); | 16 page = document.createElement('settings-privacy-page'); |
| 17 }); | 17 }); |
| 18 | 18 |
| 19 teardown(function() { page.remove(); }); | 19 teardown(function() { page.remove(); }); |
| 20 | 20 |
| 21 test('changes to whether metrics reporting is enabled/managed', function() { | 21 test('changes to whether metrics reporting is enabled/managed', function() { |
| 22 return testBrowserProxy.whenCalled('getMetricsReporting').then(function() { | 22 return testBrowserProxy.whenCalled('getMetricsReporting').then(function() { |
| 23 Polymer.dom.flush(); | 23 Polymer.dom.flush(); |
| 24 assertFalse(!!page.$$('#metricsReporting paper-button')); |
| 24 | 25 |
| 25 var checkbox = page.$.metricsReportingCheckbox; | 26 var checkbox = page.$.metricsReportingCheckbox; |
| 26 assertEquals(testBrowserProxy.metricsReporting.enabled, checkbox.checked); | 27 assertEquals(testBrowserProxy.metricsReporting.enabled, checkbox.checked); |
| 27 var indicatorVisible = !!page.$$('#indicator'); | 28 var indicatorVisible = !!page.$$('#indicator'); |
| 28 assertEquals(testBrowserProxy.metricsReporting.managed, indicatorVisible); | 29 assertEquals(testBrowserProxy.metricsReporting.managed, indicatorVisible); |
| 29 | 30 |
| 30 var changedMetrics = { | 31 var changedMetrics = { |
| 31 enabled: !testBrowserProxy.metricsReporting.enabled, | 32 enabled: !testBrowserProxy.metricsReporting.enabled, |
| 32 managed: !testBrowserProxy.metricsReporting.managed, | 33 managed: !testBrowserProxy.metricsReporting.managed, |
| 33 }; | 34 }; |
| 34 cr.webUIListenerCallback('metrics-reporting-change', changedMetrics); | 35 cr.webUIListenerCallback('metrics-reporting-change', changedMetrics); |
| 35 Polymer.dom.flush(); | 36 Polymer.dom.flush(); |
| 36 | 37 |
| 38 assertTrue(!!page.$$('#metricsReporting paper-button')); |
| 39 |
| 37 assertEquals(changedMetrics.enabled, checkbox.checked); | 40 assertEquals(changedMetrics.enabled, checkbox.checked); |
| 38 indicatorVisible = !!page.$$('#indicator'); | 41 indicatorVisible = !!page.$$('#indicator'); |
| 39 assertEquals(changedMetrics.managed, indicatorVisible); | 42 assertEquals(changedMetrics.managed, indicatorVisible); |
| 40 | 43 |
| 41 var toggled = !changedMetrics.enabled; | 44 var toggled = !changedMetrics.enabled; |
| 42 | 45 |
| 43 MockInteractions.tap(checkbox); | 46 MockInteractions.tap(checkbox); |
| 44 return testBrowserProxy.whenCalled('setMetricsReportingEnabled', toggled); | 47 return testBrowserProxy.whenCalled('setMetricsReportingEnabled', toggled); |
| 48 }).then(function() { |
| 49 assertTrue(!!page.$$('#metricsReporting paper-button')); |
| 45 }); | 50 }); |
| 46 }); | 51 }); |
| 47 }); | 52 }); |
| OLD | NEW |