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

TestBase.java 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package com.vaadin.tests.components;
  2. import com.vaadin.shared.ui.ContentMode;
  3. import com.vaadin.ui.Component;
  4. import com.vaadin.ui.Label;
  5. import com.vaadin.ui.LegacyWindow;
  6. import com.vaadin.ui.VerticalLayout;
  7. /**
  8. *
  9. * @deprecated Use {@link AbstractReindeerTestUI} or
  10. * {@link AbstractTestUIWithLog} instead. TestBase is a
  11. * LegacyApplication
  12. */
  13. @Deprecated
  14. public abstract class TestBase extends AbstractTestCase {
  15. @Override
  16. public final void init() {
  17. window = new LegacyWindow(getClass().getName());
  18. setMainWindow(window);
  19. window.getContent().setSizeFull();
  20. Label label = new Label(getDescription(), ContentMode.HTML);
  21. if (label.getValue() == null || label.getValue().isEmpty()) {
  22. // This is only an ugly hack to be screenshot compatible to be able
  23. // to detect real problems when introducing IE font-size/line-height
  24. // fixes
  25. label.setValue(" ");
  26. if (getBrowser().isIE()
  27. && getBrowser().getBrowserMajorVersion() == 9) {
  28. label.setHeight("13.8px");
  29. } else {
  30. label.setHeight("15px");
  31. }
  32. }
  33. label.setWidth("100%");
  34. window.addComponent(label);
  35. layout = new VerticalLayout();
  36. layout.setMargin(false);
  37. layout.setSpacing(false);
  38. window.addComponent(layout);
  39. ((VerticalLayout) window.getContent()).setExpandRatio(layout, 1);
  40. setup();
  41. }
  42. private LegacyWindow window;
  43. @Override
  44. public void setMainWindow(LegacyWindow mainWindow) {
  45. if (mainWindow != window) {
  46. throw new IllegalStateException(
  47. "You should not set your own main window when using TestBase. If you need to use a custom Window as the main window, use AbstractTestCase instead.");
  48. }
  49. super.setMainWindow(mainWindow);
  50. }
  51. private VerticalLayout layout;
  52. public TestBase() {
  53. }
  54. protected VerticalLayout getLayout() {
  55. return layout;
  56. }
  57. protected abstract void setup();
  58. protected void addComponent(Component c) {
  59. getLayout().addComponent(c);
  60. }
  61. protected void removeComponent(Component c) {
  62. getLayout().removeComponent(c);
  63. }
  64. protected void replaceComponent(Component oldComponent,
  65. Component newComponent) {
  66. getLayout().replaceComponent(oldComponent, newComponent);
  67. }
  68. }