Author: sdzmitrovich
Date: 2009-08-24 12:39:57 -0400 (Mon, 24 Aug 2009)
New Revision: 17243
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4775/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4775/openOn.css
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4775/openOnTestPage.html
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/OpenOnCssClassTest_JBIDE4775.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/OpenOnUtil.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4775
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4775/openOn.css
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4775/openOn.css
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4775/openOn.css 2009-08-24
16:39:57 UTC (rev 17243)
@@ -0,0 +1,3 @@
+.classB {
+ color: blue;
+}
\ No newline at end of file
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4775/openOn.css
___________________________________________________________________
Name: svn:mime-type
+ text/css
Name: svn:eol-style
+ native
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4775/openOnTestPage.html
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4775/openOnTestPage.html
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4775/openOnTestPage.html 2009-08-24
16:39:57 UTC (rev 17243)
@@ -0,0 +1,19 @@
+<html>
+
+<head>
+
+
+<style type="text/css">
+.classA {
+ color: red
+}
+</style>
+<link rel="stylesheet" href="openOn.css" />
+</head>
+
+<body>
+<div class="classA" id="openOn1">Test Page</div>
+<div class="classB" id="openOn2">Test Page</div>
+
+</body>
+</html>
\ No newline at end of file
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4775/openOnTestPage.html
___________________________________________________________________
Name: svn:mime-type
+ text/html
Name: svn:eol-style
+ native
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 2009-08-24
14:49:12 UTC (rev 17242)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-08-24
16:39:57 UTC (rev 17243)
@@ -75,6 +75,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide1718Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide2170Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide2362Test;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.OpenOnCssClassTest_JBIDE4775;
import org.jboss.tools.tests.ImportBean;
import org.jboss.tools.vpe.ui.test.VpeTestSetup;
@@ -159,6 +160,7 @@
suite.addTestSuite(JBIDE4534Test.class);
suite.addTestSuite(JBIDE3247Test.class);
suite.addTestSuite(JBIDE2550Test.class);
+ suite.addTestSuite(OpenOnCssClassTest_JBIDE4775.class);
// $JUnit-END$
// added by Max Areshkau
// add here projects which should be imported for junit tests
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/OpenOnCssClassTest_JBIDE4775.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/OpenOnCssClassTest_JBIDE4775.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/OpenOnCssClassTest_JBIDE4775.java 2009-08-24
16:39:57 UTC (rev 17243)
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * 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.core.resources.IFile;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.ui.test.OpenOnUtil;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.css.CSSStyleRule;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class OpenOnCssClassTest_JBIDE4775 extends VpeTest {
+
+ private static final String TEST_PAGE_NAME = "JBIDE/4775/openOnTestPage.html";
//$NON-NLS-1$
+
+ private static String ON_PAGE_STYLE_TEST_TAG_ID = "openOn1"; //$NON-NLS-1$
+
+ private static String LINK_STYLE_TEST_TAG_ID = "openOn2"; //$NON-NLS-1$
+
+ private static String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
+
+ public OpenOnCssClassTest_JBIDE4775(String name) {
+ super(name);
+ }
+
+ public void testOpenOnStylesOnPage() throws Throwable {
+
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
+
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(TEST_PAGE_NAME,
+ JsfAllTests.IMPORT_PROJECT_NAME);
+
+ assertNotNull("Could not open specified file. componentPage = "
+ + TEST_PAGE_NAME
+ + ";projectName = " + JsfAllTests.IMPORT_PROJECT_NAME, file);//$NON-NLS-1$
+
+ IEditorInput input = new FileEditorInput(file);
+
+ assertNotNull("Editor input is null", input);
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ // get controller
+ VpeController controller = TestUtil.getVpeController(part);
+ assertNotNull(controller);
+
+ // get source document
+ Document sourceDocument = getSourceDocument(controller);
+ assertNotNull(sourceDocument);
+
+ Element openOnTestedElement = sourceDocument
+ .getElementById(ON_PAGE_STYLE_TEST_TAG_ID);
+ Attr testedClassAttr = openOnTestedElement
+ .getAttributeNode(CLASS_ATTRIBUTE);
+
+ OpenOnUtil.performOpenOnAction(part.getSourceEditor(),
+ ((IDOMAttr) testedClassAttr).getValueRegionStartOffset() + 1);
+
+ IStructuredSelection selection = (IStructuredSelection) PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .getSelection();
+
+ TestUtil.waitForJobs();
+
+ Node cssClassNode = (Node) selection.getFirstElement();
+
+ assertEquals(cssClassNode.getParentNode().getLocalName().toLowerCase(),
+ HTML.TAG_STYLE.toLowerCase());
+
+ assertTrue(cssClassNode.getNodeValue().contains(
+ testedClassAttr.getValue()));
+
+ // check exception
+ if (getException() != null) {
+ throw getException();
+ }
+
+ }
+
+ public void testOpenOnLinkStyles() throws Throwable {
+
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
+
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(TEST_PAGE_NAME,
+ JsfAllTests.IMPORT_PROJECT_NAME);
+
+ assertNotNull("Could not open specified file. componentPage = "
+ + TEST_PAGE_NAME
+ + ";projectName = " + JsfAllTests.IMPORT_PROJECT_NAME, file);//$NON-NLS-1$
+
+ IEditorInput input = new FileEditorInput(file);
+
+ assertNotNull("Editor input is null", input);
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ // get controller
+ VpeController controller = TestUtil.getVpeController(part);
+ assertNotNull(controller);
+
+ // get source document
+ Document sourceDocument = getSourceDocument(controller);
+ assertNotNull(sourceDocument);
+
+ Element openOnTestedElement = sourceDocument
+ .getElementById(LINK_STYLE_TEST_TAG_ID);
+ Attr testedClassAttr = openOnTestedElement
+ .getAttributeNode(CLASS_ATTRIBUTE);
+
+ OpenOnUtil.performOpenOnAction(part.getSourceEditor(),
+ ((IDOMAttr) testedClassAttr).getValueRegionStartOffset() + 1);
+
+ IStructuredSelection selection = (IStructuredSelection) PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .getSelection();
+
+ TestUtil.waitForJobs();
+
+ CSSStyleRule cssClassNode = (CSSStyleRule) selection.getFirstElement();
+
+ assertTrue(cssClassNode.getSelectorText().contains(
+ testedClassAttr.getNodeValue()));
+
+ // check exception
+ if (getException() != null) {
+ throw getException();
+ }
+
+ }
+}
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/OpenOnCssClassTest_JBIDE4775.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/OpenOnUtil.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/OpenOnUtil.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/OpenOnUtil.java 2009-08-24
16:39:57 UTC (rev 17243)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.vpe.ui.test;
+
+import java.lang.reflect.Method;
+
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class OpenOnUtil {
+
+ /**
+ * method does open on action in editor
+ *
+ * @param textEditor
+ * @param lineNumber
+ * @param lineOffset
+ * @throws Throwable
+ */
+ public static final void performOpenOnAction(
+ StructuredTextEditor textEditor, int offset) throws Throwable {
+
+ // hack to get hyperlinks detectors, no other was have been founded
+ Method method = AbstractTextEditor.class
+ .getDeclaredMethod("getSourceViewerConfiguration"); //$NON-NLS-1$
+ method.setAccessible(true);
+ SourceViewerConfiguration sourceViewerConfiguration = (SourceViewerConfiguration)
method
+ .invoke(textEditor);
+ IHyperlinkDetector[] hyperlinkDetectors = sourceViewerConfiguration
+ .getHyperlinkDetectors(textEditor.getTextViewer());
+
+ for (IHyperlinkDetector iHyperlinkDetector : hyperlinkDetectors) {
+ IHyperlink[] hyperLinks = iHyperlinkDetector.detectHyperlinks(
+ textEditor.getTextViewer(), new Region(offset, 0), false);
+ if (hyperLinks != null && hyperLinks.length > 0
+ && hyperLinks[0] instanceof AbstractHyperlink) {
+ AbstractHyperlink abstractHyperlink = (AbstractHyperlink) hyperLinks[0];
+ abstractHyperlink.open();
+ break;
+ }
+ }
+
+ }
+
+}
Property changes on:
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/OpenOnUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native