Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 129936 Details for
Bug 267409
[Contributions] Tests for toggle state and radio state
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Test v02
RadioStateTest v01.txt (text/plain), 6.17 KB, created by
Prakash Rangaraj
on 2009-03-26 03:52:01 EDT
(
hide
)
Description:
Test v02
Filename:
MIME Type:
Creator:
Prakash Rangaraj
Created:
2009-03-26 03:52:01 EDT
Size:
6.17 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/commands/RadioStateTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/RadioStateTest.java,v >retrieving revision 1.1 >diff -u -r1.1 RadioStateTest.java >--- Eclipse UI Tests/org/eclipse/ui/tests/commands/RadioStateTest.java 6 Mar 2009 17:38:23 -0000 1.1 >+++ Eclipse UI Tests/org/eclipse/ui/tests/commands/RadioStateTest.java 26 Mar 2009 07:50:56 -0000 >@@ -15,9 +15,13 @@ > import org.eclipse.core.commands.Parameterization; > import org.eclipse.core.commands.ParameterizedCommand; > import org.eclipse.core.commands.State; >+import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.ui.commands.ICommandService; >+import org.eclipse.ui.commands.IElementReference; > import org.eclipse.ui.handlers.IHandlerService; > import org.eclipse.ui.handlers.RadioState; >+import org.eclipse.ui.menus.UIElement; >+import org.eclipse.ui.services.IServiceLocator; > import org.eclipse.ui.tests.harness.util.UITestCase; > > /** >@@ -70,6 +74,121 @@ > handlerService.executeCommand(parameterizedCommand2, null); > assertState(command1, "value2"); > } >+ >+ >+ static class MyUIElement extends UIElement{ >+ >+ private boolean checked; >+ protected MyUIElement(IServiceLocator serviceLocator){ >+ super(serviceLocator); >+ } >+ >+ public void setDisabledIcon(ImageDescriptor desc) {} >+ public void setHoverIcon(ImageDescriptor desc) {} >+ public void setIcon(ImageDescriptor desc) {} >+ public void setText(String text) {} >+ public void setTooltip(String text) {} >+ >+ public void setChecked(boolean checked) { >+ this.checked = checked; >+ } >+ >+ public boolean isChecked() { >+ return checked; >+ } >+ >+ } >+ >+ MyUIElement element1a; >+ MyUIElement element2a; >+ MyUIElement element3a; >+ >+ MyUIElement element1b; >+ MyUIElement element2b; >+ MyUIElement element3b; >+ >+ public void testMultipleContributions() throws Exception{ >+ >+ Command command1 = commandService.getCommand("org.eclipse.ui.tests.radioStateCommand1"); >+ >+ // group 1 >+ Parameterization radioParam1a = new Parameterization(command1.getParameter(RadioState.PARAMETER_ID), "value1"); >+ ParameterizedCommand parameterizedCommand1a = new ParameterizedCommand(command1, new Parameterization[] { radioParam1a }); >+ >+ Parameterization radioParam2a = new Parameterization(command1.getParameter(RadioState.PARAMETER_ID), "value2"); >+ ParameterizedCommand parameterizedCommand2a = new ParameterizedCommand(command1, new Parameterization[] { radioParam2a }); >+ >+ Parameterization radioParam3a = new Parameterization(command1.getParameter(RadioState.PARAMETER_ID), "value3"); >+ ParameterizedCommand parameterizedCommand3a = new ParameterizedCommand(command1, new Parameterization[] { radioParam3a }); >+ >+ element1a = new MyUIElement(fWorkbench); >+ element2a = new MyUIElement(fWorkbench); >+ element3a = new MyUIElement(fWorkbench); >+ >+ IElementReference reference1a = commandService.registerElementForCommand(parameterizedCommand1a, element1a); >+ IElementReference reference2a = commandService.registerElementForCommand(parameterizedCommand2a, element2a); >+ IElementReference reference3a = commandService.registerElementForCommand(parameterizedCommand3a, element3a); >+ >+ // group 2 >+ Parameterization radioParam1b = new Parameterization(command1.getParameter(RadioState.PARAMETER_ID), "value1"); >+ ParameterizedCommand parameterizedCommand1b = new ParameterizedCommand(command1, new Parameterization[] { radioParam1b }); >+ >+ Parameterization radioParam2b = new Parameterization(command1.getParameter(RadioState.PARAMETER_ID), "value2"); >+ ParameterizedCommand parameterizedCommand2b = new ParameterizedCommand(command1, new Parameterization[] { radioParam2b }); >+ >+ Parameterization radioParam3b = new Parameterization(command1.getParameter(RadioState.PARAMETER_ID), "value3"); >+ ParameterizedCommand parameterizedCommand3b = new ParameterizedCommand(command1, new Parameterization[] { radioParam3b }); >+ >+ element1b = new MyUIElement(fWorkbench); >+ element2b = new MyUIElement(fWorkbench); >+ element3b = new MyUIElement(fWorkbench); >+ >+ IElementReference reference1b = commandService.registerElementForCommand(parameterizedCommand1b, element1b); >+ IElementReference reference2b = commandService.registerElementForCommand(parameterizedCommand2b, element2b); >+ IElementReference reference3b = commandService.registerElementForCommand(parameterizedCommand3b, element3b); >+ >+ try{ >+ >+ // first set the state to value1 >+ handlerService.executeCommand(parameterizedCommand1a, null); >+ commandService.refreshElements(command1.getId(), null); >+ >+ assertChecked(element1a); >+ assertBothGroupsUpdated(); >+ >+ // then set the state to value2 >+ handlerService.executeCommand(parameterizedCommand2a, null); >+ >+ // only value 2 is checked >+ assertChecked(element2a); >+ assertBothGroupsUpdated(); >+ >+ >+ }finally { >+ commandService.unregisterElement(reference1a); >+ commandService.unregisterElement(reference2a); >+ commandService.unregisterElement(reference3a); >+ commandService.unregisterElement(reference1b); >+ commandService.unregisterElement(reference2b); >+ commandService.unregisterElement(reference3b); >+ } >+ >+ } >+ >+ private void assertChecked(MyUIElement checkedElement) { >+ >+ // only the element passed is checked and other two should be unchecked >+ assertTrue(checkedElement == element1a? element1a.isChecked():!element1a.isChecked()); >+ assertTrue(checkedElement == element2a? element2a.isChecked():!element2a.isChecked()); >+ assertTrue(checkedElement == element3a? element3a.isChecked():!element3a.isChecked()); >+ } >+ >+ private void assertBothGroupsUpdated() { >+ assertEquals(element1a.isChecked(), element1b.isChecked()); >+ assertEquals(element2a.isChecked(), element2b.isChecked()); >+ assertEquals(element3a.isChecked(), element3b.isChecked()); >+ } >+ > private void assertState(Command command, String expectedValue) { > State state = command.getState(RadioState.STATE_ID); > Object value = state.getValue();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 267409
:
128074
| 129936