Author: dmaliarevich
Date: 2009-12-30 06:55:45 -0500 (Wed, 30 Dec 2009)
New Revision: 19614
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/TestOpenOnForXhtmlFiles_JBIDE5577.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-5577, JUnit test for openOn was added.
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-12-30
10:34:10 UTC (rev 19613)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-12-30
11:55:45 UTC (rev 19614)
@@ -75,6 +75,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.MozDirtyTest_JBIDE5105;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.NullPointerWithStyleProperty_JBIDE5193;
import
org.jboss.tools.jsf.vpe.jsf.test.jbide.TestForUsingComponentsLibrariesWithDefaultNamespace;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.TestOpenOnForXhtmlFiles_JBIDE5577;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.VpeI18nTest_JBIDE4887;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide1467Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide1501Test;
@@ -184,6 +185,7 @@
suite.addTestSuite(OpenOnInsideJspRoot_JBIDE4852.class);
suite.addTestSuite(NullPointerWithStyleProperty_JBIDE5193.class);
suite.addTestSuite(TestFViewLocaleAttribute_JBIDE5218.class);
+ suite.addTestSuite(TestOpenOnForXhtmlFiles_JBIDE5577.class);
// $JUnit-END$
// added by Max Areshkau
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/TestOpenOnForXhtmlFiles_JBIDE5577.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/TestOpenOnForXhtmlFiles_JBIDE5577.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/TestOpenOnForXhtmlFiles_JBIDE5577.java 2009-12-30
11:55:45 UTC (rev 19614)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.core.runtime.CoreException;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+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.SelectionUtil;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Node;
+
+/**
+ * Checks that openOn will correctly resolve JSF page mapping.
+ *
+ * @author dmaliarevich
+ */
+public class TestOpenOnForXhtmlFiles_JBIDE5577 extends VpeTest {
+
+ public TestOpenOnForXhtmlFiles_JBIDE5577(String name) {
+ super(name);
+ }
+
+ public void testOpenOnForXhtmlFiles() throws CoreException {
+ /*
+ * Open index.html
+ */
+ IFile file = (IFile) TestUtil.getWebContentPath("index.html",
JsfAllTests.IMPORT_JSF_20_PROJECT_NAME); //$NON-NLS-1$
+ assertNotNull("Could not find the file for the editor",
file); //$NON-NLS-1$
+ IEditorInput input = new FileEditorInput(file);
+ assertNotNull("Editor input is null", input); //$NON-NLS-1$
+ JSPMultiPageEditor part = openEditor(input);
+ VpeController vpeController = TestUtil.getVpeController(part);
+
+ /*
+ * Make openOn action an <a> tag.
+ */
+ int position =
TestUtil.getLinePositionOffcet(vpeController.getSourceEditor().getTextViewer(), 7, 29);
+ Node sourceNode =
SelectionUtil.getNodeBySourcePosition(vpeController.getSourceEditor(), position);
+ nsIDOMNode domNode = vpeController.getDomMapping().getNearVisualNode(sourceNode);
+ vpeController.getSourceBuilder().openOn(domNode);
+ IEditorPart activeEditor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ assertEquals("head2.xhtml file should be opened","head2.xhtml",
activeEditor.getEditorInput().getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}