summaryrefslogtreecommitdiffstats
path: root/build/android/pylib/uirobot/uirobot_test_instance.py
blob: 1891ab7782b78deb54cc018b1d7660f80e7ab36f (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Copyright 2014 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.

import json
import logging

from devil.android import apk_helper
from pylib.base import test_instance

class UirobotTestInstance(test_instance.TestInstance):

  def __init__(self, args, error_func):
    """Constructor.

    Args:
      args: Command line arguments.
    """
    super(UirobotTestInstance, self).__init__()
    if not args.app_under_test:
      error_func('Must set --app-under-test.')
    self._app_under_test = args.app_under_test
    self._minutes = args.minutes

    if args.remote_device_file:
      with open(args.remote_device_file) as remote_device_file:
        device_json = json.load(remote_device_file)
    else:
      device_json = {}
    device_type = device_json.get('device_type', 'Android')
    if args.device_type:
      if device_type and device_type != args.device_type:
        logging.info('Overriding device_type from %s to %s',
                     device_type, args.device_type)
      device_type = args.device_type

    if device_type == 'Android':
      self._suite = 'Android Uirobot'
      self._package_name = apk_helper.GetPackageName(self._app_under_test)
    elif device_type == 'iOS':
      self._suite = 'iOS Uirobot'
      self._package_name = self._app_under_test


  #override
  def TestType(self):
    """Returns type of test."""
    return 'uirobot'

  #override
  def SetUp(self):
    """Setup for test."""
    pass

  #override
  def TearDown(self):
    """Teardown for test."""
    pass

  @property
  def app_under_test(self):
    """Returns the app to run the test on."""
    return self._app_under_test

  @property
  def minutes(self):
    """Returns the number of minutes to run the uirobot for."""
    return self._minutes

  @property
  def package_name(self):
    """Returns the name of the package in the APK."""
    return self._package_name

  @property
  def suite(self):
    return self._suite