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.3KB

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