Author: mareshkau
Date: 2008-08-04 13:43:10 -0400 (Mon, 04 Aug 2008)
New Revision: 9502
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2505Test.java
Log:
JBIDE-2505
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2505Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2505Test.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2505Test.java 2008-08-04
17:43:10 UTC (rev 9502)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+* Copyright (c) 2007-2008 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.swt.custom.StyledText;
+import org.eclipse.ui.IEditorInput;
+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.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsISelectionController;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class JBIDE2505Test extends VpeTest {
+
+ public JBIDE2505Test(String name) {
+ super(name);
+ }
+
+ /**
+ * Tests inner nodes include URI
+ *
+ * @throws Throwable
+ */
+ public void testCursorForJSPElements() throws Throwable {
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
+
+ //test for element node
+ testCaretManupulation(11, 34);
+ //test for sourceNode
+ testCaretManupulation(12, 58);
+ if(getException()!=null) {
+ throw getException();
+ }
+ }
+
+ private void testCaretManupulation(int sourceLine, int positioninLine) throws Throwable
{
+ // get test page path
+ IFile file = (IFile)
TestUtil.getComponentPath("JBIDE/2505/testJBIDE2505.jsp", //$NON-NLS-1$
+ JsfAllTests.IMPORT_PROJECT_NAME);
+ assertNotNull("Could not open specified file " + file.getFullPath(),
//$NON-NLS-1$
+ file);
+
+ IEditorInput input = new FileEditorInput(file);
+
+ assertNotNull("Editor input is null", input); //$NON-NLS-1$
+
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ int offset =
TestUtil.getLinePositionOffcet(part.getSourceEditor().getTextViewer(),sourceLine,
positioninLine);
+ // get editor control
+ StyledText styledText = part.getSourceEditor().getTextViewer()
+ .getTextWidget();
+
+ part.getSourceEditor().getTextViewer().getTextWidget().setCaretOffset(offset);
+
+
+
+ VpeController vpeController = getVpeController(part);
+ vpeController.sourceSelectionChanged();
+
+ for (int i=0;i<10;i++) {
+
+ nsIDOMNode domNode = vpeController.getXulRunnerEditor().getLastSelectedNode();
+ assertNotNull(domNode);
+
vpeController.getVisualSelectionController().getSelection(nsISelectionController.SELECTION_NORMAL).collapse(domNode,
i);
+ vpeController.visualRefresh();
+
+ assertEquals("Cursor position doesn't
equals",offset+i,styledText.getCaretOffset()); //$NON-NLS-1$
+ }
+ }
+}