| 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.create_profile_tests', function() { | 5 cr.define('user_manager.create_profile_tests', function() { |
| 6 /** @return {!CreateProfileElement} */ | 6 /** @return {!CreateProfileElement} */ |
| 7 function createElement() { | 7 function createElement() { |
| 8 PolymerTest.clearBody(); | 8 PolymerTest.clearBody(); |
| 9 var createProfileElement = document.createElement('create-profile'); | 9 var createProfileElement = document.createElement('create-profile'); |
| 10 document.body.appendChild(createProfileElement); | 10 document.body.appendChild(createProfileElement); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 }); | 75 }); |
| 76 | 76 |
| 77 test('Sentinel item is the initially selected item', function() { | 77 test('Sentinel item is the initially selected item', function() { |
| 78 return browserProxy.whenCalled('getSignedInUsers').then(function() { | 78 return browserProxy.whenCalled('getSignedInUsers').then(function() { |
| 79 // Simulate checking the checkbox. | 79 // Simulate checking the checkbox. |
| 80 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); | 80 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); |
| 81 Polymer.dom.flush(); | 81 Polymer.dom.flush(); |
| 82 | 82 |
| 83 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); | 83 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); |
| 84 var paperMenu = dropdownMenu.querySelector('paper-menu'); | 84 var paperMenu = dropdownMenu.querySelector('paper-menu'); |
| 85 assertEquals(createProfileElement.i18n('selectAnAccount'), | 85 assertEquals(loadTimeData.getString('selectAnAccount'), |
| 86 paperMenu.selectedItem.textContent.trim()); | 86 paperMenu.selectedItem.textContent.trim()); |
| 87 }); | 87 }); |
| 88 }); | 88 }); |
| 89 | 89 |
| 90 test('Name is non-empty by default', function() { | 90 test('Name is non-empty by default', function() { |
| 91 assertEquals('profile name', createProfileElement.$.nameInput.value); | 91 assertEquals('profile name', createProfileElement.$.nameInput.value); |
| 92 }); | 92 }); |
| 93 | 93 |
| 94 test('Create button is disabled if name is empty or invalid', function() { | 94 test('Create button is disabled if name is empty or invalid', function() { |
| 95 assertEquals('profile name', createProfileElement.$.nameInput.value); | 95 assertEquals('profile name', createProfileElement.$.nameInput.value); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 124 | 124 |
| 125 // Simulate clicking 'Create'. | 125 // Simulate clicking 'Create'. |
| 126 MockInteractions.tap(createProfileElement.$.save); | 126 MockInteractions.tap(createProfileElement.$.save); |
| 127 | 127 |
| 128 // Create is not in progress. | 128 // Create is not in progress. |
| 129 assertFalse(createProfileElement.createInProgress_); | 129 assertFalse(createProfileElement.createInProgress_); |
| 130 // Message container is visible. | 130 // Message container is visible. |
| 131 assertFalse(createProfileElement.$$('#message-container').hidden); | 131 assertFalse(createProfileElement.$$('#message-container').hidden); |
| 132 // Error message is set. | 132 // Error message is set. |
| 133 assertEquals( | 133 assertEquals( |
| 134 createProfileElement.i18n('custodianAccountNotSelectedError'), | 134 loadTimeData.getString('custodianAccountNotSelectedError'), |
| 135 createProfileElement.$.message.innerHTML); | 135 createProfileElement.$.message.innerHTML); |
| 136 }); | 136 }); |
| 137 | 137 |
| 138 test('Supervised profile name is duplicate (on the device)', function() { | 138 test('Supervised profile name is duplicate (on the device)', function() { |
| 139 // Simulate checking the checkbox. | 139 // Simulate checking the checkbox. |
| 140 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); | 140 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); |
| 141 Polymer.dom.flush(); | 141 Polymer.dom.flush(); |
| 142 | 142 |
| 143 // There is an existing supervised user with this name on the device. | 143 // There is an existing supervised user with this name on the device. |
| 144 createProfileElement.$.nameInput.value = 'existing name 1'; | 144 createProfileElement.$.nameInput.value = 'existing name 1'; |
| 145 | 145 |
| 146 // Select the first signed in user. | 146 // Select the first signed in user. |
| 147 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); | 147 var dropdownMenu = createProfileElement.$$('paper-dropdown-menu'); |
| 148 var paperMenu = dropdownMenu.querySelector('paper-menu'); | 148 var paperMenu = dropdownMenu.querySelector('paper-menu'); |
| 149 paperMenu.selected = 0; | 149 paperMenu.selected = 0; |
| 150 | 150 |
| 151 // Simulate clicking 'Create'. | 151 // Simulate clicking 'Create'. |
| 152 MockInteractions.tap(createProfileElement.$.save); | 152 MockInteractions.tap(createProfileElement.$.save); |
| 153 | 153 |
| 154 return browserProxy.whenCalled('getExistingSupervisedUsers').then( | 154 return browserProxy.whenCalled('getExistingSupervisedUsers').then( |
| 155 function(args) { | 155 function(args) { |
| 156 // Create is not in progress. | 156 // Create is not in progress. |
| 157 assertFalse(createProfileElement.createInProgress_); | 157 assertFalse(createProfileElement.createInProgress_); |
| 158 // Message container is visible. | 158 // Message container is visible. |
| 159 assertFalse(createProfileElement.$$('#message-container').hidden); | 159 assertFalse(createProfileElement.$$('#message-container').hidden); |
| 160 // Error message is set. | 160 // Error message is set. |
| 161 var message = createProfileElement.i18n( | 161 var message = loadTimeData.getString( |
| 162 'managedProfilesExistingLocalSupervisedUser'); | 162 'managedProfilesExistingLocalSupervisedUser'); |
| 163 assertEquals(message, createProfileElement.$.message.innerHTML); | 163 assertEquals(message, createProfileElement.$.message.innerHTML); |
| 164 }); | 164 }); |
| 165 }); | 165 }); |
| 166 | 166 |
| 167 test('Supervised profile name is duplicate (remote)', function() { | 167 test('Supervised profile name is duplicate (remote)', function() { |
| 168 // Simulate checking the checkbox. | 168 // Simulate checking the checkbox. |
| 169 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); | 169 MockInteractions.tap(createProfileElement.$$('paper-checkbox')); |
| 170 Polymer.dom.flush(); | 170 Polymer.dom.flush(); |
| 171 | 171 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 test('Create button is disabled', function() { | 387 test('Create button is disabled', function() { |
| 388 assertTrue(createProfileElement.$.save.disabled); | 388 assertTrue(createProfileElement.$.save.disabled); |
| 389 }); | 389 }); |
| 390 }); | 390 }); |
| 391 } | 391 } |
| 392 | 392 |
| 393 return { | 393 return { |
| 394 registerTests: registerTests, | 394 registerTests: registerTests, |
| 395 }; | 395 }; |
| 396 }); | 396 }); |
| OLD | NEW |