michael@0: # Copyright (c) 2012 The Chromium Authors. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: """This file is imported by python tests ran by run_python_tests.py.""" michael@0: michael@0: import os michael@0: michael@0: import android_commands michael@0: from run_java_tests import TestRunner michael@0: michael@0: michael@0: def _GetPackageName(fname): michael@0: """Extracts the package name from the test file path.""" michael@0: base_root = os.path.join('com', 'google', 'android') michael@0: dirname = os.path.dirname(fname) michael@0: package = dirname[dirname.rfind(base_root):] michael@0: return package.replace(os.sep, '.') michael@0: michael@0: michael@0: def RunJavaTest(fname, suite, test, ports_to_forward): michael@0: device = android_commands.GetAttachedDevices()[0] michael@0: package_name = _GetPackageName(fname) michael@0: test = package_name + '.' + suite + '#' + test michael@0: java_test_runner = TestRunner(False, device, [test], False, False, False, michael@0: False, 0, ports_to_forward) michael@0: return java_test_runner.Run()