Skip to content

Commit

Permalink
Update .gitignore, and other fixes (#196)
Browse files Browse the repository at this point in the history
* Update .gitignore

* pubspec: fix line length and whitespace encoding in description

* more lint cleanup

* Cleanup a few more hints, dartfmt
  • Loading branch information
kevmoo authored and mk13 committed Jun 5, 2018
1 parent 541cfed commit 22f7bf3
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 49 deletions.
10 changes: 2 additions & 8 deletions .gitignore
@@ -1,10 +1,4 @@
.DS_Store
packages
.dart_tool/
.pub/
.packages
pubspec.lock
.project
.pub/
.buildlog
.settings/
.idea/
bazel-*
6 changes: 3 additions & 3 deletions lib/src/async/command_event.dart
Expand Up @@ -16,12 +16,12 @@ part of webdriver.core;
class WebDriverCommandEvent {
final String method;
final String endPoint;
final params;
final Object params;
final StackTrace stackTrace;
final DateTime startTime;
final DateTime endTime;
final exception;
final result;
final Object exception;
final Object result;

WebDriverCommandEvent(
{this.method,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/async/common.dart
Expand Up @@ -98,7 +98,7 @@ class By {

@override
String toString() {
var constructor;
String constructor;
switch (_using) {
case 'link text':
constructor = 'linkText';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/async/options.dart
Expand Up @@ -73,7 +73,7 @@ class Cookie {
{this.path, this.domain, this.secure, this.expiry});

factory Cookie.fromJson(Map<String, dynamic> json) {
var expiry;
DateTime expiry;
if (json['expiry'] is num) {
expiry = new DateTime.fromMillisecondsSinceEpoch(
json['expiry'].toInt() * 1000,
Expand Down
6 changes: 3 additions & 3 deletions lib/src/async/web_driver.dart
Expand Up @@ -250,7 +250,7 @@ class WebDriver implements SearchContext {
}

// This is an ugly hack, I know, but I dunno how to cleanly do this.
var _previousEvent;
WebDriverCommandEvent _previousEvent;

// Performs the request. This will not notify any listeners or
// onCommandController. This should only be called from
Expand All @@ -264,8 +264,8 @@ class WebDriver implements SearchContext {
(f) => f.library.startsWith('package:webdriver/'),
terse: true);
}
var result;
var exception;
Object result;
Object exception;
try {
if (stepper == null || await stepper.step(method, command, params)) {
result = await fn();
Expand Down
6 changes: 3 additions & 3 deletions lib/src/sync/command_event.dart
Expand Up @@ -15,12 +15,12 @@
class WebDriverCommandEvent {
final String method;
final String endPoint;
final params;
final Object params;
final StackTrace stackTrace;
final DateTime startTime;
final DateTime endTime;
final exception;
final result;
final Object exception;
final Object result;

WebDriverCommandEvent(
{this.method,
Expand Down
5 changes: 3 additions & 2 deletions lib/src/sync/common.dart
Expand Up @@ -45,6 +45,7 @@ class SimpleAttributes extends Attributes {

SimpleAttributes(driver, command) : _resolver = new Resolver(driver, command);

@override
String operator [](String name) => _resolver.get(name)?.toString();
}

Expand Down Expand Up @@ -123,7 +124,7 @@ class By {

@override
String toString() {
var constructor;
String constructor;
switch (using) {
case 'link text':
constructor = 'linkText';
Expand Down Expand Up @@ -152,4 +153,4 @@ class By {
@override
bool operator ==(other) =>
other is By && other.using == this.using && other.value == this.value;
}
}
2 changes: 1 addition & 1 deletion lib/src/sync/common_spec/cookies.dart
Expand Up @@ -77,7 +77,7 @@ class Cookie {
{this.path, this.domain, this.secure, this.expiry});

factory Cookie.fromJson(Map<String, dynamic> json) {
var expiry;
DateTime expiry;
if (json['expiry'] is num) {
expiry = new DateTime.fromMillisecondsSinceEpoch(
json['expiry'].toInt() * 1000,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/sync/json_wire_spec/web_driver.dart
Expand Up @@ -234,8 +234,8 @@ class JsonWireWebDriver implements WebDriver, SearchContext {
(f) => f.library.startsWith('package:webdriver/'),
terse: true);
}
var result;
var exception;
Object result;
Object exception;
try {
result = fn();
return result;
Expand Down
10 changes: 4 additions & 6 deletions lib/src/sync/json_wire_spec/web_element.dart
Expand Up @@ -22,7 +22,6 @@ import '../web_driver.dart';
import '../web_element.dart';

class JsonWireWebElement implements WebElement, SearchContext {
final String _elementPrefix;
final Resolver _resolver;

@override
Expand All @@ -48,8 +47,7 @@ class JsonWireWebElement implements WebElement, SearchContext {

JsonWireWebElement(this.driver, this.id,
[this.context, this.locator, this.index])
: _elementPrefix = 'element/$id',
_resolver = new Resolver(driver, 'element/$id');
: _resolver = new Resolver(driver, 'element/$id');

@override
void click() {
Expand Down Expand Up @@ -175,14 +173,14 @@ class _ElementAttributes extends Attributes {
_ElementAttributes(this.element);

@override
String operator [](String name) => element.driver.execute("""
String operator [](String name) => element.driver.execute('''
var attr = arguments[0].attributes["$name"];
if(attr) {
return attr.value;
}
return null;
""", [element])?.toString();
''', [element])?.toString();
}

class _ElementComputedStyle extends Attributes {
Expand All @@ -209,4 +207,4 @@ class _ElementProperties extends Attributes {

/// Convert hyphenated-properties to camelCase.
String _cssPropName(String name) => name.splitMapJoin(new RegExp(r'-(\w)'),
onMatch: (m) => m.group(1).toUpperCase(), onNonMatch: (m) => m);
onMatch: (m) => m.group(1).toUpperCase(), onNonMatch: (m) => m);
4 changes: 2 additions & 2 deletions lib/src/sync/w3c_spec/element_finder.dart
Expand Up @@ -31,8 +31,8 @@ class ElementFinder {
/// In principle, W3C spec implementations should be nearly the same as
/// the existing JSON wire spec. In practice compliance is uneven.
Map<String, String> _byToJson(By by) {
var using;
var value;
String using;
String value;

switch (by.using) {
case 'id': // This doesn't exist in the W3C spec.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/sync/w3c_spec/web_driver.dart
Expand Up @@ -211,8 +211,8 @@ class W3cWebDriver implements WebDriver, SearchContext {
(f) => f.library.startsWith('package:webdriver/'),
terse: true);
}
var result;
var exception;
Object result;
Object exception;
try {
result = fn();
return result;
Expand Down
3 changes: 0 additions & 3 deletions lib/src/sync/window.dart
Expand Up @@ -50,7 +50,4 @@ abstract class Window {

/// Sets the window as active.
void setAsActive();

@override
bool operator ==(other);
}
6 changes: 3 additions & 3 deletions pubspec.yaml
Expand Up @@ -3,9 +3,9 @@ version: 2.0.0-dev
authors:
- Marc Fisher II <fisherii@google.com>
- Matt Staats<staats@google.com>
description: >
Provides WebDriver bindings for Dart. These support the WebDriver JSON interface
and the W3C spec and require the use of the WebDriver remote server.
description: >-
Provides WebDriver bindings for Dart. These support the WebDriver JSON
interface and the W3C spec and require the use of the WebDriver remote server.
homepage: https://github.com/google/webdriver.dart
environment:
sdk: '>=2.0.0-dev.23.0'
Expand Down
4 changes: 3 additions & 1 deletion test/async_command_event_test.dart
Expand Up @@ -15,6 +15,8 @@
@TestOn('vm')
library webdriver.command_event_test;

import 'dart:async';

import 'package:stack_trace/stack_trace.dart';
import 'package:test/test.dart';
import 'package:webdriver/async_core.dart';
Expand All @@ -27,7 +29,7 @@ void main() {
WebDriver driver;

var events = <WebDriverCommandEvent>[];
var sub;
StreamSubscription sub;

setUp(() async {
driver = await config.createTestDriver();
Expand Down
12 changes: 5 additions & 7 deletions test/support/async_test.dart
Expand Up @@ -107,8 +107,7 @@ void main() {
});

test('throws if condition throws and timeouts', () async {
var exception;

Object exception;
try {
await clock.waitFor(() => throw 'an exception');
} catch (e) {
Expand All @@ -118,7 +117,7 @@ void main() {
});

test('throws if condition never matches', () async {
var exception;
Object exception;
try {
await clock.waitFor(() => null, matcher: isNotNull);
} catch (e) {
Expand All @@ -134,8 +133,7 @@ void main() {
});

test('works with Future exceptions', () async {
var exception;

Object exception;
try {
await clock.waitFor(() => new Future.error('an exception'));
} catch (e) {
Expand All @@ -160,7 +158,7 @@ void main() {

test('sanity test with real Clock -- throws', () async {
var clock = const Clock();
var exception;
Object exception;
try {
await clock.waitFor(() => throw 'an exception');
} catch (e) {
Expand All @@ -171,7 +169,7 @@ void main() {

test('sanity test with real Clock -- never matches', () async {
var clock = const Clock();
var exception;
Object exception;
try {
await clock.waitFor(() => null, matcher: isNotNull);
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion test/sync/keyboard.dart
Expand Up @@ -74,4 +74,4 @@ void runTests(config.createTestDriver createTestDriver) {
expect(textInput.properties['value'], 'xxx');
});
}, timeout: const Timeout(const Duration(minutes: 2)));
}
}

0 comments on commit 22f7bf3

Please sign in to comment.