summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/build/android/pylib/base/environment.py
blob: 744c392c1bc17346a8c8e7c8b8073657e4fa4dab (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
# 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.


class Environment(object):
  """An environment in which tests can be run.

  This is expected to handle all logic that is applicable to an entire specific
  environment but is independent of the test type.

  Examples include:
    - The local device environment, for running tests on devices attached to
      the local machine.
    - The local machine environment, for running tests directly on the local
      machine.
  """

  def __init__(self, output_manager):
    """Environment constructor.

    Args:
      output_manager: Instance of |output_manager.OutputManager| used to
          save test output.
    """
    self._output_manager = output_manager

    # Some subclasses have different teardown behavior on receiving SIGTERM.
    self._received_sigterm = False

  def SetUp(self):
    raise NotImplementedError

  def TearDown(self):
    raise NotImplementedError

  def __enter__(self):
    self.SetUp()
    return self

  def __exit__(self, _exc_type, _exc_val, _exc_tb):
    self.TearDown()

  @property
  def output_manager(self):
    return self._output_manager

  def ReceivedSigterm(self):
    self._received_sigterm = True