Chromium Code Reviews| 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; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 MockInteractions.tap(checkbox); | 43 MockInteractions.tap(checkbox); |
| 44 return testBrowserProxy.whenCalled('setMetricsReportingEnabled', toggled); | 44 return testBrowserProxy.whenCalled('setMetricsReportingEnabled', toggled); |
| 45 }); | 45 }); |
| 46 }); | 46 }); |
| 47 | 47 |
| 48 test('metrics reporting restart button', function() { | 48 test('metrics reporting restart button', function() { |
| 49 return testBrowserProxy.whenCalled('getMetricsReporting').then(function() { | 49 return testBrowserProxy.whenCalled('getMetricsReporting').then(function() { |
| 50 Polymer.dom.flush(); | 50 Polymer.dom.flush(); |
| 51 | 51 |
| 52 // Restart button should be hidden by default (in any state). | 52 // Restart button should be hidden by default (in any state). |
| 53 assertFalse(!!page.$$('#metricsReporting paper-button')); | 53 assertFalse(!!page.$$('#restart')); |
|
dschuyler
2017/01/07 02:56:40
Nice.
| |
| 54 | 54 |
| 55 // Simulate toggling via policy. | 55 // Simulate toggling via policy. |
| 56 cr.webUIListenerCallback('metrics-reporting-change', { | 56 cr.webUIListenerCallback('metrics-reporting-change', { |
| 57 enabled: false, | 57 enabled: false, |
| 58 managed: true, | 58 managed: true, |
| 59 }); | 59 }); |
| 60 Polymer.dom.flush(); | 60 Polymer.dom.flush(); |
| 61 | 61 |
| 62 // No restart button should show because the value is managed. | 62 // No restart button should show because the value is managed. |
| 63 assertFalse(!!page.$$('#metricsReporting paper-button')); | 63 assertFalse(!!page.$$('#restart')); |
| 64 | 64 |
| 65 cr.webUIListenerCallback('metrics-reporting-change', { | 65 cr.webUIListenerCallback('metrics-reporting-change', { |
| 66 enabled: true, | 66 enabled: true, |
| 67 managed: true, | 67 managed: true, |
| 68 }); | 68 }); |
| 69 Polymer.dom.flush(); | 69 Polymer.dom.flush(); |
| 70 | 70 |
| 71 // Changes in policy should not show the restart button because the value | 71 // Changes in policy should not show the restart button because the value |
| 72 // is still managed. | 72 // is still managed. |
| 73 assertFalse(!!page.$$('#metricsReporting paper-button')); | 73 assertFalse(!!page.$$('#restart')); |
| 74 | 74 |
| 75 // Remove the policy and toggle the value. | 75 // Remove the policy and toggle the value. |
| 76 cr.webUIListenerCallback('metrics-reporting-change', { | 76 cr.webUIListenerCallback('metrics-reporting-change', { |
| 77 enabled: false, | 77 enabled: false, |
| 78 managed: false, | 78 managed: false, |
| 79 }); | 79 }); |
| 80 Polymer.dom.flush(); | 80 Polymer.dom.flush(); |
| 81 | 81 |
| 82 // Now the restart button should be showing. | 82 // Now the restart button should be showing. |
| 83 assertTrue(!!page.$$('#metricsReporting paper-button')); | 83 assertTrue(!!page.$$('#restart')); |
| 84 | 84 |
| 85 // Receiving the same values should have no effect. | 85 // Receiving the same values should have no effect. |
| 86 cr.webUIListenerCallback('metrics-reporting-change', { | 86 cr.webUIListenerCallback('metrics-reporting-change', { |
| 87 enabled: false, | 87 enabled: false, |
| 88 managed: false, | 88 managed: false, |
| 89 }); | 89 }); |
| 90 Polymer.dom.flush(); | 90 Polymer.dom.flush(); |
| 91 assertTrue(!!page.$$('#metricsReporting paper-button')); | 91 assertTrue(!!page.$$('#restart')); |
| 92 }); | 92 }); |
| 93 }); | 93 }); |
| 94 }); | 94 }); |
| OLD | NEW |