| OLD | NEW |
| 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 utils; | 5 library utils; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:math' show min; | 9 import 'dart:math' show min; |
| 10 import 'dart:utf' as utf; | 10 import 'dart:utf' as utf; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 return utf.encodeUtf8(string); | 120 return utf.encodeUtf8(string); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // TODO(kustermann,ricow): As soon we have a debug log we should log | 123 // TODO(kustermann,ricow): As soon we have a debug log we should log |
| 124 // invalid utf8-encoded input to the log. | 124 // invalid utf8-encoded input to the log. |
| 125 // Currently invalid bytes will be replaced by a replacement character. | 125 // Currently invalid bytes will be replaced by a replacement character. |
| 126 String decodeUtf8(List<int> bytes) { | 126 String decodeUtf8(List<int> bytes) { |
| 127 return utf.decodeUtf8(bytes); | 127 return utf.decodeUtf8(bytes); |
| 128 } | 128 } |
| 129 | 129 |
| 130 class Locations { |
| 131 static String getDartiumLocation(Map globalConfiguration) { |
| 132 var dartium = globalConfiguration['dartium']; |
| 133 if (dartium != null && dartium != '') { |
| 134 return dartium; |
| 135 } |
| 136 if (Platform.operatingSystem == 'macos') { |
| 137 return new Path('client/tests/dartium/Chromium.app/Contents/' |
| 138 'MacOS/Chromium').toNativePath(); |
| 139 } |
| 140 return new Path('client/tests/dartium/chrome').toNativePath(); |
| 141 } |
| 142 } |
| 143 |
| 130 // This function is pretty stupid and only puts quotes around an argument if | 144 // This function is pretty stupid and only puts quotes around an argument if |
| 131 // it the argument contains a space. | 145 // it the argument contains a space. |
| 132 String escapeCommandLineArgument(String argument) { | 146 String escapeCommandLineArgument(String argument) { |
| 133 if (argument.contains(' ')) { | 147 if (argument.contains(' ')) { |
| 134 return '"$argument"'; | 148 return '"$argument"'; |
| 135 } | 149 } |
| 136 return argument; | 150 return argument; |
| 137 } | 151 } |
| 138 | 152 |
| 139 class HashCodeBuilder { | 153 class HashCodeBuilder { |
| 140 int _value = 0; | 154 int _value = 0; |
| 141 | 155 |
| 142 void add(Object object) { | 156 void add(Object object) { |
| 143 _value = ((_value * 31) ^ object.hashCode) & 0x3FFFFFFF; | 157 _value = ((_value * 31) ^ object.hashCode) & 0x3FFFFFFF; |
| 144 } | 158 } |
| 145 | 159 |
| 146 int get value => _value; | 160 int get value => _value; |
| 147 } | 161 } |
| 148 | 162 |
| 149 class UniqueObject { | 163 class UniqueObject { |
| 150 static int _nextId = 1; | 164 static int _nextId = 1; |
| 151 final int _hashCode; | 165 final int _hashCode; |
| 152 | 166 |
| 153 int get hashCode => _hashCode; | 167 int get hashCode => _hashCode; |
| 154 operator==(other) => other is UniqueObject && _hashCode == other._hashCode; | 168 operator==(other) => other is UniqueObject && _hashCode == other._hashCode; |
| 155 | 169 |
| 156 UniqueObject() : _hashCode = ++_nextId; | 170 UniqueObject() : _hashCode = ++_nextId; |
| 157 } | 171 } |
| OLD | NEW |