summaryrefslogtreecommitdiff
path: root/deps/v8/build/android/pylib/local/device/local_device_instrumentation_test_run_test.py
blob: fb96ee6bbd11e3d9a228cf6b16f110064307405f (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
#!/usr/bin/env vpython
# Copyright 2017 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.

"""Tests for local_device_instrumentation_test_run."""

# pylint: disable=protected-access

import unittest

from pylib.base import base_test_result
from pylib.base import mock_environment
from pylib.base import mock_test_instance
from pylib.local.device import local_device_instrumentation_test_run

class LocalDeviceInstrumentationTestRunTest(unittest.TestCase):

  # TODO(crbug.com/797002): Decide whether the _ShouldRetry hook is worth
  # retaining and remove these tests if not.

  def testShouldRetry_failure(self):
    env = mock_environment.MockEnvironment()
    ti = mock_test_instance.MockTestInstance()
    obj = (local_device_instrumentation_test_run
           .LocalDeviceInstrumentationTestRun(env, ti))
    test = {
        'annotations': {},
        'class': 'SadTest',
        'method': 'testFailure',
        'is_junit4': True,
    }
    result = base_test_result.BaseTestResult(
        'SadTest.testFailure', base_test_result.ResultType.FAIL)
    self.assertTrue(obj._ShouldRetry(test, result))

  def testShouldRetry_retryOnFailure(self):
    env = mock_environment.MockEnvironment()
    ti = mock_test_instance.MockTestInstance()
    obj = (local_device_instrumentation_test_run
           .LocalDeviceInstrumentationTestRun(env, ti))
    test = {
        'annotations': {'RetryOnFailure': None},
        'class': 'SadTest',
        'method': 'testRetryOnFailure',
        'is_junit4': True,
    }
    result = base_test_result.BaseTestResult(
        'SadTest.testRetryOnFailure', base_test_result.ResultType.FAIL)
    self.assertTrue(obj._ShouldRetry(test, result))

  def testShouldRetry_notRun(self):
    env = mock_environment.MockEnvironment()
    ti = mock_test_instance.MockTestInstance()
    obj = (local_device_instrumentation_test_run
           .LocalDeviceInstrumentationTestRun(env, ti))
    test = {
        'annotations': {},
        'class': 'SadTest',
        'method': 'testNotRun',
        'is_junit4': True,
    }
    result = base_test_result.BaseTestResult(
        'SadTest.testNotRun', base_test_result.ResultType.NOTRUN)
    self.assertTrue(obj._ShouldRetry(test, result))


if __name__ == '__main__':
  unittest.main(verbosity=2)