| 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 ]); | 15 ]); |
| 15 }; | 16 }; |
| 16 | 17 |
| 17 TestProfileInfoBrowserProxy.prototype = { | 18 TestProfileInfoBrowserProxy.prototype = { |
| 18 __proto__: settings.TestBrowserProxy.prototype, | 19 __proto__: settings.TestBrowserProxy.prototype, |
| 19 | 20 |
| 20 fakeProfileInfo: { | 21 fakeProfileInfo: { |
| 21 name: 'fakeName', | 22 name: 'fakeName', |
| 22 iconUrl: 'http://fake-icon-url.com/', | 23 iconUrl: 'http://fake-icon-url.com/', |
| 23 }, | 24 }, |
| 24 | 25 |
| 25 /** @override */ | 26 /** @override */ |
| 26 getProfileInfo: function() { | 27 getProfileInfo: function() { |
| 27 this.methodCalled('getProfileInfo'); | 28 this.methodCalled('getProfileInfo'); |
| 28 return Promise.resolve(this.fakeProfileInfo); | 29 return Promise.resolve(this.fakeProfileInfo); |
| 29 }, | 30 }, |
| 31 |
| 32 /** @override */ |
| 33 getProfileManagesSupervisedUsers: function() { |
| 34 this.methodCalled('getProfileManagesSupervisedUsers'); |
| 35 return Promise.resolve(false); |
| 36 } |
| 30 }; | 37 }; |
| 31 | 38 |
| 32 function registerProfileInfoTests() { | 39 function registerProfileInfoTests() { |
| 33 suite('ProfileInfoTests', function() { | 40 suite('ProfileInfoTests', function() { |
| 34 var peoplePage = null; | 41 var peoplePage = null; |
| 35 var browserProxy = null; | 42 var browserProxy = null; |
| 36 | 43 |
| 37 suiteSetup(function() { | 44 suiteSetup(function() { |
| 38 // Force easy unlock off. Those have their own ChromeOS-only tests. | 45 // Force easy unlock off. Those have their own ChromeOS-only tests. |
| 39 loadTimeData.overrideValues({ | 46 loadTimeData.overrideValues({ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 64 'profile-info-changed', | 71 'profile-info-changed', |
| 65 {name: 'pushedName', iconUrl: 'http://pushed-url/'}); | 72 {name: 'pushedName', iconUrl: 'http://pushed-url/'}); |
| 66 | 73 |
| 67 Polymer.dom.flush(); | 74 Polymer.dom.flush(); |
| 68 assertEquals('pushedName', | 75 assertEquals('pushedName', |
| 69 peoplePage.$$('#profile-name').textContent.trim()); | 76 peoplePage.$$('#profile-name').textContent.trim()); |
| 70 assertEquals('http://pushed-url/', | 77 assertEquals('http://pushed-url/', |
| 71 peoplePage.$$('#profile-icon').src); | 78 peoplePage.$$('#profile-icon').src); |
| 72 }); | 79 }); |
| 73 }); | 80 }); |
| 81 |
| 82 test('GetProfileManagesSupervisedUsers', function() { |
| 83 return browserProxy.whenCalled('getProfileManagesSupervisedUsers').then( |
| 84 function() { |
| 85 Polymer.dom.flush(); |
| 86 assertFalse(!!peoplePage.$$('#manageSupervisedUsersContainer')); |
| 87 |
| 88 cr.webUIListenerCallback( |
| 89 'profile-manages-supervised-users-changed', |
| 90 true); |
| 91 |
| 92 Polymer.dom.flush(); |
| 93 assertTrue(!!peoplePage.$$('#manageSupervisedUsersContainer')); |
| 94 }); |
| 95 }); |
| 74 }); | 96 }); |
| 75 } | 97 } |
| 76 | 98 |
| 77 return { | 99 return { |
| 78 registerTests: function() { | 100 registerTests: function() { |
| 79 registerProfileInfoTests(); | 101 registerProfileInfoTests(); |
| 80 }, | 102 }, |
| 81 }; | 103 }; |
| 82 }); | 104 }); |
| OLD | NEW |