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

Unified Diff: build/android/pylib/host_driven/instrumentation_test_base.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: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: build/android/pylib/host_driven/instrumentation_test_base.py
diff --git a/build/android/pylib/host_driven/python_test_base.py b/build/android/pylib/host_driven/instrumentation_test_base.py
similarity index 50%
copy from build/android/pylib/host_driven/python_test_base.py
copy to build/android/pylib/host_driven/instrumentation_test_base.py
index 9d8f8faeb429ff4a3907ed5f87ef58f284bc9347..8b28fdcb994ebd066be6caf452ee8c2e20fd2490 100644
--- a/build/android/pylib/host_driven/python_test_base.py
+++ b/build/android/pylib/host_driven/instrumentation_test_base.py
@@ -1,68 +1,52 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Copyright (c) 2013 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 Android Python-driven tests.
+"""Base class for Android Python-driven instrumentation tests.
-This test case is intended to serve as the base class for any Python-driven
-tests. It is similar to the Python unitttest module in that the user's tests
-inherit from this case and add their tests in that case.
-
-When a PythonTestBase 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
-run. The test runner calls SetUp with the Android device ID which the test will
-run against. The runner runs the test method itself, collecting the result,
-and calls TearDown.
-
-Tests can basically do whatever they want in the test methods, such as call
-Java tests using _RunJavaTests. Those methods have the advantage of massaging
-the Java test results into Python test results.
+This test case serves as the base class for any test cases which intend
+to run instrumentation tests. It provides a constructor which accepts
+the relevant options and stores them in object variables.
"""
-import logging
import os
import time
-from pylib import android_commands
from pylib.base import base_test_result
from pylib.instrumentation import test_package
from pylib.instrumentation import test_result
from pylib.instrumentation import test_runner
+import python_test_base
# aka the parent of com.google.android
BASE_ROOT = 'src' + os.sep
-class PythonTestBase(object):
- """Base class for Python-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.
- # It's stored so we can do the attr lookup on demand, allowing this class
- # to be pickled, a requirement for the multiprocessing module.
- self.test_name = test_name
- class_name = self.__class__.__name__
- self.qualified_name = class_name + '.' + self.test_name
-
- def SetUp(self, options):
- self.options = options
- self.shard_index = self.options.shard_index
- self.device_id = self.options.device_id
- self.adb = android_commands.AndroidCommands(self.device_id)
- self.ports_to_forward = []
-
- def TearDown(self):
- pass
-
- def GetOutDir(self):
- return os.path.join(os.environ['CHROME_SRC'], 'out',
- self.options.build_type)
-
- def Run(self):
- logging.warning('Running Python-driven test: %s', self.test_name)
- return getattr(self, self.test_name)()
+class InstrumentationPythonTestBase(python_test_base.PythonTestBase):
bulach 2013/07/23 17:27:52 hehe, everytime I look into "host-driven" or "pyth
gkanwar1 2013/07/23 18:38:55 So the reason we need a new class to derive from i
frankf 2013/07/24 01:04:55 I think we should follow the accepted python unitt
gkanwar1 2013/07/24 17:38:04 Done.
+ """Base class for Python-driven instrumentation tests.
+
+ Args:
+ test_name: The name of the method to run as the test.
+ test_apk_path: Path to the test apk file.
+ test_apk_jar_path: Path to the accompanying jar file.
+ other args: All passed through to the instrumentation test runner. See the
+ test runner docs for details.
+ """
+
+ def __init__(self, test_name, test_apk_path, test_apk_jar_path,
+ test_data, install_apk, save_perf_json, screenshot_failures,
+ tool, wait_for_debugger, disable_assertions):
+ super(InstrumentationPythonTestBase, self).__init__(test_name)
+ self.test_apk_path = test_apk_path
+ self.test_apk_jar_path = test_apk_jar_path
+ self.test_data = test_data
+ self.install_apk = install_apk
+ self.save_perf_json = save_perf_json
+ self.screenshot_failures = screenshot_failures
+ self.wait_for_debugger = wait_for_debugger
+ self.tool = tool
+ self.disable_assertions = disable_assertions
def _RunJavaTest(self, fname, suite, test):
"""Runs a single Java test with a Java TestRunner.
@@ -77,20 +61,19 @@ class PythonTestBase(object):
"""
test = self._ComposeFullTestName(fname, suite, test)
test_pkg = test_package.TestPackage(
- self.options.test_apk_path, self.options.test_apk_jar_path)
- java_test_runner = test_runner.TestRunner(self.options.build_type,
- self.options.test_data,
- self.options.install_apk,
- self.options.save_perf_json,
- self.options.screenshot_failures,
- self.options.tool,
- self.options.wait_for_debugger,
- self.options.disable_assertions,
- self.options.push_deps,
- self.options.cleanup_test_files,
+ self.test_apk_path, self.test_apk_jar_path)
+ java_test_runner = test_runner.TestRunner(self.build_type,
+ self.test_data,
+ self.install_apk,
+ self.save_perf_json,
+ self.screenshot_failures,
+ self.tool,
+ self.wait_for_debugger,
+ self.disable_assertions,
+ self.push_deps,
+ self.cleanup_test_files,
self.device_id,
- self.shard_index, test_pkg,
- self.ports_to_forward)
+ self.shard_index, test_pkg, [])
try:
java_test_runner.SetUp()
return java_test_runner.RunTest(test)[0]
« no previous file with comments | « no previous file | build/android/pylib/host_driven/java_unittest_utils.py » ('j') | build/android/pylib/host_driven/setup.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698