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 """Common paths for pyauto tests.""" | 5 """Common paths for pyauto tests.""" |
6 | 6 |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 | 9 |
10 | 10 |
11 def GetSourceDir(): | 11 def GetSourceDir(): |
12 """Returns src/ directory.""" | 12 """Returns src/ directory.""" |
13 script_dir = os.path.abspath(os.path.dirname(__file__)) | 13 script_dir = os.path.abspath(os.path.dirname(__file__)) |
14 return os.path.join(script_dir, os.pardir, os.pardir, os.pardir) | 14 return os.path.join(script_dir, os.pardir, os.pardir, os.pardir) |
15 | 15 |
16 | 16 |
17 def GetThirdPartyDir(): | 17 def GetThirdPartyDir(): |
18 """Returns src/third_party directory.""" | 18 """Returns src/third_party directory.""" |
19 return os.path.join(GetSourceDir(), 'third_party') | 19 return os.path.join(GetSourceDir(), 'third_party') |
20 | 20 |
21 | 21 |
22 def GetBuildDirs(): | 22 def GetBuildDirs(): |
23 """Returns list of possible build directories.""" | 23 """Returns list of possible build directories.""" |
24 # List of dirs that can contain a Debug/Release build. | 24 # List of dirs that can contain a Debug/Release build. |
25 outer_dirs = { | 25 outer_dirs = { |
26 'linux2': ['out', 'sconsbuild'], | 26 'linux2': ['out'], |
27 'linux3': ['out', 'sconsbuild'], | 27 'linux3': ['out'], |
28 'darwin': ['out', 'xcodebuild'], | 28 'darwin': ['out', 'xcodebuild'], |
29 'win32': ['chrome', 'build', 'out'], | 29 'win32': ['chrome', 'build', 'out'], |
30 'cygwin': ['chrome'], | 30 'cygwin': ['chrome'], |
31 }.get(sys.platform, []) | 31 }.get(sys.platform, []) |
32 src_dir = GetSourceDir() | 32 src_dir = GetSourceDir() |
33 build_dirs = [] | 33 build_dirs = [] |
34 for dir in outer_dirs: | 34 for dir in outer_dirs: |
35 build_dirs += [os.path.join(src_dir, dir, 'Debug')] | 35 build_dirs += [os.path.join(src_dir, dir, 'Debug')] |
36 build_dirs += [os.path.join(src_dir, dir, 'Release')] | 36 build_dirs += [os.path.join(src_dir, dir, 'Release')] |
37 return build_dirs | 37 return build_dirs |
38 | 38 |
39 | 39 |
40 def GetChromeDriverExe(): | 40 def GetChromeDriverExe(): |
41 """Returns path to ChromeDriver executable, or None if cannot be found.""" | 41 """Returns path to ChromeDriver executable, or None if cannot be found.""" |
42 exe_name = 'chromedriver' | 42 exe_name = 'chromedriver' |
43 if sys.platform == 'win32': | 43 if sys.platform == 'win32': |
44 exe_name += '.exe' | 44 exe_name += '.exe' |
45 | 45 |
46 import pyautolib | 46 import pyautolib |
47 dir = os.path.dirname(pyautolib.__file__) | 47 dir = os.path.dirname(pyautolib.__file__) |
48 exe = os.path.join(dir, exe_name) | 48 exe = os.path.join(dir, exe_name) |
49 if os.path.exists(exe): | 49 if os.path.exists(exe): |
50 return exe | 50 return exe |
51 return None | 51 return None |
OLD | NEW |