| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_change_picture', function() { | 5 cr.define('settings_people_page_change_picture', function() { |
| 6 /** | 6 /** |
| 7 * @constructor | 7 * @constructor |
| 8 * @implements {settings.ChangePictureBrowserProxy} | 8 * @implements {settings.ChangePictureBrowserProxy} |
| 9 * @extends {TestBrowserProxy} | 9 * @extends {TestBrowserProxy} |
| 10 */ | 10 */ |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 settings.ChangePictureBrowserProxyImpl.instance_ = browserProxy; | 96 settings.ChangePictureBrowserProxyImpl.instance_ = browserProxy; |
| 97 PolymerTest.clearBody(); | 97 PolymerTest.clearBody(); |
| 98 changePicture = document.createElement('settings-change-picture'); | 98 changePicture = document.createElement('settings-change-picture'); |
| 99 document.body.appendChild(changePicture); | 99 document.body.appendChild(changePicture); |
| 100 | 100 |
| 101 crCamera = changePicture.$$('cr-camera'); | 101 crCamera = changePicture.$$('cr-camera'); |
| 102 assertTrue(!!crCamera); | 102 assertTrue(!!crCamera); |
| 103 discardControlBar = changePicture.$.discardControlBar; | 103 discardControlBar = changePicture.$.discardControlBar; |
| 104 assertTrue(!!discardControlBar); | 104 assertTrue(!!discardControlBar); |
| 105 | 105 |
| 106 changePicture.currentRouteChanged(settings.Route.CHANGE_PICTURE); | 106 changePicture.currentRouteChanged(settings.routes.CHANGE_PICTURE); |
| 107 | 107 |
| 108 return browserProxy.whenCalled('initialize').then(function() { | 108 return browserProxy.whenCalled('initialize').then(function() { |
| 109 Polymer.dom.flush(); | 109 Polymer.dom.flush(); |
| 110 }); | 110 }); |
| 111 }); | 111 }); |
| 112 | 112 |
| 113 teardown(function() { changePicture.remove(); }); | 113 teardown(function() { changePicture.remove(); }); |
| 114 | 114 |
| 115 test('ChangePictureSelectCamera', function() { | 115 test('ChangePictureSelectCamera', function() { |
| 116 var cameraIcon = changePicture.$.cameraImage; | 116 var cameraIcon = changePicture.$.cameraImage; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 132 MockInteractions.tap(cameraIcon); | 132 MockInteractions.tap(cameraIcon); |
| 133 | 133 |
| 134 Polymer.dom.flush(); | 134 Polymer.dom.flush(); |
| 135 expectFalse(cameraIcon.hidden); | 135 expectFalse(cameraIcon.hidden); |
| 136 expectTrue(crCamera.cameraActive); | 136 expectTrue(crCamera.cameraActive); |
| 137 expectEquals(ChangePictureSelectionTypes.CAMERA, | 137 expectEquals(ChangePictureSelectionTypes.CAMERA, |
| 138 changePicture.selectedItem_.dataset.type); | 138 changePicture.selectedItem_.dataset.type); |
| 139 expectTrue(discardControlBar.hidden); | 139 expectTrue(discardControlBar.hidden); |
| 140 | 140 |
| 141 // Ensure that the camera is deactivated if user navigates away. | 141 // Ensure that the camera is deactivated if user navigates away. |
| 142 changePicture.currentRouteChanged(settings.Route.BASIC); | 142 changePicture.currentRouteChanged(settings.routes.BASIC); |
| 143 expectFalse(crCamera.cameraActive); | 143 expectFalse(crCamera.cameraActive); |
| 144 }); | 144 }); |
| 145 | 145 |
| 146 test('ChangePictureProfileImage', function() { | 146 test('ChangePictureProfileImage', function() { |
| 147 var profileImage = changePicture.$.profileImage; | 147 var profileImage = changePicture.$.profileImage; |
| 148 assertTrue(!!profileImage); | 148 assertTrue(!!profileImage); |
| 149 | 149 |
| 150 expectEquals(undefined, changePicture.selectedItem_); | 150 expectEquals(undefined, changePicture.selectedItem_); |
| 151 MockInteractions.tap(profileImage); | 151 MockInteractions.tap(profileImage); |
| 152 | 152 |
| 153 return browserProxy.whenCalled('selectProfileImage').then(function() { | 153 return browserProxy.whenCalled('selectProfileImage').then(function() { |
| 154 Polymer.dom.flush(); | 154 Polymer.dom.flush(); |
| 155 | 155 |
| 156 expectEquals(ChangePictureSelectionTypes.PROFILE, | 156 expectEquals(ChangePictureSelectionTypes.PROFILE, |
| 157 changePicture.selectedItem_.dataset.type); | 157 changePicture.selectedItem_.dataset.type); |
| 158 expectFalse(crCamera.cameraActive); | 158 expectFalse(crCamera.cameraActive); |
| 159 expectTrue(discardControlBar.hidden); | 159 expectTrue(discardControlBar.hidden); |
| 160 | 160 |
| 161 // Ensure that the selection is restored after navigating away and | 161 // Ensure that the selection is restored after navigating away and |
| 162 // then back to the subpage. | 162 // then back to the subpage. |
| 163 changePicture.currentRouteChanged(settings.Route.BASIC); | 163 changePicture.currentRouteChanged(settings.routes.BASIC); |
| 164 changePicture.currentRouteChanged(settings.Route.CHANGE_PICTURE); | 164 changePicture.currentRouteChanged(settings.routes.CHANGE_PICTURE); |
| 165 expectEquals(ChangePictureSelectionTypes.PROFILE, | 165 expectEquals(ChangePictureSelectionTypes.PROFILE, |
| 166 changePicture.selectedItem_.dataset.type); | 166 changePicture.selectedItem_.dataset.type); |
| 167 }); | 167 }); |
| 168 }); | 168 }); |
| 169 | 169 |
| 170 test('ChangePictureOldImage', function() { | 170 test('ChangePictureOldImage', function() { |
| 171 // By default there is no old image and the element is hidden. | 171 // By default there is no old image and the element is hidden. |
| 172 var oldImage = changePicture.$.oldImage; | 172 var oldImage = changePicture.$.oldImage; |
| 173 assertTrue(!!oldImage); | 173 assertTrue(!!oldImage); |
| 174 assertTrue(oldImage.hidden); | 174 assertTrue(oldImage.hidden); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 }); | 238 }); |
| 239 }); | 239 }); |
| 240 } | 240 } |
| 241 | 241 |
| 242 return { | 242 return { |
| 243 registerTests: function() { | 243 registerTests: function() { |
| 244 registerChangePictureTests(); | 244 registerChangePictureTests(); |
| 245 }, | 245 }, |
| 246 }; | 246 }; |
| 247 }); | 247 }); |
| OLD | NEW |