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 2015/05/03 00:39:08 UTC

svn commit: r1677360 - in /directory/studio/trunk: plugins/rcp/src/main/java/org/apache/directory/studio/ tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ tests/test.integration.ui/src/main/java/org/apache/direct...

Author: seelmann
Date: Sat May  2 22:39:08 2015
New Revision: 1677360

URL: http://svn.apache.org/r1677360
Log:
DIRSTUDIO-1043: First open of LDIF editor fails 
* Add missing find_ext to edit menu
* Added test

Added:
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/LdifEditorTest.java
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/LdifEditorBot.java
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewWizardBot.java
Modified:
    directory/studio/trunk/plugins/rcp/src/main/java/org/apache/directory/studio/ApplicationActionBarAdvisor.java
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java

Modified: directory/studio/trunk/plugins/rcp/src/main/java/org/apache/directory/studio/ApplicationActionBarAdvisor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/rcp/src/main/java/org/apache/directory/studio/ApplicationActionBarAdvisor.java?rev=1677360&r1=1677359&r2=1677360&view=diff
==============================================================================
--- directory/studio/trunk/plugins/rcp/src/main/java/org/apache/directory/studio/ApplicationActionBarAdvisor.java (original)
+++ directory/studio/trunk/plugins/rcp/src/main/java/org/apache/directory/studio/ApplicationActionBarAdvisor.java Sat May  2 22:39:08 2015
@@ -333,6 +333,7 @@ public class ApplicationActionBarAdvisor
         editMenu.add( renameAction );
         editMenu.add( new Separator() );
         editMenu.add( findAction );
+        editMenu.add(new GroupMarker(IWorkbenchActionConstants.FIND_EXT));
 
         // Populating Navigate Menu
         navigateMenu.add( nextAction );

Added: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/LdifEditorTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/LdifEditorTest.java?rev=1677360&view=auto
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/LdifEditorTest.java (added)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/LdifEditorTest.java Sat May  2 22:39:08 2015
@@ -0,0 +1,80 @@
+/*
+ *  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;
+
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.studio.test.integration.ui.bots.LdifEditorBot;
+import org.apache.directory.studio.test.integration.ui.bots.NewWizardBot;
+import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
+import org.apache.directory.studio.test.integration.ui.bots.utils.FrameworkRunnerWithScreenshotCaptureListener;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Tests the LDIF editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(FrameworkRunnerWithScreenshotCaptureListener.class)
+public class LdifEditorTest extends AbstractLdapTestUnit
+{
+    private StudioBot studioBot;
+
+
+    @Before
+    public void setUp() throws Exception
+    {
+        studioBot = new StudioBot();
+        studioBot.resetLdapPerspective();
+    }
+
+
+    @After
+    public void tearDown() throws Exception
+    {
+    }
+
+
+    /**
+     * Test for DIRSTUDIO-1043 (First open of LDIF editor fails)
+     */
+    @Test
+    public void testNewLdifEditor() throws Exception
+    {
+        NewWizardBot newWizard = studioBot.openNewWizard();
+        newWizard.selectLdifFile();
+        assertTrue( newWizard.isFinishButtonEnabled() );
+        newWizard.clickFinishButton();
+
+        LdifEditorBot ldifEditorBot = new LdifEditorBot( "LDIF 2" );
+        ldifEditorBot.activate();
+        ldifEditorBot.typeText( "dn: dc=test\nobjectClass: domain\n\n" );
+        assertTrue( ldifEditorBot.isDirty() );
+        ldifEditorBot.close();
+    }
+
+}

Added: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/LdifEditorBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/LdifEditorBot.java?rev=1677360&view=auto
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/LdifEditorBot.java (added)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/LdifEditorBot.java Sat May  2 22:39:08 2015
@@ -0,0 +1,67 @@
+/*
+ *  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.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+
+
+public class LdifEditorBot
+{
+    private SWTBotEditor editor;
+
+
+    public LdifEditorBot( String title )
+    {
+        SWTWorkbenchBot bot = new SWTWorkbenchBot();
+        editor = bot.editorByTitle( title );
+    }
+
+
+    public void typeText( String text )
+    {
+        SWTBotPreferences.KEYBOARD_LAYOUT = "org.eclipse.swtbot.swt.finder.keyboard.EN_US";
+        SWTBotEclipseEditor textEditor = editor.toTextEditor();
+        textEditor.typeText( text );
+    }
+
+
+    public void activate()
+    {
+        editor.setFocus();
+    }
+
+
+    public void close()
+    {
+        editor.close();
+    }
+
+
+    public boolean isDirty()
+    {
+        return editor.isDirty();
+    }
+
+}

Added: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewWizardBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewWizardBot.java?rev=1677360&view=auto
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewWizardBot.java (added)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewWizardBot.java Sat May  2 22:39:08 2015
@@ -0,0 +1,41 @@
+/*
+ *  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.widgets.SWTBotTree;
+
+
+public class NewWizardBot extends WizardBot
+{
+
+    public NewWizardBot()
+    {
+        super( "New" );
+    }
+
+
+    public void selectLdifFile()
+    {
+        SWTBotTree tree = bot.tree();
+        tree.expandNode( "LDAP Browser" ).select( "LDIF File" );
+    }
+
+}

Modified: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java?rev=1677360&r1=1677359&r2=1677360&view=diff
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java (original)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java Sat May  2 22:39:08 2015
@@ -23,6 +23,7 @@ package org.apache.directory.studio.test
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 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.ui.IViewReference;
@@ -71,6 +72,12 @@ public class StudioBot
     }
 
 
+    public SearchResultEditorBot getSearchResultEditorBot( String title )
+    {
+        return new SearchResultEditorBot( title );
+    }
+
+
     public void resetLdapPerspective()
     {
         UIThreadRunnable.syncExec( new VoidResult()
@@ -141,9 +148,18 @@ public class StudioBot
     }
 
 
-    public SearchResultEditorBot getSearchResultEditorBot( String title )
+    public NewWizardBot openNewWizard()
     {
-        return new SearchResultEditorBot( title );
+        try
+        {
+            // In IDE
+            new SWTBot().menu( "File" ).menu( "New" ).menu( "Other..." ).click();
+        }
+        catch ( WidgetNotFoundException wnfe )
+        {
+            // In RCP application
+            new SWTBot().menu( "File" ).menu( "New..." ).click();
+        }
+        return new NewWizardBot();
     }
-
 }