You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/04/07 19:52:51 UTC

[GitHub] matthiasblaesing closed pull request #450: Fix favorites module qa-functional tests.

matthiasblaesing closed pull request #450: Fix favorites module qa-functional tests.
URL: https://github.com/apache/incubator-netbeans/pull/450
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/favorites/test/qa-functional/src/gui/core/favorites/BasicsTest.java b/favorites/test/qa-functional/src/org/netbeans/modules/favorites/AddToFavoritesTest.java
similarity index 73%
rename from favorites/test/qa-functional/src/gui/core/favorites/BasicsTest.java
rename to favorites/test/qa-functional/src/org/netbeans/modules/favorites/AddToFavoritesTest.java
index 9f771882d..c18fffce6 100644
--- a/favorites/test/qa-functional/src/gui/core/favorites/BasicsTest.java
+++ b/favorites/test/qa-functional/src/org/netbeans/modules/favorites/AddToFavoritesTest.java
@@ -16,9 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package gui.core.favorites;
+package org.netbeans.modules.favorites;
 
 import java.io.File;
+import java.util.logging.Logger;
 import junit.framework.Test;
 import org.netbeans.jellytools.Bundle;
 import org.netbeans.jellytools.FavoritesOperator;
@@ -31,70 +32,29 @@
 import org.netbeans.junit.NbModuleSuite;
 
 /**
- * Basic favorites test.
  *
  * @author Tomas.Musil@sun.com
  */
-public class BasicsTest extends JellyTestCase {
+public class AddToFavoritesTest extends JellyTestCase {
 
-    private final String SAMPLE_PROJECT_NAME_F1="SampleF1";
-
-
-
-    /** Need to be defined because of JUnit */
-    public BasicsTest(String name) {
-        super(name);
+    public AddToFavoritesTest(String testName) {
+        super(testName);
     }
 
     public static Test suite() {
-        return NbModuleSuite.create(BasicsTest.class, ".*", ".*");
-    }
-
-    public @Override void setUp() {
-        System.out.println("########  "+getName()+"  #######");
+        return NbModuleSuite.create(AddToFavoritesTest.class, ".*", ".*");
     }
 
-    public void testHomeFolder(){
-        // checking if $HOME is by default present in favorites
-        new FavoritesAction().performShortcut();
-        FavoritesOperator fo = FavoritesOperator.invoke();
-        File home = new File(System.getProperty("user.home"));
-        Node nodeHome = new Node(fo.tree(),home.getName());
-        nodeHome.expand();
-        nodeHome.collapse();
+    @Override
+    public void setUp() throws Exception {
+        JellyTestCase.closeAllModal();
     }
 
-// #178009
-//    public void testAddJavaPackageToFavorites(){
-//        //Creating sample project General/Java application
-//        NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke();
-//        String standard = Bundle.getString("org.netbeans.modules.java.j2seproject.ui.wizards.Bundle", "Templates/Project/Standard");
-//        String javaApp = Bundle.getString("org.netbeans.modules.java.j2seproject.ui.wizards.Bundle", "Templates/Project/Standard/emptyJ2SE.xml");
-//        npwo.selectCategory(standard);
-//        npwo.selectProject(javaApp);
-//        npwo.next();
-//        NewJavaProjectNameLocationStepOperator npnlso = new NewJavaProjectNameLocationStepOperator();
-//        npnlso.txtProjectName().setText(SAMPLE_PROJECT_NAME_F1);
-//        npnlso.txtProjectLocation().setText(System.getProperty("netbeans.user")); // NOI18N
-//        npnlso.finish();
-//        ProjectSupport.waitScanFinished();
-//        //invoking Projects tab
-//        ProjectsTabOperator pto = ProjectsTabOperator.invoke();
-//        //Selecting Source package (the one named as project)
-//        String srcPack = Bundle.getString("org.netbeans.modules.java.j2seproject.Bundle", "NAME_src.dir");
-//        Node node = new Node(pto.tree(), SAMPLE_PROJECT_NAME_F1+"|"+srcPack+"|"+SAMPLE_PROJECT_NAME_F1);
-//        //invoking popup, Tools|Add to Favorites
-//        String tools = Bundle.getString("org.openide.actions.Bundle", "CTL_Tools");
-//        String add = Bundle.getStringTrimmed("org.netbeans.modules.favorites.Bundle", "ACT_Add");
-//        node.performPopupAction(tools+"|"+add);
-//        FavoritesOperator fo = FavoritesOperator.invoke();
-//        assertEquals("items in favorites", 2, fo.tree().getChildCount(fo.tree().getRoot()));
-//    }
-
-    public void testAddFolderToFavorites(){
+    public void testAddFolderToFavorites() {
         //Opening a favorites tab (or focusing into it)
         new FavoritesAction().performShortcut();
         FavoritesOperator fo = FavoritesOperator.invoke();
+        int initialTreeChildCount = fo.tree().getChildCount(fo.tree().getRoot());
         //Invoking popup, choosing Add to favorites.
         String add2fav = Bundle.getStringTrimmed("org.netbeans.modules.favorites.Bundle", "ACT_AddOnFavoritesNode");
         new ActionNoBlock(null, add2fav).perform(fo);
@@ -107,13 +67,15 @@ public void testAddFolderToFavorites(){
         Node node = new Node(fo.tree(), f.getName());
         node.expand();
         node.collapse();
-        assertEquals("items in favorites", 2, fo.tree().getChildCount(fo.tree().getRoot()));
-     }
+        int treeChildCountExpected = initialTreeChildCount + 1;
+        assertEquals("items in favorites", treeChildCountExpected, fo.tree().getChildCount(fo.tree().getRoot()));
+    }
 
-    public void testAddNonexistingFolder(){
+    public void testAddNonexistingFolder() {
         //Opening a favorites tab (or focusing into it)
         new FavoritesAction().performShortcut();
         FavoritesOperator fo = FavoritesOperator.invoke();
+        int initialTreeChildCount = fo.tree().getChildCount(fo.tree().getRoot());
         //Invoking popup, choosing Add to favorites.
         String add2fav = Bundle.getStringTrimmed("org.netbeans.modules.favorites.Bundle", "ACT_AddOnFavoritesNode");
         new ActionNoBlock(null, add2fav).perform(fo);
@@ -124,17 +86,34 @@ public void testAddNonexistingFolder(){
         String dialogName = Bundle.getString("org.netbeans.modules.favorites.Bundle", "ERR_FileDoesNotExistDlgTitle");
         NbDialogOperator dialog = new NbDialogOperator(dialogName);
         dialog.closeByButton();
-        assertEquals("items in favorites", 2, fo.tree().getChildCount(fo.tree().getRoot()));
+        assertEquals("items in favorites", initialTreeChildCount, fo.tree().getChildCount(fo.tree().getRoot()));
     }
 
-    public void testRemoveFromFavorites(){
-        //Opening a favorites tab (or focusing into it)
-        FavoritesOperator fo = FavoritesOperator.invoke();
-        // Selecting home node in favorites window.
-        File f = new File(System.getProperty("user.home"));
-        Node node = new Node(fo.tree(), f.getName());
-        // selecting Remove from favorites from popup on homeNode
-        String removeFromFav = Bundle.getStringTrimmed("org.netbeans.modules.favorites.Bundle","ACT_Remove");
-        node.performPopupAction(removeFromFav);
-    }
+    // #178009
+    // https://netbeans.org/bugzilla/show_bug.cgi?id=178009
+//    public void testAddJavaPackageToFavorites(){
+//        //Creating sample project General/Java application
+//        NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke();
+//        String standard = Bundle.getString("org.netbeans.modules.java.j2seproject.ui.wizards.Bundle", "Templates/Project/Standard");
+//        String javaApp = Bundle.getString("org.netbeans.modules.java.j2seproject.ui.wizards.Bundle", "Templates/Project/Standard/emptyJ2SE.xml");
+//        npwo.selectCategory(standard);
+//        npwo.selectProject(javaApp);
+//        npwo.next();
+//        NewJavaProjectNameLocationStepOperator npnlso = new NewJavaProjectNameLocationStepOperator();
+//        npnlso.txtProjectName().setText(SAMPLE_PROJECT_NAME_F1);
+//        npnlso.txtProjectLocation().setText(System.getProperty("netbeans.user")); // NOI18N
+//        npnlso.finish();
+//        ProjectSupport.waitScanFinished();
+//        //invoking Projects tab
+//        ProjectsTabOperator pto = ProjectsTabOperator.invoke();
+//        //Selecting Source package (the one named as project)
+//        String srcPack = Bundle.getString("org.netbeans.modules.java.j2seproject.Bundle", "NAME_src.dir");
+//        Node node = new Node(pto.tree(), SAMPLE_PROJECT_NAME_F1+"|"+srcPack+"|"+SAMPLE_PROJECT_NAME_F1);
+//        //invoking popup, Tools|Add to Favorites
+//        String tools = Bundle.getString("org.openide.actions.Bundle", "CTL_Tools");
+//        String add = Bundle.getStringTrimmed("org.netbeans.modules.favorites.Bundle", "ACT_Add");
+//        node.performPopupAction(tools+"|"+add);
+//        FavoritesOperator fo = FavoritesOperator.invoke();
+//        assertEquals("items in favorites", 2, fo.tree().getChildCount(fo.tree().getRoot()));
+//    }
 }
diff --git a/favorites/test/qa-functional/src/org/netbeans/modules/favorites/HomeFolderTest.java b/favorites/test/qa-functional/src/org/netbeans/modules/favorites/HomeFolderTest.java
new file mode 100644
index 000000000..3227504ce
--- /dev/null
+++ b/favorites/test/qa-functional/src/org/netbeans/modules/favorites/HomeFolderTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.netbeans.modules.favorites;
+
+import java.io.File;
+import junit.framework.Test;
+import org.netbeans.jellytools.FavoritesOperator;
+import org.netbeans.jellytools.JellyTestCase;
+import org.netbeans.jellytools.actions.FavoritesAction;
+import org.netbeans.jellytools.nodes.Node;
+import org.netbeans.junit.NbModuleSuite;
+
+/**
+ * Basic favorites test.
+ *
+ * @author Tomas.Musil@sun.com
+ */
+public class HomeFolderTest extends JellyTestCase {
+
+    /** 
+     * Need to be defined because of JUnit
+     * @param name 
+     */
+    public HomeFolderTest(String name) {
+        super(name);
+    }
+
+    public static Test suite() {
+        return NbModuleSuite.create(HomeFolderTest.class, ".*", ".*");
+    }
+
+    public @Override void setUp() {
+        JellyTestCase.closeAllModal();
+    }
+
+    public void testHomeFolder(){
+        // checking if $HOME is by default present in favorites
+        new FavoritesAction().performShortcut();
+        FavoritesOperator fo = FavoritesOperator.invoke();
+        File home = new File(System.getProperty("user.home"));
+        Node nodeHome = new Node(fo.tree(),home.getName());
+        nodeHome.expand();
+        nodeHome.collapse();
+    }
+
+}
diff --git a/favorites/test/qa-functional/src/org/netbeans/modules/favorites/RemoveFromFavoritesTest.java b/favorites/test/qa-functional/src/org/netbeans/modules/favorites/RemoveFromFavoritesTest.java
new file mode 100644
index 000000000..2277a7f15
--- /dev/null
+++ b/favorites/test/qa-functional/src/org/netbeans/modules/favorites/RemoveFromFavoritesTest.java
@@ -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.netbeans.modules.favorites;
+
+import java.io.File;
+import junit.framework.Test;
+import org.netbeans.jellytools.Bundle;
+import org.netbeans.jellytools.FavoritesOperator;
+import org.netbeans.jellytools.JellyTestCase;
+import org.netbeans.jellytools.nodes.Node;
+import org.netbeans.junit.NbModuleSuite;
+
+/**
+ *
+ * @author Tomas.Musil@sun.com
+ */
+public class RemoveFromFavoritesTest  extends JellyTestCase {
+    
+    public RemoveFromFavoritesTest(String testName) {
+        super(testName);
+    }
+    
+    public static Test suite() {
+        return NbModuleSuite.create(RemoveFromFavoritesTest.class, ".*", ".*");
+    }
+
+    @Override
+    public void setUp() throws Exception {
+        JellyTestCase.closeAllModal();
+    }
+    
+    public void testRemoveFromFavorites(){
+        //Opening a favorites tab (or focusing into it)
+        FavoritesOperator fo = FavoritesOperator.invoke();
+        // Selecting home node in favorites window.
+        File f = new File(System.getProperty("user.home"));
+        Node node = new Node(fo.tree(), f.getName());
+        // selecting Remove from favorites from popup on homeNode
+        String removeFromFav = Bundle.getStringTrimmed("org.netbeans.modules.favorites.Bundle","ACT_Remove");
+        node.performPopupAction(removeFromFav);
+    }
+    
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists