Author: vpakan(a)redhat.com
Date: 2010-01-18 14:26:19 -0500 (Mon, 18 Jan 2010)
New Revision: 19795
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileRenameHelper.java
Removed:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/CheckRenaming.java
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/RenameFacesConfigFileTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/RenameJSPFileTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/RenameXHTMLFileTest.java
Log:
Renaming check moved from CheckRenaming.java to FileRenameHelper.java.
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileRenameHelper.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileRenameHelper.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/FileRenameHelper.java 2010-01-18
19:26:19 UTC (rev 19795)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.ui.bot.ext.helper;
+
+import static org.jboss.tools.ui.bot.ext.SWTTestExt.eclipse;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.ui.bot.ext.types.JobName;
+import org.jboss.tools.ui.bot.ext.types.ViewType;
+
+/**
+ * Check Renaming Functionality within WebProjects View
+ * Tests if file was properly renamed in WebProjects View
+ * and Title of file in Editor was renamed also.
+ * @author Vladimir Pakan
+ *
+ */
+public class FileRenameHelper {
+ private static final int sleepTime = 1000;
+ /**
+ * Check File Renaming
+ * @param bot
+ * @param oldFileName
+ * @param newFileName
+ * @param treePathItems
+ * @param fileTreeItemSuffix
+ * @return
+ */
+ public static String checkFileRenamingWithinWebProjects(SWTWorkbenchBot bot , String
oldFileName, String newFileName,
+ String[] treePathItems , String fileTreeItemSuffix){
+
+ bot.sleep(sleepTime);
+ SWTBot webProjects = eclipse.showView(ViewType.WEB_PROJECTS);
+ SWTBotTree tree = webProjects.tree();
+
+ tree.setFocus();
+
+ if (treePathItems != null && treePathItems.length > 0){
+ SWTBotTreeItem parentTreeItem = tree.getTreeItem(treePathItems[0]);
+ parentTreeItem.expand();
+ bot.sleep(1000);
+ parentTreeItem.select();
+ bot.sleep(1000);
+ // Do not remove this part of code otherwise tree view is not populated properly
+ parentTreeItem.collapse();
+ bot.sleep(1000);
+ parentTreeItem.expand();
+ bot.sleep(1000);
+ int index = 1;
+ while (treePathItems.length > index){
+ parentTreeItem = parentTreeItem.getNode(treePathItems[index]);
+ parentTreeItem.expand();
+ index++;
+ }
+ // Open File
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree ,
parentTreeItem.getNode(oldFileName + fileTreeItemSuffix));
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.OPEN,
true)).click();
+ bot.sleep(sleepTime);
+ // Rename file
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.RENAME,
true)).click();
+ bot.sleep(sleepTime);
+ bot.shell(IDELabel.Shell.RENAME_RESOURCE).activate();
+ bot.textWithLabel(IDELabel.RenameResourceDialog.NEW_NAME)
+ .setText(newFileName);
+ bot.button(IDELabel.Button.OK).click();
+ bot.sleep(sleepTime);
+ new SWTUtilExt(bot).waitForJobs(JobName.UPDATING_INDEXES);
+ // Check Results
+ // File with Old Name doesn't exists within WebProjects View
+ try{
+ parentTreeItem.getNode(oldFileName + fileTreeItemSuffix);
+ return "File " + oldFileName + " was not renamed to " +
newFileName + ".";
+ }catch (WidgetNotFoundException wnfe) {
+ // do nothing
+ }
+ // File with New Name exists within WebProjects View
+ try{
+ parentTreeItem.getNode(newFileName + fileTreeItemSuffix);
+ }catch (WidgetNotFoundException wnfe) {
+ return "Renamed File " + newFileName + " was not found.";
+ }
+ // Editor Title was renamed
+ try{
+ bot.editorByTitle(newFileName);
+ }catch (WidgetNotFoundException wnfe) {
+ return "Editor Title was not changed to " + newFileName + " after
renaming.";
+ }
+ }
+ else{
+ return "Unable to find file for renaming.";
+ }
+
+ return null;
+
+ }
+ /**
+ * Check File Renaming
+ * @param bot
+ * @param oldFileName
+ * @param newFileName
+ * @param treePathItems
+ * @return
+ */
+ public static String checkFileRenamingWithinWebProjects(SWTWorkbenchBot bot , String
oldFileName, String newFileName,
+ String[] treePathItems){
+ return checkFileRenamingWithinWebProjects(bot, oldFileName, newFileName,
treePathItems, "");
+ }
+}
Deleted:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/CheckRenaming.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/CheckRenaming.java 2010-01-18
18:27:34 UTC (rev 19794)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/CheckRenaming.java 2010-01-18
19:26:19 UTC (rev 19795)
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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.vpe.ui.bot.test.smoke;
-
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
-import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.jboss.tools.ui.bot.test.SWTJBTBot;
-import org.jboss.tools.ui.bot.test.WidgetVariables;
-
-/**
- * Check Renaming Functionality within WebProjects View
- * Tests if file war properly renamed in WebProjects View
- * and Title of file in Editor was renamed also.
- * @author Vladimir Pakan
- *
- */
-public class CheckRenaming {
- private static final int sleepTime = 1000;
- /**
- * Check File Renaming
- * @param bot
- * @param oldFileName
- * @param newFileName
- * @param treePathItems
- * @return
- */
- public static String checkRenameJSPFile(SWTJBTBot bot , String oldFileName, String
newFileName, String... treePathItems){
-
- bot.sleep(sleepTime);
- SWTBot webProjects = bot.viewByTitle(WidgetVariables.WEB_PROJECTS).bot();
- SWTBotTree tree = webProjects.tree();
-
- tree.setFocus();
-
- if (treePathItems != null && treePathItems.length > 0){
- SWTBotTreeItem parentTreeItem = tree.getTreeItem(treePathItems[0]);
- parentTreeItem.expand();
- int index = 1;
- while (treePathItems.length > index){
- parentTreeItem = parentTreeItem.getNode(treePathItems[index]);
- parentTreeItem.expand();
- index++;
- }
- // Open File
- ContextMenuHelper.prepareTreeItemForContextMenu(tree ,
parentTreeItem.getNode(oldFileName));
- new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.OPEN,
true)).click();
- bot.sleep(sleepTime);
- // Rename file
- new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.RENAME,
true)).click();
- bot.sleep(sleepTime);
- bot.shell(IDELabel.Shell.RENAME_RESOURCE).activate();
- bot.textWithLabel(IDELabel.RenameResourceDialog.NEW_NAME)
- .setText(newFileName);
- bot.button(IDELabel.Button.OK).click();
- bot.sleep(sleepTime);
- // Check Results
- // File with Old Name doesn't exists within WebProjects View
- try{
- parentTreeItem.getNode(oldFileName);
- return "File " + oldFileName + " was not renamed to " +
newFileName + ".";
- }catch (WidgetNotFoundException wnfe) {
- // do nothing
- }
- // File with New Name exists within WebProjects View
- try{
- parentTreeItem.getNode(newFileName);
- }catch (WidgetNotFoundException wnfe) {
- return "Renamed File " + newFileName + " was not found.";
- }
- // Editor Title was renamed
- try{
- bot.editorByTitle(newFileName);
- }catch (WidgetNotFoundException wnfe) {
- return "Editor Title was not changed to " + newFileName + " after
renaming.";
- }
- }
- else{
- return "Unable to find file for renaming.";
- }
-
- return null;
-
- }
-
-}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/RenameFacesConfigFileTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/RenameFacesConfigFileTest.java 2010-01-18
18:27:34 UTC (rev 19794)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/RenameFacesConfigFileTest.java 2010-01-18
19:26:19 UTC (rev 19795)
@@ -15,6 +15,7 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.helper.FileRenameHelper;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.test.WidgetVariables;
@@ -49,8 +50,8 @@
SWTBotTree tree = webProjects.tree();
tree.setFocus();
- String checkResult = CheckRenaming.checkRenameJSPFile(bot,
OLD_FACES_CONFIG_FILE_NAME, NEW_FACES_CONFIG_FILE_NAME,
- JBT_TEST_PROJECT_NAME,IDELabel.WebProjectsTree.CONFIGURATION);
+ String checkResult = FileRenameHelper.checkFileRenamingWithinWebProjects(bot,
OLD_FACES_CONFIG_FILE_NAME, NEW_FACES_CONFIG_FILE_NAME,
+ new String[]{JBT_TEST_PROJECT_NAME,IDELabel.WebProjectsTree.CONFIGURATION});
assertNull(checkResult,checkResult);
// web.xml file was properly modified
SWTBotTreeItem configFilesTreeItem = tree
@@ -68,7 +69,7 @@
SWTBotTable propertiesTable = bot.table();
String fullConfigFileName =
propertiesTable.cell(propertiesTable.indexOf(IDELabel.PropertiesDialog.PARAM_VALUE, 0),
1);
bot.button(IDELabel.Button.CLOSE).click();
- assertTrue(NEW_FACES_CONFIG_FILE_NAME + "Name of "
+ assertTrue(NEW_FACES_CONFIG_FILE_NAME + " Name of "
+ OLD_FACES_CONFIG_FILE_NAME
+ " file was not changed in web.xml file.",
fullConfigFileName.endsWith(NEW_FACES_CONFIG_FILE_NAME));
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/RenameJSPFileTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/RenameJSPFileTest.java 2010-01-18
18:27:34 UTC (rev 19794)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/RenameJSPFileTest.java 2010-01-18
19:26:19 UTC (rev 19795)
@@ -12,6 +12,7 @@
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.jboss.tools.ui.bot.ext.helper.FileRenameHelper;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.test.WidgetVariables;
import org.jboss.tools.vpe.ui.bot.test.editor.VPEEditorTestCase;
@@ -43,9 +44,9 @@
SWTBotTree tree = webProjects.tree();
tree.setFocus();
- String checkResult = CheckRenaming.checkRenameJSPFile(bot,
+ String checkResult = FileRenameHelper.checkFileRenamingWithinWebProjects(bot,
JSPPageCreationTest.TEST_NEW_JSP_FILE_NAME, NEW_JSP_FILE_NAME,
- JBT_TEST_PROJECT_NAME, IDELabel.WebProjectsTree.WEB_CONTENT);
+ new String[] {JBT_TEST_PROJECT_NAME, IDELabel.WebProjectsTree.WEB_CONTENT});
assertNull(checkResult, checkResult);
}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/RenameXHTMLFileTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/RenameXHTMLFileTest.java 2010-01-18
18:27:34 UTC (rev 19794)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/RenameXHTMLFileTest.java 2010-01-18
19:26:19 UTC (rev 19795)
@@ -12,6 +12,7 @@
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.jboss.tools.ui.bot.ext.helper.FileRenameHelper;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.test.WidgetVariables;
import org.jboss.tools.vpe.ui.bot.test.editor.VPEEditorTestCase;
@@ -48,9 +49,9 @@
SWTBotTree tree = webProjects.tree();
tree.setFocus();
- String checkResult = CheckRenaming.checkRenameJSPFile(bot,
+ String checkResult = FileRenameHelper.checkFileRenamingWithinWebProjects(bot,
XHTMLPageCreationTest.TEST_NEW_XHTML_FILE_NAME, NEW_XHTML_FILE_NAME,
- JBT_TEST_PROJECT_NAME, IDELabel.WebProjectsTree.WEB_CONTENT);
+ new String[] {JBT_TEST_PROJECT_NAME, IDELabel.WebProjectsTree.CONFIGURATION});
assertNull(checkResult, checkResult);
}