Bug 1170051 - Fix issues with screen shares not correctly laying out on Loop standalone UI - remove the video dimensions from the cache when the share is stopped. r=mikedeboer

This commit is contained in:
Mark Banner 2015-06-01 11:46:31 +01:00
parent 28dbc47eef
commit 589401875c
4 changed files with 48 additions and 5 deletions

View File

@ -571,7 +571,19 @@ loop.store.ActiveRoomStore = (function() {
* Used to note the current state of receiving screenshare data.
*/
receivingScreenShare: function(actionData) {
this.setStoreState({receivingScreenShare: actionData.receiving});
if (!actionData.receiving &&
this.getStoreState().remoteVideoDimensions.screen) {
// Remove the remote video dimensions for type screen as we're not
// getting the share anymore.
var newDimensions = _.extend(this.getStoreState().remoteVideoDimensions);
delete newDimensions.screen;
this.setStoreState({
receivingScreenShare: actionData.receiving,
remoteVideoDimensions: newDimensions
});
} else {
this.setStoreState({receivingScreenShare: actionData.receiving});
}
},
/**

View File

@ -337,6 +337,13 @@ loop.shared.mixins = (function() {
cache[videoType].aspectRatio = this.getAspectRatio(cache[videoType]);
}
}, this);
// Remove any streams that are no longer being published.
cacheKeys.forEach(function(videoType) {
if (!(videoType in newDimensions)) {
delete cache[videoType];
changed = true;
}
});
return changed;
},

View File

@ -1018,6 +1018,23 @@ describe("loop.store.ActiveRoomStore", function () {
expect(store.getStoreState().receivingScreenShare).eql(true);
});
it("should delete the screen remote video dimensions if screen sharing is not active", function() {
store.setStoreState({
remoteVideoDimensions: {
screen: {fake: 10},
camera: {fake: 20}
}
});
store.receivingScreenShare(new sharedActions.ReceivingScreenShare({
receiving: false
}));
expect(store.getStoreState().remoteVideoDimensions).eql({
camera: {fake: 20}
});
});
});
describe("#startScreenShare", function() {

View File

@ -465,11 +465,9 @@ describe("loop.shared.mixins", function() {
}
};
beforeEach(function() {
view.updateVideoDimensions(localVideoDimensions, remoteVideoDimensions);
});
it("should register video dimension updates correctly", function() {
view.updateVideoDimensions(localVideoDimensions, remoteVideoDimensions);
expect(view._videoDimensionsCache.local.camera.width)
.eql(localVideoDimensions.camera.width);
expect(view._videoDimensionsCache.local.camera.height)
@ -485,7 +483,16 @@ describe("loop.shared.mixins", function() {
.eql(0.32857142857142857);
});
it("should unregister video dimension updates correctly", function() {
view.updateVideoDimensions(localVideoDimensions, {});
expect("camera" in view._videoDimensionsCache.local).eql(true);
expect("camera" in view._videoDimensionsCache.remote).eql(false);
});
it("should not populate the cache on another component instance", function() {
view.updateVideoDimensions(localVideoDimensions, remoteVideoDimensions);
var view2 =
TestUtils.renderIntoDocument(React.createElement(TestComp));