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

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

Issue 19537004: [Android] Converts host driven tests to common test_dispatcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sharding_refactoring
Patch Set: Removes uiautomator host-driven interface 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
OLDNEW
(Empty)
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.
4
5 """Base class for host-driven test cases.
6
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
9 inherit from this class and add methods which will be run as tests.
10
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
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
15 itself, collecting the result, and calls TearDown.
16 """
17
18 import logging
19 import os
20
21 from pylib import android_commands
22
23
24 class HostDrivenTestCase(object):
25 """Base class for host-driven test cases."""
26
27 _HOST_DRIVEN_TAG = 'HostDriven'
28
29 def __init__(self, test_name):
30 # test_name must match one of the test methods defined on a subclass which
31 # inherits from this class.
32 self.test_name = test_name
33 class_name = self.__class__.__name__
34 self.qualified_name = '%s.%s' % (class_name, self.test_name)
35 # Use tagged_name when creating results, so that we can identify host-driven
36 # tests in the overall results.
37 self.tagged_name = '%s_%s' % (self._HOST_DRIVEN_TAG, self.qualified_name)
38
39 def SetUp(self, device, shard_index, build_type, push_deps,
40 cleanup_test_files):
41 self.device_id = device
42 self.shard_index = shard_index
43 self.build_type = build_type
44 self.adb = android_commands.AndroidCommands(self.device_id)
45 self.push_deps = push_deps
46 self.cleanup_test_files = cleanup_test_files
47
48 def TearDown(self):
49 pass
50
51 def GetOutDir(self):
52 return os.path.join(os.environ['CHROME_SRC'], 'out',
53 self.build_type)
54
55 def Run(self):
56 logging.info('Running host-driven test: %s', self.test_name)
57 # Get the test method on the derived class and execute it
58 return getattr(self, self.test_name)()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698