media/webrtc/trunk/build/android/pylib/java_unittest_utils.py

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
michael@0 2 # Use of this source code is governed by a BSD-style license that can be
michael@0 3 # found in the LICENSE file.
michael@0 4
michael@0 5 """This file is imported by python tests ran by run_python_tests.py."""
michael@0 6
michael@0 7 import os
michael@0 8
michael@0 9 import android_commands
michael@0 10 from run_java_tests import TestRunner
michael@0 11
michael@0 12
michael@0 13 def _GetPackageName(fname):
michael@0 14 """Extracts the package name from the test file path."""
michael@0 15 base_root = os.path.join('com', 'google', 'android')
michael@0 16 dirname = os.path.dirname(fname)
michael@0 17 package = dirname[dirname.rfind(base_root):]
michael@0 18 return package.replace(os.sep, '.')
michael@0 19
michael@0 20
michael@0 21 def RunJavaTest(fname, suite, test, ports_to_forward):
michael@0 22 device = android_commands.GetAttachedDevices()[0]
michael@0 23 package_name = _GetPackageName(fname)
michael@0 24 test = package_name + '.' + suite + '#' + test
michael@0 25 java_test_runner = TestRunner(False, device, [test], False, False, False,
michael@0 26 False, 0, ports_to_forward)
michael@0 27 return java_test_runner.Run()

mercurial