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/10/13 12:37:59 UTC
svn commit: r824681 - in
/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui:
EntryEditorTest.java SWTBotUtils.java
Author: seelmann
Date: Tue Oct 13 10:37:59 2009
New Revision: 824681
URL: http://svn.apache.org/viewvc?rev=824681&view=rev
Log:
o updated entry editor tests
o simplified click()
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/SWTBotUtils.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=824681&r1=824680&r2=824681&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 Tue Oct 13 10:37:59 2009
@@ -29,7 +29,6 @@
import org.apache.directory.server.integ.SiRunner;
import org.apache.directory.server.ldap.LdapServer;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.junit.After;
import org.junit.Before;
@@ -84,168 +83,45 @@
SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ou=users",
"cn=Barbara Jensen" );
- final SWTBotTree entryEditorTree = SWTBotUtils.getEntryEditorTree( bot );
+ final SWTBotTree entryEditorTree = SWTBotUtils.getEntryEditorTree( bot, "cn=Barbara Jensen,ou=users,ou=system" );
+ entryEditorTree.setFocus();
// add description attribute
entryEditorTree.contextMenu( "New Attribute..." ).click();
bot.comboBoxWithLabel( "Attribute type:" ).setText( "description" );
- SWTBotUtils.asyncClick( bot, bot.button( "Finish" ), new DefaultCondition()
- {
- public boolean test() throws Exception
- {
- return bot.text( "" ) != null;
- }
-
-
- public String getFailureMessage()
- {
- return "Could not find empty description attribute";
- }
- } );
+ bot.button( "Finish" ).click();
bot.text( "" ).setText( "This is the 1st description." );
- SWTBotUtils.asyncClick( bot, entryEditorTree.getTreeItem( "objectClass" ), new DefaultCondition()
- {
- public boolean test() throws Exception
- {
- return entryEditorTree.cell( 6, 0 ).equals( "description" )
- && entryEditorTree.cell( 6, 1 ).equals( "This is the 1st description." );
- }
-
-
- public String getFailureMessage()
- {
- return "Could not find attribute 'description:This is the 1st description.'";
- }
- } );
+ entryEditorTree.getTreeItem( "objectClass" ).click();
// add second value
entryEditorTree.getTreeItem( "description" ).click();
- SWTBotUtils.asyncClick( bot, entryEditorTree.contextMenu( "New Value" ), new DefaultCondition()
- {
- public boolean test() throws Exception
- {
- return bot.text( "" ) != null;
- }
-
-
- public String getFailureMessage()
- {
- return "Could not find empty description attribute";
- }
- } );
+ entryEditorTree.contextMenu( "New Value" ).click();
bot.text( "" ).setText( "This is the 2nd description." );
- SWTBotUtils.asyncClick( bot, entryEditorTree.getTreeItem( "objectClass" ), new DefaultCondition()
- {
- public boolean test() throws Exception
- {
- return entryEditorTree.cell( 7, 0 ).equals( "description" )
- && entryEditorTree.cell( 7, 1 ).equals( "This is the 2nd description." );
- }
-
-
- public String getFailureMessage()
- {
- return "Could not find attribute 'description:This is the 2nd description.'";
- }
- } );
+ entryEditorTree.getTreeItem( "objectClass" ).click();
// edit second value
entryEditorTree.select( 7 );
- SWTBotUtils.asyncClick( bot, entryEditorTree.contextMenu( "Edit Value" ), new DefaultCondition()
- {
- public boolean test() throws Exception
- {
- return bot.text( "This is the 2nd description." ) != null;
- }
-
-
- public String getFailureMessage()
- {
- return "Could not find description 'This is the 2nd description.'";
- }
- } );
+ entryEditorTree.contextMenu( "Edit Value" ).click();
bot.text( "This is the 2nd description." ).setText( "This is the 3rd description." );
- SWTBotUtils.asyncClick( bot, entryEditorTree.getTreeItem( "objectClass" ), new DefaultCondition()
- {
- public boolean test() throws Exception
- {
- return entryEditorTree.cell( 7, 0 ).equals( "description" )
- && entryEditorTree.cell( 7, 1 ).equals( "This is the 3rd description." );
- }
-
-
- public String getFailureMessage()
- {
- return "Could not find attribute 'description:This is the 3rd description.'";
- }
- } );
+ entryEditorTree.getTreeItem( "objectClass" ).click();
// delete second value
entryEditorTree.select( 7 );
entryEditorTree.contextMenu( "Delete Value" ).click();
- SWTBotUtils.asyncClick( bot, bot.button( "OK" ), new DefaultCondition()
- {
- public boolean test() throws Exception
- {
- return !entryEditorTree.cell( 7, 0 ).equals( "description" )
- && entryEditorTree.cell( 6, 0 ).equals( "description" )
- && entryEditorTree.cell( 6, 1 ).equals( "This is the 1st description." );
- }
-
-
- public String getFailureMessage()
- {
- return "Attribute 'description' is still there.";
- }
- } );
+ bot.shell( "Delete Value" );
+ bot.button( "OK" ).click();
// edit 1st value
entryEditorTree.select( 6 );
- SWTBotUtils.asyncClick( bot, entryEditorTree.contextMenu( "Edit Value" ), new DefaultCondition()
- {
- public boolean test() throws Exception
- {
- return bot.text( "This is the 1st description." ) != null;
- }
-
-
- public String getFailureMessage()
- {
- return "Could not find description 'This is the 1st description.'";
- }
- } );
+ entryEditorTree.contextMenu( "Edit Value" ).click();
bot.text( "This is the 1st description." ).setText( "This is the final description." );
- SWTBotUtils.asyncClick( bot, entryEditorTree.getTreeItem( "objectClass" ), new DefaultCondition()
- {
- public boolean test() throws Exception
- {
- return entryEditorTree.cell( 6, 0 ).equals( "description" )
- && entryEditorTree.cell( 6, 1 ).equals( "This is the final description." );
- }
-
-
- public String getFailureMessage()
- {
- return "Could not find attribute 'description:This is the final description.'";
- }
- } );
+ entryEditorTree.getTreeItem( "objectClass" ).click();
// delete 1st value/attribute
entryEditorTree.select( 6 );
entryEditorTree.contextMenu( "Delete Value" ).click();
- SWTBotUtils.asyncClick( bot, bot.button( "OK" ), new DefaultCondition()
- {
- public boolean test() throws Exception
- {
- return !entryEditorTree.cell( 6, 0 ).equals( "description" );
- }
-
-
- public String getFailureMessage()
- {
- return "Attribute 'description' is still there.";
- }
- } );
+ bot.shell( "Delete Value" );
+ bot.button( "OK" ).click();
}
@@ -263,7 +139,8 @@
"cn=\\#\\\\\\+\\, \\\"\u00F6\u00E9\\\"" );
SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system", "ou=groups", "cn=My Group" );
- SWTBotTree entryEditorTree = SWTBotUtils.getEntryEditorTree( bot );
+ 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" );
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=824681&r1=824680&r2=824681&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 Tue Oct 13 10:37:59 2009
@@ -21,9 +21,7 @@
package org.apache.directory.studio.test.integration.ui;
-import static org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.syncExec;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
-import static org.hamcrest.Matchers.anything;
import java.util.ArrayList;
import java.util.Arrays;
@@ -37,17 +35,12 @@
import org.apache.directory.studio.connection.core.ConnectionParameter;
import org.apache.directory.studio.connection.core.ConnectionParameter.AuthenticationMethod;
import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.Widget;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotWorkbenchPart;
-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.results.WidgetResult;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.waits.ICondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
@@ -57,11 +50,6 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
/**
@@ -99,7 +87,7 @@
}
// open "Open Perspective" dialog
- SWTBotMenu windowMenu = eBot.menu( "Window" );
+ SWTBotMenu windowMenu = eBot.menu( "&Window" );
windowMenu.click();
SWTBotMenu perspectiveMenu = windowMenu.menu( "Open Perspective" );
perspectiveMenu.click();
@@ -253,9 +241,8 @@
{
SWTBotView view = bot.viewByTitle( "Search Logs" );
view.show();
- view.toolbarButton( "Refresh" ).click();
- StyledText styledText = ( StyledText ) bot.widget( widgetOfType( StyledText.class ), view.getWidget() );
- return new SWTBotStyledText( styledText );
+ // view.toolbarButton( "Refresh" ).click();
+ return view.bot().styledText();
}
@@ -274,9 +261,8 @@
{
SWTBotView view = bot.viewByTitle( "Modification Logs" );
view.show();
- view.toolbarButton( "Refresh" ).click();
- StyledText styledText = ( StyledText ) bot.widget( widgetOfType( StyledText.class ), view.getWidget() );
- return new SWTBotStyledText( styledText );
+ // view.toolbarButton( "Refresh" ).click();
+ return view.bot().styledText();
}
@@ -291,65 +277,11 @@
* @throws Exception
* the exception
*/
- public static SWTBotTree getEntryEditorTree( final SWTWorkbenchBot bot ) throws Exception
+ public static SWTBotTree getEntryEditorTree( final SWTWorkbenchBot bot, String title ) throws Exception
{
- Tree tree = UIThreadRunnable.syncExec( new WidgetResult<Tree>()
- {
- public Tree run()
- {
- IWorkbench workbench = PlatformUI.getWorkbench();
- IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
- IWorkbenchPage[] pages = activeWorkbenchWindow.getPages();
- for ( int i = 0; i < pages.length; i++ )
- {
- IWorkbenchPage page = pages[i];
- IEditorReference[] editorReferences = page.getEditorReferences();
- for ( int j = 0; j < editorReferences.length; j++ )
- {
- IEditorReference editorReference = editorReferences[j];
- if ( editorReference.getName().equals( "Entry Editor" ) )
- {
- DummyEditor editor = new DummyEditor( editorReference, bot );
- Tree tree = ( Tree ) bot.widget( widgetOfType( Tree.class ), editor.widget );
- return tree;
-
- }
- }
- }
- throw new WidgetNotFoundException( "Could not find Entry Editor tree" );
- }
- } );
- return new SWTBotTree( tree );
- }
-
- static class DummyEditor extends SWTBotWorkbenchPart<IEditorReference>
- {
- public Widget widget;
-
-
- public DummyEditor( IEditorReference editorReference, SWTWorkbenchBot bot )
- {
- super( editorReference, bot );
- widget = findWidget( anything() );
- }
-
-
- public void setFocus()
- {
- syncExec( new VoidResult()
- {
- public void run()
- {
- ( ( Control ) widget ).setFocus();
- }
- } );
- }
-
-
- public boolean isActive()
- {
- return true;
- }
+ SWTBotEditor editor = bot.editorByTitle( title );
+ SWTBotTree tree = editor.bot().tree();
+ return tree;
}
@@ -503,15 +435,7 @@
currentPath = adjustNodeName( entry, currentPath );
entry = entry.getNode( currentPath );
}
-
- final SWTBotTreeItem tempEntry = entry;
- UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
- {
- public void run()
- {
- tempEntry.select();
- }
- } );
+ entry.click();
if ( !pathList.isEmpty() || expandChild )
{
@@ -522,6 +446,7 @@
expandEntry( bot, entry, nextName );
}
+ entry.select();
}
return entry;
}