Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Side by Side Diff: chrome/test/data/webui/settings/people_page_manage_profile_test.js

Issue 2068713003: Refactors profile avatar selector into a Polymer element to use in md-settings & md-user-manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_manage_profile', function() { 5 cr.define('settings_people_page_manage_profile', function() {
6 /** 6 /**
7 * @constructor 7 * @constructor
8 * @implements {settings.ManageProfileBrowserProxy} 8 * @implements {settings.ManageProfileBrowserProxy}
9 * @extends {settings.TestBrowserProxy} 9 * @extends {settings.TestBrowserProxy}
10 */ 10 */
11 var TestManageProfileBrowserProxy = function() { 11 var TestManageProfileBrowserProxy = function() {
12 settings.TestBrowserProxy.call(this, [ 12 settings.TestBrowserProxy.call(this, [
13 'getAvailableIcons', 13 'getAvailableIcons',
14 'setProfileIconAndName', 14 'setProfileIconAndName',
15 ]); 15 ]);
16 }; 16 };
17 17
18 TestManageProfileBrowserProxy.prototype = { 18 TestManageProfileBrowserProxy.prototype = {
19 __proto__: settings.TestBrowserProxy.prototype, 19 __proto__: settings.TestBrowserProxy.prototype,
20 20
21 /** @override */ 21 /** @override */
22 getAvailableIcons: function() { 22 getAvailableIcons: function() {
23 this.methodCalled('getAvailableIcons'); 23 this.methodCalled('getAvailableIcons');
24 return Promise.resolve(['fake-icon-1.png', 'fake-icon-2.png']); 24 return Promise.resolve([{url: 'fake-icon-1.png', label: 'fake-icon-1'},
25 {url: 'fake-icon-2.png', label: 'fake-icon-2'}]);
25 }, 26 },
26 27
27 /** @override */ 28 /** @override */
28 setProfileIconAndName: function(iconUrl, name) { 29 setProfileIconAndName: function(iconUrl, name) {
29 this.methodCalled('setProfileIconAndName', [iconUrl, name]); 30 this.methodCalled('setProfileIconAndName', [iconUrl, name]);
30 }, 31 },
31 }; 32 };
32 33
33 function registerManageProfileTests() { 34 function registerManageProfileTests() {
34 suite('ManageProfileTests', function() { 35 suite('ManageProfileTests', function() {
(...skipping 10 matching lines...) Expand all
45 document.body.appendChild(manageProfile); 46 document.body.appendChild(manageProfile);
46 }); 47 });
47 48
48 teardown(function() { manageProfile.remove(); }); 49 teardown(function() { manageProfile.remove(); });
49 50
50 // Tests that the manage profile subpage 51 // Tests that the manage profile subpage
51 // - gets and receives all the available icons 52 // - gets and receives all the available icons
52 // - has the correct icon selected 53 // - has the correct icon selected
53 // - can select a new icon 54 // - can select a new icon
54 test('ManageProfileChangeIcon', function() { 55 test('ManageProfileChangeIcon', function() {
55 var selector = manageProfile.$.selector; 56 var selector = manageProfile.$.selector.$.selector;
56 assertTrue(!!selector); 57 assertTrue(!!selector);
57 58
58 return browserProxy.whenCalled('getAvailableIcons').then(function() { 59 return browserProxy.whenCalled('getAvailableIcons').then(function() {
59 Polymer.dom.flush(); 60 Polymer.dom.flush();
60 61
61 assertEquals('fake-icon-1.png', selector.selected); 62 assertEquals('fake-icon-1.png', manageProfile.profileIconUrl);
62 assertEquals(2, selector.items.length); 63 assertEquals(2, selector.items.length);
63 assertTrue(selector.items[0].classList.contains('iron-selected')); 64 assertTrue(selector.items[0].classList.contains('iron-selected'));
64 assertFalse(selector.items[1].classList.contains('iron-selected')); 65 assertFalse(selector.items[1].classList.contains('iron-selected'));
65 66
66 MockInteractions.tap(selector.items[1]); 67 MockInteractions.tap(selector.items[1]);
67 return browserProxy.whenCalled('setProfileIconAndName').then( 68 return browserProxy.whenCalled('setProfileIconAndName').then(
68 function(args) { 69 function(args) {
69 assertEquals('fake-icon-2.png', args[0]); 70 assertEquals('fake-icon-2.png', args[0]);
70 assertEquals('Initial Fake Name', args[1]); 71 assertEquals('Initial Fake Name', args[1]);
71 }); 72 });
72 }); 73 });
73 }); 74 });
74 75
75 // Tests profile icon updates pushed from the browser. 76 // Tests profile icon updates pushed from the browser.
76 test('ManageProfileIconUpdated', function() { 77 test('ManageProfileIconUpdated', function() {
77 var selector = manageProfile.$.selector; 78 var selector = manageProfile.$.selector.$.selector;
78 assertTrue(!!selector); 79 assertTrue(!!selector);
79 80
80 return browserProxy.whenCalled('getAvailableIcons').then(function() { 81 return browserProxy.whenCalled('getAvailableIcons').then(function() {
81 manageProfile.profileIconUrl = 'fake-icon-2.png'; 82 manageProfile.profileIconUrl = 'fake-icon-2.png';
82 83
83 Polymer.dom.flush(); 84 Polymer.dom.flush();
84 85
85 assertEquals('fake-icon-2.png', selector.selected); 86 assertEquals('fake-icon-2.png', manageProfile.profileIconUrl);
86 assertEquals(2, selector.items.length); 87 assertEquals(2, selector.items.length);
87 assertFalse(selector.items[0].classList.contains('iron-selected')); 88 assertFalse(selector.items[0].classList.contains('iron-selected'));
88 assertTrue(selector.items[1].classList.contains('iron-selected')); 89 assertTrue(selector.items[1].classList.contains('iron-selected'));
89 }); 90 });
90 }); 91 });
91 92
92 test('ManageProfileChangeName', function() { 93 test('ManageProfileChangeName', function() {
93 var nameField = manageProfile.$.name; 94 var nameField = manageProfile.$.name;
94 assertTrue(!!nameField); 95 assertTrue(!!nameField);
95 96
(...skipping 24 matching lines...) Expand all
120 }); 121 });
121 }); 122 });
122 } 123 }
123 124
124 return { 125 return {
125 registerTests: function() { 126 registerTests: function() {
126 registerManageProfileTests(); 127 registerManageProfileTests();
127 }, 128 },
128 }; 129 };
129 }); 130 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698