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

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

Issue 1610973002: Settings People Revamp: Implement Change People preview pane (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0072-settings-add-tests-for-cros-choose-picture
Patch Set: Created 4 years, 11 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 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 /** @fileoverview Suite of tests for settings-change-picture. */ 5 /** @fileoverview Suite of tests for settings-change-picture. */
6 6
7 GEN_INCLUDE(['settings_page_browsertest.js']); 7 GEN_INCLUDE(['settings_page_browsertest.js']);
8 8
9 /** 9 /**
10 * @constructor 10 * @constructor
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 changePicture.addEventListener('selected-image-url_-changed', handler); 68 changePicture.addEventListener('selected-image-url_-changed', handler);
69 }); 69 });
70 } 70 }
71 71
72 suite('SettingsChangePicturePage', function() { 72 suite('SettingsChangePicturePage', function() {
73 setup(function() { 73 setup(function() {
74 // Reset the selected image to nothing. 74 // Reset the selected image to nothing.
75 changePicture.selectedImageUrl_ = ''; 75 changePicture.selectedImageUrl_ = '';
76 }); 76 });
77 77
78 test('select camera image', function() {
79 var cameraImage = changePicture.$$('#camera-image');
80 assertTrue(!!cameraImage);
81
82 expectFalse(changePicture.cameraActive);
dpapad 2016/01/21 18:11:40 Why are we using expect() here instead of assert()
tommycli 2016/01/21 18:47:05 Done.
83 expectFalse(changePicture.$.previewImage.hidden);
84
85 MockInteractions.tap(cameraImage);
86
87 Polymer.dom.flush();
88
89 expectTrue(changePicture.cameraActive);
90 expectTrue(changePicture.$.previewImage.hidden);
91 });
92
78 test('select profile image', function() { 93 test('select profile image', function() {
79 var profileImage = changePicture.$$('#profile-image'); 94 var profileImage = changePicture.$$('#profile-image');
80 assertTrue(!!profileImage); 95 assertTrue(!!profileImage);
81 96
82 MockInteractions.tap(profileImage); 97 MockInteractions.tap(profileImage);
83 98
84 return whenSelectedImageUrlChanged().then(function() { 99 return whenSelectedImageUrlChanged().then(function() {
85 expectEquals(changePicture.selectedImageUrl_, 100 expectEquals(changePicture.selectedImageUrl_,
86 changePicture.profileImageUrl_); 101 changePicture.profileImageUrl_);
87 102
88 Polymer.dom.flush(); 103 Polymer.dom.flush();
89 expectTrue(profileImage.active); 104 expectTrue(profileImage.active);
105 expectFalse(changePicture.$.previewImage.hidden);
90 }); 106 });
91 }); 107 });
92 108
93 test('select old images', function() { 109 test('select old images', function() {
94 // By default there is no old image. 110 // By default there is no old image.
95 var oldImage = changePicture.$$('#old-image'); 111 var oldImage = changePicture.$$('#old-image');
96 assertFalse(!!oldImage); 112 assertFalse(!!oldImage);
97 113
98 // The promise must start listening for the property change before 114 // The promise must start listening for the property change before
99 // we make the fake API call. 115 // we make the fake API call.
100 var promise = whenSelectedImageUrlChanged(); 116 var promise = whenSelectedImageUrlChanged();
101 117
102 settings.ChangePicturePage.receiveOldImage('fake-old-image.jpg'); 118 settings.ChangePicturePage.receiveOldImage('fake-old-image.jpg');
103 119
104 return promise.then(function() { 120 return promise.then(function() {
105 // Expect the old image to be selected once an old image is sent via 121 // Expect the old image to be selected once an old image is sent via
106 // the native interface. 122 // the native interface.
107 expectEquals(changePicture.selectedImageUrl_, 123 expectEquals(changePicture.selectedImageUrl_,
108 changePicture.oldImageUrl_); 124 changePicture.oldImageUrl_);
109 125
110 Polymer.dom.flush(); 126 Polymer.dom.flush();
111 var oldImage = changePicture.$$('#old-image'); 127 var oldImage = changePicture.$$('#old-image');
112 assertTrue(!!oldImage); 128 assertTrue(!!oldImage);
113 expectTrue(oldImage.active); 129 expectTrue(oldImage.active);
130 expectFalse(changePicture.$.previewImage.hidden);
114 }); 131 });
115 }); 132 });
116 133
117 test('select first default image', function() { 134 test('select first default image', function() {
118 var firstDefaultImage = changePicture.$$('.default-image'); 135 var firstDefaultImage = changePicture.$$('.default-image');
119 console.log(firstDefaultImage); 136 console.log(firstDefaultImage);
120 assertTrue(!!firstDefaultImage); 137 assertTrue(!!firstDefaultImage);
121 138
122 MockInteractions.tap(firstDefaultImage); 139 MockInteractions.tap(firstDefaultImage);
123 140
124 return whenSelectedImageUrlChanged().then(function() { 141 return whenSelectedImageUrlChanged().then(function() {
125 // Expect the first default image to be selected. 142 // Expect the first default image to be selected.
126 expectEquals(changePicture.selectedImageUrl_, 143 expectEquals(changePicture.selectedImageUrl_,
127 changePicture.defaultImages_[0].url); 144 changePicture.defaultImages_[0].url);
128 145
129 Polymer.dom.flush(); 146 Polymer.dom.flush();
130 expectTrue(firstDefaultImage.active); 147 expectTrue(firstDefaultImage.active);
148 expectFalse(changePicture.$.previewImage.hidden);
131 }); 149 });
132 }); 150 });
133 }); 151 });
134 152
135 // Run all registered tests. 153 // Run all registered tests.
136 mocha.run(); 154 mocha.run();
137 }); 155 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698