Chromium Code Reviews| 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 /** @override */ | |
| 21 getProfileInfo: function() { | |
| 22 this.methodCalled('getProfileInfo'); | |
| 23 return Promise.resolve({ | |
| 24 name: 'fakeName', | |
|
dpapad
2016/04/18 23:30:49
Nit (optional): Make this object a public member v
tommycli
2016/04/19 00:03:27
Done.
| |
| 25 iconUrl: 'http://fake-icon-url.com/' | |
| 26 }); | |
| 27 }, | |
| 28 }; | |
| 29 | |
| 30 function registerProfileInfoTests() { | |
| 31 suite('ProfileInfoTests', function() { | |
| 32 var peoplePage = null; | |
| 33 var browserProxy = null; | |
| 34 | |
| 35 suiteSetup(function() { | |
| 36 // Force easy unlock off. Those have their own ChromeOS-only tests. | |
| 37 loadTimeData.overrideValues({ | |
| 38 easyUnlockAllowed: false, | |
| 39 }); | |
| 40 }); | |
| 41 | |
| 42 setup(function() { | |
| 43 browserProxy = new TestProfileInfoBrowserProxy(); | |
| 44 settings.ProfileInfoBrowserProxyImpl.instance_ = browserProxy; | |
| 45 | |
| 46 PolymerTest.clearBody(); | |
| 47 peoplePage = document.createElement('settings-people-page'); | |
| 48 peoplePage.currentRoute = { | |
| 49 url: '/', | |
| 50 page: 'basic', | |
| 51 section: '', | |
| 52 }; | |
| 53 document.body.appendChild(peoplePage); | |
| 54 }); | |
| 55 | |
| 56 teardown(function() { peoplePage.remove(); }); | |
| 57 | |
| 58 test('GetProfileInfo', function() { | |
| 59 return browserProxy.whenCalled('getProfileInfo').then(function() { | |
| 60 Polymer.dom.flush(); | |
| 61 assertEquals('fakeName', | |
| 62 peoplePage.$$('#profile-name').textContent.trim()); | |
| 63 assertEquals('http://fake-icon-url.com/', | |
|
dpapad
2016/04/18 23:30:49
assertEquals(browserProxy.profileInfo.iconUrl, peo
tommycli
2016/04/19 00:03:27
Done.
| |
| 64 peoplePage.$$('#profile-icon').src); | |
| 65 | |
| 66 cr.webUIListenerCallback( | |
| 67 'profile-info-changed', | |
| 68 {name: 'pushedName', iconUrl: 'http://pushed-url/'}); | |
| 69 | |
| 70 Polymer.dom.flush(); | |
| 71 assertEquals('pushedName', | |
| 72 peoplePage.$$('#profile-name').textContent.trim()); | |
| 73 assertEquals('http://pushed-url/', | |
| 74 peoplePage.$$('#profile-icon').src); | |
| 75 }); | |
| 76 }); | |
| 77 }); | |
| 78 } | |
| 79 | |
| 80 return { | |
| 81 registerTests: function() { | |
| 82 registerProfileInfoTests(); | |
| 83 }, | |
| 84 }; | |
| 85 }); | |
| OLD | NEW |