Index: build/android/pylib/host_driven/test_case.py |
diff --git a/build/android/pylib/host_driven/test_case.py b/build/android/pylib/host_driven/test_case.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..18eefd5da700a97258b83630285d4feacdfa3f96 |
--- /dev/null |
+++ b/build/android/pylib/host_driven/test_case.py |
@@ -0,0 +1,51 @@ |
+# Copyright (c) 2012 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. |
+ |
+"""Base class for host-driven tests. |
+ |
+This test case is intended to serve as the base class for any host-driven |
+tests. It is similar to the Python unitttest module in that test cases |
+inherit from this class and add methods which will be run as tests. |
+ |
+When a HostDrivenTestCase object is instantiated, its purpose is to run only one |
+of its tests. The test runner gives it the name of the test the instance will |
frankf
2013/07/25 01:24:21
"one of its tests" -> one test method in the deriv
gkanwar1
2013/07/25 21:15:41
Done.
|
+run. The test runner calls SetUp with the device ID which the test will run |
frankf
2013/07/25 01:24:21
test -> test method everywhere
gkanwar1
2013/07/25 21:15:41
Done.
|
+against. The runner runs the test method itself, collecting the result, and |
frankf
2013/07/25 01:24:21
runner -> test runner
gkanwar1
2013/07/25 21:15:41
Done.
|
+calls TearDown. |
+""" |
+ |
+import logging |
+ |
+from pylib import android_commands |
+ |
+ |
+class HostDrivenTestCase(object): |
+ """Base class for host-driven tests.""" |
+ |
+ def __init__(self, test_name): |
+ # test_name must match one of the test methods defined on a subclass which |
+ # inherits from this class. |
+ self.test_name = test_name |
+ class_name = self.__class__.__name__ |
+ self.qualified_name = class_name + '.' + self.test_name |
+ |
+ def SetUp(self, device, shard_index, build_type, push_deps, |
+ cleanup_test_files): |
+ self.device_id = device |
+ self.shard_index = shard_index |
+ self.build_type = build_type |
+ self.adb = android_commands.AndroidCommands(self.device_id) |
+ self.push_deps = push_deps |
+ self.cleanup_test_files = cleanup_test_files |
+ |
+ def TearDown(self): |
+ pass |
+ |
+ def GetOutDir(self): |
+ return os.path.join(os.environ['CHROME_SRC'], 'out', |
+ self.build_type) |
+ |
+ def Run(self): |
+ logging.info('Running host-driven test: %s', self.test_name) |
+ return getattr(self, self.test_name)() |
frankf
2013/07/25 01:24:21
Explain what this runnable is
gkanwar1
2013/07/25 21:15:41
Done.
|