Author: dazarov
Date: 2009-02-05 13:37:37 -0500 (Thu, 05 Feb 2009)
New Revision: 13492
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizard/newfile/NewFileWizardEx.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/CssClassNewWizardTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/CssFileNewWizardTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/FacesConfigNewWizardTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/HtmlFileNewWizardTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsFileNewWizardTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JspFileNewWizardTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/PropertiesNewWizardTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/WizardTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/XhtmlFileNewWizardTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3500
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizard/newfile/NewFileWizardEx.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizard/newfile/NewFileWizardEx.java 2009-02-05
15:43:43 UTC (rev 13491)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizard/newfile/NewFileWizardEx.java 2009-02-05
18:37:37 UTC (rev 13492)
@@ -32,5 +32,11 @@
public void init(IWorkbench workbench, IStructuredSelection selection) {
context.setSelection(selection);
}
+
+
+ // added for test
https://jira.jboss.org/jira/browse/JBIDE-3500
+ public NewFileContextEx getFileContext(){
+ return context;
+ }
}
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF 2009-02-05 15:43:43
UTC (rev 13491)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF 2009-02-05 18:37:37
UTC (rev 13492)
@@ -12,5 +12,7 @@
org.jboss.tools.common.test;bundle-version="2.0.0",
org.eclipse.ui.workbench;bundle-version="3.4.0",
org.jboss.tools.jsf.ui;bundle-version="2.0.0",
- org.jboss.tools.jst.web.ui;bundle-version="2.0.0"
+ org.jboss.tools.jst.web.ui;bundle-version="2.0.0",
+ org.jboss.tools.jst.jsp;bundle-version="2.0.0",
+ org.jboss.tools.common.model.ui;bundle-version="2.0.0"
Bundle-Localization: plugin
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/CssClassNewWizardTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/CssClassNewWizardTest.java 2009-02-05
15:43:43 UTC (rev 13491)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/CssClassNewWizardTest.java 2009-02-05
18:37:37 UTC (rev 13492)
@@ -12,7 +12,7 @@
}
public void testCssClassNewWizardValidation() {
- IWizard wizard = getWizardWithoutSelection();
+ IWizard wizard = getWizard();
boolean canFinish = wizard.canFinish();
@@ -25,7 +25,7 @@
boolean canFinish = wizard.canFinish();
// Assert Finish button is enabled by default if wizard is called on Project
- assertTrue("Finish button is disabled at first wizard page.", canFinish);
+ assertFalse("Finish button is disabled at first wizard page.", canFinish);
// Assert Finish button is disabled and error is present if
// Folder field is empty
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/CssFileNewWizardTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/CssFileNewWizardTest.java 2009-02-05
15:43:43 UTC (rev 13491)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/CssFileNewWizardTest.java 2009-02-05
18:37:37 UTC (rev 13492)
@@ -12,7 +12,7 @@
}
public void testCssFileNewWizardValidation() {
- IWizard wizard = getWizardWithoutSelection();
+ IWizard wizard = getWizard();
boolean canFinish = wizard.canFinish();
@@ -20,31 +20,6 @@
}
public void testCssFileNewWizardValidation2() {
- IWizard wizard = getWizardOnProject();
-
- boolean canFinish = wizard.canFinish();
-
- // Assert Finish button is enabled by default if wizard is called on Project
- assertTrue("Finish button is disabled at first wizard page.", canFinish);
-
- // Assert Finish button is disabled and error is present if
- // Folder field is empty
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field points to folder that doesn't exist
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field is empty
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains forbidden characters
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains file name that already exists
+ validateFolderAndName();
}
}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/FacesConfigNewWizardTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/FacesConfigNewWizardTest.java 2009-02-05
15:43:43 UTC (rev 13491)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/FacesConfigNewWizardTest.java 2009-02-05
18:37:37 UTC (rev 13492)
@@ -1,14 +1,6 @@
package org.jboss.tools.jsf.ui.test;
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.IWorkbenchWizard;
-import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.common.util.WorkbenchUtils;
public class FacesConfigNewWizardTest extends WizardTest {
@@ -21,7 +13,7 @@
}
public void testFacesConfigNewWizardValidation() {
- IWizard wizard = getWizardWithoutSelection();
+ IWizard wizard = getWizard();
boolean canFinish = wizard.canFinish();
@@ -29,32 +21,7 @@
}
public void testFacesConfigNewWizardValidation2() {
- IWizard wizard = getWizardOnProject();
-
- boolean canFinish = wizard.canFinish();
-
- // Assert Finish button is enabled by default if wizard is called on Project
- assertTrue("Finish button is disabled at first wizard page.", canFinish);
-
- // Assert Finish button is disabled and error is present if
- // Folder field is empty
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field points to folder that doesn't exist
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field is empty
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains forbidden characters
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains file name that already exists
+ validateFolderAndName();
}
public void testFacesConfigNewWizardResults() {
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/HtmlFileNewWizardTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/HtmlFileNewWizardTest.java 2009-02-05
15:43:43 UTC (rev 13491)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/HtmlFileNewWizardTest.java 2009-02-05
18:37:37 UTC (rev 13492)
@@ -13,7 +13,7 @@
}
public void testHtmlFileNewWizardValidation() {
- IWizard wizard = getWizardWithoutSelection();
+ IWizard wizard = getWizard();
boolean canFinish = wizard.canFinish();
@@ -21,31 +21,5 @@
}
public void testHtmlFileNewWizardValidation2() {
- IWizard wizard = getWizardOnProject();
-
- boolean canFinish = wizard.canFinish();
-
- // Assert Finish button is enabled by default if wizard is called on Project
- assertTrue("Finish button is disabled at first wizard page.", canFinish);
-
- // Assert Finish button is disabled and error is present if
- // Folder field is empty
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field points to folder that doesn't exist
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field is empty
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains forbidden characters
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains file name that already exists
- }
+ validateFolderAndName(); }
}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsFileNewWizardTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsFileNewWizardTest.java 2009-02-05
15:43:43 UTC (rev 13491)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsFileNewWizardTest.java 2009-02-05
18:37:37 UTC (rev 13492)
@@ -13,7 +13,7 @@
}
public void testJsFileNewWizardValidation() {
- IWizard wizard = getWizardWithoutSelection();
+ IWizard wizard = getWizard();
boolean canFinish = wizard.canFinish();
@@ -21,31 +21,6 @@
}
public void testJsFileNewWizardValidation2() {
- IWizard wizard = getWizardOnProject();
-
- boolean canFinish = wizard.canFinish();
-
- // Assert Finish button is enabled by default if wizard is called on Project
- assertTrue("Finish button is disabled at first wizard page.", canFinish);
-
- // Assert Finish button is disabled and error is present if
- // Folder field is empty
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field points to folder that doesn't exist
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field is empty
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains forbidden characters
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains file name that already exists
+ validateFolderAndName();
}
}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JspFileNewWizardTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JspFileNewWizardTest.java 2009-02-05
15:43:43 UTC (rev 13491)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JspFileNewWizardTest.java 2009-02-05
18:37:37 UTC (rev 13492)
@@ -13,7 +13,7 @@
}
public void testJspFileNewWizardValidation() {
- IWizard wizard = getWizardWithoutSelection();
+ IWizard wizard = getWizard();
boolean canFinish = wizard.canFinish();
@@ -21,31 +21,6 @@
}
public void testJspFileNewWizardValidation2() {
- IWizard wizard = getWizardOnProject();
-
- boolean canFinish = wizard.canFinish();
-
- // Assert Finish button is enabled by default if wizard is called on Project
- assertTrue("Finish button is disabled at first wizard page.", canFinish);
-
- // Assert Finish button is disabled and error is present if
- // Folder field is empty
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field points to folder that doesn't exist
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field is empty
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains forbidden characters
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains file name that already exists
+ validateFolderAndName();
}
}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/PropertiesNewWizardTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/PropertiesNewWizardTest.java 2009-02-05
15:43:43 UTC (rev 13491)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/PropertiesNewWizardTest.java 2009-02-05
18:37:37 UTC (rev 13492)
@@ -13,7 +13,7 @@
}
public void testPropertiesFileNewWizardValidation() {
- IWizard wizard = getWizardWithoutSelection();
+ IWizard wizard = getWizard();
boolean canFinish = wizard.canFinish();
@@ -21,31 +21,6 @@
}
public void testPropertiesFileNewWizardValidation2() {
- IWizard wizard = getWizardOnProject();
-
- boolean canFinish = wizard.canFinish();
-
- // Assert Finish button is enabled by default if wizard is called on Project
- assertTrue("Finish button is disabled at first wizard page.", canFinish);
-
- // Assert Finish button is disabled and error is present if
- // Folder field is empty
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field points to folder that doesn't exist
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field is empty
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains forbidden characters
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains file name that already exists
+ validateFolderAndName();
}
}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/WizardTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/WizardTest.java 2009-02-05
15:43:43 UTC (rev 13491)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/WizardTest.java 2009-02-05
18:37:37 UTC (rev 13492)
@@ -2,8 +2,6 @@
import java.util.ArrayList;
-import javax.swing.text.View;
-
import junit.framework.TestCase;
import org.eclipse.core.resources.IProject;
@@ -13,9 +11,11 @@
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchWizard;
import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.common.meta.action.impl.SpecialWizardSupport;
+import org.jboss.tools.common.model.ui.wizard.newfile.NewFileContextEx;
+import org.jboss.tools.common.model.ui.wizard.newfile.NewFileWizardEx;
import org.jboss.tools.common.util.WorkbenchUtils;
import org.jboss.tools.test.util.JobUtils;
import org.jboss.tools.test.util.ProjectImportTestSetup;
@@ -75,7 +75,6 @@
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
wizard);
dialog.setBlockOnOpen(false);
- //dialog.
dialog.open();
// System.out.println("\nWizard ID - "+id);
@@ -98,7 +97,7 @@
}
- public IWizard getWizardWithoutSelection(){
+ public IWizard getWizard(){
IWizard wizard = WorkbenchUtils.findWizardByDefId(id);
dialog = new WizardDialog(
@@ -110,6 +109,33 @@
return wizard;
}
+ public IWizard getWizard(String folder, String name){
+ IWizard wizard = WorkbenchUtils.findWizardByDefId(id);
+
+ NewFileWizardEx wiz = (NewFileWizardEx)wizard;
+
+ NewFileContextEx context = wiz.getFileContext();
+
+ SpecialWizardSupport support = context.getSupport();
+
+ ArrayList<IProject> list = new ArrayList<IProject>();
+
+ StructuredSelection selection = new StructuredSelection(list);
+
+ ((IWorkbenchWizard)wizard).init(PlatformUI.getWorkbench(), selection);
+
+ support.setAttributeValue(0, "folder", folder);
+ support.setAttributeValue(0, "name", name);
+
+ dialog = new WizardDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ wizard);
+ dialog.setBlockOnOpen(false);
+ dialog.open();
+
+ return wizard;
+ }
+
public IWizard getWizardOnProject(){
ArrayList<IProject> list = new ArrayList<IProject>();
@@ -129,4 +155,89 @@
return wizard;
}
+
+ public IWizard getWizardOnProject(String name){
+ ArrayList<IProject> list = new ArrayList<IProject>();
+
+ list.add(project);
+
+ StructuredSelection selection = new StructuredSelection(list);
+
+ IWizard wizard = WorkbenchUtils.findWizardByDefId(id);
+
+ NewFileWizardEx wiz = (NewFileWizardEx)wizard;
+
+ NewFileContextEx context = wiz.getFileContext();
+
+ SpecialWizardSupport support = context.getSupport();
+
+ ((IWorkbenchWizard)wizard).init(PlatformUI.getWorkbench(), selection);
+
+ support.setAttributeValue(0, "name", name);
+
+ dialog = new WizardDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ wizard);
+ dialog.setBlockOnOpen(false);
+ dialog.open();
+
+ return wizard;
+ }
+
+ protected void validateFolderAndName(){
+ IWizard wizard = getWizardOnProject("aaa");
+
+
+ boolean canFinish = wizard.canFinish();
+
+ // Assert Finish button is enabled by default if wizard is called on Project
+ assertTrue("Finish button is disabled at first wizard page.", canFinish);
+
+ dialog.close();
+
+ // Assert Finish button is disabled and error is present if
+ // Folder field is empty
+ // All other fields are correct
+
+ wizard = getWizard("","aaa");
+ canFinish = wizard.canFinish();
+ assertFalse("Finish button is enabled when folder field is empty.",
canFinish);
+
+ dialog.close();
+
+
+ // Assert Finish button is disabled and error is present if
+ // Folder field points to folder that doesn't exist
+ // All other fields are correct
+
+ wizard = getWizard("anyFolder","aaa");
+ canFinish = wizard.canFinish();
+ assertFalse("Finish button is enabled when folders field points to folder that
does not exist", canFinish);
+
+ dialog.close();
+
+ // Assert Finish button is disabled and error is present if
+ // Folder field is correct
+ // Name field is empty
+
+ wizard = getWizardOnProject("");
+ canFinish = wizard.canFinish();
+ assertFalse("Finish button is enabled when name field is empty.",
canFinish);
+
+ dialog.close();
+
+ // Assert Finish button is disabled and error is present if
+ // Folder field is correct
+ // Name field contains forbidden characters
+
+ wizard = getWizardOnProject("?-/");
+ canFinish = wizard.canFinish();
+ assertFalse("Finish button is enabled when name field contains forbiden
characters.", canFinish);
+
+ dialog.close();
+
+ // Assert Finish button is disabled and error is present if
+ // Folder field is correct
+ // Name field contains file name that already exists
+ }
}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/XhtmlFileNewWizardTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/XhtmlFileNewWizardTest.java 2009-02-05
15:43:43 UTC (rev 13491)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/XhtmlFileNewWizardTest.java 2009-02-05
18:37:37 UTC (rev 13492)
@@ -13,7 +13,7 @@
}
public void testXhtmlFileNewWizardValidation() {
- IWizard wizard = getWizardWithoutSelection();
+ IWizard wizard = getWizard();
boolean canFinish = wizard.canFinish();
@@ -21,31 +21,6 @@
}
public void testXhtmlFileNewWizardValidation2() {
- IWizard wizard = getWizardOnProject();
-
- boolean canFinish = wizard.canFinish();
-
- // Assert Finish button is enabled by default if wizard is called on Project
- assertTrue("Finish button is disabled at first wizard page.", canFinish);
-
- // Assert Finish button is disabled and error is present if
- // Folder field is empty
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field points to folder that doesn't exist
- // All other fields are correct
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field is empty
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains forbidden characters
-
- // Assert Finish button is disabled and error is present if
- // Folder field is correct
- // Name field contains file name that already exists
+ validateFolderAndName();
}
}