| 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 cr.define('settings_privacy_page', function() { | 5 cr.define('settings_privacy_page', function() { |
| 6 /** | 6 /** |
| 7 * @constructor | 7 * @constructor |
| 8 * @extends {TestBrowserProxy} | 8 * @extends {TestBrowserProxy} |
| 9 * @implements {settings.PrivacyPageBrowserProxy} | 9 * @implements {settings.PrivacyPageBrowserProxy} |
| 10 */ | 10 */ |
| 11 function TestPrivacyPageBrowserProxy() { | 11 function TestPrivacyPageBrowserProxy() { |
| 12 settings.TestBrowserProxy.call(this, ['showManageSSLCertificates']); | 12 settings.TestBrowserProxy.call(this, ['showManageSSLCertificates']); |
| 13 } | 13 } |
| 14 | 14 |
| 15 TestPrivacyPageBrowserProxy.prototype = { | 15 TestPrivacyPageBrowserProxy.prototype = { |
| 16 __proto__: settings.TestBrowserProxy.prototype, | 16 __proto__: settings.TestBrowserProxy.prototype, |
| 17 | 17 |
| 18 /** @override */ | 18 /** @override */ |
| 19 showManageSSLCertificates: function() { | 19 showManageSSLCertificates: function() { |
| 20 this.methodCalled('showManageSSLCertificates'); | 20 this.methodCalled('showManageSSLCertificates'); |
| 21 }, | 21 }, |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 suite('PrivacyPage', function() { | 24 /** |
| 25 /** @type {settings.TestPrivacyPageBrowserProxy} */ | 25 * @constructor |
| 26 var testBrowserProxy; | 26 * @extends {TestBrowserProxy} |
| 27 * @implements {settings.ClearBrowsingDataBrowserProxy} |
| 28 */ |
| 29 function TestClearBrowsingDataBrowserProxy() { |
| 30 settings.TestBrowserProxy.call(this, ['clearBrowsingData']); |
| 31 } |
| 27 | 32 |
| 28 /** @type {SettingsPrivacyPageElement} */ | 33 TestClearBrowsingDataBrowserProxy.prototype = { |
| 29 var page; | 34 __proto__: settings.TestBrowserProxy.prototype, |
| 30 | 35 |
| 31 setup(function() { | 36 /** @override */ |
| 32 testBrowserProxy = new TestPrivacyPageBrowserProxy(); | 37 clearBrowsingData: function() { |
| 33 settings.PrivacyPageBrowserProxyImpl.instance_ = testBrowserProxy; | 38 this.methodCalled('clearBrowsingData'); |
| 34 PolymerTest.clearBody(); | 39 return Promise.resolve(); |
| 35 page = document.createElement('settings-privacy-page'); | 40 }, |
| 36 document.body.appendChild(page); | 41 }; |
| 42 |
| 43 function registerNativeCertificateManagerTests() { |
| 44 suite('NativeCertificateManager', function() { |
| 45 /** @type {settings.TestPrivacyPageBrowserProxy} */ |
| 46 var testBrowserProxy; |
| 47 |
| 48 /** @type {SettingsPrivacyPageElement} */ |
| 49 var page; |
| 50 |
| 51 setup(function() { |
| 52 testBrowserProxy = new TestPrivacyPageBrowserProxy(); |
| 53 settings.PrivacyPageBrowserProxyImpl.instance_ = testBrowserProxy; |
| 54 PolymerTest.clearBody(); |
| 55 page = document.createElement('settings-privacy-page'); |
| 56 document.body.appendChild(page); |
| 57 }); |
| 58 |
| 59 teardown(function() { page.remove(); }); |
| 60 |
| 61 test('NativeCertificateManager', function() { |
| 62 MockInteractions.tap(page.$.manageCertificates); |
| 63 return testBrowserProxy.whenCalled('showManageSSLCertificates'); |
| 64 }); |
| 37 }); | 65 }); |
| 66 } |
| 38 | 67 |
| 39 teardown(function() { page.remove(); }); | 68 function registerClearBrowsingDataTests() { |
| 69 suite('ClearBrowsingData', function() { |
| 70 /** @type {settings.TestClearBrowsingDataBrowserProxy} */ |
| 71 var testBrowserProxy; |
| 40 | 72 |
| 41 test('NativeCertificateManager', function() { | 73 /** @type {SettingsClearBrowsingDataDialogElement} */ |
| 42 MockInteractions.tap(page.$.manageCertificates); | 74 var element; |
| 43 return testBrowserProxy.whenCalled('showManageSSLCertificates'); | 75 |
| 76 setup(function() { |
| 77 testBrowserProxy = new TestClearBrowsingDataBrowserProxy(); |
| 78 settings.ClearBrowsingDataBrowserProxyImpl.instance_ = testBrowserProxy; |
| 79 PolymerTest.clearBody(); |
| 80 element = document.createElement('settings-clear-browsing-data-dialog'); |
| 81 document.body.appendChild(element); |
| 82 }); |
| 83 |
| 84 teardown(function() { element.remove(); }); |
| 85 |
| 86 test('ClearBrowsingDataTap', function() { |
| 87 element.open(); |
| 88 assertTrue(element.$.dialog.opened); |
| 89 var clearBrowsingDataButton = element.$.clearBrowsingData; |
| 90 assertTrue(!!clearBrowsingDataButton); |
| 91 |
| 92 MockInteractions.tap(clearBrowsingDataButton); |
| 93 return testBrowserProxy.whenCalled('clearBrowsingData').then( |
| 94 function() { |
| 95 assertFalse(element.$.dialog.opened); |
| 96 }); |
| 97 }); |
| 44 }); | 98 }); |
| 45 }); | 99 } |
| 100 |
| 101 return { |
| 102 registerTests: function() { |
| 103 if (cr.isMac || cr.isWin) |
| 104 registerNativeCertificateManagerTests(); |
| 105 |
| 106 registerClearBrowsingDataTests(); |
| 107 }, |
| 108 }; |
| 46 }); | 109 }); |
| OLD | NEW |