Skip to content

Commit

Permalink
Fix bug that caused screenview to stay off when screenshare was toggled
Browse files Browse the repository at this point in the history
  • Loading branch information
dylonChime authored and Andrew Burnson committed Dec 16, 2019
1 parent 84fa239 commit 5a13fcd
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ export default class DefaultScreenViewingComponentContext implements ScreenViewi
providers
);
signalingSession.registerObserver({
streamDidStart(_screenMessageDetail: ScreenMessageDetail): void {},
streamDidStart(_screenMessageDetail: ScreenMessageDetail): void {
deltaRenderer.revealViewport();
},
streamDidStop(_screenMessageDetail: ScreenMessageDetail): void {
deltaRenderer.close();
deltaRenderer.hideViewport();
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ export default class DefaultScreenViewingDeltaRenderer implements ScreenViewingD
}
}

hideViewport(): void {
if (this.content) {
this.content.style.display = 'none';
}
}

revealViewport(): void {
if (this.content) {
this.content.style.display = 'block';
}
}

changePresentationPolicy(policy: PresentationPolicy): void {
this.policy = policy;
this.updatePresentation();
Expand Down
4 changes: 4 additions & 0 deletions src/screenviewing/deltarenderer/ScreenViewingDeltaRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export default interface ScreenViewingDeltaRenderer {

setViewport(viewport: HTMLElement): void;

hideViewport(): void;

revealViewport(): void;

changePresentationPolicy(policy: PresentationPolicy): void;

close(): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ describe('DefaultScreenViewingComponentContext', () => {
{
deltaRendererProvider: () => ({
...Substitute.for(),
close(): void {
hideViewport(): void {},
revealViewport(): void {
done();
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,4 +434,47 @@ describe('DefaultScreenViewingDeltaRenderer', () => {
deltaRenderer.zoomReset();
});
});

describe('hideViewport and revealViewport', () => {
it('hides and reveals the viewport', () => {
let style = {
display: 'none',
};

let canvas = {
style: style,
};

const document: SubstituteOf<Document> = Substitute.for();
document.createElement(Arg.any()).returns(canvas);
const window: SubstituteOf<Window> = Substitute.for();
window.document.returns(document);
// @ts-ignore
window.getComputedStyle(Arg.any()).returns(canvas.style);

const deltaRenderer: ScreenViewingDeltaRenderer = new DefaultScreenViewingDeltaRenderer(
controller,
logger,
window,
Substitute.for(),
Substitute.for()
);

// Test style doesn't change before setViewport
canvas.style.display = 'block';
deltaRenderer.hideViewport();
expect(style.display).to.equal('block');
style.display = 'none';
deltaRenderer.revealViewport();
expect(style.display.valueOf()).to.equal('none');

// Test style does change after setViewport
deltaRenderer.setViewport(Substitute.for());
canvas.style.display = 'block';
deltaRenderer.hideViewport();
expect(canvas.style.display).to.equal('none');
deltaRenderer.revealViewport();
expect(canvas.style.display).to.equal('block');
});
});
});

0 comments on commit 5a13fcd

Please sign in to comment.