| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 cr.define('settings_people_page', function() { |
| 6 /** |
| 7 * @constructor |
| 8 * @implements {settings.ProfileInfoBrowserProxy} |
| 9 * @extends {settings.TestBrowserProxy} |
| 10 */ |
| 11 var TestProfileInfoBrowserProxy = function() { |
| 12 settings.TestBrowserProxy.call(this, [ |
| 13 'getProfileInfo', |
| 14 ]); |
| 15 }; |
| 16 |
| 17 TestProfileInfoBrowserProxy.prototype = { |
| 18 __proto__: settings.TestBrowserProxy.prototype, |
| 19 |
| 20 fakeProfileInfo: { |
| 21 name: 'fakeName', |
| 22 iconUrl: 'http://fake-icon-url.com/', |
| 23 }, |
| 24 |
| 25 /** @override */ |
| 26 getProfileInfo: function() { |
| 27 this.methodCalled('getProfileInfo'); |
| 28 return Promise.resolve(this.fakeProfileInfo); |
| 29 }, |
| 30 }; |
| 31 |
| 32 function registerProfileInfoTests() { |
| 33 suite('ProfileInfoTests', function() { |
| 34 var peoplePage = null; |
| 35 var browserProxy = null; |
| 36 |
| 37 suiteSetup(function() { |
| 38 // Force easy unlock off. Those have their own ChromeOS-only tests. |
| 39 loadTimeData.overrideValues({ |
| 40 easyUnlockAllowed: false, |
| 41 }); |
| 42 }); |
| 43 |
| 44 setup(function() { |
| 45 browserProxy = new TestProfileInfoBrowserProxy(); |
| 46 settings.ProfileInfoBrowserProxyImpl.instance_ = browserProxy; |
| 47 |
| 48 PolymerTest.clearBody(); |
| 49 peoplePage = document.createElement('settings-people-page'); |
| 50 peoplePage.currentRoute = { |
| 51 url: '/', |
| 52 page: 'basic', |
| 53 section: '', |
| 54 }; |
| 55 document.body.appendChild(peoplePage); |
| 56 }); |
| 57 |
| 58 teardown(function() { peoplePage.remove(); }); |
| 59 |
| 60 test('GetProfileInfo', function() { |
| 61 return browserProxy.whenCalled('getProfileInfo').then(function() { |
| 62 Polymer.dom.flush(); |
| 63 assertEquals(browserProxy.fakeProfileInfo.name, |
| 64 peoplePage.$$('#profile-name').textContent.trim()); |
| 65 assertEquals(browserProxy.fakeProfileInfo.iconUrl, |
| 66 peoplePage.$$('#profile-icon').src); |
| 67 |
| 68 cr.webUIListenerCallback( |
| 69 'profile-info-changed', |
| 70 {name: 'pushedName', iconUrl: 'http://pushed-url/'}); |
| 71 |
| 72 Polymer.dom.flush(); |
| 73 assertEquals('pushedName', |
| 74 peoplePage.$$('#profile-name').textContent.trim()); |
| 75 assertEquals('http://pushed-url/', |
| 76 peoplePage.$$('#profile-icon').src); |
| 77 }); |
| 78 }); |
| 79 }); |
| 80 } |
| 81 |
| 82 return { |
| 83 registerTests: function() { |
| 84 registerProfileInfoTests(); |
| 85 }, |
| 86 }; |
| 87 }); |
| OLD | NEW |