1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 base.require('base.properties');
10 base.unittest.testSuite('base.properties', function() {
11 test('defineProperties', function() {
12 var stateChanges = [];
14 var ASpan = ui.define('span');
16 __proto__: HTMLSpanElement.prototype,
20 decorate: function() {
22 this.addEventListener('propChange', function(event) {
23 stateChanges.push('Internal ' + event.oldValue +
24 ' to ' + event.newValue);
33 base.setPropertyAndDispatchChange(this, 'prop', newValue);
37 var aSpan = new ASpan();
39 aSpan.addEventListener('propChange', function(event) {
40 stateChanges.push(event.oldValue + ' to ' + event.newValue);
43 assertFalse(aSpan.prop);
46 assertTrue(aSpan.prop);
47 assertTrue(stateChanges.length === 2);
48 assertTrue(stateChanges[0] === 'Internal false to true');
49 assertTrue(stateChanges[1] === 'false to true');
52 assertFalse(aSpan.prop);
53 assertTrue(stateChanges[3] === 'true to false');