| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @constructor |
| 7 * @extends {TestBrowserProxy} |
| 8 * @implements {settings.PrivacyPageBrowserProxy} |
| 9 */ |
| 10 function TestPrivacyPageBrowserProxy() { |
| 11 settings.TestBrowserProxy.call(this, [ |
| 12 'getMetricsReporting', |
| 13 'setMetricsReportingEnabled', |
| 14 ]); |
| 15 } |
| 16 |
| 17 TestPrivacyPageBrowserProxy.prototype = { |
| 18 __proto__: settings.TestBrowserProxy.prototype, |
| 19 |
| 20 /** @type {!MetricsReporting} */ |
| 21 metricsReporting: { |
| 22 enabled: true, |
| 23 managed: true, |
| 24 }, |
| 25 |
| 26 /** @override */ |
| 27 getMetricsReporting: function() { |
| 28 this.methodCalled('getMetricsReporting'); |
| 29 return Promise.resolve(this.metricsReporting); |
| 30 }, |
| 31 |
| 32 /** @override */ |
| 33 setMetricsReportingEnabled: function(enabled) { |
| 34 this.methodCalled('setMetricsReportingEnabled', enabled); |
| 35 }, |
| 36 }; |
| 37 |
| 38 suite('metrics reporting', function() { |
| 39 /** @type {settings.TestPrivacyPageBrowserProxy} */ |
| 40 var testBrowserProxy; |
| 41 |
| 42 /** @type {SettingsPrivacyPageElement} */ |
| 43 var page; |
| 44 |
| 45 setup(function() { |
| 46 testBrowserProxy = new TestPrivacyPageBrowserProxy(); |
| 47 settings.PrivacyPageBrowserProxyImpl.instance_ = testBrowserProxy; |
| 48 PolymerTest.clearBody(); |
| 49 page = document.createElement('settings-privacy-page'); |
| 50 }); |
| 51 |
| 52 teardown(function() { page.remove(); }); |
| 53 |
| 54 test('changes to whether metrics reporting is enabled/managed', function() { |
| 55 return testBrowserProxy.whenCalled('getMetricsReporting').then(function() { |
| 56 Polymer.dom.flush(); |
| 57 |
| 58 var checkbox = page.$.metricsReportingCheckbox; |
| 59 assertEquals(testBrowserProxy.metricsReporting.enabled, checkbox.checked); |
| 60 var indicatorVisible = !!page.$$('#indicator'); |
| 61 assertEquals(testBrowserProxy.metricsReporting.managed, indicatorVisible); |
| 62 |
| 63 var changedMetrics = { |
| 64 enabled: !testBrowserProxy.metricsReporting.enabled, |
| 65 managed: !testBrowserProxy.metricsReporting.managed, |
| 66 }; |
| 67 cr.webUIListenerCallback('metrics-reporting-change', changedMetrics); |
| 68 Polymer.dom.flush(); |
| 69 |
| 70 assertEquals(changedMetrics.enabled, checkbox.checked); |
| 71 indicatorVisible = !!page.$$('#indicator'); |
| 72 assertEquals(changedMetrics.managed, indicatorVisible); |
| 73 |
| 74 var toggled = !changedMetrics.enabled; |
| 75 |
| 76 MockInteractions.tap(checkbox); |
| 77 return testBrowserProxy.whenCalled('setMetricsReportingEnabled', toggled); |
| 78 }); |
| 79 }); |
| 80 }); |
| OLD | NEW |