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

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

Issue 252653007: Add clear_browser_cache flag to test.dart (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « tools/test.dart ('k') | 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 */ 42 */
43 Process process; 43 Process process;
44 44
45 Function logger; 45 Function logger;
46 46
47 /** 47 /**
48 * Id of the browser 48 * Id of the browser
49 */ 49 */
50 String id; 50 String id;
51 51
52 /**
53 * Delete the browser specific caches on startup.
54 * Browser specific implementations are free to ignore this.
55 */
56 static bool deleteCache = false;
57
52 /** Print everything (stdout, stderr, usageLog) whenever we add to it */ 58 /** Print everything (stdout, stderr, usageLog) whenever we add to it */
53 bool debugPrint = false; 59 bool debugPrint = false;
54 60
55 // This future returns when the process exits. It is also the return value 61 // This future returns when the process exits. It is also the return value
56 // of close() 62 // of close()
57 Future done; 63 Future done;
58 64
59 Browser(); 65 Browser();
60 66
61 factory Browser.byName(String name, 67 factory Browser.byName(String name,
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } else { 297 } else {
292 _logEvent("${paths.current} is not present"); 298 _logEvent("${paths.current} is not present");
293 return deleteIfExists(paths); 299 return deleteIfExists(paths);
294 } 300 }
295 }); 301 });
296 } 302 }
297 303
298 // Clears the cache if the static deleteCache flag is set. 304 // Clears the cache if the static deleteCache flag is set.
299 // Returns false if the command to actually clear the cache did not complete. 305 // Returns false if the command to actually clear the cache did not complete.
300 Future<bool> clearCache() { 306 Future<bool> clearCache() {
301 if (!deleteCache) return new Future.value(true); 307 if (!Browser.deleteCache) return new Future.value(true);
302 var home = Platform.environment['HOME']; 308 var home = Platform.environment['HOME'];
303 Iterator iterator = CACHE_DIRECTORIES.map((s) => "$home/$s").iterator; 309 Iterator iterator = CACHE_DIRECTORIES.map((s) => "$home/$s").iterator;
304 return deleteIfExists(iterator); 310 return deleteIfExists(iterator);
305 } 311 }
306 312
307 Future<String> getVersion() { 313 Future<String> getVersion() {
308 /** 314 /**
309 * Example of the file: 315 * Example of the file:
310 * <?xml version="1.0" encoding="UTF-8"?> 316 * <?xml version="1.0" encoding="UTF-8"?>
311 * <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.co m/DTDs/PropertyList-1.0.dtd"> 317 * <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.co m/DTDs/PropertyList-1.0.dtd">
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 }); 373 });
368 }).catchError((error) { 374 }).catchError((error) {
369 _logEvent("Running $_binary --version failed with $error"); 375 _logEvent("Running $_binary --version failed with $error");
370 return false; 376 return false;
371 }); 377 });
372 }); 378 });
373 }); 379 });
374 } 380 }
375 381
376 String toString() => "Safari"; 382 String toString() => "Safari";
377
378 // Delete the user specific browser cache and profile data.
379 // Safari only have one per user, and you can't specify one by command line.
380 static bool deleteCache = false;
381
382 } 383 }
383 384
384 385
385 class Chrome extends Browser { 386 class Chrome extends Browser {
386 String _version = "Version not found yet"; 387 String _version = "Version not found yet";
387 388
388 Map<String, String> _getEnvironment() => null; 389 Map<String, String> _getEnvironment() => null;
389 390
390 Future<bool> _getVersion() { 391 Future<bool> _getVersion() {
391 if (Platform.isWindows) { 392 if (Platform.isWindows) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 var findString = "REG_SZ"; 474 var findString = "REG_SZ";
474 var index = result.stdout.indexOf(findString); 475 var index = result.stdout.indexOf(findString);
475 if (index > 0) { 476 if (index > 0) {
476 return result.stdout.substring(index + findString.length).trim(); 477 return result.stdout.substring(index + findString.length).trim();
477 } 478 }
478 } 479 }
479 return "Could not get the version of internet explorer"; 480 return "Could not get the version of internet explorer";
480 }); 481 });
481 } 482 }
482 483
484 // Clears the recovery cache if the static deleteCache flag is set.
485 Future<bool> clearCache() {
486 if (!Browser.deleteCache) return new Future.value(true);
487 var localAppData = Platform.environment['LOCALAPPDATA'];
488
489 Directory dir = new Directory("$localAppData\\Microsoft\\"
490 "Internet Explorer\\Recovery");
491 return dir.delete(recursive: true)
492 .then((_) { return true; })
493 .catchError((error) {
494 _logEvent("Deleting recovery dir failed with $error");
495 return false;
496 });
497 }
498
483 Future<bool> start(String url) { 499 Future<bool> start(String url) {
484 _logEvent("Starting ie browser on: $url"); 500 _logEvent("Starting ie browser on: $url");
485 return getVersion().then((version) { 501 return clearCache().then((_) => getVersion()).then((version) {
486 _logEvent("Got version: $version"); 502 _logEvent("Got version: $version");
487 return startBrowser(_binary, [url]); 503 return startBrowser(_binary, [url]);
488 }); 504 });
489 } 505 }
490 String toString() => "IE"; 506 String toString() => "IE";
507
491 } 508 }
492 509
493 510
494 class AndroidBrowserConfig { 511 class AndroidBrowserConfig {
495 final String name; 512 final String name;
496 final String package; 513 final String package;
497 final String activity; 514 final String activity;
498 final String action; 515 final String action;
499 AndroidBrowserConfig(this.name, this.package, this.activity, this.action); 516 AndroidBrowserConfig(this.name, this.package, this.activity, this.action);
500 } 517 }
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 Dart test driver, number of tests: <div id="number"></div><br> 1510 Dart test driver, number of tests: <div id="number"></div><br>
1494 Currently executing: <div id="currently_executing"></div><br> 1511 Currently executing: <div id="currently_executing"></div><br>
1495 Unhandled error: <div id="unhandled_error"></div> 1512 Unhandled error: <div id="unhandled_error"></div>
1496 <iframe id="embedded_iframe"></iframe> 1513 <iframe id="embedded_iframe"></iframe>
1497 </body> 1514 </body>
1498 </html> 1515 </html>
1499 """; 1516 """;
1500 return driverContent; 1517 return driverContent;
1501 } 1518 }
1502 } 1519 }
OLDNEW
« no previous file with comments | « tools/test.dart ('k') | tools/testing/dart/test_options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698