directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r881586 - /directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java
Date Tue, 17 Nov 2009 22:39:24 GMT
Author: seelmann
Date: Tue Nov 17 22:39:24 2009
New Revision: 881586

URL: http://svn.apache.org/viewvc?rev=881586&view=rev
Log:
Use helper bots to simplify tests.

Modified:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java

Modified: 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=881586&r1=881585&r2=881586&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SwtResourcesTest.java
Tue Nov 17 22:39:24 2009
@@ -28,16 +28,15 @@
 import org.apache.directory.server.core.integ.annotations.CleanupLevel;
 import org.apache.directory.server.integ.SiRunner;
 import org.apache.directory.server.ldap.LdapServer;
+import org.apache.directory.studio.test.integration.ui.bots.BrowserViewBot;
 import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
+import org.apache.directory.studio.test.integration.ui.bots.DeleteDialogBot;
+import org.apache.directory.studio.test.integration.ui.bots.NewEntryWizardBot;
 import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
 import org.eclipse.swt.graphics.DeviceData;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.SWTBot;
 import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
 import org.eclipse.swtbot.swt.finder.results.IntResult;
-import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -58,8 +57,7 @@
 
     private StudioBot studioBot;
     private ConnectionsViewBot connectionsViewBot;
-
-    private SWTWorkbenchBot bot;
+    private BrowserViewBot browserViewBot;
 
 
     @Before
@@ -69,8 +67,7 @@
         studioBot.resetLdapPerspective();
         connectionsViewBot = studioBot.getConnectionView();
         connectionsViewBot.createTestConnection( "SwtResourcesTest", ldapServer.getPort()
);
-
-        bot = new SWTWorkbenchBot();
+        browserViewBot = studioBot.getBrowserView();
     }
 
 
@@ -78,7 +75,6 @@
     public void tearDown() throws Exception
     {
         connectionsViewBot.deleteTestConnections();
-        bot = null;
     }
 
 
@@ -94,10 +90,8 @@
     @Test
     public void testSwtResourcesDelta() throws Exception
     {
-        SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-
         // run the new entry wizard once to ensure all SWT resources are created
-        createAndDeleteEntry( browserTree, "testSwtResourcesDelta" + 0 );
+        createAndDeleteEntry( "testSwtResourcesDelta" + 0 );
 
         // remember the SWT objects before the run
         int beforeObjectCount = getSwtObjectCount();
@@ -105,7 +99,7 @@
         // now lets run the new entry wizard it several times
         for ( int i = 1; i < 25; i++ )
         {
-            createAndDeleteEntry( browserTree, "testSwtResourcesDelta" + i );
+            createAndDeleteEntry( "testSwtResourcesDelta" + i );
         }
 
         // get the SWT objects after the run
@@ -136,6 +130,7 @@
 
     private int getSwtObjectCount()
     {
+        final SWTBot bot = new SWTBot();
         return UIThreadRunnable.syncExec( bot.getDisplay(), new IntResult()
         {
             public Integer run()
@@ -151,91 +146,27 @@
     }
 
 
-    private void createAndDeleteEntry( final SWTBotTree browserTree, final String name )
throws Exception
+    private void createAndDeleteEntry( final String name ) throws Exception
     {
-        SWTBotUtils.selectEntry( bot, browserTree, true, "DIT", "Root DSE", "ou=system" );
-        SWTBotUtils.asyncClick( bot, browserTree.contextMenu( "New Entry..." ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.shell( "New Entry" ) != null;
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not find dialog 'New Entry'";
-            }
-        } );
-
-        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 );
-        SWTBotUtils.asyncClick( bot, bot.button( "Next >" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.button( "Finish" ).isEnabled();
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Finish button is not enabled";
-            }
-        } );
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" );
+        browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system" );
+        NewEntryWizardBot wizardBot = browserViewBot.openNewEntryWizard();
 
-        // click finish to create the entry
-        SWTBotUtils.asyncClick( bot, bot.button( "Finish" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return browserTree.selection().get( 0 ).get( 0 ).startsWith( "o=" + name
);
-            }
+        wizardBot.selectCreateEntryFromScratch();
+        wizardBot.clickNextButton();
 
+        wizardBot.addObjectClasses( "organization" );
+        wizardBot.clickNextButton();
 
-            public String getFailureMessage()
-            {
-                return "Could not select 'o=" + name + "'";
-            }
-        } );
+        wizardBot.setRdnType( 1, "o" );
+        wizardBot.setRdnValue( 1, name );
+        wizardBot.clickNextButton();
 
-        // delete the entry
-        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system",
"o=" + name );
-        SWTBotUtils.asyncClick( bot, browserTree.contextMenu( "Delete Entry" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return bot.shell( "Delete Entry" ) != null;
-            }
+        wizardBot.clickFinishButton();
 
-
-            public String getFailureMessage()
-            {
-                return "Could not find dialog 'New Entry'";
-            }
-        } );
-        SWTBotUtils.asyncClick( bot, bot.button( "OK" ), new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                return browserTree.selection().get( 0 ).get( 0 ).startsWith( "ou=system"
);
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "Could not select 'ou=system'";
-            }
-        } );
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "o=" + name );
+        DeleteDialogBot dialog = browserViewBot.openDeleteDialog();
+        dialog.clickOkButton();
     }
 
 }



Mime
View raw message