| OLD | NEW |
| (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 } | |
| OLD | NEW |