Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #33569 from punamdahiya/Bug1219662
Browse files Browse the repository at this point in the history
Bug 1219662 - [Gallery] Implement fullscreen view change orientation Gij integration test
  • Loading branch information
punamdahiya committed Dec 18, 2015
2 parents fec571e + 054c1ba commit 285dc78
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 4 deletions.
47 changes: 47 additions & 0 deletions apps/gallery/test/marionette/fullscreen_image_test.js
Expand Up @@ -99,4 +99,51 @@ marionette('the gallery', function() {
fullscreen_view.fullscreenFrame3);
assert.strictEqual(translateX, 0);
});

test('Change orientation of displayed image in fullscreen', function() {
app.tapFirstThumbnail();
client.waitFor(function() {
return fullscreen_view.displayed;
});

var screen_width = fullscreen_view.screenWidth;
var screen_height = fullscreen_view.screenHeight;

// Checks the image blob is currently being displayed
assert.ok(fullscreen_view.hasSrcImageBlobURL(Gallery.ORIGIN,
fullscreen_view.displayedImage));

// Check that there are 5 options displayed beneath the picture
assert.equal(fullscreen_view.toolBarOptions.length, 5);

// Verify that the screen orientation is in portrait mode
assert.equal(fullscreen_view.screenOrientation, 'portrait');
assert.ok(fullscreen_view.fullScreenToolBar.displayed);
assert.equal(fullscreen_view.toolBarWidth, screen_width);

// Change the screen orientation to landscape mode and verify that
// the screen is in landscape mode
fullscreen_view.changeOrientation('landscape');

// Wait for orientation changes to propagate
client.helper.wait(300);
assert.equal(fullscreen_view.screenOrientation, 'landscape');
assert.ok(fullscreen_view.fullScreenToolBar.displayed);
assert.equal(fullscreen_view.toolBarWidth, screen_height);

// Change the screen orientation back to portrait and verify the screen
// is in portrait mode
fullscreen_view.changeOrientation('portrait');

// Wait for orientation changes to propagate
client.helper.wait(300);
assert.equal(fullscreen_view.screenOrientation, 'portrait');
assert.ok(fullscreen_view.fullScreenToolBar.displayed);
assert.equal(fullscreen_view.toolBarWidth, screen_width);

// Unlock the screen before exiting test
client.executeScript(function () {
window.wrappedJSObject.screen.mozUnlockOrientation();
});
});
});
69 changes: 65 additions & 4 deletions apps/gallery/test/marionette/lib/fullscreen_view.js
Expand Up @@ -43,7 +43,10 @@
editCropCanvas: '#edit-crop-canvas',
openTitle: '#filename',
openImage: '#frame > .image-view',
openSaveButton: '#save'
openSaveButton: '#save',
fullScreenToolBar: '#fullscreen-toolbar',
fullScreenToolBarOptions: '#fullscreen-toolbar > a',

});

Fullscreen_View.prototype = {
Expand Down Expand Up @@ -245,8 +248,6 @@
Fullscreen_View.Selector.editCropCanvas);
},



/**
* @return {Marionette.Element} Element to click for sharing image.
*/
Expand All @@ -255,7 +256,61 @@
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.
*/
Expand Down Expand Up @@ -375,6 +430,12 @@
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);

0 comments on commit 285dc78

Please sign in to comment.