| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 library browser; | 4 library browser; |
| 5 | 5 |
| 6 import "dart:async"; | 6 import "dart:async"; |
| 7 import "dart:core"; | 7 import "dart:core"; |
| 8 import "dart:io"; | 8 import "dart:io"; |
| 9 | 9 |
| 10 import 'android.dart'; | 10 import 'android.dart'; |
| 11 import 'utils.dart'; |
| 11 | 12 |
| 12 /** Class describing the interface for communicating with browsers. */ | 13 /** Class describing the interface for communicating with browsers. */ |
| 13 abstract class Browser { | 14 abstract class Browser { |
| 14 // Browsers actually takes a while to cleanup after itself when closing | 15 // Browsers actually takes a while to cleanup after itself when closing |
| 15 // Give it sufficient time to do that. | 16 // Give it sufficient time to do that. |
| 16 static final Duration killRepeatInternal = const Duration(seconds: 10); | 17 static final Duration killRepeatInternal = const Duration(seconds: 10); |
| 17 static final int killRetries = 5; | 18 static final int killRetries = 5; |
| 18 StringBuffer _stdout = new StringBuffer(); | 19 StringBuffer _stdout = new StringBuffer(); |
| 19 StringBuffer _stderr = new StringBuffer(); | 20 StringBuffer _stderr = new StringBuffer(); |
| 20 StringBuffer _usageLog = new StringBuffer(); | 21 StringBuffer _usageLog = new StringBuffer(); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 AndroidChrome(this._adbDevice); | 230 AndroidChrome(this._adbDevice); |
| 230 | 231 |
| 231 Future<bool> start(String url) { | 232 Future<bool> start(String url) { |
| 232 var browserIntent = new Intent( | 233 var browserIntent = new Intent( |
| 233 viewAction, browserPackage, '.BrowserActivity', url); | 234 viewAction, browserPackage, '.BrowserActivity', url); |
| 234 var chromeIntent = new Intent(viewAction, chromePackage, '.Main', url); | 235 var chromeIntent = new Intent(viewAction, chromePackage, '.Main', url); |
| 235 var firefoxIntent = new Intent(viewAction, firefoxPackage, '.App', url); | 236 var firefoxIntent = new Intent(viewAction, firefoxPackage, '.App', url); |
| 236 var turnScreenOnIntent = | 237 var turnScreenOnIntent = |
| 237 new Intent(mainAction, turnScreenOnPackage, '.Main'); | 238 new Intent(mainAction, turnScreenOnPackage, '.Main'); |
| 238 | 239 |
| 239 var chromeAPK = new Path( | 240 // FIXME(kustermann): Remove this hack as soon as we've got a v8 mirror in |
| 240 'third_party/android_testing_resources/com.android.chrome-1.apk'); | 241 // golo |
| 241 var turnScreenOnAPK = new Path( | 242 var testing_resources_dir = |
| 242 'third_party/android_testing_resources/TurnScreenOn.apk'); | 243 new Path('third_party/android_testing_resources'); |
| 243 var chromeConfDir = new Path( | 244 var testing_resources_dir_tmp = |
| 244 'third_party/android_testing_resources/chrome_configuration'); | 245 new Path('/tmp/android_testing_resources'); |
| 245 var chromeConfDirRemote = new Path( | 246 if (!new Directory.fromPath(testing_resources_dir).existsSync()) { |
| 246 '/data/user/0/com.android.chrome/'); | 247 DebugLogger.warning("$testing_resources_dir doesn't exist, " |
| 248 "trying to use $testing_resources_dir_tmp"); |
| 249 testing_resources_dir = testing_resources_dir_tmp; |
| 250 if (!new Directory.fromPath(testing_resources_dir).existsSync()) { |
| 251 DebugLogger.error("$testing_resources_dir_tmp doesn't exist either. " |
| 252 " This is a fatal error. Exiting now."); |
| 253 exit(1); |
| 254 } |
| 255 } |
| 256 |
| 257 var chromeAPK = testing_resources_dir.append('com.android.chrome-1.apk'); |
| 258 var turnScreenOnAPK = testing_resources_dir.append('TurnScreenOn.apk'); |
| 259 var chromeConfDir = testing_resources_dir.append('chrome_configuration'); |
| 260 var chromeConfDirRemote = new Path('/data/user/0/com.android.chrome/'); |
| 247 | 261 |
| 248 return _adbDevice.waitForBootCompleted().then((_) { | 262 return _adbDevice.waitForBootCompleted().then((_) { |
| 249 return _adbDevice.forceStop(chromeIntent.package); | 263 return _adbDevice.forceStop(chromeIntent.package); |
| 250 }).then((_) { | 264 }).then((_) { |
| 251 return _adbDevice.killAll(); | 265 return _adbDevice.killAll(); |
| 252 }).then((_) { | 266 }).then((_) { |
| 253 return _adbDevice.adbRoot(); | 267 return _adbDevice.adbRoot(); |
| 254 }).then((_) { | 268 }).then((_) { |
| 255 return _adbDevice.installApk(turnScreenOnAPK); | 269 return _adbDevice.installApk(turnScreenOnAPK); |
| 256 }).then((_) { | 270 }).then((_) { |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 </script> | 813 </script> |
| 800 </head> | 814 </head> |
| 801 <body> | 815 <body> |
| 802 Dart test driver, number of tests: <div id="number"></div> | 816 Dart test driver, number of tests: <div id="number"></div> |
| 803 </body> | 817 </body> |
| 804 </html> | 818 </html> |
| 805 """; | 819 """; |
| 806 return driverContent; | 820 return driverContent; |
| 807 } | 821 } |
| 808 } | 822 } |
| OLD | NEW |