Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Side by Side Diff: build/android/pylib/host_driven/test_case.py

Issue 194843003: [Android] Lint the rest of pylib. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no more linting *.py.svn-base files. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Base class for host-driven test cases. 5 """Base class for host-driven test cases.
6 6
7 This test case is intended to serve as the base class for any host-driven 7 This test case is intended to serve as the base class for any host-driven
8 test cases. It is similar to the Python unitttest module in that test cases 8 test cases. It is similar to the Python unitttest module in that test cases
9 inherit from this class and add methods which will be run as tests. 9 inherit from this class and add methods which will be run as tests.
10 10
11 When a HostDrivenTestCase object is instantiated, its purpose is to run only one 11 When a HostDrivenTestCase object is instantiated, its purpose is to run only one
12 test method in the derived class. The test runner gives it the name of the test 12 test method in the derived class. The test runner gives it the name of the test
13 method the instance will run. The test runner calls SetUp with the device ID 13 method the instance will run. The test runner calls SetUp with the device ID
14 which the test method will run against. The test runner runs the test method 14 which the test method will run against. The test runner runs the test method
15 itself, collecting the result, and calls TearDown. 15 itself, collecting the result, and calls TearDown.
16 16
17 Tests can perform arbitrary Python commands and asserts in test methods. Tests 17 Tests can perform arbitrary Python commands and asserts in test methods. Tests
18 that run instrumentation tests can make use of the _RunJavaTestFilters helper 18 that run instrumentation tests can make use of the _RunJavaTestFilters helper
19 function to trigger Java tests and convert results into a single host-driven 19 function to trigger Java tests and convert results into a single host-driven
20 test result. 20 test result.
21 """ 21 """
22 22
23 import logging 23 import logging
24 import os 24 import os
25 import time 25 import time
26 26
27 from pylib import android_commands 27 from pylib import android_commands
28 from pylib import constants
28 from pylib import forwarder 29 from pylib import forwarder
29 from pylib import valgrind_tools 30 from pylib import valgrind_tools
30 from pylib.base import base_test_result 31 from pylib.base import base_test_result
31 from pylib.instrumentation import test_package 32 from pylib.instrumentation import test_package
32 from pylib.instrumentation import test_result 33 from pylib.instrumentation import test_result
33 from pylib.instrumentation import test_runner 34 from pylib.instrumentation import test_runner
34 35
35 # aka the parent of com.google.android 36 # aka the parent of com.google.android
36 BASE_ROOT = 'src' + os.sep 37 BASE_ROOT = 'src' + os.sep
37 38
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 self.push_deps = push_deps 77 self.push_deps = push_deps
77 self.cleanup_test_files = cleanup_test_files 78 self.cleanup_test_files = cleanup_test_files
78 if ports_to_forward: 79 if ports_to_forward:
79 self.ports_to_forward = ports_to_forward 80 self.ports_to_forward = ports_to_forward
80 81
81 def TearDown(self): 82 def TearDown(self):
82 pass 83 pass
83 84
84 # TODO(craigdh): Remove GetOutDir once references have been removed 85 # TODO(craigdh): Remove GetOutDir once references have been removed
85 # downstream. 86 # downstream.
86 def GetOutDir(self): 87 @staticmethod
88 def GetOutDir():
87 return constants.GetOutDirectory() 89 return constants.GetOutDirectory()
88 90
89 def Run(self): 91 def Run(self):
90 logging.info('Running host-driven test: %s', self.tagged_name) 92 logging.info('Running host-driven test: %s', self.tagged_name)
91 # Get the test method on the derived class and execute it 93 # Get the test method on the derived class and execute it
92 return getattr(self, self.test_name)() 94 return getattr(self, self.test_name)()
93 95
94 @staticmethod 96 @staticmethod
95 def __GetHostForwarderLog(): 97 def __GetHostForwarderLog():
96 return ('-- Begin Full HostForwarder log\n' 98 return ('-- Begin Full HostForwarder log\n'
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 overall_result.AddResult( 185 overall_result.AddResult(
184 test_result.InstrumentationTestResult( 186 test_result.InstrumentationTestResult(
185 self.tagged_name, test_type, start_ms, duration_ms, log=log)) 187 self.tagged_name, test_type, start_ms, duration_ms, log=log))
186 return overall_result 188 return overall_result
187 189
188 def __str__(self): 190 def __str__(self):
189 return self.tagged_name 191 return self.tagged_name
190 192
191 def __repr__(self): 193 def __repr__(self):
192 return self.tagged_name 194 return self.tagged_name
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/setup.py ('k') | build/android/pylib/host_driven/test_info_collection.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698