[jbosstools-commits] JBoss Tools SVN: r42574 - trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Fri Jul 13 10:59:12 EDT 2012
Author: yradtsevich
Date: 2012-07-13 10:59:11 -0400 (Fri, 13 Jul 2012)
New Revision: 42574
Modified:
trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide/SelectionLosingByPropertySheet_JBIDE4791.java
Log:
https://issues.jboss.org/browse/JBIDE-12258 : SelectionLosingByPropertySheet_JBIDE4791 test failure
- rewrote test
Modified: trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide/SelectionLosingByPropertySheet_JBIDE4791.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide/SelectionLosingByPropertySheet_JBIDE4791.java 2012-07-13 14:33:33 UTC (rev 42573)
+++ trunk/jst/tests/org.jboss.tools.jst.css.test/src/org/jboss/tools/jst/css/test/jbide/SelectionLosingByPropertySheet_JBIDE4791.java 2012-07-13 14:59:11 UTC (rev 42574)
@@ -14,7 +14,11 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.TrayItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.views.properties.PropertySheet;
+import org.eclipse.ui.views.properties.PropertySheetEntry;
import org.eclipse.wst.css.core.internal.document.CSSStructuredDocumentRegionContainer;
import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
@@ -33,6 +37,10 @@
public class SelectionLosingByPropertySheet_JBIDE4791 extends
AbstractCSSViewTest {
+ private static final String FIRST_CSS_PROPERTY_VALUE = "red";
+
+ private static final String FIRST_CSS_PROPERTY_NAME = "color";
+
public static final String TEST_PAGE_NAME = "JBIDE/4791/propertyViewTest.css"; //$NON-NLS-1$
public static final String PROPERTY_SHEET_VIEW_ID = "org.eclipse.ui.views.PropertySheet"; //$NON-NLS-1$
@@ -65,34 +73,39 @@
assertNotNull(document);
CSSRule cssRule = document.getCssRules().item(0);
-
assertNotNull(cssRule);
- int offset = ((CSSStructuredDocumentRegionContainer) cssRule)
- .getStartOffset();
-
- setSelection(editor, offset, 0);
-
- ISelection selection = (ISelection) getFieldValue(propertySheet,
- SELECTION_FIELD_NAME);
-
- assertTrue(selection instanceof IStructuredSelection);
-
- assertEquals(cssRule, ((IStructuredSelection) selection)
- .getFirstElement());
-
+ int cssRuleOffset = ((CSSStructuredDocumentRegionContainer) cssRule).getStartOffset();
+ setSelection(editor, cssRuleOffset, 0);
+
+ Tree propertySheetTree = (Tree) propertySheet.getCurrentPage().getControl();
+ String colorValue = getPropertyValue(propertySheetTree.getItems(), FIRST_CSS_PROPERTY_NAME);
+ assertEquals(FIRST_CSS_PROPERTY_VALUE, colorValue);
+
CSSEditorView view = (CSSEditorView) openView(CSS_EDITOR_VIEW);
-
JobUtils.delay(1000);
- selection = (ISelection) getFieldValue(propertySheet,
- SELECTION_FIELD_NAME);
-
- assertTrue(selection instanceof IStructuredSelection);
-
- assertEquals(cssRule, ((IStructuredSelection) selection)
- .getFirstElement());
-
+ propertySheetTree = (Tree) propertySheet.getCurrentPage().getControl();
+ colorValue = getPropertyValue(propertySheetTree.getItems(), FIRST_CSS_PROPERTY_NAME);
+ assertEquals(FIRST_CSS_PROPERTY_VALUE, colorValue);
}
+
+ private String getPropertyValue(TreeItem[] treeItems, String propertyName) {
+ for (TreeItem treeItem : treeItems) {
+ Object data = treeItem.getData();
+ if (data instanceof PropertySheetEntry) {
+ PropertySheetEntry propertySheetEntry = (PropertySheetEntry) data;
+ if (propertyName.equals(propertySheetEntry.getDisplayName())) {
+ return propertySheetEntry.getValueAsString();
+ }
+ }
+ String descendantsValue = getPropertyValue(treeItem.getItems(), propertyName);
+ if (descendantsValue != null) {
+ return descendantsValue;
+ }
+ }
+
+ return null;
+ }
}
More information about the jbosstools-commits
mailing list