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

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

Issue 43773005: Adds test target for Dartium on Android. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/testing/dart/test_options.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 library browser; 4 library browser;
5 5
6 import "dart:async"; 6 import "dart:async";
7 import "dart:convert" show LineSplitter, UTF8; 7 import "dart:convert" show LineSplitter, UTF8;
8 import "dart:core"; 8 import "dart:core";
9 import "dart:io"; 9 import "dart:io";
10 10
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 return _adbDevice.killAll().then((_) => true); 569 return _adbDevice.killAll().then((_) => true);
570 }); 570 });
571 } 571 }
572 return new Future.value(true); 572 return new Future.value(true);
573 } 573 }
574 574
575 String toString() => "ContentShellOnAndroid"; 575 String toString() => "ContentShellOnAndroid";
576 } 576 }
577 577
578 578
579 class DartiumOnAndroid extends Browser {
580 static const String viewAction = 'android.intent.action.VIEW';
581 static const String dartiumPackage = 'com.google.android.apps.chrome';
582
583 AdbDevice _adbDevice;
584
585 DartiumOnAndroid(this._adbDevice);
586
587 Future<bool> start(String url) {
588 var dartiumIntent = new Intent(
589 viewAction, dartiumPackage, '.Main', url);
590
591 return _adbDevice.waitForBootCompleted().then((_) {
592 return _adbDevice.forceStop(dartiumIntent.package);
593 }).then((_) {
594 return _adbDevice.killAll();
595 }).then((_) {
596 return _adbDevice.adbRoot();
597 }).then((_) {
598 return _adbDevice.setProp("DART_FORWARDING_PRINT", "1");
599 }).then((_) {
600 return _adbDevice.startActivity(dartiumIntent).then((_) => true);
601 });
602 }
603
604 Future<bool> close() {
605 if (_adbDevice != null) {
606 return _adbDevice.forceStop(dartiumPackage).then((_) {
607 return _adbDevice.killAll().then((_) => true);
608 });
609 }
610 return new Future.value(true);
611 }
612
613 String toString() => "DartiumOnAndroid";
614 }
kustermann 2013/10/25 19:23:03 We have now three of these classes with similar fu
zra 2013/10/25 21:33:34 I'm not comfortable modifying AndroidChrome since
615
616
579 class Firefox extends Browser { 617 class Firefox extends Browser {
580 static const String enablePopUp = 618 static const String enablePopUp =
581 'user_pref("dom.disable_open_during_load", false);'; 619 'user_pref("dom.disable_open_during_load", false);';
582 static const String disableDefaultCheck = 620 static const String disableDefaultCheck =
583 'user_pref("browser.shell.checkDefaultBrowser", false);'; 621 'user_pref("browser.shell.checkDefaultBrowser", false);';
584 static const String disableScriptTimeLimit = 622 static const String disableScriptTimeLimit =
585 'user_pref("dom.max_script_run_time", 0);'; 623 'user_pref("dom.max_script_run_time", 0);';
586 624
587 static String _binary = _getBinary(); 625 static String _binary = _getBinary();
588 626
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 } 801 }
764 802
765 Future<List<Browser>> getBrowsers() { 803 Future<List<Browser>> getBrowsers() {
766 // TODO(kustermann): This is a hackisch way to accomplish it and should 804 // TODO(kustermann): This is a hackisch way to accomplish it and should
767 // be encapsulated 805 // be encapsulated
768 var browsersCompleter = new Completer(); 806 var browsersCompleter = new Completer();
769 var androidBrowserCreationMapping = { 807 var androidBrowserCreationMapping = {
770 'chromeOnAndroid' : (AdbDevice device) => new AndroidChrome(device), 808 'chromeOnAndroid' : (AdbDevice device) => new AndroidChrome(device),
771 'ContentShellOnAndroid' : (AdbDevice device) => 809 'ContentShellOnAndroid' : (AdbDevice device) =>
772 new ContentShellOnAndroid(device), 810 new ContentShellOnAndroid(device),
811 'DartiumOnAndroid' : (AdbDevice device) =>
812 new DartiumOnAndroid(device),
773 }; 813 };
774 if (androidBrowserCreationMapping.containsKey(browserName)) { 814 if (androidBrowserCreationMapping.containsKey(browserName)) {
775 AdbHelper.listDevices().then((deviceIds) { 815 AdbHelper.listDevices().then((deviceIds) {
776 if (deviceIds.length > 0) { 816 if (deviceIds.length > 0) {
777 var browsers = []; 817 var browsers = [];
778 for (int i = 0; i < deviceIds.length; i++) { 818 for (int i = 0; i < deviceIds.length; i++) {
779 var id = "BROWSER$i"; 819 var id = "BROWSER$i";
780 var device = new AdbDevice(deviceIds[i]); 820 var device = new AdbDevice(deviceIds[i]);
781 adbDeviceMapping[id] = device; 821 adbDeviceMapping[id] = device;
782 var browser = androidBrowserCreationMapping[browserName](device); 822 var browser = androidBrowserCreationMapping[browserName](device);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 status.currentTest = null; 927 status.currentTest = null;
888 928
889 // We don't want to start a new browser if we are terminating. 929 // We don't want to start a new browser if we are terminating.
890 if (underTermination) return; 930 if (underTermination) return;
891 var browser; 931 var browser;
892 var new_id = id; 932 var new_id = id;
893 if (browserName == 'chromeOnAndroid') { 933 if (browserName == 'chromeOnAndroid') {
894 browser = new AndroidChrome(adbDeviceMapping[id]); 934 browser = new AndroidChrome(adbDeviceMapping[id]);
895 } else if (browserName == 'ContentShellOnAndroid') { 935 } else if (browserName == 'ContentShellOnAndroid') {
896 browser = new ContentShellOnAndroid(adbDeviceMapping[id]); 936 browser = new ContentShellOnAndroid(adbDeviceMapping[id]);
937 } else if (browserName == 'DartiumOnAndroid') {
938 browser = new DartiumOnAndroid(adbDeviceMapping[id]);
897 } else { 939 } else {
898 browserStatus.remove(id); 940 browserStatus.remove(id);
899 browser = getInstance(); 941 browser = getInstance();
900 new_id = "BROWSER$browserIdCount"; 942 new_id = "BROWSER$browserIdCount";
901 browserIdCount++; 943 browserIdCount++;
902 browserStatus[new_id] = new BrowserTestingStatus(browser); 944 browserStatus[new_id] = new BrowserTestingStatus(browser);
903 } 945 }
904 browser.id = new_id; 946 browser.id = new_id;
905 browser.start(testingServer.getDriverUrl(new_id)).then((success) { 947 browser.start(testingServer.getDriverUrl(new_id)).then((success) {
906 // We may have started terminating in the mean time. 948 // We may have started terminating in the mean time.
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 Dart test driver, number of tests: <div id="number"></div><br> 1367 Dart test driver, number of tests: <div id="number"></div><br>
1326 Currently executing: <div id="currently_executing"></div><br> 1368 Currently executing: <div id="currently_executing"></div><br>
1327 Unhandled error: <div id="unhandled_error"></div> 1369 Unhandled error: <div id="unhandled_error"></div>
1328 <iframe id="embedded_iframe"></iframe> 1370 <iframe id="embedded_iframe"></iframe>
1329 </body> 1371 </body>
1330 </html> 1372 </html>
1331 """; 1373 """;
1332 return driverContent; 1374 return driverContent;
1333 } 1375 }
1334 } 1376 }
OLDNEW
« no previous file with comments | « no previous file | tools/testing/dart/test_options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698