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('user_manager.import_supervised_user_tests', function() { | 5 cr.define('user_manager.import_supervised_user_tests', function() { |
6 function registerTests() { | 6 function registerTests() { |
7 suite('ImportSupervisedUserTests', function() { | 7 suite('ImportSupervisedUserTests', function() { |
8 /** @type {?ImportSupervisedUserElement} */ | 8 /** @type {?ImportSupervisedUserElement} */ |
9 var importElement = null; | 9 var importElement = null; |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 }); | 25 }); |
26 | 26 |
27 teardown(function(done) { | 27 teardown(function(done) { |
28 importElement.remove(); | 28 importElement.remove(); |
29 // Allow asynchronous tasks to finish. | 29 // Allow asynchronous tasks to finish. |
30 setTimeout(done); | 30 setTimeout(done); |
31 }); | 31 }); |
32 | 32 |
33 test('Dialog does not show if no signed-in user is provided', function() { | 33 test('Dialog does not show if no signed-in user is provided', function() { |
34 // The dialog is initially not visible. | 34 // The dialog is initially not visible. |
35 assertFalse(importElement.$.dialog.opened); | 35 assertFalse(importElement.$.dialog.open); |
36 | 36 |
37 importElement.show(undefined, []); | 37 importElement.show(undefined, []); |
38 Polymer.dom.flush(); | 38 Polymer.dom.flush(); |
39 | 39 |
40 // The dialog is still not visible. | 40 // The dialog is still not visible. |
41 assertFalse(importElement.$.dialog.opened); | 41 assertFalse(importElement.$.dialog.open); |
42 }); | 42 }); |
43 | 43 |
44 test('Can import supervised user', function() { | 44 test('Can import supervised user', function() { |
45 return new Promise(function(resolve, reject) { | 45 return new Promise(function(resolve, reject) { |
46 /** @type {!SignedInUser} */ | 46 /** @type {!SignedInUser} */ |
47 var signedInUser = {username: 'username', | 47 var signedInUser = {username: 'username', |
48 profilePath: 'path/to/profile'}; | 48 profilePath: 'path/to/profile'}; |
49 | 49 |
50 /** @type {!Array<!SupervisedUser>} */ | 50 /** @type {!Array<!SupervisedUser>} */ |
51 var supervisedUsers = [{name: 'supervised user 1', | 51 var supervisedUsers = [{name: 'supervised user 1', |
52 onCurrentDevice: true}, | 52 onCurrentDevice: true}, |
53 {name: 'supervised user 3', | 53 {name: 'supervised user 3', |
54 onCurrentDevice: false}, | 54 onCurrentDevice: false}, |
55 {name: 'supervised user 2', | 55 {name: 'supervised user 2', |
56 onCurrentDevice: false}]; | 56 onCurrentDevice: false}]; |
57 | 57 |
58 // Expect an event to import the selected supervised user to be fired. | 58 // Expect an event to import the selected supervised user to be fired. |
59 importElement.addEventListener('import', function(event) { | 59 importElement.addEventListener('import', function(event) { |
60 if (event.detail.signedInUser == signedInUser && | 60 if (event.detail.signedInUser == signedInUser && |
61 event.detail.supervisedUser.name == 'supervised user 2') { | 61 event.detail.supervisedUser.name == 'supervised user 2') { |
62 Polymer.dom.flush(); | 62 Polymer.dom.flush(); |
63 // The dialog is no longer visible. | 63 // The dialog is no longer visible. |
64 assertFalse(importElement.$.dialog.opened); | 64 assertFalse(importElement.$.dialog.open); |
65 | 65 |
66 resolve(); | 66 resolve(); |
67 } | 67 } |
68 }); | 68 }); |
69 | 69 |
70 // The dialog is initially not visible. | 70 // The dialog is initially not visible. |
71 assertFalse(importElement.$.dialog.opened); | 71 assertFalse(importElement.$.dialog.open); |
72 | 72 |
73 importElement.show(signedInUser, supervisedUsers); | 73 importElement.show(signedInUser, supervisedUsers); |
74 Polymer.dom.flush(); | 74 Polymer.dom.flush(); |
75 | 75 |
76 // The dialog becomes visible. | 76 // The dialog becomes visible. |
77 assertTrue(importElement.$.dialog.opened); | 77 assertTrue(importElement.$.dialog.open); |
78 | 78 |
79 // The correct message is displayed. | 79 // The correct message is displayed. |
80 assertEquals(loadTimeData.getString('supervisedUserImportText'), | 80 assertEquals(loadTimeData.getString('supervisedUserImportText'), |
81 importElement.$$('#message').textContent.trim()); | 81 importElement.$$('#message').textContent.trim()); |
82 | 82 |
83 var selectorElement = importElement.$$('paper-listbox'); | 83 var selectorElement = importElement.$$('paper-listbox'); |
84 assertTrue(!!selectorElement); | 84 assertTrue(!!selectorElement); |
85 | 85 |
86 // Supervised users are ordered correctly (Ones that are not on the | 86 // Supervised users are ordered correctly (Ones that are not on the |
87 // current device appear first, then they are alphabetically order in | 87 // current device appear first, then they are alphabetically order in |
(...skipping 30 matching lines...) Expand all Loading... |
118 MockInteractions.tap(importElement.$$('#import')); | 118 MockInteractions.tap(importElement.$$('#import')); |
119 }); | 119 }); |
120 }); | 120 }); |
121 }); | 121 }); |
122 } | 122 } |
123 | 123 |
124 return { | 124 return { |
125 registerTests: registerTests, | 125 registerTests: registerTests, |
126 }; | 126 }; |
127 }); | 127 }); |
OLD | NEW |