summaryrefslogtreecommitdiffstats
path: root/build/android/pylib/uiautomator/setup.py
blob: 1b8746b41f61c1a5b3c176511fba583fafe14834 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Generates test runner factory and tests for uiautomator tests."""

import logging

from pylib.uiautomator import test_package
from pylib.uiautomator import test_runner


def Setup(test_options, devices):
  """Runs uiautomator tests on connected device(s).

  Args:
    test_options: A UIAutomatorOptions object.
    devices: The list of that tests will run on.

  Returns:
    A tuple of (TestRunnerFactory, tests).
  """
  test_pkg = test_package.TestPackage(test_options.uiautomator_jar,
                                      test_options.uiautomator_info_jar)
  tests = test_pkg.GetAllMatchingTests(test_options.annotations,
                                       test_options.exclude_annotations,
                                       test_options.test_filter,
                                       devices)

  if not tests:
    logging.error('No uiautomator tests to run with current args.')

  def TestRunnerFactory(device, shard_index):
    return test_runner.TestRunner(
        test_options, device, shard_index, test_pkg)

  return (TestRunnerFactory, tests)