blob: 0c7db9826ac0b4707cf9abb18bbc31f17255914e [file] [log] [blame]
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
from autotest_lib.client.common_lib import error
from autotest_lib.client.common_lib.cros import chrome
from autotest_lib.client.cros import touch_playback_test_base
class touch_TouchscreenZoom(touch_playback_test_base.touch_playback_test_base):
"""Plays back touchscreen zoom and checks for correct page movement.
Test zooms in and then out, checking that direction is correct.
version = 1
_DIRECTIONS = ['in', 'out']
_FILENAME_FMT_STR = 'zoom-%s'
def _check_zoom_in_one_direction(self, direction):'Starting to zoom %s', direction)
start_level = self._events.get_page_width()
self._playback(self._filepaths[direction], 'touchscreen')
end_level = self._events.get_page_width()
delta = end_level - start_level
if delta == 0:
raise error.TestFail('No page zoom occurred!')
if ((delta > 0 and direction == 'in') or
(delta < 0 and direction == 'out')):
raise error.TestFail('Zoom was in the wrong direction!')
def _is_testable(self):
"""Return True if test can run on this device, else False.
@raises: TestError if host has no touchscreen when it should.
# Raise error if no touchscreen detected.
if not self._has_touchscreen:
raise error.TestError('No touchscreen found on this device!')
# Check if playback files are available on DUT to run test.
self._filepaths = self._find_test_files_from_directions(
'touchscreen', self._FILENAME_FMT_STR, self._DIRECTIONS)
if not self._filepaths:'Missing gesture files, Aborting test.')
return False
return True
def run_once(self):
"""Entry point of this test."""
if not self._is_testable():
# Log in and start test.
with chrome.Chrome() as cr:
# Zoom in and out on test page.
for direction in self._DIRECTIONS: