Author: yradtsevich
Date: 2010-02-18 11:10:47 -0500 (Thu, 18 Feb 2010)
New Revision: 20362
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5872/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5872/JBIDE-5872.html
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/EditFontFamilyTest_JBIDE5872.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/FontNameFormatController.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5872
VPE throws java.lang.NullPointerException, while editing font-family
- fixed
- JUnit created
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5872/JBIDE-5872.html
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5872/JBIDE-5872.html
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/5872/JBIDE-5872.html 2010-02-18
16:10:47 UTC (rev 20362)
@@ -0,0 +1,5 @@
+<html>
+<body>
+ <button style='FONT-FAMILY: "serif"'>bla bla</button>
+</body>
+</html>
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2010-02-18
15:38:34 UTC (rev 20361)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2010-02-18
16:10:47 UTC (rev 20362)
@@ -18,6 +18,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.ChangeMessageBundleTest_JBIDE5818;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.ContextMenuDoubleInsertionTest_JBIDE3888;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.EditFontFamilyTest_JBIDE5872;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.FacetProcessingTest;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE1105Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE1460Test;
@@ -122,6 +123,7 @@
TestSuite suite = new TestSuite("Tests for Vpe Jsf components");
//$NON-NLS-1$
// $JUnit-BEGIN$
+ suite.addTestSuite(EditFontFamilyTest_JBIDE5872.class);
suite.addTestSuite(ChangeMessageBundleTest_JBIDE5818.class);
suite.addTestSuite(TestForUsingComponentsLibrariesWithDefaultNamespace.class);
suite.addTestSuite(EditingSPecialSymbolsVPE_JBIDE3810.class);
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/EditFontFamilyTest_JBIDE5872.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/EditFontFamilyTest_JBIDE5872.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/EditFontFamilyTest_JBIDE5872.java 2010-02-18
16:10:47 UTC (rev 20362)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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.jsf.vpe.jsf.test.jbide;
+
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+
+/**
+ * Test for JBIDE-5872: VPE throws java.lang.NullPointerException,
+ * while editing font-family.
+ *
+ * @see <a
href="https://jira.jboss.org/jira/browse/JBIDE-5872">JBIDE-5...
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class EditFontFamilyTest_JBIDE5872 extends VpeTest {
+ private static final Point EDIT_POSITION = new Point(3, 40);
+ private static final int SELECTION_LENGTH = 1;
+ private static final String TEST_PAGE_NAME = "JBIDE/5872/JBIDE-5872.html";
+
+ public EditFontFamilyTest_JBIDE5872(String name) {
+ super(name);
+ }
+
+ /**
+ * Deletes quote after style attribute. This may lead to NPE.
+ *
+ * @see <a
href="https://jira.jboss.org/jira/browse/JBIDE-5872">JBIDE-5...
+ */
+ public void testEditFontFamily() throws Throwable {
+ TestUtil.waitForJobs();
+ setException(null);
+
+ VpeController vpeController
+ = openInVpe(JsfAllTests.IMPORT_PROJECT_NAME, TEST_PAGE_NAME);
+ StructuredTextEditor sourceEditor = vpeController.getSourceEditor();
+ TextViewer textViewer = sourceEditor.getTextViewer();
+ StyledText textWidget = textViewer.getTextWidget();
+
+ int offset = getCaretOffset(textViewer, EDIT_POSITION);
+ textWidget.setSelectionRange(offset, SELECTION_LENGTH);
+ textWidget.insert("");
+ TestUtil.waitForIdle();
+
+ ISelectionProvider selectionProvider = sourceEditor.getSelectionProvider();
+ vpeController.selectionChanged(new SelectionChangedEvent(
+ selectionProvider, selectionProvider.getSelection()));
+
+ if(getException() != null) {
+ throw new Exception(getException());
+ }
+ }
+
+ private static int getCaretOffset(TextViewer textViewer, Point position) {
+ return TestUtil.getLinePositionOffcet(textViewer, position.x, position.y);
+ }
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/FontNameFormatController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/FontNameFormatController.java 2010-02-18
15:38:34 UTC (rev 20361)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/FontNameFormatController.java 2010-02-18
16:10:47 UTC (rev 20362)
@@ -14,6 +14,7 @@
import org.jboss.tools.vpe.editor.template.textformating.FormatAttributeData;
import org.jboss.tools.vpe.editor.toolbar.format.css.StyleAttribute;
import org.jboss.tools.vpe.editor.toolbar.format.css.StyleProperty;
+import org.jboss.tools.vpe.editor.toolbar.format.css.Token;
import org.w3c.dom.Attr;
/**
@@ -80,33 +81,34 @@
* enabled)
*/
public void setToolbarItemEnabled(boolean enabled) {
- comboBlockFormat.setEnabled(enabled);
- if (enabled) {
- Attr style = getStyleAttributeFromSelectedNode(true);
- if (style != null) {
- StyleAttribute styleAttribute = new StyleAttribute(style);
- StyleProperty fontProperty = styleAttribute
- .getProperty(STYLE_PROPERTY_NAME);
- if (fontProperty != null) {
- String fontName = fontProperty.getPropertyValue()
- .getDirtyValue().trim();
- if (fontName != null) {
- fontName = fontName.replaceAll(REPLACE_VALUE, EMPTY);
- if (getComboBlockFormat().getText().equalsIgnoreCase(
- fontName)) {
- return;
- }
- String[] items = this.getComboBlockFormat().getItems();
- for (int i = 0; i < items.length; i++) {
- if (items[i].equalsIgnoreCase(fontName)) {
- this.getComboBlockFormat().select(i);
- return;
- }
- }
+ comboBlockFormat.setEnabled(enabled);
+ if (enabled) {
+ Attr style = getStyleAttributeFromSelectedNode(true);
+ if (style != null) {
+ StyleAttribute styleAttribute = new StyleAttribute(style);
+ StyleProperty fontProperty
+ = styleAttribute.getProperty(STYLE_PROPERTY_NAME);
+ if (fontProperty != null) {
+ Token fontPropertyValue = fontProperty.getPropertyValue();
+ if (fontPropertyValue != null) {
+ String fontName
+ = fontPropertyValue.getDirtyValue().trim();
+ fontName = fontName.replaceAll(REPLACE_VALUE, EMPTY);
+ if (getComboBlockFormat().getText().equalsIgnoreCase(
+ fontName)) {
+ return;
+ }
+ String[] items = this.getComboBlockFormat().getItems();
+ for (int i = 0; i < items.length; i++) {
+ if (items[i].equalsIgnoreCase(fontName)) {
+ this.getComboBlockFormat().select(i);
+ return;
+ }
+ }
+ }
+ }
}
}
- }
- }
- getComboBlockFormat().select(0);
+ getComboBlockFormat().select(0);
}
-}
\ No newline at end of file
+}