Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
5.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. /**
  8. * Tests Ext.data.Store functionality
  9. * @author Ed Spencer
  10. */
  11. (function() {
  12. var suite = Ext.test.session.getSuite('Ext.Slider'),
  13. assert = Y.Assert;
  14. suite.add(new Y.Test.Case({
  15. name: 'constructor and initComponent',
  16. setUp: function() {
  17. this.slider = new Ext.Slider();
  18. },
  19. testDefaultValues: function() {
  20. assert.areEqual(0, this.slider.minValue);
  21. assert.areEqual(0, this.slider.value);
  22. assert.areEqual(100, this.slider.maxValue);
  23. },
  24. testDefaultValueSet: function() {
  25. var slider = new Ext.Slider({minValue: 50});
  26. assert.areEqual(50, slider.value);
  27. }
  28. }));
  29. suite.add(new Y.Test.Case({
  30. name: 'Changing value',
  31. setUp: function() {
  32. this.slider = new Ext.Slider({
  33. minValue: 30,
  34. values : [50, 70],
  35. maxValue: 90,
  36. renderTo: Ext.getBody()
  37. });
  38. this.slider.render();
  39. },
  40. tearDown: function() {
  41. this.slider.destroy();
  42. },
  43. testValueChanged: function() {
  44. this.slider.setValue(0, 60);
  45. assert.areEqual(60, this.slider.getValues()[0]);
  46. },
  47. testEventFired: function() {
  48. var executed = false,
  49. value, thumb;
  50. this.slider.on('change', function(slider, v, t) {
  51. executed = true;
  52. value = v;
  53. thumb = t;
  54. }, this);
  55. this.slider.setValue(0, 60);
  56. assert.isTrue(executed);
  57. assert.areEqual(60, value);
  58. assert.areEqual(this.slider.thumbs[0], thumb);
  59. },
  60. testThumbMoved: function() {
  61. var orig = this.slider.moveThumb,
  62. index, animate;
  63. this.slider.moveThumb = function(i, v, a) {
  64. index = i;
  65. animate = a;
  66. };
  67. this.slider.setValue(0, 60, false);
  68. assert.areEqual(0, index);
  69. assert.isFalse(animate);
  70. },
  71. testChangeComplete: function() {
  72. var executed = false,
  73. value, thumb;
  74. this.slider.on('changecomplete', function(slider, v, t) {
  75. executed = true;
  76. value = v;
  77. thumb = t;
  78. }, this);
  79. this.slider.setValue(0, 60, undefined, true);
  80. assert.isTrue(executed);
  81. assert.areEqual(60, value);
  82. assert.areEqual(this.slider.thumbs[0], thumb);
  83. },
  84. testSetMinValue: function() {
  85. this.slider.setMinValue(20);
  86. assert.areEqual(20, this.slider.minValue);
  87. assert.areEqual(50, this.slider.getValues()[0]);
  88. },
  89. testSetMaxValue: function() {
  90. this.slider.setMaxValue(110);
  91. assert.areEqual(110, this.slider.maxValue);
  92. assert.areEqual(50, this.slider.getValues()[0]);
  93. },
  94. testSetMinValueChangesValue: function() {
  95. this.slider.setMinValue(60);
  96. assert.areEqual(60, this.slider.getValues()[0]);
  97. assert.areEqual(70, this.slider.getValues()[1]);
  98. },
  99. testSetMaxValueChangesValue: function() {
  100. this.slider.setMaxValue(60);
  101. assert.areEqual(50, this.slider.getValues()[0]);
  102. assert.areEqual(60, this.slider.getValues()[1]);
  103. }
  104. }));
  105. suite.add(new Y.Test.Case({
  106. name: 'Utility functions',
  107. setUp: function() {
  108. this.slider = new Ext.Slider({
  109. //the slider has 14px of total padding on the sides, so add this here to make the numbers easier
  110. width : 214,
  111. minValue: 100,
  112. maxValue: 500,
  113. renderTo: Ext.getBody()
  114. });
  115. this.slider.render();
  116. },
  117. tearDown: function() {
  118. this.slider.destroy();
  119. },
  120. testGetRatio: function() {
  121. assert.areEqual(0.5, this.slider.getRatio());
  122. },
  123. testTranslateValue: function() {
  124. },
  125. testReverseValue: function() {
  126. },
  127. testNormalizeValue: function() {
  128. }
  129. }));
  130. suite.add(new Y.Test.Case({
  131. name: 'Snapping',
  132. setUp: function() {
  133. this.slider = new Ext.Slider({
  134. increment: 10,
  135. renderTo : Ext.getBody()
  136. });
  137. this.slider.render();
  138. },
  139. tearDown: function() {
  140. this.slider.destroy();
  141. },
  142. testSnapToFloor: function() {
  143. this.slider.setValue(0, 12);
  144. assert.areEqual(10, this.slider.doSnap(12));
  145. },
  146. testSnapToCeil: function() {
  147. assert.areEqual(20, this.slider.doSnap(18));
  148. assert.areEqual(20, this.slider.doSnap(15));
  149. }
  150. }));
  151. suite.add(new Y.Test.Case({
  152. name: 'Adding and removing thumbs'
  153. }));
  154. })();