Author: mareshkau
Date: 2010-09-22 07:41:44 -0400 (Wed, 22 Sep 2010)
New Revision: 25083
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1791Test/WebContent/pages/selectionBar.xhtml
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/SelectionBarTest.java
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java
Log:
junit test for JBIDE-7059
Added:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1791Test/WebContent/pages/selectionBar.xhtml
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1791Test/WebContent/pages/selectionBar.xhtml
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/projects/JsfJbide1791Test/WebContent/pages/selectionBar.xhtml 2010-09-22
11:41:44 UTC (rev 25083)
@@ -0,0 +1 @@
+test page
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-09-22
10:54:39 UTC (rev 25082)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/JstJspAllTests.java 2010-09-22
11:41:44 UTC (rev 25083)
@@ -6,11 +6,12 @@
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.JstJspJbide1641Test;
+import org.jboss.tools.jst.jsp.test.ca.SelectionBarTest;
public class JstJspAllTests {
public static Test suite() {
- TestSuite suite = new TestSuite("Test for org.jboss.tools.jst.jsp.test");
+ TestSuite suite = new TestSuite("Test for org.jboss.tools.jst.jsp.test");
//$NON-NLS-1$
/*
* TODO: Uncomment the following test case after
https://jira.jboss.org/browse/JBIDE-7104 issue
@@ -30,6 +31,8 @@
*/
suite.addTestSuite(JspPreferencesPageTest.class);
+
+ suite.addTestSuite(SelectionBarTest.class);
return suite;
}
Added:
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
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/SelectionBarTest.java 2010-09-22
11:41:44 UTC (rev 25083)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.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.test.util.TestProjectProvider;
+import org.jboss.tools.test.util.WorkbenchUtils;
+
+/**
+ * Junit which tests selection bar command behaviour and logic
+ * @author mareshkau
+ *
+ */
+public class SelectionBarTest extends TestCase{
+ protected IProject project = null;
+ private TestProjectProvider provider = null;
+ private Command toggleSelBarCommand;
+ private State toggleSelBarState;
+
+ 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);
+ toggleSelBarCommand = commandService.getCommand(
+ "org.jboss.tools.jst.jsp.commands.showSelectionBar"); //$NON-NLS-1$
+ toggleSelBarState= toggleSelBarCommand
+ .getState("org.eclipse.ui.commands.toggleState"); //$NON-NLS-1$
+ }
+
+ protected void tearDown() throws Exception {
+ if(provider != null) {
+ provider.dispose();
+ }
+ }
+
+ public void testSelectionBarCommandState() throws Throwable{
+ assertEquals("check command enabled command
status",false,toggleSelBarCommand.isEnabled()); //$NON-NLS-1$
+ IEditorPart editorPart =
WorkbenchUtils.openEditor(project.getName()+"/WebContent/pages/selectionBar.xhtml");
//$NON-NLS-1$
+ if(editorPart instanceof JSPMultiPageEditor){
+ JSPMultiPageEditor multiPageEditor = (JSPMultiPageEditor) editorPart;
+ multiPageEditor.pageChange(0);
+ assertEquals("check command enabled command
status",true,toggleSelBarCommand.isEnabled()&&(Boolean)toggleSelBarState.getValue());
//$NON-NLS-1$
+ multiPageEditor.pageChange(multiPageEditor.getPreviewIndex());
+ 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);
+ 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$
+ }
+ }
+}
Property changes on:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/SelectionBarTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain