directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r830104 - in /directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui: BrowserTest.java SWTBotUtils.java bots/BrowserViewBot.java bots/DeleteDialogBot.java
Date Tue, 27 Oct 2009 09:35:55 GMT
Author: seelmann
Date: Tue Oct 27 09:35:55 2009
New Revision: 830104

URL: http://svn.apache.org/viewvc?rev=830104&view=rev
Log:
o Use helper bot for tests
o Added workaround to press refresh button

Added:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DeleteDialogBot.java
Modified:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SWTBotUtils.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java?rev=830104&r1=830103&r2=830104&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java
Tue Oct 27 09:35:55 2009
@@ -30,13 +30,12 @@
 import org.apache.directory.server.integ.SiRunner;
 import org.apache.directory.server.ldap.LdapServer;
 import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+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.StudioBot;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -59,6 +58,7 @@
 
     private StudioBot studioBot;
     private ConnectionsViewBot connectionsViewBot;
+    private BrowserViewBot browserViewBot;
 
     private SWTWorkbenchBot eBot;
 
@@ -70,6 +70,7 @@
         studioBot.resetLdapPerspective();
         connectionsViewBot = studioBot.getConnectionView();
         connectionsViewBot.createTestConnection( "BrowserTest", ldapServer.getPort() );
+        browserViewBot = studioBot.getBrowserView();
 
         eBot = new SWTWorkbenchBot();
     }
@@ -94,8 +95,7 @@
     @Test
     public void testOnlyOneSearchRequestWhenExpandingEntry() throws Exception
     {
-        SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( eBot );
-        SWTBotUtils.selectEntry( eBot, browserTree, false, "DIT", "Root DSE", "ou=system"
);
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" );
 
         // get number of search requests before expanding the entry
         SWTBotStyledText searchLogsText = SWTBotUtils.getSearchLogsText( eBot );
@@ -103,13 +103,14 @@
         int countMatchesBefore = StringUtils.countMatches( text, "#!SEARCH REQUEST" );
 
         // expand
-        browserTree = SWTBotUtils.getLdapBrowserTree( eBot );
-        SWTBotUtils.selectEntry( eBot, browserTree, true, "DIT", "Root DSE", "ou=system"
);
+        browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system" );
+        browserViewBot.waitForEntry( "DIT", "Root DSE", "ou=system", "ou=users" );
 
         // get number of search requests after expanding the entry
         searchLogsText = SWTBotUtils.getSearchLogsText( eBot );
         text = searchLogsText.getText();
         int countMatchesAfter = StringUtils.countMatches( text, "#!SEARCH REQUEST" );
+        System.out.println( "countMatchesAfter: " + countMatchesAfter );
 
         assertEquals( "Expected exactly 1 search request", 1, countMatchesAfter - countMatchesBefore
);
     }
@@ -125,35 +126,19 @@
     @Test
     public void testDeleteDontUpdateUI() throws Exception
     {
-        final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( eBot );
-        SWTBotTreeItem ou = SWTBotUtils.selectEntry( eBot, browserTree, true, "DIT", "Root
DSE", "ou=system",
-            "ou=users" );
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" );
+        browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" );
 
         long fireCount0 = EventRegistry.getFireCount();
 
         // delete
-        ou.select( "uid=user.1", "uid=user.2", "uid=user.3", "uid=user.4", "uid=user.5",
"uid=user.6", "uid=user.7",
-            "uid=user.8" );
-        browserTree.contextMenu( "Delete Entries" ).click();
-        eBot.shell( "Delete Entries" );
-        eBot.button( "OK" ).click();
-
-        // wait until tree is refreshed, that is if ou=users doesn't has any children
-        eBot.waitUntil( new DefaultCondition()
-        {
-            public boolean test() throws Exception
-            {
-                SWTBotTreeItem ou = SWTBotUtils.selectEntry( eBot, browserTree, true, "DIT",
"Root DSE", "ou=system",
-                    "ou=users" );
-                return "ou=users".equals( ou.getText() ) && ou.getNodes().isEmpty();
-            }
-
-
-            public String getFailureMessage()
-            {
-                return "'ou=users' should be selected and should not contain any children";
-            }
-        } );
+        String[] children = new String[]
+            { "uid=user.1", "uid=user.2", "uid=user.3", "uid=user.4", "uid=user.5", "uid=user.6",
"uid=user.7",
+                "uid=user.8" };
+        browserViewBot.selectChildrenOfEnty( children, "DIT", "Root DSE", "ou=system", "ou=users"
);
+        DeleteDialogBot deleteDialog = browserViewBot.openDeleteDialog();
+        deleteDialog.clickOkButton();
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" );
 
         long fireCount1 = EventRegistry.getFireCount();
 

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=830104&r1=830103&r2=830104&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 27 09:35:55 2009
@@ -21,20 +21,17 @@
 package org.apache.directory.studio.test.integration.ui;
 
 
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
 import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withStyle;
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withTooltip;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import org.apache.directory.studio.connection.core.Connection;
-import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
-import org.apache.directory.studio.connection.core.ConnectionFolder;
-import org.apache.directory.studio.connection.core.ConnectionFolderManager;
-import org.apache.directory.studio.connection.core.ConnectionManager;
-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.SWT;
+import org.eclipse.swt.widgets.ToolItem;
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
@@ -46,9 +43,11 @@
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
 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.hamcrest.Matcher;
 
 
 /**
@@ -117,7 +116,12 @@
     {
         SWTBotView view = bot.viewByTitle( "Search Logs" );
         view.show();
-        // view.toolbarButton( "Refresh" ).click();
+        //view.toolbarButton( "Refresh" ).click();
+        // just a workaround till view.toolbarButton() is fixed
+        Matcher matcher = allOf( widgetOfType( ToolItem.class ), withTooltip( "Refresh" ),
withStyle( SWT.PUSH,
+            "SWT.PUSH" ) );
+        SWTBotToolbarButton button = new SWTBotToolbarButton( ( ToolItem ) bot.widget( matcher,
0 ), matcher );
+        button.click();
         return view.bot().styledText();
     }
 
@@ -138,6 +142,11 @@
         SWTBotView view = bot.viewByTitle( "Modification Logs" );
         view.show();
         //  view.toolbarButton( "Refresh" ).click();
+        // just a workaround till view.toolbarButton() is fixed
+        Matcher matcher = allOf( widgetOfType( ToolItem.class ), withTooltip( "Refresh" ),
withStyle( SWT.PUSH,
+            "SWT.PUSH" ) );
+        SWTBotToolbarButton button = new SWTBotToolbarButton( ( ToolItem ) bot.widget( matcher,
0 ), matcher );
+        button.click();
         return view.bot().styledText();
     }
 

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=830104&r1=830103&r2=830104&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
Tue Oct 27 09:35:55 2009
@@ -69,6 +69,13 @@
     }
 
 
+    public void selectChildrenOfEnty( String[] children, String... path )
+    {
+        SWTBotTreeItem entry = getEntry( path );
+        entry.select( children );
+    }
+
+
     public ReferralDialogBot selectEntryExpectingReferralDialog( String... path )
     {
         SWTBotTreeItem entry = getEntry( path );
@@ -84,6 +91,12 @@
     }
 
 
+    public void waitForEntry( String... path )
+    {
+        getEntry( path );
+    }
+
+
     public ReferralDialogBot expandEntryExpectingReferralDialog( String... path )
     {
         SWTBotTreeItem entry = getEntry( path );
@@ -106,6 +119,13 @@
     }
 
 
+    public DeleteDialogBot openDeleteDialog()
+    {
+        ContextMenuHelper.clickContextMenu( getBrowserTree(), "Delete Entries" );
+        return new DeleteDialogBot();
+    }
+
+
     private SWTBotTreeItem getEntry( String... path )
     {
         SWTBotTree browserTree = getBrowserTree();

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DeleteDialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DeleteDialogBot.java?rev=830104&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DeleteDialogBot.java
(added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DeleteDialogBot.java
Tue Oct 27 09:35:55 2009
@@ -0,0 +1,43 @@
+/*
+ *  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 DeleteDialogBot extends DialogBot
+{
+
+    public boolean isVisible()
+    {
+        return super.isVisible( "Delete Entries" );
+    }
+
+
+    public void clickOkButton()
+    {
+        super.clickButton( "OK" );
+    }
+
+
+    public void clickCancelButton()
+    {
+        super.clickButton( "Cancel" );
+    }
+
+}



Mime
View raw message