Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug that caused screenview to stay off when screenshare was toggled #7

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test does not verify the change made by hideViewport or revealViewport. It looks like other tests in this file check properties of the canvas. Could we do the same here?

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');
});
});
});