From jbosstools-commits at lists.jboss.org Fri Oct 8 02:26:50 2010 Content-Type: multipart/mixed; boundary="===============0856859846857587052==" MIME-Version: 1.0 From: jbosstools-commits at lists.jboss.org To: jbosstools-commits at lists.jboss.org Subject: [jbosstools-commits] JBoss Tools SVN: r25637 - in trunk: jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1791Test/WebContent/pages and 3 other directories. Date: Fri, 08 Oct 2010 02:26:50 -0400 Message-ID: <201010080626.o986Qolw013832@svn01.web.mwc.hst.phx2.redhat.com> --===============0856859846857587052== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/W= ebContent/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/i1= 8n/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/moz= illa/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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i= 18n/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/i= 18n/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/JsfJbide1791Te= st/WebContent/pages/extCommandTest.xhtml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 @@ +Externalize Text \ 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/js= p/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/js= p/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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/js= p/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/js= p/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.StructuredContentAssi= stant; = @@ -134,5 +137,16 @@ } return res; } - = + /** + * Close all opened editors + * @author mareshkau + */ + public static final void closeAllEditors(){ + IWorkbenchPage page =3D PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + IWorkbenchPart part =3D 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/js= p/test/ca/ExternalizeCommandTest.java (rev 0) +++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/js= p/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 =3D null; + private TestProjectProvider provider =3D null; + private Command externalizeCommand; + = + public void setUp() throws Exception { + provider =3D new TestProjectProvider("org.jboss.tools.jst.jsp.test= ", null, "JsfJbide1791Test",false); //$NON-NLS-1$ //$NON-NLS-2$ + project =3D provider.getProject(); + ICommandService commandService =3D + (ICommandService) PlatformUI.getWorkbench() + .getService(ICommandService.class); + externalizeCommand =3D commandService.getCommand( + "org.jboss.tools.jst.jsp.commands.i18"); //$NON-NLS-1$ + } + + protected void tearDown() throws Exception { + if(provider !=3D null) { + provider.dispose(); + } + } + /** + * Test behaviour of externalize string command + */ + public void testExternalizeCommand(){ + IEditorPart editorPart =3D WorkbenchUtils.openEditor(project.getName()+"= /WebContent/pages/extCommandTest.xhtml"); //$NON-NLS-1$ + if(editorPart instanceof JSPMultiPageEditor){ + JSPMultiPageEditor jspMultiPageEditor=3D (JSPMultiPageEditor) editorPar= t; + StyledText textWidget =3D jspMultiPageEditor.getSourceEditor().getText= Viewer().getTextWidget(); + textWidget.setCaretOffset(0); + assertEquals("Ext command should be disabled with current selection",fa= lse,externalizeCommand.isEnabled()); //$NON-NLS-1$ + textWidget.setCaretOffset(2); + assertEquals("Ext command should be disabled with current selection",fa= lse,externalizeCommand.isEnabled()); //$NON-NLS-1$ + textWidget.setCaretOffset(15); + assertEquals("Ext command should be enabled with current selection",tru= e,externalizeCommand.isEnabled()); //$NON-NLS-1$ + textWidget.setCaretOffset(2); + assertEquals("Ext command should be disabled with current selection",fa= lse,externalizeCommand.isEnabled()); //$NON-NLS-1$ + TestUtil.closeAllEditors(); + assertEquals("Ext command should be disabled without opened editor",fal= se,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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/js= p/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/js= p/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,toggleSelBarC= ommand.isEnabled()&&(Boolean)toggleSelBarState.getValue()); //$NON-NLS-1$ multiPageEditor.pageChange(0); assertEquals("check command enabled command status",true,toggleSelBarCo= mmand.isEnabled()&&(Boolean)toggleSelBarState.getValue()); //$NON-NLS-1$ - IWorkbenchPage page =3D PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(); - IWorkbenchPart part =3D page.getViewReferences()[0].getPart(false); - page.activate(part); - // close - page.closeAllEditors(false); + TestUtil.closeAllEditors(); assertEquals("check command enabled command status",false,toggleSelBarC= ommand.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/edi= tor/mozilla/MozillaEditor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mo= zilla/MozillaEditor.java 2010-10-08 05:03:05 UTC (rev 25636) +++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mo= zilla/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. -// *

-// * Enables the button when suitable text is selected. -// * Disabled otherwise. -// */ -// public void updateExternalizeStringsToolbarIconState() { -// StructuredTextEditor editor =3D controller.getSourceEditor(); -// ISelection sel =3D editor.getSelectionProvider().getSelection(); -// String stringToUpdate =3D Constants.EMPTY; -// if (ExternalizeStringsUtils.isSelectionCorrect(sel)) { -// String text =3D Constants.EMPTY; -// TextSelection textSelection =3D null; -// IStructuredSelection structuredSelection =3D (IStructuredSelection) s= el; -// textSelection =3D (TextSelection) sel; -// text =3D textSelection.getText(); -// Object selectedElement =3D structuredSelection.getFirstElement(); -// /* -// * When selected text is empty parse selected element and find a -// * string to replace.. -// */ -// if ((text.trim().length() =3D=3D 0)) { -// if (selectedElement instanceof org.w3c.dom.Text) { -// /* -// * ..it could be a plain text -// */ -// org.w3c.dom.Text textNode =3D (org.w3c.dom.Text) selectedElement; -// if (textNode.getNodeValue().trim().length() > 0) { -// stringToUpdate =3D textNode.getNodeValue(); -// } -// } else if (selectedElement instanceof Attr) { -// /* -// * ..or an attribute's value -// */ -// Attr attrNode =3D (Attr) selectedElement; -// if (attrNode.getNodeValue().trim().length() > 0) { -// stringToUpdate =3D attrNode.getNodeValue(); -// } -// } -// } else { -// stringToUpdate =3D text; -// } -// } -// if ((stringToUpdate.length() > 0)) { -// externalizeStringsAction.setEnabled(true); -// } else { -// externalizeStringsAction.setEnabled(false); -// } -// } } --===============0856859846857587052==--