Author: vpakan(a)redhat.com
Date: 2010-03-18 07:35:56 -0400 (Thu, 18 Mar 2010)
New Revision: 20904
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/CompareUtils.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/templates/SetTemplateForUnknownTagTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/TestDomUtil.java
Log:
Added CompareUtils.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/templates/SetTemplateForUnknownTagTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/templates/SetTemplateForUnknownTagTest.java 2010-03-18
11:32:31 UTC (rev 20903)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/templates/SetTemplateForUnknownTagTest.java 2010-03-18
11:35:56 UTC (rev 20904)
@@ -5,6 +5,7 @@
import org.jboss.tools.jsf.ui.bot.test.CSSStyleDialogVariables;
import org.jboss.tools.jsf.ui.bot.test.JSFAutoTestCase;
import org.jboss.tools.jsf.ui.bot.test.UnknownTagDialogVariables;
+import org.jboss.tools.ui.bot.ext.CompareUtils;
import org.jboss.tools.ui.bot.test.WidgetVariables;
public class SetTemplateForUnknownTagTest extends JSFAutoTestCase {
@@ -40,10 +41,13 @@
bot.textWithLabel(UnknownTagDialogVariables.TAG_STYLE_FIELD).setText("color:red");//$NON-NLS-1$
bot.buttonWithTooltip(UnknownTagDialogVariables.EDIT_TAG_STYLE_TIP).click();
String returnValue = setStyles();
- assertEquals("font-family:Arial;color:black;", returnValue);//$NON-NLS-1$
- bot.button(WidgetVariables.OK_BUTTON).click();
- bot.shell(WidgetVariables.PREF_FILTER_SHELL_TITLE).activate();
- bot.button(WidgetVariables.OK_BUTTON).click();
+ bot.button(WidgetVariables.OK_BUTTON).click();
+ bot.shell(WidgetVariables.PREF_FILTER_SHELL_TITLE).activate();
+ bot.button(WidgetVariables.OK_BUTTON).click();
+ assertTrue("Atttributes are not as expexted:\n"
+ + "Expected: " + "font-family:Arial;color:black;"
+ + "Value: " + returnValue
+ ,CompareUtils.compareStyleAttributes("font-family:Arial;color:black;",
returnValue));//$NON-NLS-1$
checkVPE("templates/SetTemplateForUnknownTag.xml");//$NON-NLS-1$
}
@@ -52,16 +56,22 @@
bot.shell(WidgetVariables.PREF_FILTER_SHELL_TITLE).activate();
bot.tabItem(WidgetVariables.VPE_TEMPLATES_TAB).activate();
bot.table().select(0);
- checkTable(bot.table());
- bot.button(WidgetVariables.EDIT_BUTTON).click();
- bot.shell(UnknownTagDialogVariables.DIALOG_TITLE).activate();
- bot.textWithLabel(UnknownTagDialogVariables.TAG_URI_FIELD).setText("");
//$NON-NLS-1$
- bot.checkBoxWithLabel(UnknownTagDialogVariables.ALLOW_CHILDREN_CHECKBOX).click();
- bot.textWithLabel(UnknownTagDialogVariables.VALUE_FIELD).setText("");
//$NON-NLS-1$
- bot.textWithLabel(UnknownTagDialogVariables.TAG_STYLE_FIELD).setText("");
//$NON-NLS-1$
- bot.button(WidgetVariables.OK_BUTTON).click();
- bot.shell(WidgetVariables.PREF_FILTER_SHELL_TITLE).activate();
- bot.button(WidgetVariables.OK_BUTTON).click();
+ try {
+ checkTable(bot.table());
+ bot.button(WidgetVariables.EDIT_BUTTON).click();
+ bot.shell(UnknownTagDialogVariables.DIALOG_TITLE).activate();
+ bot.textWithLabel(UnknownTagDialogVariables.TAG_URI_FIELD).setText("");
//$NON-NLS-1$
+ bot.checkBoxWithLabel(UnknownTagDialogVariables.ALLOW_CHILDREN_CHECKBOX)
+ .click();
+ bot.textWithLabel(UnknownTagDialogVariables.VALUE_FIELD).setText("");
//$NON-NLS-1$
+ bot.textWithLabel(UnknownTagDialogVariables.TAG_STYLE_FIELD).setText("");
//$NON-NLS-1$
+ bot.button(WidgetVariables.OK_BUTTON).click();
+ } catch (Throwable t) {
+ throw t;
+ } finally {
+ bot.shell(WidgetVariables.PREF_FILTER_SHELL_TITLE).activate();
+ bot.button(WidgetVariables.OK_BUTTON).click();
+ }
checkVPE("templates/EditedTemplateForUnknownTag.xml"); //$NON-NLS-1$
}
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/CompareUtils.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/CompareUtils.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/CompareUtils.java 2010-03-18
11:35:56 UTC (rev 20904)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * 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;
+/**
+ * Utils for Css Tests
+ * @author Vladimir Pakan
+ */
+public class CompareUtils {
+ /**
+ * Compare style attributes
+ * @param attrs1
+ * @param attrs2
+ * @return
+ */
+ public static boolean compareStyleAttributes(String attrs1 , String attrs2){
+
+ boolean result = false;
+
+ if (attrs1 != null && attrs2 != null){
+ String[] attrs1Split = attrs1.trim().split(";");
+ String[] attrs2Split = attrs2.trim().split(";");
+ if (attrs1Split.length == attrs2Split.length){
+ if(attrs1Split.length > 0){
+ boolean equals = true;
+ for (int index = 0 ; equals && index < attrs1Split.length ;
index++){
+ equals = CompareUtils.compareInAttrsList(attrs1Split[index],attrs2Split);
+ if (equals){
+ equals = CompareUtils.compareInAttrsList(attrs2Split[index],attrs1Split);
+ }
+ }
+ result = equals;
+ }
+ else{
+ result = true;
+ }
+ }
+ else{
+ result = false;
+ }
+ }
+ else{
+ result = (attrs1 == null) && (attrs2 == null);
+ }
+
+ return result;
+
+ }
+ /**
+ * Compare style attribute
+ * @param attr1
+ * @param attr2
+ * @return
+ */
+ private static boolean compareStyleAttribute (String attr1 , String attr2){
+
+ boolean result = false;
+
+ if (attr1 != null && attr2 != null){
+ String[] attr1Split = attr1.trim().split(":");
+ String[] attr2Split = attr2.trim().split(":");
+ if (attr1Split.length == attr2Split.length){
+ if(attr1Split.length > 0){
+ boolean equals = true;
+ for (int index = 0 ; equals && index < attr1Split.length ;
index++){
+ equals = attr1Split[index].trim().equals(attr2Split[index].trim());
+ }
+ result = equals;
+ }
+ else{
+ result = true;
+ }
+ }
+ else{
+ result = false;
+ }
+ }
+ else{
+ result = (attr1 == null) && (attr2 == null);
+ }
+
+ return result;
+
+ }
+ /**
+ * Search for attr in attrsList and compare values
+ * @param attr
+ * @param attrsList
+ * @return
+ */
+ private static boolean compareInAttrsList (String attr , String[] attrsList){
+
+ boolean result = false;
+
+ for (int index = 0 ; !result && index < attrsList.length ; index++){
+ result = CompareUtils.compareStyleAttribute(attr, attrsList[index]);
+ }
+
+ return result;
+
+ }
+
+}
Property changes on:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/CompareUtils.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/TestDomUtil.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/TestDomUtil.java 2010-03-18
11:32:31 UTC (rev 20903)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/TestDomUtil.java 2010-03-18
11:35:56 UTC (rev 20904)
@@ -22,6 +22,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.tools.common.model.util.XMLUtil;
+import org.jboss.tools.ui.bot.ext.CompareUtils;
import org.jboss.tools.vpe.editor.util.Constants;
import org.mozilla.interfaces.nsIDOMAttr;
import org.mozilla.interfaces.nsIDOMNamedNodeMap;
@@ -263,10 +264,18 @@
nsIDOMAttr vpeAttr = (nsIDOMAttr) vpeAttributes.getNamedItem(
name).queryInterface(nsIDOMAttr.NS_IDOMATTR_IID);
+
+ String modelAttribute = modelAttr.getNodeValue().trim();
+ String vpeAttribute = vpeAttr.getNodeValue().trim();
+ try{
+ compareComplexStrings(modelAttribute,vpeAttribute);
+ } catch (ComparisonException ce){
+ // Try to compare as list of parameters
+ if (!CompareUtils.compareStyleAttributes(modelAttribute, vpeAttribute)){
+ throw ce;
+ }
+ }
- compareComplexStrings(modelAttr.getNodeValue().trim(),
- vpeAttr.getNodeValue().trim());
-
}
}
}