from stbt import press, wait_for_match


def wait_for_vstb_startup():
    wait_for_match('stb-tester-350px.png')


def test_that_image_is_rotated_by_arrows():
    press("KEY_LEFT")
    wait_for_match('stb-tester-left.png')
    press("KEY_RIGHT")
    wait_for_match('stb-tester-right.png')
    press("KEY_UP")
    wait_for_match('stb-tester-up.png')
    press("KEY_DOWN")
    wait_for_match('stb-tester-down.png')


def test_that_image_returns_to_normal_on_OK():
    press("KEY_OK")
    wait_for_match('stb-tester-350px.png')


def test_that_custom_key_is_recognised():
    press("KEY_CUSTOM")
    wait_for_match('stb-tester-up.png', timeout_secs=1)

from stbt import press, wait_for_match


def wait_for_vstb_startup():
    wait_for_match('stb-tester-350px.png', timeout_secs=20)


def test_that_image_is_rotated_by_arrows():
    press("KEY_LEFT")
    wait_for_match('stb-tester-left.png')
    press("KEY_RIGHT")
    wait_for_match('stb-tester-right.png')
    press("KEY_UP")
    wait_for_match('stb-tester-up.png')
    press("KEY_DOWN")
    wait_for_match('stb-tester-down.png')


def test_that_image_returns_to_normal_on_OK():
    press("KEY_OK")
    wait_for_match('stb-tester-350px.png')


def test_that_custom_key_is_recognised():
    press("KEY_CUSTOM")
    wait_for_match('stb-tester-up.png', timeout_secs=1)

Fix virtual-stb intermittant test-failure on Travis
Fix virtual-stb intermittant test-failure on Travis

test_that_virtual_stb_configures_stb_tester_for_testing_virtual_stbs fails
intermittently on Travis because sometimes chrome takes longer than 10s to
start-up.  This causes the test to fail with:

> MatchTimeout: Didn't find match for '.../stb-tester-350px.png' within 10
> seconds

This commit should fix that issue.

  from stbt import press, wait_for_match
  
  
  def wait_for_vstb_startup():
-     wait_for_match('stb-tester-350px.png')
+     wait_for_match('stb-tester-350px.png', timeout_secs=20)
  
  
  def test_that_image_is_rotated_by_arrows():
      press("KEY_LEFT")
      wait_for_match('stb-tester-left.png')
      press("KEY_RIGHT")
      wait_for_match('stb-tester-right.png')
      press("KEY_UP")
      wait_for_match('stb-tester-up.png')
      press("KEY_DOWN")
      wait_for_match('stb-tester-down.png')
  
  
  def test_that_image_returns_to_normal_on_OK():
      press("KEY_OK")
      wait_for_match('stb-tester-350px.png')
  
  
  def test_that_custom_key_is_recognised():
      press("KEY_CUSTOM")
      wait_for_match('stb-tester-up.png', timeout_secs=1)
  
Fix virtual-stb intermittant test-failure on Travis
## Code Before:
from stbt import press, wait_for_match


def wait_for_vstb_startup():
    wait_for_match('stb-tester-350px.png')


def test_that_image_is_rotated_by_arrows():
    press("KEY_LEFT")
    wait_for_match('stb-tester-left.png')
    press("KEY_RIGHT")
    wait_for_match('stb-tester-right.png')
    press("KEY_UP")
    wait_for_match('stb-tester-up.png')
    press("KEY_DOWN")
    wait_for_match('stb-tester-down.png')


def test_that_image_returns_to_normal_on_OK():
    press("KEY_OK")
    wait_for_match('stb-tester-350px.png')


def test_that_custom_key_is_recognised():
    press("KEY_CUSTOM")
    wait_for_match('stb-tester-up.png', timeout_secs=1)

## Instruction:
Fix virtual-stb intermittant test-failure on Travis
## Code After:
from stbt import press, wait_for_match


def wait_for_vstb_startup():
    wait_for_match('stb-tester-350px.png', timeout_secs=20)


def test_that_image_is_rotated_by_arrows():
    press("KEY_LEFT")
    wait_for_match('stb-tester-left.png')
    press("KEY_RIGHT")
    wait_for_match('stb-tester-right.png')
    press("KEY_UP")
    wait_for_match('stb-tester-up.png')
    press("KEY_DOWN")
    wait_for_match('stb-tester-down.png')


def test_that_image_returns_to_normal_on_OK():
    press("KEY_OK")
    wait_for_match('stb-tester-350px.png')


def test_that_custom_key_is_recognised():
    press("KEY_CUSTOM")
    wait_for_match('stb-tester-up.png', timeout_secs=1)
