directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r667959 [2/2] - in /directory/studio/trunk: connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/jobs/ rcp/ test-integration-ui/ test-...
Date Sun, 15 Jun 2008 13:27:11 GMT
Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java?rev=667959&r1=667958&r2=667959&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java
Sun Jun 15 06:27:10 2008
@@ -29,8 +29,6 @@
 import net.sf.swtbot.widgets.SWTBotTree;
 
 import org.apache.directory.server.unit.AbstractServerTest;
-import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
-import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
 
 
 /**
@@ -176,7 +174,7 @@
         tree.select( "sn" );
         bot.text( "" ).setText( "test" );
         tree.select( "cn" );
-        
+
         // TODO: with SWTBot 1.2 we could use the tree.click() method! 
         // workaround to apply the new value 
         bot.button( "< Back" ).click();
@@ -213,76 +211,4 @@
         } );
     }
 
-
-    /**
-     * Test to create multiple entries.
-     * 
-     * @throws Exception the exception
-     */
-    public void testCreateMultipleEntries() throws Exception
-    {
-        SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-
-        BrowserCommonActivator.getDefault().getPreferenceStore().setValue(
-            BrowserCommonConstants.PREFERENCE_BROWSER_ENABLE_FOLDING, false );
-        
-        for ( int i = 0; i < 25; i++ )
-        {
-            createEntry( browserTree, "testCreateMultipleEntries" + i );
-        }
-    }
-
-
-    private void createEntry( final SWTBotTree browserTree, final String name ) throws Exception
-    {
-        SWTBotUtils.selectNode( bot, browserTree, "DIT", "Root DSE", "ou=system" );
-
-        SWTBotMenu contextMenu = browserTree.contextMenu( "New Entry..." );
-        contextMenu.click();
-
-        bot.radio( "Create entry from scratch" ).click();
-        bot.button( "Next >" ).click();
-
-        bot.table( 0 ).select( "organization" );
-        bot.button( "Add" ).click();
-        bot.button( "Next >" ).click();
-
-        SWTBotCombo typeCombo = bot.comboBox( "" );
-        typeCombo.setText( "o" );
-        SWTBotText valueText = bot.text( "" );
-        valueText.setText( name );
-        bot.button( "Next >" ).click();
-
-        // wait for check that entry doesn't exist yet
-        bot.waitUntil( new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.tree( 0 ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find widget";
-            }
-        } );
-        bot.button( "Finish" ).click();
-
-        // wait till entry is created and selected in the tree
-        bot.waitUntil( new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return browserTree.selection().get( 0 ).get( 0 ).equals( "o=" + name );
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find widget";
-            }
-        } );
-    }
-
 }

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreparationTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreparationTest.java?rev=667959&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreparationTest.java
(added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreparationTest.java
Sun Jun 15 06:27:10 2008
@@ -0,0 +1,53 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.test.integration.ui;
+
+
+import net.sf.swtbot.eclipse.finder.SWTEclipseBot;
+
+import org.apache.directory.server.unit.AbstractServerTest;
+
+
+/**
+ * Test preparation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PreparationTest extends AbstractServerTest
+{
+
+    /**
+     * Closes the welcome view.
+     */
+    public void testCloseWelcomeView()
+    {
+        try
+        {
+            SWTEclipseBot bot = new SWTEclipseBot();
+            bot.view( "Welcome" ).close();
+        }
+        catch ( Exception e )
+        {
+        }
+    }
+
+}

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SWTBotUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SWTBotUtils.java?rev=667959&r1=667958&r2=667959&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SWTBotUtils.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SWTBotUtils.java
Sun Jun 15 06:27:10 2008
@@ -60,10 +60,10 @@
      * 
      * @throws Exception the exception
      */
-    public static void openLdapPerspective( SWTEclipseBot bot ) throws Exception
+    public static void openLdapPerspective( final SWTEclipseBot eBot ) throws Exception
     {
         // open "Open Perspective" dialog
-        SWTBotMenu windowMenu = bot.menu( "Window" );
+        SWTBotMenu windowMenu = eBot.menu( "Window" );
         windowMenu.click();
         SWTBotMenu perspectiveMenu = windowMenu.menu( "Open Perspective" );
         perspectiveMenu.click();
@@ -71,12 +71,69 @@
         otherMenu.click();
 
         // select "LDAP" perspective
-        SWTBotTable table = bot.table();
+        SWTBotTable table = eBot.table();
         table.select( "LDAP" );
 
         // press "OK"
-        SWTBotButton okButton = bot.button( "OK" );
+        SWTBotButton okButton = eBot.button( "OK" );
         okButton.click();
+
+        // wait till Connections view become visible
+        eBot.waitUntil( new DefaultCondition()
+        {
+            public boolean test() throws Exception
+            {
+                return eBot.view( "Connections" ) != null;
+            }
+
+
+            public String getFailureMessage()
+            {
+                return "Could not find widget";
+            }
+        } );
+    }
+
+
+    /**
+     * Opens the Sleak (SWT leak) view.
+     * 
+     * @param bot the bot
+     * 
+     * @throws Exception the exception
+     */
+    public static void openSleakView( final SWTEclipseBot eBot ) throws Exception
+    {
+        // open "Show View" dialog
+        SWTBotMenu windowMenu = eBot.menu( "Window" );
+        windowMenu.click();
+        SWTBotMenu viewMenu = windowMenu.menu( "Show View" );
+        viewMenu.click();
+        SWTBotMenu otherMenu = viewMenu.menu( "Other..." );
+        otherMenu.click();
+
+        // select "Sleak"
+        SWTBotTree tree = eBot.tree();
+        SWTBotUtils.selectNode( eBot, tree, "SWT Tools", "Sleak" );
+
+        // press "OK"
+        SWTBotButton okButton = eBot.button( "OK" );
+        okButton.click();
+
+        // wait till Connections view become visible
+        eBot.waitUntil( new DefaultCondition()
+        {
+            public boolean test() throws Exception
+            {
+                return eBot.view( "Sleak" ) != null;
+            }
+
+
+            public String getFailureMessage()
+            {
+                return "Could not find widget";
+            }
+        } );
     }
 
 

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java?rev=667959&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java
(added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java
Sun Jun 15 06:27:10 2008
@@ -0,0 +1,213 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.test.integration.ui;
+
+
+import net.sf.swtbot.eclipse.finder.SWTEclipseBot;
+import net.sf.swtbot.finder.UIThreadRunnable;
+import net.sf.swtbot.finder.UIThreadRunnable.IntResult;
+import net.sf.swtbot.wait.DefaultCondition;
+import net.sf.swtbot.widgets.SWTBotCombo;
+import net.sf.swtbot.widgets.SWTBotMenu;
+import net.sf.swtbot.widgets.SWTBotText;
+import net.sf.swtbot.widgets.SWTBotTree;
+
+import org.apache.directory.server.unit.AbstractServerTest;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.eclipse.swt.graphics.DeviceData;
+
+
+/**
+ * Tests allocation of SWT Resources.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SwtResourcesTest extends AbstractServerTest
+{
+    private SWTEclipseBot bot;
+
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        bot = new SWTEclipseBot();
+        SWTBotUtils.openLdapPerspective( bot );
+        SWTBotUtils.openSleakView( bot );
+        SWTBotUtils.createTestConnection( bot, "SwtResourcesTest", ldapServer.getIpPort()
);
+    }
+
+
+    protected void tearDown() throws Exception
+    {
+        SWTBotUtils.deleteTestConnections();
+        bot = null;
+        super.tearDown();
+    }
+
+
+    /**
+     * Test for DIRSTUDIO-319.
+     * 
+     * Creates multiple entries using the New Entry wizard. Checks
+     * that we don't allocate too much SWT resources during the run.
+     * 
+     * @throws Exception the exception
+     */
+    public void testSwtResourcesDelta() throws Exception
+    {
+        SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
+
+        BrowserCommonActivator.getDefault().getPreferenceStore().setValue(
+            BrowserCommonConstants.PREFERENCE_BROWSER_ENABLE_FOLDING, false );
+
+        // run the new entry wizard once to ensure all SWT resources are created
+        createAndDeleteEntry( browserTree, "testSwtResourcesDelta" + 0 );
+
+        // remember the SWT objects before the run
+        int beforeObjectCount = getSwtObjectCount();
+
+        // now lets run the new entry wizard it several times
+        for ( int i = 1; i < 25; i++ )
+        {
+            createAndDeleteEntry( browserTree, "testSwtResourcesDelta" + i );
+
+            // update the status of SWT objects in the Sleak view
+            bot.view( "Sleak" ).show();
+            bot.button( "Snap" ).click();
+            browserTree = SWTBotUtils.getLdapBrowserTree( bot );
+        }
+
+        // get the SWT objects after the run
+        int afterObjectCount = getSwtObjectCount();
+
+        // we expect not more than 10 additional SWT objects
+        assertTrue( "Too many SWT resources were allocated in testSwtResourcesDelta: before="
+ beforeObjectCount
+            + ", after=" + afterObjectCount, afterObjectCount - beforeObjectCount < 10
);
+    }
+
+
+    /**
+     * Ensure that we have not allocated more the 1000 SWT resources 
+     * during the complete test suite.
+     * 
+     * 1000 is not a fix number but it is a good starting point.
+     * 
+     * @throws Exception the exception
+     */
+    public void testSwtResourcesCount() throws Exception
+    {
+        int swtObjectCount = getSwtObjectCount();
+        assertTrue( "Too many SWT resources were allocated: " + swtObjectCount, swtObjectCount
< 1000 );
+    }
+
+
+    private int getSwtObjectCount()
+    {
+        return UIThreadRunnable.syncExec( bot.getDisplay(), new IntResult()
+        {
+            public int run()
+            {
+                DeviceData info = bot.getDisplay().getDeviceData();
+                if ( !info.tracking )
+                {
+                    fail( "To run this test options 'org.eclipse.ui/debug' and 'org.eclipse.ui/trace/graphics'
must be true." );
+                }
+                return info.objects.length;
+            }
+        } );
+    }
+
+
+    private void createAndDeleteEntry( final SWTBotTree browserTree, final String name )
throws Exception
+    {
+        SWTBotUtils.selectNode( bot, browserTree, "DIT", "Root DSE", "ou=system" );
+
+        SWTBotMenu contextMenu = browserTree.contextMenu( "New Entry..." );
+        contextMenu.click();
+
+        bot.radio( "Create entry from scratch" ).click();
+        bot.button( "Next >" ).click();
+
+        bot.table( 0 ).select( "organization" );
+        bot.button( "Add" ).click();
+        bot.button( "Next >" ).click();
+
+        SWTBotCombo typeCombo = bot.comboBox( "" );
+        typeCombo.setText( "o" );
+        SWTBotText valueText = bot.text( "" );
+        valueText.setText( name );
+        bot.button( "Next >" ).click();
+
+        // wait for check that entry doesn't exist yet
+        bot.waitUntil( new DefaultCondition()
+        {
+            public boolean test() throws Exception
+            {
+                return bot.tree( 0 ) != null;
+            }
+
+
+            public String getFailureMessage()
+            {
+                return "Could not find widget";
+            }
+        } );
+        bot.button( "Finish" ).click();
+
+        // wait till entry is created and selected in the tree
+        bot.waitUntil( new DefaultCondition()
+        {
+            public boolean test() throws Exception
+            {
+                return browserTree.selection().get( 0 ).get( 0 ).equals( "o=" + name );
+            }
+
+
+            public String getFailureMessage()
+            {
+                return "Could not find widget";
+            }
+        } );
+
+        // delete the entry
+        contextMenu = browserTree.contextMenu( "Delete Entry" );
+        contextMenu.click();
+        bot.button( "OK" ).click();
+
+        // wait till the parent ou=system is selected in the tree
+        bot.waitUntil( new DefaultCondition()
+        {
+            public boolean test() throws Exception
+            {
+                return browserTree.selection().get( 0 ).get( 0 ).startsWith( "ou=system"
);
+            }
+
+
+            public String getFailureMessage()
+            {
+                return "Could not find widget";
+            }
+        } );
+    }
+
+}



Mime
View raw message