Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: samples/tests/samples/src/lib/observable/ObservableValueTests.dart

Issue 10253022: test rename overhaul: step 13 - samples (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 testObservableValue() {
6 test('ObservableValue', () {
7 final value = new ObservableValue<String>('initial');
8 expect(value.value).equals('initial');
9
10 // Set value.
11 value.value = 'new';
12 expect(value.value).equals('new');
13
14 // Change event is sent when value is changed.
15 EventSummary result = null;
16 value.addChangeListener((summary) {
17 expect(result).isNull();
18 result = summary;
19 expect(result).isNotNull();
20 });
21
22 value.value = 'newer';
23
24 expect(result).isNotNull();
25 expect(result.events.length).equals(1);
26 validateUpdate(result.events[0], value, 'value', null, 'newer', 'new');
27 });
28
29 test('does not raise event if unchanged', () {
30 final value = new ObservableValue<String>('foo');
31 expect(value.value).equals('foo');
32
33 bool called = false;
34 value.addChangeListener((summary) { called = true; });
35
36 // Set it to the same value.
37 value.value = 'foo';
38
39 // Should not have gotten an event.
40 expect(called).equals(false);
41 });
42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698