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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/webrtc/trunk/build/android/pylib/java_unittest_utils.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,27 @@
     1.4 +# Copyright (c) 2012 The Chromium Authors. All rights reserved.
     1.5 +# Use of this source code is governed by a BSD-style license that can be
     1.6 +# found in the LICENSE file.
     1.7 +
     1.8 +"""This file is imported by python tests ran by run_python_tests.py."""
     1.9 +
    1.10 +import os
    1.11 +
    1.12 +import android_commands
    1.13 +from run_java_tests import TestRunner
    1.14 +
    1.15 +
    1.16 +def _GetPackageName(fname):
    1.17 +  """Extracts the package name from the test file path."""
    1.18 +  base_root = os.path.join('com', 'google', 'android')
    1.19 +  dirname = os.path.dirname(fname)
    1.20 +  package = dirname[dirname.rfind(base_root):]
    1.21 +  return package.replace(os.sep, '.')
    1.22 +
    1.23 +
    1.24 +def RunJavaTest(fname, suite, test, ports_to_forward):
    1.25 +  device = android_commands.GetAttachedDevices()[0]
    1.26 +  package_name = _GetPackageName(fname)
    1.27 +  test = package_name + '.' + suite + '#' + test
    1.28 +  java_test_runner = TestRunner(False, device, [test], False, False, False,
    1.29 +                                False, 0, ports_to_forward)
    1.30 +  return java_test_runner.Run()

mercurial