| Index: chrome/test/data/extensions/api_test/file_manager_browsertest/gallery/photo_editor.js
|
| diff --git a/chrome/test/data/extensions/api_test/file_manager_browsertest/gallery/photo_editor.js b/chrome/test/data/extensions/api_test/file_manager_browsertest/gallery/photo_editor.js
|
| index 0de4a9c1be5e938546f259fe6cbda7842b16f30b..2140fa6314f570f99c8e306e1f18095cf1b6b322 100644
|
| --- a/chrome/test/data/extensions/api_test/file_manager_browsertest/gallery/photo_editor.js
|
| +++ b/chrome/test/data/extensions/api_test/file_manager_browsertest/gallery/photo_editor.js
|
| @@ -5,6 +5,20 @@
|
| 'use strict';
|
|
|
| /**
|
| + * Waits for the "Press Enter" message.
|
| + *
|
| + * @param {AppWindow} appWindow App window.
|
| + * @return {Promise} Promise to be fulfilled when the element appears.
|
| + */
|
| +function waitForPressEnterMessage(appWindow) {
|
| + return waitForElement(appWindow, '.prompt-wrapper .prompt').
|
| + then(function(element) {
|
| + chrome.test.assertEq(
|
| + 'Press Enter when done', element.innerText.trim());
|
| + });
|
| +}
|
| +
|
| +/**
|
| * Prepares the photo editor.
|
| *
|
| * @param {string} testVolumeName Test volume name passed to the addEntries
|
| @@ -89,14 +103,10 @@ function cropImage(testVolumeName, volumeType) {
|
| var appWindow = args.appWindow;
|
| return waitAndClickElement(appWindow, '.gallery:not([locked]) button.crop').
|
| then(function() {
|
| - var promptPromise =
|
| - waitForElement(appWindow, '.prompt-wrapper .prompt').
|
| - then(function(element) {
|
| - chrome.test.assertEq(
|
| - 'Press Enter when done', element.innerText.trim());
|
| - });
|
| - var cropOverlay = waitForElement(appWindow, '.crop-overlay');
|
| - return Promise.all([promptPromise, cropOverlay]);
|
| + return Promise.all([
|
| + waitForPressEnterMessage(appWindow),
|
| + waitForElement(appWindow, '.crop-overlay')
|
| + ]);
|
| }).
|
| then(function() {
|
| chrome.test.assertTrue(sendKeyDown(appWindow, 'body', 'Enter'));
|
| @@ -118,6 +128,77 @@ function cropImage(testVolumeName, volumeType) {
|
| }
|
|
|
| /**
|
| + * Obtains metadata from an entry.
|
| + *
|
| + * @param {Entry} entry Entry.
|
| + * @return {Promise} Promise to be fulfilled with the result metadata.
|
| + */
|
| +function getMetadata(entry) {
|
| + return new Promise(entry.getMetadata.bind(entry));
|
| +}
|
| +
|
| +/**
|
| + * Tests to exposure an image.
|
| + *
|
| + * @param {string} testVolumeName Test volume name passed to the addEntries
|
| + * function. Either 'drive' or 'local'.
|
| + * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
|
| + * @return {Promise} Promise to be fulfilled with on success.
|
| + */
|
| +function exposureImage(testVolumeName, volumeType) {
|
| + var launchedPromise = setupPhotoEditor(testVolumeName, volumeType);
|
| + return launchedPromise.then(function(args) {
|
| + var appWindow = args.appWindow;
|
| + var entry = args.entries[0];
|
| + var buttonQuery = '.gallery:not([locked]) button.exposure';
|
| +
|
| + // Click the exposure button.
|
| + return waitAndClickElement(appWindow, buttonQuery).then(function() {
|
| + // Wait until the edit controls appear.
|
| + return Promise.all([
|
| + waitForPressEnterMessage(appWindow),
|
| + waitForElement(appWindow, 'input.range[name="brightness"]'),
|
| + waitForElement(appWindow, 'input.range[name="contrast"]'),
|
| + ]);
|
| + }).then(function(results) {
|
| + // Update bright.
|
| + var brightnessRange = results[1];
|
| + brightnessRange.value = 20;
|
| + chrome.test.assertTrue(
|
| + brightnessRange.dispatchEvent(new Event('change')));
|
| +
|
| + // Update contrast.
|
| + var contrastRange = results[2];
|
| + contrastRange.value = -20;
|
| + chrome.test.assertTrue(
|
| + contrastRange.dispatchEvent(new Event('change')));
|
| +
|
| + return getMetadata(entry).then(function(firstMetadata) {
|
| + // Push the Enter key.
|
| + chrome.test.assertTrue(sendKeyDown(appWindow, 'body', 'Enter'));
|
| +
|
| + // Wait until the image is updated.
|
| + return repeatUntil(function() {
|
| + return getMetadata(entry).then(function(secondMetadata) {
|
| + if (firstMetadata.modificationTime !=
|
| + secondMetadata.modificationTime) {
|
| + return true;
|
| + } else {
|
| + return pending(
|
| + '%s is not updated. ' +
|
| + 'First last modified: %s, Second last modified: %s.',
|
| + entry.name,
|
| + firstMetadata.modificationTime.toString(),
|
| + secondMetadata.modificationTime.toString());
|
| + }
|
| + });
|
| + });
|
| + });
|
| + });
|
| + });
|
| +}
|
| +
|
| +/**
|
| * The rotateImage test for Downloads.
|
| * @return {Promise} Promise to be fulfilled with on success.
|
| */
|
| @@ -148,3 +229,19 @@ function cropImageOnDownloads() {
|
| function cropImageOnDrive() {
|
| return cropImage('drive', VolumeManagerCommon.VolumeType.DRIVE);
|
| }
|
| +
|
| +/**
|
| + * The exposureImage test for Downloads.
|
| + * @return {Promise} Promise to be fulfilled with on success.
|
| + */
|
| +function exposureImageOnDownloads() {
|
| + return exposureImage('local', VolumeManagerCommon.VolumeType.DOWNLOADS);
|
| +}
|
| +
|
| +/**
|
| + * The exposureImage test for Google Drive.
|
| + * @return {Promise} Promise to be fulfilled with on success.
|
| + */
|
| +function exposureImageOnDrive() {
|
| + return exposureImage('drive', VolumeManagerCommon.VolumeType.DRIVE);
|
| +}
|
|
|