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.

173 lines
4.9 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. /**
  16. * Tests Ext.data.Store functionality
  17. * @author Ed Spencer
  18. */
  19. (function() {
  20. var suite = Ext.test.session.getSuite('Ext.layout.ContainerLayout'),
  21. assert = Y.Assert;
  22. function buildLayout(config) {
  23. var layout = new Ext.layout.FormLayout(config || {});
  24. //give a mock container
  25. layout.container = {
  26. itemCls: 'ctCls'
  27. };
  28. return layout;
  29. };
  30. suite.add(new Y.Test.Case({
  31. name: 'parseMargins',
  32. setUp: function() {
  33. this.cont = new Ext.layout.ContainerLayout();
  34. },
  35. testParseFromNumber: function() {
  36. var res = this.cont.parseMargins(10);
  37. assert.areEqual(10, res.top);
  38. assert.areEqual(10, res.right);
  39. assert.areEqual(10, res.bottom);
  40. assert.areEqual(10, res.left);
  41. },
  42. testParseFromString: function() {
  43. var res = this.cont.parseMargins("10");
  44. assert.areEqual(10, res.top);
  45. assert.areEqual(10, res.right);
  46. assert.areEqual(10, res.bottom);
  47. assert.areEqual(10, res.left);
  48. },
  49. testParseFromTwoArgString: function() {
  50. var res = this.cont.parseMargins("10 5");
  51. assert.areEqual(10, res.top);
  52. assert.areEqual(5, res.right);
  53. assert.areEqual(10, res.bottom);
  54. assert.areEqual(5, res.left);
  55. },
  56. testParseFromThreeArgString: function() {
  57. var res = this.cont.parseMargins("10 5 2");
  58. assert.areEqual(10, res.top);
  59. assert.areEqual(5, res.right);
  60. assert.areEqual(2, res.bottom);
  61. assert.areEqual(5, res.left);
  62. },
  63. testParseFromFourArgString: function() {
  64. var res = this.cont.parseMargins("10 5 2 1");
  65. assert.areEqual(10, res.top);
  66. assert.areEqual(5, res.right);
  67. assert.areEqual(2, res.bottom);
  68. assert.areEqual(1, res.left);
  69. }
  70. }));
  71. suite.add(new Y.Test.Case({
  72. name: 'configureItem',
  73. setUp: function() {
  74. this.layout = new Ext.layout.ContainerLayout({
  75. extraCls: 'myExtraClass'
  76. });
  77. //mock component object
  78. this.component = {
  79. addClass: Ext.emptyFn,
  80. doLayout: Ext.emptyFn
  81. };
  82. },
  83. testAddsExtraCls: function() {
  84. var layout = this.layout;
  85. var addedClass = "";
  86. //mock component object
  87. c = {
  88. addClass: function(cls) {
  89. addedClass = cls;
  90. }
  91. };
  92. layout.configureItem(c, 0);
  93. assert.areEqual('myExtraClass', addedClass);
  94. },
  95. testAddsExtraClsToPositionEl: function() {
  96. var layout = this.layout;
  97. var addedClass = "";
  98. //mock component object
  99. c = {
  100. getPositionEl: function() {
  101. return posEl;
  102. }
  103. };
  104. //mock position el
  105. posEl = {
  106. addClass: function(cls) {
  107. addedClass = cls;
  108. }
  109. };
  110. layout.configureItem(c, 0);
  111. assert.areEqual('myExtraClass', addedClass);
  112. },
  113. testLaysOutIfForced: function() {
  114. var laidOut = false;
  115. var layout = this.layout,
  116. comp = this.component;
  117. //mock component object
  118. comp.doLayout = function() {
  119. laidOut = true;
  120. };
  121. layout.configureItem(comp, 0);
  122. assert.isFalse(laidOut);
  123. layout.forceLayout = true;
  124. layout.configureItem(comp, 0);
  125. assert.isTrue(laidOut);
  126. },
  127. testHidesIfRenderHidden: function() {
  128. }
  129. }));
  130. })();