Browse Source

Refactored Layout tests. Remove errors (#13823)

Split tests into separate classes. Create hierarcy for tests.

Change-Id: I71e20a5410612f9a246bab051173e60768532185
tags/7.3.0.beta1
Dmitrii Rogozin 10 years ago
parent
commit
ccdc34051d
80 changed files with 3088 additions and 2197 deletions
  1. 0
    30
      uitest/src/com/vaadin/tests/layouts/layouttester/AbstractLayoutTests.java
  2. 109
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMove.java
  3. 43
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java
  4. 67
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignment.java
  5. 36
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignmentTest.java
  6. 44
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaption.java
  7. 35
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaptionTest.java
  8. 38
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizing.java
  9. 45
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizingTest.java
  10. 51
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseIcon.java
  11. 37
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseIconTest.java
  12. 77
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpand.java
  13. 49
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java
  14. 81
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutForSpacingMargin.java
  15. 42
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutMarginSpacingTest.java
  16. 37
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutRegErrorTest.java
  17. 40
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizing.java
  18. 50
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizingTest.java
  19. 288
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java
  20. 60
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/BaseRegError.java
  21. 105
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMove.java
  22. 27
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMoveTest.java
  23. 41
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignment.java
  24. 21
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignmentTest.java
  25. 107
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridBaseLayoutTestUI.java
  26. 35
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaption.java
  27. 27
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaptionTest.java
  28. 32
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizing.java
  29. 22
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizingTest.java
  30. 42
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIcon.java
  31. 27
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIconTest.java
  32. 64
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpand.java
  33. 26
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpandTest.java
  34. 74
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacing.java
  35. 27
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacingTest.java
  36. 54
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegError.java
  37. 27
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java
  38. 32
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizing.java
  39. 27
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizingTest.java
  40. 0
    657
      uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java
  41. 32
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMove.java
  42. 22
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMoveTest.java
  43. 27
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignment.java
  44. 21
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignmentTest.java
  45. 32
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaption.java
  46. 22
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaptionTest.java
  47. 36
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizing.java
  48. 21
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizingTest.java
  49. 37
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIcon.java
  50. 21
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java
  51. 36
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpand.java
  52. 21
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpandTest.java
  53. 37
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacing.java
  54. 22
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacingTest.java
  55. 36
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegError.java
  56. 21
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java
  57. 36
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizing.java
  58. 22
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizingTest.java
  59. 0
    597
      uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java
  60. 0
    147
      uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java
  61. 0
    132
      uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java
  62. 36
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMove.java
  63. 27
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMoveTest.java
  64. 25
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignment.java
  65. 21
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java
  66. 38
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaption.java
  67. 27
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaptionTest.java
  68. 37
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizing.java
  69. 21
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizingTest.java
  70. 37
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIcon.java
  71. 21
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIconTest.java
  72. 37
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpand.java
  73. 27
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpandTest.java
  74. 37
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacing.java
  75. 22
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacingTest.java
  76. 36
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegError.java
  77. 27
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java
  78. 37
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizing.java
  79. 27
    0
      uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizingTest.java
  80. 0
    634
      uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java

+ 0
- 30
uitest/src/com/vaadin/tests/layouts/layouttester/AbstractLayoutTests.java View File

@@ -1,30 +0,0 @@
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.ui.Layout;

public abstract class AbstractLayoutTests {

protected static final String FOLDER_16_PNG = "../icons/runo/16/folder.png";
protected static final String CALENDAR_32_PNG = "../runo/icons/32/calendar.png";
protected static final String LOCK_16_PNG = "../runo/icons/16/lock.png";
protected static final String GLOBE_16_PNG = "../runo/icons/16/globe.png";

abstract protected Layout getCaptionsTests();

abstract protected Layout getIconsTests();

abstract protected Layout getRequiredErrorIndicatorsTests();

abstract protected Layout getAlignmentTests();

abstract protected Layout getExpandRatiosTests();

abstract protected Layout getMarginSpacingTests();

abstract protected Layout getComponentAddReplaceMoveTests();

abstract protected Layout getComponentSizingTests();

abstract protected Layout getLayoutSizingTests();

}

+ 109
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMove.java View File

@@ -0,0 +1,109 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;

/**
*
* @since
* @author Vaadin Ltd
*/
public class BaseAddReplaceMove extends BaseLayoutTestUI {

/**
* @param layoutClass
*/
public BaseAddReplaceMove(Class<? extends AbstractLayout> layoutClass) {
super(layoutClass);
}

@Override
protected void setup(VaadinRequest request) {
init();
buildLayout();
super.setup(request);
}

private void buildLayout() {
// Set undefined height to avoid expanding
l2.setHeight(null);
// extra layout from which components will be moved
final HorizontalLayout source = new HorizontalLayout();
source.addComponent(new Label("OTHER LABEL 1"));
source.addComponent(new Label("OTHER LABEL 2"));

final AbstractComponent c1 = new Label("<b>LABEL</b>", ContentMode.HTML);
final AbstractComponent c2 = new Label("<b>LABEL</b>", ContentMode.HTML);
final AbstractComponent c3 = new Table("TABLE");
c3.setHeight("100px");
c3.setWidth("100%");

final Button btnAdd = new Button("Test add");
final Button btnReplace = new Button("Test replace");
final Button btnMove = new Button("Test move");
final Button btnRemove = new Button("Test remove");

l1.addComponent(btnAdd);
l1.addComponent(btnReplace);
l1.addComponent(btnMove);
l1.addComponent(btnRemove);

btnAdd.addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
l2.addComponent(new TextField());
}
});
btnReplace.addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
l2.replaceComponent(c1, c3);
}
});
btnMove.addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
l2.moveComponentsFrom(source);
}
});
btnRemove.addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
l2.removeComponent(c1);
l2.removeComponent(c2);
}
});

l2.addComponent(c1);
l2.addComponent(c2);
l2.addComponent(c3);
}
}

+ 43
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java View File

@@ -0,0 +1,43 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import java.io.IOException;
import java.util.List;

import org.junit.Test;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public abstract class BaseAddReplaceMoveTest extends MultiBrowserTest {
@Test
public void LayoutAlignment() throws IOException, InterruptedException {
openTestURL();
sleep(500);
compareScreen("initial");
String[] states = { "add", "replace", "move", "remove" };
List<ButtonElement> buttons = $(ButtonElement.class).all();
int index = 0;
// go through all buttons click them and see result
for (ButtonElement btn : buttons) {
btn.click();
sleep(500);
compareScreen(states[index]);
index++;
}
}
}

+ 67
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignment.java View File

@@ -0,0 +1,67 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.AbstractOrderedLayout;

/**
*
* @since
* @author Vaadin Ltd
*/
abstract public class BaseAlignment extends BaseLayoutTestUI {

@Override
protected void setup(VaadinRequest request) {
// create two columns of components with different
// alignment. Used to test alignment in layouts
init();
buildLayout();
super.setup(request);
}

public BaseAlignment(Class<? extends AbstractOrderedLayout> layoutClass) {
super(layoutClass);
}

/**
* Build Layout for test
*/
private void buildLayout() {
for (int i = 0; i < components.length; i++) {
AbstractOrderedLayout layout = null;
try {
layout = (AbstractOrderedLayout) layoutClass.newInstance();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
layout.setHeight("300px");
layout.setWidth("200px");
layout.addComponent(components[i]);
layout.setComponentAlignment(components[i], alignments[i]);
if (i < components.length / 2) {
l1.addComponent(layout);
} else {
l2.addComponent(layout);
}
}
}
}

+ 36
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignmentTest.java View File

@@ -0,0 +1,36 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import java.io.IOException;

import org.junit.Test;

import com.vaadin.tests.tb3.MultiBrowserTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public abstract class BaseAlignmentTest extends MultiBrowserTest {

@Test
public void layoutAlignment() throws IOException {
openTestURL();
compareScreen("alignment");
}
}

+ 44
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaption.java View File

@@ -0,0 +1,44 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.TabSheet;

/**
*
* @since
* @author Vaadin Ltd
*/
public class BaseCaption extends BaseLayoutTestUI {

/**
* @param layoutClass
*/
public BaseCaption(Class<? extends AbstractLayout> layoutClass) {
super(layoutClass);
}

@Override
protected void setup(VaadinRequest request) {
init();
l1.addComponent(createLabelsFields(ComboBox.class, true, ""));
l2.addComponent(createLabelsFields(TabSheet.class, false, ""));
super.setup(request);
}
}

+ 35
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaptionTest.java View File

@@ -0,0 +1,35 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import java.io.IOException;

import org.junit.Test;

import com.vaadin.tests.tb3.MultiBrowserTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public abstract class BaseCaptionTest extends MultiBrowserTest {
@Test
public void LayoutCaption() throws IOException, InterruptedException {
openTestURL();
compareScreen("caption");
}
}

+ 38
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizing.java View File

@@ -0,0 +1,38 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.AbstractLayout;

/**
*
* @since
* @author Vaadin Ltd
*/
public class BaseComponentSizing extends BaseLayoutTestUI {

public BaseComponentSizing(Class<? extends AbstractLayout> layoutClass) {
super(layoutClass);
}

@Override
protected void setup(VaadinRequest request) {
init();
getLayoutForLayoutSizing("component");
super.setup(request);
}
}

+ 45
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizingTest.java View File

@@ -0,0 +1,45 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import java.io.IOException;
import java.util.List;

import org.junit.Test;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public abstract class BaseComponentSizingTest extends MultiBrowserTest {
@Test
public void ComponentSizing() throws IOException, InterruptedException {
openTestURL();
sleep(500);
compareScreen("initial");
String[] states = { "setSize350px", "setSize_-1px", "setSize75Percent",
"setSize100Percent" };
List<ButtonElement> buttons = $(ButtonElement.class).all();
int index = 0;
// go through all buttons click them and see result
for (ButtonElement btn : buttons) {
btn.click();
sleep(500);
compareScreen(states[index]);
index++;
}
}

}

+ 51
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseIcon.java View File

@@ -0,0 +1,51 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TextField;

/**
*
* @since
* @author Vaadin Ltd
*/
public class BaseIcon extends BaseLayoutTestUI {
/**
* @param layoutClass
*/
public BaseIcon(Class<? extends AbstractLayout> layoutClass) {
super(layoutClass);
}

@Override
protected void setup(VaadinRequest request) {
init();
l1.addComponent(createLabelsFields(TextField.class, true, ""));
l1.addComponent(createLabelsFields(Label.class, true, ""));
l1.addComponent(createLabelsFields(Button.class, true, ""));
l2.addComponent(createLabelsFields(ComboBox.class, true, ""));
l2.addComponent(createLabelsFields(Link.class, true, ""));
l2.addComponent(createLabelsFields(TabSheet.class, true, ""));
super.setup(request);
}
}

+ 37
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseIconTest.java View File

@@ -0,0 +1,37 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import java.io.IOException;

import org.junit.Test;

import com.vaadin.tests.tb3.MultiBrowserTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public abstract class BaseIconTest extends MultiBrowserTest {

@Test
public void LayoutIcon() throws IOException {
openTestURL();
compareScreen("icon");
}

}

+ 77
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpand.java View File

@@ -0,0 +1,77 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.Table;

/**
*
* @since
* @author Vaadin Ltd
*/
public class BaseLayoutExpand extends BaseLayoutTestUI {

public BaseLayoutExpand(Class<? extends AbstractLayout> layoutClass) {
super(layoutClass);
}

@Override
protected void setup(VaadinRequest request) {
init();
buildLayout();
super.setup(request);
}

private void buildLayout() {
class ExpandButton extends Button {
final private AbstractComponent c1;
private AbstractComponent c2;
private float expandComp1;
private float expandComp2;

public ExpandButton(final AbstractComponent c1,
final AbstractComponent c2, float e1, float e2) {
super();
this.c1 = c1;
this.c2 = c2;
expandComp1 = e1;
expandComp2 = e2;
setCaption("Expand ratio: " + e1 * 100 + " /" + e2 * 100);
addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
l2.setExpandRatio(c1, expandComp1);
l2.setExpandRatio(c2, expandComp2);
}
});
}
}
Table t1 = getTestTable();
Table t2 = getTestTable();
t1.setSizeFull();
t2.setSizeFull();
l2.addComponent(t1);
l2.addComponent(t2);

l1.addComponent(new ExpandButton(t1, t2, 1.0f, 0.0f));
l1.addComponent(new ExpandButton(t1, t2, 0.5f, 0.50f));
l1.addComponent(new ExpandButton(t1, t2, .25f, 0.75f));
}
}

+ 49
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java View File

@@ -0,0 +1,49 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import java.io.IOException;
import java.util.List;

import org.junit.Test;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public abstract class BaseLayoutExpandTest extends MultiBrowserTest {

@Test
public void LayoutExpand() throws IOException, InterruptedException {
openTestURL();
sleep(500);
compareScreen("initial");
String[] states = { "expand_100_0", "expand_50_50", "expand_25_75" };
List<ButtonElement> buttons = $(ButtonElement.class).all();
int index = 0;
// go through all buttons click them and see result
for (ButtonElement btn : buttons) {
btn.click();
sleep(500);
compareScreen(states[index]);
index++;
}
}
}

+ 81
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutForSpacingMargin.java View File

@@ -0,0 +1,81 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;

/**
*
* @since
* @author Vaadin Ltd
*/
public class BaseLayoutForSpacingMargin extends BaseLayoutTestUI {
/**
* @param layoutClass
*/
public BaseLayoutForSpacingMargin(
Class<? extends AbstractLayout> layoutClass) {
super(layoutClass);
}

@Override
protected void setup(VaadinRequest request) {
init();
buildLayout();
super.setup(request);
}

private void buildLayout() {
Table t1 = getTestTable();
Table t2 = getTestTable();
t1.setSizeFull();
t2.setSizeFull();
l2.addComponent(t1);
l2.setMargin(false);
l2.setSpacing(false);
// Must add something around the hr to avoid the margins collapsing
l2.addComponent(new Label(
"<div style='height: 1px'></div><hr /><div style='height: 1px'></div>",
ContentMode.HTML));
l2.addComponent(t2);
final Button btn1 = new Button("Toggle margin on/off");
btn1.addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
boolean margin = l2.getMargin().hasLeft();
l2.setMargin(!margin);

}
});
final Button btn2 = new Button("Toggle spacing on/off");
btn2.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
l2.setSpacing(!l2.isSpacing());
}
});
l1.addComponent(btn1);
l1.addComponent(btn2);
}
}

+ 42
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutMarginSpacingTest.java View File

@@ -0,0 +1,42 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import java.io.IOException;

import org.junit.Test;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public abstract class BaseLayoutMarginSpacingTest extends MultiBrowserTest {

@Test
public void LayoutMarginSpacing() throws IOException, InterruptedException {
openTestURL();
sleep(500);
compareScreen("initial");
String[] states = { "marginOnSpaceOff", "marginOnfSpaceOn" };
ButtonElement marginBtn = $(ButtonElement.class).get(0);
ButtonElement spaceBtn = $(ButtonElement.class).get(1);
marginBtn.click();
sleep(1000);
compareScreen(states[0]);
spaceBtn.click();
sleep(1000);
compareScreen(states[1]);
}
}

+ 37
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutRegErrorTest.java View File

@@ -0,0 +1,37 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import java.io.IOException;

import org.junit.Test;

import com.vaadin.tests.tb3.MultiBrowserTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public abstract class BaseLayoutRegErrorTest extends MultiBrowserTest {

@Test
public void LayoutRegError() throws IOException {
openTestURL();
compareScreen("RegError");
}

}

+ 40
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizing.java View File

@@ -0,0 +1,40 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.AbstractLayout;

/**
*
* @since
* @author Vaadin Ltd
*/
public class BaseLayoutSizing extends BaseLayoutTestUI {
/**
* @param layoutClass
*/
public BaseLayoutSizing(Class<? extends AbstractLayout> layoutClass) {
super(layoutClass);
}

@Override
protected void setup(VaadinRequest request) {
init();
getLayoutForLayoutSizing("layout");
super.setup(request);
}
}

+ 50
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizingTest.java View File

@@ -0,0 +1,50 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import java.io.IOException;
import java.util.List;

import org.junit.Test;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public abstract class BaseLayoutSizingTest extends MultiBrowserTest {
@Test
public void LayoutSizing() throws IOException, InterruptedException {
openTestURL();
sleep(500);
compareScreen("initial");
String[] states = { "setSize350px", "setSize_-1px", "setSize75Percent",
"setSize100Percent" };
List<ButtonElement> buttons = $(ButtonElement.class).all();
int index = 0;
// go through all buttons click them and see result
for (ButtonElement btn : buttons) {
btn.click();
sleep(500);
compareScreen(states[index]);
index++;
}
}

}

+ 288
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java View File

@@ -0,0 +1,288 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.Resource;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.UserError;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;

/**
*
* Base class for Layout tests.
*/
public abstract class BaseLayoutTestUI extends AbstractTestUI {
protected static final String FOLDER_16_PNG = "../icons/runo/16/folder.png";
protected static final String CALENDAR_32_PNG = "../runo/icons/16/calendar.png";
protected static final String LOCK_16_PNG = "../runo/icons/16/lock.png";
protected static final String GLOBE_16_PNG = "../runo/icons/16/globe.png";
public Alignment[] alignments = new Alignment[] { Alignment.TOP_CENTER,
Alignment.TOP_LEFT, Alignment.TOP_RIGHT, Alignment.BOTTOM_CENTER,
Alignment.BOTTOM_LEFT, Alignment.BOTTOM_RIGHT,
Alignment.MIDDLE_CENTER, Alignment.MIDDLE_LEFT,
Alignment.MIDDLE_RIGHT };

public final String[] CAPTIONS = new String[] { "",
"VeryLongOneWordCaption",
"Very long caption of 50 approximately symbols aaaaaaaaaaaa aaaaaa aaa " };
Resource[] ICONS = new Resource[] { new ThemeResource(CALENDAR_32_PNG),
new ThemeResource(LOCK_16_PNG), new ThemeResource(GLOBE_16_PNG) };
public AbstractComponent[] components = new AbstractComponent[alignments.length];

protected AbstractOrderedLayout l1;
protected AbstractOrderedLayout l2;
protected Class<? extends AbstractLayout> layoutClass;
protected VerticalLayout mainLayout = new VerticalLayout();

public BaseLayoutTestUI(Class<? extends AbstractLayout> layoutClass) {
super();
fillComponents();
this.layoutClass = layoutClass;

}

protected void init() {
try {
l1 = (AbstractOrderedLayout) layoutClass.newInstance();
l2 = (AbstractOrderedLayout) layoutClass.newInstance();
} catch (InstantiationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (layoutClass.equals(HorizontalLayout.class)) {
setLayoutMeasures(l1, l2, "600px", "400px");
} else if (layoutClass.equals(VerticalLayout.class)) {
setLayoutMeasures(l1, l2, "400px", "400px");
} else {
setDefaultForVertical(l1, l2);
}
}

private void fillComponents() {
for (int i = 0; i < components.length; i++) {
String name = "Field" + i;
TextField field = new TextField();
field.setValue(name);
components[i] = field;
}
}

protected AbstractLayout createLabelsFields(
Class<? extends AbstractComponent> compType) {
return createLabelsFields(compType, false, null);
}

protected void getLayoutForLayoutSizing(final String compType) {

l2.setSpacing(false);
l2.setMargin(false);

final AbstractComponent c1 = getTestTable();
c1.setSizeFull();
final AbstractComponent c2 = getTestTable();
c2.setSizeFull();

class SetSizeButton extends Button {
SetSizeButton(final String size) {
super();
setCaption("Set size " + size);
addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
if (compType == "layout") {
l2.setHeight(size);
l2.setWidth(size);
} else if (compType == "component") {
c2.setHeight(size);
c2.setWidth(size);
} else {
}

}
});
}

}
Button btn1 = new SetSizeButton("350px");
Button btn2 = new SetSizeButton("-1px");
Button btn3 = new SetSizeButton("75%");
Button btn4 = new SetSizeButton("100%");

l1.addComponent(btn1);
l1.addComponent(btn2);
l1.addComponent(btn3);
l1.addComponent(btn4);
l2.addComponent(c1);
l2.addComponent(new Label(
"<div style='height: 1px'></div><hr /><div style='height: 1px'></div>",
ContentMode.HTML));
l2.addComponent(c2);
l2.setExpandRatio(c1, 0.5f);
l2.setExpandRatio(c2, 0.5f);

btn2.addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
Label newLabel = new Label("--- NEW LABEL ---");
newLabel.setSizeUndefined();
l2.addComponent(newLabel);

}
});
}

protected Table getTestTable() {
Table t = new Table();
t.setPageLength(5);
t.addContainerProperty("test", String.class, null);
t.addItem(new Object[] { "qwertyuiop asdfghjköäxccvbnm,m,." }, 1);
t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2);
return t;
}

protected AbstractLayout createLabelsFields(
Class<? extends AbstractComponent> compType, boolean useIcon,
String ErrorMessage) {
AbstractLayout mainLayout = new VerticalLayout();
AbstractLayout curLayout = null;
try {
curLayout = layoutClass.newInstance();
} catch (InstantiationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
final Component[] components = new Component[CAPTIONS.length];

for (int i = 0; i < components.length; i++) {
AbstractComponent comp = null;
try {
comp = compType.newInstance();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
components[i] = comp;
comp.setCaption(CAPTIONS[i]);
if (useIcon) {
comp.setIcon(ICONS[i]);
}
if (ErrorMessage != null) {
if (ErrorMessage.length() == 0) {
comp.setComponentError(new UserError(null));
} else {
comp.setComponentError(new UserError(ErrorMessage));
}
}
// if component is a tab sheet add two tabs for it
if (comp instanceof TabSheet) {
comp.setSizeUndefined();
TabSheet tab = (TabSheet) comp;
tab.addTab(new UndefWideLabel("TAB1"), "TAB1",
new ThemeResource(GLOBE_16_PNG));
tab.addTab(new UndefWideLabel("TAB2"), "TAB2", null);
}
curLayout.addComponent(comp);
mainLayout.addComponent(curLayout);
}
return mainLayout;
}

/*
* (non-Javadoc)
*
* @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
* VaadinRequest)
*/
@Override
protected void setup(VaadinRequest request) {
mainLayout.addComponent(l1);
mainLayout.addComponent(l2);
addComponent(mainLayout);
}

/*
* (non-Javadoc)
*
* @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
*/
@Override
protected String getTestDescription() {
return null;
}

protected void setLayoutMeasures(AbstractOrderedLayout l1,
AbstractOrderedLayout l2, String w, String h) {
l1.setWidth(w);
l1.setHeight(h);
l2.setWidth(h);
l2.setHeight(w);
}

protected void setDefaultForVertical(AbstractOrderedLayout l1,
AbstractOrderedLayout l2) {
l1.setWidth("800px");
l1.setHeight("600px");
l2.setWidth("800px");
l2.setHeight("600px");
}

protected void setDefaultForHorizontal(AbstractOrderedLayout l1,
AbstractOrderedLayout l2) {
l1.setWidth("600px");
l1.setHeight("600px");
l2.setWidth("600px");
l2.setHeight("600px");
}

/*
* (non-Javadoc)
*
* @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
*/
@Override
protected Integer getTicketNumber() {
// TODO Auto-generated method stub
return null;
}

}

+ 60
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/BaseRegError.java View File

@@ -0,0 +1,60 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.Label;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TextField;

/**
*
* @since
* @author Vaadin Ltd
*/
public class BaseRegError extends BaseLayoutTestUI {

public BaseRegError(Class<? extends AbstractLayout> layoutClass) {
super(layoutClass);
}

@Override
protected void setup(VaadinRequest request) {
init();
buildLayout();
super.setup(request);
}

private void buildLayout() {

l1.addComponent(createLabelsFields(Label.class, true, ""));
l1.addComponent(createLabelsFields(Button.class, true, ""));
l1.addComponent(createLabelsFields(TabSheet.class, true, ""));
l1.addComponent(createLabelsFields(TextField.class, true, ""));

l2.addComponent(createLabelsFields(ComboBox.class, true, ""));
l2.addComponent(createLabelsFields(DateField.class, true, ""));
l2.addComponent(createLabelsFields(NativeSelect.class, true, ""));
l2.addComponent(createLabelsFields(CheckBox.class, true, ""));

}
}

+ 105
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMove.java View File

@@ -0,0 +1,105 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;

/**
*
* @since
* @author Vaadin Ltd
*/

public class GridAddReplaceMove extends GridBaseLayoutTestUI {

/*
* (non-Javadoc)
*
* @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
* VaadinRequest)
*/
@Override
protected void setup(VaadinRequest request) {
buildLayout();
super.setup(request);
}

private void buildLayout() {

final HorizontalLayout source = new HorizontalLayout();
source.addComponent(new Label("OTHER LABEL 1"));
source.addComponent(new Label("OTHER LABEL 2"));

final AbstractComponent c1 = new Label("<b>LABEL</b>", ContentMode.HTML);
final AbstractComponent c2 = new Label("<b>LABEL</b>", ContentMode.HTML);
final AbstractComponent c3 = new Table("TABLE");
c3.setHeight("100px");
c3.setWidth("100%");

final Button btnAdd = new Button("Test add");
final Button btnReplace = new Button("Test replace");
final Button btnMove = new Button("Test move");
final Button btnRemove = new Button("Test remove");

layout.addComponent(btnAdd);
layout.addComponent(btnReplace);
layout.addComponent(btnMove);
layout.addComponent(btnRemove);

btnAdd.addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
layout.addComponent(new TextField());
}
});
btnReplace.addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
layout.replaceComponent(c1, c3);
}
});
btnMove.addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
layout.moveComponentsFrom(source);
}
});
btnRemove.addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
layout.removeComponent(c1);
layout.removeComponent(c2);
}
});

layout.addComponent(c1);
layout.addComponent(c2);
layout.addComponent(c3);
}
}

+ 27
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMoveTest.java View File

@@ -0,0 +1,27 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMoveTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public class GridAddReplaceMoveTest extends BaseAddReplaceMoveTest {

}

+ 41
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignment.java View File

@@ -0,0 +1,41 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.server.VaadinRequest;

public class GridAlignment extends GridBaseLayoutTestUI {

@Override
protected void setup(VaadinRequest request) {
buildLayout();
super.setup(request);
}

/**
* Build Layout for test
*/
private void buildLayout() {
layout.setColumns(3);
layout.setRows(3);
// layout.setHeight("600px");
// layout.setWidth("900px");
for (int i = 0; i < components.length; i++) {
layout.addComponent(components[i]);
layout.setComponentAlignment(components[i], alignments[i]);
}
}
}

+ 21
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignmentTest.java View File

@@ -0,0 +1,21 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.tests.layouts.layouttester.BaseAlignmentTest;

public class GridAlignmentTest extends BaseAlignmentTest {
}

+ 107
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridBaseLayoutTestUI.java View File

@@ -0,0 +1,107 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.tests.layouts.layouttester.BaseLayoutTestUI;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;

/**
*
* @since
* @author Vaadin Ltd
*/
public abstract class GridBaseLayoutTestUI extends BaseLayoutTestUI {
protected GridLayout layout = new GridLayout();

/**
* @param layoutClass
*/
public GridBaseLayoutTestUI() {
super(GridLayout.class);
}

@Override
protected void setup(VaadinRequest request) {
layout.setMargin(true);
layout.setSizeFull();
getUI().setContent(layout);
}

@Override
protected void getLayoutForLayoutSizing(final String compType) {

layout.setSpacing(false);
layout.setMargin(false);

final AbstractComponent c1 = getTestTable();
c1.setSizeFull();
final AbstractComponent c2 = getTestTable();
c2.setSizeFull();

class SetSizeButton extends Button {
SetSizeButton(final String size) {
super();
setCaption("Set size " + size);
addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
if (compType == "layout") {
layout.setHeight(size);
layout.setWidth(size);
} else if (compType == "component") {
c2.setHeight(size);
c2.setWidth(size);
} else {
}

}
});
}

}
Button btn1 = new SetSizeButton("550px");
Button btn2 = new SetSizeButton("-1px");
Button btn3 = new SetSizeButton("75%");
Button btn4 = new SetSizeButton("100%");

layout.addComponent(btn1);
layout.addComponent(btn2);
layout.addComponent(btn3);
layout.addComponent(btn4);
layout.addComponent(c1);
layout.addComponent(new Label(
"<div style='height: 1px'></div><hr /><div style='height: 1px'></div>",
ContentMode.HTML));
layout.addComponent(c2);
btn2.addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
Label newLabel = new Label("--- NEW LABEL ---");
newLabel.setSizeUndefined();
layout.addComponent(newLabel);
}
});
}
}

+ 35
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaption.java View File

@@ -0,0 +1,35 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;

public class GridCaption extends GridBaseLayoutTestUI {

@Override
protected void setup(VaadinRequest request) {
layout.addComponent(createLabelsFields(Button.class, true, ""));
layout.addComponent(createLabelsFields(Label.class, true, ""));
layout.addComponent(createLabelsFields(ComboBox.class, true, ""));
layout.addComponent(createLabelsFields(TabSheet.class, false, ""));
super.setup(request);
}

}

+ 27
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaptionTest.java View File

@@ -0,0 +1,27 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.tests.layouts.layouttester.BaseCaptionTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public class GridCaptionTest extends BaseCaptionTest {

}

+ 32
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizing.java View File

@@ -0,0 +1,32 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.server.VaadinRequest;

/**
*
* @since
* @author Vaadin Ltd
*/
public class GridComponentSizing extends GridBaseLayoutTestUI {

@Override
protected void setup(VaadinRequest request) {
getLayoutForLayoutSizing("component");
super.setup(request);
}
}

+ 22
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizingTest.java View File

@@ -0,0 +1,22 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.tests.layouts.layouttester.BaseComponentSizingTest;

public class GridComponentSizingTest extends BaseComponentSizingTest {

}

+ 42
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIcon.java View File

@@ -0,0 +1,42 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TextField;

/**
*
* @since
* @author Vaadin Ltd
*/
public class GridIcon extends GridBaseLayoutTestUI {
@Override
protected void setup(VaadinRequest request) {
layout.addComponent(createLabelsFields(TextField.class, true, ""));
layout.addComponent(createLabelsFields(Label.class, true, ""));
layout.addComponent(createLabelsFields(Button.class, true, ""));
layout.addComponent(createLabelsFields(ComboBox.class, true, ""));
layout.addComponent(createLabelsFields(Link.class, true, ""));
layout.addComponent(createLabelsFields(TabSheet.class, true, ""));
super.setup(request);
}
}

+ 27
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIconTest.java View File

@@ -0,0 +1,27 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.tests.layouts.layouttester.BaseIconTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public class GridIconTest extends BaseIconTest {

}

+ 64
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpand.java View File

@@ -0,0 +1,64 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Table;

/**
*
* @since
* @author Vaadin Ltd
*/
public class GridLayoutExpand extends GridBaseLayoutTestUI {

@Override
protected void setup(VaadinRequest request) {
buildLayout();
super.setup(request);
}

private void buildLayout() {
class ExpandButton extends Button {

public ExpandButton(final int i1, final int i2, final float e1,
final float e2) {
super();
setCaption("Expand ratio: " + e1 * 100 + " /" + e2 * 100);
addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
layout.setColumnExpandRatio(i1, e1);
layout.setColumnExpandRatio(i2, e2);
}
});
}
}
Table t1 = getTestTable();
Table t2 = getTestTable();
t1.setSizeFull();
t2.setSizeFull();
layout.setColumns(4);
layout.setRows(4);
layout.addComponent(new ExpandButton(1, 2, 1.0f, 0.0f), 0, 0);
layout.addComponent(new ExpandButton(1, 2, 0.5f, 0.50f), 0, 1);
layout.addComponent(new ExpandButton(1, 2, .25f, 0.75f), 0, 2);

layout.addComponent(t1, 1, 1);
layout.addComponent(t2, 2, 1);
}
}

+ 26
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpandTest.java View File

@@ -0,0 +1,26 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.tests.layouts.layouttester.BaseLayoutExpandTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public class GridLayoutExpandTest extends BaseLayoutExpandTest {
}

+ 74
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacing.java View File

@@ -0,0 +1,74 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;

/**
*
* @since
* @author Vaadin Ltd
*/
public class GridLayoutMarginSpacing extends GridBaseLayoutTestUI {

@Override
protected void setup(VaadinRequest request) {
buildLayout();
super.setup(request);
}

private void buildLayout() {
Table t1 = getTestTable();
Table t2 = getTestTable();
t1.setSizeFull();
t2.setSizeFull();

final Button btn1 = new Button("Toggle margin on/off");
btn1.addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
boolean margin = layout.getMargin().hasLeft();
layout.setMargin(!margin);

}
});
final Button btn2 = new Button("Toggle spacing on/off");
btn2.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
layout.setSpacing(!layout.isSpacing());
}
});
layout.addComponent(btn1);
layout.addComponent(btn2);

layout.addComponent(t1);
layout.setMargin(false);
layout.setSpacing(false);
// Must add something around the hr to avoid the margins collapsing
layout.addComponent(new Label(
"<div style='height: 1px'></div><hr /><div style='height: 1px'></div>",
ContentMode.HTML));
layout.addComponent(t2);
}
}

+ 27
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacingTest.java View File

@@ -0,0 +1,27 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.tests.layouts.layouttester.BaseLayoutMarginSpacingTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public class GridLayoutMarginSpacingTest extends BaseLayoutMarginSpacingTest {

}

+ 54
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegError.java View File

@@ -0,0 +1,54 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.Label;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TextField;

/**
*
* @since
* @author Vaadin Ltd
*/
public class GridLayoutRegError extends GridBaseLayoutTestUI {

@Override
protected void setup(VaadinRequest request) {
buildLayout();
super.setup(request);
}

private void buildLayout() {

layout.addComponent(createLabelsFields(Label.class, true, ""));
layout.addComponent(createLabelsFields(Button.class, true, ""));
layout.addComponent(createLabelsFields(TabSheet.class, true, ""));
layout.addComponent(createLabelsFields(TextField.class, true, ""));

layout.addComponent(createLabelsFields(ComboBox.class, true, ""));
layout.addComponent(createLabelsFields(DateField.class, true, ""));
layout.addComponent(createLabelsFields(NativeSelect.class, true, ""));
layout.addComponent(createLabelsFields(CheckBox.class, true, ""));

}
}

+ 27
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java View File

@@ -0,0 +1,27 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public class GridLayoutRegErrorTest extends BaseLayoutRegErrorTest {

}

+ 32
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizing.java View File

@@ -0,0 +1,32 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.server.VaadinRequest;

/**
*
* @since
* @author Vaadin Ltd
*/
public class GridLayoutSizing extends GridBaseLayoutTestUI {

@Override
protected void setup(VaadinRequest request) {
getLayoutForLayoutSizing("layout");
super.setup(request);
}
}

+ 27
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizingTest.java View File

@@ -0,0 +1,27 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.tests.layouts.layouttester.BaseLayoutSizingTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public class GridLayoutSizingTest extends BaseLayoutSizingTest {

}

+ 0
- 657
uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java View File

@@ -1,657 +0,0 @@
package com.vaadin.tests.layouts.layouttester;

import java.util.Date;

import com.vaadin.server.LegacyApplication;
import com.vaadin.server.Resource;
import com.vaadin.server.SystemError;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.UserError;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.InlineDateField;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.Link;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.Reindeer;

public class GridLayoutTests extends AbstractLayoutTests {

private AbstractComponent rc1, col1, col2, col3, row1, row2, row3, x3, x22;

public GridLayoutTests(LegacyApplication application) {
super();
}

@Override
protected Layout getAlignmentTests() {
HorizontalLayout hlo = new HorizontalLayout();
hlo.setSpacing(true);
GridLayout glo = getTestGrid();
glo.addStyleName(Reindeer.LAYOUT_WHITE);
Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_LEFT,
Alignment.BOTTOM_CENTER, Alignment.BOTTOM_RIGHT,
Alignment.MIDDLE_LEFT, Alignment.MIDDLE_CENTER,
Alignment.MIDDLE_RIGHT, Alignment.TOP_LEFT,
Alignment.TOP_CENTER, Alignment.TOP_RIGHT };

glo.replaceComponent(col1, col1 = new TextField());
glo.replaceComponent(col2, col2 = new TextField());
glo.replaceComponent(col3, col3 = new TextField());
((TextField) col1).setValue("BOTTOM_RIGHT");
((TextField) col2).setValue("BOTTOM_LEFT");
((TextField) col3).setValue("BOTTOM_CENTER");
glo.setComponentAlignment(col2, alignments[0]);
glo.setComponentAlignment(col3, alignments[1]);
glo.setComponentAlignment(col1, alignments[2]);

glo.setComponentAlignment(row1, alignments[3]);
glo.setComponentAlignment(row2, alignments[4]);
glo.setComponentAlignment(row3, alignments[5]);
hlo.addComponent(glo);
glo = getTestGrid();
glo.replaceComponent(row1, row1 = new DateField());
glo.replaceComponent(row2, row2 = new DateField());
glo.replaceComponent(row3, row3 = new DateField());
((DateField) row1).setResolution(DateField.RESOLUTION_SEC);
((DateField) row2).setResolution(DateField.RESOLUTION_SEC);
((DateField) row3).setResolution(DateField.RESOLUTION_SEC);
glo.setComponentAlignment(col2, alignments[6]);
glo.setComponentAlignment(col3, alignments[7]);
glo.setComponentAlignment(col1, alignments[8]);
hlo.addComponent(glo);
return hlo;
}

@Override
protected Layout getCaptionsTests() {
GridLayout glo = getTestGrid();
glo.setWidth("600px");
String[] captions = new String[] {
"",
"abcdefghijklmnopq",
"abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" };
glo.replaceComponent(col1, col1 = new TextField());
glo.replaceComponent(col2, col2 = new TextField());
glo.replaceComponent(col3, col3 = new TextField());

col1.setCaption(captions[0]);
col2.setCaption(captions[1]);
col3.setCaption(captions[2]);
col3.setIcon(new ThemeResource(LOCK_16_PNG));

glo.replaceComponent(row1, row1 = new Label());
glo.replaceComponent(row2, row2 = new Label());
glo.replaceComponent(row3, row3 = new Label());

row1.setCaption(captions[0]);
row2.setCaption(captions[1]);
row3.setCaption(captions[2]);

glo.replaceComponent(x3, x3 = getTestTabsheet());
glo.replaceComponent(x22, x22 = getTestTable());
x22.setComponentError(new UserError("component error, user error"));

x3.setCaption(captions[1]);
x22.setCaption(captions[2]);

return glo;
}

@Override
protected Layout getComponentAddReplaceMoveTests() {
final GridLayout glo = getTestGrid();
glo.setHeight("350px");
Layout baseLayout = getBaseLayout();
final Button button1 = new Button("Test add");
final Button button2 = new Button("Test replace");
final Button button3 = new Button("Test move");
final Button button4 = new Button("Test remove comp 1,1");
final Button button5 = new Button("Test remove row 0");
final Button button6 = new Button("Test remove comp row3");

button1.setId("testButton1");
button2.setId("testButton2");
button3.setId("testButton3");
button4.setId("testButton4");
button5.setId("testButton5");
button6.setId("testButton6");

baseLayout.addComponent(button1);
baseLayout.addComponent(button2);
baseLayout.addComponent(button3);
baseLayout.addComponent(button4);
baseLayout.addComponent(button5);
baseLayout.addComponent(button6);
baseLayout.addComponent(glo);
button1.setEnabled(true);
button2.setEnabled(false);
button3.setEnabled(false);
button4.setEnabled(false);
button5.setEnabled(false);
button6.setEnabled(false);

final HorizontalLayout source = new HorizontalLayout();
source.addComponent(new Label("MOVE LABEL 1"));
source.addComponent(new Label("MOVE LABEL 2"));

final AbstractComponent cc1 = getTestTabsheet();
cc1.setCaption("ADDED COMPONENT");

final AbstractComponent cc2 = getTestTabsheet();
cc2.setCaption("REPLACEMENT COMPONENT");

button1.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.addComponent(cc1);
button1.setEnabled(false);
button2.setEnabled(true);
}
});
button2.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.replaceComponent(x22, cc2);
button2.setEnabled(false);
button3.setEnabled(true);
}
});
button3.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.moveComponentsFrom(source);
button3.setEnabled(false);
button4.setEnabled(true);
}
});
button4.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.removeComponent(1, 1);
button4.setEnabled(false);
button5.setEnabled(true);
}
});

button5.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.removeRow(0);
button5.setEnabled(false);
button6.setEnabled(true);
}
});
button6.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.removeComponent(row3);
button6.setEnabled(false);
}
});

return baseLayout;
}

@Override
protected Layout getComponentSizingTests() {
final GridLayout glo = getTestGrid();
glo.setHeight("350px");
Layout baseLayout = getBaseLayout();
final Button button1 = new Button("full size, 3x1");
final Button button2 = new Button("200 px width, 3x1");
final Button button3 = new Button("200 px width, table");
final Button button4 = new Button("undefined size+add, table");

glo.replaceComponent(x22, x22 = getTestTable());
button1.setId("testButton1");
button2.setId("testButton2");
button3.setId("testButton3");
button4.setId("testButton4");

baseLayout.addComponent(button1);
baseLayout.addComponent(button2);
baseLayout.addComponent(button3);
baseLayout.addComponent(button4);
baseLayout.addComponent(glo);
button1.setEnabled(true);
button2.setEnabled(false);
button3.setEnabled(false);
button4.setEnabled(false);

button1.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
x3.setSizeFull();
button1.setEnabled(false);
button2.setEnabled(true);
}
});
button2.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
x3.setWidth("200px");
button2.setEnabled(false);
button3.setEnabled(true);
}
});
button3.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
x22.setWidth("200px");
button3.setEnabled(false);
button4.setEnabled(true);
}
});
button4.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
x22.setSizeUndefined();
((Table) x22).addItem(new Object[] { "NEW ROW1" }, 3);
((Table) x22).addItem(new Object[] { "NEW ROW2" }, 4);
button4.setEnabled(false);
}
});

return baseLayout;
}

@Override
protected Layout getExpandRatiosTests() {
final GridLayout glo = getTestGrid();
Layout baseLayout = getBaseLayout();
final Button button1 = new Button("set col 3 expand 1");
final Button button2 = new Button("set all cols expand 0.25");
final Button button3 = new Button("set row 0 expand 0.5");
final Button button4 = new Button("set row 3 expand 0.2");
button1.setId("testButton1");
button2.setId("testButton2");
button3.setId("testButton3");
button4.setId("testButton4");

glo.setHeight("400px");
glo.replaceComponent(x22, x22 = getTestTable());

baseLayout.addComponent(button1);
baseLayout.addComponent(button2);
baseLayout.addComponent(button3);
baseLayout.addComponent(button4);
baseLayout.addComponent(glo);
button1.setEnabled(true);
button2.setEnabled(false);
button3.setEnabled(false);
button4.setEnabled(false);

button1.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.setColumnExpandRatio(3, 1);
button1.setEnabled(false);
button2.setEnabled(true);
}
});
button2.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.setColumnExpandRatio(0, 0.25f);
glo.setColumnExpandRatio(1, 0.25f);
glo.setColumnExpandRatio(2, 0.25f);
glo.setColumnExpandRatio(3, 0.25f);
button2.setEnabled(false);
button3.setEnabled(true);
}
});
button3.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.setRowExpandRatio(0, 0.5f);
button3.setEnabled(false);
button4.setEnabled(true);
}
});
button4.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.setRowExpandRatio(3, 0.3f);
button4.setEnabled(false);
}
});

return baseLayout;
}

@Override
protected Layout getIconsTests() {
GridLayout glo = getTestGrid();
glo.setWidth("600px");
Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG),
new ThemeResource(LOCK_16_PNG) };

glo.replaceComponent(col1, col1 = new TextField("TEXTFIELD"));
glo.replaceComponent(col2, col2 = new Label("LABEL"));
glo.replaceComponent(col3, col3 = new Link("LINK", null));

col1.setIcon(icons[0]);
col2.setIcon(icons[1]);
col3.setIcon(icons[0]);
rc1.setIcon(icons[1]);
col3.setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd");
col3.setComponentError(new UserError("component error, user error"));

glo.replaceComponent(row1, row1 = new DateField());
glo.replaceComponent(row2, row2 = new NativeSelect());
glo.replaceComponent(row3, row3 = getTestTabsheet());

row1.setIcon(icons[1]);
row2.setIcon(icons[0]);
row3.setIcon(icons[1]);

glo.replaceComponent(x3, x3 = new CheckBox("CHECKBOX"));
VerticalLayout pl = new VerticalLayout();
pl.setMargin(true);
glo.replaceComponent(x22, x22 = new Panel("PANEL", pl));
x22.setIcon(new ThemeResource(CALENDAR_32_PNG));

x3.setIcon(icons[0]);
x22.setIcon(icons[1]);

return glo;
}

@Override
protected Layout getLayoutSizingTests() {
final GridLayout glo = getTestGrid();
Layout baseLayout = getBaseLayout();
baseLayout.setWidth("500px");
baseLayout.setHeight("500px");
final Button button1 = new Button("Set fixed height 350px");
final Button button2 = new Button(
"Set undefined size and add component");
final Button button3 = new Button("Set fixed width and height 75%");
final Button button4 = new Button("Set size full");

button1.setId("testButton1");
button2.setId("testButton2");
button3.setId("testButton3");
button4.setId("testButton4");

glo.replaceComponent(x22, x22 = getTestTable());

baseLayout.addComponent(button1);
baseLayout.addComponent(button2);
baseLayout.addComponent(button3);
baseLayout.addComponent(button4);
baseLayout.addComponent(glo);
// Don't expand the buttons
((AbstractOrderedLayout) baseLayout).setExpandRatio(glo, 1);

button1.setEnabled(true);
button2.setEnabled(false);
button3.setEnabled(false);
button4.setEnabled(false);

button1.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.setHeight("350px");
button1.setEnabled(false);
button2.setEnabled(true);
}
});
button2.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.setSizeUndefined();
glo.addComponent(new Label("--- NEW LABEL ---"));
button2.setEnabled(false);
button3.setEnabled(true);
}
});
button3.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.setWidth("75%");
glo.setHeight("75%");
button3.setEnabled(false);
button4.setEnabled(true);
}
});
button4.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.setSizeFull();
button4.setEnabled(false);
}
});

return baseLayout;
}

@Override
protected Layout getMarginSpacingTests() {
final GridLayout glo = getTestGrid();
Layout baseLayout = getBaseLayout();
baseLayout.setWidth("500px");
baseLayout.setHeight("500px");
final Button button1 = new Button("Set margin on");
final Button button2 = new Button("Set spacing on");
final Button button3 = new Button("Set margin off");
final Button button4 = new Button("Set spacing off");

button1.setId("testButton1");
button2.setId("testButton2");
button3.setId("testButton3");
button4.setId("testButton4");

baseLayout.addComponent(button1);
baseLayout.addComponent(button2);
baseLayout.addComponent(button3);
baseLayout.addComponent(button4);
button1.setEnabled(true);
button2.setEnabled(false);
button3.setEnabled(false);
button4.setEnabled(false);

baseLayout.addComponent(glo);

// Don't expand the buttons
((AbstractOrderedLayout) baseLayout).setExpandRatio(glo, 1);

button1.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.setMargin(true);
button1.setEnabled(false);
button2.setEnabled(true);
}
});
button2.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.setSpacing(true);
button2.setEnabled(false);
button3.setEnabled(true);
}
});
button3.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.setMargin(false);
button3.setEnabled(false);
button4.setEnabled(true);
}
});
button4.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
glo.setSpacing(false);
button4.setEnabled(false);
}
});

return baseLayout;
}

@Override
protected Layout getRequiredErrorIndicatorsTests() {
GridLayout glo = getTestGrid();
glo.setWidth("600px");
Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG),
new ThemeResource(LOCK_16_PNG) };

glo.replaceComponent(col1, col1 = new TextField("TEXTFIELD"));
glo.replaceComponent(col2, col2 = new Label("LABEL"));
// Make sure it doesn't shrink to 0px
col2.setWidth(null);
glo.replaceComponent(col3, col3 = new Link("LINK", null));

col1.setIcon(icons[0]);
col1.setComponentError(new UserError("component error, user error"));
col2.setComponentError(new SystemError("component error, system error"));
col3.setComponentError(new UserError("component error, user error"));

glo.replaceComponent(row1, row1 = new DateField());
glo.replaceComponent(row2, row2 = new NativeSelect());
glo.replaceComponent(row3, row3 = getTestTabsheet());

((AbstractField<?>) col1).setRequired(true);
((AbstractField<?>) col1).setValidationVisible(true);
((AbstractField<?>) col1).setRequiredError("required error");

((AbstractField<?>) row1).setRequired(true);
((AbstractField<?>) row1).setValidationVisible(true);
((AbstractField<?>) row1).setRequiredError("required error");

((AbstractField<?>) row2).setRequired(true);
((AbstractField<?>) row2).setValidationVisible(true);
((AbstractField<?>) row2).setRequiredError("required error");
row2.setComponentError(new UserError("component error, user error"));

row3.setComponentError(new UserError("component error, user error"));
row3.setIcon(icons[1]);
row3.setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd");

glo.replaceComponent(x3, x3 = new CheckBox("CHECKBOX"));
VerticalLayout pl = new VerticalLayout();
pl.setMargin(true);
glo.replaceComponent(x22, x22 = new Panel("PANEL", pl));

x3.setComponentError(new UserError("component error, user error"));
x22.setComponentError(new UserError("component error, user error"));
x22.setIcon(icons[0]);

return glo;
}

private GridLayout getTestGrid() {
// Create a 4 by 4 grid layout.
GridLayout grid = new GridLayout(4, 4);
// Fill out the first row using the cursor.
grid.addComponent(rc1 = new Button("R/C 1"));

grid.addComponent(col1 = new Button("Col " + (grid.getCursorX() + 1)));
grid.addComponent(col2 = new Button("Col " + (grid.getCursorX() + 1)));
grid.addComponent(col3 = new Button("Col " + (grid.getCursorX() + 1)));

// Fill out the first column using coordinates.

grid.addComponent(row1 = new Button("Row " + 1), 0, 1);
grid.addComponent(row2 = new Button("Row " + 2), 0, 2);
grid.addComponent(row3 = new Button("Row " + 3), 0, 3);

// Add some components of various shapes.
grid.addComponent(x3 = new Button("3x1 button"), 1, 1, 3, 1);
grid.addComponent(new Label("1x2 cell"), 1, 2, 1, 3);
x22 = new InlineDateField("A 2x2 date field");
((InlineDateField) x22).setResolution(DateField.RESOLUTION_DAY);
((InlineDateField) x22).setValue(new Date(128028960000l));
grid.addComponent(x22, 2, 2, 3, 3);
grid.setWidth("450px");
grid.setHeight("450px");
return grid;
}

private VerticalLayout getBaseLayout() {
VerticalLayout vlo = new VerticalLayout();
vlo.setSizeUndefined();
return vlo;
}

private AbstractComponent getTestTabsheet() {
TabSheet tabsheet = new TabSheet();
tabsheet.setSizeUndefined();
tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource(
GLOBE_16_PNG));
tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null);
return tabsheet;
}

private Table getTestTable() {
Table t = new Table();
t.setSizeUndefined();
t.setPageLength(5);
t.addContainerProperty("test", String.class, null);
t.addItem(new Object[] { "qwertyuiop asdfghjklzxccvbnm,m,." }, 1);
t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2);
return t;
}

}

+ 32
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMove.java View File

@@ -0,0 +1,32 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMove;
import com.vaadin.ui.HorizontalLayout;


public class HAddReplaceMove extends BaseAddReplaceMove {

/**
* @param layoutClass
*/
public HAddReplaceMove() {
super(HorizontalLayout.class);
}

}

+ 22
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMoveTest.java View File

@@ -0,0 +1,22 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMoveTest;

public class HAddReplaceMoveTest extends BaseAddReplaceMoveTest {

}

+ 27
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignment.java View File

@@ -0,0 +1,27 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.tests.layouts.layouttester.BaseAlignment;
import com.vaadin.ui.HorizontalLayout;

public class HAlignment extends BaseAlignment {

public HAlignment() {
super(HorizontalLayout.class);
}

}

+ 21
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignmentTest.java View File

@@ -0,0 +1,21 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.tests.layouts.layouttester.BaseAlignmentTest;

public class HAlignmentTest extends BaseAlignmentTest {
}

+ 32
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaption.java View File

@@ -0,0 +1,32 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseCaption;
import com.vaadin.ui.HorizontalLayout;


public class HCaption extends BaseCaption {

/**
* @param layoutClass
*/
public HCaption() {
super(HorizontalLayout.class);
}

}

+ 22
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaptionTest.java View File

@@ -0,0 +1,22 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.tests.layouts.layouttester.BaseCaptionTest;

public class HCaptionTest extends BaseCaptionTest {

}

+ 36
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizing.java View File

@@ -0,0 +1,36 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseComponentSizing;
import com.vaadin.ui.HorizontalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class HComponentSizing extends BaseComponentSizing {

/**
* @param layoutClass
*/
public HComponentSizing() {
super(HorizontalLayout.class);
}
}

+ 21
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizingTest.java View File

@@ -0,0 +1,21 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.tests.layouts.layouttester.BaseComponentSizingTest;

public class HComponentSizingTest extends BaseComponentSizingTest {
}

+ 37
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIcon.java View File

@@ -0,0 +1,37 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseIcon;
import com.vaadin.ui.HorizontalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class HIcon extends BaseIcon {

/**
* @param layoutClass
*/
public HIcon() {
super(HorizontalLayout.class);
}

}

+ 21
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java View File

@@ -0,0 +1,21 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.tests.layouts.layouttester.BaseIconTest;

public class HIconTest extends BaseIconTest {
}

+ 36
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpand.java View File

@@ -0,0 +1,36 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseLayoutExpand;
import com.vaadin.ui.HorizontalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class HLayoutExpand extends BaseLayoutExpand {

/**
* @param layoutClass
*/
public HLayoutExpand() {
super(HorizontalLayout.class);
}
}

+ 21
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpandTest.java View File

@@ -0,0 +1,21 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.tests.layouts.layouttester.BaseLayoutExpandTest;

public class HLayoutExpandTest extends BaseLayoutExpandTest {
}

+ 37
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacing.java View File

@@ -0,0 +1,37 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseLayoutForSpacingMargin;
import com.vaadin.ui.HorizontalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class HLayoutMarginSpacing extends BaseLayoutForSpacingMargin {

/**
* @param layoutClass
*/
public HLayoutMarginSpacing() {
super(HorizontalLayout.class);
}

}

+ 22
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacingTest.java View File

@@ -0,0 +1,22 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.tests.layouts.layouttester.BaseLayoutMarginSpacingTest;

public class HLayoutMarginSpacingTest extends BaseLayoutMarginSpacingTest {

}

+ 36
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegError.java View File

@@ -0,0 +1,36 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseRegError;
import com.vaadin.ui.HorizontalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class HLayoutRegError extends BaseRegError {

/**
* @param layoutClass
*/
public HLayoutRegError() {
super(HorizontalLayout.class);
}
}

+ 21
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java View File

@@ -0,0 +1,21 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest;

public class HLayoutRegErrorTest extends BaseLayoutRegErrorTest {
}

+ 36
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizing.java View File

@@ -0,0 +1,36 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseComponentSizing;
import com.vaadin.ui.HorizontalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class HLayoutSizing extends BaseComponentSizing {

/**
* @param layoutClass
*/
public HLayoutSizing() {
super(HorizontalLayout.class);
}
}

+ 22
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizingTest.java View File

@@ -0,0 +1,22 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.tests.layouts.layouttester.BaseLayoutSizingTest;

public class HLayoutSizingTest extends BaseLayoutSizingTest {

}

+ 0
- 597
uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java View File

@@ -1,597 +0,0 @@
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.LegacyApplication;
import com.vaadin.server.Resource;
import com.vaadin.server.SystemError;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.UserError;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.Link;
import com.vaadin.ui.Select;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.Reindeer;

public class HorizontalLayoutTests extends AbstractLayoutTests {

public HorizontalLayoutTests(LegacyApplication application) {
super();
}

@Override
protected Layout getAlignmentTests() {
Layout baseLayout = getBaseLayout();
HorizontalLayout vlo = getTestLaytout();
AbstractComponent[] components = new AbstractComponent[9];
String[] styles = { Reindeer.LAYOUT_BLUE, Reindeer.LAYOUT_WHITE };
Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_LEFT,
Alignment.BOTTOM_CENTER, Alignment.BOTTOM_RIGHT,
Alignment.MIDDLE_LEFT, Alignment.MIDDLE_CENTER,
Alignment.MIDDLE_RIGHT, Alignment.TOP_LEFT,
Alignment.TOP_CENTER, Alignment.TOP_RIGHT };

vlo.addStyleName(Reindeer.LAYOUT_WHITE);
baseLayout.addComponent(vlo);
int index = 0;
for (int i = 0; i < components.length; i++) {
if (i > 0 && i % 3 == 0) {
vlo = getTestLaytout();
vlo.addStyleName(styles[index++]);
baseLayout.addComponent(vlo);
}
components[i] = new TextField();
((TextField) components[i]).setValue("FIELD " + i);
vlo.addComponent(components[i]);
vlo.setComponentAlignment(components[i], alignments[i]);
}
return baseLayout;
}

@Override
protected Layout getCaptionsTests() {
Layout baseLayout = getBaseLayout();
AbstractComponent component = null;

String[] captions = new String[] {
"",
"abcdefghijklmnopq",
"abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" };

HorizontalLayout vlo = getTestLaytout();
for (int i = 0; i < captions.length; i++) {
component = new TextField();
((TextField) component).setValue("FIELD " + i);
component.setCaption(captions[i]);
vlo.addComponent(component);
}
baseLayout.addComponent(vlo);
vlo = getTestLaytout();
for (int i = 0; i < captions.length; i++) {
component = new Label();
((Label) component).setValue("Label " + i);
component.setCaption(captions[i]);
vlo.addComponent(component);
}
baseLayout.addComponent(vlo);
vlo = getTestLaytout();
for (int i = 0; i < captions.length; i++) {
component = new Select();
component.setCaption(captions[i]);
component.setIcon(new ThemeResource(LOCK_16_PNG));
vlo.addComponent(component);
}
baseLayout.addComponent(vlo);
vlo = getTestLaytout();
for (int i = 0; i < captions.length; i++) {
component = getTestTabsheet();
component.setCaption(captions[i]);
component.setComponentError(new UserError(""));
vlo.addComponent(component);
}
baseLayout.addComponent(vlo);
return baseLayout;
}

@Override
protected Layout getComponentAddReplaceMoveTests() {
final HorizontalLayout vlo = getTestLaytout();
Layout baseLayout = getBaseLayout();
final HorizontalLayout source = new HorizontalLayout();
source.addComponent(new Label("OTHER LABEL 1"));
source.addComponent(new Label("OTHER LABEL 2"));

final AbstractComponent c1 = new Button("BUTTON");
final AbstractComponent c2 = new Label("<b>LABEL</b>", ContentMode.HTML);
final AbstractComponent c3 = new Table("TABLE");
c3.setHeight("100px");
c3.setWidth("100%");

final Button addButton = new Button("Test add");
final Button replaceButton = new Button("Test replace");
final Button moveButton = new Button("Test move");
final Button removeButton = new Button("Test remove");
addButton.setId("testButton1");
replaceButton.setId("testButton2");
moveButton.setId("testButton3");
removeButton.setId("testButton4");
replaceButton.setEnabled(false);
moveButton.setEnabled(false);
removeButton.setEnabled(false);

addButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.addComponent(new TextField());
addButton.setEnabled(false);
replaceButton.setEnabled(true);
}
});
replaceButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.replaceComponent(c1, c3);
replaceButton.setEnabled(false);
moveButton.setEnabled(true);
}
});
moveButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.moveComponentsFrom(source);
moveButton.setEnabled(false);
removeButton.setEnabled(true);
}
});
removeButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.removeComponent(c1);
vlo.removeComponent(c2);
removeButton.setEnabled(false);
}
});

baseLayout.addComponent(addButton);
baseLayout.addComponent(replaceButton);
baseLayout.addComponent(moveButton);
baseLayout.addComponent(removeButton);

vlo.addComponent(c1);
vlo.addComponent(c2);
vlo.addComponent(c3);
baseLayout.addComponent(vlo);

return baseLayout;
}

@Override
protected Layout getComponentSizingTests() {
final HorizontalLayout vlo = getTestLaytout();
Layout baseLayout = getBaseLayout();

final AbstractComponent c = getTestTable();

final Button biggerButton = new Button("full size");
final Button smallerButton = new Button("200 px width");
final Button originalButton = new Button("undefined size+add");

biggerButton.setId("testButton1");
smallerButton.setId("testButton2");
originalButton.setId("testButton3");

baseLayout.addComponent(biggerButton);
baseLayout.addComponent(smallerButton);
baseLayout.addComponent(originalButton);
vlo.addComponent(c);
baseLayout.addComponent(vlo);

biggerButton.setEnabled(true);
smallerButton.setEnabled(false);
originalButton.setEnabled(false);

biggerButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
c.setSizeFull();
biggerButton.setEnabled(false);
smallerButton.setEnabled(true);
}
});
smallerButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
c.setWidth("200px");
smallerButton.setEnabled(false);
originalButton.setEnabled(true);
}
});
originalButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
originalButton.setEnabled(false);
c.setSizeUndefined();
((Table) c)
.addItem(
new Object[] { "VYVTCTC VYVYV ECECCE NIDSD SDMPOM" },
3);
}
});

return baseLayout;
}

@Override
protected Layout getLayoutSizingTests() {
final HorizontalLayout vlo = getTestLaytout();
vlo.setSpacing(false);
vlo.setMargin(false);
Layout baseLayout = getBaseLayout();
final AbstractComponent c1 = getTestTable();
c1.setSizeFull();
final AbstractComponent c2 = getTestTable();
c2.setSizeFull();

final Button button1 = new Button("Set fixed height 350px");
final Button button2 = new Button(
"Set undefined size and add component");
final Button button3 = new Button("Set fixed width and height 75%");
final Button button4 = new Button("Set size full");

button1.setId("testButton1");
button2.setId("testButton2");
button3.setId("testButton3");
button4.setId("testButton4");

baseLayout.addComponent(button1);
baseLayout.addComponent(button2);
baseLayout.addComponent(button3);
baseLayout.addComponent(button4);
button1.setEnabled(true);
button2.setEnabled(false);
button3.setEnabled(false);
button4.setEnabled(false);

vlo.addComponent(c1);
vlo.addComponent(c2);
vlo.setExpandRatio(c1, 0.5f);
vlo.setExpandRatio(c2, 0.5f);

baseLayout.addComponent(vlo);

button1.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.setHeight("350px");
button1.setEnabled(false);
button2.setEnabled(true);
}
});
button2.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.setSizeUndefined();
Label label = new Label("--- NEW LABEL ---");
label.setWidth(null);
vlo.addComponent(label);
button2.setEnabled(false);
button3.setEnabled(true);
}
});
button3.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.setWidth("75%");
vlo.setHeight("75%");
button3.setEnabled(false);
button4.setEnabled(true);
}
});
button4.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.setSizeFull();
button4.setEnabled(false);
}
});

return baseLayout;
}

@Override
protected Layout getExpandRatiosTests() {
final HorizontalLayout vlo = getTestLaytout();
Layout baseLayout = getBaseLayout();
final AbstractComponent c1 = getTestTable();
c1.setSizeFull();
final AbstractComponent c2 = getTestTable();
c2.setSizeFull();

final Button button1 = new Button("Expand to 1/undefined");
final Button button2 = new Button("Expand to 0.5/0.5");
final Button button3 = new Button("Expand to 0.75/0.25");
button1.setId("testButton1");
button2.setId("testButton2");
button3.setId("testButton3");

baseLayout.addComponent(button1);
baseLayout.addComponent(button2);
baseLayout.addComponent(button3);
button1.setEnabled(true);
button2.setEnabled(false);
button3.setEnabled(false);

vlo.addComponent(c1);
vlo.addComponent(c2);
baseLayout.addComponent(vlo);

button1.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.setExpandRatio(c1, 1.0f);
button1.setEnabled(false);
button2.setEnabled(true);
}
});
button2.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.setExpandRatio(c1, 0.5f);
vlo.setExpandRatio(c2, 0.5f);
button2.setEnabled(false);
button3.setEnabled(true);
}
});
button3.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.setExpandRatio(c1, 0.75f);
vlo.setExpandRatio(c2, 0.25f);
button3.setEnabled(false);
}
});
return baseLayout;
}

@Override
protected Layout getIconsTests() {
HorizontalLayout vlo = getTestLaytout();
AbstractComponent[] components = new AbstractComponent[2];
Layout baseLayout = getBaseLayout();
Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG),
new ThemeResource(LOCK_16_PNG) };

for (int i = 0; i < components.length; i++) {
components[i] = new TextField();
((TextField) components[i]).setValue("FIELD " + i);
components[i].setIcon(icons[i]);
components[i]
.setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd");
vlo.addComponent(components[i]);
}
for (int i = 0; i < components.length; i++) {
components[i] = new Label();
((Label) components[i]).setValue("Label " + i);
components[i].setIcon(icons[i]);
vlo.addComponent(components[i]);
}
baseLayout.addComponent(vlo);
vlo = getTestLaytout();
for (int i = 0; i < components.length; i++) {
components[i] = new Select();
components[i].setIcon(icons[i]);
vlo.addComponent(components[i]);
}
for (int i = 0; i < components.length; i++) {
components[i] = new Button();
components[i].setComponentError(new UserError(
"component error, user error"));
components[i].setIcon(icons[i]);
vlo.addComponent(components[i]);
}
for (int i = 0; i < components.length; i++) {
components[i] = new Link("Link", null);
components[i].setIcon(icons[i]);
vlo.addComponent(components[i]);
}
baseLayout.addComponent(vlo);
return baseLayout;
}

@Override
protected Layout getMarginSpacingTests() {
final HorizontalLayout vlo = getTestLaytout();
vlo.setSpacing(false);
vlo.setMargin(false);
Layout baseLayout = getBaseLayout();
final AbstractComponent c1 = getTestTable();
c1.setSizeFull();
final AbstractComponent c2 = getTestTable();
c2.setSizeFull();

final Button button1 = new Button("Set margin on");
final Button button2 = new Button("Set spacing on");
final Button button3 = new Button("Set margin off");
final Button button4 = new Button("Set spacing off");
button1.setId("testButton1");
button2.setId("testButton2");
button3.setId("testButton3");
button4.setId("testButton4");

baseLayout.addComponent(button1);
baseLayout.addComponent(button2);
baseLayout.addComponent(button3);
baseLayout.addComponent(button4);
button1.setEnabled(true);
button2.setEnabled(false);
button3.setEnabled(false);
button4.setEnabled(false);

vlo.addComponent(c1);
vlo.addComponent(c2);
vlo.setExpandRatio(c1, 0.5f);
vlo.setExpandRatio(c2, 0.5f);
baseLayout.addComponent(vlo);

button1.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.setMargin(true);
button1.setEnabled(false);
button2.setEnabled(true);
}
});
button2.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.setSpacing(true);
button2.setEnabled(false);
button3.setEnabled(true);
}
});
button3.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.setMargin(false);
button3.setEnabled(false);
button4.setEnabled(true);
}
});
button4.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo.setSpacing(false);
button4.setEnabled(false);
}
});

return baseLayout;
}

@Override
protected Layout getRequiredErrorIndicatorsTests() {
HorizontalLayout vlo = getTestLaytout();
Layout baseLayout = getBaseLayout();
AbstractComponent[] components = new AbstractComponent[4];
components[0] = new Label("LABEL");
components[0].setSizeUndefined();
components[1] = new Button("BUTTON");
components[2] = getTestTable();
components[3] = getTestTabsheet();
components[3].setIcon(new ThemeResource(LOCK_16_PNG));

AbstractField<?>[] fields = new AbstractField<?>[5];
fields[0] = new TextField();
fields[0].setRequired(true);
fields[0].setValidationVisible(true);
fields[0].setRequiredError("required error");

fields[1] = new TextField();
((TextField) fields[1]).setValue("TEXTFIELD2");
fields[1]
.setComponentError(new UserError("component error, user error"));

fields[2] = new Select();
fields[2].setComponentError(new SystemError(
"component error, system error"));
fields[3] = new DateField();
fields[3].setComponentError(new SystemError(
"component error, system error"));

fields[4] = new CheckBox();
fields[4]
.setComponentError(new UserError("component error, user error"));

for (int i = 0; i < components.length; i++) {
components[i].setComponentError(new UserError(
"component error, user error"));
vlo.addComponent(components[i]);
}
baseLayout.addComponent(vlo);
vlo = getTestLaytout();
for (int i = 0; i < fields.length; i++) {
vlo.addComponent(fields[i]);
}
baseLayout.addComponent(vlo);
return baseLayout;
}

private VerticalLayout getBaseLayout() {
VerticalLayout vlo = new VerticalLayout();
vlo.setSizeUndefined();
return vlo;
}

private HorizontalLayout getTestLaytout() {
HorizontalLayout vlo = new HorizontalLayout();
vlo.setHeight("100px");
vlo.setWidth("750px");
return vlo;
}

private AbstractComponent getTestTabsheet() {
TabSheet tabsheet = new TabSheet();
tabsheet.setSizeUndefined();
tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource(
GLOBE_16_PNG));
tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null);
return tabsheet;
}

private Table getTestTable() {
Table t = new Table();
t.setSizeUndefined();
t.setPageLength(5);
t.addContainerProperty("test", String.class, null);
t.addItem(new Object[] { "qwertyuiop asdfghjkl zxccvbnm,m,." }, 1);
t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2);
return t;
}
}

+ 0
- 147
uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java View File

@@ -1,147 +0,0 @@
package com.vaadin.tests.layouts.layouttester;

import java.lang.reflect.Method;

import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.tests.components.AbstractTestCase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Layout;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.Reindeer;

@SuppressWarnings("serial")
public class LayoutTesterApplication extends AbstractTestCase {
Button nextButton = new Button("Next");
private int layoutIndex = -1;

static final String[] layoutGetters = new String[] { "getCaptionsTests",
"getIconsTests", "getRequiredErrorIndicatorsTests",
"getAlignmentTests", "getExpandRatiosTests",
"getMarginSpacingTests", "getComponentAddReplaceMoveTests",
"getComponentSizingTests", "getLayoutSizingTests" };
public static final String NEXT_BUTTON_ID = "nextButton";
private static final String LAYOUT_SELECT_ID = "layoutSelect";

private LegacyWindow mainWindow;
private NativeSelect layoutSelector;

@Override
public void init() {
nextButton.setId(NEXT_BUTTON_ID);
mainWindow = new LegacyWindow("LayoutTesterApplication");
setMainWindow(mainWindow);
nextLayout();

nextButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = -1577298910202253538L;

@Override
public void buttonClick(ClickEvent event) {
nextLayout();
}
});
}

private void nextLayout() {
try {
mainWindow.removeAllComponents();
HorizontalLayout vlo = new HorizontalLayout();
vlo.setSpacing(true);
++layoutIndex;
if (layoutIndex >= layoutGetters.length) {
layoutIndex = 0;
}
mainWindow.addComponent(vlo);
vlo.addComponent(nextButton);
vlo.addComponent(getLayoutTypeSelect());
vlo.addComponent(new UndefWideLabel(getLayoutGetterMethod(
layoutGetters[layoutIndex]).getName()));

Layout lo = null;
if (layoutSelector.getValue() == VerticalLayout.class) {
lo = getVerticalTestLayout(layoutIndex);
} else if (layoutSelector.getValue() == HorizontalLayout.class) {
lo = getHorizontalTestLayout(layoutIndex);
} else if (layoutSelector.getValue() == GridLayout.class) {
lo = getGridTestLayout(layoutIndex);
}
if (lo != null) {
lo.addStyleName(Reindeer.LAYOUT_BLUE);
mainWindow.addComponent(lo);
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

private Method getLayoutGetterMethod(String method) {
try {
return AbstractLayoutTests.class.getDeclaredMethod(method);
} catch (SecurityException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

public Layout getVerticalTestLayout(int index) throws Exception {
VerticalLayoutTests vlotest = new VerticalLayoutTests(this);
return (Layout) getLayoutGetterMethod(layoutGetters[index]).invoke(
vlotest, (Object[]) null);
}

public Layout getHorizontalTestLayout(int index) throws Exception {
HorizontalLayoutTests hlotest = new HorizontalLayoutTests(this);
return (Layout) getLayoutGetterMethod(layoutGetters[index]).invoke(
hlotest, (Object[]) null);
}

public Layout getGridTestLayout(int index) throws Exception {
GridLayoutTests hlotest = new GridLayoutTests(this);
return (Layout) getLayoutGetterMethod(layoutGetters[index]).invoke(
hlotest, (Object[]) null);
}

private NativeSelect getLayoutTypeSelect() {
if (layoutSelector == null) {
layoutSelector = new NativeSelect();
layoutSelector.setId(LAYOUT_SELECT_ID);
layoutSelector.addItem(VerticalLayout.class);
layoutSelector.addItem(HorizontalLayout.class);
layoutSelector.addItem(GridLayout.class);
layoutSelector.setNullSelectionAllowed(false);
layoutSelector.setImmediate(true);
layoutSelector.select(VerticalLayout.class);
layoutSelector.addListener(new Property.ValueChangeListener() {
private static final long serialVersionUID = -605319614765838359L;

@Override
public void valueChange(ValueChangeEvent event) {
layoutIndex = -1;
nextLayout();
}
});
}
return layoutSelector;
}

@Override
protected String getDescription() {
return "Test application for VerticalLayout, HorizontalLayout, and GridLayout";
}

@Override
protected Integer getTicketNumber() {
return 5334;
}

}

+ 0
- 132
uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java View File

@@ -1,132 +0,0 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.Select;

import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.VerticalLayout;

public class LayoutTesterApplicationTest extends MultiBrowserTest {

@Override
protected DesiredCapabilities getDesiredCapabilities() {
DesiredCapabilities cap = new DesiredCapabilities(
super.getDesiredCapabilities());
cap.setCapability("nativeEvents", false);

return cap;
}

Map<String, Integer> numberOfSubTests = new HashMap<String, Integer>();
private Set<String> tableOrIconsTests = new HashSet<String>();

{
numberOfSubTests.put("getExpandRatiosTests", 3);
numberOfSubTests.put("getLayoutSizingTests", 4);
numberOfSubTests.put("getComponentAddReplaceMoveTests", 4);
numberOfSubTests.put("getMarginSpacingTests", 4);
numberOfSubTests.put("getComponentSizingTests", 3);

tableOrIconsTests.add("getComponentSizingTests");
tableOrIconsTests.add("getExpandRatiosTests");
tableOrIconsTests.add("getLayoutSizingTests");
tableOrIconsTests.add("getMarginSpacingTests");
tableOrIconsTests.add("getIconsTests");

}

@Test
public void verticalLayout() throws Exception {
openTestURL();
runTest(VerticalLayout.class);
}

@Test
public void horizontalLayout() throws Exception {
openTestURL();
runTest(HorizontalLayout.class);
}

@Test
public void gridLayout() throws Exception {
numberOfSubTests.put("getComponentAddReplaceMoveTests", 6);
numberOfSubTests.put("getComponentSizingTests", 4);
numberOfSubTests.put("getExpandRatiosTests", 4);

openTestURL();
runTest(GridLayout.class);
}

private void runTest(Class<?> layoutClass) throws Exception {
new Select(vaadinElementById("layoutSelect").findElement(
By.xpath("select")))
.selectByVisibleText(layoutClass.toString());

for (String subTest : LayoutTesterApplication.layoutGetters) {
compareScreen(subTest);
Integer subTests = numberOfSubTests.get(subTest);
if (subTests != null) {
for (int i = 1; i <= subTests; i++) {
clickAndCompareScreen(subTest, "testButton" + i);
}
}

hitButton("nextButton");
}

}

/**
* Clicks the button with the given id and compares the result to a
* screenshot named 'screenshotPrefix'-buttonCaption.
*
* @param screenshotPrefix
* @param buttonId
* @throws Exception
*/
private void clickAndCompareScreen(String screenshotPrefix, String buttonId)
throws Exception {
hitButton(buttonId);

if (needsDelayToStabilize(screenshotPrefix)) {
// Table does some extra layout phase and TestBench does not always
// take this into account, grabbing screenshots before the layout
// phase is done (see #12866).
sleep(500);
}
compareScreen(screenshotPrefix + "-"
+ sanitize(driver.findElement(By.id(buttonId)).getText()));
}

private boolean needsDelayToStabilize(String screenshotPrefix) {
return tableOrIconsTests.contains(screenshotPrefix);
}

private String sanitize(String text) {
return text.replace("%", "pct").replaceAll("[^a-zA-Z0-9]", "-");
}
}

+ 36
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMove.java View File

@@ -0,0 +1,36 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMove;
import com.vaadin.ui.VerticalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class VAddReplaceMove extends BaseAddReplaceMove {

/**
* @param layoutClass
*/
public VAddReplaceMove() {
super(VerticalLayout.class);
}
}

+ 27
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMoveTest.java View File

@@ -0,0 +1,27 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMoveTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public class VAddReplaceMoveTest extends BaseAddReplaceMoveTest {

}

+ 25
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignment.java View File

@@ -0,0 +1,25 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.tests.layouts.layouttester.BaseAlignment;
import com.vaadin.ui.VerticalLayout;

public class VAlignment extends BaseAlignment {
public VAlignment() {
super(VerticalLayout.class);
}
}

+ 21
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java View File

@@ -0,0 +1,21 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.tests.layouts.layouttester.BaseAlignmentTest;

public class VAlignmentTest extends BaseAlignmentTest {
}

+ 38
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaption.java View File

@@ -0,0 +1,38 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseCaption;
import com.vaadin.ui.VerticalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class VCaption extends BaseCaption {

/**
* @param layoutClass
*/
public VCaption() {
super(VerticalLayout.class);
// TODO Auto-generated constructor stub
}

}

+ 27
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaptionTest.java View File

@@ -0,0 +1,27 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.tests.layouts.layouttester.BaseCaptionTest;

/**
*
* @since
* @author Vaadin Ltd
*/
public class VCaptionTest extends BaseCaptionTest {

}

+ 37
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizing.java View File

@@ -0,0 +1,37 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseComponentSizing;
import com.vaadin.ui.VerticalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class VComponentSizing extends BaseComponentSizing {

/**
* @param layoutClass
*/
public VComponentSizing() {
super(VerticalLayout.class);
}

}

+ 21
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizingTest.java View File

@@ -0,0 +1,21 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.tests.layouts.layouttester.BaseComponentSizingTest;

public class VComponentSizingTest extends BaseComponentSizingTest {
}

+ 37
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIcon.java View File

@@ -0,0 +1,37 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseIcon;
import com.vaadin.ui.VerticalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class VIcon extends BaseIcon {

/**
* @param layoutClass
*/
public VIcon() {
super(VerticalLayout.class);
}

}

+ 21
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIconTest.java View File

@@ -0,0 +1,21 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.tests.layouts.layouttester.BaseIconTest;

public class VIconTest extends BaseIconTest {
}

+ 37
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpand.java View File

@@ -0,0 +1,37 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseLayoutExpand;
import com.vaadin.ui.VerticalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class VLayoutExpand extends BaseLayoutExpand {

/**
* @param layoutClass
*/
public VLayoutExpand() {
super(VerticalLayout.class);
}

}

+ 27
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpandTest.java View File

@@ -0,0 +1,27 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.tests.layouts.layouttester.BaseLayoutExpandTest;


/**
*
* @since
* @author Vaadin Ltd
*/
public class VLayoutExpandTest extends BaseLayoutExpandTest {
}

+ 37
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacing.java View File

@@ -0,0 +1,37 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseLayoutForSpacingMargin;
import com.vaadin.ui.VerticalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class VLayoutMarginSpacing extends BaseLayoutForSpacingMargin {

/**
* @param layoutClass
*/
public VLayoutMarginSpacing() {
super(VerticalLayout.class);
}

}

+ 22
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacingTest.java View File

@@ -0,0 +1,22 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.tests.layouts.layouttester.BaseLayoutMarginSpacingTest;

public class VLayoutMarginSpacingTest extends BaseLayoutMarginSpacingTest {

}

+ 36
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegError.java View File

@@ -0,0 +1,36 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseRegError;
import com.vaadin.ui.VerticalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class VLayoutRegError extends BaseRegError {

/**
* @param layoutClass
*/
public VLayoutRegError() {
super(VerticalLayout.class);
}
}

+ 27
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java View File

@@ -0,0 +1,27 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest;


/**
*
* @since
* @author Vaadin Ltd
*/
public class VLayoutRegErrorTest extends BaseLayoutRegErrorTest {
}

+ 37
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizing.java View File

@@ -0,0 +1,37 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.annotations.Theme;
import com.vaadin.tests.layouts.layouttester.BaseComponentSizing;
import com.vaadin.ui.VerticalLayout;

/**
*
* @since
* @author Vaadin Ltd
*/

public class VLayoutSizing extends BaseComponentSizing {

/**
* @param layoutClass
*/
public VLayoutSizing() {
super(VerticalLayout.class);
}

}

+ 27
- 0
uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizingTest.java View File

@@ -0,0 +1,27 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.layouts.layouttester.VLayout;

import com.vaadin.tests.layouts.layouttester.BaseLayoutSizingTest;


/**
*
* @since
* @author Vaadin Ltd
*/
public class VLayoutSizingTest extends BaseLayoutSizingTest {
}

+ 0
- 634
uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java View File

@@ -1,634 +0,0 @@
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.LegacyApplication;
import com.vaadin.server.Resource;
import com.vaadin.server.SystemError;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.UserError;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.Link;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.Select;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;

public class VerticalLayoutTests extends AbstractLayoutTests {

public VerticalLayoutTests(LegacyApplication application) {
super();
}

@Override
protected Layout getAlignmentTests() {
Layout baseLayout = getBaseLayout();
((HorizontalLayout) baseLayout).setSpacing(true);
VerticalLayout vlo = getTestLaytout();
AbstractComponent[] components = new AbstractComponent[9];
Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_CENTER,
Alignment.BOTTOM_LEFT, Alignment.BOTTOM_RIGHT,
Alignment.MIDDLE_CENTER, Alignment.MIDDLE_LEFT,
Alignment.MIDDLE_RIGHT, Alignment.TOP_CENTER,
Alignment.TOP_LEFT, Alignment.TOP_RIGHT };

for (int i = 0; i < components.length / 2; i++) {
components[i] = new TextField();
((TextField) components[i]).setValue("FIELD " + i);
vlo.addComponent(components[i]);
vlo.setComponentAlignment(components[i], alignments[i]);
vlo.addComponent(new Label("<hr />", ContentMode.HTML));
}
baseLayout.addComponent(vlo);
vlo = getTestLaytout();
for (int i = components.length / 2; i < components.length; i++) {
components[i] = new TextField();
((TextField) components[i]).setValue("FIELD " + i);
vlo.addComponent(components[i]);
vlo.setComponentAlignment(components[i], alignments[i]);
vlo.addComponent(new Label("<hr />", ContentMode.HTML));
}
baseLayout.addComponent(vlo);
return baseLayout;
}

@Override
protected Layout getCaptionsTests() {
Layout baseLayout = getBaseLayout();
VerticalLayout vlo = getTestLaytout();
AbstractComponent component = null;

String[] captions = new String[] {
"",
"abcdefghijklmnopq",
"abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" };

for (int i = 0; i < captions.length; i++) {
component = new TextField();
((TextField) component).setValue("FIELD " + i);
component.setCaption(captions[i]);
vlo.addComponent(component);
}
for (int i = 0; i < captions.length; i++) {
component = new Label();
((Label) component).setValue("Label " + i);
component.setCaption(captions[i]);
vlo.addComponent(component);
}
baseLayout.addComponent(vlo);
vlo = getTestLaytout();
for (int i = 0; i < captions.length; i++) {
component = new Select();
component.setCaption(captions[i]);
component.setIcon(new ThemeResource(LOCK_16_PNG));
vlo.addComponent(component);
}
for (int i = 0; i < captions.length; i++) {
component = getTestTabsheet();
component.setCaption(captions[i]);
component.setComponentError(new UserError(""));
vlo.addComponent(component);
}
baseLayout.addComponent(vlo);
return baseLayout;
}

@Override
protected Layout getComponentAddReplaceMoveTests() {
Layout baseLayout = getBaseLayout();
final VerticalLayout vlo = getTestLaytout();
final VerticalLayout vlo2 = getTestLaytout();

// Set undefined height to avoid expanding
vlo2.setHeight(null);

final HorizontalLayout source = new HorizontalLayout();
source.addComponent(new Label("OTHER LABEL 1"));
source.addComponent(new Label("OTHER LABEL 2"));

final AbstractComponent c1 = new Button("BUTTON");
final AbstractComponent c2 = new Label("<b>LABEL</b>", ContentMode.HTML);
final AbstractComponent c3 = new Table("TABLE");
c3.setHeight("100px");
c3.setWidth("100%");

final Button addButton = new Button("Test add");
final Button replaceButton = new Button("Test replace");
final Button moveButton = new Button("Test move");
final Button removeButton = new Button("Test remove");
addButton.setId("testButton1");
replaceButton.setId("testButton2");
moveButton.setId("testButton3");
removeButton.setId("testButton4");

replaceButton.setEnabled(false);
moveButton.setEnabled(false);
removeButton.setEnabled(false);

addButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.addComponent(new TextField());
addButton.setEnabled(false);
replaceButton.setEnabled(true);
}
});
replaceButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.replaceComponent(c1, c3);
replaceButton.setEnabled(false);
moveButton.setEnabled(true);
}
});
moveButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.moveComponentsFrom(source);
moveButton.setEnabled(false);
removeButton.setEnabled(true);
}
});
removeButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.removeComponent(c1);
vlo2.removeComponent(c2);
removeButton.setEnabled(false);
}
});

vlo.addComponent(addButton);
vlo.addComponent(replaceButton);
vlo.addComponent(moveButton);
vlo.addComponent(removeButton);

baseLayout.addComponent(vlo);
vlo2.addComponent(c1);
vlo2.addComponent(c2);
vlo2.addComponent(c3);
baseLayout.addComponent(vlo2);
return baseLayout;
}

@Override
protected Layout getComponentSizingTests() {
Layout baseLayout = getBaseLayout();
final VerticalLayout vlo = getTestLaytout();

final AbstractComponent c = getTestTable();

final Button biggerButton = new Button("full size");
final Button smallerButton = new Button("200 px width");
final Button originalButton = new Button("undefined size and add");
biggerButton.setId("testButton1");
smallerButton.setId("testButton2");
originalButton.setId("testButton3");
vlo.addComponent(biggerButton);
vlo.addComponent(smallerButton);
vlo.addComponent(originalButton);
baseLayout.addComponent(vlo);
final VerticalLayout vlo2 = getTestLaytout();
vlo2.addComponent(c);
baseLayout.addComponent(vlo2);

biggerButton.setEnabled(true);
smallerButton.setEnabled(false);
originalButton.setEnabled(false);

biggerButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
c.setSizeFull();
biggerButton.setEnabled(false);
smallerButton.setEnabled(true);
}
});
smallerButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
c.setWidth("200px");
smallerButton.setEnabled(false);
originalButton.setEnabled(true);
}
});
originalButton.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
originalButton.setEnabled(false);
c.setSizeUndefined();
((Table) c)
.addItem(
new Object[] { "VYVTCTC VYVYV ECECCE NIDSD SDMPOM" },
3);
}
});

return baseLayout;
}

@Override
protected Layout getLayoutSizingTests() {
Layout baseLayout = getBaseLayout();
final VerticalLayout vlo = getTestLaytout();

vlo.setSpacing(false);
vlo.setMargin(false);

final AbstractComponent c1 = getTestTable();
c1.setSizeFull();
final AbstractComponent c2 = getTestTable();
c2.setSizeFull();

final Button button1 = new Button("Set fixed height 350px");
final Button button2 = new Button(
"Set undefined size and add component");
final Button button3 = new Button("Set fixed width and height 75%");
final Button button4 = new Button("Set size full");

button1.setId("testButton1");
button2.setId("testButton2");
button3.setId("testButton3");
button4.setId("testButton4");

vlo.addComponent(button1);
vlo.addComponent(button2);
vlo.addComponent(button3);
vlo.addComponent(button4);
baseLayout.addComponent(vlo);
final VerticalLayout vlo2 = getTestLaytout();

button1.setEnabled(true);
button2.setEnabled(false);
button3.setEnabled(false);
button4.setEnabled(false);

vlo2.addComponent(c1);
vlo2.addComponent(new Label(
"<div style='height: 1px'></div><hr /><div style='height: 1px'></div>",
ContentMode.HTML));
vlo2.addComponent(c2);
vlo2.setExpandRatio(c1, 0.5f);
vlo2.setExpandRatio(c2, 0.5f);
baseLayout.addComponent(vlo2);

button1.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.setHeight("350px");
button1.setEnabled(false);
button2.setEnabled(true);
}
});
button2.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.setSizeUndefined();
Label newLabel = new Label("--- NEW LABEL ---");
newLabel.setSizeUndefined();
vlo2.addComponent(newLabel);
button2.setEnabled(false);
button3.setEnabled(true);
}
});
button3.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.setWidth("75%");
vlo2.setHeight("75%");
button3.setEnabled(false);
button4.setEnabled(true);
}
});
button4.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.setSizeFull();
button4.setEnabled(false);
}
});

return baseLayout;
}

@Override
protected Layout getExpandRatiosTests() {
Layout baseLayout = getBaseLayout();
final VerticalLayout vlo = getTestLaytout();

final AbstractComponent c1 = getTestTable();
c1.setSizeFull();
final AbstractComponent c2 = getTestTable();
c2.setSizeFull();

final Button button1 = new Button("Expand to 1/undefined");
button1.setId("testButton1");
final Button button2 = new Button("Expand to 0.5/0.5");
button2.setId("testButton2");
final Button button3 = new Button("Expand to 0.75/0.25");
button3.setId("testButton3");

vlo.addComponent(button1);
vlo.addComponent(button2);
vlo.addComponent(button3);
button1.setEnabled(true);
button2.setEnabled(false);
button3.setEnabled(false);

baseLayout.addComponent(vlo);
final VerticalLayout vlo2 = getTestLaytout();

vlo2.addComponent(c1);
vlo2.addComponent(c2);
baseLayout.addComponent(vlo2);

button1.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.setExpandRatio(c1, 1.0f);
button1.setEnabled(false);
button2.setEnabled(true);
}
});
button2.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.setExpandRatio(c1, 0.5f);
vlo2.setExpandRatio(c2, 0.5f);
button2.setEnabled(false);
button3.setEnabled(true);
}
});
button3.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.setExpandRatio(c1, 0.75f);
vlo2.setExpandRatio(c2, 0.25f);
button3.setEnabled(false);
}
});
return baseLayout;
}

@Override
protected Layout getIconsTests() {
Layout baseLayout = getBaseLayout();
VerticalLayout vlo = getTestLaytout();
AbstractComponent[] components = new AbstractComponent[2];

Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG),
new ThemeResource(LOCK_16_PNG) };

for (int i = 0; i < components.length; i++) {
components[i] = new TextField();
((TextField) components[i]).setValue("FIELD " + i);
components[i].setIcon(icons[i]);
components[i]
.setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd");
vlo.addComponent(components[i]);
}

for (int i = 0; i < components.length; i++) {
components[i] = new Label();
((Label) components[i]).setValue("Label " + i);
components[i].setIcon(icons[i]);
vlo.addComponent(components[i]);
}

for (int i = 0; i < components.length; i++) {
components[i] = new Select();
components[i].setIcon(icons[i]);
vlo.addComponent(components[i]);
}
baseLayout.addComponent(vlo);
final VerticalLayout vlo2 = getTestLaytout();
for (int i = 0; i < components.length; i++) {
components[i] = new Button();
components[i].setComponentError(new UserError(
"component error, user error"));
components[i].setIcon(icons[i]);
vlo2.addComponent(components[i]);
}

for (int i = 0; i < components.length; i++) {
components[i] = new Link("Link", null);
components[i].setIcon(icons[i]);
vlo2.addComponent(components[i]);
}
baseLayout.addComponent(vlo2);
return baseLayout;
}

@Override
protected Layout getMarginSpacingTests() {
Layout baseLayout = getBaseLayout();
final VerticalLayout vlo = getTestLaytout();
vlo.setSpacing(false);
vlo.setMargin(false);

final AbstractComponent c1 = getTestTable();
c1.setSizeFull();
final AbstractComponent c2 = getTestTable();
c2.setSizeFull();

final Button button1 = new Button("Set margin on");
final Button button2 = new Button("Set spacing on");
final Button button3 = new Button("Set margin off");
final Button button4 = new Button("Set spacing off");
button1.setId("testButton1");
button2.setId("testButton2");
button3.setId("testButton3");
button4.setId("testButton4");

vlo.addComponent(button1);
vlo.addComponent(button2);
vlo.addComponent(button3);
vlo.addComponent(button4);
button1.setEnabled(true);
button2.setEnabled(false);
button3.setEnabled(false);
button4.setEnabled(false);

baseLayout.addComponent(vlo);
final VerticalLayout vlo2 = getTestLaytout();

vlo2.addComponent(c1);
// Must add something around the hr to avoid the margins collapsing
vlo2.addComponent(new Label(
"<div style='height: 1px'></div><hr /><div style='height: 1px'></div>",
ContentMode.HTML));
vlo2.addComponent(c2);
vlo2.setExpandRatio(c1, 0.5f);
vlo2.setExpandRatio(c2, 0.5f);
baseLayout.addComponent(vlo2);

button1.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.setMargin(true);
button1.setEnabled(false);
button2.setEnabled(true);
}
});
button2.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.setSpacing(true);
button2.setEnabled(false);
button3.setEnabled(true);
}
});
button3.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.setMargin(false);
button3.setEnabled(false);
button4.setEnabled(true);
}
});
button4.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 7716267156088629379L;

@Override
public void buttonClick(ClickEvent event) {
vlo2.setSpacing(false);
button4.setEnabled(false);
}
});

return baseLayout;
}

@Override
protected Layout getRequiredErrorIndicatorsTests() {
Layout baseLayout = getBaseLayout();
VerticalLayout vlo = getTestLaytout();
AbstractComponent[] components = new AbstractComponent[4];
components[0] = new Label("LABEL");
components[0].setSizeUndefined();
components[1] = new Button("BUTTON");
components[2] = getTestTable();
components[3] = getTestTabsheet();
components[3].setIcon(new ThemeResource(LOCK_16_PNG));

AbstractField<?>[] fields = new AbstractField<?>[6];
fields[0] = new TextField();
fields[0].setRequired(true);
fields[0].setValidationVisible(true);
fields[0].setRequiredError("required error");

fields[1] = new TextField();
((TextField) fields[1]).setValue("TEXTFIELD2");
fields[1]
.setComponentError(new UserError("component error, user error"));

fields[2] = new Select();
fields[2].setComponentError(new SystemError(
"component error, system error"));
fields[3] = new DateField();
fields[3].setComponentError(new SystemError(
"component error, system error"));

fields[4] = new CheckBox();
fields[4]
.setComponentError(new UserError("component error, user error"));

fields[5] = new NativeSelect();
fields[5].setRequired(true);
fields[5].setValidationVisible(true);
fields[5].setRequiredError("required error");
fields[5]
.setComponentError(new UserError("component error, user error"));
fields[5].setIcon(new ThemeResource(CALENDAR_32_PNG));

for (int i = 0; i < components.length; i++) {
components[i].setComponentError(new UserError(
"component error, user error"));
vlo.addComponent(components[i]);
}
baseLayout.addComponent(vlo);
final VerticalLayout vlo2 = getTestLaytout();
for (int i = 0; i < fields.length; i++) {
vlo2.addComponent(fields[i]);
}

baseLayout.addComponent(vlo2);
return baseLayout;
}

private HorizontalLayout getBaseLayout() {
HorizontalLayout hlo = new HorizontalLayout();
hlo.setSizeUndefined();
return hlo;
}

private VerticalLayout getTestLaytout() {
VerticalLayout vlo = new VerticalLayout();
vlo.setHeight("500px");
vlo.setWidth("400px");
return vlo;
}

private AbstractComponent getTestTabsheet() {
TabSheet tabsheet = new TabSheet();
tabsheet.setSizeUndefined();
tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource(
GLOBE_16_PNG));
tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null);
return tabsheet;
}

private Table getTestTable() {
Table t = new Table();
t.setSizeUndefined();
t.setPageLength(5);
t.addContainerProperty("test", String.class, null);
t.addItem(new Object[] { "qwertyuiop asdfghjköäxccvbnm,m,." }, 1);
t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2);
return t;
}
}

Loading…
Cancel
Save