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

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..52a977f6bbe2dfd76f504684d1bcb93df81389f1
--- /dev/null
+++ b/chrome/test/data/webui/settings/change_picture_browsertest_chromeos.js
@@ -0,0 +1,137 @@
+// 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.
+
+/** @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',
+
+ /** @override */
+ preLoad: function() {
+ cr.define('settings_test', function() {
+ var changePictureOptions = {
+ /**
+ * True if property changes should fire events for testing purposes.
+ * @type {boolean}
+ */
+ notifyPropertyChangesForTest: true,
+ };
+ return {changePictureOptions: changePictureOptions};
+ });
+ }
+};
+
+// 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 whenSelectedImageUrlChanged() {
+ return new Promise(function(resolve, reject) {
+ var handler = function() {
+ changePicture.removeEventListener('selected-image-url_-changed',
+ handler);
+ resolve();
+ };
+ 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);
+
+ MockInteractions.tap(profileImage);
+
+ return whenSelectedImageUrlChanged().then(function() {
+ expectEquals(changePicture.selectedImageUrl_,
+ changePicture.profileImageUrl_);
+
+ Polymer.dom.flush();
+ expectTrue(profileImage.active);
+ });
+ });
+
+ test('select old images', function() {
+ // By default there is no old image.
+ var oldImage = changePicture.$$('#old-image');
+ assertFalse(!!oldImage);
+
+ // The promise must start listening for the property change before
+ // we make the fake API call.
+ var promise = whenSelectedImageUrlChanged();
+
+ settings.ChangePicturePage.receiveOldImage('fake-old-image.jpg');
+
+ return promise.then(function() {
+ // Expect the old image to be selected once an old image is sent via
+ // the native interface.
+ expectEquals(changePicture.selectedImageUrl_,
+ changePicture.oldImageUrl_);
+
+ Polymer.dom.flush();
+ var oldImage = changePicture.$$('#old-image');
+ assertTrue(!!oldImage);
+ expectTrue(oldImage.active);
+ });
+ });
+
+ test('select first default image', function() {
+ var firstDefaultImage = changePicture.$$('.default-image');
+ console.log(firstDefaultImage);
+ assertTrue(!!firstDefaultImage);
+
+ MockInteractions.tap(firstDefaultImage);
+
+ return whenSelectedImageUrlChanged().then(function() {
+ // Expect the first default image to be selected.
+ expectEquals(changePicture.selectedImageUrl_,
+ changePicture.defaultImages_[0].url);
+
+ Polymer.dom.flush();
+ expectTrue(firstDefaultImage.active);
+ });
+ });
+ });
+
+ // 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