summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2011-03-03 15:50:29 +0000
committerArtur Signell <artur.signell@itmill.com>2011-03-03 15:50:29 +0000
commit90683341534163ccbc695606b1f6cafa754a6438 (patch)
tree21d931b0d8d88efe49175b7df13c1e3cd6b10338 /tests
parent4afbe794fce8c824def80aad0b04f93f9ad21d45 (diff)
downloadvaadin-framework-90683341534163ccbc695606b1f6cafa754a6438.tar.gz
vaadin-framework-90683341534163ccbc695606b1f6cafa754a6438.zip
Test for #6578 Handling of icons in caption is slow in FF/IE
svn changeset:17584/svn branch:6.5
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/vaadin/tests/VaadinClasses.java15
-rw-r--r--tests/src/com/vaadin/tests/components/caption/IconsInCaption.java136
2 files changed, 151 insertions, 0 deletions
diff --git a/tests/src/com/vaadin/tests/VaadinClasses.java b/tests/src/com/vaadin/tests/VaadinClasses.java
index 3508f84059..9aef3f5277 100644
--- a/tests/src/com/vaadin/tests/VaadinClasses.java
+++ b/tests/src/com/vaadin/tests/VaadinClasses.java
@@ -20,9 +20,14 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DragAndDropWrapper;
+import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.LoginForm;
import com.vaadin.ui.PopupView;
+import com.vaadin.ui.SplitPanel;
+import com.vaadin.ui.VerticalSplitPanel;
+import com.vaadin.ui.Window;
+@SuppressWarnings("deprecation")
public class VaadinClasses {
public static void main(String[] args) {
@@ -68,6 +73,16 @@ public class VaadinClasses {
return classes;
}
+ public static List<Class<? extends ComponentContainer>> getComponentContainersSupportingUnlimitedNumberOfComponents() {
+ List<Class<? extends ComponentContainer>> classes = getComponentContainersSupportingAddRemoveComponent();
+ classes.remove(SplitPanel.class);
+ classes.remove(VerticalSplitPanel.class);
+ classes.remove(HorizontalSplitPanel.class);
+ classes.remove(Window.class);
+
+ return classes;
+ }
+
@SuppressWarnings({ "unchecked", "rawtypes" })
public static List<Class<? extends AbstractComponentTest<?>>> getBasicComponentTests() {
try {
diff --git a/tests/src/com/vaadin/tests/components/caption/IconsInCaption.java b/tests/src/com/vaadin/tests/components/caption/IconsInCaption.java
new file mode 100644
index 0000000000..926088ff48
--- /dev/null
+++ b/tests/src/com/vaadin/tests/components/caption/IconsInCaption.java
@@ -0,0 +1,136 @@
+package com.vaadin.tests.components.caption;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.VaadinClasses;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.Embedded;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+public class IconsInCaption extends TestBase {
+
+ private static final String TYPE_EMBEDDED = "Embedded";
+ private static final String TYPE_CAPTION = "In caption";
+
+ private static final String[] icons = new String[] { "arrow-down.png",
+ "arrow-left.png", "arrow-right.png", "arrow-up.png",
+ "attention.png", "calendar.png", "cancel.png", "document.png",
+ "document-add.png", "document-delete.png", "document-doc.png",
+ "document-image.png", "document-pdf.png", "document-ppt.png",
+ "document-txt.png", "document-web.png", "document-xsl.png",
+ "email.png", "email-reply.png", "email-send.png", "folder.png",
+ "folder-add.png", "folder-delete.png", "globe.png", "help.png",
+ "lock.png", "note.png", "ok.png", "reload.png", "settings.png",
+ "trash.png", "trash-full.png", "user.png", "users.png" };
+
+ private static final String[] sizes = new String[] { "16", "32", "64" };
+
+ private ComponentContainer container = new VerticalLayout();
+
+ private Log log = new Log(5);
+
+ private ComboBox containerSelect;
+
+ private ComboBox iconTypeSelect;
+
+ @Override
+ protected void setup() {
+ iconTypeSelect = new ComboBox("Icon container");
+ iconTypeSelect.addItem(TYPE_EMBEDDED);
+ iconTypeSelect.addItem(TYPE_CAPTION);
+ iconTypeSelect.setImmediate(true);
+ iconTypeSelect.setNullSelectionAllowed(false);
+ iconTypeSelect.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ updateContainer();
+ }
+ });
+
+ containerSelect = new ComboBox("Container");
+ for (Class<? extends ComponentContainer> cc : VaadinClasses
+ .getComponentContainersSupportingUnlimitedNumberOfComponents()) {
+ containerSelect.addItem(cc);
+ }
+ containerSelect.setImmediate(true);
+ containerSelect.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ updateContainer();
+
+ }
+ });
+
+ addComponent(log);
+ addComponent(iconTypeSelect);
+ addComponent(containerSelect);
+ addComponent(container);
+
+ iconTypeSelect.setValue(TYPE_CAPTION);
+ containerSelect.setValue(VerticalLayout.class);
+ }
+
+ protected void updateContainer() {
+ Class<? extends ComponentContainer> containerClass = (Class<? extends ComponentContainer>) containerSelect
+ .getValue();
+ if (containerClass == null) {
+ return;
+ }
+
+ Object iconType = iconTypeSelect.getValue();
+ try {
+ ComponentContainer newContainer = createContainer(containerClass,
+ iconType);
+ replaceComponent(container, newContainer);
+ container = newContainer;
+ log.log("Container changed to " + containerClass.getName() + "/"
+ + iconType);
+ } catch (Exception e) {
+ log.log("Create container failed for " + containerClass.getName()
+ + ": " + e.getMessage());
+ e.printStackTrace();
+ }
+
+ }
+
+ private static ComponentContainer createContainer(
+ Class<? extends ComponentContainer> containerClass, Object iconType)
+ throws InstantiationException, IllegalAccessException {
+ ComponentContainer container = containerClass.newInstance();
+ for (String size : sizes) {
+ Label title = new Label("<h3>" + size + "x" + size + "</h3>",
+ Label.CONTENT_XHTML);
+ container.addComponent(title);
+ for (String icon : icons) {
+ ThemeResource res = new ThemeResource("../runo/icons/" + size
+ + "/" + icon);
+ if (TYPE_CAPTION.equals(iconType)) {
+ Label name = new Label();
+ name.setCaption(icon);
+ name.setIcon(res);
+ container.addComponent(name);
+ } else if (TYPE_EMBEDDED.equals(iconType)) {
+ Embedded e = new Embedded(icon, res);
+ container.addComponent(e);
+ }
+ }
+ }
+
+ return container;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Test for comparing rendering speed of icons in a caption and in an Embedded component in different component containers.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6578;
+ }
+
+}