Author: DartPeng
Date: 2010-04-06 03:05:31 -0400 (Tue, 06 Apr 2010)
New Revision: 21277
Added:
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/KeyPressHelper.java
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/jira/KeyboradAbility_JBIDE5831.java
Log:
JBIDE-5831
Install the feature test case for Keyboard ability in Smooks editor
Added:
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/KeyPressHelper.java
===================================================================
---
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/KeyPressHelper.java
(rev 0)
+++
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/KeyPressHelper.java 2010-04-06
07:05:31 UTC (rev 21277)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.ui.bot.test;
+
+import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory;
+import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+
+/**
+ * @author Dart
+ *
+ */
+public class KeyPressHelper {
+ public static void pressSingleKeyCode(int keyCode) {
+ SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
+ KeyboardFactory.getSWTKeyboard().pressShortcut(Keystrokes.DELETE);
+
+ }
+
+ public static void pressCompositeKeyCode(int stateMask, char c) {
+
+ SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
+ KeyboardFactory.getSWTKeyboard().pressShortcut(stateMask,c);
+ }
+}
Property changes on:
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/KeyPressHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/jira/KeyboradAbility_JBIDE5831.java
===================================================================
---
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/jira/KeyboradAbility_JBIDE5831.java
(rev 0)
+++
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/jira/KeyboradAbility_JBIDE5831.java 2010-04-06
07:05:31 UTC (rev 21277)
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.ui.bot.test.jira;
+
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.zest.core.widgets.Graph;
+import org.eclipse.zest.core.widgets.GraphNode;
+import org.jboss.tools.smooks.graphical.editors.TaskTypeManager;
+import org.jboss.tools.smooks.graphical.editors.process.TaskType;
+import org.jboss.tools.smooks.ui.bot.test.AbstractSmooksUIBotTest;
+import org.jboss.tools.smooks.ui.bot.test.KeyPressHelper;
+
+/**
+ * @author Dart
+ *
+ */
+public class KeyboradAbility_JBIDE5831 extends AbstractSmooksUIBotTest {
+ private String fileName;
+ public void testKeyboradAbility(){
+ SWTGefBot gefBot = new SWTGefBot();
+
+ fileName = "keyborad.xml";
+ this.newSmooksConfigFile(getTestProjectName(), fileName);
+ SWTBotEditor editor = bot.editorByTitle(fileName);
+ final SWTBot innerBot = editor.bot();
+
+ // add task node via pop menu
+ selectNode(innerBot, TaskTypeManager.TASK_ID_INPUT, 3);
+ SWTBotMenu addJavaMappingMenu = findProcessMapViewerContext(getGraph(innerBot),
"Java Mapping");
+ addJavaMappingMenu.click();
+
+ // select at the java mapping task
+ selectNode(innerBot, TaskTypeManager.TASK_ID_JAVA_MAPPING, 1);
+
+ SWTBotGefEditor editor1 = gefBot.gefEditor(fileName);
+
+ // add java class model via pop menu
+ editor1.rootEditPart().click();
+ editor1.clickContextMenu("Java Class ");
+
+ // open java bean creation dialog , add a new Java Bean figure
+ bot.shell("New Java Class Model").activate();
+
+ bot.textWithLabel("Bean ID :").setText("order");
+
+ bot.textWithLabel("Java Class
:").setText("edi2java.example.model.Order");
+
+ bot.button("Finish").click();
+
+ /* Test keyborad ability in the Mapping Viewer */
+
+ // Test the Delete key:
+
+ // to find the 'order' GEF edit part:
+ SWTBotGefEditPart part = editor1.getEditPart("order");
+ part.click();
+ // Press Delete
+ KeyPressHelper.pressSingleKeyCode( SWT.DEL);
+ // Find the 'order' GEF edit part agian to test if it disappear.
+ part = editor1.getEditPart("order");
+ Assert.isTrue(part == null , "Delete key doesn't effect");
+
+ // Test Ctrl+Z (redo) key:
+ editor1.rootEditPart().click();
+ KeyPressHelper.pressCompositeKeyCode(SWT.CTRL, 'z');
+
+ part = editor1.getEditPart("order");
+ Assert.isNotNull(part , "Order part isn't added again !!");
+
+ // Test Ctrl+y (undo) key:
+ editor1.rootEditPart().click();
+ KeyPressHelper.pressCompositeKeyCode(SWT.CTRL, 'y');
+
+ part = editor1.getEditPart("order");
+ Assert.isTrue(part == null , "Order part isn't deleted again !!");
+
+ /* Test keyborad ability in Process Viewer*/
+ // select at the java mapping task
+ selectNode(innerBot, TaskTypeManager.TASK_ID_JAVA_MAPPING, 1);
+ KeyPressHelper.pressSingleKeyCode( SWT.DEL);
+ final Graph graph = getGraph(innerBot);
+ final List<?> nodes = graph.getNodes();
+ innerBot.getDisplay().syncExec(new Runnable() {
+ public void run(){
+ for (Iterator<?> iterator = nodes.iterator(); iterator.hasNext();) {
+ GraphNode node = (GraphNode) iterator.next();
+ Object data = node.getData();
+ if (data instanceof TaskType) {
+ String id = ((TaskType) data).getId();
+ if(id.equals(TaskTypeManager.TASK_ID_JAVA_MAPPING)){
+ Assert.isTrue(false,"Java Mapping node isn't deleted");
+ }
+ }
+ }
+ }
+ });
+
+ }
+
+}
Property changes on:
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/jira/KeyboradAbility_JBIDE5831.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain