chore: dartfmt Dart code in the repo

This commit is contained in:
Kevin Moore 2015-05-08 19:51:19 -07:00
parent a5638a940c
commit 7844e3a275
27 changed files with 252 additions and 332 deletions

View File

@ -1,8 +1,7 @@
library change_detectoin.change_detection_jit_generator;
class ChangeDetectorJITGenerator {
ChangeDetectorJITGenerator(typeName, strategy, records, directiveMementos) {
}
ChangeDetectorJITGenerator(typeName, strategy, records, directiveMementos) {}
generate() {
throw "Jit Change Detection is not supported in Dart";

View File

@ -15,7 +15,10 @@ class BaseQueryList extends Object with IterableMixin<Directive> {
List _callbacks;
bool _dirty;
BaseQueryList(): _results = [], _callbacks = [], _dirty = false;
BaseQueryList()
: _results = [],
_callbacks = [],
_dirty = false;
Iterator<Directive> get iterator => _results.iterator;

View File

@ -10,16 +10,14 @@ import 'dart:js' as js;
// Proxies a Dart function that accepts up to 10 parameters.
js.JsFunction _jsFunction(Function fn) {
const Object X = __varargSentinel;
return new js.JsFunction.withThis(
(thisArg, [o1=X, o2=X, o3=X, o4=X, o5=X, o6=X, o7=X, o8=X, o9=X, o10=X]) {
return new js.JsFunction.withThis((thisArg, [o1 = X, o2 = X, o3 = X, o4 = X,
o5 = X, o6 = X, o7 = X, o8 = X, o9 = X, o10 = X]) {
return __invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10);
});
}
const Object __varargSentinel = const Object();
__invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10) {
var args = [o1, o2, o3, o4, o5, o6, o7, o8, o9, o10];
while (args.length > 0 && identical(args.last, __varargSentinel)) {
@ -28,7 +26,6 @@ __invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10) {
return _jsify(Function.apply(fn, args));
}
// Helper function to JSify a Dart object. While this is *required* to JSify
// the result of a scope.eval(), other uses are not required and are used to
// work around http://dartbug.com/17752 in a convenient way (that bug affects
@ -44,8 +41,9 @@ _jsify(var obj) {
return _jsFunction(obj);
}
if ((obj is Map) || (obj is Iterable)) {
var mappedObj = (obj is Map) ?
new Map.fromIterables(obj.keys, obj.values.map(_jsify)) : obj.map(_jsify);
var mappedObj = (obj is Map)
? new Map.fromIterables(obj.keys, obj.values.map(_jsify))
: obj.map(_jsify);
if (obj is List) {
return new js.JsArray.from(mappedObj);
} else {
@ -77,8 +75,7 @@ class PublicTestability implements _JsObjectProxyable {
return _jsify({
'findBindings': (bindingString, [exactMatch, allowNonElementNodes]) =>
findBindings(bindingString, exactMatch, allowNonElementNodes),
'whenStable': (callback) =>
whenStable(() => callback.apply([])),
'whenStable': (callback) => whenStable(() => callback.apply([])),
})..['_dart_'] = this;
}
}

View File

@ -52,7 +52,8 @@ class VmTurnZone {
* @param {Function} onScheduleMicrotask
* @param {Function} onErrorHandler called when an exception is thrown by a macro or micro task
*/
initCallbacks({Function onTurnStart, Function onTurnDone, Function onScheduleMicrotask, Function onErrorHandler}) {
initCallbacks({Function onTurnStart, Function onTurnDone,
Function onScheduleMicrotask, Function onErrorHandler}) {
this._onTurnStart = onTurnStart;
this._onTurnDone = onTurnDone;
this._onScheduleMicrotask = onScheduleMicrotask;
@ -111,17 +112,19 @@ class VmTurnZone {
}
async.Zone _createInnerZone(async.Zone zone) {
return zone.fork(specification: new async.ZoneSpecification(
return zone.fork(
specification: new async.ZoneSpecification(
run: _onRun,
runUnary: _onRunUnary,
scheduleMicrotask: _onMicrotask
));
scheduleMicrotask: _onMicrotask));
}
dynamic _onRunBase(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) {
dynamic _onRunBase(
async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) {
_nestedRunCounter++;
try {
if (_nestedRunCounter == 1 && _onTurnStart != null) delegate.run(zone, _onTurnStart);
if (_nestedRunCounter == 1 && _onTurnStart != null) delegate.run(
zone, _onTurnStart);
return fn();
} catch (e, s) {
if (_onErrorHandler != null && _nestedRunCounter == 1) {
@ -131,21 +134,24 @@ class VmTurnZone {
}
} finally {
_nestedRunCounter--;
if (_nestedRunCounter == 0 && _onTurnDone != null) _finishTurn(zone, delegate);
if (_nestedRunCounter == 0 && _onTurnDone != null) _finishTurn(
zone, delegate);
}
}
dynamic _onRun(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) =>
_onRunBase(self, delegate, zone, () => delegate.run(zone, fn));
dynamic _onRun(async.Zone self, async.ZoneDelegate delegate, async.Zone zone,
fn()) => _onRunBase(self, delegate, zone, () => delegate.run(zone, fn));
dynamic _onRunUnary(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn(args), args) =>
dynamic _onRunUnary(async.Zone self, async.ZoneDelegate delegate,
async.Zone zone, fn(args), args) =>
_onRunBase(self, delegate, zone, () => delegate.runUnary(zone, fn, args));
void _finishTurn(zone, delegate) {
delegate.run(zone, _onTurnDone);
}
_onMicrotask(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn) {
_onMicrotask(
async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn) {
if (this._onScheduleMicrotask != null) {
_onScheduleMicrotask(fn);
} else {

View File

@ -33,8 +33,10 @@ class PromiseWrapper {
}
class ObservableWrapper {
static StreamSubscription subscribe(Stream s, Function onNext, [onError, onComplete]) {
return s.listen(onNext, onError: onError, onDone: onComplete, cancelOnError: true);
static StreamSubscription subscribe(Stream s, Function onNext,
[onError, onComplete]) {
return s.listen(onNext,
onError: onError, onDone: onComplete, cancelOnError: true);
}
static bool isObservable(obs) {
@ -65,14 +67,10 @@ class EventEmitter extends Stream {
_controller = new StreamController.broadcast();
}
StreamSubscription listen(void onData(String line), {
void onError(Error error),
void onDone(),
bool cancelOnError }) {
StreamSubscription listen(void onData(String line),
{void onError(Error error), void onDone(), bool cancelOnError}) {
return _controller.stream.listen(onData,
onError: onError,
onDone: onDone,
cancelOnError: cancelOnError);
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
}
void add(value) {
@ -88,7 +86,6 @@ class EventEmitter extends Stream {
}
}
class _Completer {
final Completer c;

View File

@ -6,7 +6,8 @@ library angular2.src.facade.browser;
import 'dart:js' show context;
export 'dart:html' show
export 'dart:html'
show
document,
location,
window,

View File

@ -96,7 +96,8 @@ class ListWrapper {
static bool contains(List m, k) => m.contains(k);
static List map(list, fn(item)) => list.map(fn).toList();
static List filter(List list, bool fn(item)) => list.where(fn).toList();
static int indexOf(List list, value, [int startIndex = 0]) => list.indexOf(value, startIndex);
static int indexOf(List list, value, [int startIndex = 0]) =>
list.indexOf(value, startIndex);
static int lastIndexOf(List list, value, [int startIndex = null]) =>
list.lastIndexOf(value, startIndex == null ? list.length : startIndex);
static find(List list, bool fn(item)) =>
@ -115,7 +116,9 @@ class ListWrapper {
l.add(e);
}
static List concat(List a, List b) {
return []..addAll(a)..addAll(b);
return []
..addAll(a)
..addAll(b);
}
static bool isList(l) => l is List;
static void insert(List l, int index, value) {

View File

@ -123,7 +123,8 @@ class RegExpWrapper {
static RegExp create(regExpStr, [String flags = '']) {
bool multiLine = flags.contains('m');
bool caseSensitive = !flags.contains('i');
return new RegExp(regExpStr, multiLine: multiLine, caseSensitive: caseSensitive);
return new RegExp(regExpStr,
multiLine: multiLine, caseSensitive: caseSensitive);
}
static Match firstMatch(RegExp regExp, String input) {
return regExp.firstMatch(input);

View File

@ -11,14 +11,17 @@ class HammerGesturesPlugin extends HammerGesturesPluginCommon {
if (!super.supports(eventName)) return false;
if (!js.context.hasProperty('Hammer')) {
throw new BaseException('Hammer.js is not loaded, can not bind ${eventName} event');
throw new BaseException(
'Hammer.js is not loaded, can not bind ${eventName} event');
}
return true;
}
addEventListener(Element element, String eventName, Function handler, bool shouldSupportBubble) {
if (shouldSupportBubble) throw new BaseException('Hammer.js plugin does not support bubbling gestures.');
addEventListener(Element element, String eventName, Function handler,
bool shouldSupportBubble) {
if (shouldSupportBubble) throw new BaseException(
'Hammer.js plugin does not support bubbling gestures.');
var zone = this.manager.getZone();
eventName = eventName.toLowerCase();

View File

@ -10,7 +10,6 @@ class XHRImpl extends XHR {
Future<String> get(String url) {
return HttpRequest.request(url).then(
(HttpRequest request) => request.responseText,
onError: (Error e) => throw 'Failed to load $url'
);
onError: (Error e) => throw 'Failed to load $url');
}
}

View File

@ -1,7 +1,8 @@
library test_lib.test_lib;
import 'package:guinness/guinness.dart' as gns;
export 'package:guinness/guinness.dart' hide Expect, expect, NotExpect, beforeEach, it, iit, xit;
export 'package:guinness/guinness.dart'
hide Expect, expect, NotExpect, beforeEach, it, iit, xit;
import 'package:unittest/unittest.dart' hide expect;
import 'dart:async';
@ -42,12 +43,9 @@ void testSetup() {
// - Priority 2: collect the bindings before each test, see beforeEachBindings(),
// - Priority 1: create the test injector to be used in beforeEach() and it()
gns.beforeEach(
() {
gns.beforeEach(() {
_testBindings.clear();
},
priority: 3
);
}, priority: 3);
var completerBinding = bind(AsyncTestCompleter).toFactory(() {
// Mark the test as async when an AsyncTestCompleter is injected in an it(),
@ -56,14 +54,11 @@ void testSetup() {
return new AsyncTestCompleter();
});
gns.beforeEach(
() {
gns.beforeEach(() {
_isCurrentTestAsync = false;
_testBindings.add(completerBinding);
_injector = createTestInjector(_testBindings);
},
priority: 1
);
}, priority: 1);
}
Expect expect(actual, [matcher]) {
@ -86,7 +81,8 @@ class Expect extends gns.Expect {
void toBeNaN() => _expect(double.NAN.compareTo(actual) == 0, equals(true));
void toHaveText(expected) => _expect(elementText(actual), expected);
void toHaveBeenCalledWith([a = _u, b = _u, c = _u, d = _u, e = _u, f = _u]) =>
_expect(_argsMatch(actual, a, b, c, d, e, f), true, reason: 'method invoked with correct arguments');
_expect(_argsMatch(actual, a, b, c, d, e, f), true,
reason: 'method invoked with correct arguments');
Function get _expect => gns.guinness.matchers.expect;
// TODO(tbosch): move this hack into Guinness
@ -141,13 +137,10 @@ void beforeEach(fn) {
* ]);
*/
void beforeEachBindings(Function fn) {
gns.beforeEach(
() {
gns.beforeEach(() {
var bindings = fn();
if (bindings != null) _testBindings.addAll(bindings);
},
priority: 2
);
}, priority: 2);
}
void _it(gnsFn, name, fn) {
@ -160,7 +153,6 @@ void _it(gnsFn, name, fn) {
});
}
void it(name, fn) {
_it(gns.it, name, fn);
}
@ -205,8 +197,6 @@ class SpyObject extends gns.SpyObject {
}
}
String elementText(n) {
hasNodes(n) {
var children = DOM.childNodes(n);

View File

@ -3,4 +3,3 @@ import 'dart:html';
Rectangle createRectangle(left, top, width, height) {
return new Rectangle(left, top, width, height);
}

View File

@ -7,7 +7,6 @@ import 'dart:html';
import 'package:angular2/src/test_lib/benchmark_util.dart';
main() {
var count = getIntParameter('elements');
var m = new Module()
@ -36,7 +35,6 @@ main() {
bindAction('#compileWithBindings', compileWithBindings);
bindAction('#compileNoBindings', compileNoBindings);
}
loadTemplate(templateId, repeatCount) {
@ -58,64 +56,35 @@ createTemplate(String html) {
return div;
}
@Directive(
selector: '[dir0]',
map: const {
'attr0': '=>prop'
}
)
@Directive(selector: '[dir0]', map: const {'attr0': '=>prop'})
class Dir0 {
Object prop;
}
@Directive(
selector: '[dir1]',
map: const {
'attr1': '=>prop'
}
)
@Directive(selector: '[dir1]', map: const {'attr1': '=>prop'})
class Dir1 {
Object prop;
constructor(Dir0 dir0) {
}
constructor(Dir0 dir0) {}
}
@Directive(
selector: '[dir2]',
map: const {
'attr2': '=>prop'
}
)
@Directive(selector: '[dir2]', map: const {'attr2': '=>prop'})
class Dir2 {
Object prop;
constructor(Dir1 dir1) {
}
constructor(Dir1 dir1) {}
}
@Directive(
selector: '[dir3]',
map: const {
'attr3': '=>prop'
}
)
@Directive(selector: '[dir3]', map: const {'attr3': '=>prop'})
class Dir3 {
Object prop;
constructor(Dir2 dir2) {
}
constructor(Dir2 dir2) {}
}
@Directive(
selector: '[dir4]',
map: const {
'attr4': '=>prop'
}
)
@Directive(selector: '[dir4]', map: const {'attr4': '=>prop'})
class Dir4 {
Object prop;
constructor(Dir3 dir3) {
}
constructor(Dir3 dir3) {}
}

View File

@ -5,9 +5,7 @@ import 'dart:html';
import 'package:angular/angular.dart';
import 'package:angular2/src/test_lib/benchmark_util.dart';
@Component(
selector: 'scroll-app',
template: '''
@Component(selector: 'scroll-app', template: '''
<div>
<div style="display: flex">
<scroll-area scroll-top="scrollTop"></scroll-area>

View File

@ -3,43 +3,25 @@ library cells;
import 'package:angular/angular.dart';
import 'common.dart';
@Component(
selector: 'company-name',
template: '''
@Component(selector: 'company-name', template: '''
<div style="width: {{width}}">{{company.name}}</div>
''',
map: const {
'company': '=>company',
'cell-width': '=>width',
})
''', map: const {'company': '=>company', 'cell-width': '=>width',})
class CompanyNameComponent {
String width;
Company company;
}
@Component(
selector: 'opportunity-name',
template: '''
@Component(selector: 'opportunity-name', template: '''
<div style="width: {{width}}">{{opportunity.name}}</div>
''',
map: const {
'opportunity': '=>opportunity',
'cell-width': '=>width',
})
''', map: const {'opportunity': '=>opportunity', 'cell-width': '=>width',})
class OpportunityNameComponent {
String width;
Opportunity opportunity;
}
@Component(
selector: 'offering-name',
template: '''
@Component(selector: 'offering-name', template: '''
<div style="width: {{width}}">{{offering.name}}</div>
''',
map: const {
'offering': '=>offering',
'cell-width': '=>width',
})
''', map: const {'offering': '=>offering', 'cell-width': '=>width',})
class OfferingNameComponent {
String width;
Offering offering;
@ -52,15 +34,11 @@ class Stage {
Function apply;
String get styleString => style != null
? style.keys
.map((prop) => '$prop: ${style[prop]}')
.join(';')
? style.keys.map((prop) => '$prop: ${style[prop]}').join(';')
: '';
}
@Component(
selector: 'stage-buttons',
template: '''
@Component(selector: 'stage-buttons', template: '''
<div style="width: {{width}}">
<button ng-repeat="stage in stages"
ng-disabled="stage.isDisabled"
@ -69,11 +47,7 @@ class Stage {
{{stage.name}}
</button>
</div>
''',
map: const {
'offering': '=>offering',
'cell-width': '=>width',
})
''', map: const {'offering': '=>offering', 'cell-width': '=>width',})
class StageButtonsComponent {
Offering _offering;
List<Stage> stages;
@ -92,42 +66,30 @@ class StageButtonsComponent {
_computeStageButtons() {
bool disabled = true;
stages = STATUS_LIST
.map((String status) {
stages = STATUS_LIST.map((String status) {
bool isCurrent = offering.status == status;
var stage = new Stage();
stage
..name = status
..isDisabled = disabled
..style = {
'background-color': disabled
? '#DDD'
: isCurrent
? '#DDF'
: '#FDD'
'background-color': disabled ? '#DDD' : isCurrent ? '#DDF' : '#FDD'
};
if (isCurrent) {
disabled = false;
}
return stage;
})
.toList();
}).toList();
}
}
@Component(
selector: 'account-cell',
template: '''
@Component(selector: 'account-cell', template: '''
<div style="width: {{width}}">
<a href="/account/{{account.accountId}}">
{{account.accountId}}
</a>
</div>
''',
map: const {
'account': '=>account',
'cell-width': '=>width',
})
''', map: const {'account': '=>account', 'cell-width': '=>width',})
class AccountCellComponent {
Account account;
String width;
@ -136,10 +98,7 @@ class AccountCellComponent {
@Component(
selector: 'formatted-cell',
template: '''<div style="width: {{width}}">{{formattedValue}}</div>''',
map: const {
'value': '=>value',
'cell-width': '=>width',
})
map: const {'value': '=>value', 'cell-width': '=>width',})
class FormattedCellComponent {
String formattedValue;
String width;

View File

@ -34,21 +34,14 @@ const ROW_WIDTH = COMPANY_NAME_WIDTH +
END_DATE_WIDTH +
AAT_STATUS_WIDTH;
const STATUS_LIST = const [
'Planned', 'Pitched', 'Won', 'Lost'
];
const STATUS_LIST = const ['Planned', 'Pitched', 'Won', 'Lost'];
const AAT_STATUS_LIST = const [
'Active', 'Passive', 'Abandoned'
];
const AAT_STATUS_LIST = const ['Active', 'Passive', 'Abandoned'];
// Imitate Streamy entities.
class RawEntity
extends Object
with MapMixin<String, dynamic>
class RawEntity extends Object with MapMixin<String, dynamic>
implements ObservableMap<String, dynamic> {
ObservableMap _data = new ObservableMap();
@override
@ -199,7 +192,6 @@ class Opportunity extends RawEntity {
set name(String val) {
this['name'] = val;
}
}
class Account extends RawEntity {

View File

@ -9,7 +9,8 @@ import 'cells.dart';
class MyAppModule extends Module {
MyAppModule() {
bind(ResourceResolverConfig, toValue: new ResourceResolverConfig.resolveRelativeUrls(false));
bind(ResourceResolverConfig,
toValue: new ResourceResolverConfig.resolveRelativeUrls(false));
bind(App);
bind(ScrollAreaComponent);
bind(ScrollItemComponent);
@ -23,7 +24,5 @@ class MyAppModule extends Module {
}
void main() {
applicationFactory()
.addModule(new MyAppModule())
.run();
applicationFactory().addModule(new MyAppModule()).run();
}

View File

@ -22,24 +22,32 @@ Offering generateOffering(int seed) {
}
Company generateCompany(int seed) {
return new Company()
..name = generateName(seed);
return new Company()..name = generateName(seed);
}
Opportunity generateOpportunity(int seed) {
return new Opportunity()
..name = generateName(seed);
return new Opportunity()..name = generateName(seed);
}
Account generateAccount(int seed) {
return new Account()
..accountId = seed;
return new Account()..accountId = seed;
}
String generateName(int seed) {
const names = const [
'Foo', 'Bar', 'Baz', 'Qux', 'Quux', 'Garply', 'Waldo', 'Fred', 'Plugh',
'Xyzzy', 'Thud', 'Cruft', 'Stuff'
'Foo',
'Bar',
'Baz',
'Qux',
'Quux',
'Garply',
'Waldo',
'Fred',
'Plugh',
'Xyzzy',
'Thud',
'Cruft',
'Stuff'
];
return names[seed % names.length];
}
@ -54,8 +62,12 @@ DateTime randomDate(int seed, {DateTime minDate}) {
}
String randomString(int seed) {
return new String.fromCharCodes(new List.generate(
const[5, 7, 9, 11, 13][seed % 5],
(i) => 'a'.codeUnitAt(0) + const[0, 1, 2, 3, 4, 5, 6, 7, 8][seed % 9] + i
));
return new String.fromCharCodes(new List.generate(const [
5,
7,
9,
11,
13
][seed % 5], (i) =>
'a'.codeUnitAt(0) + const [0, 1, 2, 3, 4, 5, 6, 7, 8][seed % 9] + i));
}

View File

@ -9,9 +9,7 @@ import 'random_data.dart';
@Component(
selector: 'scroll-area',
templateUrl: 'scroll_area.html',
map: const {
'scroll-top': '=>scrollTop',
})
map: const {'scroll-top': '=>scrollTop',})
class ScrollAreaComponent implements ShadowRootAware {
Element scrollDiv;
List<Offering> _fullList;
@ -52,7 +50,8 @@ class ScrollAreaComponent implements ShadowRootAware {
int padding = iStart * ITEM_HEIGHT;
innerStyle['height'] = '${HEIGHT - padding}px';
paddingStyle['height'] = '${padding}px';
visibleItems..clear()..addAll(_fullList.getRange(iStart, iEnd));
visibleItems
..clear()
..addAll(_fullList.getRange(iStart, iEnd));
}
}

View File

@ -6,11 +6,8 @@ import 'common.dart';
@Component(
selector: 'scroll-item',
templateUrl: 'scroll_item.html',
map: const {
'offering': '=>offering',
})
map: const {'offering': '=>offering',})
class ScrollItemComponent implements ShadowRootAware {
Offering offering;
// Init empty maps and populate later. There seems to be a bug in Angular

View File

@ -6,10 +6,11 @@ import 'package:angular/application_factory.dart';
import 'package:angular2/src/test_lib/benchmark_util.dart';
setup() {
var m = new Module()
..bind(CompilerConfig, toValue: new CompilerConfig.withOptions(elementProbeEnabled: false))
..bind(ScopeDigestTTL, toFactory: () => new ScopeDigestTTL.value(15), inject: [])
..bind(CompilerConfig,
toValue: new CompilerConfig.withOptions(elementProbeEnabled: false))
..bind(ScopeDigestTTL,
toFactory: () => new ScopeDigestTTL.value(15), inject: [])
..bind(TreeComponent);
final injector = applicationFactory().addModule(m).run();
@ -33,9 +34,9 @@ main() {
createDom() {
zone.run(() {
var values = count++ % 2 == 0 ?
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'] :
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
var values = count++ % 2 == 0
? ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*']
: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
rootScope.context['initData'] = buildTree(maxDepth, values, 0);
});
@ -51,16 +52,14 @@ main() {
template: '<span> {{data.value}}'
'<span ng-if="data.right != null"><tree data=data.right></span>'
'<span ng-if="data.left != null"><tree data=data.left></span>'
'</span>'
)
'</span>')
class TreeComponent {
var data;
}
buildTree(maxDepth, values, curDepth) {
if (maxDepth == curDepth) return new TreeNode('');
return new TreeNode(
values[curDepth],
return new TreeNode(values[curDepth],
buildTree(maxDepth, values, curDepth + 1),
buildTree(maxDepth, values, curDepth + 1));
}
@ -71,4 +70,3 @@ class TreeNode {
TreeNode right;
TreeNode([this.value, this.left, this.right]);
}

View File

@ -1,2 +1,3 @@
export './common.dart';
export './src/webdriver/async_webdriver_adapter.dart' show AsyncWebDriverAdapter;
export './src/webdriver/async_webdriver_adapter.dart'
show AsyncWebDriverAdapter;

View File

@ -21,10 +21,9 @@ class AsyncWebDriverAdapter extends WebDriverAdapter {
}
Future<List<Map>> logs(String type) {
return _driver.logs.get(type)
.map((LogEntry entry) => {
'message': entry.message
})
return _driver.logs
.get(type)
.map((LogEntry entry) => {'message': entry.message})
.fold(<Map>[], (log, Map entry) {
return log..add(entry);
});

View File

@ -2,7 +2,8 @@ import 'dart:async';
import 'dart:io' show Platform;
import 'package:guinness/guinness.dart';
import 'package:benchpress/benchpress.dart';
import 'package:webdriver/webdriver.dart' show WebDriver, Capabilities, LogType, LogLevel, By;
import 'package:webdriver/webdriver.dart'
show WebDriver, Capabilities, LogType, LogLevel, By;
main() {
describe('benchpress', () {
@ -11,10 +12,12 @@ main() {
beforeEach(() async {
driver = await createTestDriver();
await driver.get('http://localhost:8002/examples/src/benchpress/index.html');
await driver
.get('http://localhost:8002/examples/src/benchpress/index.html');
var bindings = [
bind(WebDriverAdapter).toFactory(() => new AsyncWebDriverAdapter(driver), [])
bind(WebDriverAdapter).toFactory(
() => new AsyncWebDriverAdapter(driver), [])
];
runner = new Runner(bindings);
});
@ -24,34 +27,30 @@ main() {
});
it('should work', () {
return runner.sample(
id: 'benchpress smoke test',
execute: () async {
return runner.sample(id: 'benchpress smoke test', execute: () async {
var button = await driver.findElement(const By.tagName('button'));
await button.click();
var logText = await (await driver.findElement(const By.id('log'))).text;
expect(logText, 'hi');
}
);
});
});
});
}
Future<WebDriver> createTestDriver() {
Map env = Platform.environment;
return WebDriver.createDriver(desiredCapabilities: {
return WebDriver.createDriver(
desiredCapabilities: {
'name': 'Dartium',
'browserName': 'chrome',
'chromeOptions': {
'binary': env['DARTIUM_BIN'],
'args': ['--js-flags=--expose-gc'],
'perfLoggingPrefs': {
'traceCategories': 'v8,blink.console,disabled-by-default-devtools.timeline'
'traceCategories':
'v8,blink.console,disabled-by-default-devtools.timeline'
},
},
'loggingPrefs': {
'performance': 'ALL',
'browser': 'ALL',
}
'loggingPrefs': {'performance': 'ALL', 'browser': 'ALL',}
});
}