This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
fullscreen_view.js
441 lines (386 loc) · 12.4 KB
/
fullscreen_view.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
/* global module */
(function(module) {
'use strict';
/**
* @constructor
* @param {Marionette.Client} client Marionette client to use.
*/
function Fullscreen_View(client) {
this.client = client.scope({
searchTimeout: 20000
});
}
module.exports = Fullscreen_View;
/**
* @const {Object}
*/
Fullscreen_View.Selector = Object.freeze({
currentImage: '#frames .current > .image-view',
fullscreenView: '#fullscreen-view',
fullscreenBackButton: '#fullscreen-back-button-tiny',
editButton: '#fullscreen-edit-button-tiny',
shareButton: '#fullscreen-share-button-tiny',
editView: '#edit-view',
editExposureButton: '#edit-exposure-button',
editCropButton: '#edit-crop-button',
editEffectButton: '#edit-effect-button',
editEnhanceButton: '#edit-enhance-button',
exposureOptions: '#exposure-slider',
cropOptions: '#edit-crop-options',
effectOptions: '#edit-effect-options',
exposureSlider: '#sliderthumb',
editCropAspectPortraitButton: '#edit-crop-aspect-portrait',
editEffectSepiaButton: '#edit-effect-sepia',
editSaveButton: '#edit-save-button',
editToolApplyButton: '#edit-tool-apply-button',
editHeader: '#edit-view gaia-header',
fullscreenFrame2: '#frame2',
fullscreenFrame3: '#frame3',
cropDoneButton: '#crop-done-button',
editCropCanvas: '#edit-crop-canvas',
openTitle: '#filename',
openImage: '#frame > .image-view',
openSaveButton: '#save',
fullScreenToolBar: '#fullscreen-toolbar',
fullScreenToolBarOptions: '#fullscreen-toolbar > a',
});
Fullscreen_View.prototype = {
client: null,
/**
* @return {Marionette.Element} Currently displayed image element.
*/
get displayedImage() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.currentImage);
},
/**
* @return {numeric} Currently displayed image width.
*/
get width() {
return this.displayedImage.size().width;
},
/**
* @return {numeric} Currently displayed image height.
*/
get height() {
return this.displayedImage.size().height;
},
/**
* @return {Marionette.Element} Container for fullscreen view of an image.
*/
get fullscreenView() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.fullscreenView);
},
/**
* @return {boolean} display status of Fullscreen View.
*/
get displayed() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.fullscreenView).displayed();
},
/**
* @return {Marionette.Element} Element to click to get back
* to thumbnail view.
*/
get fullscreenBackButton() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.fullscreenBackButton);
},
/**
* @return {Marionette.Element} Element to click for image editing mode.
*/
get editButton() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.editButton);
},
/**
* @return {Marionette.Element} Element to click for effects editing mode.
*/
get editEffectButton() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.editEffectButton);
},
/**
* @return {Marionette.Element} Element to click for the auto-enhance
* editing mode.
*/
get editEnhanceButton() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.editEnhanceButton);
},
/**
* @return {Marionette.Element} Element to click for the exposure editing
* mode.
*/
get editExposureButton() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.editExposureButton);
},
/**
* @return {Marionette.Element} Element to click for crop editing mode.
*/
get editCropButton() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.editCropButton);
},
/**
* @return {Marionette.Element} Container to host the exposure options.
*/
get exposureOptions() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.exposureOptions);
},
/**
* @return {Marionette.Element} Container to host the crop options.
*/
get cropOptions() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.cropOptions);
},
/**
* @return {Marionette.Element} Container to host the effect options.
*/
get effectOptions() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.effectOptions);
},
/**
* @return {Marionette.Element} Container to host the enhance options.
*/
get enhanceOptions() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.enhanceOptions);
},
/**
* @return {Marionette.Element}
* Element to swipe to change exposure settings.
*/
get exposureSlider() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.exposureSlider);
},
/**
* @return {Marionette.Element}
* Element to click to save changes from editing.
*/
get editSaveButton() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.editSaveButton);
},
/**
* @return {Marionette.Element} Element to apply edits in edit tool.
*/
get editToolApplyButton() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.editToolApplyButton);
},
/**
* @return {Marionette.Element} Element to click to crop an image.
*/
get editCropAspectPortraitButton() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.editCropAspectPortraitButton);
},
/**
* @return {Marionette.Element} Element to click to apply a sepia affect.
*/
get editEffectSepiaButton() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.editEffectSepiaButton);
},
/**
* @return {Marionette.Element} Container element to host fullscreen images.
*/
get fullscreenFrame2() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.fullscreenFrame2);
},
/**
* @return {Marionette.Element} Container element to host fullscreen images.
*/
get fullscreenFrame3() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.fullscreenFrame3);
},
/**
* @return {Marionette.Element} Done Button to finish crop and pick image.
*/
get cropDoneButton() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.cropDoneButton);
},
/**
* @return {Marionette.Element} edit crop canvas showing crop overlay.
*/
get editCropCanvas() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.editCropCanvas);
},
/**
* @return {Marionette.Element} Element to click for sharing image.
*/
get shareButton() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.shareButton);
},
/**
* @return {Marionette.Element} Element containing fullScreenView toolbar
*/
get fullScreenToolBar() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.fullScreenToolBar);
},
/**
* @return {numeric} fullScreenToolBar width.
*/
get toolBarWidth() {
return this.fullScreenToolBar.size().width;
},
/**
* @return {Marionette.Element} List of elements of toolbar options.
*/
get toolBarOptions() {
this.waitFor(Fullscreen_View.Selector.fullScreenToolBarOptions);
return this.client.findElements(
Fullscreen_View.Selector.fullScreenToolBarOptions);
},
/**
* @return {String} screen orientation
*/
get screenOrientation() {
var orientation = this.client.executeScript(function () {
return window.wrappedJSObject.screen.mozOrientation;
});
return orientation;
},
/**
* @return {numeric} screen width
*/
get screenWidth() {
var width = this.client.executeScript(function () {
return window.wrappedJSObject.screen.width;
});
return width;
},
/**
* @return {numeric} screen height
*/
get screenHeight() {
var height = this.client.executeScript(function () {
return window.wrappedJSObject.screen.height;
});
return height;
},
/**
* @return {Marionette.Element} element to display image opened using
* gallery app open activity.
*/
get openActivityImage() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.openImage);
},
/**
* @return {Marionette.Element} header element
* showing file name opened using gallery app open activity.
*/
get openActivityImageTitle() {
return this.client.helper.waitForElement(
Fullscreen_View.Selector.openTitle);
},
/**
* @return {Marionette.Element} save button that saves image opened using
* gallery app open activity.
*/
get openActivitySaveButton() {
return this.client.findElement(Fullscreen_View.Selector.openSaveButton);
},
/**
* Check referenced image src
* is set with the URL provided
*/
hasSrcImageBlobURL: function(appURL, image) {
var url = 'blob:' + appURL;
return image.getAttribute('src').indexOf(url) > -1;
},
/**
* Read the translateX style and return its integer value.
*/
getFrameTranslation: function(frame) {
var style = frame.getAttribute('style');
return parseInt(style.match(/.*:\s.*\((\d*).*/)[1]);
},
waitFor: function(selector) {
return this.client.helper.waitForElement(selector);
},
/**
* Wait for the image editor view to render before continuing with the tests.
*/
waitForImageEditor: function() {
this.waitFor(Fullscreen_View.Selector.editCropButton);
this.waitFor(Fullscreen_View.Selector.editEffectButton);
this.waitFor(Fullscreen_View.Selector.editExposureButton);
this.waitFor(Fullscreen_View.Selector.editEnhanceButton);
},
getExposureSliderPosition: function() {
return this.exposureSlider.text();
},
applyEditToolOptions: function() {
this.editToolApplyButton.click();
},
saveEditedImage: function() {
this.editSaveButton.click();
},
performEditHeaderCancelAction: function() {
this.waitFor(Fullscreen_View.Selector.editHeader).scriptWith(
function(header) {
var event = document.createEvent('HTMLEvents');
event.initEvent('action', true, true);
header.dispatchEvent(event);
});
},
performEditEnhanceButtonClick: function() {
this.waitFor(Fullscreen_View.Selector.editEnhanceButton).scriptWith(
function(button) {
var event = document.createEvent('HTMLEvents');
event.initEvent('click', true, true);
button.dispatchEvent(event);
});
},
applyAutoEnhance: function() {
this.client.waitFor(function() {
return this.editEnhanceButton.enabled();
}.bind(this));
this.performEditEnhanceButtonClick();
},
waitForCropAspectPortraitSelected: function() {
this.client.waitFor(function() {
return this.editCropAspectPortraitButton
.getAttribute('class').indexOf('selected') > -1;
}.bind(this));
},
waitForSepiaEffectSelected: function() {
this.client.waitFor(function() {
return this.editEffectSepiaButton
.getAttribute('class').indexOf('selected') > -1;
}.bind(this));
},
waitForAutoEnhanceButtonOn: function() {
this.client.waitFor(function() {
return this.editEnhanceButton
.getAttribute('class').split(' ').indexOf('on') > -1;
}.bind(this));
},
waitForAutoEnhanceButtonOff: function() {
this.client.waitFor(function() {
return this.editEnhanceButton
.getAttribute('class').split(' ').indexOf('on') < 0;
}.bind(this));
},
changeOrientation: function(orientation) {
this.client.executeScript(function(orientation) {
window.wrappedJSObject.screen.mozLockOrientation(orientation);
}, [orientation]);
}
};
})(module);