Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: tools/testing/dart/android.dart

Issue 2750403006: test.py: Push dart_precompiled_runtime and process_test once per device instead of once per test. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/testing/dart/test_runner.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4
5 library android; 5 library android;
6 6
7 import "dart:async"; 7 import "dart:async";
8 import "dart:convert" show LineSplitter, UTF8; 8 import "dart:convert" show LineSplitter, UTF8;
9 import "dart:core"; 9 import "dart:core";
10 import "dart:collection"; 10 import "dart:collection";
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 result.throwIfFailed(); 186 result.throwIfFailed();
187 } 187 }
188 } 188 }
189 189
190 /** 190 /**
191 * Used for communicating with an emulator or with a real device. 191 * Used for communicating with an emulator or with a real device.
192 */ 192 */
193 class AdbDevice { 193 class AdbDevice {
194 static const _adbServerStartupTime = const Duration(seconds: 3); 194 static const _adbServerStartupTime = const Duration(seconds: 3);
195 String _deviceId; 195 String _deviceId;
196 List<String> _cachedData = new List<String>();
196 197
197 String get deviceId => _deviceId; 198 String get deviceId => _deviceId;
198 199
199 AdbDevice(this._deviceId); 200 AdbDevice(this._deviceId);
200 201
201 /** 202 /**
202 * Blocks execution until the device is online 203 * Blocks execution until the device is online
203 */ 204 */
204 Future waitForDevice() { 205 Future waitForDevice() {
205 return _adbCommand(['wait-for-device']); 206 return _adbCommand(['wait-for-device']);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 242 }
242 243
243 /** 244 /**
244 * Upload data to the device. 245 * Upload data to the device.
245 */ 246 */
246 Future pushData(Path local, Path remote) { 247 Future pushData(Path local, Path remote) {
247 return _adbCommand(['push', '$local', '$remote']); 248 return _adbCommand(['push', '$local', '$remote']);
248 } 249 }
249 250
250 /** 251 /**
252 * Upload data to the device only on first use of [remote].
253 */
254 Future pushCachedData(String local, String remote) {
255 if (_cachedData.contains(remote)) {
256 return new Future.value(new AdbCommandResult(
257 "Skipped cached push", "", "", 0, false));
258 }
259 _cachedData.add(remote);
260 return _adbCommand(['push', local, remote]);
kustermann 2017/03/19 17:11:05 This is not quite safe I think: It's possible to r
261 }
262
263 /**
251 * Change permission of directory recursively. 264 * Change permission of directory recursively.
252 */ 265 */
253 Future chmod(String mode, Path directory) { 266 Future chmod(String mode, Path directory) {
254 var arguments = ['shell', 'chmod', '-R', mode, '$directory']; 267 var arguments = ['shell', 'chmod', '-R', mode, '$directory'];
255 return _adbCommand(arguments); 268 return _adbCommand(arguments);
256 } 269 }
257 270
258 /** 271 /**
259 * Install an application on the device. 272 * Install an application on the device.
260 */ 273 */
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 422 }
410 423
411 static Future<AdbDevicePool> create() async { 424 static Future<AdbDevicePool> create() async {
412 var names = await AdbHelper.listDevices(); 425 var names = await AdbHelper.listDevices();
413 var devices = names.map((id) => new AdbDevice(id)).toList(); 426 var devices = names.map((id) => new AdbDevice(id)).toList();
414 if (devices.length == 0) { 427 if (devices.length == 0) {
415 throw new Exception( 428 throw new Exception(
416 'No android devices found. ' 429 'No android devices found. '
417 'Please make sure "adb devices" shows your device!'); 430 'Please make sure "adb devices" shows your device!');
418 } 431 }
432 print("Found ${devices.length} Android devices.");
419 return new AdbDevicePool(devices); 433 return new AdbDevicePool(devices);
420 } 434 }
421 435
422 Future<AdbDevice> acquireDevice() async { 436 Future<AdbDevice> acquireDevice() async {
423 if (_idleDevices.length > 0) { 437 if (_idleDevices.length > 0) {
424 return _idleDevices.removeFirst(); 438 return _idleDevices.removeFirst();
425 } else { 439 } else {
426 var completer = new Completer(); 440 var completer = new Completer();
427 _waiter.add(completer); 441 _waiter.add(completer);
428 return completer.future; 442 return completer.future;
429 } 443 }
430 } 444 }
431 445
432 void releaseDevice(AdbDevice device) { 446 void releaseDevice(AdbDevice device) {
433 if (_waiter.length > 0) { 447 if (_waiter.length > 0) {
434 Completer completer = _waiter.removeFirst(); 448 Completer completer = _waiter.removeFirst();
435 completer.complete(device); 449 completer.complete(device);
436 } else { 450 } else {
437 _idleDevices.add(device); 451 _idleDevices.add(device);
438 } 452 }
439 } 453 }
440 } 454 }
OLDNEW
« no previous file with comments | « no previous file | tools/testing/dart/test_runner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698