Author: vpakan(a)redhat.com
Date: 2010-08-12 10:13:17 -0400 (Thu, 12 Aug 2010)
New Revision: 24103
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/ManagePaletteGroupsTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/PaletteEditorTest.java
Removed:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/ManagePaletteGroups.java
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ContextMenuHelper.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java
Log:
Added Palette Editor Text and added suffix Test to MannagePaletteGroups class name
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ContextMenuHelper.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ContextMenuHelper.java 2010-08-12
14:12:33 UTC (rev 24102)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ContextMenuHelper.java 2010-08-12
14:13:17 UTC (rev 24103)
@@ -21,13 +21,19 @@
import org.apache.log4j.Logger;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Decorations;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget;
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.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.results.WidgetResult;
import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
@@ -277,6 +283,191 @@
}
});
}
+ /**
+ * Returns tree menu which contains menuLabel
+ * @param tree
+ * @param menuLabel
+ * @return
+ */
+ public static Menu getTreeMenuViaReflections (final Tree tree, final String
menuLabel){
+ // Menu has to be already created
+ return UIThreadRunnable.syncExec(new WidgetResult<Menu>() {
+ public Menu run() {
+ Menu result = null;
+ Composite parent = tree.getParent();
+ while (!(parent instanceof Decorations)){
+ parent = parent.getParent();
+ }
+ try {
+ Menu[] menus = ReflectionsHelper.getPrivateFieldValue(Decorations.class,
+ "menus",
+ parent,
+ Menu[].class);
+ if (menus != null){
+ MenuItem topMenuItem = null;
+ int index = menus.length - 1;
+ while (topMenuItem == null && index >= 0){
+ if (menus[index] != null){
+ MenuItem[] menuItems = menus[index].getItems();
+ int menuItemIndex = 0;
+ while (topMenuItem == null && menuItemIndex <
menuItems.length){
+ if (menuItems[menuItemIndex].getText().equals(menuLabel)){
+ topMenuItem = menuItems[menuItemIndex];
+ }
+ menuItemIndex++;
+ }
+ }
+ index--;
+ }
+ if (topMenuItem != null){
+ result = topMenuItem.getParent();
+ }
+ }
+ else{
+ throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabel);
+ }
+ } catch (SecurityException se) {
+ throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabel,se);
+ } catch (NoSuchFieldException nsfe) {
+ throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabel,nsfe);
+ } catch (IllegalArgumentException iae) {
+ throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabel,iae);
+ } catch (IllegalAccessException iace) {
+ throw new WidgetNotFoundException("Unable to find MenuItem with label
" + menuLabel,iace);
+ }
+ return result;
+ }});
+ }
+ /**
+ * Simulate Right Click on treeItem
+ * @param tree
+ * @param treeItem
+ */
+ public static void treeRightClick(final Tree tree , final TreeItem treeItem) {
+ Rectangle cellBounds = UIThreadRunnable.syncExec(new Result<Rectangle>() {
+ public Rectangle run() {
+ return treeItem.getBounds();
+ }
+ });
+ clickXY(cellBounds.x + (cellBounds.width / 2), cellBounds.y + (cellBounds.height /
2), tree , treeItem);
+ }
+ /**
+ * Simulate Right Click on treeItem on specified position
+ * @param x
+ * @param y
+ * @param tree
+ * @param treeItem
+ */
+ protected static void clickXY(int x, int y,final Tree tree , final TreeItem treeItem)
{
+ notifyTree(SWT.MouseEnter,tree,treeItem);
+ notifyTree(SWT.MouseMove,tree,treeItem);
+ notifyTree(SWT.Activate,tree,treeItem);
+ notifyTree(SWT.FocusIn,tree,treeItem);
+ notifyTree(SWT.MouseDown, createMouseEvent(x, y, 3, SWT.BUTTON3, 1, tree,
treeItem),tree);
+ notifyTree(SWT.MouseUp,createMouseEvent(x, y, 3, SWT.BUTTON3, 1, tree,
treeItem),tree);
+ notifyTree(SWT.Selection, createEvent(tree,treeItem),tree);
+ notifyTree(SWT.MouseHover,tree,treeItem);
+ notifyTree(SWT.MouseMove,tree,treeItem);
+ notifyTree(SWT.MouseExit,tree,treeItem);
+ notifyTree(SWT.Deactivate,tree,treeItem);
+ notifyTree(SWT.FocusOut,tree,treeItem);
+ }
+ /**
+ * Notify tree with Event of specified eventType
+ * @param eventType
+ * @param tree
+ * @param treeItem
+ */
+ private static void notifyTree(int eventType , Tree tree , TreeItem treeItem) {
+ Event event = new Event();
+ event.time = (int) System.currentTimeMillis();
+ event.widget = tree;
+ event.display = tree.getDisplay();
+ event.item = treeItem;
+ notify(eventType, event, tree);
+ }
+ /**
+ * Notify tree with Event of specified eventType
+ * @param eventType
+ * @param event
+ * @param tree
+ */
+ private static void notifyTree(int eventType , Event event , Tree tree) {
+ notify(eventType, event, tree);
+ }
+ /**
+ * Sends a non-blocking notification of the specified type to the widget.
+ *
+ * @param eventType the type of event.
+ * @param createEvent the event to be sent to the {@link #widget}.
+ * @param widget the widget to send the event to.
+ */
+ protected static void notify(final int eventType, final Event createEvent, final
Widget widget) {
+ createEvent.type = eventType;
+ widget.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if ((widget == null) || widget.isDisposed()) {
+ return;
+ }
+ widget.notifyListeners(eventType, createEvent);
+ }
+ });
+ widget.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ // do nothing, just wait for sync.
+ }
+ });
+ }
+ /**
+ * Create a mouse event
+ *
+ * @param x the x co-ordinate of the mouse event.
+ * @param y the y co-ordinate of the mouse event.
+ * @param button the mouse button that was clicked.
+ * @param stateMask the state of the keyboard modifier keys.
+ * @param count the number of times the mouse was clicked.
+ * @return an event that encapsulates {@link #widget} and {@link #display}
+ * @since 1.2
+ */
+ protected static Event createMouseEvent(int x, int y, int button, int stateMask, int
count, Tree tree , TreeItem treeItem) {
+ Event event = new Event();
+ event.time = (int) System.currentTimeMillis();
+ event.widget = tree;
+ event.display = tree.getDisplay();
+ event.x = x;
+ event.y = y;
+ event.button = button;
+ event.stateMask = stateMask;
+ event.count = count;
+ event.item = treeItem;
+ return event;
+ }
+ /**
+ * Create default Event for tree and treeItem
+ * @param tree
+ * @param treeItem
+ * @return
+ */
+ protected static Event createEvent(Tree tree, TreeItem treeItem) {
+ Event event = new Event();
+ event.time = (int) System.currentTimeMillis();
+ event.widget = tree;
+ event.display = tree.getDisplay();
+ event.item = treeItem;
+ return event;
+ }
+ /**
+ * Hide menu and all his parent menus
+ * @param menu
+ */
+ public static void hideMenuRecursively(final Menu menu){
+ menu.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ ContextMenuHelper.hide(menu);
+ menu.setVisible(false);
+ }
+ });
+ }
}
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 2010-08-12
14:12:33 UTC (rev 24102)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-08-12
14:13:17 UTC (rev 24103)
@@ -140,6 +140,11 @@
public static final String COPY_FILE_FROM_GUVNOR_TO_PACKAGE_EXPLORER = "File
Operation";
public static final String INSERT_TAG = "Insert Tag";
public static final String SHOW_HIDE_DRAWERS = "Show/Hide Drawers";
+ public static final String PALETTE_EDITOR = "Palette Editor";
+ public static final String CREATE_GROUP = "Create Group";
+ public static final String ADD_PALETTE_GROUP = "Add Palette Group";
+ public static final String ADD_PALETTE_MACRO = "Add Palette Macro";
+ public static final String CONFIRMATION = "Confirmation";
}
public class EntityGroup {
@@ -539,4 +544,36 @@
public static final String SHOW_HIDE_TOOL_ITEM = "Show/Hide";
}
+
+ public static class PaletteEditor{
+
+ public static final String XSTUDIO_NODE = "XStudio";
+ public static final String PALETTE_NODE = "Palette";
+ public static final String NEW_MENU_ITEM = "New";
+ public static final String CREATE_GROUP_MENU_ITEM = "Create Group...";
+ public static final String CREATE_MACRO_MENU_ITEM = "Create Macro...";
+ public static final String DELETE_MENU_ITEM = "Delete";
+
+ }
+
+ public static class CreateGroupDialog{
+
+ public static final String NAME = "Name*";
+
+ }
+
+ public static class AddPaletteGroupDialog{
+
+ public static final String NAME = "Name*";
+
+ }
+
+ public static class AddPaletteMacroDialog{
+
+ public static final String NAME = "Name*";
+ public static final String START_TEXT = "Start Text";
+ public static final String END_TEXT = "End Text";
+
+ }
+
}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-08-12
14:12:33 UTC (rev 24102)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-08-12
14:13:17 UTC (rev 24103)
@@ -19,7 +19,8 @@
import org.jboss.tools.vpe.ui.bot.test.jbide.JBIDE4556Test;
import org.jboss.tools.vpe.ui.bot.test.palette.CancelTagLibDefenitionTest;
import org.jboss.tools.vpe.ui.bot.test.palette.ImportTagsFromTLDFileTest;
-import org.jboss.tools.vpe.ui.bot.test.palette.ManagePaletteGroups;
+import org.jboss.tools.vpe.ui.bot.test.palette.ManagePaletteGroupsTest;
+import org.jboss.tools.vpe.ui.bot.test.palette.PaletteEditorTest;
import org.jboss.tools.vpe.ui.bot.test.smoke.EditorSynchronizationTest;
import org.jboss.tools.vpe.ui.bot.test.smoke.JSPPageCreationTest;
import org.jboss.tools.vpe.ui.bot.test.smoke.RenameFacesConfigFileTest;
@@ -60,8 +61,9 @@
suite.addTestSuite(ExternalizeStringsDialogTest.class);
suite.addTestSuite(JspFileEditingTest.class);
suite.addTestSuite(XhtmlFilePerformanceTest.class);
- suite.addTestSuite(ManagePaletteGroups.class);
-
+ suite.addTestSuite(ManagePaletteGroupsTest.class);
+ suite.addTestSuite(PaletteEditorTest.class);
+
return new TestSetup(suite);
}
}
Deleted:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/ManagePaletteGroups.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/ManagePaletteGroups.java 2010-08-12
14:12:33 UTC (rev 24102)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/ManagePaletteGroups.java 2010-08-12
14:13:17 UTC (rev 24103)
@@ -1,72 +0,0 @@
-/*******************************************************************************
-
- * Copyright (c) 2007-2010 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.ui.bot.test.palette;
-
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.ui.bot.ext.SWTBotExt;
-import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.jboss.tools.vpe.ui.bot.test.VPEAutoTestCase;
-import org.jboss.tools.vpe.ui.bot.test.tools.SWTBotWebBrowser;
-/**
- * Tests Showing/hiding JBoss Tools Palette Groups
- * @author vlado pakan
- *
- */
-public class ManagePaletteGroups extends VPEAutoTestCase {
-
- private static final String TEST_PALETTE_GROUP_LABEL = "JSF HTML";
- private static final String TEST_PALETTE_TREE_GROUP_LABEL = "JSF";
-
- private SWTBotExt botExt = null;
-
- public ManagePaletteGroups() {
- super();
- botExt = new SWTBotExt();
- }
- public void testManagePaletteGroups(){
-
- openPage();
- openPalette();
-
bot.toolbarButtonWithTooltip(IDELabel.JBossToolsPalette.SHOW_HIDE_TOOL_ITEM).click();
- SWTBot dialogBot = bot.shell(IDELabel.Shell.SHOW_HIDE_DRAWERS).activate().bot();
- SWTBotTreeItem tiTestPaletteGroup =
dialogBot.tree().getTreeItem(ManagePaletteGroups.TEST_PALETTE_TREE_GROUP_LABEL);
- if (tiTestPaletteGroup.isChecked()){
- // Check Palette Group hiding
- tiTestPaletteGroup.uncheck();
- dialogBot.button("Ok").click();
- assertTrue("Palette Group " +
ManagePaletteGroups.TEST_PALETTE_GROUP_LABEL +
- " has to be hidden but is visible.",
- !SWTBotWebBrowser.paletteContainsPaletteEntry(botExt,
ManagePaletteGroups.TEST_PALETTE_GROUP_LABEL));
- }
- else{
- // Check Palette Group showing
- tiTestPaletteGroup.check();
- dialogBot.button("Ok").click();
- assertTrue("Palette Group " +
ManagePaletteGroups.TEST_PALETTE_GROUP_LABEL +
- " has to be visible but is hidden.",
- SWTBotWebBrowser.paletteContainsPaletteEntry(botExt,
ManagePaletteGroups.TEST_PALETTE_GROUP_LABEL));
- }
-
-
- }
- @Override
- protected void closeUnuseDialogs() {
-
- }
-
- @Override
- protected boolean isUnuseDialogOpened() {
- return false;
- }
-
-}
Copied:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/ManagePaletteGroupsTest.java
(from rev 24005,
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/ManagePaletteGroups.java)
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/ManagePaletteGroupsTest.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/ManagePaletteGroupsTest.java 2010-08-12
14:13:17 UTC (rev 24103)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+
+ * Copyright (c) 2007-2010 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.ui.bot.test.palette;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.vpe.ui.bot.test.VPEAutoTestCase;
+import org.jboss.tools.vpe.ui.bot.test.tools.SWTBotWebBrowser;
+/**
+ * Tests Showing/hiding JBoss Tools Palette Groups
+ * @author vlado pakan
+ *
+ */
+public class ManagePaletteGroupsTest extends VPEAutoTestCase {
+
+ private static final String TEST_PALETTE_GROUP_LABEL = "JSF HTML";
+ private static final String TEST_PALETTE_TREE_GROUP_LABEL = "JSF";
+
+ private SWTBotExt botExt = null;
+
+ public ManagePaletteGroupsTest() {
+ super();
+ botExt = new SWTBotExt();
+ }
+ public void testManagePaletteGroups(){
+
+ openPage();
+ openPalette();
+
bot.toolbarButtonWithTooltip(IDELabel.JBossToolsPalette.SHOW_HIDE_TOOL_ITEM).click();
+ SWTBot dialogBot = bot.shell(IDELabel.Shell.SHOW_HIDE_DRAWERS).activate().bot();
+ SWTBotTreeItem tiTestPaletteGroup =
dialogBot.tree().getTreeItem(ManagePaletteGroupsTest.TEST_PALETTE_TREE_GROUP_LABEL);
+ if (tiTestPaletteGroup.isChecked()){
+ // Check Palette Group hiding
+ tiTestPaletteGroup.uncheck();
+ dialogBot.button("Ok").click();
+ assertTrue("Palette Group " +
ManagePaletteGroupsTest.TEST_PALETTE_GROUP_LABEL +
+ " has to be hidden but is visible.",
+ !SWTBotWebBrowser.paletteContainsPaletteEntry(botExt,
ManagePaletteGroupsTest.TEST_PALETTE_GROUP_LABEL));
+ }
+ else{
+ // Check Palette Group showing
+ tiTestPaletteGroup.check();
+ dialogBot.button("Ok").click();
+ assertTrue("Palette Group " +
ManagePaletteGroupsTest.TEST_PALETTE_GROUP_LABEL +
+ " has to be visible but is hidden.",
+ SWTBotWebBrowser.paletteContainsPaletteEntry(botExt,
ManagePaletteGroupsTest.TEST_PALETTE_GROUP_LABEL));
+ }
+
+
+ }
+ @Override
+ protected void closeUnuseDialogs() {
+
+ }
+
+ @Override
+ protected boolean isUnuseDialogOpened() {
+ return false;
+ }
+
+}
Property changes on:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/ManagePaletteGroupsTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/PaletteEditorTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/PaletteEditorTest.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/PaletteEditorTest.java 2010-08-12
14:13:17 UTC (rev 24103)
@@ -0,0 +1,132 @@
+/*******************************************************************************
+
+ * Copyright (c) 2007-2010 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.ui.bot.test.palette;
+
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.vpe.ui.bot.test.VPEAutoTestCase;
+import org.jboss.tools.vpe.ui.bot.test.tools.SWTBotWebBrowser;
+/**
+ * Tests Palette Editor
+ * @author vlado pakan
+ *
+ */
+public class PaletteEditorTest extends VPEAutoTestCase {
+ private SWTBotExt botExt = null;
+
+ public PaletteEditorTest() {
+ super();
+ botExt = new SWTBotExt();
+ }
+
+ public void testPaletteEditor(){
+ openPage();
+ openPalette();
+ // add First Palette Group
+
bot.toolbarButtonWithTooltip(IDELabel.JBossToolsPalette.PALETTE_EDITOR_TOOL_ITEM).click();
+ SWTBot palettEditorBot = bot.shell(IDELabel.Shell.PALETTE_EDITOR).activate().bot();
+ SWTBotTree tree = palettEditorBot.tree();
+ SWTBotTreeItem tiPalette = tree.expandNode(IDELabel.PaletteEditor.XSTUDIO_NODE)
+ .getNode(IDELabel.PaletteEditor.PALETTE_NODE)
+ .select();
+ ContextMenuHelper.treeRightClick(tree.widget, tiPalette.widget);
+ Menu menu =
ContextMenuHelper.getTreeMenuViaReflections(tree.widget,IDELabel.PaletteEditor.NEW_MENU_ITEM);
+ ContextMenuHelper.clickContextMenu(menu,
+ IDELabel.PaletteEditor.NEW_MENU_ITEM,
+ IDELabel.PaletteEditor.CREATE_GROUP_MENU_ITEM);
+ ContextMenuHelper.hideMenuRecursively(menu);
+ SWTBot createGroupDialogBot =
bot.shell(IDELabel.Shell.CREATE_GROUP).activate().bot();
+ final String firstGroup = "First";
+
createGroupDialogBot.textWithLabel(IDELabel.CreateGroupDialog.NAME).setText(firstGroup);
+ createGroupDialogBot.button(IDELabel.Button.FINISH).click();
+ // add Second Inner Palette Group
+ SWTBotTreeItem tiFirstGroup = tree.expandNode(IDELabel.PaletteEditor.XSTUDIO_NODE)
+ .expandNode(IDELabel.PaletteEditor.PALETTE_NODE)
+ .expandNode(firstGroup)
+ .select();
+ ContextMenuHelper.treeRightClick(tree.widget, tiFirstGroup.widget);
+ menu =
ContextMenuHelper.getTreeMenuViaReflections(tree.widget,IDELabel.PaletteEditor.CREATE_GROUP_MENU_ITEM);
+ ContextMenuHelper.clickContextMenu(menu,
+ IDELabel.PaletteEditor.CREATE_GROUP_MENU_ITEM);
+ ContextMenuHelper.hideMenuRecursively(menu);
+ SWTBot addPaletteGroupBot =
bot.shell(IDELabel.Shell.ADD_PALETTE_GROUP).activate().bot();
+ final String secondGroup = "Second";
+
addPaletteGroupBot.textWithLabel(IDELabel.AddPaletteGroupDialog.NAME).setText(secondGroup);
+ addPaletteGroupBot.button(IDELabel.Button.FINISH).click();
+ // add Macro
+ SWTBotTreeItem tiSecondGroup = tree.expandNode(IDELabel.PaletteEditor.XSTUDIO_NODE)
+ .expandNode(IDELabel.PaletteEditor.PALETTE_NODE)
+ .expandNode(firstGroup)
+ .expandNode(secondGroup)
+ .select();
+ ContextMenuHelper.treeRightClick(tree.widget, tiSecondGroup.widget);
+ menu =
ContextMenuHelper.getTreeMenuViaReflections(tree.widget,IDELabel.PaletteEditor.NEW_MENU_ITEM);
+ ContextMenuHelper.clickContextMenu(menu,
+ IDELabel.PaletteEditor.NEW_MENU_ITEM,
+ IDELabel.PaletteEditor.CREATE_MACRO_MENU_ITEM);
+ ContextMenuHelper.hideMenuRecursively(menu);
+ SWTBot addPaletteMacroBot =
bot.shell(IDELabel.Shell.ADD_PALETTE_MACRO).activate().bot();
+ final String macroName = "Test Macro";
+
addPaletteMacroBot.textWithLabel(IDELabel.AddPaletteMacroDialog.NAME).setText(macroName);
+ final String startText = "<HTML>";
+
addPaletteMacroBot.textWithLabel(IDELabel.AddPaletteMacroDialog.START_TEXT).setText(startText);
+ final String endText = "</HTML>";
+
addPaletteMacroBot.textWithLabel(IDELabel.AddPaletteMacroDialog.END_TEXT).setText(endText);
+ addPaletteMacroBot.button(IDELabel.Button.FINISH).click();
+ palettEditorBot.button(IDELabel.Button.OK).click();
+ //add Test Macro to Page Source
+ final SWTBotEclipseEditor jspTextEditor = botExt.editorByTitle(TEST_PAGE)
+ .toTextEditor();
+ final String originalText = jspTextEditor.getText();
+ jspTextEditor.setFocus();
+ jspTextEditor.insertText(0, 0, "\n");
+ jspTextEditor.insertText(0, 0, "");
+ SWTBotWebBrowser.activatePaletteTool(botExt,macroName);
+ // Check if Macro was added to Source Editor
+ String insertedText = jspTextEditor.getTextOnCurrentLine().trim();
+ assertTrue("Inserted text has to be '" + startText + endText +
+ "' and was '" + insertedText + "'",
+ insertedText.equals(startText + endText));
+ jspTextEditor.setText(originalText);
+ jspTextEditor.saveAndClose();
+ // Delete New Group From Palette
+
bot.toolbarButtonWithTooltip(IDELabel.JBossToolsPalette.PALETTE_EDITOR_TOOL_ITEM).click();
+ palettEditorBot = bot.shell(IDELabel.Shell.PALETTE_EDITOR).activate().bot();
+ tree = palettEditorBot.tree();
+ tiFirstGroup = tree.expandNode(IDELabel.PaletteEditor.XSTUDIO_NODE)
+ .expandNode(IDELabel.PaletteEditor.PALETTE_NODE)
+ .expandNode(firstGroup)
+ .select();
+ ContextMenuHelper.treeRightClick(tree.widget, tiFirstGroup.widget);
+ menu =
ContextMenuHelper.getTreeMenuViaReflections(tree.widget,IDELabel.PaletteEditor.CREATE_GROUP_MENU_ITEM);
+ ContextMenuHelper.clickContextMenu(menu,
+ IDELabel.PaletteEditor.DELETE_MENU_ITEM);
+ SWTBot deleteDialogBot = bot.shell(IDELabel.Shell.CONFIRMATION).activate().bot();
+ deleteDialogBot.button(IDELabel.Button.OK).click();
+ palettEditorBot.button(IDELabel.Button.OK).click();
+ }
+ @Override
+ protected void closeUnuseDialogs() {
+
+ }
+
+ @Override
+ protected boolean isUnuseDialogOpened() {
+ return false;
+ }
+}
Property changes on:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/palette/PaletteEditorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java 2010-08-12
14:12:33 UTC (rev 24102)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java 2010-08-12
14:13:17 UTC (rev 24103)
@@ -29,7 +29,6 @@
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swtbot.eclipse.gef.finder.finders.PaletteFinder;
import org.eclipse.swtbot.eclipse.gef.finder.matchers.ToolEntryLabelMatcher;
-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.Result;
@@ -435,6 +434,15 @@
*/
public void activatePaletteTool (String toolLabel){
+ SWTBotWebBrowser.activatePaletteTool(bot,toolLabel);
+
+ }
+ /**
+ * Activate JBoss Tools Palette Tool with specified Label static version
+ * @param toolLabel
+ */
+ public static void activatePaletteTool (SWTBotExt bot , String toolLabel){
+
PaletteViewer paletteViewer = SWTBotWebBrowser.getPaletteViewer(bot);
PaletteEntry peJsfHtml = SWTBotWebBrowser.getPaletteEntry(paletteViewer ,
toolLabel);
paletteViewer.setActiveTool((ToolEntry) peJsfHtml);