directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r880635 - in /directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui: ./ bots/
Date Mon, 16 Nov 2009 07:05:42 GMT
Author: seelmann
Date: Mon Nov 16 07:05:37 2009
New Revision: 880635

URL: http://svn.apache.org/viewvc?rev=880635&view=rev
Log:
Extracted SWTBot calls to reusable helper bots.

Added:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchDialogBot.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPageWrapperBot.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPropertiesDialogBot.java
Modified:
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ContextMenuHelper.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.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/ContextMenuHelper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ContextMenuHelper.java?rev=880635&r1=880634&r2=880635&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ContextMenuHelper.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ContextMenuHelper.java
Mon Nov 16 07:05:37 2009
@@ -20,7 +20,7 @@
 package org.apache.directory.studio.test.integration.ui;
 
 
-import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withRegex;
 import static org.hamcrest.Matchers.allOf;
 import static org.hamcrest.Matchers.instanceOf;
 
@@ -61,7 +61,8 @@
         final Matcher<?>[] matchers = new Matcher<?>[texts.length];
         for ( int i = 0; i < texts.length; i++ )
         {
-            matchers[i] = allOf( instanceOf( MenuItem.class ), withMnemonic( texts[i] ) );
+            // matchers[i] = allOf( instanceOf( MenuItem.class ), withMnemonic( texts[i]
) );
+            matchers[i] = allOf( instanceOf( MenuItem.class ), withRegex( texts[i] ) );
         }
 
         // show

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java?rev=880635&r1=880634&r2=880635&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
Mon Nov 16 07:05:37 2009
@@ -22,6 +22,7 @@
 
 
 import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
 
 import org.apache.directory.server.core.integ.Level;
 import org.apache.directory.server.core.integ.annotations.CleanupLevel;
@@ -30,10 +31,11 @@
 import org.apache.directory.studio.ldapbrowser.core.BrowserConnectionManager;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+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.SearchDialogBot;
+import org.apache.directory.studio.test.integration.ui.bots.SearchPropertiesDialogBot;
 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.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -55,8 +57,7 @@
 
     private StudioBot studioBot;
     private ConnectionsViewBot connectionsViewBot;
-
-    private SWTWorkbenchBot bot;
+    private BrowserViewBot browserViewBot;
 
 
     @Before
@@ -67,8 +68,7 @@
         connectionsViewBot = studioBot.getConnectionView();
         connectionsViewBot.createTestConnection( "SearchTest1", ldapServer.getPort() );
         connectionsViewBot.createTestConnection( "SearchTest2", ldapServer.getPort() );
-
-        bot = new SWTWorkbenchBot();
+        browserViewBot = studioBot.getBrowserView();
     }
 
 
@@ -76,7 +76,6 @@
     public void tearDown() throws Exception
     {
         connectionsViewBot.deleteTestConnections();
-        bot = null;
     }
 
 
@@ -96,21 +95,15 @@
         assertEquals( 0, browserConnection1.getSearchManager().getSearches().size() );
         assertEquals( 0, browserConnection2.getSearchManager().getSearches().size() );
 
-        SWTBotTree connectionsTree = SWTBotUtils.getConnectionsTree( bot );
-        SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
-
         // create a search for in connection 1
-        connectionsTree.select( "SearchTest1" );
-        SWTBotUtils.selectEntry( bot, browserTree, false, "DIT", "Root DSE", "ou=system"
);
-        ContextMenuHelper.clickContextMenu( browserTree, "New", "New Search..." );
-        bot.shell( "Search" );
-        //SWTBotAssert.assertEnabled( bot.textWithLabel( "Connection:" ) );
-        //SWTBotAssert.assertText( "SearchTest1", bot.textWithLabel( "Connection:" ) );
-        bot.textWithLabel( "Search Name:" ).setText( "Search all persons" );
-        bot.comboBoxWithLabel( "Filter:" ).setText( "(objectClass=person)" );
-        //bot.radioWithLabelInGroup( "Subtree", "Scope" ).click();
-        bot.button( "Search" ).click();
-        SWTBotUtils.selectEntry( bot, browserTree, false, "Searches", "Search all persons"
);
+        connectionsViewBot.selectConnection( "SearchTest1" );
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" );
+        SearchDialogBot dialogBot = browserViewBot.openSearchDialog();
+        assertTrue( dialogBot.isVisible() );
+        dialogBot.setSearchName( "Search all persons" );
+        dialogBot.setFilter( "(objectClass=person)" );
+        dialogBot.clickSearchButton();
+        browserViewBot.selectEntry( "Searches", "Search all persons" );
 
         // assert browser connection in searches
         assertEquals( 1, browserConnection1.getSearchManager().getSearches().size() );
@@ -119,14 +112,12 @@
         assertEquals( 0, browserConnection2.getSearchManager().getSearches().size() );
 
         // copy/paste the created search from connection 1 to connection 2
-        ContextMenuHelper.clickContextMenu( browserTree, "Copy Search" );
-        connectionsTree.select( "SearchTest2" );
-        SWTBotUtils.selectEntry( bot, browserTree, false, "Searches" );
-        ContextMenuHelper.clickContextMenu( browserTree, "Paste Search" );
-        bot.shell( "Properties for Search all persons" );
-        //SWTBotAssert.assertNotEnabled( bot.textWithLabel( "Connection:" ) );
-        //SWTBotAssert.assertText( "SearchTest2", bot.textWithLabel( "Connection:" ) );
-        bot.button( "Cancel" ).click();
+        browserViewBot.copy();
+        connectionsViewBot.selectConnection( "SearchTest2" );
+        browserViewBot.selectEntry( "Searches" );
+        SearchPropertiesDialogBot searchPropertiesDialogBot = browserViewBot.pasteSearch();
+        assertTrue( searchPropertiesDialogBot.isVisible() );
+        searchPropertiesDialogBot.clickCancelButton();
 
         // assert browser connection in searches
         assertEquals( 1, browserConnection1.getSearchManager().getSearches().size() );

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=880635&r1=880634&r2=880635&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 16 07:05:37 2009
@@ -90,6 +90,13 @@
     }
 
 
+    public SearchDialogBot openSearchDialog()
+    {
+        ContextMenuHelper.clickContextMenu( browserBot.getTree(), "New", "New Search..."
);
+        return new SearchDialogBot();
+    }
+
+
     public RenameEntryDialogBot openRenameDialog()
     {
         ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Rename Entry..." );
@@ -145,4 +152,21 @@
         ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Reload Entry" );
     }
 
+
+    public void copy()
+    {
+        ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Copy" );
+    }
+    
+    public void paste()
+    {
+        ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Paste" );
+    }
+    
+    public SearchPropertiesDialogBot pasteSearch()
+    {
+        ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Paste" );
+        return new SearchPropertiesDialogBot();
+    }
+
 }

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchDialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchDialogBot.java?rev=880635&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchDialogBot.java
(added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchDialogBot.java
Mon Nov 16 07:05:37 2009
@@ -0,0 +1,63 @@
+/*
+ *  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 SearchDialogBot extends DialogBot
+{
+    SearchPageWrapperBot searchPageWrapperBot;
+
+
+    public SearchDialogBot()
+    {
+        this.searchPageWrapperBot = new SearchPageWrapperBot( bot );
+    }
+
+
+    public boolean isVisible()
+    {
+        return super.isVisible( "Search" ) && bot.tabItem( "LDAP Search" ).isActive();
+    }
+
+
+    public void setSearchName( String string )
+    {
+        searchPageWrapperBot.setSearchName( string );
+    }
+
+
+    public void setFilter( String string )
+    {
+        searchPageWrapperBot.setFilter( string );
+    }
+
+
+    public void clickSearchButton()
+    {
+        super.clickButton( "Search" );
+    }
+
+
+    public void clickCancelButton()
+    {
+        super.clickButton( "Cancel" );
+    }
+
+}

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPageWrapperBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPageWrapperBot.java?rev=880635&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPageWrapperBot.java
(added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPageWrapperBot.java
Mon Nov 16 07:05:37 2009
@@ -0,0 +1,54 @@
+/*
+ *  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;
+
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+
+
+class SearchPageWrapperBot
+{
+    private SWTBot bot;
+
+
+    SearchPageWrapperBot( SWTBot bot )
+    {
+        this.bot = bot;
+    }
+
+
+    boolean isVisible()
+    {
+        return bot.textWithLabel( "Search Name:" ).isVisible();
+    }
+
+
+    void setSearchName( String string )
+    {
+        bot.textWithLabel( "Search Name:" ).setText( "Search all persons" );
+    }
+
+
+    void setFilter( String string )
+    {
+        bot.comboBoxWithLabel( "Filter:" ).setText( "(objectClass=person)" );
+    }
+
+}

Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPropertiesDialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPropertiesDialogBot.java?rev=880635&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPropertiesDialogBot.java
(added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPropertiesDialogBot.java
Mon Nov 16 07:05:37 2009
@@ -0,0 +1,65 @@
+/*
+ *  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 SearchPropertiesDialogBot extends DialogBot
+{
+
+    SearchPageWrapperBot searchPageWrapperBot;
+
+
+    public SearchPropertiesDialogBot()
+    {
+        this.searchPageWrapperBot = new SearchPageWrapperBot( bot );
+    }
+
+
+    public boolean isVisible()
+    {
+        // "Properties for Search ..."
+        return searchPageWrapperBot.isVisible();
+    }
+
+
+    public void setSearchName( String string )
+    {
+        searchPageWrapperBot.setSearchName( string );
+    }
+
+
+    public void setFilter( String string )
+    {
+        searchPageWrapperBot.setFilter( string );
+    }
+
+
+    public void clickOkButton()
+    {
+        super.clickButton( "OK" );
+    }
+
+
+    public void clickCancelButton()
+    {
+        super.clickButton( "Cancel" );
+    }
+
+}



Mime
View raw message