diff options
author | Christophe Cornu <ccornu> | 2003-07-15 19:39:00 +0000 |
---|---|---|
committer | Christophe Cornu <ccornu> | 2003-07-15 19:39:00 +0000 |
commit | 65ed208c63a8fc4bcf32511eca0efe2c7b2a0220 (patch) | |
tree | b35397fda7475413dc3ed71de5139940c7ff1236 | |
parent | c448d529148b078625fe558e1ba96098788837a8 (diff) | |
download | eclipse.platform.swt-65ed208c63a8fc4bcf32511eca0efe2c7b2a0220.tar.gz eclipse.platform.swt-65ed208c63a8fc4bcf32511eca0efe2c7b2a0220.tar.xz eclipse.platform.swt-65ed208c63a8fc4bcf32511eca0efe2c7b2a0220.zip |
monitor api
5 files changed, 169 insertions, 1 deletions
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllTests.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllTests.java index 857cc0818d..7bd2eea1cf 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllTests.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllTests.java @@ -110,7 +110,7 @@ public AllTests() { addTest(Test_org_eclipse_swt_widgets_DirectoryDialog.suite()); addTest(Test_org_eclipse_swt_widgets_FontDialog.suite()); addTest(Test_org_eclipse_swt_widgets_MessageBox.suite()); - + addTest(Test_org_eclipse_swt_widgets_Monitor.suite()); addTest(Test_org_eclipse_swt_layout_GridData.suite()); addTest(Test_org_eclipse_swt_layout_RowData.suite()); addTest(Test_org_eclipse_swt_layout_GridLayout.suite()); diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllWidgetTests.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllWidgetTests.java index 8164c91513..aa4fe37277 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllWidgetTests.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllWidgetTests.java @@ -64,6 +64,7 @@ public static Test suite() { suite.addTest(Test_org_eclipse_swt_widgets_DirectoryDialog.suite()); suite.addTest(Test_org_eclipse_swt_widgets_FontDialog.suite()); suite.addTest(Test_org_eclipse_swt_widgets_MessageBox.suite()); + suite.addTest(Test_org_eclipse_swt_widgets_Monitor.suite()); return suite; } diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java index 3bf8624c17..d9783f7cc7 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java @@ -264,6 +264,37 @@ public void test_getMenu() { // tested in test_setMenuLorg_eclipse_swt_widgets_Menu } +public void test_getMonitor() { + Monitor monitor = control.getMonitor(); + assertNotNull(monitor); + Display display = control.getDisplay(); + Monitor[] monitors = display.getMonitors(); + int i; + /* monitor must be listed in Display.getMonitors */ + for (i = 0; i < monitors.length; i++) { + if (monitor.equals(monitors[i])) break; + } + if (i == monitors.length) { + fail("Control.getMonitor does not return a monitor listed in Display.getMonitors"); + } + + /* set control into each monitor and check getMonitor returns the right monitor */ + Rectangle oldBounds = control.getBounds(); + for (i = 0; i < monitors.length; i++) { + Monitor src = monitors[i]; + control.setBounds(src.getBounds()); + Monitor target = control.getMonitor(); + assertTrue(target.equals(src)); + } + for (i = 0; i < monitors.length; i++) { + Monitor src = monitors[i]; + control.setBounds(src.getClientArea()); + Monitor target = control.getMonitor(); + assertTrue(target.equals(src)); + } + control.setBounds(oldBounds); +} + public void test_getParent() { assertEquals(shell, control.getParent()); } @@ -706,6 +737,7 @@ public static java.util.Vector methodNames() { methodNames.addElement("test_getLayoutData"); methodNames.addElement("test_getLocation"); methodNames.addElement("test_getMenu"); + methodNames.addElement("test_getMonitor"); methodNames.addElement("test_getParent"); methodNames.addElement("test_getShell"); methodNames.addElement("test_getSize"); @@ -784,6 +816,7 @@ protected void runTest() throws Throwable { else if (getName().equals("test_getLayoutData")) test_getLayoutData(); else if (getName().equals("test_getLocation")) test_getLocation(); else if (getName().equals("test_getMenu")) test_getMenu(); + else if (getName().equals("test_getMonitor")) test_getMonitor(); else if (getName().equals("test_getParent")) test_getParent(); else if (getName().equals("test_getShell")) test_getShell(); else if (getName().equals("test_getSize")) test_getSize(); diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java index d08da1e15d..326b298702 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java @@ -187,6 +187,23 @@ public void test_getIconDepth() { warnUnimpl("Test test_getIconDepth not written"); } +public void test_getMonitors() { + Display display = new Display(); + Monitor[] monitors = display.getMonitors(); + assertNotNull(monitors); + assertTrue("at least one monitor should be returned", monitors.length >= 1); + for (int i = 0; i < monitors.length; i++) + assertTrue("monitor at index "+i+" should not be null", monitors[i] != null); + display.dispose(); +} + +public void test_getPrimaryMonitor() { + Display display = new Display(); + Monitor monitor = display.getPrimaryMonitor(); + assertNotNull(monitor); + display.dispose(); +} + public void test_getShells() { warnUnimpl("Test test_getShells not written"); } @@ -337,6 +354,8 @@ public static java.util.Vector methodNames() { methodNames.addElement("test_getDoubleClickTime"); methodNames.addElement("test_getFocusControl"); methodNames.addElement("test_getIconDepth"); + methodNames.addElement("test_getMonitors"); + methodNames.addElement("test_getPrimaryMonitor"); methodNames.addElement("test_getShells"); methodNames.addElement("test_getSyncThread"); methodNames.addElement("test_getSystemColorI"); @@ -385,6 +404,8 @@ protected void runTest() throws Throwable { else if (getName().equals("test_getDoubleClickTime")) test_getDoubleClickTime(); else if (getName().equals("test_getFocusControl")) test_getFocusControl(); else if (getName().equals("test_getIconDepth")) test_getIconDepth(); + else if (getName().equals("test_getMonitors")) test_getMonitors(); + else if (getName().equals("test_getPrimaryMonitor")) test_getPrimaryMonitor(); else if (getName().equals("test_getShells")) test_getShells(); else if (getName().equals("test_getSyncThread")) test_getSyncThread(); else if (getName().equals("test_getSystemColorI")) test_getSystemColorI(); diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Monitor.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Monitor.java new file mode 100644 index 0000000000..f1d18d99b4 --- /dev/null +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Monitor.java @@ -0,0 +1,113 @@ +package org.eclipse.swt.tests.junit; + +/* + * (c) Copyright IBM Corp. 2000, 2002. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +import junit.framework.*; +import junit.textui.*; +import org.eclipse.swt.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.events.*; +/** + * Automated Test Suite for class org.eclipse.swt.widgets.Monitor + * + * @see org.eclipse.swt.widgets.Monitor + */ +public class Test_org_eclipse_swt_widgets_Monitor extends SwtTestCase { + +Display display = null; +Monitor[] monitors = null; +Monitor primary = null; + +public Test_org_eclipse_swt_widgets_Monitor(String name) { + super(name); +} + +public static void main(String[] args) { + TestRunner.run(suite()); +} + +protected void setUp() { + display = Display.getDefault(); + monitors = display.getMonitors(); + primary = display.getPrimaryMonitor(); +} + +protected void tearDown() { +} + +public void test_equalsLjava_lang_Object() { + int i; + for (i = 0; i < monitors.length; i++) { + if (primary.equals(monitors[i])) break; + } + if (i == monitors.length) fail(); + for (i = 0; i < monitors.length; i++) { + Monitor test = monitors[i]; + for (int j = 0; j < monitors.length; j++) { + if (test.equals(monitors[j])) { + if (i != j) fail("Monitors "+i+" and "+j+" should not be equal"); + } + } + } +} + +public void test_getBounds() { + Rectangle bounds = primary.getBounds(); + assertNotNull(bounds); + for (int i = 0; i < monitors.length; i++) { + bounds = monitors[i].getBounds(); + assertNotNull(bounds); + } +} + +public void test_getClientArea() { + Rectangle bounds = primary.getClientArea(); + assertNotNull(bounds); + for (int i = 0; i < monitors.length; i++) { + bounds = monitors[i].getClientArea(); + assertNotNull(bounds); + } +} + +public void test_hashCode() { + for (int i = 0; i < monitors.length; i++) { + if (primary.equals(monitors[i])) { + assertTrue(primary.hashCode() == monitors[i].hashCode()); + break; + } + } +} + + +public static Test suite() { + TestSuite suite = new TestSuite(); + java.util.Vector methodNames = methodNames(); + java.util.Enumeration e = methodNames.elements(); + while (e.hasMoreElements()) { + suite.addTest(new Test_org_eclipse_swt_widgets_Monitor((String)e.nextElement())); + } + return suite; +} + +public static java.util.Vector methodNames() { + java.util.Vector methodNames = new java.util.Vector(); + methodNames.addElement("test_equalsLjava_lang_Object"); + methodNames.addElement("test_getBounds"); + methodNames.addElement("test_getClientArea"); + methodNames.addElement("test_hashCode"); + return methodNames; +} + +protected void runTest() throws Throwable { + if (getName().equals("test_equalsLjava_lang_Object")) test_equalsLjava_lang_Object(); + else if (getName().equals("test_getBounds")) test_getBounds(); + else if (getName().equals("test_getClientArea")) test_getClientArea(); + else if (getName().equals("test_hashCode")) test_hashCode(); +} +} |