mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:37:12 +00:00
Better way of fixing attribute_changed_callback_test, doesn't require a timer
BUG= Review URL: https://codereview.chromium.org//1061403002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44946 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
8c4caa642b
commit
4b119a94d8
|
@ -32,8 +32,14 @@ class B extends HtmlElement {
|
||||||
|
|
||||||
static var invocations = [];
|
static var invocations = [];
|
||||||
|
|
||||||
|
Completer completer;
|
||||||
|
|
||||||
void attributeChanged(name, oldValue, newValue) {
|
void attributeChanged(name, oldValue, newValue) {
|
||||||
invocations.add('$name: $oldValue => $newValue');
|
invocations.add('$name: $oldValue => $newValue');
|
||||||
|
if (completer != null) {
|
||||||
|
completer.complete('value changed to $newValue');
|
||||||
|
completer = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,16 +96,19 @@ main() {
|
||||||
B.invocations = [];
|
B.invocations = [];
|
||||||
|
|
||||||
var b = new B();
|
var b = new B();
|
||||||
|
var completer = new Completer();
|
||||||
|
b.completer = completer;
|
||||||
b.id = 'x';
|
b.id = 'x';
|
||||||
|
return completer.future
|
||||||
return new Future.delayed(new Duration(milliseconds: 1))
|
|
||||||
.then((_) => expect(B.invocations, ['created', 'id: null => x']))
|
.then((_) => expect(B.invocations, ['created', 'id: null => x']))
|
||||||
.then((_) {
|
.then((_) {
|
||||||
B.invocations = [];
|
B.invocations = [];
|
||||||
b.attributes.remove('id');
|
var secondCompleter = new Completer();
|
||||||
})
|
b.completer = secondCompleter;
|
||||||
.then((_) => new Future.delayed(new Duration(milliseconds: 1)))
|
b.attributes.remove('id');
|
||||||
.then((_) => expect(B.invocations, ['id: x => null']));
|
return secondCompleter.future;
|
||||||
|
})
|
||||||
|
.then((_) => expect(B.invocations, ['id: x => null']));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue