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

Unified Diff: tools/testing/dart/browser_controller.dart

Issue 262763005: Add mobile safari simulator support in the testing scripts (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: tools/testing/dart/browser_controller.dart
===================================================================
--- tools/testing/dart/browser_controller.dart (revision 35615)
+++ tools/testing/dart/browser_controller.dart (working copy)
@@ -76,6 +76,8 @@
browser = new Dartium(checkedMode);
} else if (name == 'safari') {
browser = new Safari();
+ } else if (name == 'safarimobilesim') {
+ browser = new SafariMobileSimulator();
} else if (name.startsWith('ie')) {
browser = new IE();
} else {
@@ -440,6 +442,54 @@
String toString() => "Chrome";
}
+
+class SafariMobileSimulator extends Safari {
+ String _version = "Version not found yet";
+
+ Map<String, String> _getEnvironment() => null;
+
+ /**
+ * Directories where safari simulator stores state. We delete these if the
+ * deleteCache is set
+ */
+ static const List<String> CACHE_DIRECTORIES =
+ const ["Library/Application Support/iPhone Simulator/7.1/Applications"];
+
+ // Clears the cache if the static deleteCache flag is set.
+ // Returns false if the command to actually clear the cache did not complete.
+ Future<bool> clearCache() {
+ if (!Browser.deleteCache) return new Future.value(true);
+ var home = Platform.environment['HOME'];
+ Iterator iterator = CACHE_DIRECTORIES.map((s) => "$home/$s").iterator;
+ return deleteIfExists(iterator);
+ }
+
+ Future<bool> start(String url) {
+ _logEvent("Starting safari mobile browser on: $url");
+ return clearCache().then((success) {
+ if (!success) {
+ _logEvent("Could not clear cache, exiting");
+ return false;
+ }
+ // Get the version and log that.
+ var args = ["-SimulateApplication",
+ "/Applications/Xcode.app/Contents/Developer/Platforms/"
+ "iPhoneSimulator.platform/Developer/SDKs/"
+ "iPhoneSimulator7.1.sdk/Applications/MobileSafari.app/"
+ "MobileSafari",
+ "-u", url];
+ return startBrowser(_binary, args, environment: _getEnvironment())
+ .catchError((e) {
+ _logEvent("Running $_binary --version failed with $e");
+ return false;
+ });
+ });
+ }
+
+ String toString() => "SafariMobile";
+}
+
+
class Dartium extends Chrome {
final bool checkedMode;

Powered by Google App Engine
This is Rietveld 408576698