Author: vpakan(a)redhat.com
Date: 2011-11-25 11:03:47 -0500 (Fri, 25 Nov 2011)
New Revision: 36670
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorBot.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorPartMatcher.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorUtil.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/META-INF/MANIFEST.MF
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAutoTestCase.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTest.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/DragAndDropHelper.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
Log:
Added test of editing via GUI Editor
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/META-INF/MANIFEST.MF 2011-11-25
16:01:30 UTC (rev 36669)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/META-INF/MANIFEST.MF 2011-11-25
16:03:47 UTC (rev 36670)
@@ -8,11 +8,14 @@
org.eclipse.core.runtime,
org.eclipse.swtbot.eclipse.core;bundle-version="2.0.0",
org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.0",
+ org.eclipse.swtbot.eclipse.gef.finder,
org.eclipse.swtbot.swt.finder;bundle-version="2.0.0",
org.apache.log4j;bundle-version="1.2.13",
org.junit4;bundle-version="4.5.0",
org.eclipse.swtbot.junit4_x;bundle-version="2.0.0",
- org.jboss.tools.ui.bot.ext
+ org.jboss.tools.jsf.ui;bundle-version="3.2.0",
+ org.jboss.tools.ui.bot.ext,
+ org.eclipse.gef
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.jboss.tools.ui.bot.test,
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAutoTestCase.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAutoTestCase.java 2011-11-25
16:01:30 UTC (rev 36669)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAutoTestCase.java 2011-11-25
16:03:47 UTC (rev 36670)
@@ -2,6 +2,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.NoSuchElementException;
import java.util.Scanner;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
@@ -91,17 +92,23 @@
File file = new File(getPathToResources(resourceRelativePath));
StringBuilder builder = new StringBuilder(""); //$NON-NLS-1$
Scanner scanner = null;
- try {
- scanner = new Scanner(file);
- while (scanner.hasNextLine()) {
- builder.append(scanner.nextLine()+"\n"); //$NON-NLS-1$
- }
- } catch (IOException e) {
- if (scanner != null) {
- scanner.close();
- }
- }
- return builder.toString();
+ try {
+ scanner = new Scanner(file);
+ while (scanner.hasNextLine()) {
+ builder.append(scanner.nextLine() + "\n"); //$NON-NLS-1$
+ }
+ }
+ catch (IllegalStateException e) {
+ if (scanner != null) {
+ scanner.close();
+ }
+ }
+ catch (NoSuchElementException e) {
+ if (scanner != null) {
+ scanner.close();
+ }
+ }
+ return builder.toString();
}
/**
* Returns CSS Editor text striped from spaces, tabs CR and EOL
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTest.java 2011-11-25
16:01:30 UTC (rev 36669)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/FacesConfigEditingTest.java 2011-11-25
16:03:47 UTC (rev 36670)
@@ -10,16 +10,25 @@
******************************************************************************/
package org.jboss.tools.jsf.ui.bot.test.smoke;
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefViewer;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.jsf.ui.bot.test.JSFAutoTestCase;
+import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorBot;
+import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorPartMatcher;
+import org.jboss.tools.jsf.ui.bot.test.smoke.gefutils.FacesConfigGefEditorUtil;
import org.jboss.tools.ui.bot.ext.Assertions;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
-import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+import org.jboss.tools.ui.bot.ext.helper.DragAndDropHelper;
import org.jboss.tools.ui.bot.ext.parts.SWTBotEditorExt;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.view.ProblemsView;
@@ -35,7 +44,10 @@
private String originalContent;
private SWTBotEditorExt facesConfigEditorExt;
private SWTBotExt botExt;
-
+ private SWTBotGefEditPart gefObjectAddedViaViewTool = null;
+ private SWTBotGefEditPart gefObjectAddedViaDnDTool = null;
+ private SWTBotGefViewer gefViewer = null;
+
@Override
public void setUp() throws Exception {
super.setUp();
@@ -50,9 +62,26 @@
@Override
public void tearDown() throws Exception {
+ if (gefViewer != null){
+ if (gefObjectAddedViaViewTool != null){
+ gefObjectAddedViaViewTool.click();
+ bot.sleep(Timing.time1S());
+ gefViewer.clickContextMenu(IDELabel.Menu.DELETE);
+ confirmViewDelete();
+ bot.sleep(Timing.time1S());
+ }
+ if (gefObjectAddedViaDnDTool != null){
+ gefObjectAddedViaDnDTool.click();
+ bot.sleep(Timing.time1S());
+ gefViewer.clickContextMenu(IDELabel.Menu.DELETE);
+ confirmViewDelete();
+ bot.sleep(Timing.time1S());
+ }
+ }
if (facesConfigEditor != null) {
facesConfigEditor.toTextEditor().setText(originalContent);
facesConfigEditor.saveAndClose();
+ bot.sleep(Timing.time1S());
}
super.tearDown();
}
@@ -63,7 +92,6 @@
facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.TREE_TAB_LABEL);
SWTBot editorBot = facesConfigEditorExt.bot();
SWTBotTree tree = editorBot.tree();
- SWTUtilExt.displayAllBotWidgets(facesConfigEditor.bot());
final String managedBeanName = "TestBean";
final String managedBeanClass = "TestBeanClass";
SWTBotTreeItem tiFacesConfigXml =
tree.expandNode(FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
@@ -87,13 +115,11 @@
selectedNode.equals(managedBeanName));
Assertions.assertFileExistsInWorkspace(managedBeanClass + ".java",
JBT_TEST_PROJECT_NAME,"JavaSource");
- Assertions.assertSourceEditorContains(facesConfigEditorExt.getText(),
- "<managed-bean-name>" + managedBeanName +
"</managed-bean-name>",
+
Assertions.assertSourceEditorContains(stripXMLSourceText(facesConfigEditorExt.getText()),
+ "<managed-bean><managed-bean-name>" + managedBeanName +
"</managed-bean-name>" +
+ "<managed-bean-class>" + managedBeanClass +
"</managed-bean-class>" +
+
"<managed-bean-scope>request</managed-bean-scope></managed-bean>",
FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- Assertions.assertSourceEditorContains(facesConfigEditorExt.getText(),
- "<managed-bean-class>" + managedBeanClass +
"</managed-bean-class>",
- FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
- SWTUtilExt.displayAllBotWidgets(facesConfigEditor.bot());
// Modify Managed Bean
editorBot.textWithLabel(IDELabel.FacesConfigEditor.MANAGED_BEAN_CLASS_LABEL)
.setText(managedBeanClass + "xxqq");
@@ -131,6 +157,81 @@
FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
}
/**
+ * Tests Component editing
+ */
+ public void testComponent (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.COMPONENTS_NODE,
+ IDELabel.Shell.ADD_COMPONENT,
+ IDELabel.FacesConfigEditor.NEW_COMPONENT_TYPE_LABEL,
+ "TestComponentType",
+ IDELabel.FacesConfigEditor.NEW_COMPONENT_CLASS_LABEL,
+ "TestComponentClass",
+ "component",
+ "component-type",
+ "component-class",
+ true);
+ }
+ /**
+ * Tests Converter editing
+ */
+ public void testConverter (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.CONVERTERS_NODE,
+ IDELabel.Shell.ADD_CONVERTER,
+ IDELabel.FacesConfigEditor.NEW_CONVERTER_ID_LABEL,
+ "TestConverterID",
+ IDELabel.FacesConfigEditor.NEW_CONVERTER_CLASS_LABEL,
+ "TestConverterClass",
+ "converter",
+ "converter-id",
+ "converter-class",
+ true);
+ }
+ /**
+ * Tests Referenced Bean editing
+ */
+ public void testReferencedBean (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.REFERENCED_BEAN_NODE,
+ IDELabel.Shell.ADD_REFERENCED_BEAN,
+ IDELabel.FacesConfigEditor.NEW_REFERENCED_BEAN_NAME_LABEL,
+ "TestReferencedBeanName",
+ IDELabel.FacesConfigEditor.NEW_REFERENCED_BEAN_CLASS_LABEL,
+ "TestReferencedBeanClass",
+ "referenced-bean",
+ "referenced-bean-name",
+ "referenced-bean-class",
+ true);
+ }
+ /**
+ * Tests Render Kit editing
+ */
+ public void testRenderKit (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.RENDER_KITS_NODE,
+ IDELabel.Shell.ADD_RENDER_KIT,
+ IDELabel.FacesConfigEditor.NEW_RENDER_KIT_ID_LABEL,
+ "TestRenderKitID",
+ IDELabel.FacesConfigEditor.NEW_RENDER_KIT_CLASS_LABEL,
+ "TestRenderKitClass",
+ "render-kit",
+ "render-kit-id",
+ "render-kit-class",
+ false);
+ }
+ /**
+ * Tests Validator editing
+ */
+ public void testValidator (){
+ checkFacesConfigNodeEditing(IDELabel.FacesConfigEditor.VALIDATOR_NODE,
+ IDELabel.Shell.ADD_VALIDATOR,
+ IDELabel.FacesConfigEditor.NEW_VALIDATOR_ID_LABEL,
+ "TestValidatorID",
+ IDELabel.FacesConfigEditor.NEW_VALIDATOR_CLASS_LABEL,
+ "TestValidatorClass",
+ "validator",
+ "validator-id",
+ "validator-class",
+ false);
+ }
+ /**
* Asserts if faces-config.xml has no errors
* @param botExt
*/
@@ -153,10 +254,174 @@
assertTrue("There are missing errors in Problems view for " +
FacesConfigEditingTest.FACES_CONFIG_FILE_NAME + " file.",
areThereErrors);
}
- // adding Component
- // adding Custom Converter
- // adding Render Kit
- // adding Referenced Bean
- // adding Validator
-
-}
\ No newline at end of file
+ /**
+ * Check editing of particular tree node within Face Config Editor Tree
+ * @param treeNodeLabel
+ * @param addWizardTitle
+ * @param nameTextLabel
+ * @param typeTextValue
+ * @param classTextLabel
+ * @param classTextValue
+ * @param xmlNodeName
+ * @param nameXmlNodeName
+ * @param classXmlNodeName
+ * @param checkForValdiationErrors
+ */
+ private void checkFacesConfigNodeEditing(String treeNodeLabel,
+ String addWizardTitle,
+ String nameTextLabel,
+ String typeTextValue,
+ String classTextLabel,
+ String classTextValue,
+ String xmlNodeName,
+ String nameXmlNodeName,
+ String classXmlNodeName,
+ boolean checkForValdiationErrors){
+
+ facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.TREE_TAB_LABEL);
+ SWTBot editorBot = facesConfigEditorExt.bot();
+ SWTBotTree tree = editorBot.tree();
+ SWTBotTreeItem tiFacesConfigXml =
tree.expandNode(FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ SWTBotTreeItem tiNodeToCheck = tiFacesConfigXml.getNode(treeNodeLabel);
+ tiNodeToCheck.select();
+ bot.sleep(Timing.time1S());
+ // Add Node
+ editorBot.button(IDELabel.Button.ADD).click();
+ bot.shell(addWizardTitle).activate();
+ bot.textWithLabel(nameTextLabel).setText(typeTextValue);
+ bot.textWithLabel(classTextLabel).setText(classTextValue);
+ bot.button(IDELabel.Button.FINISH).click();
+ facesConfigEditorExt.save();
+ bot.sleep(Timing.time1S());
+ if (checkForValdiationErrors){
+ assertFacesConfigXmlHasErrors(botExt);
+ }
+ final String selectedNode = tree.selection().get(0,0);
+ assertTrue ("Selected node has to have label '" + typeTextValue
+"'\n" +
+ "but has '" + selectedNode + "'.",
+ selectedNode.equals(typeTextValue));
+
Assertions.assertSourceEditorContains(stripXMLSourceText(facesConfigEditorExt.getText()),
+ "<" + xmlNodeName + ">" +
+ "<" + nameXmlNodeName + ">" + typeTextValue +
"</" + nameXmlNodeName +">" +
+ "<" + classXmlNodeName + ">" + classTextValue +
"</" + classXmlNodeName +">" +
+ "</" + xmlNodeName + ">",
+ FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ // Delete Node
+ tiNodeToCheck.select();
+ editorBot.table().select(typeTextValue);
+ editorBot.button(IDELabel.Button.REMOVE_WITH_DOTS).click();
+ bot.shell(IDELabel.Shell.CONFIRMATION).activate();
+ bot.button(IDELabel.Button.OK).click();
+ boolean nodeWasDeleted = false;
+ try{
+ editorBot.table().select(typeTextValue);
+ } catch (WidgetNotFoundException wnfe){
+ nodeWasDeleted = true;
+ } catch (IllegalArgumentException iae){
+ nodeWasDeleted = true;
+ }
+ assertTrue(typeTextValue + " was not deleted properly.",
+ nodeWasDeleted);
+ Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
+ "<" + nameXmlNodeName + ">" + typeTextValue +
"</" + nameXmlNodeName +">",
+ FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ Assertions.assertSourceEditorNotContain(facesConfigEditorExt.getText(),
+ "<" + classXmlNodeName + ">" + classTextValue +
"</" + classXmlNodeName +">",
+ FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ }
+ /**
+ * Test editing via Diagram tab
+ */
+ public void testDiagramEditing(){
+ final int verticalSpacing = 100;
+ facesConfigEditorExt.selectPage(IDELabel.FacesConfigEditor.DIAGRAM_TAB_LABEL);
+ final FacesConfigGefEditorBot gefEditorBot = new
FacesConfigGefEditorBot(facesConfigEditorExt.getReference());
+ gefViewer = gefEditorBot.getViewer();
+ SWTBotGefEditPart mainPart = gefViewer.mainEditPart();
+ // add View to diagram via pallete tool
+ gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_VIEW_TEMPLATE_TOOL);
+ SWTBotGefEditPart gefObjectPart = mainPart.descendants(new
FacesConfigGefEditorPartMatcher("/pages/inputUserName.jsp")).get(0);
+ gefViewer.click(FacesConfigGefEditorUtil.getGefPartPosition(gefObjectPart).x,
+ FacesConfigGefEditorUtil.getGefPartPosition(gefObjectPart).y + verticalSpacing);
+ final String viewAddedViaToolName = "addedViaTool";
+ handleNewViewWizard(viewAddedViaToolName + ".jsp");
+ bot.sleep(Timing.time3S());
+ facesConfigEditor.save();
+ bot.sleep(Timing.time3S());
+ assertFacesConfigXmlHasNoErrors(botExt);
+ Assertions.assertFileExistsInWorkspace(viewAddedViaToolName + ".jsp",
+ JBT_TEST_PROJECT_NAME,"WebContent");
+ gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_CREATE_NEW_CONNECTION_TOOL);
+ gefObjectPart.click();
+ bot.sleep(Timing.time1S());
+ gefObjectAddedViaViewTool = mainPart.descendants(new
FacesConfigGefEditorPartMatcher("/" + viewAddedViaToolName +
".jsp")).get(0);
+ gefObjectAddedViaViewTool.click();
+ bot.sleep(Timing.time1S());
+ facesConfigEditor.save();
+ bot.sleep(Timing.time3S());
+
Assertions.assertSourceEditorContains(FacesConfigEditingTest.stripXMLSourceText(facesConfigEditorExt.getText()),
+ "<navigation-case><from-outcome>" + viewAddedViaToolName +
+ "</from-outcome><to-view-id>/" + viewAddedViaToolName +
".jsp</to-view-id></navigation-case>",
+ FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ // add View to Diagram via D'n'D
+ final String dndPageName = "testDnDPage";
+ createJspPage(dndPageName + ".jsp");
+ facesConfigEditor.show();
+ facesConfigEditor.setFocus();
+ SWTBotTreeItem tiPage =
SWTEclipseExt.selectTreeLocation(open.viewOpen(ActionItem.View.JBossToolsWebWebProjects.LABEL).bot(),
+
VPEAutoTestCase.JBT_TEST_PROJECT_NAME,"WebContent","pages",dndPageName
+ ".jsp");
+ DragAndDropHelper.dnd((TreeItem)tiPage.widget, (FigureCanvas)
gefEditorBot.getControl());
+ facesConfigEditor.save();
+ bot.sleep(Timing.time3S());
+ assertFacesConfigXmlHasNoErrors(botExt);
+ gefViewer.activateTool(IDELabel.FacesConfigEditor.GEF_CREATE_NEW_CONNECTION_TOOL);
+ gefObjectPart.click();
+ bot.sleep(Timing.time1S());
+ gefObjectAddedViaDnDTool = mainPart.descendants(new
FacesConfigGefEditorPartMatcher("/pages/" + dndPageName +
".jsp")).get(0);
+ gefObjectAddedViaDnDTool.click();
+ bot.sleep(Timing.time1S());
+
gefViewer.click(FacesConfigGefEditorUtil.getGefPartPosition(gefObjectAddedViaDnDTool).x,
+ FacesConfigGefEditorUtil.getGefPartPosition(gefObjectAddedViaDnDTool).y +
verticalSpacing);
+ gefViewer.clickContextMenu(IDELabel.Menu.AUTO_LAYOUT);
+ bot.shell(IDELabel.Shell.AUTO_LAYOUT).activate();
+ bot.button(IDELabel.Button.OK).click();
+ facesConfigEditor.save();
+ bot.sleep(Timing.time3S());
+
Assertions.assertSourceEditorContains(FacesConfigEditingTest.stripXMLSourceText(facesConfigEditorExt.getText()),
+ "<navigation-case><from-outcome>" + dndPageName +
+ "</from-outcome><to-view-id>/pages/" + dndPageName +
".jsp</to-view-id></navigation-case>",
+ FacesConfigEditingTest.FACES_CONFIG_FILE_NAME);
+ }
+ /**
+ * Handle adding new View
+ * @param fromViewID
+ */
+ private void handleNewViewWizard(String fromViewID){
+ SWTBot dialogBot = bot.shell(IDELabel.Shell.NEW_VIEW).activate().bot();
+ dialogBot.textWithLabel(IDELabel.NewViewDialog.FROM_VIEW_ID_TEXT_LABEL)
+ .setText(fromViewID);
+ dialogBot.checkBox(IDELabel.NewViewDialog.CREATE_FILE_ON_DISK_CHECKBOX_LABEL)
+ .select();
+ dialogBot.button(IDELabel.Button.FINISH).click();
+
+ }
+ /**
+ * Returns XNL Source striped from spaces, tabs and EOL
+ *
+ * @return String
+ */
+ protected static String stripXMLSourceText(String editorText) {
+ return editorText.replaceAll("\n", "").replaceAll("\t",
"")
+ .replaceAll("\b", "").replaceAll(" ",
"").replaceAll("\r", "")
+ .replaceAll("\f", "");
+ }
+ /**
+ * Confirm deletion of View from Diagram Editor
+ */
+ private void confirmViewDelete(){
+ bot.shell(IDELabel.Shell.CONFIRMATION).activate();
+ bot.checkBox(IDELabel.FacesConfigEditor.DELETE_FILE_FROM_DISK_CHECK_BOX).select();
+ bot.button(IDELabel.Button.OK).click();
+ }
+}
+
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorBot.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorBot.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorBot.java 2011-11-25
16:03:47 UTC (rev 36670)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.ui.bot.test.smoke.gefutils;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefViewer;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.part.EditorPart;
+
+/**
+ * modified copy of SWTBotGefEditor class to get it working with Faces Config GEF editor
+ *
+ * @author Vlado Pakan
+ */
+public class FacesConfigGefEditorBot extends SWTBotEditor {
+
+ private final FacesConfigGefEditorViewer viewer;
+ private static final Logger log =
Logger.getLogger(FacesConfigGefEditorBot.class.getName());
+
+ public FacesConfigGefEditorBot(final IEditorReference editorReference)
+ throws WidgetNotFoundException {
+ super(editorReference, new SWTWorkbenchBot());
+ GraphicalViewer graphicalViewer = UIThreadRunnable.syncExec(new
Result<GraphicalViewer>() {
+ public GraphicalViewer run() {
+ final IEditorPart editor = partReference.getEditor(true);
+ EditorPart ep = null;
+ try {
+ Field f = editor.getClass().getDeclaredField("editor");
+ f.setAccessible(true);
+ Object/*StrutsConfigEditor*/ o = f.get(editor);
+ f.setAccessible(false);
+ f = o.getClass().getDeclaredField("guiEditor");
+ f.setAccessible(true);
+ Object o2 = f.get(o);
+ f.setAccessible(false);
+ Method m = o2.getClass().getMethod("getGUI");
+ ep = (EditorPart) m.invoke(o2);
+ } catch (SecurityException e) {
+ log.log(Level.WARNING, e.getMessage(), e);
+ } catch (NoSuchFieldException e) {
+ log.log(Level.WARNING, e.getMessage(), e);
+ } catch (IllegalArgumentException e) {
+ log.log(Level.WARNING, e.getMessage(), e);
+ } catch (IllegalAccessException e) {
+ log.log(Level.WARNING, e.getMessage(), e);
+ } catch (NoSuchMethodException e) {
+ log.log(Level.WARNING, e.getMessage(), e);
+ } catch (InvocationTargetException e) {
+ log.log(Level.WARNING, e.getMessage(), e);
+ }
+ return (GraphicalViewer) ep.getAdapter(GraphicalViewer.class);
+ }
+ });
+ viewer = new FacesConfigGefEditorViewer(graphicalViewer);
+ }
+
+ public SWTBotGefViewer getViewer(){
+ return viewer;
+ }
+
+ public Control getControl(){
+ return viewer.getControl();
+ }
+
+ private static class FacesConfigGefEditorViewer extends SWTBotGefViewer {
+
+ public FacesConfigGefEditorViewer(GraphicalViewer graphicalViewer)
+ throws WidgetNotFoundException {
+ super(graphicalViewer);
+ }
+
+ public Control getControl() {
+ return super.getControl();
+ }
+
+ }
+}
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorBot.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorPartMatcher.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorPartMatcher.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorPartMatcher.java 2011-11-25
16:03:47 UTC (rev 36670)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.ui.bot.test.smoke.gefutils;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher;
+import org.hamcrest.Description;
+import org.jboss.tools.jsf.ui.editor.model.IGroup;
+/**
+ * Matcher for Editor Part within Face Config Diagram Editor
+ * @author Vlado Pakan
+ *
+ */
+public class FacesConfigGefEditorPartMatcher extends AbstractMatcher<EditPart> {
+
+ private final String path;
+
+ public FacesConfigGefEditorPartMatcher(String path) {
+ assert path != null;
+ assert path.trim().length() > 0;
+ this.path = path;
+ }
+
+ @Override
+ protected boolean doMatch(Object item) {
+ EditPart ep = (EditPart) item;
+ IGroup iGroup = (IGroup) ep.getModel();
+ return path.equals(iGroup.getPath());
+ }
+
+ public void describeTo(Description d) {
+ d.appendText("Edit Part with path: " + path);
+ }
+}
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorPartMatcher.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorUtil.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorUtil.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorUtil.java 2011-11-25
16:03:47 UTC (rev 36670)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.ui.bot.test.smoke.gefutils;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
+import org.jboss.tools.jsf.ui.editor.model.IGroup;
+/**
+ * Utils for Faces Config GEF Editor
+ * @author Vlado Pakan
+ *
+ */
+public class FacesConfigGefEditorUtil {
+ /**
+ * Returns position of gefPart
+ * @param gefPart
+ * @return
+ */
+ public static Point getGefPartPosition (SWTBotGefEditPart gefPart) {
+ return ((IGroup)gefPart.part().getModel()).getPosition();
+ }
+ /**
+ * Returns gefPart bounds
+ * @param gefPart
+ * @return
+ */
+ public static Rectangle getGefPartBounds(SWTBotGefEditPart gefPart) {
+ return ((IGroup)gefPart.part().getModel()).getImage().getBounds();
+ }
+
+ public static Rectangle getEditorControlBounds(final FacesConfigGefEditorBot
facesConfigGefEditorBot){
+ return UIThreadRunnable.syncExec(new Result<Rectangle>() {
+ public Rectangle run() {
+ return facesConfigGefEditorBot.getControl().getBounds();
+ }
+ });
+
+ }
+}
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/gefutils/FacesConfigGefEditorUtil.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/DragAndDropHelper.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/DragAndDropHelper.java 2011-11-25
16:01:30 UTC (rev 36669)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/DragAndDropHelper.java 2011-11-25
16:03:47 UTC (rev 36670)
@@ -15,8 +15,11 @@
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
+import java.text.MessageFormat;
import org.apache.log4j.Logger;
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.jface.util.Geometry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
@@ -24,15 +27,17 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.Result;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
/**
* Adds DnD Bot functionality
- * @author Vladimir Pakan
+ * @author jlukas, Vladimir Pakan
*
*/
public class DragAndDropHelper {
private static final Logger log = Logger.getLogger(DragAndDropHelper.class);
+ private static final int robotDelay =
Integer.getInteger("org.jboss.tools.ui.bot.ext.dndDelay", 150);
private static Robot robot = null;
/**
* Drag&Drop sourceWidget on to targetWidget
@@ -136,4 +141,125 @@
}
});
}
+
+ public static void dnd(final TreeItem ti, final TreeItem ti2) {
+ Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
+
+ public Rectangle run() {
+ return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
+ }
+ });
+ final Point slightOffset = Geometry.add(Geometry.getLocation(r1),
+ new Point(10, 10));
+
+ Rectangle r2 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
+
+ public Rectangle run() {
+ return ti2.getDisplay().map(ti2.getParent(), null, ti2.getBounds());
+ }
+ });
+
+ doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset),
+ Geometry.centerPoint(r2));
+ }
+
+ public static void dnd(final TreeItem ti, final FigureCanvas fc) {
+ Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
+
+ public Rectangle run() {
+ return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
+ }
+ });
+ final Point slightOffset = Geometry.add(Geometry.getLocation(r1),
+ new Point(10, 10));
+
+ Rectangle r2 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
+
+ public Rectangle run() {
+ return fc.getDisplay().map(fc.getParent(), null, fc.getBounds());
+ }
+ });
+
+ doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset),
+ Geometry.centerPoint(r2));
+ }
+
+ public static void dnd(final TreeItem ti, final Control fc, final int x,
+ final int y) {
+ Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
+
+ public Rectangle run() {
+ return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
+ }
+ });
+ final Point slightOffset = Geometry.add(Geometry.getLocation(r1),
+ new Point(10, 10));
+
+ Point r2 = UIThreadRunnable.syncExec(new Result<Point>() {
+
+ public Point run() {
+ log.info("xxx: " + fc.getLocation().x + ":" +
fc.getLocation().y);
+ return fc.getDisplay().map(fc, null, x, y);
+ }
+ });
+
+ doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset), r2);
+ }
+
+ /**
+ *
+ */
+ private static void doDragAndDrop(final Point source, final Point dest) {
+ log.info(MessageFormat.format(
+ "Drag-and-dropping from ({0},{1}) to ({2},{3})", source.x, source.y,
+ dest.x, dest.y));
+ try {
+ final Robot awtRobot = new Robot();
+ awtRobot.setAutoDelay(robotDelay);
+ // the x+10 motion is needed to let native functions register a drag
+ // detect. It did not work under Windows
+ // otherwise and has been reported to be required for linux, too.
+ // But I could not test that.
+ UIThreadRunnable.syncExec(new VoidResult() {
+
+ public void run() {
+ awtRobot.mouseMove(source.x, source.y);
+ awtRobot.mousePress(InputEvent.BUTTON1_MASK);
+ awtRobot.mouseMove((source.x + 10), source.y);
+ }
+ });
+
+ // now pause the test until all runnables on the Display thread have
+ // run this is necessary for the pick up
+ // to register on linux
+ waitForIdle(awtRobot);
+
+ UIThreadRunnable.syncExec(new VoidResult() {
+
+ public void run() {
+ awtRobot.mouseMove((dest.x + 10), dest.y);
+ awtRobot.mouseMove(dest.x, dest.y);
+ }
+ });
+
+ waitForIdle(awtRobot);
+
+ UIThreadRunnable.syncExec(new VoidResult() {
+
+ public void run() {
+ awtRobot.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+ });
+ waitForIdle(awtRobot);
+ } catch (final AWTException e) {
+ log.info(e.getMessage(), e);
+ throw new RuntimeException(e);
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+
}
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2011-11-25
16:01:30 UTC (rev 36669)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2011-11-25
16:03:47 UTC (rev 36670)
@@ -84,6 +84,7 @@
public static final String UNDO = "Undo";
public static final String CLOSE_ALL = "Close All";
public static final String SAVE_AS_TEMPLATE = "Save As Template...";
+ public static final String AUTO_LAYOUT = "Auto Layout";
}
public class Button {
@@ -168,6 +169,13 @@
public static final String SECURE_STORAGE = "Secure Storage";
public static final String ADD_JSF_PROJECT_TEMPLATE = "Add JSF Project
Template";
public static final String NEW_MANAGED_BEAN = "New Managed Bean";
+ public static final String ADD_COMPONENT = "Add Component";
+ public static final String ADD_CONVERTER = "Add Converter";
+ public static final String ADD_REFERENCED_BEAN = "Add Referenced Bean";
+ public static final String ADD_RENDER_KIT = "Add Render Kit";
+ public static final String ADD_VALIDATOR = "Add Validator";
+ public static final String NEW_VIEW = "New View";
+ public static final String AUTO_LAYOUT = "Auto Layout";
}
public class EntityGroup {
@@ -691,11 +699,28 @@
public static final String TREE_TAB_LABEL = "Tree";
public static final String DIAGRAM_TAB_LABEL = "Diagram";
public static final String MANAGED_BEANS_NODE = "Managed Beans";
+ public static final String COMPONENTS_NODE = "Components";
+ public static final String CONVERTERS_NODE = "Converters";
+ public static final String RENDER_KITS_NODE = "Render Kits";
+ public static final String VALIDATOR_NODE = "Validators";
+ public static final String REFERENCED_BEAN_NODE = "Referenced Beans";
public static final String NEW_MANAGED_BEAN_CLASS_LABEL = "Class:*";
public static final String MANAGED_BEAN_CLASS_LABEL = "Managed Bean
Class:";
public static final String NEW_MANAGED_BEAN_NAME_LABEL = "Name:*";
public static final String DELETE_JAVA_SOURCE_CHECK_BOX = "Delete Java
Source";
-
+ public static final String NEW_COMPONENT_TYPE_LABEL = "Component Type:*";
+ public static final String NEW_COMPONENT_CLASS_LABEL = "Component
Class:*";
+ public static final String NEW_CONVERTER_ID_LABEL = "Converter ID:*";
+ public static final String NEW_CONVERTER_CLASS_LABEL = "Converter
Class:*";
+ public static final String NEW_REFERENCED_BEAN_NAME_LABEL = "Referenced Bean
Name:*";
+ public static final String NEW_REFERENCED_BEAN_CLASS_LABEL = "Referenced Bean
Class:*";
+ public static final String NEW_RENDER_KIT_ID_LABEL = "Render Kit ID:";
+ public static final String NEW_RENDER_KIT_CLASS_LABEL = "Render Kit
Class:";
+ public static final String NEW_VALIDATOR_ID_LABEL = "Validator ID:*";
+ public static final String NEW_VALIDATOR_CLASS_LABEL = "Validator
Class:*";
+ public static final String GEF_VIEW_TEMPLATE_TOOL = "View Template";
+ public static final String GEF_CREATE_NEW_CONNECTION_TOOL = "Create New
Connection";
+ public static final String DELETE_FILE_FROM_DISK_CHECK_BOX = "Delete file from
disk";
}
public static class NewJsfProjectDialog{
@@ -738,4 +763,10 @@
public static final String NAME_TEXT_LABEL = "Name:*";
public static final String IMPLEMENTATION_COMBO_LABEL =
"Implementation:*";
}
+
+ public static class NewViewDialog{
+ public static final String FROM_VIEW_ID_TEXT_LABEL = "From View ID:";
+ public static final String TEMPLATE_TEXT_LABEL = "Template:*";
+ public static final String CREATE_FILE_ON_DISK_CHECKBOX_LABEL = "Create File on
Disk";
+ }
}