| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @implements {settings.ChromeCleanupProxy} | 7 * @implements {settings.ChromeCleanupProxy} |
| 8 * @extends {TestBrowserProxy} | 8 * @extends {TestBrowserProxy} |
| 9 */ | 9 */ |
| 10 var TestChromeCleanupProxy = function() { | 10 var TestChromeCleanupProxy = function() { |
| 11 TestBrowserProxy.call(this, [ | 11 TestBrowserProxy.call(this, [ |
| 12 'dismissCleanupPage', | 12 'dismissCleanupPage', |
| 13 'registerChromeCleanerObserver', | 13 'registerChromeCleanerObserver', |
| 14 'restartComputer', | 14 'restartComputer', |
| 15 'setLogsUploadPermission', |
| 15 'startCleanup', | 16 'startCleanup', |
| 16 ]); | 17 ]); |
| 17 }; | 18 }; |
| 18 | 19 |
| 19 TestChromeCleanupProxy.prototype = { | 20 TestChromeCleanupProxy.prototype = { |
| 20 __proto__: TestBrowserProxy.prototype, | 21 __proto__: TestBrowserProxy.prototype, |
| 21 | 22 |
| 22 /** @override */ | 23 /** @override */ |
| 23 dismissCleanupPage: function() { | 24 dismissCleanupPage: function() { |
| 24 this.methodCalled('dismissCleanupPage'); | 25 this.methodCalled('dismissCleanupPage'); |
| 25 }, | 26 }, |
| 26 | 27 |
| 27 /** @override */ | 28 /** @override */ |
| 28 registerChromeCleanerObserver: function() { | 29 registerChromeCleanerObserver: function() { |
| 29 this.methodCalled('registerChromeCleanerObserver'); | 30 this.methodCalled('registerChromeCleanerObserver'); |
| 30 }, | 31 }, |
| 31 | 32 |
| 32 /** @override */ | 33 /** @override */ |
| 33 restartComputer: function() { | 34 restartComputer: function() { |
| 34 this.methodCalled('restartComputer'); | 35 this.methodCalled('restartComputer'); |
| 35 }, | 36 }, |
| 36 | 37 |
| 37 /** @override */ | 38 /** @override */ |
| 38 startCleanup: function() { | 39 setLogsUploadPermission: function(enabled) { |
| 39 this.methodCalled('startCleanup'); | 40 this.methodCalled('setLogsUploadPermission', enabled); |
| 40 }, | 41 }, |
| 42 |
| 43 /** @override */ |
| 44 startCleanup: function(logsUploadEnabled) { |
| 45 this.methodCalled('startCleanup', logsUploadEnabled); |
| 46 } |
| 41 }; | 47 }; |
| 42 | 48 |
| 43 var chromeCleanupPage = null; | 49 var chromeCleanupPage = null; |
| 44 | 50 |
| 45 /** @type {?TestDownloadsBrowserProxy} */ | 51 /** @type {?TestDownloadsBrowserProxy} */ |
| 46 var ChromeCleanupProxy = null; | 52 var ChromeCleanupProxy = null; |
| 47 | 53 |
| 48 suite('ChromeCleanupHandler', function() { | 54 suite('ChromeCleanupHandler', function() { |
| 49 setup(function() { | 55 setup(function() { |
| 50 ChromeCleanupProxy = new TestChromeCleanupProxy(); | 56 ChromeCleanupProxy = new TestChromeCleanupProxy(); |
| 51 settings.ChromeCleanupProxyImpl.instance_ = ChromeCleanupProxy; | 57 settings.ChromeCleanupProxyImpl.instance_ = ChromeCleanupProxy; |
| 52 | 58 |
| 53 PolymerTest.clearBody(); | 59 PolymerTest.clearBody(); |
| 54 | 60 |
| 55 chromeCleanupPage = document.createElement('settings-chrome-cleanup-page'); | 61 chromeCleanupPage = document.createElement('settings-chrome-cleanup-page'); |
| 56 document.body.appendChild(chromeCleanupPage); | 62 document.body.appendChild(chromeCleanupPage); |
| 57 }); | 63 }); |
| 58 | 64 |
| 59 teardown(function() { | 65 teardown(function() { |
| 60 chromeCleanupPage.remove(); | 66 chromeCleanupPage.remove(); |
| 61 }); | 67 }); |
| 62 | 68 |
| 63 test('startCleanupFromInfected', function() { | 69 test('startCleanupFromInfected', function() { |
| 70 cr.webUIListenerCallback('chrome-cleanup-upload-permission-change', false); |
| 64 cr.webUIListenerCallback( | 71 cr.webUIListenerCallback( |
| 65 'chrome-cleanup-on-infected', ['file 1', 'file 2', 'file 3']); | 72 'chrome-cleanup-on-infected', ['file 1', 'file 2', 'file 3']); |
| 66 Polymer.dom.flush(); | 73 Polymer.dom.flush(); |
| 67 | 74 |
| 68 var showFilesButton = chromeCleanupPage.$$('#show-files-button'); | 75 var showFilesButton = chromeCleanupPage.$$('#show-files-button'); |
| 69 assertTrue(!!showFilesButton); | 76 assertTrue(!!showFilesButton); |
| 70 MockInteractions.tap(showFilesButton); | 77 MockInteractions.tap(showFilesButton); |
| 71 filesToRemove = chromeCleanupPage.$$('#files-to-remove-list'); | 78 filesToRemove = chromeCleanupPage.$$('#files-to-remove-list'); |
| 72 assertTrue(!!filesToRemove); | 79 assertTrue(!!filesToRemove); |
| 73 assertEquals(filesToRemove.getElementsByTagName('li').length, 3); | 80 assertEquals(filesToRemove.getElementsByTagName('li').length, 3); |
| 74 | 81 |
| 75 var actionButton = chromeCleanupPage.$$('#action-button'); | 82 var actionButton = chromeCleanupPage.$$('#action-button'); |
| 76 assertTrue(!!actionButton); | 83 assertTrue(!!actionButton); |
| 77 MockInteractions.tap(actionButton); | 84 MockInteractions.tap(actionButton); |
| 78 ChromeCleanupProxy.whenCalled('startCleanup').then(function() { | 85 ChromeCleanupProxy.whenCalled('startCleanup').then( |
| 79 cr.webUIListenerCallback('chrome-cleanup-on-cleaning', false); | 86 function(logsUploadEnabled) { |
| 80 Polymer.dom.flush(); | 87 assertFalse(logsUploadEnabled); |
| 88 cr.webUIListenerCallback('chrome-cleanup-on-cleaning', false); |
| 89 Polymer.dom.flush(); |
| 81 | 90 |
| 82 var spinner = chromeCleanupPage.$$('#cleaning-spinner'); | 91 var spinner = chromeCleanupPage.$$('#cleaning-spinner'); |
| 83 assertTrue(spinner.active); | 92 assertTrue(spinner.active); |
| 84 }) | 93 }) |
| 85 }); | 94 }); |
| 86 | 95 |
| 87 test('rebootFromRebootRequired', function() { | 96 test('rebootFromRebootRequired', function() { |
| 88 cr.webUIListenerCallback('chrome-cleanup-on-reboot-required'); | 97 cr.webUIListenerCallback('chrome-cleanup-on-reboot-required'); |
| 89 Polymer.dom.flush(); | 98 Polymer.dom.flush(); |
| 90 | 99 |
| 91 var actionButton = chromeCleanupPage.$$('#action-button'); | 100 var actionButton = chromeCleanupPage.$$('#action-button'); |
| 92 assertTrue(!!actionButton); | 101 assertTrue(!!actionButton); |
| 93 MockInteractions.tap(actionButton); | 102 MockInteractions.tap(actionButton); |
| 94 return ChromeCleanupProxy.whenCalled('restartComputer'); | 103 return ChromeCleanupProxy.whenCalled('restartComputer'); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 112 cr.webUIListenerCallback( | 121 cr.webUIListenerCallback( |
| 113 'chrome-cleanup-on-idle', | 122 'chrome-cleanup-on-idle', |
| 114 settings.ChromeCleanupIdleReason.CLEANING_SUCCEEDED); | 123 settings.ChromeCleanupIdleReason.CLEANING_SUCCEEDED); |
| 115 Polymer.dom.flush(); | 124 Polymer.dom.flush(); |
| 116 | 125 |
| 117 var actionButton = chromeCleanupPage.$$('#action-button'); | 126 var actionButton = chromeCleanupPage.$$('#action-button'); |
| 118 assertTrue(!!actionButton); | 127 assertTrue(!!actionButton); |
| 119 MockInteractions.tap(actionButton); | 128 MockInteractions.tap(actionButton); |
| 120 return ChromeCleanupProxy.whenCalled('dismissCleanupPage'); | 129 return ChromeCleanupProxy.whenCalled('dismissCleanupPage'); |
| 121 }); | 130 }); |
| 131 |
| 132 test('setLogsUploadPermission', function() { |
| 133 cr.webUIListenerCallback( |
| 134 'chrome-cleanup-on-infected', ['file 1', 'file 2', 'file 3']); |
| 135 Polymer.dom.flush(); |
| 136 |
| 137 var control = chromeCleanupPage.$$('#chromeCleanupLogsUploadControl'); |
| 138 assertTrue(!!control); |
| 139 |
| 140 cr.webUIListenerCallback('chrome-cleanup-upload-permission-change', true); |
| 141 Polymer.dom.flush(); |
| 142 assertTrue(control.checked); |
| 143 |
| 144 cr.webUIListenerCallback('chrome-cleanup-upload-permission-change', false); |
| 145 Polymer.dom.flush(); |
| 146 assertFalse(control.checked); |
| 147 |
| 148 // TODO(proberge): Mock tapping on |control| and verify that |
| 149 // |setLogsUploadPermission| is called with the right argument. |
| 150 }); |
| 122 }); | 151 }); |
| OLD | NEW |