Skip to content

Commit a7172f5

Browse files
committed
Fix path processing.
Reformat files with current version of dartfmt.
1 parent 8f13667 commit a7172f5

14 files changed

+76
-55
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ pubspec.lock
77
*.so
88
.idea/
99
.pub/
10-
10+
.packages

lib/src/command_event.dart

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,37 @@ part of sync.webdriver;
2020
class CommandEvent {
2121
/// HTTP method for the command.
2222
final String method;
23+
2324
/// HTTP endpoint for the command.
2425
final String endpoint;
26+
2527
/// String representation of the params sent for the command.
2628
final String params;
29+
2730
/// When the command started execution.
2831
final DateTime startTime;
32+
2933
/// When the command ended execution.
3034
final DateTime endTime;
35+
3136
/// String representation of the returned response for the command.
3237
/// If the command failed, this will be null.
3338
final String result;
39+
3440
/// String representation of the exception thrown when the command failed.
3541
/// If the command succeeded, this will be null.
3642
final String exception;
43+
3744
/// Stack trace at the point of the execution of the WebDriver command.
3845
final Trace stackTrace;
3946

40-
CommandEvent({this.method, this.endpoint, this.params, this.startTime,
41-
this.endTime, this.result, this.exception, this.stackTrace});
47+
CommandEvent(
48+
{this.method,
49+
this.endpoint,
50+
this.params,
51+
this.startTime,
52+
this.endTime,
53+
this.result,
54+
this.exception,
55+
this.stackTrace});
4256
}

lib/src/common.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ abstract class _WebDriverBase {
113113
return command;
114114
} else if (command.startsWith('/')) {
115115
return '$_prefix$command';
116-
} else return '$_prefix/$command';
116+
} else
117+
return '$_prefix/$command';
117118
}
118119
}
119120

lib/src/options.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,19 @@ class Cookies extends _WebDriverBase {
3636
class Cookie {
3737
/// The name of the cookie.
3838
final String name;
39+
3940
/// The cookie value.
4041
final String value;
42+
4143
/// (Optional) The cookie path.
4244
final String path;
45+
4346
/// (Optional) The domain the cookie is visible to.
4447
final String domain;
48+
4549
/// (Optional) Whether the cookie is a secure cookie.
4650
final bool secure;
51+
4752
/// (Optional) When the cookie expires.
4853
final DateTime expiry;
4954

@@ -54,7 +59,8 @@ class Cookie {
5459
var expiry;
5560
if (json['expiry'] is num) {
5661
expiry = new DateTime.fromMillisecondsSinceEpoch(
57-
(json['expiry'] * 1000).round(), isUtc: true);
62+
(json['expiry'] * 1000).round(),
63+
isUtc: true);
5864
}
5965
return new Cookie(json['name'], json['value'],
6066
path: json['path'],
@@ -96,6 +102,7 @@ class Timeouts extends _WebDriverBase {
96102

97103
/// Get the script timeout.
98104
Duration get scriptTimeout => _scriptTimeout;
105+
99106
/// Set the script timeout.
100107
set scriptTimeout(Duration duration) {
101108
_set('script', duration);
@@ -104,6 +111,7 @@ class Timeouts extends _WebDriverBase {
104111

105112
/// Get the implicit timeout.
106113
Duration get implicitWaitTimeout => _implicitWaitTimeout;
114+
107115
/// Set the implicit timeout.
108116
set implicitWaitTimeout(Duration duration) {
109117
_set('implicit', duration);
@@ -112,6 +120,7 @@ class Timeouts extends _WebDriverBase {
112120

113121
/// Get the page load timeout.
114122
Duration get pageLoadTimeout => _pageLoadTimeout;
123+
115124
/// Set the page load timeout.
116125
set pageLoadTimeout(Duration duration) {
117126
_set('page load', duration);

lib/src/touch.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ class Touch extends _WebDriverBase {
6868
*/
6969
void flickElement(WebElement start, int xOffset, int yOffset, int speed) =>
7070
_post('flick', {
71-
'element': start.id,
72-
'xoffset': xOffset.floor(),
73-
'yoffset': yOffset.floor(),
74-
'speed': speed.floor()
75-
});
71+
'element': start.id,
72+
'xoffset': xOffset.floor(),
73+
'yoffset': yOffset.floor(),
74+
'speed': speed.floor()
75+
});
7676

7777
/**
7878
* Flick on the touch screen using finger motion events.

lib/src/util.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ bool useUnittestMatchers = false;
3131
* Any exceptions raised during the evauluation of [condition] are
3232
* caught and treated as an unsuccessful evaluation.
3333
*/
34-
waitForValue(condition(), {Duration timeout: _DEFAULT_WAIT,
35-
Duration interval: _INTERVAL, onError(Object error)}) {
34+
waitForValue(condition(),
35+
{Duration timeout: _DEFAULT_WAIT,
36+
Duration interval: _INTERVAL,
37+
onError(Object error)}) {
3638
return waitFor(condition, useUnittestMatchers ? ut.isNotNull : m.isNotNull,
3739
timeout: timeout, interval: interval);
3840
}
@@ -47,8 +49,10 @@ waitForValue(condition(), {Duration timeout: _DEFAULT_WAIT,
4749
* Any exceptions raised during the evauluation of [condition] are
4850
* caught and treated as an unsuccessful evaluation.
4951
*/
50-
waitFor(condition(), matcher, {Duration timeout: _DEFAULT_WAIT,
51-
Duration interval: _INTERVAL, onError(Object error)}) {
52+
waitFor(condition(), matcher,
53+
{Duration timeout: _DEFAULT_WAIT,
54+
Duration interval: _INTERVAL,
55+
onError(Object error)}) {
5256
conditionWithExpect() {
5357
expect(value, matcher) {
5458
if (matcher is! m.Matcher) {

lib/src/web_driver.dart

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
part of sync.webdriver;
1818

1919
@deprecated
20+
2021
/// Use [CommandEvent] instead.
2122
typedef void CommandListener(String method, String endpoint, params);
2223

@@ -34,13 +35,15 @@ class WebDriver extends SearchContext {
3435
new StreamController.broadcast(sync: true);
3536
Stream<CommandEvent> get onCommand => _onCommand.stream;
3637

37-
factory WebDriver({Uri uri: null, Map<String, String> required: null,
38+
factory WebDriver(
39+
{Uri uri: null,
40+
Map<String, String> required: null,
3841
Map<String, String> desired: const <String, String>{}}) {
3942
if (uri == null) {
4043
uri = DEFAULT_URI;
4144
}
42-
var request =
43-
_client.postUrl(new Uri.http(uri.authority, '${uri.path}/session'));
45+
var request = _client
46+
.postUrl(new Uri.http(uri.authority, path.join(uri.path, 'session')));
4447
var jsonParams = {"desiredCapabilities": desired};
4548

4649
if (required != null) {
@@ -57,14 +60,14 @@ class WebDriver extends SearchContext {
5760
switch (resp.statusCode) {
5861
case HttpStatus.SEE_OTHER:
5962
case HttpStatus.MOVED_TEMPORARILY:
63+
case HttpStatus.MOVED_PERMANENTLY:
6064
sessionUri = Uri.parse(resp.headers.value(HttpHeaders.LOCATION));
6165
if (sessionUri.authority == null || sessionUri.authority.isEmpty) {
6266
sessionUri = new Uri.http(uri.authority, sessionUri.path);
6367
}
6468
break;
6569
case HttpStatus.OK:
6670
var jsonResp = _parseBody(resp);
67-
6871
if (jsonResp is! Map || jsonResp['status'] != 0) {
6972
throw new WebDriverException(
7073
httpStatusCode: resp.statusCode,
@@ -106,7 +109,7 @@ class WebDriver extends SearchContext {
106109
}
107110

108111
static Uri _sessionUri(Uri uri, String sessionId) =>
109-
new Uri.http(uri.authority, '${uri.path}/session/$sessionId');
112+
new Uri.http(uri.authority, path.join(uri.path, "session", sessionId));
110113

111114
WebDriver._(this.uri, this.capabilities) {
112115
_jsonDecoder = new JsonCodec.withReviver(_reviver);
@@ -195,8 +198,8 @@ class WebDriver extends SearchContext {
195198
dynamic execute(String script, List args) =>
196199
post('execute', {'script': script, 'args': args});
197200

198-
List<int> captureScreenshot() => new UnmodifiableListView(
199-
BASE64.decode(captureScreenshotAsBase64()));
201+
List<int> captureScreenshot() =>
202+
new UnmodifiableListView(BASE64.decode(captureScreenshotAsBase64()));
200203

201204
String captureScreenshotAsBase64() => get('screenshot');
202205

@@ -291,12 +294,7 @@ class WebDriver extends SearchContext {
291294
}
292295

293296
String _processCommand(String command) {
294-
StringBuffer path = new StringBuffer(uri.path);
295-
if (!command.isEmpty && !command.startsWith('/')) {
296-
path.write('/');
297-
}
298-
path.write(command);
299-
return path.toString();
297+
return path.join(uri.path, command);
300298
}
301299

302300
_processResponse(HttpClientResponseSync resp) {

lib/src/web_element.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,15 @@ class WebElement extends _WebDriverBase with SearchContext {
113113
StringBuffer result = new StringBuffer('{WebElement ');
114114
result.write(id);
115115
if (_context != null && _finder != null) {
116-
result
117-
..write(' ')
118-
..write(_context);
116+
result..write(' ')..write(_context);
119117
if (_index >= 0) {
120118
result.write('.findElements(');
121119
} else {
122120
result.write('.findElement(');
123121
}
124122
result.write(_finder);
125123
if (_index >= 0) {
126-
result
127-
..write(')[')
128-
..write(_index)
129-
..write(']}');
124+
result..write(')[')..write(_index)..write(']}');
130125
} else {
131126
result.write(')}');
132127
}

lib/sync_webdriver.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import 'dart:math' show Point;
2424
import 'dart:mirrors';
2525

2626
import 'package:matcher/matcher.dart' as m;
27+
import 'package:path/path.dart' as path;
2728
import 'package:stack_trace/stack_trace.dart' show Trace;
2829
import 'package:sync_socket/sync_socket.dart';
2930
import 'package:unittest/unittest.dart' as ut;

pubspec.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sync_webdriver
2-
version: 2.0.0-pre.1
2+
version: 2.0.0-pre.2
33
author: Marc Fisher II <[email protected]>
44
description: >
55
Provides WebDriver bindings for Dart. These use the WebDriver JSON interface,
@@ -8,10 +8,10 @@ homepage: https://github.com/google/dart-sync-webdriver
88
environment:
99
sdk: '>=1.13.0 <2.0.0'
1010
dependencies:
11-
matcher: '^0.12.0+1'
12-
stack_trace: '^1.3.2'
13-
sync_socket: '^1.0.2+1'
14-
unittest: '^0.11.6+1'
11+
matcher: '^0.12.0'
12+
path: '^1.3.0'
13+
stack_trace: '^1.3.0'
14+
sync_socket: '^1.0.0'
15+
unittest: '^0.11.0'
1516
dev_dependencies:
16-
path: '^1.3.5'
17-
test: '^0.12.2'
17+
test: '^0.12.0'

test/src/command_event_test.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,18 @@ _checkCommand(CommandEvent log, method, command, params,
118118
expect(log.method, method);
119119
expect(log.endpoint, command);
120120
expect(log.params, params);
121-
expect(log.endTime, predicate(
122-
log.startTime.isBefore, 'event endTime is not after event startTime'));
121+
expect(
122+
log.endTime,
123+
predicate(log.startTime.isBefore,
124+
'event endTime is not after event startTime'));
123125
expect(log.result, response);
124126
expect(log.exception, exception);
125127

126128
var trace = new Trace.current(2).frames.map((f) => f.toString()).toList();
127-
expect(log.stackTrace.frames
128-
.map((f) => f.toString())
129-
.skipWhile((f) => f != trace[0])
130-
.toList(), trace);
129+
expect(
130+
log.stackTrace.frames
131+
.map((f) => f.toString())
132+
.skipWhile((f) => f != trace[0])
133+
.toList(),
134+
trace);
131135
}

test/src/keyboard_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ void main() {
4646
});
4747

4848
test('sendKeys -- twice', () {
49-
driver.keyboard
50-
..sendKeys('abc')
51-
..sendKeys('def');
49+
driver.keyboard..sendKeys('abc')..sendKeys('def');
5250
expect(textInput.attributes['value'], 'abcdef');
5351
});
5452

test/src/logs_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ void main() {
2727
WebDriver driver;
2828

2929
setUp(() {
30-
driver = createTestDriver(
31-
additionalCapabilities: {
30+
driver = createTestDriver(additionalCapabilities: {
3231
Capabilities.LOGGING_PREFS: {LogType.PERFORMANCE: LogLevel.INFO}
3332
});
3433
driver.url = testPagePath;

test/src/util_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,7 @@ void main() {
288288
});
289289

290290
test('[de]selectByIndex multiple', () {
291-
var select = new Select(selectMulti)
292-
..selectByIndex(1)
293-
..selectByIndex(3);
291+
var select = new Select(selectMulti)..selectByIndex(1)..selectByIndex(3);
294292
var options = select.options;
295293

296294
expect(options[0].selected, false);

0 commit comments

Comments
 (0)