3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
8 * Tests Ext.data.Store functionality
12 var suite = Ext.test.session.getSuite('Ext.Slider'),
15 suite.add(new Y.Test.Case({
16 name: 'constructor and initComponent',
19 this.slider = new Ext.Slider();
22 testDefaultValues: function() {
23 assert.areEqual(0, this.slider.minValue);
24 assert.areEqual(0, this.slider.value);
25 assert.areEqual(100, this.slider.maxValue);
28 testDefaultValueSet: function() {
29 var slider = new Ext.Slider({minValue: 50});
31 assert.areEqual(50, slider.value);
35 suite.add(new Y.Test.Case({
36 name: 'Changing value',
39 this.slider = new Ext.Slider({
43 renderTo: Ext.getBody()
49 tearDown: function() {
50 this.slider.destroy();
53 testValueChanged: function() {
54 this.slider.setValue(0, 60);
56 assert.areEqual(60, this.slider.getValues()[0]);
59 testEventFired: function() {
63 this.slider.on('change', function(slider, v, t) {
69 this.slider.setValue(0, 60);
71 assert.isTrue(executed);
72 assert.areEqual(60, value);
73 assert.areEqual(this.slider.thumbs[0], thumb);
76 testThumbMoved: function() {
77 var orig = this.slider.moveThumb,
80 this.slider.moveThumb = function(i, v, a) {
85 this.slider.setValue(0, 60, false);
87 assert.areEqual(0, index);
88 assert.isFalse(animate);
91 testChangeComplete: function() {
95 this.slider.on('changecomplete', function(slider, v, t) {
101 this.slider.setValue(0, 60, undefined, true);
103 assert.isTrue(executed);
104 assert.areEqual(60, value);
105 assert.areEqual(this.slider.thumbs[0], thumb);
108 testSetMinValue: function() {
109 this.slider.setMinValue(20);
111 assert.areEqual(20, this.slider.minValue);
112 assert.areEqual(50, this.slider.getValues()[0]);
115 testSetMaxValue: function() {
116 this.slider.setMaxValue(110);
118 assert.areEqual(110, this.slider.maxValue);
119 assert.areEqual(50, this.slider.getValues()[0]);
122 testSetMinValueChangesValue: function() {
123 this.slider.setMinValue(60);
125 assert.areEqual(60, this.slider.getValues()[0]);
126 assert.areEqual(70, this.slider.getValues()[1]);
129 testSetMaxValueChangesValue: function() {
130 this.slider.setMaxValue(60);
132 assert.areEqual(50, this.slider.getValues()[0]);
133 assert.areEqual(60, this.slider.getValues()[1]);
137 suite.add(new Y.Test.Case({
138 name: 'Utility functions',
141 this.slider = new Ext.Slider({
142 //the slider has 14px of total padding on the sides, so add this here to make the numbers easier
146 renderTo: Ext.getBody()
149 this.slider.render();
152 tearDown: function() {
153 this.slider.destroy();
156 testGetRatio: function() {
157 assert.areEqual(0.5, this.slider.getRatio());
160 testTranslateValue: function() {
164 testReverseValue: function() {
168 testNormalizeValue: function() {
173 suite.add(new Y.Test.Case({
177 this.slider = new Ext.Slider({
179 renderTo : Ext.getBody()
182 this.slider.render();
185 tearDown: function() {
186 this.slider.destroy();
189 testSnapToFloor: function() {
190 this.slider.setValue(0, 12);
192 assert.areEqual(10, this.slider.doSnap(12));
195 testSnapToCeil: function() {
196 assert.areEqual(20, this.slider.doSnap(18));
197 assert.areEqual(20, this.slider.doSnap(15));
201 suite.add(new Y.Test.Case({
202 name: 'Adding and removing thumbs'