Author: mareshkau
Date: 2010-10-08 02:26:49 -0400 (Fri, 08 Oct 2010)
New Revision: 25637
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1791Test/WebContent/pages/extCommandTest.xhtml
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ExternalizeCommandTest.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18Handler.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/TestUtil.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/SelectionBarTest.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
Log:
Junit for JBIDE-7060
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18Handler.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18Handler.java 2010-10-08
05:03:05 UTC (rev 25636)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/handlers/I18Handler.java 2010-10-08
06:26:49 UTC (rev 25637)
@@ -55,9 +55,9 @@
/**
*
*/
- public I18Handler() {
- setBaseEnabled(true);
- }
+// public I18Handler() {
+// setBaseEnabled(true);
+// }
/**
* Calculates the state of ext command
* @param selection
@@ -124,6 +124,5 @@
public void updateElement(UIElement element, Map parameters) {
fireHandlerChanged(new HandlerEvent(this, true, false));
-
}
}
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1791Test/WebContent/pages/extCommandTest.xhtml
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1791Test/WebContent/pages/extCommandTest.xhtml
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1791Test/WebContent/pages/extCommandTest.xhtml 2010-10-08
06:26:49 UTC (rev 25637)
@@ -0,0 +1 @@
+<html>Externalize Text</html>
\ No newline at end of file
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java 2010-10-08
05:03:05 UTC (rev 25636)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java 2010-10-08
06:26:49 UTC (rev 25637)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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.jst.jsp.test;
import junit.framework.Test;
@@ -3,6 +13,5 @@
import junit.framework.TestSuite;
-import org.jboss.tools.jst.jsp.test.ca.Jbide1791Test;
-import org.jboss.tools.jst.jsp.test.ca.JstJspJbide1585Test;
+import org.jboss.tools.jst.jsp.test.ca.ExternalizeCommandTest;
import org.jboss.tools.jst.jsp.test.ca.JstJspJbide1641Test;
import org.jboss.tools.jst.jsp.test.ca.SelectionBarTest;
@@ -33,6 +42,7 @@
suite.addTestSuite(JspPreferencesPageTest.class);
suite.addTestSuite(SelectionBarTest.class);
+ suite.addTestSuite(ExternalizeCommandTest.class);
return suite;
}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/TestUtil.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/TestUtil.java 2010-10-08
05:03:05 UTC (rev 25636)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/TestUtil.java 2010-10-08
06:26:49 UTC (rev 25637)
@@ -17,6 +17,9 @@
import org.eclipse.jface.text.contentassist.IContentAssistantExtension;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.wst.sse.ui.internal.contentassist.StructuredContentAssistant;
@@ -134,5 +137,16 @@
}
return res;
}
-
+ /**
+ * Close all opened editors
+ * @author mareshkau
+ */
+ public static final void closeAllEditors(){
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPart part = page.getViewReferences()[0].getPart(false);
+ page.activate(part);
+ // close
+ page.closeAllEditors(false);
+ }
}
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ExternalizeCommandTest.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ExternalizeCommandTest.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ExternalizeCommandTest.java 2010-10-08
06:26:49 UTC (rev 25637)
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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.jst.jsp.test.ca;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.jst.jsp.test.TestUtil;
+import org.jboss.tools.test.util.TestProjectProvider;
+import org.jboss.tools.test.util.WorkbenchUtils;
+
+/**
+ * Junit for JBIDE-7060
+ *
+ * @author mareshkau
+ *
+ */
+public class ExternalizeCommandTest extends TestCase {
+ protected IProject project = null;
+ private TestProjectProvider provider = null;
+ private Command externalizeCommand;
+
+ public void setUp() throws Exception {
+ provider = new TestProjectProvider("org.jboss.tools.jst.jsp.test",
null, "JsfJbide1791Test",false); //$NON-NLS-1$ //$NON-NLS-2$
+ project = provider.getProject();
+ ICommandService commandService =
+ (ICommandService) PlatformUI.getWorkbench()
+ .getService(ICommandService.class);
+ externalizeCommand = commandService.getCommand(
+ "org.jboss.tools.jst.jsp.commands.i18"); //$NON-NLS-1$
+ }
+
+ protected void tearDown() throws Exception {
+ if(provider != null) {
+ provider.dispose();
+ }
+ }
+ /**
+ * Test behaviour of externalize string command
+ */
+ public void testExternalizeCommand(){
+ IEditorPart editorPart =
WorkbenchUtils.openEditor(project.getName()+"/WebContent/pages/extCommandTest.xhtml");
//$NON-NLS-1$
+ if(editorPart instanceof JSPMultiPageEditor){
+ JSPMultiPageEditor jspMultiPageEditor= (JSPMultiPageEditor) editorPart;
+ StyledText textWidget =
jspMultiPageEditor.getSourceEditor().getTextViewer().getTextWidget();
+ textWidget.setCaretOffset(0);
+ assertEquals("Ext command should be disabled with current
selection",false,externalizeCommand.isEnabled()); //$NON-NLS-1$
+ textWidget.setCaretOffset(2);
+ assertEquals("Ext command should be disabled with current
selection",false,externalizeCommand.isEnabled()); //$NON-NLS-1$
+ textWidget.setCaretOffset(15);
+ assertEquals("Ext command should be enabled with current
selection",true,externalizeCommand.isEnabled()); //$NON-NLS-1$
+ textWidget.setCaretOffset(2);
+ assertEquals("Ext command should be disabled with current
selection",false,externalizeCommand.isEnabled()); //$NON-NLS-1$
+ TestUtil.closeAllEditors();
+ assertEquals("Ext command should be disabled without opened
editor",false,externalizeCommand.isEnabled()); //$NON-NLS-1$
+ }else{
+ fail("Should be opened JSPMultiPage Editor"); //$NON-NLS-1$
+ }
+
+ }
+}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/SelectionBarTest.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/SelectionBarTest.java 2010-10-08
05:03:05 UTC (rev 25636)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/SelectionBarTest.java 2010-10-08
06:26:49 UTC (rev 25637)
@@ -17,11 +17,10 @@
import org.eclipse.core.commands.State;
import org.eclipse.core.resources.IProject;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.test.util.TestProjectProvider;
import org.jboss.tools.test.util.WorkbenchUtils;
@@ -65,12 +64,7 @@
assertEquals("check command enabled command
status",false,toggleSelBarCommand.isEnabled()&&(Boolean)toggleSelBarState.getValue());
//$NON-NLS-1$
multiPageEditor.pageChange(0);
assertEquals("check command enabled command
status",true,toggleSelBarCommand.isEnabled()&&(Boolean)toggleSelBarState.getValue());
//$NON-NLS-1$
- IWorkbenchPage page = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- IWorkbenchPart part = page.getViewReferences()[0].getPart(false);
- page.activate(part);
- // close
- page.closeAllEditors(false);
+ TestUtil.closeAllEditors();
assertEquals("check command enabled command
status",false,toggleSelBarCommand.isEnabled()&&(Boolean)toggleSelBarState.getValue());
//$NON-NLS-1$
} else{
fail("Should be opened JSPMultiPage Editor"); //$NON-NLS-1$
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2010-10-08
05:03:05 UTC (rev 25636)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2010-10-08
06:26:49 UTC (rev 25637)
@@ -1101,54 +1101,4 @@
public MozillaTooltipListener getTooltipListener() {
return tooltipListener;
}
-
-// /**
-// * Update Externalize Strings toolbar icon state.
-// * <p>
-// * Enables the button when suitable text is selected.
-// * Disabled otherwise.
-// */
-// public void updateExternalizeStringsToolbarIconState() {
-// StructuredTextEditor editor = controller.getSourceEditor();
-// ISelection sel = editor.getSelectionProvider().getSelection();
-// String stringToUpdate = Constants.EMPTY;
-// if (ExternalizeStringsUtils.isSelectionCorrect(sel)) {
-// String text = Constants.EMPTY;
-// TextSelection textSelection = null;
-// IStructuredSelection structuredSelection = (IStructuredSelection) sel;
-// textSelection = (TextSelection) sel;
-// text = textSelection.getText();
-// Object selectedElement = structuredSelection.getFirstElement();
-// /*
-// * When selected text is empty parse selected element and find a
-// * string to replace..
-// */
-// if ((text.trim().length() == 0)) {
-// if (selectedElement instanceof org.w3c.dom.Text) {
-// /*
-// * ..it could be a plain text
-// */
-// org.w3c.dom.Text textNode = (org.w3c.dom.Text) selectedElement;
-// if (textNode.getNodeValue().trim().length() > 0) {
-// stringToUpdate = textNode.getNodeValue();
-// }
-// } else if (selectedElement instanceof Attr) {
-// /*
-// * ..or an attribute's value
-// */
-// Attr attrNode = (Attr) selectedElement;
-// if (attrNode.getNodeValue().trim().length() > 0) {
-// stringToUpdate = attrNode.getNodeValue();
-// }
-// }
-// } else {
-// stringToUpdate = text;
-// }
-// }
-// if ((stringToUpdate.length() > 0)) {
-// externalizeStringsAction.setEnabled(true);
-// } else {
-// externalizeStringsAction.setEnabled(false);
-// }
-// }
}