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

Unified Diff: chrome/test/data/webui/settings/change_picture_browsertest_chromeos.js

Issue 1585963004: Settings People Revamp: Add tests for ChromeOS Change Picture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/settings/change_picture_browsertest_chromeos.js
diff --git a/chrome/test/data/webui/settings/change_picture_browsertest_chromeos.js b/chrome/test/data/webui/settings/change_picture_browsertest_chromeos.js
new file mode 100644
index 0000000000000000000000000000000000000000..f33a040eb2781de0c0fe47f6ee42a770b187210b
--- /dev/null
+++ b/chrome/test/data/webui/settings/change_picture_browsertest_chromeos.js
@@ -0,0 +1,135 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+changePictureOptions = {
+ /**
+ * True if property changes should fire events for testing purposes.
+ * @type {boolean}
+ */
+ notifyPropertyChangesForTest: true,
+};
+
+/** @fileoverview Suite of tests for settings-change-picture. */
+
+GEN_INCLUDE(['settings_page_browsertest.js']);
+
+/**
+ * @constructor
+ * @extends {SettingsPageBrowserTest}
+*/
+function SettingsChangePictureBrowserTest() {
+}
+
+SettingsChangePictureBrowserTest.prototype = {
+ __proto__: SettingsPageBrowserTest.prototype,
+
+ /** @override */
+ browsePreload: 'chrome://md-settings/changePicture',
+};
+
+// Times out on debug builders and may time out on memory bots because
+// the Settings page can take several seconds to load in a Release build
+// and several times that in a Debug build. See https://crbug.com/558434.
+GEN('#if defined(MEMORY_SANITIZER) || !defined(NDEBUG)');
+GEN('#define MAYBE_ChangePicture DISABLED_ChangePicture');
+GEN('#else');
+GEN('#define MAYBE_ChangePicture ChangePicture');
+GEN('#endif');
+
+// Runs change picture tests.
+TEST_F('SettingsChangePictureBrowserTest', 'MAYBE_ChangePicture', function() {
+ var basic = this.getPage('basic');
+ assertTrue(!!basic);
+ var peopleSection = this.getSection(basic, 'people');
+ assertTrue(!!peopleSection);
+ var peoplePage = peopleSection.querySelector('settings-people-page');
+ assertTrue(!!peoplePage);
+ var changePicture = peoplePage.$$('settings-change-picture');
+ assertTrue(!!changePicture);
+
+ /**
+ * Registers a callback to be called once when the selected image URL changes.
+ * @param {!function()} callback
+ */
+ function onceSelectedImageUrlChanged(callback) {
+ var handler = function() {
dpapad 2016/01/19 19:44:59 function whenSelectedImageUrlChanged() { return
tommycli 2016/01/20 00:30:27 Done.
+ callback();
+ changePicture.removeEventListener('selected-image-url_-changed',
+ handler);
+ };
+ changePicture.addEventListener('selected-image-url_-changed', handler);
+ };
+
+ suite('SettingsChangePicturePage', function() {
+ setup(function() {
+ // Reset the selected image to nothing.
+ changePicture.selectedImageUrl_ = '';
+ });
+
+ test('select profile image', function() {
+ var profileImage = changePicture.$$('#profile-image');
+ assertTrue(!!profileImage);
+
+ return new Promise(function(resolve) {
+ // Expect the profile image to be selected.
+ onceSelectedImageUrlChanged(function() {
dpapad 2016/01/19 19:44:59 No need to pass your assertions as a callback. See
tommycli 2016/01/20 00:30:27 Done. That is much better.
+ expectEquals(changePicture.selectedImageUrl_,
+ changePicture.profileImageUrl_);
+
+ Polymer.dom.flush();
+ expectTrue(profileImage.active);
+
+ resolve();
+ });
+ MockInteractions.tap(profileImage);
+ });
+ });
+
+ test('select old images', function() {
+ // By default there is no old image.
+ var oldImage = changePicture.$$('#old-image');
+ assertFalse(!!oldImage);
+
+ return new Promise(function(resolve) {
+ // Expect the old image to be selected once an old image is sent via
+ // the native interface.
+ onceSelectedImageUrlChanged(function() {
+ expectEquals(changePicture.selectedImageUrl_,
+ changePicture.oldImageUrl_);
+
+ Polymer.dom.flush();
+ var oldImage = changePicture.$$('#old-image');
+ assertTrue(!!oldImage);
+ expectTrue(oldImage.active);
+
+ resolve();
+ });
+ settings.ChangePicturePage.receiveOldImage('fake-old-image.jpg');
+ });
+ });
+
+ test('select first default image', function() {
+ var firstDefaultImage = changePicture.$$('.default-image');
+ console.log(firstDefaultImage);
+ assertTrue(!!firstDefaultImage);
+
+ return new Promise(function(resolve) {
+ // Expect the first default image to be selected.
+ onceSelectedImageUrlChanged(function() {
+ expectEquals(changePicture.selectedImageUrl_,
+ changePicture.defaultImages_[0].url);
+
+ Polymer.dom.flush();
+ expectTrue(firstDefaultImage.active);
+
+ resolve();
+ });
+ MockInteractions.tap(firstDefaultImage);
+ });
+ });
+ });
+
+ // Run all registered tests.
+ mocha.run();
+});
« chrome/browser/resources/settings/people_page/change_picture.js ('K') | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698