OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """TestEnvironment classes. | 5 """TestEnvironment classes. |
6 | 6 |
7 These classes abstract away the various setups needed to run the WebDriver java | 7 These classes abstract away the various setups needed to run the WebDriver java |
8 tests in various environments. | 8 tests in various environments. |
9 """ | 9 """ |
10 | 10 |
11 import os | 11 import os |
12 import sys | 12 import sys |
13 | 13 |
| 14 import util |
| 15 |
14 _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) | 16 _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) |
15 | 17 |
16 sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, 'pylib')) | |
17 | |
18 from common import util | |
19 | |
20 if util.IsLinux(): | 18 if util.IsLinux(): |
21 sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, os.pardir, os.pardir, | 19 sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, os.pardir, os.pardir, |
22 'build', 'android')) | 20 'build', 'android')) |
23 from pylib import android_commands | 21 from pylib import android_commands |
24 from pylib import forwarder | 22 from pylib import forwarder |
25 from pylib import valgrind_tools | 23 from pylib import valgrind_tools |
26 | 24 |
27 ANDROID_TEST_HTTP_PORT = 2311 | 25 ANDROID_TEST_HTTP_PORT = 2311 |
28 ANDROID_TEST_HTTPS_PORT = 2411 | 26 ANDROID_TEST_HTTPS_PORT = 2411 |
29 | 27 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 """ | 69 """ |
72 with open(os.path.join(_THIS_DIR, 'java_tests.txt'), 'r') as f: | 70 with open(os.path.join(_THIS_DIR, 'java_tests.txt'), 'r') as f: |
73 return _EXPECTATIONS['ApplyJavaTestFilter']( | 71 return _EXPECTATIONS['ApplyJavaTestFilter']( |
74 self.GetOS(), self._chrome_version, | 72 self.GetOS(), self._chrome_version, |
75 [t.strip('\n') for t in f.readlines()]) | 73 [t.strip('\n') for t in f.readlines()]) |
76 | 74 |
77 | 75 |
78 class DesktopTestEnvironment(BaseTestEnvironment): | 76 class DesktopTestEnvironment(BaseTestEnvironment): |
79 """Manages the environment java tests require to run on Desktop.""" | 77 """Manages the environment java tests require to run on Desktop.""" |
80 | 78 |
81 #override | 79 # override |
82 def GetOS(self): | 80 def GetOS(self): |
83 return util.GetPlatformName() | 81 return util.GetPlatformName() |
84 | 82 |
85 | 83 |
86 class AndroidTestEnvironment(DesktopTestEnvironment): | 84 class AndroidTestEnvironment(DesktopTestEnvironment): |
87 """Manages the environment java tests require to run on Android.""" | 85 """Manages the environment java tests require to run on Android.""" |
88 | 86 |
89 def __init__(self, chrome_version='HEAD'): | 87 def __init__(self, chrome_version='HEAD'): |
90 super(AndroidTestEnvironment, self).__init__(chrome_version) | 88 super(AndroidTestEnvironment, self).__init__(chrome_version) |
91 self._adb = None | 89 self._adb = None |
92 self._forwarder = None | 90 self._forwarder = None |
93 | 91 |
94 #override | 92 # override |
95 def GlobalSetUp(self): | 93 def GlobalSetUp(self): |
96 os.putenv('TEST_HTTP_PORT', str(ANDROID_TEST_HTTP_PORT)) | 94 os.putenv('TEST_HTTP_PORT', str(ANDROID_TEST_HTTP_PORT)) |
97 os.putenv('TEST_HTTPS_PORT', str(ANDROID_TEST_HTTPS_PORT)) | 95 os.putenv('TEST_HTTPS_PORT', str(ANDROID_TEST_HTTPS_PORT)) |
98 self._adb = android_commands.AndroidCommands() | 96 self._adb = android_commands.AndroidCommands() |
99 self._forwarder = forwarder.Forwarder(self._adb, 'Debug') | 97 self._forwarder = forwarder.Forwarder(self._adb, 'Debug') |
100 self._forwarder.Run( | 98 self._forwarder.Run( |
101 [(ANDROID_TEST_HTTP_PORT, ANDROID_TEST_HTTP_PORT), | 99 [(ANDROID_TEST_HTTP_PORT, ANDROID_TEST_HTTP_PORT), |
102 (ANDROID_TEST_HTTPS_PORT, ANDROID_TEST_HTTPS_PORT)], | 100 (ANDROID_TEST_HTTPS_PORT, ANDROID_TEST_HTTPS_PORT)], |
103 valgrind_tools.BaseTool(), '127.0.0.1') | 101 valgrind_tools.BaseTool(), '127.0.0.1') |
104 | 102 |
105 #override | 103 # override |
106 def GlobalTearDown(self): | 104 def GlobalTearDown(self): |
107 if self._adb is not None: | 105 if self._adb is not None: |
108 forwarder.Forwarder.KillDevice(self._adb, valgrind_tools.BaseTool()) | 106 forwarder.Forwarder.KillDevice(self._adb, valgrind_tools.BaseTool()) |
109 if self._forwarder is not None: | 107 if self._forwarder is not None: |
110 self._forwarder.Close() | 108 self._forwarder.Close() |
111 | 109 |
112 #override | 110 # override |
113 def GetOS(self): | 111 def GetOS(self): |
114 return 'android' | 112 return 'android' |
OLD | NEW |