1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Base class representing GTest test packages."""
10 class TestPackage(object):
12 """A helper base class for both APK and stand-alone executables.
15 suite_name: Name of the test suite (e.g. base_unittests).
17 def __init__(self, suite_name):
18 self.suite_name = suite_name
20 def ClearApplicationState(self, adb):
21 """Clears the application state.
24 adb: Instance of AndroidCommands.
26 raise NotImplementedError('Method must be overriden.')
28 def CreateCommandLineFileOnDevice(self, adb, test_filter, test_arguments):
29 """Creates a test runner script and pushes to the device.
32 adb: Instance of AndroidCommands.
33 test_filter: A test_filter flag.
34 test_arguments: Additional arguments to pass to the test binary.
36 raise NotImplementedError('Method must be overriden.')
38 def GetAllTests(self, adb):
39 """Returns a list of all tests available in the test suite.
42 adb: Instance of AndroidCommands.
44 raise NotImplementedError('Method must be overriden.')
46 def GetGTestReturnCode(self, adb):
49 def SpawnTestProcess(self, adb):
50 """Spawn the test process.
53 adb: Instance of AndroidCommands.
56 An instance of pexpect spawn class.
58 raise NotImplementedError('Method must be overriden.')
60 def Install(self, adb):
61 """Install the test package to the device.
64 adb: Instance of AndroidCommands.
66 raise NotImplementedError('Method must be overriden.')
68 def _ParseGTestListTests(self, raw_list):
69 """Parses a raw test list as provided by --gtest_list_tests.
72 raw_list: The raw test listing with the following format:
75 SendMessageInChannelConnected
78 DISABLED_SendWithTimeoutMixedOKAndTimeout
81 A list of all tests. For the above raw listing:
83 [IPCChannelTest.SendMessageInChannelConnected, IPCSyncChannelTest.Simple,
84 IPCSyncChannelTest.DISABLED_SendWithTimeoutMixedOKAndTimeout]
91 if test[0] != ' ' and not test.endswith('.'):
92 # Ignore any lines with unexpected format.
94 if test[0] != ' ' and test.endswith('.'):
97 if 'YOU HAVE' in test:
100 ret += [current + test_name]