Skip to content

Commit

Permalink
feat: Add support for the HUB_LANDSCAPE_SMALL (Echo Show 5) viewport (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenChen93 authored May 29, 2019
1 parent f898423 commit 707b0b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ask-sdk-core/lib/util/ViewportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Shape = interfaces.viewport.Shape;

export type ViewportProfile =
'HUB-ROUND-SMALL' |
'HUB-LANDSCAPE-SMALL' |
'HUB-LANDSCAPE-MEDIUM' |
'HUB-LANDSCAPE-LARGE' |
'MOBILE-LANDSCAPE-SMALL' |
Expand Down Expand Up @@ -152,6 +153,15 @@ export function getViewportProfile(requestEnvelope : RequestEnvelope) : Viewport
return 'HUB-ROUND-SMALL';
}

if (shape === 'RECTANGLE'
&& viewportOrientation === 'LANDSCAPE'
&& viewportDpiGroup === 'LOW'
&& ViewportSizeGroupOrder.indexOf(pixelWidthSizeGroup) <= ViewportSizeGroupOrder.indexOf('MEDIUM')
&& ViewportSizeGroupOrder.indexOf(pixelHeightSizeGroup) <= ViewportSizeGroupOrder.indexOf('XSMALL')
) {
return 'HUB-LANDSCAPE-SMALL';
}

if (shape === 'RECTANGLE'
&& viewportOrientation === 'LANDSCAPE'
&& viewportDpiGroup === 'LOW'
Expand Down
6 changes: 6 additions & 0 deletions ask-sdk-core/tst/util/ViewportUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ describe('ViewportUtils', () => {
requestEnvelope.context.Viewport.dpi = 160;
expect(getViewportProfile(requestEnvelope)).eq('HUB-ROUND-SMALL');

requestEnvelope.context.Viewport.shape = 'RECTANGLE';
requestEnvelope.context.Viewport.currentPixelHeight = 300;
requestEnvelope.context.Viewport.currentPixelWidth = 960;
requestEnvelope.context.Viewport.dpi = 160;
expect(getViewportProfile(requestEnvelope)).eq('HUB-LANDSCAPE-SMALL');

requestEnvelope.context.Viewport.shape = 'RECTANGLE';
requestEnvelope.context.Viewport.currentPixelHeight = 600;
requestEnvelope.context.Viewport.currentPixelWidth = 960;
Expand Down

0 comments on commit 707b0b2

Please sign in to comment.