Author: vpakan(a)redhat.com
Date: 2010-11-16 09:43:55 -0500 (Tue, 16 Nov 2010)
New Revision: 26619
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/ManipulatingELValueTest.java
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotTableExt.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/VPEAutoTestCase.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/PageDesignTestCase.java
Log:
Added Manipulating EL Value Test
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotTableExt.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotTableExt.java 2010-11-16
14:35:12 UTC (rev 26618)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotTableExt.java 2010-11-16
14:43:55 UTC (rev 26619)
@@ -16,6 +16,7 @@
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem;
import org.jboss.tools.ui.bot.ext.Timing;
/**
@@ -53,5 +54,37 @@
bot.text(oldValue, 0).setText(newValue);
}
+ /**
+ * Returns first Table Item from table which has column values specified by columns
parameter
+ * @param columns
+ * @return
+ */
+ public SWTBotTableItem getTableItem (String... columns){
+
+ SWTBotTableItem result = null;
+
+ int rowIndex = 0;
+ while (result == null && rowIndex < swtBotTable.rowCount()) {
+ int columnIndex = 0;
+ boolean isEqual = true;
+ while (isEqual && columnIndex < columns.length){
+ if (columns[columnIndex] == null ||
+ swtBotTable.cell(rowIndex,
columnIndex).trim().equals(columns[columnIndex].trim())){
+ columnIndex++;
+ }
+ else{
+ isEqual = false;
+ }
+ }
+ if (isEqual) {
+ result = swtBotTable.getTableItem(rowIndex);
+ } else {
+ rowIndex++;
+ }
+ }
+
+ return result;
+
+ }
}
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-11-16
14:35:12 UTC (rev 26618)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-11-16
14:43:55 UTC (rev 26619)
@@ -608,6 +608,12 @@
public static final String SUBSTITUTED_EL_EXPRESSIONS_TAB = "Substituted EL
expressions";
public static final String SUBSTITUTED_EL_EXPRESSIONS_EL_NAME = "El
Name*";
public static final String SUBSTITUTED_EL_EXPRESSIONS_VALUE = "Value";
+
+ public static final String SUBSTITUTED_EL_EXPRESSIONS_SCOPE_PAGE = "Page: Only
This Page";
+ public static final String SUBSTITUTED_EL_EXPRESSIONS_SCOPE_FOLDER = "Folder:
Any Page at the Same Folder";
+ public static final String SUBSTITUTED_EL_EXPRESSIONS_SCOPE_PROJECT = "Project:
Any Page at the Same Project";
+ public static final String SUBSTITUTED_EL_EXPRESSIONS_FOLDER_SCOPE_TABLE_LABEL =
"Folder";
+
}
public static class AddTaglibReferenceDialog{
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-11-16
14:35:12 UTC (rev 26618)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-11-16
14:43:55 UTC (rev 26619)
@@ -17,6 +17,7 @@
import
org.jboss.tools.vpe.ui.bot.test.editor.pagedesign.AddSubstitutedELExpressionFolderScopeTest;
import org.jboss.tools.vpe.ui.bot.test.editor.pagedesign.EditingELValueTest;
import org.jboss.tools.vpe.ui.bot.test.editor.pagedesign.IncludedTagLibsTest;
+import org.jboss.tools.vpe.ui.bot.test.editor.pagedesign.ManipulatingELValueTest;
import org.jboss.tools.vpe.ui.bot.test.editor.pagedesign.SubstitutedELExressionsTest;
import org.jboss.tools.vpe.ui.bot.test.editor.pagedesign.ToolbarTextFormattingTest;
import
org.jboss.tools.vpe.ui.bot.test.editor.preferences.AlwaysHideSelectionBarWithoutPromptTest;
@@ -82,6 +83,7 @@
suite.addTestSuite(SubstitutedELExressionsTest.class);
suite.addTestSuite(MinMaxPanesTest.class);
suite.addTestSuite(EditingELValueTest.class);
+ suite.addTestSuite(ManipulatingELValueTest.class);
return new TestSetup(suite);
}
}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java 2010-11-16
14:35:12 UTC (rev 26618)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java 2010-11-16
14:43:55 UTC (rev 26619)
@@ -3,6 +3,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import org.eclipse.core.runtime.FileLocator;
@@ -445,13 +446,20 @@
/**
* Creates new empty JSP page within test project
* @param pageName
+ * @param subDirs - complete path to page location within workspace
*/
- protected void createJspPage (String pageName){
- SWTBotTreeItem tiPages = packageExplorer.selectTreeItem("pages", new
String[] {VPEAutoTestCase.JBT_TEST_PROJECT_NAME,"WebContent"});
- tiPages.expand();
+ protected void createJspPage (String pageName , String... subDirs){
+ SWTBotTreeItem tiPageParent = null;
+ if (subDirs == null || subDirs.length == 0) {
+ tiPageParent = packageExplorer.selectTreeItem("pages", new String[]
{VPEAutoTestCase.JBT_TEST_PROJECT_NAME,"WebContent"});
+ }
+ else{
+ String[] subPath = Arrays.copyOfRange(subDirs, 0, subDirs.length - 1);
+ tiPageParent = packageExplorer.selectTreeItem(subDirs[subDirs.length - 1],
subPath);
+ }
+ tiPageParent.expand();
try {
- tiPages.getNode(pageName);
- openPage(pageName);
+ tiPageParent.getNode(pageName).doubleClick();
} catch (WidgetNotFoundException e) {
open.newObject(ActionItem.NewObject.WebJSP.LABEL);
bot.shell(IDELabel.Shell.NEW_JSP_FILE).activate();
@@ -459,8 +467,9 @@
bot.button(IDELabel.Button.NEXT).click();
bot.table().select(IDELabel.NewJSPFileDialog.JSP_TEMPLATE);
bot.button(IDELabel.Button.FINISH).click();
- bot.sleep(Timing.time2S());
}
+ bot.sleep(Timing.time2S());
+
}
/**
* Deletes page pageName
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/ManipulatingELValueTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/ManipulatingELValueTest.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/ManipulatingELValueTest.java 2010-11-16
14:43:55 UTC (rev 26619)
@@ -0,0 +1,125 @@
+/*******************************************************************************
+
+ * 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.editor.pagedesign;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.vpe.ui.bot.test.tools.SWTBotWebBrowser;
+/**
+ * Tests manipulating of EL value
+ * @author vlado pakan
+ *
+ */
+public class ManipulatingELValueTest extends PageDesignTestCase {
+
+ private SWTBotExt botExt = null;
+ private static final String TEST_IN_PAGE_FOLDER_PAGE_NAME =
"testInPageFolder.jsp";
+ private static final String TEST_IN_MAIN_FOLDER_PAGE_NAME =
"testInMainFolder.jsp";
+ private static final String EL_VARIABLE_NAME = "test.variable";
+ private static final String EL_IN_PAGE_FOLDER_VARIABLE_VALUE = "EL test value in
Page folder";
+ private static final String EL_IN_MAIN_FOLDER_VARIABLE_VALUE = "EL test value in
main folder";
+ private static final String PAGE_TEXT = "<%@ taglib
uri=\"http://java.sun.com/jsf/html\" prefix=\"h\" %>\n" +
+ "<html>\n" +
+ " <body>\n" +
+ " <h:outputText value = \"#{" +
ManipulatingELValueTest.EL_VARIABLE_NAME + "}\"/>\n" +
+ " </body>\n" +
+ "</html>";
+ private SWTBotEclipseEditor testInPageFolderEditor;
+ private SWTBotEclipseEditor testInMainFolderEditor;
+
+ public ManipulatingELValueTest() {
+ super();
+ botExt = new SWTBotExt();
+ }
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ eclipse.maximizeActiveShell();
+ }
+ /**
+ * Tests manipulating of EL value
+ */
+ public void testManipulatingELValue(){
+ createJspPage(ManipulatingELValueTest.TEST_IN_PAGE_FOLDER_PAGE_NAME);
+ testInPageFolderEditor =
botExt.editorByTitle(ManipulatingELValueTest.TEST_IN_PAGE_FOLDER_PAGE_NAME).toTextEditor();
+ testInPageFolderEditor.setText(ManipulatingELValueTest.PAGE_TEXT);
+ createJspPage(ManipulatingELValueTest.TEST_IN_MAIN_FOLDER_PAGE_NAME ,
JBT_TEST_PROJECT_NAME , "WebContent");
+ testInMainFolderEditor =
botExt.editorByTitle(ManipulatingELValueTest.TEST_IN_MAIN_FOLDER_PAGE_NAME).toTextEditor();
+ testInMainFolderEditor.setText(ManipulatingELValueTest.PAGE_TEXT);
+ testInPageFolderEditor.show();
+ addELSubstitution(ManipulatingELValueTest.EL_VARIABLE_NAME,
ManipulatingELValueTest.EL_IN_PAGE_FOLDER_VARIABLE_VALUE,
+ IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_SCOPE_FOLDER);
+ testInPageFolderEditor.save();
+ bot.sleep(Timing.time2S());
+ SWTBotWebBrowser webBrowserInPageFolder = new
SWTBotWebBrowser(ManipulatingELValueTest.TEST_IN_PAGE_FOLDER_PAGE_NAME, botExt);
+ assertVisualEditorContainsNodeWithValue(webBrowserInPageFolder,
+ ManipulatingELValueTest.EL_IN_PAGE_FOLDER_VARIABLE_VALUE,
+ ManipulatingELValueTest.TEST_IN_PAGE_FOLDER_PAGE_NAME);
+ testInMainFolderEditor.show();
+ addELSubstitution(ManipulatingELValueTest.EL_VARIABLE_NAME,
ManipulatingELValueTest.EL_IN_MAIN_FOLDER_VARIABLE_VALUE,
+ IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_SCOPE_FOLDER);
+ testInMainFolderEditor.save();
+ bot.sleep(Timing.time2S());
+ SWTBotWebBrowser webBrowserInMainFolder = new
SWTBotWebBrowser(ManipulatingELValueTest.TEST_IN_MAIN_FOLDER_PAGE_NAME, botExt);
+ assertVisualEditorContainsNodeWithValue(webBrowserInMainFolder,
+ ManipulatingELValueTest.EL_IN_MAIN_FOLDER_VARIABLE_VALUE,
+ ManipulatingELValueTest.TEST_IN_MAIN_FOLDER_PAGE_NAME);
+ // Edit EL value from Main Folder Page
+ testInMainFolderEditor.show();
+ editELSubstitution(ManipulatingELValueTest.EL_VARIABLE_NAME,
+
IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_FOLDER_SCOPE_TABLE_LABEL,
+ ManipulatingELValueTest.EL_IN_MAIN_FOLDER_VARIABLE_VALUE,
+ IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_SCOPE_PROJECT);
+ assertVisualEditorContainsNodeWithValue(webBrowserInMainFolder,
+ ManipulatingELValueTest.EL_IN_MAIN_FOLDER_VARIABLE_VALUE,
+ ManipulatingELValueTest.TEST_IN_MAIN_FOLDER_PAGE_NAME);
+ testInPageFolderEditor.show();
+ assertVisualEditorContainsNodeWithValue(webBrowserInPageFolder,
+ ManipulatingELValueTest.EL_IN_PAGE_FOLDER_VARIABLE_VALUE,
+ ManipulatingELValueTest.TEST_IN_PAGE_FOLDER_PAGE_NAME);
+ // Delete Folder scoped definition of EL Variable
+ deleteELSubstitution(ManipulatingELValueTest.EL_VARIABLE_NAME,
+
IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_FOLDER_SCOPE_TABLE_LABEL);
+ assertVisualEditorContainsNodeWithValue(webBrowserInMainFolder,
+ ManipulatingELValueTest.EL_IN_MAIN_FOLDER_VARIABLE_VALUE,
+ ManipulatingELValueTest.TEST_IN_MAIN_FOLDER_PAGE_NAME);
+ assertVisualEditorContainsNodeWithValue(webBrowserInPageFolder,
+ ManipulatingELValueTest.EL_IN_MAIN_FOLDER_VARIABLE_VALUE,
+ ManipulatingELValueTest.TEST_IN_PAGE_FOLDER_PAGE_NAME);
+ }
+
+ @Override
+ protected void closeUnuseDialogs() {
+
+ }
+
+ @Override
+ protected boolean isUnuseDialogOpened() {
+ return false;
+ }
+ @Override
+ protected void tearDown() throws Exception {
+
+ deleteAllELSubstitutions();
+
+ if (testInPageFolderEditor != null){
+ testInPageFolderEditor.close();
+ }
+ if (testInMainFolderEditor != null){
+ testInMainFolderEditor.close();
+ }
+
+ super.tearDown();
+ }
+}
Property changes on:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/ManipulatingELValueTest.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/editor/pagedesign/PageDesignTestCase.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/PageDesignTestCase.java 2010-11-16
14:35:12 UTC (rev 26618)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/PageDesignTestCase.java 2010-11-16
14:43:55 UTC (rev 26619)
@@ -8,6 +8,8 @@
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.parts.SWTBotTableExt;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.vpe.ui.bot.test.Activator;
import org.jboss.tools.vpe.ui.bot.test.editor.VPEEditorTestCase;
@@ -52,6 +54,7 @@
* Deletes all defined EL Substitutions. VPE has to be opened when called this method
*/
public void deleteAllELSubstitutions(){
+ bot.toolbarButtonWithTooltip(PAGE_DESIGN).click();
SWTBot optionsDialogBot =
bot.shell(IDELabel.Shell.PAGE_DESIGN_OPTIONS).activate().bot();
optionsDialogBot.tabItem(IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_TAB).activate();
SWTBotTable elVariablesTable = optionsDialogBot.table();
@@ -60,5 +63,63 @@
optionsDialogBot.button(IDELabel.Button.REMOVE).click();
}
optionsDialogBot.button(IDELabel.Button.OK).click();
+ bot.sleep(Timing.time2S());
}
+ /**
+ * Adds EL Definition
+ * @param elName
+ * @param value
+ * @param scope
+ */
+ public void addELSubstitution (String elName , String value , String scope){
+ bot.toolbarButtonWithTooltip(PAGE_DESIGN).click();
+ SWTBot optionsDialogBot =
bot.shell(IDELabel.Shell.PAGE_DESIGN_OPTIONS).activate().bot();
+
optionsDialogBot.tabItem(IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_TAB).activate();
+ optionsDialogBot.button(IDELabel.Button.ADD_WITHOUT_DOTS).click();
+ SWTBot addELReferenceDialogBot =
optionsDialogBot.shell(IDELabel.Shell.ADD_EL_REFERENCE).activate().bot();
+
addELReferenceDialogBot.textWithLabel(IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_EL_NAME)
+ .setText(elName);
+
addELReferenceDialogBot.textWithLabel(IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_VALUE)
+ .setText(value);
+ addELReferenceDialogBot.radio(scope).click();
+ addELReferenceDialogBot.button(IDELabel.Button.FINISH).click();
+ optionsDialogBot.button(IDELabel.Button.OK).click();
+ }
+ /**
+ * Edits EL Variable elName Definition
+ * @param elName
+ * @param oldScope
+ * @param newValue
+ * @param scopeRadioLabel
+ */
+ public void editELSubstitution (String elName , String oldScope, String newValue ,
String scopeRadioLabel){
+ bot.toolbarButtonWithTooltip(PAGE_DESIGN).click();
+ SWTBot optionsDialogBot =
bot.shell(IDELabel.Shell.PAGE_DESIGN_OPTIONS).activate().bot();
+
optionsDialogBot.tabItem(IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_TAB).activate();
+ new SWTBotTableExt(optionsDialogBot.table())
+ .getTableItem(oldScope,elName)
+ .select();
+ optionsDialogBot.button(IDELabel.Button.EDIT_WITHOUT_DOTS).click();
+ SWTBot addELReferenceDialogBot =
optionsDialogBot.shell(IDELabel.Shell.ADD_EL_REFERENCE).activate().bot();
+
addELReferenceDialogBot.textWithLabel(IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_VALUE)
+ .setText(newValue);
+ addELReferenceDialogBot.radio(scopeRadioLabel).click();
+ addELReferenceDialogBot.button(IDELabel.Button.FINISH).click();
+ optionsDialogBot.button(IDELabel.Button.OK).click();
+ }
+ /**
+ * Deletes EL Variable elName Definition
+ * @param elName
+ * @param scope
+ */
+ public void deleteELSubstitution (String elName , String scope){
+ bot.toolbarButtonWithTooltip(PAGE_DESIGN).click();
+ SWTBot optionsDialogBot =
bot.shell(IDELabel.Shell.PAGE_DESIGN_OPTIONS).activate().bot();
+
optionsDialogBot.tabItem(IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_TAB).activate();
+ new SWTBotTableExt(optionsDialogBot.table())
+ .getTableItem(scope,elName)
+ .select();
+ optionsDialogBot.button(IDELabel.Button.REMOVE).click();
+ optionsDialogBot.button(IDELabel.Button.OK).click();
+ }
}