Author: vpakan(a)redhat.com
Date: 2010-11-16 03:06:14 -0500 (Tue, 16 Nov 2010)
New Revision: 26604
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/EditingELValueTest.java
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/VPEAutoTestCase.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.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 Editing EL Value Test.
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
08:06:10 UTC (rev 26603)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-11-16
08:06:14 UTC (rev 26604)
@@ -15,6 +15,7 @@
import org.jboss.tools.vpe.ui.bot.test.editor.VisualEditorContextMenuTest;
import org.jboss.tools.vpe.ui.bot.test.editor.XhtmlFilePerformanceTest;
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.SubstitutedELExressionsTest;
import org.jboss.tools.vpe.ui.bot.test.editor.pagedesign.ToolbarTextFormattingTest;
@@ -80,6 +81,7 @@
suite.addTestSuite(IncludedTagLibsTest.class);
suite.addTestSuite(SubstitutedELExressionsTest.class);
suite.addTestSuite(MinMaxPanesTest.class);
+ suite.addTestSuite(EditingELValueTest.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
08:06:10 UTC (rev 26603)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java 2010-11-16
08:06:14 UTC (rev 26604)
@@ -419,17 +419,28 @@
* @param pageName
*/
protected void openPage(String pageName){
+ openPage(pageName,VPEAutoTestCase.JBT_TEST_PROJECT_NAME);
+ }
+ /**
+ * Opens page pageName from projectName
+ * @param pageName
+ * @param projectName
+ */
+ protected void openPage(String pageName , String projectName){
SWTBot innerBot = bot.viewByTitle(WidgetVariables.PACKAGE_EXPLORER).bot();
SWTBotTree tree = innerBot.tree();
- tree.expandNode(JBT_TEST_PROJECT_NAME)
-
.expandNode("WebContent").expandNode("pages").getNode(pageName).doubleClick();
//$NON-NLS-1$ //$NON-NLS-2$
+ tree.expandNode(projectName)
+ .expandNode("WebContent")
+ .expandNode("pages")
+ .getNode(pageName)
+ .doubleClick(); //$NON-NLS-1$ //$NON-NLS-2$
bot.sleep(Timing.time3S());
}
/**
* Opens Test Page
*/
protected void openPage(){
- openPage(TEST_PAGE);
+ openPage(VPEAutoTestCase.TEST_PAGE,VPEAutoTestCase.JBT_TEST_PROJECT_NAME);
}
/**
* Creates new empty JSP page within test project
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java 2010-11-16
08:06:10 UTC (rev 26603)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java 2010-11-16
08:06:14 UTC (rev 26604)
@@ -196,4 +196,23 @@
}
+ /**
+ * Asserts if Visual Editor doesn't contain node with particular attributes
+ * @param webBrowser
+ * @param valueToContain
+ * @param fileName
+ */
+ protected static void assertVisualEditorNotContainNodeWithValue (SWTBotWebBrowser
webBrowser,
+ String valueToContain,
+ String fileName){
+
+ assertFalse("Visual Representation of file " + fileName
+ + " cannot contain node with "
+ + valueToContain
+ + " value but it does",
+ webBrowser.containsNodeWithValue(webBrowser.getMozillaEditor().getDomDocument(),
+ valueToContain));
+
+ }
+
}
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/EditingELValueTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/EditingELValueTest.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/pagedesign/EditingELValueTest.java 2010-11-16
08:06:14 UTC (rev 26604)
@@ -0,0 +1,146 @@
+/*******************************************************************************
+
+ * 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.eclipse.swtbot.swt.finder.SWTBot;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+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.VPEAutoTestCase;
+import org.jboss.tools.vpe.ui.bot.test.tools.SWTBotWebBrowser;
+/**
+ * Tests editing of EL value
+ * @author vlado pakan
+ *
+ */
+public class EditingELValueTest extends PageDesignTestCase {
+
+ private SWTBotExt botExt = null;
+ private static final String GREETING_PAGE_NAME = "greeting.xhtml";
+ private static final String INPUT_NAME_PAGE_NAME = "inputname.xhtml";
+ private static final String EL_VARIABLE_NAME = "request.contextPath";
+ private SWTBotEclipseEditor jspGreetingPageEditor;
+ private SWTBotEclipseEditor jspInputNamePageEditor;
+ private String greetingPageOrigText;
+ private String inputNamePageOrigText;
+
+ public EditingELValueTest() {
+ super();
+ botExt = new SWTBotExt();
+ }
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ eclipse.maximizeActiveShell();
+ }
+ /**
+ * Tests editing of EL value
+ */
+ public void testEditingELValue(){
+
openPage(EditingELValueTest.GREETING_PAGE_NAME,VPEAutoTestCase.FACELETS_TEST_PROJECT_NAME);
+
openPage(EditingELValueTest.INPUT_NAME_PAGE_NAME,VPEAutoTestCase.FACELETS_TEST_PROJECT_NAME);
+ jspGreetingPageEditor =
botExt.editorByTitle(EditingELValueTest.GREETING_PAGE_NAME).toTextEditor();
+ greetingPageOrigText = jspGreetingPageEditor.getText();
+ jspInputNamePageEditor =
botExt.editorByTitle(EditingELValueTest.INPUT_NAME_PAGE_NAME).toTextEditor();
+ inputNamePageOrigText = jspGreetingPageEditor.getText();
+ jspGreetingPageEditor.setText(jspGreetingPageEditor.getText()
+ .replaceFirst("/templates/common.xhtml", "#{" +
EditingELValueTest.EL_VARIABLE_NAME + "}templates/common.xhtml"));
+ jspGreetingPageEditor.save();
+ bot.sleep(Timing.time2S());
+ assertVisualEditorContainsNodeWithValue(new
SWTBotWebBrowser(EditingELValueTest.GREETING_PAGE_NAME,botExt),
+ " Template file is not found: \"#{" +
EditingELValueTest.EL_VARIABLE_NAME + "}templates/common.xhtml\"",
+ EditingELValueTest.GREETING_PAGE_NAME);
+ jspInputNamePageEditor.setText(jspInputNamePageEditor.getText()
+ .replaceFirst("/templates/common.xhtml", "#{" +
EditingELValueTest.EL_VARIABLE_NAME + "}templates/common.xhtml"));
+ jspInputNamePageEditor.save();
+ bot.sleep(Timing.time2S());
+ assertVisualEditorContainsNodeWithValue(new
SWTBotWebBrowser(EditingELValueTest.INPUT_NAME_PAGE_NAME,botExt),
+ " Template file is not found: \"#{" +
EditingELValueTest.EL_VARIABLE_NAME + "}templates/common.xhtml\"",
+ EditingELValueTest.INPUT_NAME_PAGE_NAME);
+ // Opens Page Design Options Dialog
+ 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_VALUE)
+ .setText("/");
+
addELReferenceDialogBot.textWithLabel(IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_EL_NAME)
+ .setText(EditingELValueTest.EL_VARIABLE_NAME);
+ addELReferenceDialogBot.button(IDELabel.Button.FINISH).click();
+ optionsDialogBot.button(IDELabel.Button.OK).click();
+ jspGreetingPageEditor.close();
+ jspInputNamePageEditor.close();
+
openPage(EditingELValueTest.GREETING_PAGE_NAME,VPEAutoTestCase.FACELETS_TEST_PROJECT_NAME);
+
openPage(EditingELValueTest.INPUT_NAME_PAGE_NAME,VPEAutoTestCase.FACELETS_TEST_PROJECT_NAME);
+ // Checks Visual Representation of Pages
+ SWTBotWebBrowser webBrowserGreetingPage = new
SWTBotWebBrowser(EditingELValueTest.GREETING_PAGE_NAME,botExt);
+ assertVisualEditorNotContainNodeWithValue(webBrowserGreetingPage,
+ " Template file is not found: \"#{" +
EditingELValueTest.EL_VARIABLE_NAME + "}templates/common.xhtml\"",
+ EditingELValueTest.GREETING_PAGE_NAME);
+ SWTBotWebBrowser webBrowserInputNamePage = new
SWTBotWebBrowser(EditingELValueTest.INPUT_NAME_PAGE_NAME,botExt);
+ assertVisualEditorNotContainNodeWithValue(webBrowserInputNamePage,
+ " Template file is not found: \"#{" +
EditingELValueTest.EL_VARIABLE_NAME + "}templates/common.xhtml\"",
+ EditingELValueTest.INPUT_NAME_PAGE_NAME);
+ // Delete EL Variable from Pages
+ jspGreetingPageEditor =
botExt.editorByTitle(EditingELValueTest.GREETING_PAGE_NAME).toTextEditor();
+ jspGreetingPageEditor.setText(jspGreetingPageEditor.getText()
+ .replaceFirst("\\#\\{" + EditingELValueTest.EL_VARIABLE_NAME +
"\\}", "/"));
+ jspGreetingPageEditor.save();
+ bot.sleep(Timing.time2S());
+ assertVisualEditorNotContainNodeWithValue(webBrowserGreetingPage,
+ " Template file is not found: \"#{" +
EditingELValueTest.EL_VARIABLE_NAME + "}templates/common.xhtml\"",
+ EditingELValueTest.GREETING_PAGE_NAME);
+ jspInputNamePageEditor =
botExt.editorByTitle(EditingELValueTest.INPUT_NAME_PAGE_NAME).toTextEditor();
+ jspInputNamePageEditor.setText(jspInputNamePageEditor.getText()
+ .replaceFirst("\\#\\{" + EditingELValueTest.EL_VARIABLE_NAME +
"\\}", "/"));
+ jspInputNamePageEditor.save();
+ bot.sleep(Timing.time2S());
+ assertVisualEditorNotContainNodeWithValue(webBrowserInputNamePage,
+ " Template file is not found: \"#{" +
EditingELValueTest.EL_VARIABLE_NAME + "}templates/common.xhtml\"",
+ EditingELValueTest.INPUT_NAME_PAGE_NAME);
+ bot.toolbarButtonWithTooltip(PAGE_DESIGN).click();
+ optionsDialogBot = bot.shell(IDELabel.Shell.PAGE_DESIGN_OPTIONS).activate().bot();
+
optionsDialogBot.tabItem(IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_TAB).activate();
+ assertTrue ("EL Substitution for EL Name " +
EditingELValueTest.EL_VARIABLE_NAME + " is not defined.",
+ SWTEclipseExt.isItemInTableColumn(optionsDialogBot.table(),
EditingELValueTest.EL_VARIABLE_NAME, 0));
+ optionsDialogBot.button(IDELabel.Button.OK).click();
+ }
+
+ @Override
+ protected void closeUnuseDialogs() {
+
+ }
+
+ @Override
+ protected boolean isUnuseDialogOpened() {
+ return false;
+ }
+ @Override
+ protected void tearDown() throws Exception {
+
+ if (jspGreetingPageEditor != null){
+ jspGreetingPageEditor.setText(greetingPageOrigText);
+ jspGreetingPageEditor.saveAndClose();
+ }
+ if (jspInputNamePageEditor != null){
+ jspInputNamePageEditor.setText(inputNamePageOrigText);
+ jspInputNamePageEditor.saveAndClose();
+ }
+
+ deleteAllELSubstitutions();
+
+ 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/EditingELValueTest.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
08:06:10 UTC (rev 26603)
+++
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
08:06:14 UTC (rev 26604)
@@ -5,11 +5,14 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
+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.types.IDELabel;
import org.jboss.tools.vpe.ui.bot.test.Activator;
-import org.jboss.tools.vpe.ui.bot.test.VPEAutoTestCase;
+import org.jboss.tools.vpe.ui.bot.test.editor.VPEEditorTestCase;
-public abstract class PageDesignTestCase extends VPEAutoTestCase{
+public abstract class PageDesignTestCase extends VPEEditorTestCase{
final static String PAGE_DESIGN = "Page Design Options"; //$NON-NLS-1$
@@ -45,5 +48,17 @@
}
return filePath;
}
-
+ /**
+ * Deletes all defined EL Substitutions. VPE has to be opened when called this method
+ */
+ public void deleteAllELSubstitutions(){
+ SWTBot optionsDialogBot =
bot.shell(IDELabel.Shell.PAGE_DESIGN_OPTIONS).activate().bot();
+
optionsDialogBot.tabItem(IDELabel.PageDesignOptionsDialog.SUBSTITUTED_EL_EXPRESSIONS_TAB).activate();
+ SWTBotTable elVariablesTable = optionsDialogBot.table();
+ while (elVariablesTable.rowCount() > 0){
+ elVariablesTable.select(0);
+ optionsDialogBot.button(IDELabel.Button.REMOVE).click();
+ }
+ optionsDialogBot.button(IDELabel.Button.OK).click();
+ }
}