Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: chrome/test/data/webui/settings/metrics_reporting_tests.js

Issue 2494813002: MD Settings: slight tweaks to when the metrics reporting restart button shows up (Closed)
Patch Set: fixes Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/settings/privacy_page/privacy_page.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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'));
25 24
26 var checkbox = page.$.metricsReportingCheckbox; 25 var checkbox = page.$.metricsReportingCheckbox;
27 assertEquals(testBrowserProxy.metricsReporting.enabled, checkbox.checked); 26 assertEquals(testBrowserProxy.metricsReporting.enabled, checkbox.checked);
28 var indicatorVisible = !!page.$$('#indicator'); 27 var indicatorVisible = !!page.$$('#indicator');
29 assertEquals(testBrowserProxy.metricsReporting.managed, indicatorVisible); 28 assertEquals(testBrowserProxy.metricsReporting.managed, indicatorVisible);
30 29
31 var changedMetrics = { 30 var changedMetrics = {
32 enabled: !testBrowserProxy.metricsReporting.enabled, 31 enabled: !testBrowserProxy.metricsReporting.enabled,
33 managed: !testBrowserProxy.metricsReporting.managed, 32 managed: !testBrowserProxy.metricsReporting.managed,
34 }; 33 };
35 cr.webUIListenerCallback('metrics-reporting-change', changedMetrics); 34 cr.webUIListenerCallback('metrics-reporting-change', changedMetrics);
36 Polymer.dom.flush(); 35 Polymer.dom.flush();
37 36
38 assertTrue(!!page.$$('#metricsReporting paper-button'));
39
40 assertEquals(changedMetrics.enabled, checkbox.checked); 37 assertEquals(changedMetrics.enabled, checkbox.checked);
41 indicatorVisible = !!page.$$('#indicator'); 38 indicatorVisible = !!page.$$('#indicator');
42 assertEquals(changedMetrics.managed, indicatorVisible); 39 assertEquals(changedMetrics.managed, indicatorVisible);
43 40
44 var toggled = !changedMetrics.enabled; 41 var toggled = !changedMetrics.enabled;
45 42
46 MockInteractions.tap(checkbox); 43 MockInteractions.tap(checkbox);
47 return testBrowserProxy.whenCalled('setMetricsReportingEnabled', toggled); 44 return testBrowserProxy.whenCalled('setMetricsReportingEnabled', toggled);
48 }).then(function() { 45 });
46 });
47
48 test('metrics reporting restart button', function() {
49 return testBrowserProxy.whenCalled('getMetricsReporting').then(function() {
50 Polymer.dom.flush();
51
52 // Restart button should be hidden by default (in any state).
53 assertFalse(!!page.$$('#metricsReporting paper-button'));
54
55 // Simulate toggling via policy.
56 cr.webUIListenerCallback('metrics-reporting-change', {
57 enabled: false,
58 managed: true,
59 });
60 Polymer.dom.flush();
61
62 // No restart button should show because the value is managed.
63 assertFalse(!!page.$$('#metricsReporting paper-button'));
64
65 cr.webUIListenerCallback('metrics-reporting-change', {
66 enabled: true,
67 managed: true,
68 });
69 Polymer.dom.flush();
70
71 // Changes in policy should not show the restart button because the value
72 // is still managed.
73 assertFalse(!!page.$$('#metricsReporting paper-button'));
74
75 // Remove the policy and toggle the value.
76 cr.webUIListenerCallback('metrics-reporting-change', {
77 enabled: false,
78 managed: false,
79 });
80 Polymer.dom.flush();
81
82 // Now the restart button should be showing.
83 assertTrue(!!page.$$('#metricsReporting paper-button'));
84
85 // Receiving the same values should have no effect.
86 cr.webUIListenerCallback('metrics-reporting-change', {
87 enabled: false,
88 managed: false,
89 });
90 Polymer.dom.flush();
49 assertTrue(!!page.$$('#metricsReporting paper-button')); 91 assertTrue(!!page.$$('#metricsReporting paper-button'));
50 }); 92 });
51 }); 93 });
52 }); 94 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/privacy_page/privacy_page.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698