Skip to content

Commit 6c03c8f

Browse files
authored
Add support for the HUB_LANDSCAPE_SMALL (Echo Show 5) viewport (#90)
1 parent c4bab99 commit 6c03c8f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

ask-sdk-core/ask_sdk_core/utils/viewport.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Size(OrderedEnum):
6969

7070
class ViewportProfile(Enum):
7171
HUB_ROUND_SMALL = "HUB_ROUND_SMALL"
72+
HUB_LANDSCAPE_SMALL = "HUB_LANDSCAPE_SMALL"
7273
HUB_LANDSCAPE_MEDIUM = "HUB_LANDSCAPE_MEDIUM"
7374
HUB_LANDSCAPE_LARGE = "HUB_LANDSCAPE_LARGE"
7475
MOBILE_LANDSCAPE_SMALL = "MOBILE_LANDSCAPE_SMALL"
@@ -180,6 +181,13 @@ def get_viewport_profile(request_envelope):
180181
and pixel_height_size_group is Size.XSMALL):
181182
return ViewportProfile.HUB_ROUND_SMALL
182183

184+
elif (shape is Shape.RECTANGLE
185+
and orientation is Orientation.LANDSCAPE
186+
and dpi_group is Density.LOW
187+
and pixel_width_size_group <= Size.MEDIUM
188+
and pixel_height_size_group <= Size.XSMALL):
189+
return ViewportProfile.HUB_LANDSCAPE_SMALL
190+
183191
elif (shape is Shape.RECTANGLE
184192
and orientation is Orientation.LANDSCAPE
185193
and dpi_group is Density.LOW

ask-sdk-core/tests/unit/test_utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,20 @@ def test_viewport_map_to_hub_round_small(self):
252252
is viewport.ViewportProfile.HUB_ROUND_SMALL), (
253253
"Viewport profile couldn't resolve HUB_ROUND_SMALL")
254254

255+
def test_viewport_map_to_hub_landscape_small(self):
256+
viewport_state = ViewportState(
257+
shape=Shape.RECTANGLE,
258+
dpi=float(160),
259+
current_pixel_width=float(960),
260+
current_pixel_height=float(480))
261+
test_request_env = RequestEnvelope(
262+
context=Context(
263+
viewport=viewport_state))
264+
265+
assert (viewport.get_viewport_profile(test_request_env)
266+
is viewport.ViewportProfile.HUB_LANDSCAPE_SMALL), (
267+
"Viewport profile couldn't resolve HUB_LANDSCAPE_SMALL")
268+
255269
def test_viewport_map_to_hub_landscape_medium(self):
256270
viewport_state = ViewportState(
257271
shape=Shape.RECTANGLE,

0 commit comments

Comments
 (0)