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

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

Issue 2069243002: Fix analyzer warnings for browser_controller. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 | no next file » | 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, JSON; 7 import "dart:convert" show LineSplitter, UTF8, JSON;
8 import "dart:core"; 8 import "dart:core";
9 import "dart:io"; 9 import "dart:io";
10 import "dart:math" show max, min; 10 import "dart:math" show max, min;
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 497
498 class SafariMobileSimulator extends Safari { 498 class SafariMobileSimulator extends Safari {
499 /** 499 /**
500 * Directories where safari simulator stores state. We delete these if the 500 * Directories where safari simulator stores state. We delete these if the
501 * resetBrowserConfiguration is set 501 * resetBrowserConfiguration is set
502 */ 502 */
503 static const List<String> CACHE_DIRECTORIES = const [ 503 static const List<String> CACHE_DIRECTORIES = const [
504 "Library/Application Support/iPhone Simulator/7.1/Applications" 504 "Library/Application Support/iPhone Simulator/7.1/Applications"
505 ]; 505 ];
506 506
507 // Helper function to delete many directories recursively.
508 Future<bool> deleteIfExists(Iterable<String> paths) async {
509 for (var path in paths) {
510 Directory directory = new Directory(path);
511 if (await directory.exists()) {
512 _logEvent("Deleting $path");
513 try {
514 await directory.delete(recursive: true);
515 } catch (error) {
516 _logEvent("Failure trying to delete $path: $error");
517 return false;
518 }
519 } else {
520 _logEvent("$path is not present");
521 }
522 }
523 return true;
524 }
525
507 // Clears the cache if the static resetBrowserConfiguration flag is set. 526 // Clears the cache if the static resetBrowserConfiguration flag is set.
508 // Returns false if the command to actually clear the cache did not complete. 527 // Returns false if the command to actually clear the cache did not complete.
509 Future<bool> resetConfiguration() { 528 Future<bool> resetConfiguration() {
510 if (!Browser.resetBrowserConfiguration) return new Future.value(true); 529 if (!Browser.resetBrowserConfiguration) return new Future.value(true);
511 var home = Platform.environment['HOME']; 530 var home = Platform.environment['HOME'];
512 Iterator iterator = CACHE_DIRECTORIES.map((s) => "$home/$s").iterator; 531 var paths = CACHE_DIRECTORIES.map((s) => "$home/$s");
513 return deleteIfExists(iterator); 532 return deleteIfExists(paths);
514 } 533 }
515 534
516 Future<bool> start(String url) { 535 Future<bool> start(String url) {
517 _logEvent("Starting safari mobile simulator browser on: $url"); 536 _logEvent("Starting safari mobile simulator browser on: $url");
518 return resetConfiguration().then((success) { 537 return resetConfiguration().then((success) {
519 if (!success) { 538 if (!success) {
520 _logEvent("Could not clear cache, exiting"); 539 _logEvent("Could not clear cache, exiting");
521 return false; 540 return false;
522 } 541 }
523 var args = [ 542 var args = [
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 static const Duration RESTART_BROWSER_INTERVAL = const Duration(seconds: 60); 914 static const Duration RESTART_BROWSER_INTERVAL = const Duration(seconds: 60);
896 915
897 /// If the queue was recently empty, don't start another browser. 916 /// If the queue was recently empty, don't start another browser.
898 static const Duration MIN_NONEMPTY_QUEUE_TIME = const Duration(seconds: 1); 917 static const Duration MIN_NONEMPTY_QUEUE_TIME = const Duration(seconds: 1);
899 918
900 final Map configuration; 919 final Map configuration;
901 final BrowserTestingServer testingServer; 920 final BrowserTestingServer testingServer;
902 921
903 final String localIp; 922 final String localIp;
904 final String browserName; 923 final String browserName;
905 final int maxNumBrowsers; 924 int maxNumBrowsers;
906 final bool checkedMode; 925 final bool checkedMode;
907 int numBrowsers = 0; 926 int numBrowsers = 0;
908 // Used to send back logs from the browser (start, stop etc) 927 // Used to send back logs from the browser (start, stop etc)
909 Function logger; 928 Function logger;
910 929
911 int browserIdCounter = 1; 930 int browserIdCounter = 1;
912 931
913 bool testingServerStarted = false; 932 bool testingServerStarted = false;
914 bool underTermination = false; 933 bool underTermination = false;
915 int numBrowserGetTestTimeouts = 0; 934 int numBrowserGetTestTimeouts = 0;
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 </div> 1849 </div>
1831 <div id="embedded_iframe_div" class="test box"> 1850 <div id="embedded_iframe_div" class="test box">
1832 <iframe id="embedded_iframe"></iframe> 1851 <iframe id="embedded_iframe"></iframe>
1833 </div> 1852 </div>
1834 </body> 1853 </body>
1835 </html> 1854 </html>
1836 """; 1855 """;
1837 return driverContent; 1856 return driverContent;
1838 } 1857 }
1839 } 1858 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698