You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2009/11/10 00:46:05 UTC
svn commit: r834280 - in
/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui:
./ bots/
Author: seelmann
Date: Mon Nov 9 23:46:04 2009
New Revision: 834280
URL: http://svn.apache.org/viewvc?rev=834280&view=rev
Log:
Refactorings in UI tests, added more helper bots
Added:
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DnEditorDialogBot.java
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SelectDnDialogBot.java
Modified:
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewEntryWizardBot.java
Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java?rev=834280&r1=834279&r2=834280&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java (original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java Mon Nov 9 23:46:04 2009
@@ -22,16 +22,22 @@
import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
import org.apache.directory.server.core.integ.Level;
import org.apache.directory.server.core.integ.annotations.ApplyLdifFiles;
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.DnEditorDialogBot;
+import org.apache.directory.studio.test.integration.ui.bots.EntryEditorBot;
+import org.apache.directory.studio.test.integration.ui.bots.NewAttributeWizardBot;
+import org.apache.directory.studio.test.integration.ui.bots.SelectDnDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -54,8 +60,7 @@
private StudioBot studioBot;
private ConnectionsViewBot connectionsViewBot;
-
- private SWTWorkbenchBot bot;
+ private BrowserViewBot browserViewBot;
@Before
@@ -65,8 +70,7 @@
studioBot.resetLdapPerspective();
connectionsViewBot = studioBot.getConnectionView();
connectionsViewBot.createTestConnection( "EntryEditorTest", ldapServer.getPort() );
-
- bot = new SWTWorkbenchBot();
+ browserViewBot = studioBot.getBrowserView();
}
@@ -74,7 +78,6 @@
public void tearDown() throws Exception
{
connectionsViewBot.deleteTestConnections();
- bot = null;
}
@@ -87,49 +90,56 @@
@Test
public void testAddEditDeleteAttribute() throws Exception
{
- final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
- SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ou=users",
- "cn=Barbara Jensen" );
+ browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=Barbara Jensen" );
- final SWTBotTree entryEditorTree = SWTBotUtils.getEntryEditorTree( bot, "cn=Barbara Jensen,ou=users,ou=system" );
- entryEditorTree.setFocus();
+ EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( "cn=Barbara Jensen,ou=users,ou=system" );
+ entryEditorBot.activate();
+ String dn = entryEditorBot.getDnText();
+ assertEquals( "DN: cn=Barbara Jensen,ou=users,ou=system", dn );
+ assertEquals( 8, entryEditorBot.getAttributeValues().size() );
// add description attribute
- entryEditorTree.contextMenu( "New Attribute..." ).click();
- bot.comboBoxWithLabel( "Attribute type:" ).setText( "description" );
- bot.button( "Finish" ).click();
- bot.text( "" ).setText( "This is the 1st description." );
- entryEditorTree.getTreeItem( "objectClass" ).click();
+ NewAttributeWizardBot wizardBot = entryEditorBot.openNewAttributeWizard();
+ assertTrue( wizardBot.isVisible() );
+ wizardBot.typeAttributeType( "description" );
+ wizardBot.clickFinishButton();
+ entryEditorBot.typeValueAndFinish( "This is the 1st description." );
+ assertEquals( 9, entryEditorBot.getAttributeValues().size() );
+ assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the 1st description." ) );
// add second value
- entryEditorTree.getTreeItem( "description" ).click();
- entryEditorTree.contextMenu( "New Value" ).click();
- bot.text( "" ).setText( "This is the 2nd description." );
- entryEditorTree.getTreeItem( "objectClass" ).click();
+ entryEditorBot.addValue( "description" );
+ entryEditorBot.typeValueAndFinish( "This is the 2nd description." );
+ assertEquals( 10, entryEditorBot.getAttributeValues().size() );
+ assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the 1st description." ) );
+ assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the 2nd description." ) );
// edit second value
- entryEditorTree.select( 7 );
- entryEditorTree.contextMenu( "Edit Value" ).click();
- bot.text( "This is the 2nd description." ).setText( "This is the 3rd description." );
- entryEditorTree.getTreeItem( "objectClass" ).click();
+ entryEditorBot.editValue( "description", "This is the 2nd description." );
+ entryEditorBot.typeValueAndFinish( "This is the 3rd description." );
+ assertEquals( 10, entryEditorBot.getAttributeValues().size() );
+ assertEquals( 10, entryEditorBot.getAttributeValues().size() );
+ assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the 1st description." ) );
+ assertFalse( entryEditorBot.getAttributeValues().contains( "description: This is the 2nd description." ) );
+ assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the 3rd description." ) );
// delete second value
- entryEditorTree.select( 7 );
- entryEditorTree.contextMenu( "Delete Value" ).click();
- bot.shell( "Delete Value" );
- bot.button( "OK" ).click();
+ entryEditorBot.deleteValue( "description", "This is the 3rd description." );
+ assertEquals( 9, entryEditorBot.getAttributeValues().size() );
+ assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the 1st description." ) );
+ assertFalse( entryEditorBot.getAttributeValues().contains( "description: This is the 3rd description." ) );
// edit 1st value
- entryEditorTree.select( 6 );
- entryEditorTree.contextMenu( "Edit Value" ).click();
- bot.text( "This is the 1st description." ).setText( "This is the final description." );
- entryEditorTree.getTreeItem( "objectClass" ).click();
+ entryEditorBot.editValue( "description", "This is the 1st description." );
+ entryEditorBot.typeValueAndFinish( "This is the final description." );
+ assertEquals( 9, entryEditorBot.getAttributeValues().size() );
+ assertFalse( entryEditorBot.getAttributeValues().contains( "description: This is the 1st description." ) );
+ assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the final description." ) );
// delete 1st value/attribute
- entryEditorTree.select( 6 );
- entryEditorTree.contextMenu( "Delete Value" ).click();
- bot.shell( "Delete Value" );
- bot.button( "OK" ).click();
+ entryEditorBot.deleteValue( "description", "This is the final description." );
+ assertEquals( 8, entryEditorBot.getAttributeValues().size() );
+ assertFalse( entryEditorBot.getAttributeValues().contains( "description: This is the final description." ) );
}
@@ -142,43 +152,36 @@
@Test
public void testDnValueEditor() throws Exception
{
- SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
- SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ou=users",
- "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\"" );
- SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ou=groups", "cn=My Group" );
-
- SWTBotTree entryEditorTree = SWTBotUtils.getEntryEditorTree( bot, "cn=My Group,ou=groups,ou=system" );
- entryEditorTree.setFocus();
- entryEditorTree.contextMenu( "New Attribute..." ).click();
- bot.shell( "New Attribute" );
- bot.comboBoxWithLabel( "Attribute type:" ).setText( "member" );
- bot.button( "Finish" ).click();
-
- // DN Editor automatically opened
- bot.shell( "DN Editor" );
- bot.button( "Browse..." ).click();
-
- // select value from DN picker
- bot.shell( "Select DN" );
- SWTBotTree tree = bot.tree( 0 );
- SWTBotUtils.selectEntry( bot, tree, false, "Root DSE", "ou=system", "ou=users",
- "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\"" );
- bot.button( "OK" ).click();
-
- // assert value after selection
- assertEquals( "Unexpected value", "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\",ou=users,ou=system", bot.comboBox()
- .getText() );
-
- // save value
- bot.button( "OK" ).click();
- bot.sleep( 1000 );
+ browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=groups", "cn=My Group" );
+
+ EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( "cn=My Group,ou=groups,ou=system" );
+ entryEditorBot.activate();
+ String dn = entryEditorBot.getDnText();
+ assertEquals( "DN: cn=My Group,ou=groups,ou=system", dn );
+ assertEquals( 4, entryEditorBot.getAttributeValues().size() );
+
+ // add member attribute
+ NewAttributeWizardBot wizardBot = entryEditorBot.openNewAttributeWizard();
+ assertTrue( wizardBot.isVisible() );
+ wizardBot.typeAttributeType( "member" );
+ DnEditorDialogBot dnEditorBot = wizardBot.clickFinishButtonExpectingDnEditor();
+ assertTrue( dnEditorBot.isVisible() );
+ SelectDnDialogBot selectDnBot = dnEditorBot.clickBrowseButtonExpectingSelectDnDialog();
+ assertTrue( selectDnBot.isVisible() );
+ selectDnBot.selectEntry( "Root DSE", "ou=system", "ou=users", "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\"" );
+ selectDnBot.clickOkButton();
+ assertEquals( "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\",ou=users,ou=system", dnEditorBot.getDnText() );
+ dnEditorBot.clickOkButton();
// assert value after saved and reloaded from server
- entryEditorTree.select( 3 );
- entryEditorTree.getTreeItem( "member" ).doubleClick();
- assertEquals( "Unexpected value", "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\",ou=users,ou=system", bot.comboBox()
- .getText() );
- bot.button( "Cancel" ).click();
+ SWTUtils.sleep( 1000 );
+ assertEquals( 5, entryEditorBot.getAttributeValues().size() );
+ assertTrue( entryEditorBot.getAttributeValues().contains(
+ "member: cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\",ou=users,ou=system" ) );
+ dnEditorBot = entryEditorBot.editValueExpectingDnEditor( "member",
+ "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\",ou=users,ou=system" );
+ assertEquals( "cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\",ou=users,ou=system", dnEditorBot.getDnText() );
+ dnEditorBot.clickCancelButton();
}
}
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=834280&r1=834279&r2=834280&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 Mon Nov 9 23:46:04 2009
@@ -196,7 +196,7 @@
wizardBot.setRdnValue( 1, "testCreatePersonEntry" );
wizardBot.clickNextButton();
- wizardBot.setAttributeValue( "sn", 1, "test" );
+ wizardBot.typeValueAndFinish( "test" );
wizardBot.clickFinishButton();
assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "cn=testCreatePersonEntry" ) );
@@ -280,8 +280,10 @@
wizardBot.setRdnValue( 1, "kadmin/changepw@DOMAIN" );
wizardBot.clickNextButton();
- wizardBot.setAttributeValue( "cn", 1, "test" );
- wizardBot.setAttributeValue( "sn", 1, "test" );
+ wizardBot.editValue( "cn", "" );
+ wizardBot.typeValueAndFinish( "test" );
+ wizardBot.editValue( "sn", "" );
+ wizardBot.typeValueAndFinish( "test" );
wizardBot.clickFinishButton();
assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system",
Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java?rev=834280&r1=834279&r2=834280&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java (original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java Mon Nov 9 23:46:04 2009
@@ -20,258 +20,93 @@
package org.apache.directory.studio.test.integration.ui.bots;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
import org.apache.directory.studio.test.integration.ui.ContextMenuHelper;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
-import org.eclipse.swtbot.swt.finder.results.VoidResult;
-import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
-import org.eclipse.swtbot.swt.finder.waits.ICondition;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
public class BrowserViewBot
{
- private SWTWorkbenchBot bot = new SWTWorkbenchBot();
+ private SWTWorkbenchBot bot;
+ private BrowserWidgetBot browserBot;
+
+
+ public BrowserViewBot()
+ {
+ bot = new SWTWorkbenchBot();
+ SWTBotView view = bot.viewByTitle( "LDAP Browser" );
+ view.show();
+
+ browserBot = new BrowserWidgetBot( view.bot() );
+ }
public boolean existsEntry( String... path )
{
- // ensure the parent exists
- String[] parentPath = new String[path.length - 1];
- System.arraycopy( path, 0, parentPath, 0, parentPath.length );
- getEntry( parentPath );
-
- // check if the child exists
- try
- {
- getEntry( path );
- return true;
- }
- catch ( WidgetNotFoundException e )
- {
- return false;
- }
+ return browserBot.existsEntry( path );
}
public void selectEntry( String... path )
{
- SWTBotTreeItem entry = getEntry( path );
- select( entry );
+ browserBot.selectEntry( path );
}
public void selectChildrenOfEnty( String[] children, String... path )
{
- SWTBotTreeItem entry = getEntry( path );
- entry.select( children );
+ browserBot.selectChildrenOfEnty( children, path );
}
public ReferralDialogBot selectEntryExpectingReferralDialog( String... path )
{
- SWTBotTreeItem entry = getEntry( path );
- select( entry );
- return new ReferralDialogBot();
+ return browserBot.selectEntryExpectingReferralDialog( path );
}
public void expandEntry( String... path )
{
- SWTBotTreeItem entry = getEntry( path );
- expand( entry, true, null );
+ browserBot.expandEntry( path );
}
public void waitForEntry( String... path )
{
- getEntry( path );
+ browserBot.waitForEntry( path );
}
public ReferralDialogBot expandEntryExpectingReferralDialog( String... path )
{
- SWTBotTreeItem entry = getEntry( path );
- expand( entry, false, null );
- return new ReferralDialogBot();
+ return browserBot.expandEntryExpectingReferralDialog( path );
}
public NewEntryWizardBot openNewEntryWizard()
{
- ContextMenuHelper.clickContextMenu( getBrowserTree(), "New", "New Entry..." );
+ ContextMenuHelper.clickContextMenu( browserBot.getTree(), "New", "New Entry..." );
return new NewEntryWizardBot();
}
public RenameEntryDialogBot openRenameDialog()
{
- ContextMenuHelper.clickContextMenu( getBrowserTree(), "Rename Entry..." );
+ ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Rename Entry..." );
return new RenameEntryDialogBot();
}
public DeleteDialogBot openDeleteDialog()
{
- ContextMenuHelper.clickContextMenu( getBrowserTree(), "Delete Entries" );
+ ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Delete Entries" );
return new DeleteDialogBot();
}
- private SWTBotTreeItem getEntry( String... path )
- {
- SWTBotTree browserTree = getBrowserTree();
- List<String> pathList = new ArrayList<String>( Arrays.asList( path ) );
- SWTBotTreeItem entry = null;
-
- while ( !pathList.isEmpty() )
- {
- String node = pathList.remove( 0 );
-
- if ( entry == null )
- {
- node = adjustNodeName( browserTree, node );
- entry = browserTree.getTreeItem( node );
- }
- else
- {
- // adjust current path, because the label is decorated with the
- // number of children
- node = adjustNodeName( entry, node );
- entry = entry.getNode( node );
- }
-
- if ( !pathList.isEmpty() )
- {
- // expand entry and wait till
- // - children are displayed
- // - next child is visible
- final String nextNode = !pathList.isEmpty() ? pathList.get( 0 ) : null;
- expand( entry, true, nextNode );
- }
- }
-
- return entry;
- }
-
-
- private void expand( final SWTBotTreeItem entry, boolean wait, final String nextNode )
- {
- UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
- {
- public void run()
- {
- entry.expand();
- }
- } );
-
- if ( wait )
- {
- bot.waitUntil( new DefaultCondition()
- {
- public boolean test() throws Exception
- {
- // if ( nextNode != null )
- // {
- // String adjustedNodeName = nextNode != null ? adjustNodeName( entry, nextNode ) : null;
- // SWTBotTreeItem node = entry.getNode( adjustedNodeName );
- // if ( node == null )
- // {
- // return false;
- // }
- // }
- return !entry.getNodes().contains( "Fetching Entries..." )
- && !entry.getNodes().contains( "Opening Connection..." );
- }
-
-
- public String getFailureMessage()
- {
- return "Could not find entry " + entry.getText() + " -> " + nextNode;
- }
- } );
- }
- }
-
-
- private void select( final SWTBotTreeItem entry )
- {
- if ( !getBrowserTree().isEnabled() )
- {
- bot.waitUntil( new ICondition()
- {
-
- public boolean test() throws Exception
- {
- return getBrowserTree().isEnabled();
- }
-
-
- public void init( SWTBot bot )
- {
- }
-
-
- public String getFailureMessage()
- {
- return "Entry " + entry + " is not enabled!";
- }
- } );
- }
- entry.click();
- entry.select();
- }
-
-
- private String adjustNodeName( SWTBotTreeItem child, String nodeName )
- {
- List<String> nodes = child.getNodes();
- for ( String node : nodes )
- {
- if ( node.toUpperCase().startsWith( nodeName.toUpperCase() ) )
- {
- return node;
- }
- }
- return nodeName;
- }
-
-
- private String adjustNodeName( SWTBotTree tree, String nodeName )
- {
- SWTBotTreeItem[] allItems = tree.getAllItems();
- for ( SWTBotTreeItem item : allItems )
- {
- String node = item.getText();
- if ( node.toUpperCase().startsWith( nodeName.toUpperCase() ) )
- {
- return node;
- }
- }
- return nodeName;
- }
-
-
- private SWTBotTree getBrowserTree()
- {
- SWTBotView view = bot.viewByTitle( "LDAP Browser" );
- view.show();
- SWTBotTree tree = view.bot().tree();
- return tree;
- }
-
-
public void refresh()
{
- ContextMenuHelper.clickContextMenu( getBrowserTree(), "Reload Entry" );
+ ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Reload Entry" );
}
}
Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java?rev=834280&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java Mon Nov 9 23:46:04 2009
@@ -0,0 +1,225 @@
+package org.apache.directory.studio.test.integration.ui.bots;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+
+
+class BrowserWidgetBot
+{
+ private SWTBot bot;
+
+
+ BrowserWidgetBot( SWTBot bot )
+ {
+ this.bot = bot;
+ }
+
+
+ boolean existsEntry( String... path )
+ {
+ // ensure the parent exists
+ String[] parentPath = new String[path.length - 1];
+ System.arraycopy( path, 0, parentPath, 0, parentPath.length );
+ getEntry( parentPath );
+
+ // check if the child exists
+ try
+ {
+ getEntry( path );
+ return true;
+ }
+ catch ( WidgetNotFoundException e )
+ {
+ return false;
+ }
+ }
+
+
+ void selectEntry( String... path )
+ {
+ SWTBotTreeItem entry = getEntry( path );
+ select( entry );
+ }
+
+
+ void selectChildrenOfEnty( String[] children, String... path )
+ {
+ SWTBotTreeItem entry = getEntry( path );
+ entry.select( children );
+ }
+
+
+ ReferralDialogBot selectEntryExpectingReferralDialog( String... path )
+ {
+ SWTBotTreeItem entry = getEntry( path );
+ select( entry );
+ return new ReferralDialogBot();
+ }
+
+
+ void expandEntry( String... path )
+ {
+ SWTBotTreeItem entry = getEntry( path );
+ expand( entry, true, null );
+ }
+
+
+ void waitForEntry( String... path )
+ {
+ getEntry( path );
+ }
+
+
+ ReferralDialogBot expandEntryExpectingReferralDialog( String... path )
+ {
+ SWTBotTreeItem entry = getEntry( path );
+ expand( entry, false, null );
+ return new ReferralDialogBot();
+ }
+
+
+ private SWTBotTreeItem getEntry( String... path )
+ {
+ SWTBotTree browserTree = bot.tree();
+ List<String> pathList = new ArrayList<String>( Arrays.asList( path ) );
+ SWTBotTreeItem entry = null;
+
+ while ( !pathList.isEmpty() )
+ {
+ String node = pathList.remove( 0 );
+
+ if ( entry == null )
+ {
+ node = adjustNodeName( browserTree, node );
+ entry = browserTree.getTreeItem( node );
+ }
+ else
+ {
+ // adjust current path, because the label is decorated with the
+ // number of children
+ node = adjustNodeName( entry, node );
+ entry = entry.getNode( node );
+ }
+
+ if ( !pathList.isEmpty() )
+ {
+ // expand entry and wait till
+ // - children are displayed
+ // - next child is visible
+ final String nextNode = !pathList.isEmpty() ? pathList.get( 0 ) : null;
+ expand( entry, true, nextNode );
+ }
+ }
+
+ return entry;
+ }
+
+
+ private void expand( final SWTBotTreeItem entry, boolean wait, final String nextNode )
+ {
+ UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
+ {
+ public void run()
+ {
+ entry.expand();
+ }
+ } );
+
+ if ( wait )
+ {
+ bot.waitUntil( new DefaultCondition()
+ {
+ public boolean test() throws Exception
+ {
+ // if ( nextNode != null )
+ // {
+ // String adjustedNodeName = nextNode != null ? adjustNodeName( entry, nextNode ) : null;
+ // SWTBotTreeItem node = entry.getNode( adjustedNodeName );
+ // if ( node == null )
+ // {
+ // return false;
+ // }
+ // }
+ return !entry.getNodes().contains( "Fetching Entries..." )
+ && !entry.getNodes().contains( "Opening Connection..." );
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Could not find entry " + entry.getText() + " -> " + nextNode;
+ }
+ } );
+ }
+ }
+
+
+ private void select( final SWTBotTreeItem entry )
+ {
+ if ( !bot.tree().isEnabled() )
+ {
+ bot.waitUntil( new DefaultCondition()
+ {
+
+ public boolean test() throws Exception
+ {
+ return bot.tree().isEnabled();
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Entry " + entry + " is not enabled!";
+ }
+ } );
+ }
+ entry.click();
+ entry.select();
+ }
+
+
+ private String adjustNodeName( SWTBotTreeItem child, String nodeName )
+ {
+ List<String> nodes = child.getNodes();
+ for ( String node : nodes )
+ {
+ if ( node.toUpperCase().startsWith( nodeName.toUpperCase() ) )
+ {
+ return node;
+ }
+ }
+ return nodeName;
+ }
+
+
+ private String adjustNodeName( SWTBotTree tree, String nodeName )
+ {
+ SWTBotTreeItem[] allItems = tree.getAllItems();
+ for ( SWTBotTreeItem item : allItems )
+ {
+ String node = item.getText();
+ if ( node.toUpperCase().startsWith( nodeName.toUpperCase() ) )
+ {
+ return node;
+ }
+ }
+ return nodeName;
+ }
+
+
+ SWTBotTree getTree()
+ {
+ return bot.tree();
+ }
+
+}
Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DnEditorDialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DnEditorDialogBot.java?rev=834280&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DnEditorDialogBot.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DnEditorDialogBot.java Mon Nov 9 23:46:04 2009
@@ -0,0 +1,56 @@
+/*
+ * 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.bots;
+
+
+public class DnEditorDialogBot extends DialogBot
+{
+
+ public boolean isVisible()
+ {
+ return super.isVisible( "DN Editor" );
+ }
+
+
+ public void clickOkButton()
+ {
+ super.clickButton( "OK" );
+ }
+
+
+ public void clickCancelButton()
+ {
+ super.clickButton( "Cancel" );
+ }
+
+
+ public SelectDnDialogBot clickBrowseButtonExpectingSelectDnDialog()
+ {
+ super.clickButton( "Browse..." );
+ return new SelectDnDialogBot();
+ }
+
+
+ public String getDnText()
+ {
+ return bot.comboBox().getText();
+ }
+
+}
Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java?rev=834280&r1=834279&r2=834280&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java (original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java Mon Nov 9 23:46:04 2009
@@ -21,13 +21,11 @@
package org.apache.directory.studio.test.integration.ui.bots;
-import java.util.ArrayList;
import java.util.List;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
public class EntryEditorBot
@@ -35,6 +33,7 @@
private SWTBotEditor editor;
private SWTBot bot;
+ private EntryEditorWidgetBot editorBot;
public EntryEditorBot( String title )
@@ -42,6 +41,7 @@
SWTWorkbenchBot bot = new SWTWorkbenchBot();
editor = bot.editorByTitle( title );
this.bot = editor.bot();
+ this.editorBot = new EntryEditorWidgetBot( editor.bot() );
}
@@ -60,16 +60,50 @@
public List<String> getAttributeValues()
{
- SWTBotTree tree = bot.tree();
- List<String> attributes = new ArrayList<String>();
- int rowCount = tree.rowCount();
- for ( int i = 0; i < rowCount; i++ )
- {
- String attribute = tree.cell( i, 0 );
- String value = tree.cell( i, 1 );
- attributes.add( attribute + ": " + value );
- }
- return attributes;
+ return editorBot.getAttributeValues();
+ }
+
+
+ public NewAttributeWizardBot openNewAttributeWizard()
+ {
+ return editorBot.openNewAttributeWizard();
+ }
+
+
+ public void activate()
+ {
+ editor.setFocus();
+ bot.tree().setFocus();
+ }
+
+
+ public void typeValueAndFinish( String value )
+ {
+ editorBot.typeValueAndFinish( value );
+ }
+
+
+ public void addValue( String attributeType )
+ {
+ editorBot.addValue( attributeType );
+ }
+
+
+ public void editValue( String attributeType, String value )
+ {
+ editorBot.editValue( attributeType, value );
+ }
+
+
+ public DnEditorDialogBot editValueExpectingDnEditor( String attributeType, String value )
+ {
+ return editorBot.editValueExpectingDnEditor( attributeType, value );
+ }
+
+
+ public void deleteValue( String attributeType, String value )
+ {
+ editorBot.deleteValue( attributeType, value );
}
}
Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java?rev=834280&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java Mon Nov 9 23:46:04 2009
@@ -0,0 +1,120 @@
+package org.apache.directory.studio.test.integration.ui.bots;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.test.integration.ui.ContextMenuHelper;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+
+
+class EntryEditorWidgetBot
+{
+ private SWTBot bot;
+
+
+ EntryEditorWidgetBot( SWTBot bot )
+ {
+ this.bot = bot;
+ }
+
+
+ boolean isVisisble()
+ {
+ return bot.tree() != null;
+ }
+
+
+ List<String> getAttributeValues()
+ {
+ SWTBotTree tree = bot.tree();
+ List<String> attributes = new ArrayList<String>();
+ int rowCount = tree.rowCount();
+ for ( int i = 0; i < rowCount; i++ )
+ {
+ String attribute = tree.cell( i, 0 );
+ String value = tree.cell( i, 1 );
+ attributes.add( attribute + ": " + value );
+ }
+ return attributes;
+ }
+
+
+ NewAttributeWizardBot openNewAttributeWizard()
+ {
+ ContextMenuHelper.clickContextMenu( bot.tree(), "New Attribute..." );
+ return new NewAttributeWizardBot();
+ }
+
+
+ void typeValueAndFinish( String value )
+ {
+ SWTBotPreferences.KEYBOARD_LAYOUT = "org.eclipse.swtbot.swt.finder.keyboard.EN_US";
+ SWTBotText text = bot.text( 1 );
+ text.setText( value );
+ bot.tree().pressShortcut( Keystrokes.LF );
+ }
+
+
+ void cancelEditValue()
+ {
+ SWTBotTree tree = bot.tree( 0 );
+ tree.getTreeItem( "objectClass" ).click();
+ }
+
+
+ void addValue( String attributeType )
+ {
+ SWTBotTree tree = bot.tree();
+ tree.getTreeItem( attributeType ).click();
+ ContextMenuHelper.clickContextMenu( bot.tree(), "New Value" );
+ }
+
+
+ void editValue( String attributeType, String value )
+ {
+ cancelEditValue();
+ SWTBotTreeItem treeItem = getTreeItem( attributeType, value );
+ System.out.println( treeItem.cell( 0 ) + " - '" + treeItem.cell( 1 ) + "'" );
+ treeItem.doubleClick();
+ }
+
+
+ DnEditorDialogBot editValueExpectingDnEditor( String attributeType, String value )
+ {
+ editValue( attributeType, value );
+ return new DnEditorDialogBot();
+ }
+
+
+ private SWTBotTreeItem getTreeItem( String attributeType, String value )
+ {
+ SWTBotTree tree = bot.tree();
+ SWTBotTreeItem[] allItems = tree.getAllItems();
+ for ( SWTBotTreeItem item : allItems )
+ {
+ if ( item.cell( 0 ).equals( attributeType ) && item.cell( 1 ).equals( value ) )
+ {
+ return item;
+ }
+ }
+ throw new WidgetNotFoundException( "Attribute " + attributeType + ":" + value + " not found." );
+ }
+
+
+ void deleteValue( String attributeType, String value )
+ {
+ SWTBotTreeItem treeItem = getTreeItem( attributeType, value );
+ treeItem.click();
+ ContextMenuHelper.clickContextMenu( bot.tree(), "Delete Value" );
+ DeleteDialogBot deleteDialogBot = new DeleteDialogBot();
+ deleteDialogBot.clickOkButton();
+ }
+
+}
Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java?rev=834280&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java Mon Nov 9 23:46:04 2009
@@ -0,0 +1,44 @@
+/*
+ * 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.bots;
+
+
+public class NewAttributeWizardBot extends WizardBot
+{
+
+ public boolean isVisible()
+ {
+ return isVisible( "New Attribute" );
+ }
+
+
+ public void typeAttributeType( String text )
+ {
+ bot.comboBox().setText( text );
+ }
+
+
+ public DnEditorDialogBot clickFinishButtonExpectingDnEditor()
+ {
+ clickFinishButton();
+ return new DnEditorDialogBot();
+ }
+
+}
Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewEntryWizardBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewEntryWizardBot.java?rev=834280&r1=834279&r2=834280&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewEntryWizardBot.java (original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewEntryWizardBot.java Mon Nov 9 23:46:04 2009
@@ -21,12 +21,18 @@
import org.apache.directory.shared.ldap.name.LdapDN;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
public class NewEntryWizardBot extends WizardBot
{
+ private EntryEditorWidgetBot widgetBot;
+
+
+ public NewEntryWizardBot()
+ {
+ this.widgetBot = new EntryEditorWidgetBot( bot );
+ }
+
public boolean isVisible()
{
@@ -67,19 +73,24 @@
}
- public void setAttributeValue( String type, int number, String value )
+ public void typeValueAndFinish( String value )
{
- SWTBotTree tree = bot.tree( 0 );
+ widgetBot.isVisisble();
+ widgetBot.typeValueAndFinish( value );
+ }
- // click to finish editing of value
- tree.getTreeItem( type ).click();
- tree.getTreeItem( type ).doubleClick();
- SWTBotText text = bot.text( "" );
- text.setText( value );
+ public void editValue( String attributeType, String value )
+ {
+ widgetBot.isVisisble();
+ widgetBot.editValue( attributeType, value );
+ }
- // click to finish editing of value
- tree.getTreeItem( type ).click();
+
+ public void cancelEditValue()
+ {
+ widgetBot.isVisisble();
+ widgetBot.cancelEditValue();
}
Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SelectDnDialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SelectDnDialogBot.java?rev=834280&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SelectDnDialogBot.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SelectDnDialogBot.java Mon Nov 9 23:46:04 2009
@@ -0,0 +1,59 @@
+/*
+ * 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.bots;
+
+
+public class SelectDnDialogBot extends DialogBot
+{
+
+ private BrowserWidgetBot browserBot;
+
+
+ public SelectDnDialogBot()
+ {
+ super();
+ browserBot = new BrowserWidgetBot( bot );
+ }
+
+
+ public boolean isVisible()
+ {
+ return super.isVisible( "Select DN" );
+ }
+
+
+ public void clickOkButton()
+ {
+ super.clickButton( "OK" );
+ }
+
+
+ public void clickCancelButton()
+ {
+ super.clickButton( "Cancel" );
+ }
+
+
+ public void selectEntry( String... path )
+ {
+ browserBot.selectEntry( path );
+ }
+
+}