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

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

Issue 2684853003: MD Settings: change how tap is handled on custom toggle rows (Closed)
Patch Set: if the compiler ain't happy, ain't nobody happy Created 3 years, 10 months 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
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 24
25 var control = page.$.metricsReportingControl; 25 var control = page.$.metricsReportingControl;
26 assertEquals(testBrowserProxy.metricsReporting.enabled, control.checked); 26 assertEquals(testBrowserProxy.metricsReporting.enabled, control.checked);
27 var indicatorVisible = !!page.$$('#indicator'); 27 var indicatorVisible = !!control.$$('cr-policy-pref-indicator');
Dan Beam 2017/02/09 16:07:42 dpapad@: i'll do whatever you want here, this is o
dpapad 2017/02/09 19:51:45 Ok, perhaps add the following? if (testBrowserProx
Dan Beam 2017/02/09 20:48:45 that still pokes into <settings-toggle-button>'s D
28 assertEquals(testBrowserProxy.metricsReporting.managed, indicatorVisible); 28 assertEquals(testBrowserProxy.metricsReporting.managed, indicatorVisible);
29 29
30 var changedMetrics = { 30 var changedMetrics = {
31 enabled: !testBrowserProxy.metricsReporting.enabled, 31 enabled: !testBrowserProxy.metricsReporting.enabled,
32 managed: !testBrowserProxy.metricsReporting.managed, 32 managed: !testBrowserProxy.metricsReporting.managed,
33 }; 33 };
34 cr.webUIListenerCallback('metrics-reporting-change', changedMetrics); 34 cr.webUIListenerCallback('metrics-reporting-change', changedMetrics);
35 Polymer.dom.flush(); 35 Polymer.dom.flush();
36 36
37 assertEquals(changedMetrics.enabled, control.checked); 37 assertEquals(changedMetrics.enabled, control.checked);
38 indicatorVisible = !!page.$$('#indicator'); 38 indicatorVisible = !!control.$$('cr-policy-pref-indicator');
39 assertEquals(changedMetrics.managed, indicatorVisible); 39 assertEquals(changedMetrics.managed, indicatorVisible);
40 40
41 var toggled = !changedMetrics.enabled; 41 var toggled = !changedMetrics.enabled;
42 42 control.checked = toggled;
43 MockInteractions.tap(control);
44 return testBrowserProxy.whenCalled('setMetricsReportingEnabled', toggled); 43 return testBrowserProxy.whenCalled('setMetricsReportingEnabled', toggled);
dpapad 2017/02/09 19:51:45 whenCalled() only accepts one parameter. I am not
Dan Beam 2017/02/09 20:48:45 Done. (thanks!)
45 }); 44 });
46 }); 45 });
47 46
48 test('metrics reporting restart button', function() { 47 test('metrics reporting restart button', function() {
49 return testBrowserProxy.whenCalled('getMetricsReporting').then(function() { 48 return testBrowserProxy.whenCalled('getMetricsReporting').then(function() {
50 Polymer.dom.flush(); 49 Polymer.dom.flush();
51 50
52 // Restart button should be hidden by default (in any state). 51 // Restart button should be hidden by default (in any state).
53 assertFalse(!!page.$$('#restart')); 52 assertFalse(!!page.$$('#restart'));
54 53
(...skipping 30 matching lines...) Expand all
85 // Receiving the same values should have no effect. 84 // Receiving the same values should have no effect.
86 cr.webUIListenerCallback('metrics-reporting-change', { 85 cr.webUIListenerCallback('metrics-reporting-change', {
87 enabled: false, 86 enabled: false,
88 managed: false, 87 managed: false,
89 }); 88 });
90 Polymer.dom.flush(); 89 Polymer.dom.flush();
91 assertTrue(!!page.$$('#restart')); 90 assertTrue(!!page.$$('#restart'));
92 }); 91 });
93 }); 92 });
94 }); 93 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698