diff options
author | Chris Goldthorpe | 2007-10-15 16:27:06 +0000 |
---|---|---|
committer | Chris Goldthorpe | 2007-10-15 16:27:06 +0000 |
commit | 825481a234941257731848482319a12dad848e9a (patch) | |
tree | f10c571f606c5fc02e1508c04a0f8fa930748d3b /org.eclipse.ua.tests | |
parent | 43aece94a7a19ed1703448d99f4f3aa14e4fe40a (diff) | |
download | eclipse.platform.ua-825481a234941257731848482319a12dad848e9a.tar.gz eclipse.platform.ua-825481a234941257731848482319a12dad848e9a.tar.xz eclipse.platform.ua-825481a234941257731848482319a12dad848e9a.zip |
Diffstat (limited to 'org.eclipse.ua.tests')
12 files changed, 10 insertions, 751 deletions
diff --git a/org.eclipse.ua.tests/.classpath b/org.eclipse.ua.tests/.classpath index 1a880ac90..01c312f45 100644 --- a/org.eclipse.ua.tests/.classpath +++ b/org.eclipse.ua.tests/.classpath @@ -1,11 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry path="base" kind="src"/> - <classpathentry path="cheatsheet" kind="src"/> - <classpathentry path="intro" kind="src"/> - <classpathentry path="help" kind="src"/> - <classpathentry path="forms" kind="src"/> - <classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"/> - <classpathentry path="org.eclipse.pde.core.requiredPlugins" kind="con"/> - <classpathentry path="bin" kind="output"/> + <classpathentry kind="src" path="base"/> + <classpathentry kind="src" path="cheatsheet"/> + <classpathentry kind="src" path="intro"/> + <classpathentry kind="src" path="help"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> </classpath> diff --git a/org.eclipse.ua.tests/META-INF/MANIFEST.MF b/org.eclipse.ua.tests/META-INF/MANIFEST.MF index 9b652083a..b697caca5 100644 --- a/org.eclipse.ua.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.ua.tests/META-INF/MANIFEST.MF @@ -15,8 +15,8 @@ Require-Bundle: org.junit, org.eclipse.ui, org.eclipse.ui.cheatsheets, org.eclipse.ui.intro, - org.eclipse.ui.forms, - org.eclipse.ui.intro.universal + org.eclipse.ui.intro.universal, + org.eclipse.ui.forms Eclipse-LazyStart: true Bundle-Vendor: Eclipse.org Bundle-ClassPath: ua-tests.jar diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/AllPerformanceTests.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/AllPerformanceTests.java index de2847060..225690ec5 100644 --- a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/AllPerformanceTests.java +++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/AllPerformanceTests.java @@ -14,7 +14,6 @@ import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.ua.tests.cheatsheet.AllCheatSheetPerformanceTests; -import org.eclipse.ua.tests.forms.performance.AllFormsPerformanceTests; /* * Tests all user assistance performance (automated). @@ -47,6 +46,5 @@ public class AllPerformanceTests extends TestSuite { */ //addTest(AllIntroPerformanceTests.suite()); - addTest(AllFormsPerformanceTests.suite()); } } diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/AllTests.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/AllTests.java index a726287ae..51e4e6b6e 100644 --- a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/AllTests.java +++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/AllTests.java @@ -14,7 +14,6 @@ import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.ua.tests.cheatsheet.AllCheatSheetTests; -import org.eclipse.ua.tests.forms.AllFormsTests; import org.eclipse.ua.tests.help.AllHelpTests; import org.eclipse.ua.tests.intro.AllIntroTests; @@ -37,6 +36,5 @@ public class AllTests extends TestSuite { addTest(AllCheatSheetTests.suite()); addTest(AllIntroTests.suite()); addTest(AllHelpTests.suite()); - addTest(AllFormsTests.suite()); } } diff --git a/org.eclipse.ua.tests/build.properties b/org.eclipse.ua.tests/build.properties index 076f5fbf1..e771f876b 100644 --- a/org.eclipse.ua.tests/build.properties +++ b/org.eclipse.ua.tests/build.properties @@ -21,5 +21,4 @@ output.ua-tests.jar = bin/ source.ua-tests.jar = base/,\ cheatsheet/,\ help/,\ - intro/,\ - forms/ + intro/ diff --git a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/AllFormsTests.java b/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/AllFormsTests.java deleted file mode 100644 index da587e8ff..000000000 --- a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/AllFormsTests.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ua.tests.forms; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.eclipse.ua.tests.forms.layout.AllLayoutTests; -import org.eclipse.ua.tests.forms.util.AllUtilityTests; - -/* - * Tests all cheat sheet functionality (automated). - */ -public class AllFormsTests extends TestSuite { - - /* - * Returns the entire test suite. - */ - public static Test suite() { - return new AllFormsTests(); - } - - /* - * Constructs a new test suite. - */ - public AllFormsTests() { - addTest(AllLayoutTests.suite()); - addTest(AllUtilityTests.suite()); - } -} diff --git a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/layout/AllLayoutTests.java b/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/layout/AllLayoutTests.java deleted file mode 100644 index 9c78a4c53..000000000 --- a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/layout/AllLayoutTests.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ua.tests.forms.layout; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllLayoutTests { - - public static Test suite() { - TestSuite suite = new TestSuite( - "org.eclipse.ua.tests.forms.AllLayoutTests"); - //$JUnit-BEGIN$ - suite.addTestSuite(TestTableWrapLayout.class); - //$JUnit-END$ - return suite; - } - -} diff --git a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/layout/TestTableWrapLayout.java b/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/layout/TestTableWrapLayout.java deleted file mode 100644 index 224e55bb4..000000000 --- a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/layout/TestTableWrapLayout.java +++ /dev/null @@ -1,210 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ua.tests.forms.layout; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.widgets.TableWrapData; -import org.eclipse.ui.forms.widgets.TableWrapLayout; - -import junit.framework.TestCase; - -public class TestTableWrapLayout extends TestCase { - - private final String A1 = "A"; - private final String A10 = "A A A A A A A A A A"; - private final String A20 = A10 + " " + A10; - private final String A40 = A20 + " " + A20; - private final String A80 = A40 + " " + A40; - - // Returns the width + left - private int rightEdge(Label lab) { - Rectangle r = lab.getBounds(); - return r.x + r.width; - } - - /** - * Test that labels with the WRAP property set do indeed wrap. - */ - public void testTableWrapLayoutNonWrappingLabels() { - Display display = PlatformUI.getWorkbench().getDisplay(); - Shell shell = new Shell(display); - shell.setSize(100, 300); - shell.setLayout(new FillLayout()); - Composite inner = new Composite(shell, SWT.V_SCROLL); - inner.setLayout(new TableWrapLayout()); - Label l1 = new Label(inner, SWT.NULL); - l1.setText(A10); - Label l2 = new Label(inner, SWT.NULL); - l2.setText(A80); - shell.layout(); - assertEquals(l1.getSize().y, l2.getSize().y); - assertTrue(l2.getSize().x > 100); - shell.dispose(); - } - - /** - * Test that labels with the WRAP property set do indeed wrap. - */ - // Test suppressed for now - does not pass but not sure if this is a bug - public void suppressed_testWrappingPoint() { - Display display = PlatformUI.getWorkbench().getDisplay(); - Shell shell = new Shell(display); - shell.setSize(300, 300); - shell.setLayout(new FillLayout()); - Composite inner = new Composite(shell, SWT.V_SCROLL); - TableWrapLayout tableWrapLayout = new TableWrapLayout(); - tableWrapLayout.leftMargin = 0; - tableWrapLayout.rightMargin = 0; - inner.setLayout(tableWrapLayout); - Label l1 = new Label(inner, SWT.WRAP); - l1.setText(A10); - shell.layout(); - int originalWidth = l1.getSize().x; - int originalHeight = l1.getSize().y; - shell.setSize(originalWidth, 300); - shell.layout(); - assertEquals(l1.getSize().y, originalHeight); - shell.setSize(originalWidth / 2, 300); - shell.layout(); - inner.layout(); - assertTrue(l1.getSize().y > originalHeight); - shell.dispose(); - } - - /** - * Test that labels with the WRAP property set do indeed wrap. - */ - // Test suppressed for now, see Bug 196686 - public void suppressed_testTableWrapLayoutWrappingLabels() { - Display display = PlatformUI.getWorkbench().getDisplay(); - Shell shell = new Shell(display); - shell.setSize(100, 300); - shell.setLayout(new FillLayout()); - Composite inner = new Composite(shell, SWT.V_SCROLL); - inner.setLayout(new TableWrapLayout()); - Label l1 = new Label(inner, SWT.WRAP); - l1.setText(A10); - Label l2 = new Label(inner, SWT.WRAP); - l2.setText(A80); - shell.layout(); - assertTrue(l1.getSize().y < l2.getSize().y); - assertTrue("Label is too wide for layout ", l1.getSize().x <= 100); - assertTrue("Label is too wide for layout ", l2.getSize().x <= 100); - assertTrue("Labels overlap", l2.getBounds().y >= l1.getBounds().y + l1.getBounds().height); - shell.dispose(); - } - - /** - * Test a 2x2 grid with unequal sizes - */ - public void testTableWrapLayoutTwoColumnsWrappingLabels() { - Display display = PlatformUI.getWorkbench().getDisplay(); - Shell shell = new Shell(display); - shell.setSize(100, 300); - shell.setLayout(new FillLayout()); - Composite inner = new Composite(shell, SWT.V_SCROLL); - TableWrapLayout tableWrapLayout = new TableWrapLayout(); - tableWrapLayout.numColumns = 2; - inner.setLayout(tableWrapLayout); - Label l1 = new Label(inner, SWT.WRAP); - l1.setText(A10); - Label l2 = new Label(inner, SWT.WRAP); - l2.setText(A20); - Label l3 = new Label(inner, SWT.WRAP); - l3.setText(A40); - Label l4 = new Label(inner, SWT.WRAP); - l4.setText(A80); - shell.layout(); - assertTrue(l1.getSize().x < l2.getSize().x); - assertTrue(l1.getSize().y < l3.getSize().y); - assertTrue(l1.getSize().x < l4.getSize().x); - assertTrue(l2.getSize().y < l3.getSize().y); - assertTrue("Label is too wide for layout ", l1.getSize().x + l2.getSize().x <= 100); - assertTrue("Labels overlap", l2.getBounds().x >= l1.getBounds().x + l1.getBounds().width); - assertTrue("Labels overlap", l3.getBounds().y >= l1.getBounds().y + l1.getBounds().height); - assertTrue("Labels overlap", l4.getBounds().x >= l3.getBounds().x + l3.getBounds().width); - assertTrue("Labels overlap", l4.getBounds().y >= l2.getBounds().y + l2.getBounds().height); - shell.dispose(); - } - - /** - * Test alignments and margins - */ - // Suppressed for now - see Bug 196686 - public void suppressed_testTableWrapLayoutAlignment() { - Display display = PlatformUI.getWorkbench().getDisplay(); - Shell shell = new Shell(display); - shell.setSize(100, 300); - shell.setLayout(new FillLayout()); - Composite inner = new Composite(shell, SWT.V_SCROLL); - TableWrapLayout tableWrapLayout = new TableWrapLayout(); - final int LEFT_MARGIN = 1; - final int RIGHT_MARGIN = 2; - final int TOP_MARGIN = 3; - final int BOTTOM_MARGIN = 4; - tableWrapLayout.leftMargin = LEFT_MARGIN; - tableWrapLayout.rightMargin = RIGHT_MARGIN; - tableWrapLayout.topMargin = TOP_MARGIN; - tableWrapLayout.bottomMargin = BOTTOM_MARGIN; - inner.setLayout(tableWrapLayout); - Label lab0 = new Label(inner, SWT.WRAP); - lab0.setText(A80); - Label labLeft = new Label(inner, SWT.NULL); - labLeft.setText(A1); - TableWrapData dataLeft = new TableWrapData(); - dataLeft.align = TableWrapData.LEFT; - labLeft.setLayoutData(dataLeft); - Label labRight = new Label(inner, SWT.NULL); - labRight.setText(A1); - TableWrapData dataRight = new TableWrapData(); - dataRight.align = TableWrapData.RIGHT; - labRight.setLayoutData(dataRight); - Label labCenter = new Label(inner, SWT.NULL); - labCenter.setText(A1); - TableWrapData dataCenter = new TableWrapData(); - dataCenter.align = TableWrapData.CENTER; - labCenter.setLayoutData(dataCenter); - Label labFill = new Label(inner, SWT.NULL); - labFill.setText(A1); - TableWrapData dataFill = new TableWrapData(); - dataFill.align = TableWrapData.FILL; - labFill.setLayoutData(dataFill); - shell.layout(); - // Check layout - assertEquals(LEFT_MARGIN , labLeft.getBounds().x); - assertTrue(rightEdge(lab0) > rightEdge(labLeft)); - assertTrue(rightEdge(labLeft) + tableWrapLayout.rightMargin < 100); - - assertEquals(rightEdge(labRight), rightEdge(lab0)); - assertTrue(labRight.getBounds().x > LEFT_MARGIN); - - assertTrue(labCenter.getBounds().x > LEFT_MARGIN); - assertTrue(rightEdge(lab0) > rightEdge(labCenter)); - - int offCenter = rightEdge(labCenter) + labCenter.getBounds().x - - rightEdge(lab0) + lab0.getBounds().x; - assertTrue(offCenter >= -2); - assertTrue(offCenter <= 2); - - assertEquals(LEFT_MARGIN , labFill.getBounds().x); - assertEquals(rightEdge(labFill), rightEdge(lab0)); - shell.dispose(); - } - -} diff --git a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/performance/AllFormsPerformanceTests.java b/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/performance/AllFormsPerformanceTests.java deleted file mode 100644 index 0c5c1e170..000000000 --- a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/performance/AllFormsPerformanceTests.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ua.tests.forms.performance; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/* - * Tests forms performance (automated). - */ -public class AllFormsPerformanceTests extends TestSuite { - - /* - * Returns the entire test suite. - */ - public static Test suite() { - return new AllFormsPerformanceTests(); - } - - /* - * Constructs a new performance test suite. - */ - public AllFormsPerformanceTests() { - addTestSuite(FormsPerformanceTest.class); - } -} diff --git a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/performance/FormsPerformanceTest.java b/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/performance/FormsPerformanceTest.java deleted file mode 100644 index 052d4e31b..000000000 --- a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/performance/FormsPerformanceTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ua.tests.forms.performance; - -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.test.performance.Dimension; -import org.eclipse.test.performance.Performance; -import org.eclipse.test.performance.PerformanceTestCase; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.events.ExpansionAdapter; -import org.eclipse.ui.forms.events.ExpansionEvent; -import org.eclipse.ui.forms.events.HyperlinkAdapter; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.widgets.ExpandableComposite; -import org.eclipse.ui.forms.widgets.FormText; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Hyperlink; -import org.eclipse.ui.forms.widgets.ImageHyperlink; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.forms.widgets.Section; -import org.eclipse.ui.forms.widgets.TableWrapData; -import org.eclipse.ui.forms.widgets.TableWrapLayout; - -public class FormsPerformanceTest extends PerformanceTestCase { - - public void test_createForm() { - tagAsSummary("Create Form", Dimension.ELAPSED_PROCESS); - Performance.getDefault(); - - // Warm up. - - Display display = PlatformUI.getWorkbench().getDisplay(); - - FormToolkit toolkit; - toolkit = new FormToolkit(display); - for(int samples = 0; samples < 2; samples++) { - Shell shell = new Shell(display); - shell.setSize(400, 300); - shell.setLayout(new FillLayout()); - shell.open(); - - for (int i = 0; i < 5; i++) { - Composite c = new Composite(shell, SWT.H_SCROLL + SWT.V_SCROLL); - c.setLayout(new FillLayout()); - createPartControl(c, toolkit); - shell.layout(true); - while(display.readAndDispatch()){/*empty*/} - c.dispose(); - } - shell.dispose(); - while(display.readAndDispatch()){/*empty*/} - } - - for(int samples = 0; samples < 50; samples++) { - Shell shell = new Shell(display); - shell.setSize(400, 300); - shell.setLayout(new FillLayout()); - shell.open(); - startMeasuring(); - for (int i = 0; i < 3; i++) { - Composite c = new Composite(shell, SWT.H_SCROLL + SWT.V_SCROLL); - c.setLayout(new FillLayout()); - createPartControl(c, toolkit); - shell.layout(true); - while(display.readAndDispatch()){/*empty*/} - c.dispose(); - } - stopMeasuring(); - shell.dispose(); - while(display.readAndDispatch()){/*empty*/} - } - toolkit.dispose(); - commitMeasurements(); - assertPerformance(); - } - - public void createPartControl(Composite parent, FormToolkit toolkit) { - //Label l = new Label(parent, SWT.NULL); - //l.setText ("a label"); - ScrolledForm form; - form = toolkit.createScrolledForm(parent); - form.setText("Hello, Eclipse Forms"); - TableWrapLayout layout = new TableWrapLayout(); - form.getBody().setLayout(layout); - - Hyperlink link = toolkit.createHyperlink(form.getBody(), "Click here.", - SWT.WRAP); - link.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { - System.out.println("Link activated!"); - } - }); - link.setText("This is an example of a form that is much longer and will need to wrap."); - layout.numColumns = 2; - TableWrapData td = new TableWrapData(); - td.colspan = 2; - link.setLayoutData(td); - toolkit.createLabel(form.getBody(), "Text field label:"); - Text text = toolkit.createText(form.getBody(), ""); - td = new TableWrapData(TableWrapData.FILL_GRAB); - text.setLayoutData(td); - Button button = toolkit.createButton(form.getBody(), - "An example of a checkbox in a form", SWT.CHECK); - td = new TableWrapData(); - td.colspan = 2; - button.setLayoutData(td); - - ImageHyperlink ih = toolkit.createImageHyperlink(form.getBody(), SWT.NULL); - ih.setText("Image link with no image"); - ih = toolkit.createImageHyperlink(form.getBody(), SWT.NULL); - //ih.setImage(ExamplesPlugin.getDefault().getImageRegistry().get(ExamplesPlugin.IMG_SAMPLE)); - ih.setText("Link with image and text"); - - ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TREE_NODE|ExpandableComposite.CLIENT_INDENT); - ImageHyperlink eci = toolkit.createImageHyperlink(ec, SWT.NULL); - //eci.setImage(ExamplesPlugin.getDefault().getImageRegistry().get(ExamplesPlugin.IMG_SAMPLE)); - ec.setTextClient(eci); - ec.setText("Expandable Composite title"); - String ctext = "We will now create a somewhat long text so that "+ - "we can use it as content for the expandable composite. "+ - "Expandable composite is used to hide or show the text using the "+ - "toggle control"; - Label client = toolkit.createLabel(ec, ctext, SWT.WRAP); - ec.setClient(client); - td = new TableWrapData(); - td.colspan = 2; - ec.setLayoutData(td); - ec.addExpansionListener(new ExpansionAdapter() { - public void expansionStateChanged(ExpansionEvent e) { - //form.reflow(true); - } - }); - Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TWISTIE|Section.EXPANDED); - td = new TableWrapData(TableWrapData.FILL); - td.colspan = 2; - section.setLayoutData(td); - section.addExpansionListener(new ExpansionAdapter() { - public void expansionStateChanged(ExpansionEvent e) { - //form.reflow(true); - } - }); - section.setText("Section title"); - toolkit.createCompositeSeparator(section); - section.setDescription("This is the description that goes below the title"); - Composite sectionClient = toolkit.createComposite(section); - sectionClient.setLayout(new GridLayout()); - button = toolkit.createButton(sectionClient, "Radio 1", SWT.RADIO); - button = toolkit.createButton(sectionClient, "Radio 2", SWT.RADIO); - section.setClient(sectionClient); - - StringBuffer buf = new StringBuffer(); - buf.append("<form>"); - buf.append("<p>"); - buf.append("Here is some plain text for the text to render; "); - buf.append("this text is at <a href=\"http://www.eclipse.org\" nowrap=\"true\">http://www.eclipse.org</a> web site."); - buf.append("</p>"); - buf.append("<p>"); - buf.append("<span color=\"header\" font=\"header\">This text is in header font.</span>"); - buf.append("</p>"); - buf.append("<p>This line will contain some <b>bold</b> and some <span font=\"code\">source</span> text. "); - buf.append("We can also add <img href=\"image\"/> an image. "); - buf.append("</p>"); - buf.append("<li>A default (bulleted) list item.</li>"); - buf.append("<li>Another bullet list item.</li>"); - buf.append("<li style=\"text\" value=\"1.\">A list item with text.</li>"); - buf.append("<li style=\"text\" value=\"2.\">Another list item with text</li>"); - buf.append("<li style=\"image\" value=\"image\">List item with an image bullet</li>"); - buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"3.\">A list item with text.</li>"); - buf.append("<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"4.\">A list item with text.</li>"); - buf.append("<p> leading blanks; more white \n\n new lines <br/><br/><br/> \n more <b> bb </b> white . </p>"); - buf.append("</form>"); - FormText rtext = toolkit.createFormText(form.getBody(), false); - //rtext.setWhitespaceNormalized(false); - td = new TableWrapData(TableWrapData.FILL); - td.colspan = 2; - rtext.setLayoutData(td); - //rtext.setImage("image", ExamplesPlugin.getDefault().getImageRegistry().get(ExamplesPlugin.IMG_SAMPLE)); - //rtext.setColor("header", JFaceColors.getErrorText(display)); - rtext.setFont("header", JFaceResources.getHeaderFont()); - rtext.setFont("code", JFaceResources.getTextFont()); - rtext.setText(buf.toString(), true, false); - rtext.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { - System.out.println("Link active: "+e.getHref()); - } - }); -/* layout.numColumns = 3; - Label label; - TableWrapData td; - - label = toolkit.createLabel(form.getBody(), "Some text to put in the first column", SWT.WRAP); - label = toolkit.createLabel(form.getBody() ,"Some text to put in the second column and make it a bit longer so that we can see what happens with column distribution. This text must be the longest so that it can get more space allocated to the columns it belongs to.", SWT.WRAP); - td = new TableWrapData(); - td.colspan = 2; - label.setLayoutData(td); - label = toolkit.createLabel(form.getBody(), "This text will span two rows and should not grow the column.", SWT.WRAP); - td = new TableWrapData(); - td.rowspan = 2; - label.setLayoutData(td); - label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); - label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); - label.setLayoutData(new TableWrapData(TableWrapData.FILL)); - label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); - label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); - label.setLayoutData(new TableWrapData(TableWrapData.FILL)); - form.getBody().setBackground(form.getBody().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));*/ - - toolkit.paintBordersFor(form.getBody()); - } - -} diff --git a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/util/AllUtilityTests.java b/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/util/AllUtilityTests.java deleted file mode 100644 index 47d5be5ff..000000000 --- a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/util/AllUtilityTests.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ua.tests.forms.util; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/* - * Tests forms performance (automated). - */ -public class AllUtilityTests extends TestSuite { - - /* - * Returns the entire test suite. - */ - public static Test suite() { - return new AllUtilityTests(); - } - - /* - * Constructs a new performance test suite. - */ - public AllUtilityTests() { - addTestSuite(FormImagesTests.class); - } -} diff --git a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/util/FormImagesTests.java b/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/util/FormImagesTests.java deleted file mode 100644 index aa9eac878..000000000 --- a/org.eclipse.ua.tests/forms/org/eclipse/ua/tests/forms/util/FormImagesTests.java +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ua.tests.forms.util; - -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.internal.forms.widgets.FormImages; - -import junit.framework.Assert; -import junit.framework.TestCase; - -public class FormImagesTests extends TestCase { - public void testSingleton() { - Display display = Display.getCurrent(); - FormImages instance = FormImages.getInstance(); - // ensure the singleton is returning the same instance - Assert.assertTrue("getInstance() returned a different FormImages instance", instance.equals(FormImages.getInstance())); - Image gradient = instance.getGradient(display, new Color(display, 1, 1, 1), new Color(display, 7, 7, 7), 21, 21, 0); - instance.markFinished(gradient); - // ensure the singleton is returning the same instance after creating and disposing one gradient - Assert.assertTrue("getInstance() returned a different FormImages instance after creation and disposal of one image", instance.equals(FormImages.getInstance())); - } - - public void testDisposeOne() { - Display display = Display.getCurrent(); - Image gradient = FormImages.getInstance().getGradient(display, new Color(display, 255, 255, 255), new Color(display, 0, 0, 0), 21, 21, 0); - FormImages.getInstance().markFinished(gradient); - // ensure that getting a single gradient and marking it as finished disposed it - Assert.assertTrue("markFinished(...) did not dispose an image after a single getGradient()", gradient.isDisposed()); - } - - public void testMultipleSimpleInstances() { - Display display = Display.getCurrent(); - Image gradient = FormImages.getInstance().getGradient(display, new Color(display, 200, 200, 200), new Color(display, 0, 0, 0), 30, 16, 3); - int count; - // ensure that the same image is returned for many calls with the same parameter - for (count = 1; count < 20; count ++) - Assert.assertEquals("getGradient(...) returned a different image for the same params on iteration "+count, - gradient, FormImages.getInstance().getGradient(display, new Color(display, 200, 200, 200), new Color(display, 0, 0, 0), 30, 16, 3)); - for ( ;count > 0; count--) { - FormImages.getInstance().markFinished(gradient); - if (count != 1) - // ensure that the gradient is not disposed early - Assert.assertFalse("markFinished(...) disposed a shared image early on iteration "+count,gradient.isDisposed()); - else - // ensure that the gradient is disposed on the last markFinished - Assert.assertTrue("markFinished(...) did not dispose a shared image on the last call",gradient.isDisposed()); - } - } - - public void testMultipleComplexInstances() { - Display display = Display.getCurrent(); - Image gradient = FormImages.getInstance().getGradient(display, new Color[] {new Color(display, 200, 200, 200), new Color(display, 0, 0, 0)}, - new int[] {100}, 31, true, null); - int count; - // ensure that the same image is returned for many calls with the same parameter - for (count = 1; count < 20; count ++) - Assert.assertEquals("getGradient(...) returned a different image for the same params on iteration "+count, - gradient, FormImages.getInstance().getGradient(display, new Color[] {new Color(display, 200, 200, 200), new Color(display, 0, 0, 0)}, - new int[] {100}, 31, true, null)); - for ( ;count > 0; count--) { - FormImages.getInstance().markFinished(gradient); - if (count != 1) - // ensure that the gradient is not disposed early - Assert.assertFalse("markFinished(...) disposed a shared image early on iteration "+count,gradient.isDisposed()); - else - // ensure that the gradient is disposed on the last markFinished - Assert.assertTrue("markFinished(...) did not dispose a shared image on the last call",gradient.isDisposed()); - } - } - - public void testMultipleUniqueInstances() { - Display display = Display.getCurrent(); - Image[] images = new Image[24]; - images[0] = FormImages.getInstance().getGradient(display, new Color(display, 1, 0, 0), new Color(display, 100, 100, 100), 25, 23, 1); - images[1] = FormImages.getInstance().getGradient(display, new Color(display, 0, 1, 0), new Color(display, 100, 100, 100), 25, 23, 1); - images[2] = FormImages.getInstance().getGradient(display, new Color(display, 0, 0, 1), new Color(display, 100, 100, 100), 25, 23, 1); - images[3] = FormImages.getInstance().getGradient(display, new Color(display, 0, 0, 0), new Color(display, 101, 100, 100), 25, 23, 1); - images[4] = FormImages.getInstance().getGradient(display, new Color(display, 0, 0, 0), new Color(display, 100, 101, 100), 25, 23, 1); - images[5] = FormImages.getInstance().getGradient(display, new Color(display, 0, 0, 0), new Color(display, 100, 100, 101), 25, 23, 1); - images[6] = FormImages.getInstance().getGradient(display, new Color(display, 0, 0, 0), new Color(display, 100, 100, 100), 20, 23, 1); - images[7] = FormImages.getInstance().getGradient(display, new Color(display, 0, 0, 0), new Color(display, 100, 100, 100), 25, 10, 1); - images[8] = FormImages.getInstance().getGradient(display, new Color(display, 0, 0, 0), new Color(display, 100, 100, 100), 25, 23, 2); - images[9] = FormImages.getInstance().getGradient(display, new Color(display, 1, 1, 1), new Color(display, 101, 101, 101), 20, 10, 2); - images[10] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,0,0,0)}, new int[] {}, 31, true, null); - images[11] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,0,0,0), new Color(display,1,1,1)}, - new int[] {80}, 31, true, new Color(display,255,255,255)); - images[12] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,0,0,0), new Color(display,1,1,1)}, - new int[] {80}, 31, true, new Color(display,0,0,0)); - images[13] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,0,0,0), new Color(display,100,100,100)}, - new int[] {100}, 31, true, null); - images[14] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,1,0,0), new Color(display,100,100,100)}, - new int[] {100}, 31, true, null); - images[15] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,0,1,0), new Color(display,100,100,100)}, - new int[] {100}, 31, true, null); - images[16] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,0,0,1), new Color(display,100,100,100)}, - new int[] {100}, 31, true, null); - images[17] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,0,0,0), new Color(display,101,100,100)}, - new int[] {100}, 31, true, null); - images[18] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,0,0,0), new Color(display,100,101,100)}, - new int[] {100}, 31, true, null); - images[19] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,0,0,0), new Color(display,100,100,101)}, - new int[] {100}, 31, true, null); - images[20] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,0,0,0), new Color(display,100,100,100)}, - new int[] {100}, 20, true, null); - images[21] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,0,0,0), new Color(display,100,100,100)}, - new int[] {100}, 31, false, null); - images[22] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,0,0,0), new Color(display,100,100,100)}, - new int[] {50}, 31, true, new Color(display,1,1,1)); - images[23] = FormImages.getInstance().getGradient(display, new Color[]{new Color(display,1,1,1), new Color(display,101,101,101)}, - new int[] {50}, 20, false, new Color(display,1,1,1)); - // ensure none of the images are the same - for (int i = 0; i < images.length - 1; i++) { - for (int j = i+1; j < images.length; j++) { - Assert.assertNotSame("getGradient(...) returned the same image for different parameters: i = " + i + "; j = " + j, images[i], images[j]); - } - } - // ensure all of the images are disposed with one call to markFinished - for (int i = 0; i < images.length; i++) { - FormImages.getInstance().markFinished(images[i]); - Assert.assertTrue("markFinished(...) did not dispose an image that was only requested once: i = " + i, images[i].isDisposed()); - } - } - - public void testComplexEquality() { - Display display = Display.getCurrent(); - Image image1 = FormImages.getInstance().getGradient(display, new Color[] {new Color(display,0,0,0), new Color(display,255,255,255)}, - new int[] {100}, 20, true, new Color(display,100,100,100)); - Image image2 = FormImages.getInstance().getGradient(display, new Color[] {new Color(display,0,0,0), new Color(display,255,255,255)}, - new int[] {100}, 20, true, new Color(display,0,0,0)); - Assert.assertEquals("different images were created with only the background color differing when that difference is irrelevant", image1, image2); - FormImages.getInstance().markFinished(image1); - FormImages.getInstance().markFinished(image2); - image1 = FormImages.getInstance().getGradient(display, new Color[] {new Color(display,0,0,0), new Color(display,255,255,255)}, - new int[] {80}, 20, true, new Color(display,100,100,100)); - image2 = FormImages.getInstance().getGradient(display, new Color[] {new Color(display,0,0,0), new Color(display,255,255,255)}, - new int[] {80}, 20, true, new Color(display,0,0,0)); - Assert.assertNotSame("the same image was used when different background colors were specified", image1, image2); - FormImages.getInstance().markFinished(image1); - FormImages.getInstance().markFinished(image2); - } - - public void testDisposeUnknown() { - Display display = Display.getCurrent(); - Image image = new Image(display, 10, 10); - FormImages.getInstance().markFinished(image); - Assert.assertTrue("markFinished(...) did not dispose of an unknown image", image.isDisposed()); - } -} |