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

Unified 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: Adds tagging of host-driven, re-adds exception handling 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/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..2f71b28265e7bf809d444e9381db76cbe7eaa66b
--- /dev/null
+++ b/build/android/pylib/host_driven/test_case.py
@@ -0,0 +1,58 @@
+# 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 test cases.
+
+This test case is intended to serve as the base class for any host-driven
+test cases. 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
+test method in the derived class. The test runner gives it the name of the test
+method the instance will run. The test runner calls SetUp with the device ID
+which the test method will run against. The test runner runs the test method
+itself, collecting the result, and calls TearDown.
+"""
+
+import logging
+import os
+
+from pylib import android_commands
+
+
+class HostDrivenTestCase(object):
+ """Base class for host-driven test cases."""
+
+ _HOST_DRIVEN_TAG = 'HostDriven'
+
+ 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 = '%s.%s' % (class_name, self.test_name)
+ # Use tagged_name when creating results, so that we can identify host-driven
+ # tests in the overall results.
+ self.tagged_name = '%s_%s' % (self._HOST_DRIVEN_TAG, self.qualified_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)
+ # Get the test method on the derived class and execute it
+ return getattr(self, self.test_name)()

Powered by Google App Engine
This is Rietveld 408576698