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

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

Issue 22933005: [android] Make build_type a singleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
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 _RunJavaTests helper function 18 that run instrumentation tests can make use of the _RunJavaTests helper function
19 to trigger Java tests and convert results into a single host-driven test result. 19 to trigger Java tests and convert results into a single host-driven test result.
20 """ 20 """
21 21
22 import logging 22 import logging
23 import os 23 import os
24 import time 24 import time
25 25
26 from pylib import android_commands 26 from pylib import android_commands
27 from pylib import constants
27 from pylib.base import base_test_result 28 from pylib.base import base_test_result
28 from pylib.instrumentation import test_package 29 from pylib.instrumentation import test_package
29 from pylib.instrumentation import test_result 30 from pylib.instrumentation import test_result
30 from pylib.instrumentation import test_runner 31 from pylib.instrumentation import test_runner
31 32
32 # aka the parent of com.google.android 33 # aka the parent of com.google.android
33 BASE_ROOT = 'src' + os.sep 34 BASE_ROOT = 'src' + os.sep
34 35
35 36
36 class HostDrivenTestCase(object): 37 class HostDrivenTestCase(object):
(...skipping 11 matching lines...) Expand all
48 self.test_name = test_name 49 self.test_name = test_name
49 class_name = self.__class__.__name__ 50 class_name = self.__class__.__name__
50 self.qualified_name = '%s.%s' % (class_name, self.test_name) 51 self.qualified_name = '%s.%s' % (class_name, self.test_name)
51 # Use tagged_name when creating results, so that we can identify host-driven 52 # Use tagged_name when creating results, so that we can identify host-driven
52 # tests in the overall results. 53 # tests in the overall results.
53 self.tagged_name = '%s_%s' % (self._HOST_DRIVEN_TAG, self.qualified_name) 54 self.tagged_name = '%s_%s' % (self._HOST_DRIVEN_TAG, self.qualified_name)
54 55
55 self.instrumentation_options = instrumentation_options 56 self.instrumentation_options = instrumentation_options
56 self.ports_to_forward = [] 57 self.ports_to_forward = []
57 58
58 def SetUp(self, device, shard_index, build_type, push_deps, 59 def SetUp(self, device, shard_index, push_deps,
59 cleanup_test_files): 60 cleanup_test_files):
60 self.device_id = device 61 self.device_id = device
61 self.shard_index = shard_index 62 self.shard_index = shard_index
62 self.build_type = build_type
63 self.adb = android_commands.AndroidCommands(self.device_id) 63 self.adb = android_commands.AndroidCommands(self.device_id)
64 self.push_deps = push_deps 64 self.push_deps = push_deps
65 self.cleanup_test_files = cleanup_test_files 65 self.cleanup_test_files = cleanup_test_files
66 66
67 def TearDown(self): 67 def TearDown(self):
68 pass 68 pass
69 69
70 def GetOutDir(self): 70 def GetOutDir(self):
71 return os.path.join(os.environ['CHROME_SRC'], 'out', 71 return os.path.join(os.environ['CHROME_SRC'], 'out',
72 self.build_type) 72 constants.GetBuildType())
73 73
74 def Run(self): 74 def Run(self):
75 logging.info('Running host-driven test: %s', self.tagged_name) 75 logging.info('Running host-driven test: %s', self.tagged_name)
76 # Get the test method on the derived class and execute it 76 # Get the test method on the derived class and execute it
77 return getattr(self, self.test_name)() 77 return getattr(self, self.test_name)()
78 78
79 def __RunJavaTest(self, package_name, test_case, test_method): 79 def __RunJavaTest(self, package_name, test_case, test_method):
80 """Runs a single Java test method with a Java TestRunner. 80 """Runs a single Java test method with a Java TestRunner.
81 81
82 Args: 82 Args:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 overall_result.AddResult( 142 overall_result.AddResult(
143 test_result.InstrumentationTestResult( 143 test_result.InstrumentationTestResult(
144 self.tagged_name, test_type, start_ms, duration_ms, log=log)) 144 self.tagged_name, test_type, start_ms, duration_ms, log=log))
145 return overall_result 145 return overall_result
146 146
147 def __str__(self): 147 def __str__(self):
148 return self.tagged_name 148 return self.tagged_name
149 149
150 def __repr__(self): 150 def __repr__(self):
151 return self.tagged_name 151 return self.tagged_name
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698