chore: dartfmt Dart code in the repo
This commit is contained in:
parent
a5638a940c
commit
7844e3a275
|
@ -1,8 +1,7 @@
|
||||||
library change_detectoin.change_detection_jit_generator;
|
library change_detectoin.change_detection_jit_generator;
|
||||||
|
|
||||||
class ChangeDetectorJITGenerator {
|
class ChangeDetectorJITGenerator {
|
||||||
ChangeDetectorJITGenerator(typeName, strategy, records, directiveMementos) {
|
ChangeDetectorJITGenerator(typeName, strategy, records, directiveMementos) {}
|
||||||
}
|
|
||||||
|
|
||||||
generate() {
|
generate() {
|
||||||
throw "Jit Change Detection is not supported in Dart";
|
throw "Jit Change Detection is not supported in Dart";
|
||||||
|
|
|
@ -15,7 +15,10 @@ class BaseQueryList extends Object with IterableMixin<Directive> {
|
||||||
List _callbacks;
|
List _callbacks;
|
||||||
bool _dirty;
|
bool _dirty;
|
||||||
|
|
||||||
BaseQueryList(): _results = [], _callbacks = [], _dirty = false;
|
BaseQueryList()
|
||||||
|
: _results = [],
|
||||||
|
_callbacks = [],
|
||||||
|
_dirty = false;
|
||||||
|
|
||||||
Iterator<Directive> get iterator => _results.iterator;
|
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.
|
// Proxies a Dart function that accepts up to 10 parameters.
|
||||||
js.JsFunction _jsFunction(Function fn) {
|
js.JsFunction _jsFunction(Function fn) {
|
||||||
const Object X = __varargSentinel;
|
const Object X = __varargSentinel;
|
||||||
return new js.JsFunction.withThis(
|
return new js.JsFunction.withThis((thisArg, [o1 = X, o2 = X, o3 = X, o4 = X,
|
||||||
(thisArg, [o1=X, o2=X, o3=X, o4=X, o5=X, o6=X, o7=X, o8=X, o9=X, o10=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 __invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Object __varargSentinel = const Object();
|
const Object __varargSentinel = const Object();
|
||||||
|
|
||||||
|
|
||||||
__invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10) {
|
__invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10) {
|
||||||
var args = [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)) {
|
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));
|
return _jsify(Function.apply(fn, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Helper function to JSify a Dart object. While this is *required* to JSify
|
// 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
|
// 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
|
// work around http://dartbug.com/17752 in a convenient way (that bug affects
|
||||||
|
@ -44,8 +41,9 @@ _jsify(var obj) {
|
||||||
return _jsFunction(obj);
|
return _jsFunction(obj);
|
||||||
}
|
}
|
||||||
if ((obj is Map) || (obj is Iterable)) {
|
if ((obj is Map) || (obj is Iterable)) {
|
||||||
var mappedObj = (obj is Map) ?
|
var mappedObj = (obj is Map)
|
||||||
new Map.fromIterables(obj.keys, obj.values.map(_jsify)) : obj.map(_jsify);
|
? new Map.fromIterables(obj.keys, obj.values.map(_jsify))
|
||||||
|
: obj.map(_jsify);
|
||||||
if (obj is List) {
|
if (obj is List) {
|
||||||
return new js.JsArray.from(mappedObj);
|
return new js.JsArray.from(mappedObj);
|
||||||
} else {
|
} else {
|
||||||
|
@ -77,8 +75,7 @@ class PublicTestability implements _JsObjectProxyable {
|
||||||
return _jsify({
|
return _jsify({
|
||||||
'findBindings': (bindingString, [exactMatch, allowNonElementNodes]) =>
|
'findBindings': (bindingString, [exactMatch, allowNonElementNodes]) =>
|
||||||
findBindings(bindingString, exactMatch, allowNonElementNodes),
|
findBindings(bindingString, exactMatch, allowNonElementNodes),
|
||||||
'whenStable': (callback) =>
|
'whenStable': (callback) => whenStable(() => callback.apply([])),
|
||||||
whenStable(() => callback.apply([])),
|
|
||||||
})..['_dart_'] = this;
|
})..['_dart_'] = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,8 @@ class VmTurnZone {
|
||||||
* @param {Function} onScheduleMicrotask
|
* @param {Function} onScheduleMicrotask
|
||||||
* @param {Function} onErrorHandler called when an exception is thrown by a macro or micro task
|
* @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._onTurnStart = onTurnStart;
|
||||||
this._onTurnDone = onTurnDone;
|
this._onTurnDone = onTurnDone;
|
||||||
this._onScheduleMicrotask = onScheduleMicrotask;
|
this._onScheduleMicrotask = onScheduleMicrotask;
|
||||||
|
@ -111,17 +112,19 @@ class VmTurnZone {
|
||||||
}
|
}
|
||||||
|
|
||||||
async.Zone _createInnerZone(async.Zone zone) {
|
async.Zone _createInnerZone(async.Zone zone) {
|
||||||
return zone.fork(specification: new async.ZoneSpecification(
|
return zone.fork(
|
||||||
|
specification: new async.ZoneSpecification(
|
||||||
run: _onRun,
|
run: _onRun,
|
||||||
runUnary: _onRunUnary,
|
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++;
|
_nestedRunCounter++;
|
||||||
try {
|
try {
|
||||||
if (_nestedRunCounter == 1 && _onTurnStart != null) delegate.run(zone, _onTurnStart);
|
if (_nestedRunCounter == 1 && _onTurnStart != null) delegate.run(
|
||||||
|
zone, _onTurnStart);
|
||||||
return fn();
|
return fn();
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
if (_onErrorHandler != null && _nestedRunCounter == 1) {
|
if (_onErrorHandler != null && _nestedRunCounter == 1) {
|
||||||
|
@ -131,21 +134,24 @@ class VmTurnZone {
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
_nestedRunCounter--;
|
_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()) =>
|
dynamic _onRun(async.Zone self, async.ZoneDelegate delegate, async.Zone zone,
|
||||||
_onRunBase(self, delegate, zone, () => delegate.run(zone, fn));
|
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));
|
_onRunBase(self, delegate, zone, () => delegate.runUnary(zone, fn, args));
|
||||||
|
|
||||||
void _finishTurn(zone, delegate) {
|
void _finishTurn(zone, delegate) {
|
||||||
delegate.run(zone, _onTurnDone);
|
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) {
|
if (this._onScheduleMicrotask != null) {
|
||||||
_onScheduleMicrotask(fn);
|
_onScheduleMicrotask(fn);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -33,8 +33,10 @@ class PromiseWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ObservableWrapper {
|
class ObservableWrapper {
|
||||||
static StreamSubscription subscribe(Stream s, Function onNext, [onError, onComplete]) {
|
static StreamSubscription subscribe(Stream s, Function onNext,
|
||||||
return s.listen(onNext, onError: onError, onDone: onComplete, cancelOnError: true);
|
[onError, onComplete]) {
|
||||||
|
return s.listen(onNext,
|
||||||
|
onError: onError, onDone: onComplete, cancelOnError: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isObservable(obs) {
|
static bool isObservable(obs) {
|
||||||
|
@ -65,14 +67,10 @@ class EventEmitter extends Stream {
|
||||||
_controller = new StreamController.broadcast();
|
_controller = new StreamController.broadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamSubscription listen(void onData(String line), {
|
StreamSubscription listen(void onData(String line),
|
||||||
void onError(Error error),
|
{void onError(Error error), void onDone(), bool cancelOnError}) {
|
||||||
void onDone(),
|
|
||||||
bool cancelOnError }) {
|
|
||||||
return _controller.stream.listen(onData,
|
return _controller.stream.listen(onData,
|
||||||
onError: onError,
|
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
|
||||||
onDone: onDone,
|
|
||||||
cancelOnError: cancelOnError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(value) {
|
void add(value) {
|
||||||
|
@ -88,7 +86,6 @@ class EventEmitter extends Stream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _Completer {
|
class _Completer {
|
||||||
final Completer c;
|
final Completer c;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@ library angular2.src.facade.browser;
|
||||||
|
|
||||||
import 'dart:js' show context;
|
import 'dart:js' show context;
|
||||||
|
|
||||||
export 'dart:html' show
|
export 'dart:html'
|
||||||
|
show
|
||||||
document,
|
document,
|
||||||
location,
|
location,
|
||||||
window,
|
window,
|
||||||
|
|
|
@ -96,7 +96,8 @@ class ListWrapper {
|
||||||
static bool contains(List m, k) => m.contains(k);
|
static bool contains(List m, k) => m.contains(k);
|
||||||
static List map(list, fn(item)) => list.map(fn).toList();
|
static List map(list, fn(item)) => list.map(fn).toList();
|
||||||
static List filter(List list, bool fn(item)) => list.where(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]) =>
|
static int lastIndexOf(List list, value, [int startIndex = null]) =>
|
||||||
list.lastIndexOf(value, startIndex == null ? list.length : startIndex);
|
list.lastIndexOf(value, startIndex == null ? list.length : startIndex);
|
||||||
static find(List list, bool fn(item)) =>
|
static find(List list, bool fn(item)) =>
|
||||||
|
@ -115,7 +116,9 @@ class ListWrapper {
|
||||||
l.add(e);
|
l.add(e);
|
||||||
}
|
}
|
||||||
static List concat(List a, List b) {
|
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 bool isList(l) => l is List;
|
||||||
static void insert(List l, int index, value) {
|
static void insert(List l, int index, value) {
|
||||||
|
@ -154,7 +157,7 @@ class ListWrapper {
|
||||||
l.removeRange(from, to);
|
l.removeRange(from, to);
|
||||||
return sub;
|
return sub;
|
||||||
}
|
}
|
||||||
static void sort(List l, compareFn(a,b)) {
|
static void sort(List l, compareFn(a, b)) {
|
||||||
l.sort(compareFn);
|
l.sort(compareFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,8 @@ class RegExpWrapper {
|
||||||
static RegExp create(regExpStr, [String flags = '']) {
|
static RegExp create(regExpStr, [String flags = '']) {
|
||||||
bool multiLine = flags.contains('m');
|
bool multiLine = flags.contains('m');
|
||||||
bool caseSensitive = !flags.contains('i');
|
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) {
|
static Match firstMatch(RegExp regExp, String input) {
|
||||||
return regExp.firstMatch(input);
|
return regExp.firstMatch(input);
|
||||||
|
@ -147,7 +148,7 @@ class _JSLikeMatch {
|
||||||
|
|
||||||
_JSLikeMatch(this._m);
|
_JSLikeMatch(this._m);
|
||||||
|
|
||||||
String operator[](index) => _m[index];
|
String operator [](index) => _m[index];
|
||||||
int get index => _m.start;
|
int get index => _m.start;
|
||||||
int get length => _m.groupCount + 1;
|
int get length => _m.groupCount + 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,17 @@ class HammerGesturesPlugin extends HammerGesturesPluginCommon {
|
||||||
if (!super.supports(eventName)) return false;
|
if (!super.supports(eventName)) return false;
|
||||||
|
|
||||||
if (!js.context.hasProperty('Hammer')) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
addEventListener(Element element, String eventName, Function handler, bool shouldSupportBubble) {
|
addEventListener(Element element, String eventName, Function handler,
|
||||||
if (shouldSupportBubble) throw new BaseException('Hammer.js plugin does not support bubbling gestures.');
|
bool shouldSupportBubble) {
|
||||||
|
if (shouldSupportBubble) throw new BaseException(
|
||||||
|
'Hammer.js plugin does not support bubbling gestures.');
|
||||||
var zone = this.manager.getZone();
|
var zone = this.manager.getZone();
|
||||||
eventName = eventName.toLowerCase();
|
eventName = eventName.toLowerCase();
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ class XHRImpl extends XHR {
|
||||||
Future<String> get(String url) {
|
Future<String> get(String url) {
|
||||||
return HttpRequest.request(url).then(
|
return HttpRequest.request(url).then(
|
||||||
(HttpRequest request) => request.responseText,
|
(HttpRequest request) => request.responseText,
|
||||||
onError: (Error e) => throw 'Failed to load $url'
|
onError: (Error e) => throw 'Failed to load $url');
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
library test_lib.test_lib;
|
library test_lib.test_lib;
|
||||||
|
|
||||||
import 'package:guinness/guinness.dart' as gns;
|
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 'package:unittest/unittest.dart' hide expect;
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
@ -42,12 +43,9 @@ void testSetup() {
|
||||||
// - Priority 2: collect the bindings before each test, see beforeEachBindings(),
|
// - Priority 2: collect the bindings before each test, see beforeEachBindings(),
|
||||||
// - Priority 1: create the test injector to be used in beforeEach() and it()
|
// - Priority 1: create the test injector to be used in beforeEach() and it()
|
||||||
|
|
||||||
gns.beforeEach(
|
gns.beforeEach(() {
|
||||||
() {
|
|
||||||
_testBindings.clear();
|
_testBindings.clear();
|
||||||
},
|
}, priority: 3);
|
||||||
priority: 3
|
|
||||||
);
|
|
||||||
|
|
||||||
var completerBinding = bind(AsyncTestCompleter).toFactory(() {
|
var completerBinding = bind(AsyncTestCompleter).toFactory(() {
|
||||||
// Mark the test as async when an AsyncTestCompleter is injected in an it(),
|
// Mark the test as async when an AsyncTestCompleter is injected in an it(),
|
||||||
|
@ -56,14 +54,11 @@ void testSetup() {
|
||||||
return new AsyncTestCompleter();
|
return new AsyncTestCompleter();
|
||||||
});
|
});
|
||||||
|
|
||||||
gns.beforeEach(
|
gns.beforeEach(() {
|
||||||
() {
|
|
||||||
_isCurrentTestAsync = false;
|
_isCurrentTestAsync = false;
|
||||||
_testBindings.add(completerBinding);
|
_testBindings.add(completerBinding);
|
||||||
_injector = createTestInjector(_testBindings);
|
_injector = createTestInjector(_testBindings);
|
||||||
},
|
}, priority: 1);
|
||||||
priority: 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Expect expect(actual, [matcher]) {
|
Expect expect(actual, [matcher]) {
|
||||||
|
@ -80,13 +75,14 @@ class Expect extends gns.Expect {
|
||||||
NotExpect get not => new NotExpect(actual);
|
NotExpect get not => new NotExpect(actual);
|
||||||
|
|
||||||
void toEqual(expected) => toHaveSameProps(expected);
|
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 toBePromise() => _expect(actual is Future, equals(true));
|
||||||
void toImplement(expected) => toBeA(expected);
|
void toImplement(expected) => toBeA(expected);
|
||||||
void toBeNaN() => _expect(double.NAN.compareTo(actual) == 0, equals(true));
|
void toBeNaN() => _expect(double.NAN.compareTo(actual) == 0, equals(true));
|
||||||
void toHaveText(expected) => _expect(elementText(actual), expected);
|
void toHaveText(expected) => _expect(elementText(actual), expected);
|
||||||
void toHaveBeenCalledWith([a = _u, b = _u, c = _u, d = _u, e = _u, f = _u]) =>
|
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;
|
Function get _expect => gns.guinness.matchers.expect;
|
||||||
|
|
||||||
// TODO(tbosch): move this hack into Guinness
|
// TODO(tbosch): move this hack into Guinness
|
||||||
|
@ -97,7 +93,7 @@ class Expect extends gns.Expect {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
gns.SamePropsMatcher matcher = new gns.SamePropsMatcher(toMatch);
|
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];
|
var call = calls[i];
|
||||||
// TODO: create a better error message, not just 'Expected: <true> Actual: <false>'.
|
// TODO: create a better error message, not just 'Expected: <true> Actual: <false>'.
|
||||||
// For hacking this is good:
|
// For hacking this is good:
|
||||||
|
@ -141,13 +137,10 @@ void beforeEach(fn) {
|
||||||
* ]);
|
* ]);
|
||||||
*/
|
*/
|
||||||
void beforeEachBindings(Function fn) {
|
void beforeEachBindings(Function fn) {
|
||||||
gns.beforeEach(
|
gns.beforeEach(() {
|
||||||
() {
|
|
||||||
var bindings = fn();
|
var bindings = fn();
|
||||||
if (bindings != null) _testBindings.addAll(bindings);
|
if (bindings != null) _testBindings.addAll(bindings);
|
||||||
},
|
}, priority: 2);
|
||||||
priority: 2
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _it(gnsFn, name, fn) {
|
void _it(gnsFn, name, fn) {
|
||||||
|
@ -160,7 +153,6 @@ void _it(gnsFn, name, fn) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void it(name, fn) {
|
void it(name, fn) {
|
||||||
_it(gns.it, name, fn);
|
_it(gns.it, name, fn);
|
||||||
}
|
}
|
||||||
|
@ -174,7 +166,7 @@ void xit(name, fn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
class SpyFunction extends gns.SpyFunction {
|
class SpyFunction extends gns.SpyFunction {
|
||||||
SpyFunction(String name): super(name);
|
SpyFunction(String name) : super(name);
|
||||||
|
|
||||||
// TODO: vsavkin move to guinness
|
// TODO: vsavkin move to guinness
|
||||||
andReturn(value) {
|
andReturn(value) {
|
||||||
|
@ -185,7 +177,7 @@ class SpyFunction extends gns.SpyFunction {
|
||||||
class SpyObject extends gns.SpyObject {
|
class SpyObject extends gns.SpyObject {
|
||||||
final Map<String, SpyFunction> _spyFuncs = {};
|
final Map<String, SpyFunction> _spyFuncs = {};
|
||||||
|
|
||||||
SpyObject([arg]){}
|
SpyObject([arg]) {}
|
||||||
|
|
||||||
SpyFunction spy(String funcName) =>
|
SpyFunction spy(String funcName) =>
|
||||||
_spyFuncs.putIfAbsent(funcName, () => new SpyFunction(funcName));
|
_spyFuncs.putIfAbsent(funcName, () => new SpyFunction(funcName));
|
||||||
|
@ -198,15 +190,13 @@ class SpyObject extends gns.SpyObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
var m = StringMapWrapper.merge(config, overrides);
|
var m = StringMapWrapper.merge(config, overrides);
|
||||||
StringMapWrapper.forEach(m, (value, key){
|
StringMapWrapper.forEach(m, (value, key) {
|
||||||
object.spy(key).andReturn(value);
|
object.spy(key).andReturn(value);
|
||||||
});
|
});
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String elementText(n) {
|
String elementText(n) {
|
||||||
hasNodes(n) {
|
hasNodes(n) {
|
||||||
var children = DOM.childNodes(n);
|
var children = DOM.childNodes(n);
|
||||||
|
|
|
@ -3,4 +3,3 @@ import 'dart:html';
|
||||||
Rectangle createRectangle(left, top, width, height) {
|
Rectangle createRectangle(left, top, width, height) {
|
||||||
return new Rectangle(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';
|
import 'package:angular2/src/test_lib/benchmark_util.dart';
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
|
||||||
var count = getIntParameter('elements');
|
var count = getIntParameter('elements');
|
||||||
|
|
||||||
var m = new Module()
|
var m = new Module()
|
||||||
|
@ -36,13 +35,12 @@ main() {
|
||||||
|
|
||||||
bindAction('#compileWithBindings', compileWithBindings);
|
bindAction('#compileWithBindings', compileWithBindings);
|
||||||
bindAction('#compileNoBindings', compileNoBindings);
|
bindAction('#compileNoBindings', compileNoBindings);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadTemplate(templateId, repeatCount) {
|
loadTemplate(templateId, repeatCount) {
|
||||||
String result = '';
|
String result = '';
|
||||||
var content = document.querySelector("#${templateId}").innerHtml;
|
var content = document.querySelector("#${templateId}").innerHtml;
|
||||||
for (var i=0; i<repeatCount; i++) {
|
for (var i = 0; i < repeatCount; i++) {
|
||||||
result += content;
|
result += content;
|
||||||
}
|
}
|
||||||
return createTemplate(result.replaceAll(new RegExp(r'[\[\]]'), ''));
|
return createTemplate(result.replaceAll(new RegExp(r'[\[\]]'), ''));
|
||||||
|
@ -54,68 +52,39 @@ class IdentitySanitizer implements NodeTreeSanitizer {
|
||||||
|
|
||||||
createTemplate(String html) {
|
createTemplate(String html) {
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
div.setInnerHtml(html, treeSanitizer:new IdentitySanitizer());
|
div.setInnerHtml(html, treeSanitizer: new IdentitySanitizer());
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive(
|
@Directive(selector: '[dir0]', map: const {'attr0': '=>prop'})
|
||||||
selector: '[dir0]',
|
|
||||||
map: const {
|
|
||||||
'attr0': '=>prop'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
class Dir0 {
|
class Dir0 {
|
||||||
Object prop;
|
Object prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive(
|
@Directive(selector: '[dir1]', map: const {'attr1': '=>prop'})
|
||||||
selector: '[dir1]',
|
|
||||||
map: const {
|
|
||||||
'attr1': '=>prop'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
class Dir1 {
|
class Dir1 {
|
||||||
Object prop;
|
Object prop;
|
||||||
|
|
||||||
constructor(Dir0 dir0) {
|
constructor(Dir0 dir0) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive(
|
@Directive(selector: '[dir2]', map: const {'attr2': '=>prop'})
|
||||||
selector: '[dir2]',
|
|
||||||
map: const {
|
|
||||||
'attr2': '=>prop'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
class Dir2 {
|
class Dir2 {
|
||||||
Object prop;
|
Object prop;
|
||||||
|
|
||||||
constructor(Dir1 dir1) {
|
constructor(Dir1 dir1) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive(
|
@Directive(selector: '[dir3]', map: const {'attr3': '=>prop'})
|
||||||
selector: '[dir3]',
|
|
||||||
map: const {
|
|
||||||
'attr3': '=>prop'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
class Dir3 {
|
class Dir3 {
|
||||||
Object prop;
|
Object prop;
|
||||||
|
|
||||||
constructor(Dir2 dir2) {
|
constructor(Dir2 dir2) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive(
|
@Directive(selector: '[dir4]', map: const {'attr4': '=>prop'})
|
||||||
selector: '[dir4]',
|
|
||||||
map: const {
|
|
||||||
'attr4': '=>prop'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
class Dir4 {
|
class Dir4 {
|
||||||
Object prop;
|
Object prop;
|
||||||
|
|
||||||
constructor(Dir3 dir3) {
|
constructor(Dir3 dir3) {}
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -5,9 +5,7 @@ import 'dart:html';
|
||||||
import 'package:angular/angular.dart';
|
import 'package:angular/angular.dart';
|
||||||
import 'package:angular2/src/test_lib/benchmark_util.dart';
|
import 'package:angular2/src/test_lib/benchmark_util.dart';
|
||||||
|
|
||||||
@Component(
|
@Component(selector: 'scroll-app', template: '''
|
||||||
selector: 'scroll-app',
|
|
||||||
template: '''
|
|
||||||
<div>
|
<div>
|
||||||
<div style="display: flex">
|
<div style="display: flex">
|
||||||
<scroll-area scroll-top="scrollTop"></scroll-area>
|
<scroll-area scroll-top="scrollTop"></scroll-area>
|
||||||
|
|
|
@ -3,43 +3,25 @@ library cells;
|
||||||
import 'package:angular/angular.dart';
|
import 'package:angular/angular.dart';
|
||||||
import 'common.dart';
|
import 'common.dart';
|
||||||
|
|
||||||
@Component(
|
@Component(selector: 'company-name', template: '''
|
||||||
selector: 'company-name',
|
|
||||||
template: '''
|
|
||||||
<div style="width: {{width}}">{{company.name}}</div>
|
<div style="width: {{width}}">{{company.name}}</div>
|
||||||
''',
|
''', map: const {'company': '=>company', 'cell-width': '=>width',})
|
||||||
map: const {
|
|
||||||
'company': '=>company',
|
|
||||||
'cell-width': '=>width',
|
|
||||||
})
|
|
||||||
class CompanyNameComponent {
|
class CompanyNameComponent {
|
||||||
String width;
|
String width;
|
||||||
Company company;
|
Company company;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component(
|
@Component(selector: 'opportunity-name', template: '''
|
||||||
selector: 'opportunity-name',
|
|
||||||
template: '''
|
|
||||||
<div style="width: {{width}}">{{opportunity.name}}</div>
|
<div style="width: {{width}}">{{opportunity.name}}</div>
|
||||||
''',
|
''', map: const {'opportunity': '=>opportunity', 'cell-width': '=>width',})
|
||||||
map: const {
|
|
||||||
'opportunity': '=>opportunity',
|
|
||||||
'cell-width': '=>width',
|
|
||||||
})
|
|
||||||
class OpportunityNameComponent {
|
class OpportunityNameComponent {
|
||||||
String width;
|
String width;
|
||||||
Opportunity opportunity;
|
Opportunity opportunity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component(
|
@Component(selector: 'offering-name', template: '''
|
||||||
selector: 'offering-name',
|
|
||||||
template: '''
|
|
||||||
<div style="width: {{width}}">{{offering.name}}</div>
|
<div style="width: {{width}}">{{offering.name}}</div>
|
||||||
''',
|
''', map: const {'offering': '=>offering', 'cell-width': '=>width',})
|
||||||
map: const {
|
|
||||||
'offering': '=>offering',
|
|
||||||
'cell-width': '=>width',
|
|
||||||
})
|
|
||||||
class OfferingNameComponent {
|
class OfferingNameComponent {
|
||||||
String width;
|
String width;
|
||||||
Offering offering;
|
Offering offering;
|
||||||
|
@ -52,15 +34,11 @@ class Stage {
|
||||||
Function apply;
|
Function apply;
|
||||||
|
|
||||||
String get styleString => style != null
|
String get styleString => style != null
|
||||||
? style.keys
|
? style.keys.map((prop) => '$prop: ${style[prop]}').join(';')
|
||||||
.map((prop) => '$prop: ${style[prop]}')
|
|
||||||
.join(';')
|
|
||||||
: '';
|
: '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component(
|
@Component(selector: 'stage-buttons', template: '''
|
||||||
selector: 'stage-buttons',
|
|
||||||
template: '''
|
|
||||||
<div style="width: {{width}}">
|
<div style="width: {{width}}">
|
||||||
<button ng-repeat="stage in stages"
|
<button ng-repeat="stage in stages"
|
||||||
ng-disabled="stage.isDisabled"
|
ng-disabled="stage.isDisabled"
|
||||||
|
@ -69,11 +47,7 @@ class Stage {
|
||||||
{{stage.name}}
|
{{stage.name}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
''',
|
''', map: const {'offering': '=>offering', 'cell-width': '=>width',})
|
||||||
map: const {
|
|
||||||
'offering': '=>offering',
|
|
||||||
'cell-width': '=>width',
|
|
||||||
})
|
|
||||||
class StageButtonsComponent {
|
class StageButtonsComponent {
|
||||||
Offering _offering;
|
Offering _offering;
|
||||||
List<Stage> stages;
|
List<Stage> stages;
|
||||||
|
@ -92,42 +66,30 @@ class StageButtonsComponent {
|
||||||
|
|
||||||
_computeStageButtons() {
|
_computeStageButtons() {
|
||||||
bool disabled = true;
|
bool disabled = true;
|
||||||
stages = STATUS_LIST
|
stages = STATUS_LIST.map((String status) {
|
||||||
.map((String status) {
|
|
||||||
bool isCurrent = offering.status == status;
|
bool isCurrent = offering.status == status;
|
||||||
var stage = new Stage();
|
var stage = new Stage();
|
||||||
stage
|
stage
|
||||||
..name = status
|
..name = status
|
||||||
..isDisabled = disabled
|
..isDisabled = disabled
|
||||||
..style = {
|
..style = {
|
||||||
'background-color': disabled
|
'background-color': disabled ? '#DDD' : isCurrent ? '#DDF' : '#FDD'
|
||||||
? '#DDD'
|
|
||||||
: isCurrent
|
|
||||||
? '#DDF'
|
|
||||||
: '#FDD'
|
|
||||||
};
|
};
|
||||||
if (isCurrent) {
|
if (isCurrent) {
|
||||||
disabled = false;
|
disabled = false;
|
||||||
}
|
}
|
||||||
return stage;
|
return stage;
|
||||||
})
|
}).toList();
|
||||||
.toList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component(
|
@Component(selector: 'account-cell', template: '''
|
||||||
selector: 'account-cell',
|
|
||||||
template: '''
|
|
||||||
<div style="width: {{width}}">
|
<div style="width: {{width}}">
|
||||||
<a href="/account/{{account.accountId}}">
|
<a href="/account/{{account.accountId}}">
|
||||||
{{account.accountId}}
|
{{account.accountId}}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
''',
|
''', map: const {'account': '=>account', 'cell-width': '=>width',})
|
||||||
map: const {
|
|
||||||
'account': '=>account',
|
|
||||||
'cell-width': '=>width',
|
|
||||||
})
|
|
||||||
class AccountCellComponent {
|
class AccountCellComponent {
|
||||||
Account account;
|
Account account;
|
||||||
String width;
|
String width;
|
||||||
|
@ -136,10 +98,7 @@ class AccountCellComponent {
|
||||||
@Component(
|
@Component(
|
||||||
selector: 'formatted-cell',
|
selector: 'formatted-cell',
|
||||||
template: '''<div style="width: {{width}}">{{formattedValue}}</div>''',
|
template: '''<div style="width: {{width}}">{{formattedValue}}</div>''',
|
||||||
map: const {
|
map: const {'value': '=>value', 'cell-width': '=>width',})
|
||||||
'value': '=>value',
|
|
||||||
'cell-width': '=>width',
|
|
||||||
})
|
|
||||||
class FormattedCellComponent {
|
class FormattedCellComponent {
|
||||||
String formattedValue;
|
String formattedValue;
|
||||||
String width;
|
String width;
|
||||||
|
|
|
@ -34,21 +34,14 @@ const ROW_WIDTH = COMPANY_NAME_WIDTH +
|
||||||
END_DATE_WIDTH +
|
END_DATE_WIDTH +
|
||||||
AAT_STATUS_WIDTH;
|
AAT_STATUS_WIDTH;
|
||||||
|
|
||||||
const STATUS_LIST = const [
|
const STATUS_LIST = const ['Planned', 'Pitched', 'Won', 'Lost'];
|
||||||
'Planned', 'Pitched', 'Won', 'Lost'
|
|
||||||
];
|
|
||||||
|
|
||||||
const AAT_STATUS_LIST = const [
|
const AAT_STATUS_LIST = const ['Active', 'Passive', 'Abandoned'];
|
||||||
'Active', 'Passive', 'Abandoned'
|
|
||||||
];
|
|
||||||
|
|
||||||
// Imitate Streamy entities.
|
// Imitate Streamy entities.
|
||||||
|
|
||||||
class RawEntity
|
class RawEntity extends Object with MapMixin<String, dynamic>
|
||||||
extends Object
|
implements ObservableMap<String, dynamic> {
|
||||||
with MapMixin<String, dynamic>
|
|
||||||
implements ObservableMap<String, dynamic> {
|
|
||||||
|
|
||||||
ObservableMap _data = new ObservableMap();
|
ObservableMap _data = new ObservableMap();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -60,7 +53,7 @@ implements ObservableMap<String, dynamic> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
operator[](String key) {
|
operator [](String key) {
|
||||||
if (!key.contains('.')) {
|
if (!key.contains('.')) {
|
||||||
return _data[key];
|
return _data[key];
|
||||||
}
|
}
|
||||||
|
@ -74,7 +67,7 @@ implements ObservableMap<String, dynamic> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
operator[]=(String key, value) {
|
operator []=(String key, value) {
|
||||||
if (!key.contains('.')) {
|
if (!key.contains('.')) {
|
||||||
_data[key] = value;
|
_data[key] = value;
|
||||||
return;
|
return;
|
||||||
|
@ -199,7 +192,6 @@ class Opportunity extends RawEntity {
|
||||||
set name(String val) {
|
set name(String val) {
|
||||||
this['name'] = val;
|
this['name'] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Account extends RawEntity {
|
class Account extends RawEntity {
|
||||||
|
|
|
@ -9,7 +9,8 @@ import 'cells.dart';
|
||||||
|
|
||||||
class MyAppModule extends Module {
|
class MyAppModule extends Module {
|
||||||
MyAppModule() {
|
MyAppModule() {
|
||||||
bind(ResourceResolverConfig, toValue: new ResourceResolverConfig.resolveRelativeUrls(false));
|
bind(ResourceResolverConfig,
|
||||||
|
toValue: new ResourceResolverConfig.resolveRelativeUrls(false));
|
||||||
bind(App);
|
bind(App);
|
||||||
bind(ScrollAreaComponent);
|
bind(ScrollAreaComponent);
|
||||||
bind(ScrollItemComponent);
|
bind(ScrollItemComponent);
|
||||||
|
@ -23,7 +24,5 @@ class MyAppModule extends Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
applicationFactory()
|
applicationFactory().addModule(new MyAppModule()).run();
|
||||||
.addModule(new MyAppModule())
|
|
||||||
.run();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,24 +22,32 @@ Offering generateOffering(int seed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Company generateCompany(int seed) {
|
Company generateCompany(int seed) {
|
||||||
return new Company()
|
return new Company()..name = generateName(seed);
|
||||||
..name = generateName(seed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Opportunity generateOpportunity(int seed) {
|
Opportunity generateOpportunity(int seed) {
|
||||||
return new Opportunity()
|
return new Opportunity()..name = generateName(seed);
|
||||||
..name = generateName(seed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Account generateAccount(int seed) {
|
Account generateAccount(int seed) {
|
||||||
return new Account()
|
return new Account()..accountId = seed;
|
||||||
..accountId = seed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String generateName(int seed) {
|
String generateName(int seed) {
|
||||||
const names = const [
|
const names = const [
|
||||||
'Foo', 'Bar', 'Baz', 'Qux', 'Quux', 'Garply', 'Waldo', 'Fred', 'Plugh',
|
'Foo',
|
||||||
'Xyzzy', 'Thud', 'Cruft', 'Stuff'
|
'Bar',
|
||||||
|
'Baz',
|
||||||
|
'Qux',
|
||||||
|
'Quux',
|
||||||
|
'Garply',
|
||||||
|
'Waldo',
|
||||||
|
'Fred',
|
||||||
|
'Plugh',
|
||||||
|
'Xyzzy',
|
||||||
|
'Thud',
|
||||||
|
'Cruft',
|
||||||
|
'Stuff'
|
||||||
];
|
];
|
||||||
return names[seed % names.length];
|
return names[seed % names.length];
|
||||||
}
|
}
|
||||||
|
@ -49,13 +57,17 @@ DateTime randomDate(int seed, {DateTime minDate}) {
|
||||||
minDate = new DateTime.now();
|
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]));
|
return minDate.add(new Duration(days: offsets[seed % offsets.length]));
|
||||||
}
|
}
|
||||||
|
|
||||||
String randomString(int seed) {
|
String randomString(int seed) {
|
||||||
return new String.fromCharCodes(new List.generate(
|
return new String.fromCharCodes(new List.generate(const [
|
||||||
const[5, 7, 9, 11, 13][seed % 5],
|
5,
|
||||||
(i) => 'a'.codeUnitAt(0) + const[0, 1, 2, 3, 4, 5, 6, 7, 8][seed % 9] + i
|
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(
|
@Component(
|
||||||
selector: 'scroll-area',
|
selector: 'scroll-area',
|
||||||
templateUrl: 'scroll_area.html',
|
templateUrl: 'scroll_area.html',
|
||||||
map: const {
|
map: const {'scroll-top': '=>scrollTop',})
|
||||||
'scroll-top': '=>scrollTop',
|
|
||||||
})
|
|
||||||
class ScrollAreaComponent implements ShadowRootAware {
|
class ScrollAreaComponent implements ShadowRootAware {
|
||||||
Element scrollDiv;
|
Element scrollDiv;
|
||||||
List<Offering> _fullList;
|
List<Offering> _fullList;
|
||||||
|
@ -52,7 +50,8 @@ class ScrollAreaComponent implements ShadowRootAware {
|
||||||
int padding = iStart * ITEM_HEIGHT;
|
int padding = iStart * ITEM_HEIGHT;
|
||||||
innerStyle['height'] = '${HEIGHT - padding}px';
|
innerStyle['height'] = '${HEIGHT - padding}px';
|
||||||
paddingStyle['height'] = '${padding}px';
|
paddingStyle['height'] = '${padding}px';
|
||||||
visibleItems..clear()..addAll(_fullList.getRange(iStart, iEnd));
|
visibleItems
|
||||||
|
..clear()
|
||||||
|
..addAll(_fullList.getRange(iStart, iEnd));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,8 @@ import 'common.dart';
|
||||||
@Component(
|
@Component(
|
||||||
selector: 'scroll-item',
|
selector: 'scroll-item',
|
||||||
templateUrl: 'scroll_item.html',
|
templateUrl: 'scroll_item.html',
|
||||||
map: const {
|
map: const {'offering': '=>offering',})
|
||||||
'offering': '=>offering',
|
|
||||||
})
|
|
||||||
class ScrollItemComponent implements ShadowRootAware {
|
class ScrollItemComponent implements ShadowRootAware {
|
||||||
|
|
||||||
Offering offering;
|
Offering offering;
|
||||||
|
|
||||||
// Init empty maps and populate later. There seems to be a bug in Angular
|
// Init empty maps and populate later. There seems to be a bug in Angular
|
||||||
|
|
|
@ -6,10 +6,11 @@ import 'package:angular/application_factory.dart';
|
||||||
import 'package:angular2/src/test_lib/benchmark_util.dart';
|
import 'package:angular2/src/test_lib/benchmark_util.dart';
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
|
||||||
var m = new Module()
|
var m = new Module()
|
||||||
..bind(CompilerConfig, toValue: new CompilerConfig.withOptions(elementProbeEnabled: false))
|
..bind(CompilerConfig,
|
||||||
..bind(ScopeDigestTTL, toFactory: () => new ScopeDigestTTL.value(15), inject: [])
|
toValue: new CompilerConfig.withOptions(elementProbeEnabled: false))
|
||||||
|
..bind(ScopeDigestTTL,
|
||||||
|
toFactory: () => new ScopeDigestTTL.value(15), inject: [])
|
||||||
..bind(TreeComponent);
|
..bind(TreeComponent);
|
||||||
|
|
||||||
final injector = applicationFactory().addModule(m).run();
|
final injector = applicationFactory().addModule(m).run();
|
||||||
|
@ -33,9 +34,9 @@ main() {
|
||||||
|
|
||||||
createDom() {
|
createDom() {
|
||||||
zone.run(() {
|
zone.run(() {
|
||||||
var values = count++ % 2 == 0 ?
|
var values = count++ % 2 == 0
|
||||||
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'] :
|
? ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*']
|
||||||
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
|
: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
|
||||||
|
|
||||||
rootScope.context['initData'] = buildTree(maxDepth, values, 0);
|
rootScope.context['initData'] = buildTree(maxDepth, values, 0);
|
||||||
});
|
});
|
||||||
|
@ -51,18 +52,16 @@ main() {
|
||||||
template: '<span> {{data.value}}'
|
template: '<span> {{data.value}}'
|
||||||
'<span ng-if="data.right != null"><tree data=data.right></span>'
|
'<span ng-if="data.right != null"><tree data=data.right></span>'
|
||||||
'<span ng-if="data.left != null"><tree data=data.left></span>'
|
'<span ng-if="data.left != null"><tree data=data.left></span>'
|
||||||
'</span>'
|
'</span>')
|
||||||
)
|
|
||||||
class TreeComponent {
|
class TreeComponent {
|
||||||
var data;
|
var data;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTree(maxDepth, values, curDepth) {
|
buildTree(maxDepth, values, curDepth) {
|
||||||
if (maxDepth == curDepth) return new TreeNode('');
|
if (maxDepth == curDepth) return new TreeNode('');
|
||||||
return new TreeNode(
|
return new TreeNode(values[curDepth],
|
||||||
values[curDepth],
|
buildTree(maxDepth, values, curDepth + 1),
|
||||||
buildTree(maxDepth, values, curDepth+1),
|
buildTree(maxDepth, values, curDepth + 1));
|
||||||
buildTree(maxDepth, values, curDepth+1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class TreeNode {
|
class TreeNode {
|
||||||
|
@ -71,4 +70,3 @@ class TreeNode {
|
||||||
TreeNode right;
|
TreeNode right;
|
||||||
TreeNode([this.value, this.left, this.right]);
|
TreeNode([this.value, this.left, this.right]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
export './common.dart';
|
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) {
|
Future executeScript(String script) {
|
||||||
return _driver.execute(script, const[]);
|
return _driver.execute(script, const []);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map> capabilities() {
|
Future<Map> capabilities() {
|
||||||
|
@ -21,10 +21,9 @@ class AsyncWebDriverAdapter extends WebDriverAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Map>> logs(String type) {
|
Future<List<Map>> logs(String type) {
|
||||||
return _driver.logs.get(type)
|
return _driver.logs
|
||||||
.map((LogEntry entry) => {
|
.get(type)
|
||||||
'message': entry.message
|
.map((LogEntry entry) => {'message': entry.message})
|
||||||
})
|
|
||||||
.fold(<Map>[], (log, Map entry) {
|
.fold(<Map>[], (log, Map entry) {
|
||||||
return log..add(entry);
|
return log..add(entry);
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,8 @@ import 'dart:async';
|
||||||
import 'dart:io' show Platform;
|
import 'dart:io' show Platform;
|
||||||
import 'package:guinness/guinness.dart';
|
import 'package:guinness/guinness.dart';
|
||||||
import 'package:benchpress/benchpress.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() {
|
main() {
|
||||||
describe('benchpress', () {
|
describe('benchpress', () {
|
||||||
|
@ -11,10 +12,12 @@ main() {
|
||||||
|
|
||||||
beforeEach(() async {
|
beforeEach(() async {
|
||||||
driver = await createTestDriver();
|
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 = [
|
var bindings = [
|
||||||
bind(WebDriverAdapter).toFactory(() => new AsyncWebDriverAdapter(driver), [])
|
bind(WebDriverAdapter).toFactory(
|
||||||
|
() => new AsyncWebDriverAdapter(driver), [])
|
||||||
];
|
];
|
||||||
runner = new Runner(bindings);
|
runner = new Runner(bindings);
|
||||||
});
|
});
|
||||||
|
@ -24,34 +27,30 @@ main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work', () {
|
it('should work', () {
|
||||||
return runner.sample(
|
return runner.sample(id: 'benchpress smoke test', execute: () async {
|
||||||
id: 'benchpress smoke test',
|
|
||||||
execute: () async {
|
|
||||||
var button = await driver.findElement(const By.tagName('button'));
|
var button = await driver.findElement(const By.tagName('button'));
|
||||||
await button.click();
|
await button.click();
|
||||||
var logText = await (await driver.findElement(const By.id('log'))).text;
|
var logText = await (await driver.findElement(const By.id('log'))).text;
|
||||||
expect(logText, 'hi');
|
expect(logText, 'hi');
|
||||||
}
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<WebDriver> createTestDriver() {
|
Future<WebDriver> createTestDriver() {
|
||||||
Map env = Platform.environment;
|
Map env = Platform.environment;
|
||||||
return WebDriver.createDriver(desiredCapabilities: {
|
return WebDriver.createDriver(
|
||||||
|
desiredCapabilities: {
|
||||||
'name': 'Dartium',
|
'name': 'Dartium',
|
||||||
'browserName': 'chrome',
|
'browserName': 'chrome',
|
||||||
'chromeOptions': {
|
'chromeOptions': {
|
||||||
'binary': env['DARTIUM_BIN'],
|
'binary': env['DARTIUM_BIN'],
|
||||||
'args': ['--js-flags=--expose-gc'],
|
'args': ['--js-flags=--expose-gc'],
|
||||||
'perfLoggingPrefs': {
|
'perfLoggingPrefs': {
|
||||||
'traceCategories': 'v8,blink.console,disabled-by-default-devtools.timeline'
|
'traceCategories':
|
||||||
|
'v8,blink.console,disabled-by-default-devtools.timeline'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'loggingPrefs': {
|
'loggingPrefs': {'performance': 'ALL', 'browser': 'ALL',}
|
||||||
'performance': 'ALL',
|
|
||||||
'browser': 'ALL',
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue