Chromium Code Reviews| Index: chrome/test/data/webui/settings/people_page_test.js |
| diff --git a/chrome/test/data/webui/settings/people_page_test.js b/chrome/test/data/webui/settings/people_page_test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5045c1ed822f982b16279e8150a2cb3a022b8c68 |
| --- /dev/null |
| +++ b/chrome/test/data/webui/settings/people_page_test.js |
| @@ -0,0 +1,85 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +cr.define('settings_people_page', function() { |
| + /** |
| + * @constructor |
| + * @implements {settings.ProfileInfoBrowserProxy} |
| + * @extends {settings.TestBrowserProxy} |
| + */ |
| + var TestProfileInfoBrowserProxy = function() { |
| + settings.TestBrowserProxy.call(this, [ |
| + 'getProfileInfo', |
| + ]); |
| + }; |
| + |
| + TestProfileInfoBrowserProxy.prototype = { |
| + __proto__: settings.TestBrowserProxy.prototype, |
| + |
| + /** @override */ |
| + getProfileInfo: function() { |
| + this.methodCalled('getProfileInfo'); |
| + return Promise.resolve({ |
| + 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.
|
| + iconUrl: 'http://fake-icon-url.com/' |
| + }); |
| + }, |
| + }; |
| + |
| + function registerProfileInfoTests() { |
| + suite('ProfileInfoTests', function() { |
| + var peoplePage = null; |
| + var browserProxy = null; |
| + |
| + suiteSetup(function() { |
| + // Force easy unlock off. Those have their own ChromeOS-only tests. |
| + loadTimeData.overrideValues({ |
| + easyUnlockAllowed: false, |
| + }); |
| + }); |
| + |
| + setup(function() { |
| + browserProxy = new TestProfileInfoBrowserProxy(); |
| + settings.ProfileInfoBrowserProxyImpl.instance_ = browserProxy; |
| + |
| + PolymerTest.clearBody(); |
| + peoplePage = document.createElement('settings-people-page'); |
| + peoplePage.currentRoute = { |
| + url: '/', |
| + page: 'basic', |
| + section: '', |
| + }; |
| + document.body.appendChild(peoplePage); |
| + }); |
| + |
| + teardown(function() { peoplePage.remove(); }); |
| + |
| + test('GetProfileInfo', function() { |
| + return browserProxy.whenCalled('getProfileInfo').then(function() { |
| + Polymer.dom.flush(); |
| + assertEquals('fakeName', |
| + peoplePage.$$('#profile-name').textContent.trim()); |
| + 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.
|
| + peoplePage.$$('#profile-icon').src); |
| + |
| + cr.webUIListenerCallback( |
| + 'profile-info-changed', |
| + {name: 'pushedName', iconUrl: 'http://pushed-url/'}); |
| + |
| + Polymer.dom.flush(); |
| + assertEquals('pushedName', |
| + peoplePage.$$('#profile-name').textContent.trim()); |
| + assertEquals('http://pushed-url/', |
| + peoplePage.$$('#profile-icon').src); |
| + }); |
| + }); |
| + }); |
| + } |
| + |
| + return { |
| + registerTests: function() { |
| + registerProfileInfoTests(); |
| + }, |
| + }; |
| +}); |