1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 * Runs a test to open a single image.
10 * @param {string} testVolumeName Test volume name passed to the addEntries
11 * function. Either 'drive' or 'local'.
12 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
13 * @return {Promise} Promise to be fulfilled with on success.
15 function openSingleImage(testVolumeName
, volumeType
) {
16 var launchedPromise
= launch(testVolumeName
, volumeType
, [ENTRIES
.desktop
]);
17 return launchedPromise
.then(function(args
) {
19 var HEIGHT
= 603; /* Inner height 570px + native header 33px. */
20 var appId
= args
.appId
;
21 var resizedWindowPromise
= gallery
.callRemoteTestUtil(
22 'resizeWindow', appId
, [WIDTH
, HEIGHT
]
24 return repeatUntil(function() {
25 return gallery
.callRemoteTestUtil('getWindows', null, []
26 ).then(function(windows
) {
27 var bounds
= windows
[appId
];
29 return pending('Window is not ready yet.');
31 if (bounds
.outerWidth
!== WIDTH
|| bounds
.outerHeight
!== HEIGHT
) {
33 'Window bounds is expected %d x %d, but is %d x %d',
43 return resizedWindowPromise
.then(function() {
44 var rootElementPromise
=
45 gallery
.waitForElement(appId
, '.gallery[mode="slide"]');
46 var imagePromise
= gallery
.waitForElement(
47 appId
, '.gallery .content canvas.image[width="760"]');
48 var fullImagePromsie
= gallery
.waitForElement(
49 appId
, '.gallery .content canvas.fullres[width="800"]');
50 return Promise
.all([rootElementPromise
, imagePromise
, fullImagePromsie
]).
52 chrome
.test
.assertEq('760', args
[1].attributes
.width
);
53 chrome
.test
.assertEq('570', args
[1].attributes
.height
);
54 chrome
.test
.assertEq('800', args
[2].attributes
.width
);
55 chrome
.test
.assertEq('600', args
[2].attributes
.height
);
62 * Runs a test to open multiple images.
64 * @param {string} testVolumeName Test volume name passed to the addEntries
65 * function. Either 'drive' or 'local'.
66 * @param {VolumeManagerCommon.VolumeType} volumeType Volume type.
67 * @return {Promise} Promise to be fulfilled with on success.
69 function openMultipleImages(testVolumeName
, volumeType
) {
70 var testEntries
= [ENTRIES
.desktop
, ENTRIES
.image3
];
71 var launchedPromise
= launch(testVolumeName
, volumeType
, testEntries
);
72 return launchedPromise
.then(function(args
) {
73 var appId
= args
.appId
;
74 var rootElementPromise
=
75 gallery
.waitForElement(appId
, '.gallery[mode="thumbnail"]');
76 var tilesPromise
= repeatUntil(function() {
77 return gallery
.callRemoteTestUtil(
80 ['.thumbnail-view .thumbnail']
81 ).then(function(tiles
) {
82 if (tiles
.length
!== 2)
83 return pending('The number of tiles is expected 2, but is %d',
88 return Promise
.all([rootElementPromise
, tilesPromise
]);
93 * The openSingleImage test for Downloads.
94 * @return {Promise} Promise to be fulfilled with on success.
96 testcase
.openSingleImageOnDownloads = function() {
97 return openSingleImage('local', 'downloads');
101 * The openSingleImage test for Google Drive.
102 * @return {Promise} Promise to be fulfilled with on success.
104 testcase
.openSingleImageOnDrive = function() {
105 return openSingleImage('drive', 'drive');
109 * The openMultiImages test for Downloads.
110 * @return {Promise} Promise to be fulfilled with on success.
112 testcase
.openMultipleImagesOnDownloads = function() {
113 return openMultipleImages('local', 'downloads');
117 * The openMultiImages test for Google Drive.
118 * @return {Promise} Promise to be fulfilled with on success.
120 testcase
.openMultipleImagesOnDrive = function() {
121 return openMultipleImages('drive', 'drive');