| 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_people_page', function() { | 5 cr.define('settings_people_page', function() { |
| 6 /** | 6 /** |
| 7 * @constructor | 7 * @constructor |
| 8 * @implements {settings.ProfileInfoBrowserProxy} | 8 * @implements {settings.ProfileInfoBrowserProxy} |
| 9 * @extends {settings.TestBrowserProxy} | 9 * @extends {settings.TestBrowserProxy} |
| 10 */ | 10 */ |
| 11 var TestProfileInfoBrowserProxy = function() { | 11 var TestProfileInfoBrowserProxy = function() { |
| 12 settings.TestBrowserProxy.call(this, [ | 12 settings.TestBrowserProxy.call(this, [ |
| 13 'getProfileInfo', | 13 'getProfileInfo', |
| 14 'getProfileManagesSupervisedUsers', | 14 'getProfileManagesSupervisedUsers', |
| 15 ]); | 15 ]); |
| 16 |
| 17 this.fakeProfileInfo = { |
| 18 name: 'fakeName', |
| 19 iconUrl: 'http://fake-icon-url.com/', |
| 20 }; |
| 16 }; | 21 }; |
| 17 | 22 |
| 18 TestProfileInfoBrowserProxy.prototype = { | 23 TestProfileInfoBrowserProxy.prototype = { |
| 19 __proto__: settings.TestBrowserProxy.prototype, | 24 __proto__: settings.TestBrowserProxy.prototype, |
| 20 | 25 |
| 21 fakeProfileInfo: { | |
| 22 name: 'fakeName', | |
| 23 iconUrl: 'http://fake-icon-url.com/', | |
| 24 }, | |
| 25 | |
| 26 /** @override */ | 26 /** @override */ |
| 27 getProfileInfo: function() { | 27 getProfileInfo: function() { |
| 28 this.methodCalled('getProfileInfo'); | 28 this.methodCalled('getProfileInfo'); |
| 29 return Promise.resolve(this.fakeProfileInfo); | 29 return Promise.resolve(this.fakeProfileInfo); |
| 30 }, | 30 }, |
| 31 | 31 |
| 32 /** @override */ | 32 /** @override */ |
| 33 getProfileManagesSupervisedUsers: function() { | 33 getProfileManagesSupervisedUsers: function() { |
| 34 this.methodCalled('getProfileManagesSupervisedUsers'); | 34 this.methodCalled('getProfileManagesSupervisedUsers'); |
| 35 return Promise.resolve(false); | 35 return Promise.resolve(false); |
| 36 } | 36 } |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 /** |
| 40 * @constructor |
| 41 * @implements {settings.SyncBrowserProxy} |
| 42 * @extends {settings.TestBrowserProxy} |
| 43 */ |
| 44 var TestSyncBrowserProxy = function() { |
| 45 settings.TestBrowserProxy.call(this, [ |
| 46 'getSyncStatus', |
| 47 'signOut', |
| 48 ]); |
| 49 }; |
| 50 |
| 51 TestSyncBrowserProxy.prototype = { |
| 52 __proto__: settings.TestBrowserProxy.prototype, |
| 53 |
| 54 /** @override */ |
| 55 getSyncStatus: function() { |
| 56 this.methodCalled('getSyncStatus'); |
| 57 return Promise.resolve({ |
| 58 signedIn: true, |
| 59 }); |
| 60 }, |
| 61 |
| 62 /** @override */ |
| 63 signOut: function(deleteProfile) { |
| 64 this.methodCalled('signOut', deleteProfile); |
| 65 }, |
| 66 }; |
| 67 |
| 39 function registerProfileInfoTests() { | 68 function registerProfileInfoTests() { |
| 40 suite('ProfileInfoTests', function() { | 69 suite('ProfileInfoTests', function() { |
| 41 var peoplePage = null; | 70 var peoplePage = null; |
| 42 var browserProxy = null; | 71 var browserProxy = null; |
| 43 | 72 |
| 44 suiteSetup(function() { | 73 suiteSetup(function() { |
| 45 // Force easy unlock off. Those have their own ChromeOS-only tests. | 74 // Force easy unlock off. Those have their own ChromeOS-only tests. |
| 46 loadTimeData.overrideValues({ | 75 loadTimeData.overrideValues({ |
| 47 easyUnlockAllowed: false, | 76 easyUnlockAllowed: false, |
| 48 }); | 77 }); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 'profile-manages-supervised-users-changed', | 118 'profile-manages-supervised-users-changed', |
| 90 true); | 119 true); |
| 91 | 120 |
| 92 Polymer.dom.flush(); | 121 Polymer.dom.flush(); |
| 93 assertTrue(!!peoplePage.$$('#manageSupervisedUsersContainer')); | 122 assertTrue(!!peoplePage.$$('#manageSupervisedUsersContainer')); |
| 94 }); | 123 }); |
| 95 }); | 124 }); |
| 96 }); | 125 }); |
| 97 } | 126 } |
| 98 | 127 |
| 128 function registerSyncStatusTests() { |
| 129 suite('SyncStatusTests', function() { |
| 130 var peoplePage = null; |
| 131 var browserProxy = null; |
| 132 |
| 133 suiteSetup(function() { |
| 134 // Force easy unlock off. Those have their own ChromeOS-only tests. |
| 135 loadTimeData.overrideValues({ |
| 136 easyUnlockAllowed: false, |
| 137 }); |
| 138 }); |
| 139 |
| 140 setup(function() { |
| 141 browserProxy = new TestSyncBrowserProxy(); |
| 142 settings.SyncBrowserProxyImpl.instance_ = browserProxy; |
| 143 |
| 144 PolymerTest.clearBody(); |
| 145 peoplePage = document.createElement('settings-people-page'); |
| 146 document.body.appendChild(peoplePage); |
| 147 }); |
| 148 |
| 149 teardown(function() { peoplePage.remove(); }); |
| 150 |
| 151 test('GetProfileInfo', function() { |
| 152 return browserProxy.whenCalled('getSyncStatus').then(function() { |
| 153 Polymer.dom.flush(); |
| 154 var disconnectButton = peoplePage.$$('#disconnectButton'); |
| 155 assertTrue(!!disconnectButton); |
| 156 |
| 157 MockInteractions.tap(disconnectButton); |
| 158 Polymer.dom.flush(); |
| 159 |
| 160 assertTrue(peoplePage.$.disconnectDialog.opened); |
| 161 assertFalse(peoplePage.$.deleteProfile.hidden); |
| 162 |
| 163 var disconnectConfirm = peoplePage.$.disconnectConfirm; |
| 164 assertTrue(!!disconnectConfirm); |
| 165 assertFalse(disconnectConfirm.hidden); |
| 166 MockInteractions.tap(disconnectConfirm); |
| 167 |
| 168 return browserProxy.whenCalled('signOut').then( |
| 169 function(deleteProfile) { |
| 170 Polymer.dom.flush(); |
| 171 |
| 172 assertFalse(deleteProfile); |
| 173 |
| 174 cr.webUIListenerCallback('sync-status-changed', { |
| 175 signedIn: true, |
| 176 domain: 'example.com', |
| 177 }); |
| 178 Polymer.dom.flush(); |
| 179 |
| 180 assertFalse(peoplePage.$.disconnectDialog.opened); |
| 181 MockInteractions.tap(disconnectButton); |
| 182 Polymer.dom.flush(); |
| 183 |
| 184 assertTrue(peoplePage.$.disconnectDialog.opened); |
| 185 assertTrue(peoplePage.$.deleteProfile.hidden); |
| 186 |
| 187 var disconnectManagedProfileConfirm = |
| 188 peoplePage.$.disconnectManagedProfileConfirm; |
| 189 assertTrue(!!disconnectManagedProfileConfirm); |
| 190 assertFalse(disconnectManagedProfileConfirm.hidden); |
| 191 |
| 192 browserProxy.resetResolver('signOut'); |
| 193 MockInteractions.tap(disconnectManagedProfileConfirm); |
| 194 |
| 195 return browserProxy.whenCalled('signOut').then( |
| 196 function(deleteProfile) { |
| 197 assertTrue(deleteProfile); |
| 198 }); |
| 199 }); |
| 200 }); |
| 201 }); |
| 202 }); |
| 203 } |
| 204 |
| 99 return { | 205 return { |
| 100 registerTests: function() { | 206 registerTests: function() { |
| 101 registerProfileInfoTests(); | 207 registerProfileInfoTests(); |
| 208 if (!cr.isChromeOS) |
| 209 registerSyncStatusTests(); |
| 102 }, | 210 }, |
| 103 }; | 211 }; |
| 104 }); | 212 }); |
| OLD | NEW |