chore: dartfmt Dart code in the repo
This commit is contained in:
parent
a5638a940c
commit
7844e3a275
|
@ -1,3 +1,3 @@
|
|||
// Globals are provided by lang.dart in Dart.
|
||||
// This file exists to prevent global.ts from being transpiled.
|
||||
library angular2.globals;
|
||||
library angular2.globals;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 __invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10);
|
||||
});
|
||||
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 {
|
||||
|
@ -75,10 +73,9 @@ class PublicTestability implements _JsObjectProxyable {
|
|||
|
||||
js.JsObject _toJsObject() {
|
||||
return _jsify({
|
||||
'findBindings': (bindingString, [exactMatch, allowNonElementNodes]) =>
|
||||
findBindings(bindingString, exactMatch, allowNonElementNodes),
|
||||
'whenStable': (callback) =>
|
||||
whenStable(() => callback.apply([])),
|
||||
'findBindings': (bindingString, [exactMatch, allowNonElementNodes]) =>
|
||||
findBindings(bindingString, exactMatch, allowNonElementNodes),
|
||||
'whenStable': (callback) => whenStable(() => callback.apply([])),
|
||||
})..['_dart_'] = this;
|
||||
}
|
||||
}
|
||||
|
@ -86,8 +83,8 @@ class PublicTestability implements _JsObjectProxyable {
|
|||
class GetTestability {
|
||||
static addToWindow(TestabilityRegistry registry) {
|
||||
js.context['getAngularTestability'] = _jsify((Element elem) {
|
||||
Testability testability = registry.findTestabilityInTree(elem);
|
||||
return _jsify(new PublicTestability(testability));
|
||||
});
|
||||
Testability testability = registry.findTestabilityInTree(elem);
|
||||
return _jsify(new PublicTestability(testability));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
run: _onRun,
|
||||
runUnary: _onRunUnary,
|
||||
scheduleMicrotask: _onMicrotask
|
||||
));
|
||||
return zone.fork(
|
||||
specification: new async.ZoneSpecification(
|
||||
run: _onRun,
|
||||
runUnary: _onRunUnary,
|
||||
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 {
|
||||
|
|
|
@ -2,4 +2,4 @@ library angular2.di.decorators;
|
|||
|
||||
/* This file is empty because, Dart does not have decorators. */
|
||||
|
||||
export 'annotations.dart';
|
||||
export 'annotations.dart';
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -6,15 +6,16 @@ library angular2.src.facade.browser;
|
|||
|
||||
import 'dart:js' show context;
|
||||
|
||||
export 'dart:html' show
|
||||
document,
|
||||
location,
|
||||
window,
|
||||
Element,
|
||||
Node,
|
||||
MouseEvent,
|
||||
KeyboardEvent,
|
||||
Event;
|
||||
export 'dart:html'
|
||||
show
|
||||
document,
|
||||
location,
|
||||
window,
|
||||
Element,
|
||||
Node,
|
||||
MouseEvent,
|
||||
KeyboardEvent,
|
||||
Event;
|
||||
|
||||
final _gc = context['gc'];
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ class StringMapWrapper {
|
|||
map[key] = value;
|
||||
}
|
||||
static void delete(Map m, k) {
|
||||
m.remove(k);
|
||||
m.remove(k);
|
||||
}
|
||||
static void forEach(Map m, fn(v, k)) {
|
||||
m.forEach((k, v) => fn(v, k));
|
||||
|
@ -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) {
|
||||
|
@ -154,7 +157,7 @@ class ListWrapper {
|
|||
l.removeRange(from, to);
|
||||
return sub;
|
||||
}
|
||||
static void sort(List l, compareFn(a,b)) {
|
||||
static void sort(List l, compareFn(a, b)) {
|
||||
l.sort(compareFn);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
@ -147,7 +148,7 @@ class _JSLikeMatch {
|
|||
|
||||
_JSLikeMatch(this._m);
|
||||
|
||||
String operator[](index) => _m[index];
|
||||
String operator [](index) => _m[index];
|
||||
int get index => _m.start;
|
||||
int get length => _m.groupCount + 1;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
library angular2.src.services.xhr_impl;
|
||||
library angular2.src.services.xhr_impl;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:html';
|
||||
|
@ -9,8 +9,7 @@ import './xhr.dart' show XHR;
|
|||
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'
|
||||
);
|
||||
(HttpRequest request) => request.responseText,
|
||||
onError: (Error e) => throw 'Failed to load $url');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
() {
|
||||
_testBindings.clear();
|
||||
},
|
||||
priority: 3
|
||||
);
|
||||
gns.beforeEach(() {
|
||||
_testBindings.clear();
|
||||
}, 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(
|
||||
() {
|
||||
_isCurrentTestAsync = false;
|
||||
_testBindings.add(completerBinding);
|
||||
_injector = createTestInjector(_testBindings);
|
||||
},
|
||||
priority: 1
|
||||
);
|
||||
gns.beforeEach(() {
|
||||
_isCurrentTestAsync = false;
|
||||
_testBindings.add(completerBinding);
|
||||
_injector = createTestInjector(_testBindings);
|
||||
}, priority: 1);
|
||||
}
|
||||
|
||||
Expect expect(actual, [matcher]) {
|
||||
|
@ -80,13 +75,14 @@ class Expect extends gns.Expect {
|
|||
NotExpect get not => new NotExpect(actual);
|
||||
|
||||
void toEqual(expected) => toHaveSameProps(expected);
|
||||
void toThrowError([message=""]) => toThrowWith(message: message);
|
||||
void toThrowError([message = ""]) => toThrowWith(message: message);
|
||||
void toBePromise() => _expect(actual is Future, equals(true));
|
||||
void toImplement(expected) => toBeA(expected);
|
||||
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
|
||||
|
@ -97,7 +93,7 @@ class Expect extends gns.Expect {
|
|||
return false;
|
||||
} else {
|
||||
gns.SamePropsMatcher matcher = new gns.SamePropsMatcher(toMatch);
|
||||
for (var i=0; i<calls.length; i++) {
|
||||
for (var i = 0; i < calls.length; i++) {
|
||||
var call = calls[i];
|
||||
// TODO: create a better error message, not just 'Expected: <true> Actual: <false>'.
|
||||
// For hacking this is good:
|
||||
|
@ -141,13 +137,10 @@ void beforeEach(fn) {
|
|||
* ]);
|
||||
*/
|
||||
void beforeEachBindings(Function fn) {
|
||||
gns.beforeEach(
|
||||
() {
|
||||
var bindings = fn();
|
||||
if (bindings != null) _testBindings.addAll(bindings);
|
||||
},
|
||||
priority: 2
|
||||
);
|
||||
gns.beforeEach(() {
|
||||
var bindings = fn();
|
||||
if (bindings != null) _testBindings.addAll(bindings);
|
||||
}, 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);
|
||||
}
|
||||
|
@ -174,7 +166,7 @@ void xit(name, fn) {
|
|||
}
|
||||
|
||||
class SpyFunction extends gns.SpyFunction {
|
||||
SpyFunction(String name): super(name);
|
||||
SpyFunction(String name) : super(name);
|
||||
|
||||
// TODO: vsavkin move to guinness
|
||||
andReturn(value) {
|
||||
|
@ -185,10 +177,10 @@ class SpyFunction extends gns.SpyFunction {
|
|||
class SpyObject extends gns.SpyObject {
|
||||
final Map<String, SpyFunction> _spyFuncs = {};
|
||||
|
||||
SpyObject([arg]){}
|
||||
SpyObject([arg]) {}
|
||||
|
||||
SpyFunction spy(String funcName) =>
|
||||
_spyFuncs.putIfAbsent(funcName, () => new SpyFunction(funcName));
|
||||
_spyFuncs.putIfAbsent(funcName, () => new SpyFunction(funcName));
|
||||
|
||||
static stub([object = null, config = null, overrides = null]) {
|
||||
if (object is! SpyObject) {
|
||||
|
@ -198,15 +190,13 @@ class SpyObject extends gns.SpyObject {
|
|||
}
|
||||
|
||||
var m = StringMapWrapper.merge(config, overrides);
|
||||
StringMapWrapper.forEach(m, (value, key){
|
||||
StringMapWrapper.forEach(m, (value, key) {
|
||||
object.spy(key).andReturn(value);
|
||||
});
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
String elementText(n) {
|
||||
hasNodes(n) {
|
||||
var children = DOM.childNodes(n);
|
||||
|
|
|
@ -1 +1 @@
|
|||
library util_decorators;
|
||||
library util_decorators;
|
||||
|
|
|
@ -3,4 +3,3 @@ import 'dart:html';
|
|||
Rectangle createRectangle(left, top, width, height) {
|
||||
return new Rectangle(left, top, width, height);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,13 +35,12 @@ main() {
|
|||
|
||||
bindAction('#compileWithBindings', compileWithBindings);
|
||||
bindAction('#compileNoBindings', compileNoBindings);
|
||||
|
||||
}
|
||||
|
||||
loadTemplate(templateId, repeatCount) {
|
||||
String result = '';
|
||||
var content = document.querySelector("#${templateId}").innerHtml;
|
||||
for (var i=0; i<repeatCount; i++) {
|
||||
for (var i = 0; i < repeatCount; i++) {
|
||||
result += content;
|
||||
}
|
||||
return createTemplate(result.replaceAll(new RegExp(r'[\[\]]'), ''));
|
||||
|
@ -54,68 +52,39 @@ class IdentitySanitizer implements NodeTreeSanitizer {
|
|||
|
||||
createTemplate(String html) {
|
||||
var div = document.createElement('div');
|
||||
div.setInnerHtml(html, treeSanitizer:new IdentitySanitizer());
|
||||
div.setInnerHtml(html, treeSanitizer: new IdentitySanitizer());
|
||||
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) {}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
@ -29,7 +27,7 @@ class App implements ShadowRootAware {
|
|||
int appSize = getIntParameter('appSize');
|
||||
iterationCount = getIntParameter('iterationCount');
|
||||
scrollIncrement = getIntParameter('scrollIncrement');
|
||||
appSize = appSize > 1 ? appSize - 1 : 0; // draw at least one table
|
||||
appSize = appSize > 1 ? appSize - 1 : 0; // draw at least one table
|
||||
scrollAreas = new List.generate(appSize, (i) => i);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -23,32 +23,25 @@ const DUE_DATE_WIDTH = 100;
|
|||
const END_DATE_WIDTH = 100;
|
||||
const AAT_STATUS_WIDTH = 100;
|
||||
const ROW_WIDTH = COMPANY_NAME_WIDTH +
|
||||
OPPORTUNITY_NAME_WIDTH +
|
||||
OFFERING_NAME_WIDTH +
|
||||
ACCOUNT_CELL_WIDTH +
|
||||
BASE_POINTS_WIDTH +
|
||||
KICKER_POINTS_WIDTH +
|
||||
STAGE_BUTTONS_WIDTH +
|
||||
BUNDLES_WIDTH +
|
||||
DUE_DATE_WIDTH +
|
||||
END_DATE_WIDTH +
|
||||
AAT_STATUS_WIDTH;
|
||||
OPPORTUNITY_NAME_WIDTH +
|
||||
OFFERING_NAME_WIDTH +
|
||||
ACCOUNT_CELL_WIDTH +
|
||||
BASE_POINTS_WIDTH +
|
||||
KICKER_POINTS_WIDTH +
|
||||
STAGE_BUTTONS_WIDTH +
|
||||
BUNDLES_WIDTH +
|
||||
DUE_DATE_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>
|
||||
implements ObservableMap<String, dynamic> {
|
||||
|
||||
class RawEntity extends Object with MapMixin<String, dynamic>
|
||||
implements ObservableMap<String, dynamic> {
|
||||
ObservableMap _data = new ObservableMap();
|
||||
|
||||
@override
|
||||
|
@ -60,7 +53,7 @@ implements ObservableMap<String, dynamic> {
|
|||
}
|
||||
|
||||
@override
|
||||
operator[](String key) {
|
||||
operator [](String key) {
|
||||
if (!key.contains('.')) {
|
||||
return _data[key];
|
||||
}
|
||||
|
@ -74,7 +67,7 @@ implements ObservableMap<String, dynamic> {
|
|||
}
|
||||
|
||||
@override
|
||||
operator[]=(String key, value) {
|
||||
operator []=(String key, value) {
|
||||
if (!key.contains('.')) {
|
||||
_data[key] = value;
|
||||
return;
|
||||
|
@ -115,7 +108,7 @@ implements ObservableMap<String, dynamic> {
|
|||
bool deliverChanges() => _data.deliverChanges();
|
||||
@override
|
||||
notifyPropertyChange(Symbol field, Object oldValue, Object newValue) =>
|
||||
_data.notifyPropertyChange(field, oldValue, newValue);
|
||||
_data.notifyPropertyChange(field, oldValue, newValue);
|
||||
@override
|
||||
void notifyChange(ChangeRecord record) {
|
||||
_data.notifyChange(record);
|
||||
|
@ -199,7 +192,6 @@ class Opportunity extends RawEntity {
|
|||
set name(String val) {
|
||||
this['name'] = val;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Account extends RawEntity {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ library random_data;
|
|||
import 'common.dart';
|
||||
|
||||
List<Offering> generateOfferings(int count) =>
|
||||
new List.generate(count, generateOffering);
|
||||
new List.generate(count, generateOffering);
|
||||
|
||||
Offering generateOffering(int seed) {
|
||||
final res = new Offering();
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -49,13 +57,17 @@ DateTime randomDate(int seed, {DateTime minDate}) {
|
|||
minDate = new DateTime.now();
|
||||
}
|
||||
|
||||
const offsets = const[0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
const offsets = const [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
return minDate.add(new Duration(days: offsets[seed % offsets.length]));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -32,10 +30,10 @@ class ScrollAreaComponent implements ShadowRootAware {
|
|||
scrollDiv = shadowRoot.querySelector('#scrollDiv');
|
||||
onScroll();
|
||||
scrollDivStyle.addAll({
|
||||
'height': '${VIEW_PORT_HEIGHT}px',
|
||||
'width': '1000px',
|
||||
'border': '1px solid #000',
|
||||
'overflow': 'scroll',
|
||||
'height': '${VIEW_PORT_HEIGHT}px',
|
||||
'width': '1000px',
|
||||
'border': '1px solid #000',
|
||||
'overflow': 'scroll',
|
||||
});
|
||||
innerStyle['width'] = '${ROW_WIDTH}px';
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,36 +6,33 @@ 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;
|
||||
|
||||
Offering offering;
|
||||
// Init empty maps and populate later. There seems to be a bug in Angular
|
||||
// that makes it choke on pre-populated style maps.
|
||||
Map itemStyle = {};
|
||||
|
||||
// Init empty maps and populate later. There seems to be a bug in Angular
|
||||
// that makes it choke on pre-populated style maps.
|
||||
Map itemStyle = {};
|
||||
|
||||
@override
|
||||
void onShadowRoot(_) {
|
||||
itemStyle.addAll({
|
||||
'height': '${ITEM_HEIGHT}px',
|
||||
'line-height': '${ITEM_HEIGHT}px',
|
||||
'font-size': '18px',
|
||||
'display': 'flex',
|
||||
'justify-content': 'space-between',
|
||||
});
|
||||
}
|
||||
get companyNameWidth => '${COMPANY_NAME_WIDTH}px';
|
||||
get opportunityNameWidth => '${OPPORTUNITY_NAME_WIDTH}px';
|
||||
get offeringNameWidth => '${OFFERING_NAME_WIDTH}px';
|
||||
get accountCellWidth => '${ACCOUNT_CELL_WIDTH}px';
|
||||
get basePointsWidth => '${BASE_POINTS_WIDTH}px';
|
||||
get kickerPointsWidth => '${KICKER_POINTS_WIDTH}px';
|
||||
get stageButtonsWidth => '${STAGE_BUTTONS_WIDTH}px';
|
||||
get bundlesWidth => '${BUNDLES_WIDTH}px';
|
||||
get dueDateWidth => '${DUE_DATE_WIDTH}px';
|
||||
get endDateWidth => '${END_DATE_WIDTH}px';
|
||||
get aatStatusWidth => '${AAT_STATUS_WIDTH}px';
|
||||
@override
|
||||
void onShadowRoot(_) {
|
||||
itemStyle.addAll({
|
||||
'height': '${ITEM_HEIGHT}px',
|
||||
'line-height': '${ITEM_HEIGHT}px',
|
||||
'font-size': '18px',
|
||||
'display': 'flex',
|
||||
'justify-content': 'space-between',
|
||||
});
|
||||
}
|
||||
get companyNameWidth => '${COMPANY_NAME_WIDTH}px';
|
||||
get opportunityNameWidth => '${OPPORTUNITY_NAME_WIDTH}px';
|
||||
get offeringNameWidth => '${OFFERING_NAME_WIDTH}px';
|
||||
get accountCellWidth => '${ACCOUNT_CELL_WIDTH}px';
|
||||
get basePointsWidth => '${BASE_POINTS_WIDTH}px';
|
||||
get kickerPointsWidth => '${KICKER_POINTS_WIDTH}px';
|
||||
get stageButtonsWidth => '${STAGE_BUTTONS_WIDTH}px';
|
||||
get bundlesWidth => '${BUNDLES_WIDTH}px';
|
||||
get dueDateWidth => '${DUE_DATE_WIDTH}px';
|
||||
get endDateWidth => '${END_DATE_WIDTH}px';
|
||||
get aatStatusWidth => '${AAT_STATUS_WIDTH}px';
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
@ -46,23 +47,21 @@ main() {
|
|||
}
|
||||
|
||||
@Component(
|
||||
selector: 'tree',
|
||||
map: const {'data': '=>data'},
|
||||
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>'
|
||||
)
|
||||
selector: 'tree',
|
||||
map: const {'data': '=>data'},
|
||||
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>')
|
||||
class TreeComponent {
|
||||
var data;
|
||||
}
|
||||
|
||||
buildTree(maxDepth, values, curDepth) {
|
||||
if (maxDepth == curDepth) return new TreeNode('');
|
||||
return new TreeNode(
|
||||
values[curDepth],
|
||||
buildTree(maxDepth, values, curDepth+1),
|
||||
buildTree(maxDepth, values, curDepth+1));
|
||||
return new TreeNode(values[curDepth],
|
||||
buildTree(maxDepth, values, curDepth + 1),
|
||||
buildTree(maxDepth, values, curDepth + 1));
|
||||
}
|
||||
|
||||
class TreeNode {
|
||||
|
@ -71,4 +70,3 @@ class TreeNode {
|
|||
TreeNode right;
|
||||
TreeNode([this.value, this.left, this.right]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -13,7 +13,7 @@ class AsyncWebDriverAdapter extends WebDriverAdapter {
|
|||
}
|
||||
|
||||
Future executeScript(String script) {
|
||||
return _driver.execute(script, const[]);
|
||||
return _driver.execute(script, const []);
|
||||
}
|
||||
|
||||
Future<Map> capabilities() {
|
||||
|
@ -21,12 +21,11 @@ class AsyncWebDriverAdapter extends WebDriverAdapter {
|
|||
}
|
||||
|
||||
Future<List<Map>> logs(String type) {
|
||||
return _driver.logs.get(type)
|
||||
.map((LogEntry entry) => {
|
||||
'message': entry.message
|
||||
})
|
||||
.fold(<Map>[], (log, Map entry) {
|
||||
return log..add(entry);
|
||||
});
|
||||
return _driver.logs
|
||||
.get(type)
|
||||
.map((LogEntry entry) => {'message': entry.message})
|
||||
.fold(<Map>[], (log, Map entry) {
|
||||
return log..add(entry);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
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');
|
||||
}
|
||||
);
|
||||
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',}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue