Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorIvan Furnadjiev2011-01-13 11:48:07 +0000
committerIvan Furnadjiev2011-01-13 11:48:07 +0000
commit2e7a22b9d33aaab4f6cde36b27d753e3aa8f2d5d (patch)
treee87527e3afd9e119e197a70e6dbdbedd26e6807a /tests
parente1686a8ceb3019d0dcd48335da46e2ab8e871c1f (diff)
downloadorg.eclipse.rap-2e7a22b9d33aaab4f6cde36b27d753e3aa8f2d5d.tar.gz
org.eclipse.rap-2e7a22b9d33aaab4f6cde36b27d753e3aa8f2d5d.tar.xz
org.eclipse.rap-2e7a22b9d33aaab4f6cde36b27d753e3aa8f2d5d.zip
Fixed - 334003: Update org.eclipse.rap.ui.tests to Indigo (3.7)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=334003
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/AllTests.java9
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/AllTests.java3
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/CoolBarManagerTest.java61
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/MenuManagerTest.java12
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/AllTests.java4
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/DialogSettingsTest.java31
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/DialogTest.java110
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/InputDialogTest.java15
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/ProgressIndicatorStyleTest.java14
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/ProgressMonitorDialogTest.java60
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/TitleAreaDialogTest.java18
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/AbstractFieldAssistTestCase.java220
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/AbstractFieldAssistWindow.java164
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/ComboFieldAssistTests.java27
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/ComboFieldAssistWindow.java37
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/ControlDecorationTests.java88
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/FieldAssistAPITests.java58
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/FieldAssistTestCase.java281
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/FieldAssistTestSuite.java38
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/TextFieldAssistTests.java27
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/TextFieldAssistWindow.java40
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTests.java2
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingStyledCellLabelProviderTest.java667
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/IDecorationContextTest.java137
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/AllTests.java31
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/BooleanFieldEditorTest.java284
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/IntegerFieldEditorTest.java115
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/SamplePreferencePage.java40
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/StringFieldEditorTest.java143
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/AllTests.java13
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug138608Test.java3
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TreeViewerTest.java325
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TableViewerTest.java36
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TreeViewerTest.java36
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java3
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug256889TableViewerTest.java159
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug287765Test.java166
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckStateProviderTestsUtil.java135
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTableViewerTest.java323
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerTest.java327
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java2
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java2
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java8
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java102
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeManagerTest.java654
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ConcurrentTableTestView.java2
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyVirtualTableView.java31
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/StyledCellLabelProviderTests.java329
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/VirtualTableView.java10
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/ButtonAlignmentTest.java156
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/TheTestWizard.java69
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/TheTestWizardDialog.java65
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/TheTestWizardPage.java101
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/WizardProgressMonitorTest.java189
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/WizardTest.java294
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/WizardTestSuite.java32
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/RCPSessionApplication.java55
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/WindowlessRCPApplication.java20
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/commands/DefaultHandler.java29
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/session/NonRestorableView.java24
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/UiTestSuite.java10
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/ActivitiesTestSuite.java2
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java163
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/StaticTest.java6
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/UtilTest.java215
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ApiTestSuite.java5
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/BadElementFactory.java10
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/DummyService.java40
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/DummyServiceFactory.java31
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IActionBarsTest.java138
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IAggregateWorkingSetTest.java334
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorRegistryTest.java104
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IFileEditorMappingTest.java6
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPageListenerTest.java4
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPartServiceTest.java35
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPerspectiveListenerTest.java4
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ISelectionServiceTest.java2
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPageTest.java1295
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPartSiteTest.java35
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchTest.java4
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetElementAdapterTests.java72
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetManagerTest.java42
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ListView.java2
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/MockReusableEditorPart.java188
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/SaveableMockViewPart.java69
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/StickyViewTest.java127
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ViewUtils.java27
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ArbitraryPropertyTest.java12
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/HeavyResourceView.java2
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/LifecycleView.java10
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/OverriddenTitleTest.java14
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/RawIViewPartTest.java14
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ViewPartTitleTest.java14
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java73
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java102
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandParameterTypeTest.java31
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandsTestSuite.java4
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/EditorActionDelegate.java50
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ExceptionThrowingHandler.java28
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HandlerActivationTest.java17
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HelpContextIdTest.java4
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/RadioStateHandler.java37
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/RadioStateTest.java199
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/SimplyGoActionDelegate.java57
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/StateTest.java88
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ToggleStateHandler.java26
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ToggleStateTest.java139
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/Bug_262032.java117
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/ConcurrencyTestSuite.java13
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/ModalContextCrashTest.java52
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/SyncExecWhileUIThreadWaitsForLock.java87
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/SyncExecWhileUIThreadWaitsForRuleTest.java109
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/DataTransferTestSuite.java2
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorsTestSuite.java8
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIDialogs.java14
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIDialogsAuto.java8
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ActionSetTests.java2
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicContributionTest.java80
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicInvalidContributionTest.java66
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicPluginsTestSuite.java4
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/EditorTests.java80
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ViewTests.java108
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/AbstractContentAssistCommandAdapterTest.java114
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/ComboCommandFieldAssistWindow.java28
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/ComboContentAssistCommandAdapterTest.java39
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/FieldAssistTestSuite.java5
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/TextCommandFieldAssistWindow.java28
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/TextContentAssistCommandAdapterTest.java70
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/helpers/TestFacade.java84
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/helpers/TestFacadeImpl.java245
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/AnimationEngineTest.java124
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/FileEditorMappingTest.java158
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/InternalTestSuite.java12
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/PerspectiveSwitcherTest.java103
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/ReopenMenuTest.java85
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/StickyViewManagerTest.java191
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/TestMemento.java2
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/TextControlView.java115
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/TextHandlerTest.java130
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/UtilTest.java112
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingInteractionsTest.java56
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug189167Test.java10
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/Bug43597Test.java14
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/KeysTestSuite.java3
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/leaks/LeakTests.java137
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerSortUtilTest.java112
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerTesterTest.java240
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkersViewColumnSizeTest.java76
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/ResourceMappingTestView.java7
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug231304Test.java61
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/Bug264804Test.java97
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/DynamicContributionItemPopup.java44
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/DynamicMenuTest.java116
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuPopulationTest.java515
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/MenusTestSuite.java6
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/ObjectContributionClasses.java29
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/ShowViewMenuTest.java66
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multieditor/TiledEditor.java4
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/PartPageListener.java100
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/FontPreferenceTestCase.java75
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/CommandHandler.java26
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/DummyJob.java55
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/ProgressContantsTest.java120
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/ProgressTestCase.java65
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/ProgressTestSuite.java37
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/ProgressViewTests.java98
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/AbstractPropertySheetTest.java83
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/MultiInstancePropertySheetTest.java499
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/NewPropertySheetHandlerTest.java291
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java193
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetPerspectiveFactory.java60
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetPerspectiveFactory2.java58
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetPerspectiveFactory3.java64
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetTestSuite.java6
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertyShowInContextTest.java279
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/ShowInPropertySheetTest.java100
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestNewPropertySheetHandler.java65
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/TestPropertySheetPage.java79
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/quickaccess/QuickAccessDialogTest.java83
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/quickaccess/QuickAccessTestSuite.java3
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/CheckHandler.java14
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/EditorSourceTest.java187
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/EvaluationServiceTest.java282
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/ServicesTestSuite.java4
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/StaticVarPropertyTester.java31
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/WorkbenchSiteProgressServiceTest.java157
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/NonRestorablePropertySheetTest.java94
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/NonRestorableViewTest.java75
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/RestoreSessionTest.java56
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/SessionTests.java56
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/WindowlessSessionTest.java43
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/session/WorkbenchSessionTest.java28
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/FaultyExportWizard.java14
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/FreeStatusHandler.java34
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/LabelProviderWrapperTest.java166
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogManagerTest.java1177
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogUtil.java180
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusHandlerConfigurationSuite.java45
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusHandlingConfigurationTest.java62
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusHandlingTestSuite.java8
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/SupportTrayTest.java148
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/WorkbenchStatusDialogManagerImplTest.java94
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/stress/OpenCloseTest.java2
-rw-r--r--tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/themes/JFaceThemeTest.java2
-rw-r--r--tests/org.eclipse.rap.ui.tests/plugin.xml563
205 files changed, 19213 insertions, 1063 deletions
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/AllTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/AllTests.java
index 720adcb20b..6857c14531 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/AllTests.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.jface.tests;
-import org.eclipse.jface.tests.labelProviders.DecoratingLabelProviderTests;
-
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -31,6 +29,9 @@ public class AllTests extends TestSuite {
addTest(new org.eclipse.jface.tests.images.AllTests());
addTest(new org.eclipse.jface.tests.viewers.AllTests());
addTest(new org.eclipse.jface.tests.layout.AllTests());
- addTest(new DecoratingLabelProviderTests());
+ addTest(new org.eclipse.jface.tests.preferences.AllTests());
+ addTest(new org.eclipse.jface.tests.wizards.WizardTestSuite());
+ addTest(new org.eclipse.jface.tests.labelProviders.DecoratingLabelProviderTests());
+ addTest(new org.eclipse.jface.tests.fieldassist.FieldAssistTestSuite());
}
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/AllTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/AllTests.java
index 20ca5dff38..213e6d93cf 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/AllTests.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,6 +25,7 @@ public class AllTests extends TestSuite {
public AllTests() {
addTestSuite(ContributionItemTest.class);
+ addTestSuite(CoolBarManagerTest.class);
addTestSuite(MenuManagerTest.class);
}
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/CoolBarManagerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/CoolBarManagerTest.java
new file mode 100644
index 0000000000..a2329200a3
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/CoolBarManagerTest.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.action;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.CoolBarManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.CoolBar;
+import org.eclipse.swt.widgets.CoolItem;
+
+/**
+ * @since 3.6
+ */
+public class CoolBarManagerTest extends JFaceActionTest {
+
+ private CoolBarManager coolBarManager;
+
+ private CoolBar coolBar;
+
+ public CoolBarManagerTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ coolBarManager = new CoolBarManager(SWT.FLAT);
+ coolBar = coolBarManager.createControl(getShell());
+ }
+
+ public void testResetItemOrderBug293433() {
+ IToolBarManager manager = new ToolBarManager();
+ manager.add(new Action() {
+ });
+ coolBarManager.add(manager);
+ coolBarManager.update(true);
+
+ CoolItem[] items = coolBar.getItems();
+ assertEquals(1, items.length);
+
+ Control control = items[0].getControl();
+
+ // reset causes items to be disposed
+ coolBarManager.resetItemOrder();
+
+ // ensure that the control was actually disposed
+ assertTrue(control.isDisposed());
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/MenuManagerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/MenuManagerTest.java
index e090125739..766d753c8b 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/MenuManagerTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/action/MenuManagerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -99,6 +99,16 @@ public class MenuManagerTest extends JFaceActionTest {
menuBarMgr.dispose();
assertTrue(menuBarMgr.isDirty());
}
+
+ /**
+ * This is a test case for bug 255429 to ensure that a menu manager without any text
+ * set does not throw an NPE.
+ */
+ public void testEmptyMenuManagerNPE() {
+ Menu menu = new Menu(getShell());
+ MenuManager manager = new MenuManager();
+ manager.fill(menu, -1);
+ }
/**
* Creates a menu manager with the given name, adding items based on the given template.
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/AllTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/AllTests.java
index 0c0d7fcc35..2e74b55f83 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/AllTests.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,10 +24,12 @@ public class AllTests extends TestSuite {
}
public AllTests() {
+ addTestSuite(DialogTest.class);
addTestSuite(DialogSettingsTest.class);
addTestSuite(InputDialogTest.class);
addTestSuite(TitleAreaDialogTest.class);
addTestSuite(SafeRunnableErrorTest.class);
addTestSuite(ProgressIndicatorStyleTest.class);
+ addTestSuite(ProgressMonitorDialogTest.class);
}
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/DialogSettingsTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/DialogSettingsTest.java
index 1e1bdcf3ba..f09deab024 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/DialogSettingsTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/DialogSettingsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,12 +7,15 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Marc R. Hoffmann <hoffmann@mountainminds.com> - Bug 284265 [JFace]
+ * DialogSettings.save() silently ignores IOException
*******************************************************************************/
package org.eclipse.jface.tests.dialogs;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
+import java.io.Writer;
import junit.framework.TestCase;
@@ -433,4 +436,30 @@ public class DialogSettingsTest extends TestCase {
.checkAfterDeserialization(deserializedDialogSettings);
}
+ public void testSaveWithIOException() {
+ final DialogSettings settings = new DialogSettings("test");
+ try {
+ settings.save(new BrokenWriter());
+ fail("IOException expected");
+ } catch (IOException e) {
+ }
+ }
+
+ private static class BrokenWriter extends Writer {
+
+ public void write(final char[] cbuf, final int off, final int len)
+ throws IOException {
+ throw new IOException("Bang!");
+ }
+
+ public void close() throws IOException {
+ throw new IOException("Bang!");
+ }
+
+ public void flush() throws IOException {
+ throw new IOException("Bang!");
+ }
+
+ }
+
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/DialogTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/DialogTest.java
new file mode 100644
index 0000000000..63d59d4ef0
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/DialogTest.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Remy Chi Jian Suen and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * Remy Chi Jian Suen - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jface.tests.dialogs;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+public class DialogTest extends TestCase {
+
+ /**
+ * The dialog being tested.
+ */
+ private Dialog dialog;
+
+ protected void tearDown() throws Exception {
+ if (dialog != null) {
+ // close the dialog
+ dialog.close();
+ dialog = null;
+ }
+ super.tearDown();
+ }
+
+ /**
+ * If a layout is invoked prior to the button being shifted in
+ * {@link org.eclipse.jface.dialogs.Dialog Dialog}'s
+ * {@link org.eclipse.jface.dialogs.Dialog#initializeBounds()
+ * initializeBounds()} invocation, the button will not be visually shifted
+ * even though getChildren() may prove otherwise. We check for this by
+ * comparing the X coordinate of the 'OK' and 'Cancel' buttons to ensure
+ * that they are in the right place if the dismissal alignment for the
+ * current platform is SWT.RIGHT.
+ */
+ public void testButtonAlignmentBug272583() {
+ // instantiate a new dialog
+ ForceLayoutDialog forceLayoutDialog = new ForceLayoutDialog();
+ dialog = forceLayoutDialog;
+ // don't block the UI/testing thread
+ forceLayoutDialog.setBlockOnOpen(false);
+ // open the dialog so the widgets will be realized
+ forceLayoutDialog.open();
+
+ // retrieve the 'OK' and 'Cancel' buttons
+ Button okBtn = forceLayoutDialog.getButton(IDialogConstants.OK_ID);
+ Button cancelBtn = forceLayoutDialog
+ .getButton(IDialogConstants.CANCEL_ID);
+
+ // retrieve the X coordinates of the two buttons
+ int okX = okBtn.getBounds().x;
+ int cancelX = cancelBtn.getBounds().x;
+
+ if (okBtn.getDisplay().getDismissalAlignment() == SWT.LEFT) {
+ assertTrue(
+ "The 'OK' button should be to the left of the 'Cancel' button",
+ okX < cancelX);
+ } else {
+ assertTrue(
+ "The 'OK' button should be to the right of the 'Cancel' button",
+ cancelX < okX);
+ }
+
+ forceLayoutDialog.close();
+ }
+
+ /**
+ * A dialog that explicitly invokes a layout operation prior to the shell
+ * being opened. Calls to moveBelow(Control) should be followed by a layout
+ * operation and as clients may explicitly invoke layout while subclassing
+ * Dialog, we want to be sure that this doesn't prevent the
+ * moveBelow(Control) call from working.
+ */
+ private class ForceLayoutDialog extends Dialog {
+
+ ForceLayoutDialog() {
+ super((Shell) null);
+ }
+
+ protected Control createContents(Composite parent) {
+ Control contents = super.createContents(parent);
+ // explicitly layout the button prior to the shell being realized
+ getShell().layout(
+ new Control[] { getButton(IDialogConstants.OK_ID) });
+ return contents;
+ }
+
+ /**
+ * Overridden to allow it to be invoked locally.
+ */
+ protected Button getButton(int id) {
+ return super.getButton(id);
+ }
+
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/InputDialogTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/InputDialogTest.java
index 51f4474219..0b4e42583b 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/InputDialogTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/InputDialogTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,10 +15,19 @@ import junit.framework.TestCase;
import org.eclipse.jface.dialogs.InputDialog;
public class InputDialogTest extends TestCase {
+
+ private InputDialog dialog;
+
+ protected void tearDown() throws Exception {
+ if (dialog != null) {
+ dialog.close();
+ dialog = null;
+ }
+ super.tearDown();
+ }
public void testSetErrorMessageEarly() {
- final InputDialog dialog = new InputDialog(null, "TEST", "value",
- "test", null);
+ dialog = new InputDialog(null, "TEST", "value", "test", null);
dialog.setBlockOnOpen(false);
dialog.setErrorMessage("error");
dialog.open();
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/ProgressIndicatorStyleTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/ProgressIndicatorStyleTest.java
index 071137ea2f..367ef29382 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/ProgressIndicatorStyleTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/ProgressIndicatorStyleTest.java
@@ -22,9 +22,9 @@ import org.eclipse.swt.widgets.Shell;
/**
* Test case to assert proper styles have been set for ProgressIndicator.
- *
+ *
* @since 3.4
- *
+ *
*/
public class ProgressIndicatorStyleTest extends TestCase {
@@ -44,26 +44,24 @@ public class ProgressIndicatorStyleTest extends TestCase {
style = SWT.SMOOTH;
verifyIndicator();
-
style = SWT.VERTICAL;
- verifyIndicator();
+ verifyIndicator();
style = SWT.HORIZONTAL;
verifyIndicator();
-
+
}
/**
* Verify the indicator is working by opening it and doing something.
*/
private void verifyIndicator() {
-// Shell shell = new Shell();
- Shell shell = new Shell( SWT.NONE );
+ Shell shell = new Shell();
progress = new ProgressIndicator(shell, style);
progress.setSize(175,175);
shell.setSize(200,200);
shell.open();
-// shell.forceActive();
+ shell.forceActive();
progress.beginTask(100);
progress.worked(50);
loader("determinateProgressBar", deter);
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/ProgressMonitorDialogTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/ProgressMonitorDialogTest.java
new file mode 100644
index 0000000000..6d4016d917
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/ProgressMonitorDialogTest.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.dialogs;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.widgets.Display;
+
+public class ProgressMonitorDialogTest extends TestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // ensure we've initialized a display for this thread
+ Display.getDefault();
+ }
+
+ private void testRun(boolean fork, boolean cancelable) throws Exception {
+ ProgressMonitorDialog pmd = new ProgressMonitorDialog(null);
+ pmd.open();
+ pmd.run(fork, cancelable, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ // nothing to do, just need this to happen to test bug 299731
+ }
+ });
+
+ // process asynchronous runnables, the error will happen here when we
+ // try to do some with a widget that has already been disposed
+ while (Display.getDefault().readAndDispatch())
+ ;
+ }
+
+ public void testRunTrueTrue() throws Exception {
+ testRun(true, true);
+ }
+
+ public void testRunTrueFalse() throws Exception {
+ testRun(true, false);
+ }
+
+ public void testRunFalseTrue() throws Exception {
+ testRun(false, true);
+ }
+
+ public void testRunFalseFalse() throws Exception {
+ testRun(false, false);
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/TitleAreaDialogTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/TitleAreaDialogTest.java
index 43e7ff0db4..211e9880d5 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/TitleAreaDialogTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/TitleAreaDialogTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,9 +24,19 @@ public class TitleAreaDialogTest extends TestCase {
static ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.rap.ui.tests", "icons/anything.gif");
+ private TitleAreaDialog dialog;
+
+ protected void tearDown() throws Exception {
+ if (dialog != null) {
+ dialog.close();
+ dialog = null;
+ }
+ super.tearDown();
+ }
+
// Test setting the title image before creating the dialog.
public void testSetTitleImageEarly() {
- final TitleAreaDialog dialog = new TitleAreaDialog(null);
+ dialog = new TitleAreaDialog(null);
dialog.setBlockOnOpen(false);
final Image image = descriptor.createImage();
dialog.setTitleImage(image);
@@ -40,9 +50,9 @@ public class TitleAreaDialogTest extends TestCase {
});
dialog.open();
}
-
+
public void testSetTitleImageNull() {
- TitleAreaDialog dialog = new TitleAreaDialog(null);
+ dialog = new TitleAreaDialog(null);
dialog.setBlockOnOpen(false);
dialog.setTitleImage(null);
dialog.open();
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/AbstractFieldAssistTestCase.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/AbstractFieldAssistTestCase.java
new file mode 100644
index 0000000000..461ead0a94
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/AbstractFieldAssistTestCase.java
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Remy Chi Jian Suen and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * Remy Chi Jian Suen <remy.suen@gmail.com> - initial API and implementation
+ * IBM - ongoing development
+ ******************************************************************************/
+package org.eclipse.jface.tests.fieldassist;
+
+import junit.framework.TestCase;
+
+//import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+//import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public abstract class AbstractFieldAssistTestCase extends TestCase {
+
+ /**
+ * The window that is being tested.
+ */
+ private AbstractFieldAssistWindow window;
+
+ /**
+ * A shell used to take focus away from the field assist window
+ */
+ private Shell anotherShell;
+
+ /**
+ * The original number of shells at the beginning of the test.
+ */
+ private int originalShellCount;
+
+ /**
+ * Sets up this field assist test case. Subclasses should extend but not
+ * override.
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ Display display = getDisplay();
+ anotherShell = new Shell(display);
+ new Text(anotherShell, SWT.SINGLE);
+ anotherShell.open();
+ spinEventLoop();
+ originalShellCount = display.getShells().length;
+ window = createFieldAssistWindow();
+ assertNotNull(window);
+ }
+
+ /**
+ * Tears down this field assist test case. Subclasses should extend but not
+ * override.
+ */
+ protected void tearDown() throws Exception {
+ if (window != null) {
+ spinEventLoop();
+ }
+ closeFieldAssistWindow();
+ anotherShell.close();
+
+ super.tearDown();
+ }
+
+ protected Display getDisplay() {
+ Display display = Display.getCurrent();
+ if (display == null)
+ display = Display.getDefault();
+ return display;
+ }
+
+ protected void closeFieldAssistWindow() {
+ if (window != null) {
+ window.close();
+ window = null;
+ }
+ }
+
+ /**
+ * Creates the field assist window that is to be tested.
+ */
+ protected abstract AbstractFieldAssistWindow createFieldAssistWindow();
+
+ /**
+ * Returns the created field assist window. May be null if
+ * {@link #createFieldAssistWindow()} has not been called yet or if the test
+ * is being torn down.
+ */
+ protected AbstractFieldAssistWindow getFieldAssistWindow() {
+ return window;
+ }
+
+ protected void spinEventLoop() {
+ // spin the event loop again because we have some asyncExec calls in the
+ // ContentProposalAdapter class
+
+ Display disp = getDisplay();
+ while (disp.readAndDispatch()) {
+ ;
+ }
+ }
+
+ protected void ensurePopupIsUp() {
+ // if our autoactivation delay is zero, we use an asyncExec to get the
+ // popup up, hence, we need to spin the event loop
+ if (window.getAutoActivationDelay() == 0) {
+ spinEventLoop();
+ } else {
+ long time = System.currentTimeMillis();
+ long target = time + window.getAutoActivationDelay();
+ while (target > time) {
+ spinEventLoop(); // remain responsive
+ time = System.currentTimeMillis();
+ }
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ // nothing to do
+ }
+ spinEventLoop();
+ }
+ }
+
+ /**
+ * Gives focus to the field assist control.
+ */
+ protected void sendFocusInToControl() {
+ window.getFieldAssistControl().setFocus();
+ spinEventLoop();
+ }
+
+ /**
+ * Send focus somewhere besides the field assist shell.
+ * This involves optionally creating another shell. If we
+ * create another shell, we need to adjust the originalShellCount
+ */
+ protected void sendFocusElsewhere() {
+ anotherShell.setFocus();
+ spinEventLoop();
+ }
+
+ /**
+ * Sends focus to the field assist popup.
+ */
+ protected void sendFocusToPopup() {
+ getFieldAssistWindow().getContentProposalAdapter().setProposalPopupFocus();
+ spinEventLoop();
+ }
+
+// /**
+// * Sends an SWT KeyDown event for the specified character to the field
+// * assist control.
+// *
+// * @param character
+// * the character that has been pressed
+// */
+// protected void sendKeyDownToControl(char character) {
+// // fake a KeyDown event
+// sendFocusInToControl();
+// Event event = new Event();
+// event.type = SWT.KeyDown;
+// event.character = character;
+// assertTrue("unable to post event to display queue for test case", window.getDisplay().post(event));
+// spinEventLoop();
+// }
+
+// /**
+// * Sends an SWT KeyDown event for the specified keystroke
+// *
+// * @param character
+// * the character that has been pressed
+// */
+// protected void sendKeyDownToControl(KeyStroke keystroke) {
+// // fake a KeyDown event
+// sendFocusInToControl();
+// Event event = new Event();
+// event.type = SWT.KeyDown;
+// event.keyCode = keystroke.getNaturalKey();
+// assertTrue("unable to post event to display queue for test case", window.getDisplay().post(event));
+// spinEventLoop();
+// }
+
+ /**
+ * Checks that there is only one shell up, the original field assist window.
+ */
+ protected void assertOneShellUp() {
+ spinEventLoop();
+ assertEquals("There should only be one shell up, the dialog",
+ originalShellCount + 1, window.getDisplay().getShells().length);
+ }
+
+ /**
+ * Checks that there are two shells up, the original field assist window and
+ * the proposals popup.
+ */
+ protected void assertTwoShellsUp() {
+ spinEventLoop();
+ assertEquals(
+ "There should two shells up, the dialog and the proposals dialog",
+ originalShellCount + 2, window.getDisplay().getShells().length);
+ }
+
+ protected void setControlContent(String text) {
+ window.getControlContentAdapter().setControlContents(
+ window.getFieldAssistControl(), text, text.length());
+
+ }
+
+ protected String getControlContent() {
+ return window.getControlContentAdapter().getControlContents(
+ window.getFieldAssistControl());
+
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/AbstractFieldAssistWindow.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/AbstractFieldAssistWindow.java
new file mode 100644
index 0000000000..398c0d619b
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/AbstractFieldAssistWindow.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Remy Chi Jian Suen and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * Remy Chi Jian Suen <remy.suen@gmail.com> - initial API and implementation
+ * IBM - ongoing development
+ ******************************************************************************/
+package org.eclipse.jface.tests.fieldassist;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.IContentProposalProvider;
+import org.eclipse.jface.fieldassist.IControlContentAdapter;
+import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Shell;
+
+public abstract class AbstractFieldAssistWindow extends Window {
+
+ private Control fieldAssistControl;
+
+ private IContentProposalProvider proposalProvider;
+ private KeyStroke keyStroke = null;
+ private char[] autoActivationCharacters = null;
+ private int filterStyle = ContentProposalAdapter.FILTER_NONE;
+ private boolean propagateKeys = true;
+ private int acceptance = ContentProposalAdapter.PROPOSAL_INSERT;
+ private int autoActivationDelay = 0;
+ private ContentProposalAdapter adapter;
+
+ public AbstractFieldAssistWindow() {
+ super((Shell) null);
+ }
+
+ public Display getDisplay() {
+ return getShell().getDisplay();
+ }
+
+ protected Control createContents(Composite parent) {
+ Composite content = (Composite) super.createContents(parent);
+ content.setLayout(new FillLayout());
+
+ fieldAssistControl = createFieldAssistControl(parent);
+ Assert.isNotNull(fieldAssistControl);
+
+ adapter = createContentProposalAdapter(fieldAssistControl);
+ adapter.setAutoActivationDelay(autoActivationDelay);
+ adapter.setFilterStyle(filterStyle);
+ adapter.setPropagateKeys(propagateKeys);
+ adapter.setProposalAcceptanceStyle(acceptance);
+
+ createExtraControls(parent);
+
+ return content;
+ }
+
+ protected void createExtraControls(Composite parent) {
+ // default is to do nothing
+ }
+
+ protected Layout getLayout() {
+ return new FillLayout();
+ }
+
+ /**
+ * Create and return the content proposal adapter that will be used by this
+ * field assist window.
+ *
+ * @param control
+ * the SWT control to provide field assist for
+ */
+ protected ContentProposalAdapter createContentProposalAdapter(
+ Control control) {
+ return new ContentProposalAdapter(control, getControlContentAdapter(),
+ getContentProposalProvider(), getKeyStroke(),
+ getAutoActivationCharacters());
+ }
+
+ protected abstract IControlContentAdapter getControlContentAdapter();
+
+ public Control getFieldAssistControl() {
+ return fieldAssistControl;
+ }
+
+ protected abstract Control createFieldAssistControl(Composite parent);
+
+ public void setAutoActivationDelay(int autoActivationDelay) {
+ this.autoActivationDelay = autoActivationDelay;
+ }
+
+ public final int getAutoActivationDelay() {
+ return autoActivationDelay;
+ }
+
+ protected boolean shouldFilterProposals() {
+ return true;
+ }
+
+ protected String[] getProposals() {
+ return new String[] { "one", "two", "three", "four", "five", "six",
+ "seven", "eight", "nine", "ten" };
+ }
+
+ protected char[] getAutoActivationCharacters() {
+ return autoActivationCharacters;
+ }
+
+ public void setAutoActivationCharacters(char[] autoActivationCharacters) {
+ this.autoActivationCharacters = autoActivationCharacters;
+ }
+
+ protected IContentProposalProvider createContentProposalProvider() {
+ SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(
+ getProposals());
+ proposalProvider.setFiltering(shouldFilterProposals());
+ return proposalProvider;
+ }
+
+ protected IContentProposalProvider getContentProposalProvider() {
+ if (proposalProvider == null) {
+ proposalProvider = createContentProposalProvider();
+ }
+ return proposalProvider;
+ }
+
+ protected ContentProposalAdapter getContentProposalAdapter() {
+ return adapter;
+ }
+
+ public void setContentProposalProvider(
+ IContentProposalProvider proposalProvider) {
+ this.proposalProvider = proposalProvider;
+ }
+
+ public void setFilterStyle(int filterStyle) {
+ this.filterStyle = filterStyle;
+ }
+
+ public void setPropagateKeys(boolean propagateKeys) {
+ this.propagateKeys = propagateKeys;
+ }
+
+ public void setProposalAcceptanceStyle(int acceptance) {
+ this.acceptance = acceptance;
+ }
+
+ protected KeyStroke getKeyStroke() {
+ return keyStroke;
+ }
+
+ public void setKeyStroke(KeyStroke keyStroke) {
+ this.keyStroke = keyStroke;
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/ComboFieldAssistTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/ComboFieldAssistTests.java
new file mode 100644
index 0000000000..5eb46594e7
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/ComboFieldAssistTests.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.fieldassist;
+
+/**
+ * @since 3.6
+ *
+ */
+public class ComboFieldAssistTests extends FieldAssistTestCase {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.tests.fieldassist.AbstractFieldAssistTestCase#createFieldAssistWindow()
+ */
+ protected AbstractFieldAssistWindow createFieldAssistWindow() {
+ return new ComboFieldAssistWindow();
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/ComboFieldAssistWindow.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/ComboFieldAssistWindow.java
new file mode 100644
index 0000000000..0ad66168ea
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/ComboFieldAssistWindow.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Remy Chi Jian Suen and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * Remy Chi Jian Suen <remy.suen@gmail.com> - initial API and implementation
+ * IBM - ongoing development
+******************************************************************************/
+package org.eclipse.jface.tests.fieldassist;
+
+import org.eclipse.jface.fieldassist.ComboContentAdapter;
+import org.eclipse.jface.fieldassist.IControlContentAdapter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+public class ComboFieldAssistWindow extends AbstractFieldAssistWindow {
+
+ protected IControlContentAdapter getControlContentAdapter() {
+ return new ComboContentAdapter();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.jface.tests.fieldassist.AbstractFieldAssistWindow#
+ * createFieldAssistControl(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createFieldAssistControl(Composite parent) {
+ return new Combo(parent, SWT.DROP_DOWN);
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/ControlDecorationTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/ControlDecorationTests.java
new file mode 100644
index 0000000000..b7ceed4a91
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/ControlDecorationTests.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jface.tests.fieldassist;
+
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+public class ControlDecorationTests extends AbstractFieldAssistTestCase {
+
+ private Text anotherControl;
+
+ public void testDecorationIsVisible() {
+ AbstractFieldAssistWindow window = getFieldAssistWindow();
+ window.open();
+ ControlDecoration decoration = new ControlDecoration(getFieldAssistWindow().getFieldAssistControl(), SWT.RIGHT);
+ decoration.setImage(FieldDecorationRegistry.getDefault()
+ .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
+ decoration.setDescriptionText("foo");
+ window.open();
+ assertTrue("1.0", decoration.isVisible());
+ decoration.hide();
+ assertFalse("1.1", decoration.isVisible());
+ decoration.show();
+ assertTrue("1.2", decoration.isVisible());
+ window.getFieldAssistControl().setVisible(false);
+ assertFalse("1.3", decoration.isVisible());
+ window.getFieldAssistControl().setVisible(true);
+ assertTrue("1.4", decoration.isVisible());
+
+ // focus related tests. Comment out for now.
+ // see bug 275393
+ decoration.setShowOnlyOnFocus(true);
+ anotherControl.setFocus();
+ spinEventLoop();
+
+ /*
+ assertFalse("1.5", decoration.isVisible());
+ window.getFieldAssistControl().setFocus();
+ spinEventLoop();
+ assertTrue("1.6", decoration.isVisible());
+ decoration.setShowOnlyOnFocus(false);
+ */
+
+ }
+
+// public void testHoverVisibility() {
+// AbstractFieldAssistWindow window = getFieldAssistWindow();
+// window.open();
+// ControlDecoration decoration = new ControlDecoration(window.getFieldAssistControl(), SWT.RIGHT);
+// decoration.setImage(FieldDecorationRegistry.getDefault()
+// .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
+// decoration.setDescriptionText("foo");
+// assertTrue("1.0", decoration.isVisible());
+// assertOneShellUp();
+// decoration.hide();
+// decoration.showHoverText("Show me");
+// assertOneShellUp(); // because the decoration is hidden;
+// decoration.show();
+// getFieldAssistWindow().getFieldAssistControl().setVisible(false);
+// decoration.showHoverText("Show me");
+// assertOneShellUp(); // because the control is hidden, bug 295386
+// getFieldAssistWindow().getFieldAssistControl().setVisible(true);
+// decoration.showHoverText("Show me");
+// assertTwoShellsUp();
+// }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.tests.fieldassist.AbstractFieldAssistTestCase#createFieldAssistWindow()
+ */
+ protected AbstractFieldAssistWindow createFieldAssistWindow() {
+ return new TextFieldAssistWindow() {
+ protected void createExtraControls(Composite parent) {
+ anotherControl = new Text(parent, SWT.DEFAULT);
+ }
+ };
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/FieldAssistAPITests.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/FieldAssistAPITests.java
new file mode 100644
index 0000000000..59d18671a6
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/FieldAssistAPITests.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jface.tests.fieldassist;
+
+import org.eclipse.jface.fieldassist.ContentProposal;
+import org.eclipse.jface.fieldassist.IContentProposal;
+
+public class FieldAssistAPITests extends AbstractFieldAssistTestCase {
+
+ public void testSimpleContentProposal() {
+ String content = "Name";
+ String label = "LabelForName";
+ String description = "Description";
+ IContentProposal proposal = new ContentProposal(content);
+ assertEquals("1.0", content, proposal.getContent());
+ assertEquals("1.1", content, proposal.getLabel());
+ assertNull("1.2", proposal.getDescription());
+ assertEquals("1.3", content.length(), proposal.getCursorPosition());
+ proposal = new ContentProposal(content, description);
+ assertEquals("2.0", content, proposal.getContent());
+ assertEquals("2.1", content, proposal.getLabel());
+ assertEquals("2.2", description, proposal.getDescription());
+ assertEquals("2.3", content.length(), proposal.getCursorPosition());
+ proposal = new ContentProposal(content, label, description);
+ assertEquals("3.0", content, proposal.getContent());
+ assertEquals("3.1", label, proposal.getLabel());
+ assertEquals("3.2", description, proposal.getDescription());
+ assertEquals("3.3", content.length(), proposal.getCursorPosition());
+ proposal = new ContentProposal(content, label, description, 3);
+ assertEquals("3.0", content, proposal.getContent());
+ assertEquals("3.1", label, proposal.getLabel());
+ assertEquals("3.2", description, proposal.getDescription());
+ assertEquals("3.3", 3, proposal.getCursorPosition());
+ try {
+ proposal = new ContentProposal(content, label, description, 100);
+ fail("4.0");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.tests.fieldassist.AbstractFieldAssistTestCase#createFieldAssistWindow()
+ */
+ protected AbstractFieldAssistWindow createFieldAssistWindow() {
+ return new TextFieldAssistWindow();
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/FieldAssistTestCase.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/FieldAssistTestCase.java
new file mode 100644
index 0000000000..1cc5c490dd
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/FieldAssistTestCase.java
@@ -0,0 +1,281 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jface.tests.fieldassist;
+
+//import org.eclipse.jface.bindings.keys.KeyStroke;
+//import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.swt.SWT;
+//import org.eclipse.swt.graphics.Rectangle;
+//import org.eclipse.swt.widgets.Display;
+//import org.eclipse.swt.widgets.Event;
+//import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This class contains test cases appropriate for generic field assist
+ * tests in various controls. Tests that are not appropriate for the
+ * pre-configured content assist command adapter should go here.
+ *
+ * @since 3.6
+ *
+ */
+public abstract class FieldAssistTestCase extends AbstractFieldAssistTestCase {
+ static final String SAMPLE_CONTENT = "s";
+ static final char ACTIVATE_CHAR = 'i';
+ static final char EXTRA_CHAR = 'b';
+
+// public void testAutoactivateNoDelay() {
+// AbstractFieldAssistWindow window = getFieldAssistWindow();
+// window.setPropagateKeys(false);
+// window.setAutoActivationDelay(0);
+// window.setAutoActivationCharacters(new char [] {ACTIVATE_CHAR});
+// window.open();
+// setControlContent(SAMPLE_CONTENT);
+// sendKeyDownToControl(ACTIVATE_CHAR);
+// ensurePopupIsUp();
+// assertTwoShellsUp();
+// }
+//
+// public void testAutoactivateWithDelay() {
+// AbstractFieldAssistWindow window = getFieldAssistWindow();
+// window.setPropagateKeys(false);
+// window.setAutoActivationDelay(600);
+// window.setAutoActivationCharacters(new char [] {ACTIVATE_CHAR});
+// window.open();
+// setControlContent(SAMPLE_CONTENT);
+// sendKeyDownToControl(ACTIVATE_CHAR);
+// ensurePopupIsUp();
+// assertTwoShellsUp();
+// }
+//
+// public void testExplicitActivate() {
+// AbstractFieldAssistWindow window = getFieldAssistWindow();
+// window.setPropagateKeys(false);
+// KeyStroke stroke = KeyStroke.getInstance(SWT.F4);
+// window.setKeyStroke(stroke);
+// window.open();
+// sendKeyDownToControl(stroke);
+// assertTwoShellsUp();
+// }
+//
+// public void testPopupDeactivates() {
+// AbstractFieldAssistWindow window = getFieldAssistWindow();
+// window.setPropagateKeys(false);
+// window.setAutoActivationDelay(0);
+// window.setAutoActivationCharacters(new char [] {ACTIVATE_CHAR});
+// window.open();
+// setControlContent(SAMPLE_CONTENT);
+// sendKeyDownToControl(ACTIVATE_CHAR);
+// ensurePopupIsUp();
+// assertTwoShellsUp();
+// sendFocusElsewhere();
+// spinEventLoop();
+// assertOneShellUp();
+// }
+//
+// public void testPropagateKeysOff() {
+// AbstractFieldAssistWindow window = getFieldAssistWindow();
+// window.setPropagateKeys(false);
+// window.setAutoActivationCharacters(new char [] {ACTIVATE_CHAR});
+// window.open();
+// setControlContent(SAMPLE_CONTENT);
+// sendKeyDownToControl(ACTIVATE_CHAR);
+// ensurePopupIsUp();
+// assertTwoShellsUp();
+// sendKeyDownToControl(EXTRA_CHAR);
+// assertEquals("1.0", SAMPLE_CONTENT + new String(new char [] {ACTIVATE_CHAR}), getControlContent());
+// }
+//
+// public void testPropagateKeysOn() {
+// AbstractFieldAssistWindow window = getFieldAssistWindow();
+// window.setPropagateKeys(true);
+// window.setAutoActivationCharacters(new char [] {ACTIVATE_CHAR});
+// window.open();
+// setControlContent(SAMPLE_CONTENT);
+// sendKeyDownToControl(ACTIVATE_CHAR);
+// ensurePopupIsUp();
+// assertTwoShellsUp();
+// sendKeyDownToControl(EXTRA_CHAR);
+// assertEquals("1.0", SAMPLE_CONTENT + new String(new char [] {ACTIVATE_CHAR, EXTRA_CHAR}), getControlContent());
+// }
+//
+// public void testBug262022() {
+// AbstractFieldAssistWindow window = getFieldAssistWindow();
+// window.setPropagateKeys(false);
+// window.setAutoActivationCharacters(new char [] {ACTIVATE_CHAR});
+// window.open();
+// setControlContent(SAMPLE_CONTENT);
+// sendKeyDownToControl(ACTIVATE_CHAR);
+// ensurePopupIsUp();
+// assertTwoShellsUp();
+// // cursor key down will cause an asyncExec that recomputes proposals. Before we process the event, let's
+// // kill the window in an async. That should cause the event to be processed and then the window killed before
+// // the subsequent async.
+// Event event = new Event();
+// event.type = SWT.KeyDown;
+// event.keyCode = SWT.ARROW_LEFT;
+// window.getDisplay().post(event);
+// window.getDisplay().asyncExec(new Runnable() {
+// public void run() {
+// closeFieldAssistWindow();
+// }
+// });
+// spinEventLoop();
+// }
+//
+// public void testBug279953() {
+// AbstractFieldAssistWindow window = getFieldAssistWindow();
+// window.setPropagateKeys(false);
+// window.setAutoActivationCharacters(new char [] {ACTIVATE_CHAR});
+// window.open();
+// assertOneShellUp();
+// ControlDecoration decoration = new ControlDecoration(getFieldAssistWindow().getFieldAssistControl(), SWT.RIGHT);
+// decoration.setImage(FieldDecorationRegistry.getDefault()
+// .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
+// decoration.setDescriptionText("");
+// decoration.showHoverText("");
+// assertOneShellUp();
+// }
+
+ public void testDecorationIsVisible() {
+ AbstractFieldAssistWindow window = getFieldAssistWindow();
+ window.setPropagateKeys(false);
+ window.setAutoActivationCharacters(new char [] {ACTIVATE_CHAR});
+ window.open();
+ assertOneShellUp();
+ ControlDecoration decoration = new ControlDecoration(getFieldAssistWindow().getFieldAssistControl(), SWT.RIGHT);
+ decoration.setImage(FieldDecorationRegistry.getDefault()
+ .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
+ decoration.setDescriptionText("foo");
+ spinEventLoop();
+ assertTrue("1.0", decoration.isVisible());
+ decoration.hide();
+ assertFalse("1.1", decoration.isVisible());
+ decoration.setShowOnlyOnFocus(true);
+ sendFocusElsewhere();
+ sendFocusInToControl();
+ spinEventLoop();
+ assertFalse("1.2", decoration.isVisible());
+ decoration.show();
+ assertTrue("1.3", decoration.isVisible());
+ sendFocusElsewhere();
+ spinEventLoop();
+ assertFalse("1.4", decoration.isVisible());
+ decoration.setShowOnlyOnFocus(false);
+ assertTrue("1.5", decoration.isVisible());
+ window.getFieldAssistControl().setVisible(false);
+ assertFalse("1.6", decoration.isVisible());
+ decoration.hide();
+ window.getFieldAssistControl().setVisible(true);
+ assertFalse("1.7", decoration.isVisible());
+ decoration.show();
+ assertTrue("1.8", decoration.isVisible());
+ }
+
+// public void testPopupFocus() {
+// AbstractFieldAssistWindow window = getFieldAssistWindow();
+// window.setPropagateKeys(false);
+// KeyStroke stroke = KeyStroke.getInstance(SWT.F4);
+// window.setKeyStroke(stroke);
+// window.open();
+// sendKeyDownToControl(stroke);
+// assertTwoShellsUp();
+//
+// // Send focus to the control (not the popup)
+// window.getFieldAssistControl().setFocus();
+// spinEventLoop();
+// assertFalse("1.0", window.getContentProposalAdapter().hasProposalPopupFocus());
+// window.getContentProposalAdapter().setProposalPopupFocus();
+// spinEventLoop();
+// assertTrue("1.1", window.getContentProposalAdapter().hasProposalPopupFocus());
+//
+// // Setting focus to another shell deactivates the popup
+// sendFocusElsewhere();
+// spinEventLoop();
+// assertOneShellUp();
+// assertFalse("1.2", window.getContentProposalAdapter().hasProposalPopupFocus());
+// }
+//
+// public void testPopupIsOpen() {
+// AbstractFieldAssistWindow window = getFieldAssistWindow();
+// window.setPropagateKeys(false);
+// KeyStroke stroke = KeyStroke.getInstance(SWT.F4);
+// window.setKeyStroke(stroke);
+// window.open();
+//
+// assertFalse("1.0", window.getContentProposalAdapter().isProposalPopupOpen());
+// sendKeyDownToControl(stroke);
+// assertTwoShellsUp();
+// assertTrue("1.1", window.getContentProposalAdapter().isProposalPopupOpen());
+//
+// // Setting focus to another shell deactivates the popup
+// sendFocusElsewhere();
+// spinEventLoop();
+// assertOneShellUp();
+// assertFalse("1.2", window.getContentProposalAdapter().isProposalPopupOpen());
+// }
+//
+// /**
+// * Replace mode is easier to test because we can check that the bounds
+// * does not intersect the control. In insertion mode, the popup is
+// * supposed to overlap the control (using the insertion cursor to track
+// * position).
+// */
+// public void testBug256651ReplaceMode() {
+// AbstractFieldAssistWindow window = getFieldAssistWindow();
+// window.setPropagateKeys(false);
+// window.setAutoActivationCharacters(new char [] {ACTIVATE_CHAR});
+// window.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
+// window.open();
+// Display display = getDisplay();
+// Rectangle displayBounds = display.getBounds();
+// window.getShell().setLocation(0, displayBounds.height - window.getShell().getBounds().height);
+// assertOneShellUp();
+// setControlContent(SAMPLE_CONTENT);
+// sendKeyDownToControl(ACTIVATE_CHAR);
+// ensurePopupIsUp();
+// assertTwoShellsUp();
+// sendFocusToPopup();
+// Shell popupShell = display.getActiveShell();
+// Rectangle popupBounds = popupShell.getBounds();
+// Rectangle controlBounds = getFieldAssistWindow().getFieldAssistControl().getBounds();
+// controlBounds = getDisplay().map(getFieldAssistWindow().getFieldAssistControl().getParent(), null, controlBounds);
+// assertFalse("Popup is blocking the control", popupBounds.intersects(controlBounds));
+// }
+//
+// /**
+// * Replace mode is easier to test because we can check that the bounds
+// * does not intersect the control. In insertion mode, the popup is
+// * supposed to overlap the control (using the insertion cursor to track
+// * position).
+// */
+// public void testDefaultPopupPositioningReplaceMode() {
+// AbstractFieldAssistWindow window = getFieldAssistWindow();
+// window.setPropagateKeys(false);
+// window.setAutoActivationCharacters(new char [] {ACTIVATE_CHAR});
+// window.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
+// window.open();
+// Display display = getDisplay();
+// window.getShell().setLocation(0, 0);
+// assertOneShellUp();
+// setControlContent(SAMPLE_CONTENT);
+// sendKeyDownToControl(ACTIVATE_CHAR);
+// ensurePopupIsUp();
+// assertTwoShellsUp();
+// sendFocusToPopup();
+// Shell popupShell = display.getActiveShell();
+// Rectangle popupBounds = popupShell.getBounds();
+// Rectangle controlBounds = getFieldAssistWindow().getFieldAssistControl().getBounds();
+// controlBounds = getDisplay().map(getFieldAssistWindow().getFieldAssistControl().getParent(), null, controlBounds);
+// assertFalse("Popup is blocking the control", popupBounds.intersects(controlBounds));
+// }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/FieldAssistTestSuite.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/FieldAssistTestSuite.java
new file mode 100644
index 0000000000..6b841ce8a0
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/FieldAssistTestSuite.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jface.tests.fieldassist;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Tests for the platform operations support.
+ */
+public class FieldAssistTestSuite extends TestSuite {
+ /**
+ * Returns the suite. This is required to use the JUnit Launcher.
+ */
+ public static final Test suite() {
+ return new FieldAssistTestSuite();
+ }
+
+ /**
+ * Construct the test suite.
+ */
+ public FieldAssistTestSuite() {
+ // disabled, see bug 275393...
+ // addTest(new TestSuite(TextFieldAssistTests.class));
+ // addTest(new TestSuite(ComboFieldAssistTests.class));
+ addTest(new TestSuite(ControlDecorationTests.class));
+ addTest(new TestSuite(FieldAssistAPITests.class));
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/TextFieldAssistTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/TextFieldAssistTests.java
new file mode 100644
index 0000000000..9a31e59349
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/TextFieldAssistTests.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.fieldassist;
+
+/**
+ * @since 3.6
+ *
+ */
+public class TextFieldAssistTests extends FieldAssistTestCase {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.tests.fieldassist.AbstractFieldAssistTestCase#createFieldAssistWindow()
+ */
+ protected AbstractFieldAssistWindow createFieldAssistWindow() {
+ return new TextFieldAssistWindow();
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/TextFieldAssistWindow.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/TextFieldAssistWindow.java
new file mode 100644
index 0000000000..6a27dc177e
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/fieldassist/TextFieldAssistWindow.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Remy Chi Jian Suen and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * Remy Chi Jian Suen <remy.suen@gmail.com> - initial API and implementation
+ * IBM - ongoing development
+ ******************************************************************************/
+package org.eclipse.jface.tests.fieldassist;
+
+import org.eclipse.jface.fieldassist.IControlContentAdapter;
+import org.eclipse.jface.fieldassist.TextContentAdapter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+
+public class TextFieldAssistWindow extends AbstractFieldAssistWindow {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.jface.tests.fieldassist.AbstractFieldAssistWindow#
+ * createFieldAssistControl(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createFieldAssistControl(Composite parent) {
+ return new Text(parent, SWT.SINGLE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.tests.fieldassist.AbstractFieldAssistWindow#getControlContentAdapter()
+ */
+ protected IControlContentAdapter getControlContentAdapter() {
+ return new TextContentAdapter();
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTests.java
index 145a57d545..9485000eb9 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTests.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTests.java
@@ -29,5 +29,7 @@ public class DecoratingLabelProviderTests extends TestSuite {
addTestSuite(DecoratingLabelProviderTreeTest.class);
addTestSuite(ColorAndFontLabelProviderTest.class);
addTestSuite(ColorAndFontViewerLabelProviderTest.class);
+// addTestSuite(DecoratingStyledCellLabelProviderTest.class);
+// addTestSuite(IDecorationContextTest.class);
}
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingStyledCellLabelProviderTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingStyledCellLabelProviderTest.java
new file mode 100644
index 0000000000..556b269d30
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingStyledCellLabelProviderTest.java
@@ -0,0 +1,667 @@
+///*******************************************************************************
+// * Copyright (c) 2008, 2009 IBM Corporation and others.
+// * All rights reserved. This program and the accompanying materials
+// * are 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
+// *
+// * Contributors:
+// * IBM Corporation - initial API and implementation
+// ******************************************************************************/
+//
+//package org.eclipse.jface.tests.labelProviders;
+//
+//import org.eclipse.core.runtime.AssertionFailedException;
+//import org.eclipse.jface.resource.JFaceResources;
+//import org.eclipse.jface.tests.viewers.ViewerTestCase;
+//import org.eclipse.jface.viewers.CellLabelProvider;
+//import org.eclipse.jface.viewers.ColumnPixelData;
+//import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
+//import org.eclipse.jface.viewers.IColorDecorator;
+//import org.eclipse.jface.viewers.IDecorationContext;
+//import org.eclipse.jface.viewers.IFontProvider;
+//import org.eclipse.jface.viewers.ILabelDecorator;
+//import org.eclipse.jface.viewers.ILabelProviderListener;
+//import org.eclipse.jface.viewers.IStructuredContentProvider;
+//import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+//import org.eclipse.jface.viewers.StructuredSelection;
+//import org.eclipse.jface.viewers.StructuredViewer;
+//import org.eclipse.jface.viewers.StyledString;
+//import org.eclipse.jface.viewers.TableLayout;
+//import org.eclipse.jface.viewers.TableViewer;
+//import org.eclipse.jface.viewers.ViewerCell;
+//import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+//import org.eclipse.swt.SWT;
+//import org.eclipse.swt.graphics.Color;
+//import org.eclipse.swt.graphics.Font;
+//import org.eclipse.swt.graphics.Image;
+//import org.eclipse.swt.graphics.Rectangle;
+//import org.eclipse.swt.graphics.TextLayout;
+//import org.eclipse.swt.graphics.TextStyle;
+//import org.eclipse.swt.layout.GridData;
+//import org.eclipse.swt.widgets.Composite;
+//import org.eclipse.swt.widgets.Display;
+//import org.eclipse.swt.widgets.Event;
+//import org.eclipse.swt.widgets.Table;
+//import org.eclipse.swt.widgets.TableColumn;
+//
+///**
+// * Most of the setup has been taken from
+// * org.eclipse.jface.snippets.viewers.Snippet010OwnerDraw.java
+// *
+// * @since 3.4
+// *
+// */
+//public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
+//
+// // static ResourceManager resourceManager = PlatformUI.getWorkbench().
+// private class TestCellLabelProvider extends CellLabelProvider implements
+// IStyledLabelProvider, IFontProvider {
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
+// */
+// public void update(ViewerCell cell) {
+// Object element = cell.getElement();
+// cell.setText((element == null) ? "" : element.toString());
+// cell.setImage(getImage(element));
+// cell.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT));
+// cell.setForeground(cell.getControl().getDisplay().getSystemColor(
+// SWT.COLOR_BLUE));
+// cell.setBackground(cell.getControl().getDisplay().getSystemColor(
+// SWT.COLOR_RED));
+// }
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getImage(java.lang.Object)
+// */
+// public Image getImage(Object element) {
+// // create a resource manager that holds onto images
+// // OR create image set, dispose in teardown
+//
+// return fViewer.getControl().getDisplay().getSystemImage(
+// SWT.ICON_WARNING);
+// }
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
+// */
+// public StyledString getStyledText(Object element) {
+// return new StyledString(element.toString(),
+// StyledString.COUNTER_STYLER);
+// }
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
+// */
+// public Font getFont(Object element) {
+// return JFaceResources.getFont(JFaceResources.BANNER_FONT);
+// }
+//
+// }
+//
+// private class TestLabelDecorator implements ILabelDecorator,
+// IColorDecorator {
+//
+// public Image decorateImage(Image image, Object element) {
+// return image;
+// }
+//
+// public String decorateText(String text, Object element) {
+// return text;
+// }
+//
+// public void addListener(ILabelProviderListener listener) {
+// }
+//
+// public void dispose() {
+// }
+//
+// public boolean isLabelProperty(Object element, String property) {
+// return false;
+// }
+//
+// public void removeListener(ILabelProviderListener listener) {
+// }
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.jface.viewers.IColorDecorator#decorateBackground(java.lang.Object)
+// */
+// public Color decorateBackground(Object element) {
+// return fViewer.getControl().getDisplay().getSystemColor(
+// SWT.COLOR_RED);
+// }
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.jface.viewers.IColorDecorator#decorateForeground(java.lang.Object)
+// */
+// public Color decorateForeground(Object element) {
+// return fViewer.getControl().getDisplay().getSystemColor(
+// SWT.COLOR_BLUE);
+// }
+// }
+//
+// private CountryEntry[] entries;
+// protected String changeMe = "OLD";
+// private static int COLUMN_COUNT = 3;
+//
+// public DecoratingStyledCellLabelProviderTest(String name) {
+// super(name);
+// entries = new CountryEntry[3];
+// entries[0] = new AustriaEntry();
+// entries[1] = new GermanyEntry();
+// entries[2] = new EnglandEntry();
+// }
+//
+// protected StructuredViewer createViewer(Composite parent) {
+// TableViewer viewer = new TableViewer(parent, SWT.FULL_SELECTION);
+//
+// viewer.setContentProvider(new IStructuredContentProvider() {
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+// */
+// public void dispose() {
+// };
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+// */
+// public Object[] getElements(Object inputElement) {
+// return entries;
+// };
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
+// * java.lang.Object, java.lang.Object)
+// */
+// public void inputChanged(org.eclipse.jface.viewers.Viewer viewer,
+// Object oldInput, Object newInput) {
+// }
+//
+// });
+// createColumns(viewer);
+// viewer.setLabelProvider(createLabelProvider());
+//
+// GridData data = new GridData(GridData.GRAB_HORIZONTAL
+// | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
+//
+// viewer.getControl().setLayoutData(data);
+// viewer.setSelection(new StructuredSelection(entries[1]));
+//
+// return viewer;
+// }
+//
+// /**
+// * @return {@link DecoratingStyledCellLabelProvider}
+// */
+// private DecoratingStyledCellLabelProvider createLabelProvider() {
+// return new DecoratingStyledCellLabelProvider(
+// new TestCellLabelProvider(), getDecorator(), getContext());
+// }
+//
+// /**
+// * @return
+// */
+// private IDecorationContext getContext() {
+// return new IDecorationContext() {
+//
+// public String[] getProperties() {
+// return null;
+// }
+//
+// public Object getProperty(String property) {
+// return null;
+// }
+// };
+// }
+//
+// /**
+// * @return
+// */
+// private ILabelDecorator getDecorator() {
+// return new TestLabelDecorator();
+// }
+//
+// private ILabelProviderListener getListener() {
+// return new ILabelProviderListener() {
+//
+// public void labelProviderChanged(LabelProviderChangedEvent event) {
+// changeMe = "been changed";
+// }
+// };
+// }
+//
+// /**
+// * Create the columns to be used in the tree.
+// */
+// private void createColumns(TableViewer viewer) {
+// TableLayout layout = new TableLayout();
+// Table table = viewer.getTable();
+// table.setLayout(layout);
+// table.setHeaderVisible(true);
+// table.setLinesVisible(true);
+//
+// for (int i = 0; i < COLUMN_COUNT; i++) {
+// TableColumn tc = new TableColumn(table, SWT.NONE, i);
+// layout.addColumnData(new ColumnPixelData(100));
+// tc.setText(getTitleFor(i));
+// }
+// }
+//
+// protected void setInput() {
+// fViewer.setInput(this);
+// }
+//
+// // the tests
+// public void testGetDecorationContext() {
+// assertNotNull(getDecoratingStyledLabelProvider().getDecorationContext());
+// }
+//
+// public void testSetDecorationContext() {
+// try {
+// getDecoratingStyledLabelProvider().setDecorationContext(null);
+// fail("DecoratingStyledCellLabelProvider.setDecorationContext did not throw an exception when passed null");
+// } catch (AssertionFailedException e) {
+// // A Good Thing.
+// }
+// }
+//
+// public void testUpdate() {
+// Table table = ((TableViewer) fViewer).getTable();
+// String before = table.getItem(0).toString();
+// entries[0].name = "Updated";
+// fViewer.refresh();
+// assertNotSame(before, table.getItem(0).toString());
+// }
+//
+// public void testGetForeground() {
+// // TODO: Incomplete test
+// // fViewer.getControl().getShell().setFocus();
+// //
+// // long stopTime = System.currentTimeMillis() + 1000;
+// // while (stopTime < System.currentTimeMillis()) {
+// // Display.getCurrent().readAndDispatch();
+// // }
+// //
+// // Table table = ((TableViewer) fViewer).getTable();
+// //
+// // TableItem ti = table.getItem(0);
+// //
+// // Color widget = ti.getForeground();
+// // assertEquals(widget,
+// // getDecoratingStyledLabelProvider().getForeground(
+// // ti));
+// }
+//
+// public void testGetBackground() {
+// // TODO: Incomplete test
+//
+// // Table table = ((TableViewer) fViewer).getTable();
+// // TableItem ti = table.getItem(0);
+// // Color d = ((DecoratingStyledCellLabelProvider) ((TableViewer)
+// // fViewer)
+// // .getLabelProvider(0)).getBackground(ti);
+// // assertEquals(d,
+// // getDecoratingStyledLabelProvider().getBackground(ti));
+// }
+//
+// public void testGetFont() {
+// // TODO: Incomplete test
+//
+// // Table table = ((TableViewer) fViewer).getTable();
+// // TableItem ti = table.getItem(0);
+//
+// // assertEquals(f, getDecoratingStyledLabelProvider().getFont(ti));
+// }
+//
+// public void testGetImage() {
+// Table table = ((TableViewer) fViewer).getTable();
+//
+// assertEquals(table.getItem(0).getImage(),
+// getDecoratingStyledLabelProvider().getImage(table.getItem(0)));
+//
+// }
+//
+// public void testGetLabelDecorator() {
+// assertNotNull(getDecoratingStyledLabelProvider().getLabelDecorator());
+//
+// getDecoratingStyledLabelProvider().setLabelDecorator(null);
+// assertNull(getDecoratingStyledLabelProvider().getLabelDecorator());
+// }
+//
+// public void testSetLabelDecorator() {
+// ILabelDecorator labelDecorator = getDecorator();
+// getDecoratingStyledLabelProvider().setLabelDecorator(labelDecorator);
+// assertEquals(labelDecorator, getDecoratingStyledLabelProvider()
+// .getLabelDecorator());
+//
+// }
+//
+// public void testAddListener() {
+// String old = changeMe; // String will change because the listener will
+// // be listening for it
+// ILabelProviderListener listener = getListener();
+// getDecoratingStyledLabelProvider().addListener(listener);
+// getDecoratingStyledLabelProvider().setLabelDecorator(getDecorator());
+// assertNotSame(old, changeMe);
+// }
+//
+// public void testRemoveListener() {
+// String old = changeMe = "OLD";
+// ILabelProviderListener listener = getListener();
+// getDecoratingStyledLabelProvider().addListener(listener);
+// getDecoratingStyledLabelProvider().removeListener(listener);
+// getDecoratingStyledLabelProvider().setLabelDecorator(getDecorator());
+// assertEquals(old, changeMe);
+// }
+//
+// public void testIsLabelProperty() {
+// boolean check = getDecoratingStyledLabelProvider().isLabelProperty(
+// "element", "property");
+// assertTrue(check);
+// }
+//
+// public void testDispose() {
+// fShell.dispose();
+// assertFalse(fViewer.getLabelProvider() instanceof DecoratingStyledCellLabelProvider);
+// // the viewer will return a new LabelProvider if the current is null
+// }
+//
+// /**
+// * @return Returns the {@link DecoratingStyledCellLabelProvider} used for
+// * this test
+// */
+// private DecoratingStyledCellLabelProvider getDecoratingStyledLabelProvider() {
+// return ((DecoratingStyledCellLabelProvider) fViewer.getLabelProvider());
+// }
+//
+// class CountryEntry {
+//
+// String name;
+//
+// String cupYear;
+//
+// private String baseName;
+//
+// /**
+// * Create a new instance of the receiver.
+// *
+// * @param countryName
+// * @param worldCupYear
+// */
+// CountryEntry(String countryName, String englishName, String worldCupYear) {
+// name = countryName;
+// cupYear = worldCupYear;
+// baseName = englishName;
+// }
+//
+// public String toString() {
+// return name + " " + cupYear + " " + baseName;
+// }
+//
+// /**
+// * @param index
+// * @return
+// */
+// public int getHeight(Event event) {
+// switch (event.index) {
+// case 0:
+// return event.gc.textExtent(name).y;
+// case 1:
+// return 50;
+// case 2:
+// return event.gc.textExtent(cupYear).y;
+// default:
+// return 10;
+// }
+// }
+//
+// /**
+// * @param index
+// * @return
+// */
+// public int getWidth(Event event) {
+//
+// switch (event.index) {
+// case 0:
+// return event.gc.textExtent(getDisplayString().toString()).x + 4;
+//
+// case 1:
+// return 200;
+//
+// case 2:
+// return event.gc.textExtent(cupYear).x + 5;
+//
+// default:
+// return 10;
+// }
+// }
+//
+// /**
+// * Draw the flag in bounds.
+// *
+// * @param event
+// */
+// protected void drawFlag(Event event) {
+// event.gc.setBackground(fViewer.getControl().getDisplay()
+// .getSystemColor(SWT.COLOR_BLUE));
+//
+// Rectangle bounds = event.getBounds();
+// bounds.width += 100;
+// event.gc.fillRectangle(bounds);
+// }
+//
+// /**
+// * Draw the cup year
+// *
+// * @param event
+// */
+// private void drawCupYear(Event event) {
+// event.gc.drawText(cupYear, event.x, event.y);
+//
+// }
+//
+// /**
+// * Draw the name of the receiver.
+// *
+// * @param event
+// */
+// protected void drawName(Event event) {
+//
+// StringBuffer buffer = getDisplayString();
+//
+// Display display = fViewer.getControl().getDisplay();
+// TextLayout layout = new TextLayout(display);
+// layout.setText(buffer.toString());
+//
+// TextStyle plain = new TextStyle(JFaceResources
+// .getFont(JFaceResources.DEFAULT_FONT), display
+// .getSystemColor(SWT.COLOR_LIST_FOREGROUND), display
+// .getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+//
+// TextStyle italic = new TextStyle(JFaceResources.getFontRegistry()
+// .getItalic(JFaceResources.DEFAULT_FONT), display
+// .getSystemColor(SWT.COLOR_BLUE), display
+// .getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+//
+// layout.setStyle(plain, 0, name.length() - 1);
+// layout.setStyle(italic, name.length(), buffer.length() - 1);
+//
+// layout.draw(event.gc, event.x, event.y);
+//
+// layout.dispose();
+//
+// }
+//
+// /**
+// * @return
+// */
+// private StringBuffer getDisplayString() {
+// StringBuffer buffer = new StringBuffer();
+// buffer.append(name);
+// buffer.append(" (");
+// buffer.append(baseName);
+// buffer.append(")");
+// return buffer;
+// }
+//
+// /**
+// * @param event
+// */
+// public void draw(Event event) {
+//
+// switch (event.index) {
+// case 0:
+// drawName(event);
+// break;
+// case 1:
+// drawFlag(event);
+// break;
+// case 2:
+// drawCupYear(event);
+// break;
+//
+// default:
+// break;
+// }
+//
+// }
+// }
+//
+// private class GermanyEntry extends CountryEntry {
+//
+// GermanyEntry() {
+// super("Deutschland", "Germany", "1990");
+// }
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.jface.tests.viewers.OwnerDrawExample.CountryEntry#drawFlag(org.eclipse.swt.widgets.Event)
+// */
+// protected void drawFlag(Event event) {
+//
+// Rectangle bounds = event.getBounds();
+// bounds.width += 100;
+// int stripeHeight = bounds.height / 3;
+// Rectangle stripe = new Rectangle(bounds.x, bounds.y, bounds.width,
+// stripeHeight);
+//
+// event.gc.setBackground(fViewer.getControl().getDisplay()
+// .getSystemColor(SWT.COLOR_BLACK));
+// event.gc.fillRectangle(stripe);
+//
+// stripe.y += stripeHeight;
+//
+// event.gc.setBackground(fViewer.getControl().getDisplay()
+// .getSystemColor(SWT.COLOR_YELLOW));
+// event.gc.fillRectangle(stripe);
+//
+// stripe.y += stripeHeight;
+//
+// event.gc.setBackground(fViewer.getControl().getDisplay()
+// .getSystemColor(SWT.COLOR_RED));
+// event.gc.fillRectangle(stripe);
+//
+// }
+//
+// }
+//
+// private class AustriaEntry extends CountryEntry {
+//
+// AustriaEntry() {
+// super("\u00D6sterreich", "Austria", "TBD");
+// }
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.jface.tests.viewers.OwnerDrawExample.CountryEntry#drawFlag(org.eclipse.swt.widgets.Event)
+// */
+// protected void drawFlag(Event event) {
+//
+// Rectangle bounds = event.getBounds();
+// bounds.width += 100;
+// int stripeHeight = bounds.height / 3;
+// Rectangle stripe = new Rectangle(bounds.x, bounds.y, bounds.width,
+// stripeHeight);
+//
+// event.gc.setBackground(fViewer.getControl().getDisplay()
+// .getSystemColor(SWT.COLOR_RED));
+// event.gc.fillRectangle(stripe);
+//
+// stripe.y += stripeHeight;
+//
+// event.gc.setBackground(fViewer.getControl().getDisplay()
+// .getSystemColor(SWT.COLOR_WHITE));
+// event.gc.fillRectangle(stripe);
+//
+// stripe.y += stripeHeight;
+//
+// event.gc.setBackground(fViewer.getControl().getDisplay()
+// .getSystemColor(SWT.COLOR_RED));
+// event.gc.fillRectangle(stripe);
+//
+// }
+// }
+//
+// private class EnglandEntry extends CountryEntry {
+// EnglandEntry() {
+// super("Blighty", "England", "1966");
+// }
+//
+// /*
+// * (non-Javadoc)
+// *
+// * @see org.eclipse.jface.tests.viewers.OwnerDrawExample.CountryEntry#drawFlag(org.eclipse.swt.widgets.Event)
+// */
+// protected void drawFlag(Event event) {
+//
+// Rectangle bounds = event.getBounds();
+// bounds.width += 100;
+//
+// event.gc.setBackground(fViewer.getControl().getDisplay()
+// .getSystemColor(SWT.COLOR_RED));
+// event.gc.fillRectangle(new Rectangle(bounds.width / 2 + bounds.x
+// - 5, bounds.y, 10, bounds.height));
+// event.gc.fillRectangle(new Rectangle(bounds.x, bounds.height / 2
+// + bounds.y - 5, bounds.width, 10));
+//
+// }
+// }
+//
+// /**
+// * @param i
+// * @return
+// */
+// private String getTitleFor(int i) {
+// switch (i) {
+// case 0:
+// return "Name";
+// case 1:
+// return "Flag";
+// case 2:
+// return "World Cup Year";
+// }
+// return "Unknown";
+// }
+//
+//}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/IDecorationContextTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/IDecorationContextTest.java
new file mode 100644
index 0000000000..630f42d713
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/IDecorationContextTest.java
@@ -0,0 +1,137 @@
+///*******************************************************************************
+// * Copyright (c) 2008 IBM Corporation and others.
+// * All rights reserved. This program and the accompanying materials
+// * are 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
+// *
+// * Contributors:
+// * IBM Corporation - initial API and implementation
+// ******************************************************************************/
+//
+//package org.eclipse.jface.tests.labelProviders;
+//
+//import junit.framework.TestCase;
+//
+//import org.eclipse.core.runtime.AssertionFailedException;
+//import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
+//import org.eclipse.jface.viewers.DecorationContext;
+//import org.eclipse.jface.viewers.IDecorationContext;
+//import org.eclipse.jface.viewers.ILabelDecorator;
+//import org.eclipse.jface.viewers.ILabelProviderListener;
+//import org.eclipse.jface.viewers.StyledString;
+//import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+//import org.eclipse.swt.graphics.Image;
+//
+///**
+// * Most of the setup has been taken from
+// * org.eclipse.jface.snippets.viewers.Snippet010OwnerDraw.java
+// *
+// * @since 3.4
+// *
+// */
+//public class IDecorationContextTest extends TestCase {
+//
+// private IDecorationContext getDecorationContext() {
+// return new IDecorationContext() {
+//
+// public String[] getProperties() {
+// return null;
+// }
+//
+// public Object getProperty(String property) {
+// return null;
+// }
+// };
+// }
+//
+// private IStyledLabelProvider getStyledLabelProvider() {
+// return new IStyledLabelProvider() {
+//
+// public Image getImage(Object element) {
+// return null;
+// }
+//
+// public StyledString getStyledText(Object element) {
+// return null;
+// }
+//
+// public void addListener(ILabelProviderListener listener) {
+//
+// }
+//
+// public void dispose() {
+//
+// }
+//
+// public boolean isLabelProperty(Object element, String property) {
+// return false;
+// }
+//
+// public void removeListener(ILabelProviderListener listener) {
+//
+// }
+// };
+// }
+//
+// private ILabelDecorator getLabelDecorator() {
+// return new ILabelDecorator() {
+//
+// public Image decorateImage(Image image, Object element) {
+// return null;
+// }
+//
+// public String decorateText(String text, Object element) {
+// return null;
+// }
+//
+// public void addListener(ILabelProviderListener listener) {
+//
+// }
+//
+// public void dispose() {
+//
+// }
+//
+// public boolean isLabelProperty(Object element, String property) {
+// return false;
+// }
+//
+// public void removeListener(ILabelProviderListener listener) {
+//
+// }
+// };
+// }
+//
+// private DecoratingStyledCellLabelProvider getDecoratingStyledCellLabelProvider(
+// boolean nullDecorationContext) {
+// return nullDecorationContext ? new DecoratingStyledCellLabelProvider(
+// getStyledLabelProvider(), getLabelDecorator(), null)
+// : new DecoratingStyledCellLabelProvider(
+// getStyledLabelProvider(), getLabelDecorator(),
+// getDecorationContext());
+// }
+//
+// public IDecorationContextTest(String name) {
+// super(name);
+// }
+//
+// public void testDefaultContextIsUsed() {
+// // Create a DecoratingStyledCellLabelProvider with a null
+// // decorationContext
+// assertEquals(getDecoratingStyledCellLabelProvider(true)
+// .getDecorationContext(), DecorationContext.DEFAULT_CONTEXT);
+//
+// }
+//
+// public void testSetDecorationContextNull() {
+// DecoratingStyledCellLabelProvider label = getDecoratingStyledCellLabelProvider(false);
+// try {
+// label.setDecorationContext(null);
+// fail("DecoratingStyledCellLabelProvider.setDecorationContext did not throw an exception when passed null");
+// } catch (AssertionFailedException e) {
+// // A Good Thing.
+// }
+// }
+//
+//}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/AllTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/AllTests.java
new file mode 100644
index 0000000000..7e59139019
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/AllTests.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jface.tests.preferences;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests extends TestSuite {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite() {
+ return new AllTests();
+ }
+
+ public AllTests() {
+ addTestSuite(BooleanFieldEditorTest.class);
+ addTestSuite(StringFieldEditorTest.class);
+ addTestSuite(IntegerFieldEditorTest.class);
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/BooleanFieldEditorTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/BooleanFieldEditorTest.java
new file mode 100644
index 0000000000..2c0fe43a49
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/BooleanFieldEditorTest.java
@@ -0,0 +1,284 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Matthew Bisson - <mrbisson@ca.ibm.com> Initial test implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.preferences;
+
+import java.lang.reflect.Field;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class BooleanFieldEditorTest extends TestCase {
+
+ private Shell shell;
+ private BooleanFieldEditor bfEditorWithSameLabel;
+ private BooleanFieldEditor bfEditorWithSeparateLabel;
+
+ private boolean otherThreadEventOccurred = false;
+ private final Object lock = new Object();
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ shell = new Shell();
+
+ bfEditorWithSameLabel = new BooleanFieldEditor("name", "label", shell);
+ bfEditorWithSeparateLabel = new BooleanFieldEditor("name2", "label", BooleanFieldEditor.SEPARATE_LABEL, shell);
+ }
+
+ public void testSetLabelText() {
+ bfEditorWithSameLabel.setLabelText("label text");
+ assertEquals("label text", bfEditorWithSameLabel.getLabelText());
+
+ bfEditorWithSeparateLabel.setLabelText("label text");
+ assertEquals("label text", bfEditorWithSameLabel.getLabelText());
+ }
+
+ public void testLoad() {
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ bfEditorWithSameLabel.setPreferenceName("name");
+ bfEditorWithSameLabel.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setDefault("name", true); //Make sure this doesn't interfere
+ myPreferenceStore.setValue("name", false);
+ bfEditorWithSameLabel.load();
+ assertFalse(bfEditorWithSameLabel.getBooleanValue());
+
+ myPreferenceStore.setDefault("name", false); //Make sure this doesn't interfere
+ myPreferenceStore.setValue("name", true);
+ bfEditorWithSameLabel.load();
+ assertTrue(bfEditorWithSameLabel.getBooleanValue());
+ }
+
+ public void testLoadDefault() {
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ bfEditorWithSameLabel.setPreferenceName("name");
+ bfEditorWithSameLabel.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setDefault("name", false);
+ myPreferenceStore.setValue("name", true); //Make sure this doesn't interfere
+ bfEditorWithSameLabel.loadDefault();
+ assertFalse(bfEditorWithSameLabel.getBooleanValue());
+
+ myPreferenceStore.setDefault("name", true);
+ myPreferenceStore.setValue("name", false); //Make sure this doesn't interfere
+ bfEditorWithSameLabel.loadDefault();
+ assertTrue(bfEditorWithSameLabel.getBooleanValue());
+ }
+
+ public void testGetBooleanValue() {
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ bfEditorWithSameLabel.setPreferenceName("name");
+ bfEditorWithSameLabel.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setValue("name", true);
+ bfEditorWithSameLabel.load();
+ assertTrue(bfEditorWithSameLabel.getBooleanValue());
+
+ Button button = getButton(bfEditorWithSameLabel);
+ button.setSelection(false);
+ assertFalse(bfEditorWithSameLabel.getBooleanValue());
+
+ button.setSelection(true);
+ assertTrue(bfEditorWithSameLabel.getBooleanValue());
+ }
+
+ public void testStore() {
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ bfEditorWithSameLabel.setPreferenceName("name");
+ bfEditorWithSameLabel.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setValue("name", true);
+ bfEditorWithSameLabel.load();
+ assertTrue(bfEditorWithSameLabel.getBooleanValue());
+
+ Button button = getButton(bfEditorWithSameLabel);
+ button.setSelection(false);
+ assertTrue(myPreferenceStore.getBoolean("name"));
+ bfEditorWithSameLabel.store();
+ assertFalse(myPreferenceStore.getBoolean("name"));
+
+ button.setSelection(true);
+ assertTrue(bfEditorWithSameLabel.getBooleanValue());
+ assertFalse(myPreferenceStore.getBoolean("name"));
+ bfEditorWithSameLabel.store();
+ assertTrue(myPreferenceStore.getBoolean("name"));
+ }
+
+ public void testValueChanged() {
+ bfEditorWithSameLabel.setPropertyChangeListener(new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ otherThreadEventOccurred();
+ }
+ });
+
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ bfEditorWithSameLabel.setPreferenceName("name");
+ bfEditorWithSameLabel.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setValue("name", false);
+ bfEditorWithSameLabel.load();
+ assertFalse(bfEditorWithSameLabel.getBooleanValue());
+
+ Button button = getButton(bfEditorWithSameLabel);
+ button.setSelection(true);
+
+ assertFalse(otherThreadEventOccurred);
+ button.notifyListeners(SWT.Selection, null);
+ assertTrue(bfEditorWithSameLabel.getBooleanValue());
+
+ waitForEventInOtherThread();
+
+ assertTrue(otherThreadEventOccurred);
+ }
+
+
+ public void testSetFocus() {
+ bfEditorWithSameLabel = new BooleanFieldEditor("name", "label", shell){
+ protected Button getChangeControl(Composite parent) {
+ return new Button(parent,SWT.CHECK){
+ protected void checkSubclass() {}
+ public boolean setFocus() {
+ otherThreadEventOccurred();
+ return super.setFocus();
+ }
+ };
+ }
+ };
+ assertFalse(otherThreadEventOccurred);
+ bfEditorWithSameLabel.setFocus();
+ waitForEventInOtherThread();
+ assertTrue(otherThreadEventOccurred);
+ }
+
+ public void testSetEnabled() {
+ Button buttonWithSameLabel = getButton(bfEditorWithSameLabel);
+
+ bfEditorWithSameLabel.setEnabled(true, shell);
+ assertTrue(buttonWithSameLabel.isEnabled());
+
+ bfEditorWithSameLabel.setEnabled(false, shell);
+ assertFalse(buttonWithSameLabel.isEnabled());
+
+ bfEditorWithSameLabel.setEnabled(true, shell);
+ assertTrue(buttonWithSameLabel.isEnabled());
+
+ Button buttonWithSeparateLabel = getButton(bfEditorWithSeparateLabel);
+ Label separateLabel = bfEditorWithSeparateLabel.getLabelControl(shell);
+
+ bfEditorWithSeparateLabel.setEnabled(true, shell);
+ assertTrue(buttonWithSeparateLabel.isEnabled());
+ assertTrue(separateLabel.isEnabled());
+
+ bfEditorWithSeparateLabel.setEnabled(false, shell);
+ assertFalse(buttonWithSeparateLabel.isEnabled());
+ assertFalse(separateLabel.isEnabled());
+
+ bfEditorWithSeparateLabel.setEnabled(true, shell);
+ assertTrue(buttonWithSeparateLabel.isEnabled());
+ assertTrue(separateLabel.isEnabled());
+ }
+
+ public void testAdjustForNumColumns() {
+ final BooleanFieldEditor[] editors = new BooleanFieldEditor[2];
+
+ PreferencePage page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) {
+ protected void createFieldEditors() {
+ Composite parent = getFieldEditorParent();
+ BooleanFieldEditor bfEditorWithSameLabel = new BooleanFieldEditor("name", "label", parent);
+ BooleanFieldEditor bfEditorWithSeparateLabel = new BooleanFieldEditor("name2", "label", BooleanFieldEditor.SEPARATE_LABEL, parent);
+
+ editors[0] = bfEditorWithSameLabel;
+ editors[1] = bfEditorWithSeparateLabel;
+
+ addField(bfEditorWithSameLabel);
+ addField(bfEditorWithSeparateLabel);
+ }
+ };
+
+ page.createControl(shell);
+
+ BooleanFieldEditor bfEditorWithSameLabel = editors[0];
+ BooleanFieldEditor bfEditorWithSeparateLabel = editors[1];
+
+ Button buttonWithSameLabel = getButton(bfEditorWithSameLabel);
+ Button buttonWithSeparateLabel = getButton(bfEditorWithSeparateLabel);
+
+ int withLabelSpan = ((GridData)buttonWithSameLabel.getLayoutData()).horizontalSpan;
+ int separateLabelSpan = ((GridData)buttonWithSeparateLabel.getLayoutData()).horizontalSpan;
+
+ assertEquals(withLabelSpan - 1, separateLabelSpan);
+ }
+
+ /**
+ * Reads the button control from the BooleanFieldEditor
+ */
+ private Button getButton(BooleanFieldEditor booleanFieldEditor) {
+ try {
+ Field f = BooleanFieldEditor.class.getDeclaredField("checkBox");
+ f.setAccessible(true);
+ return (Button) f.get(booleanFieldEditor);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Invoke to signal a single expected event from another thread.
+ */
+ private void otherThreadEventOccurred() {
+ synchronized (lock) {
+ otherThreadEventOccurred = true;
+ lock.notify();
+ }
+ }
+
+ /**
+ * Invoke to wait for a single expected event from another thread.
+ * Times out after one second.
+ */
+ private void waitForEventInOtherThread() {
+ synchronized (lock) {
+ if(!otherThreadEventOccurred) {
+ try {
+ lock.wait(1000);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
+
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/IntegerFieldEditorTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/IntegerFieldEditorTest.java
new file mode 100644
index 0000000000..c839dbf982
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/IntegerFieldEditorTest.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Matthew Bisson - <mrbisson@ca.ibm.com> Initial test implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.preferences;
+
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class IntegerFieldEditorTest extends TestCase {
+
+ private Shell shell;
+ private IntegerFieldEditor integerFieldEditor;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ shell = new Shell();
+
+ integerFieldEditor = new IntegerFieldEditor("name", "label", shell);
+ integerFieldEditor.setValidRange(0, 500);
+ integerFieldEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
+ }
+
+ public void testLoad() {
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ integerFieldEditor.setPreferenceName("name");
+ integerFieldEditor.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setDefault("name", 5);
+ integerFieldEditor.load();
+ assertEquals(integerFieldEditor.getIntValue(), 5);
+
+ myPreferenceStore.setDefault("name", 5);
+ myPreferenceStore.setValue("name", 6);
+ integerFieldEditor.load();
+ assertEquals(integerFieldEditor.getIntValue(), 6);
+ }
+
+ public void testLoadDefault() {
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ integerFieldEditor.setPreferenceName("name");
+ integerFieldEditor.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setDefault("name", 5);
+ myPreferenceStore.setValue("name", 6);
+ integerFieldEditor.loadDefault();
+ assertEquals(integerFieldEditor.getIntValue(), 5);
+ }
+
+ public void testSetValueInWidget() {
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ integerFieldEditor.setPreferenceName("name");
+ integerFieldEditor.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setValue("name", 5);
+ integerFieldEditor.load();
+ assertEquals(integerFieldEditor.getIntValue(), 5);
+
+ Text text = integerFieldEditor.getTextControl(shell);
+ text.setText("6");
+ assertEquals(integerFieldEditor.getIntValue(), 6);
+ }
+
+ public void testSetValueInEditor() {
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ integerFieldEditor.setPreferenceName("name");
+ integerFieldEditor.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setValue("name", 5);
+ integerFieldEditor.load();
+ assertEquals(integerFieldEditor.getIntValue(), 5);
+
+ integerFieldEditor.setStringValue("6");
+ Text text = integerFieldEditor.getTextControl(shell);
+ assertEquals(text.getText(), "6");
+ assertEquals(integerFieldEditor.getIntValue(), 6);
+ }
+
+ public void testValidate() {
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ integerFieldEditor.setPreferenceName("name");
+ integerFieldEditor.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setValue("name", 5000);
+ integerFieldEditor.load();
+ assertFalse(integerFieldEditor.isValid());
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
+
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/SamplePreferencePage.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/SamplePreferencePage.java
new file mode 100644
index 0000000000..9b0e14c393
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/SamplePreferencePage.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.preferences;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+
+public class SamplePreferencePage extends PreferencePage {
+
+ private String text;
+
+ public SamplePreferencePage(String title, String text) {
+ super(title);
+ this.text = text;
+ }
+
+ protected Control createContents(Composite parent) {
+ Label label = new Label(parent, SWT.LEFT);
+ label.setText(text);
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ label.setLayoutData(data);
+
+ return new Composite(parent, SWT.NULL);
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/StringFieldEditorTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/StringFieldEditorTest.java
new file mode 100644
index 0000000000..37dd2c87a4
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/preferences/StringFieldEditorTest.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Matthew Bisson - <mrbisson@ca.ibm.com> Initial test implementation
+ * Pawel Pogorzelski - <Pawel.Pogorzelski@pl.ibm.com> - test for bug 289599
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.preferences;
+
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class StringFieldEditorTest extends TestCase {
+
+ private Shell shell;
+ private StringFieldEditor stringFieldEditor;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ shell = new Shell();
+
+ stringFieldEditor = new StringFieldEditor("name", "label", shell);
+ }
+
+ public void testSetLabelText() {
+ stringFieldEditor.setLabelText("label text");
+ assertEquals("label text", stringFieldEditor.getLabelText());
+
+ stringFieldEditor.setLabelText("label text");
+ assertEquals("label text", stringFieldEditor.getLabelText());
+ }
+
+ public void testLoad() {
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ stringFieldEditor.setPreferenceName("name");
+ stringFieldEditor.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setDefault("name", "foo");
+ stringFieldEditor.load();
+ assertEquals(stringFieldEditor.getStringValue(), "foo");
+
+ myPreferenceStore.setDefault("name", "foo");
+ myPreferenceStore.setValue("name", "bar");
+ stringFieldEditor.load();
+ assertEquals(stringFieldEditor.getStringValue(), "bar");
+ }
+
+ public void testLoadDefault() {
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ stringFieldEditor.setPreferenceName("name");
+ stringFieldEditor.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setDefault("name", "foo");
+ myPreferenceStore.setValue("name", "bar");
+ stringFieldEditor.loadDefault();
+ assertEquals(stringFieldEditor.getStringValue(), "foo");
+ }
+
+ public void testSetValueInWidget() {
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ stringFieldEditor.setPreferenceName("name");
+ stringFieldEditor.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setValue("name", "foo");
+ stringFieldEditor.load();
+ assertEquals(stringFieldEditor.getStringValue(), "foo");
+
+ Text text = stringFieldEditor.getTextControl(shell);
+ text.setText("bar");
+ assertEquals(stringFieldEditor.getStringValue(), "bar");
+ }
+
+ public void testSetValueInEditor() {
+ PreferenceStore myPreferenceStore = new PreferenceStore();
+ stringFieldEditor.setPreferenceName("name");
+ stringFieldEditor.setPreferenceStore(myPreferenceStore);
+
+ myPreferenceStore.setValue("name", "foo");
+ stringFieldEditor.load();
+ assertEquals(stringFieldEditor.getStringValue(), "foo");
+
+ stringFieldEditor.setStringValue("bar");
+ Text text = stringFieldEditor.getTextControl(shell);
+ assertEquals(text.getText(), "bar");
+ assertEquals(stringFieldEditor.getStringValue(), "bar");
+ }
+
+ public void testBug289599() {
+ PreferenceStore store = new PreferenceStore();
+ store.setDefault("foo", "bar");
+ assertEquals("bar", store.getString("foo"));
+ store.setValue("foo", "???");
+ assertEquals("???", store.getString("foo"));
+ IPropertyChangeListener listener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ assertEquals("foo", event.getProperty());
+ assertEquals("???", event.getOldValue());
+ assertEquals("bar", event.getNewValue());
+ }
+ };
+ store.addPropertyChangeListener(listener);
+ store.setToDefault("foo");
+ store.removePropertyChangeListener(listener);
+ assertEquals("bar", store.getString("foo"));
+ IPropertyChangeListener failingListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ // Make sure no event is fired to this listener
+ fail("1.0");
+ }
+ };
+ store.addPropertyChangeListener(failingListener);
+ // We already called setToDefault, nothing should happen this time
+ store.setToDefault("foo");
+ store.removePropertyChangeListener(failingListener);
+ assertEquals("bar", store.getString("foo"));
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
+
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/AllTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/AllTests.java
index b4edf5d233..e5cc275f34 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/AllTests.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -42,24 +42,29 @@ public class AllTests extends TestSuite {
addTestSuite(TableFontProviderTest.class);
addTestSuite(ListViewerTest.class);
addTestSuite(CheckboxTableViewerTest.class);
+ addTestSuite(CheckboxTableViewerTest.DeprecatedConstructor.class);
+ addTestSuite(CheckboxTableViewerTest.FactoryMethod.class);
addTestSuite(CheckboxTreeViewerTest.class);
addTestSuite(ComboViewerTest.class);
addTestSuite(CComboViewerTest.class);
addTestSuite(TreeViewerComparatorTest.class);
addTestSuite(ListViewerComparatorTest.class);
addTestSuite(TableViewerComparatorTest.class);
- addTestSuite(Bug138608Test.class);
+// addTestSuite(Bug138608Test.class);
addTestSuite(ComboViewerComparerTest.class);
addTestSuite(ListViewerRefreshTest.class);
addTestSuite(Bug200558Test.class);
addTestSuite(Bug201002TableViewerTest.class);
// addTestSuite(Bug201002TreeViewerTest.class);
addTestSuite(Bug200337TableViewerTest.class);
- addTestSuite(Bug180504TableViewerTest.class);
- addTestSuite(Bug180504TreeViewerTest.class);
addTestSuite(Bug203657TreeViewerTest.class);
addTestSuite(Bug203657TableViewerTest.class);
addTestSuite(Bug205700TreeViewerTest.class);
+ addTestSuite(Bug180504TableViewerTest.class);
+ addTestSuite(Bug180504TreeViewerTest.class);
+ addTestSuite(Bug256889TableViewerTest.class);
+ addTestSuite(Bug287765Test.class);
// addTestSuite(StyledStringBuilderTest.class);
+ addTestSuite(TreeManagerTest.class);
}
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug138608Test.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug138608Test.java
index 35187733a2..da40a0b4e5 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug138608Test.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug138608Test.java
@@ -18,6 +18,7 @@ import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TreeNode;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
/**
@@ -53,7 +54,7 @@ public class Bug138608Test extends ViewerTestCase {
protected StructuredViewer createViewer(Composite parent) {
final TreeViewer viewer = new TreeViewer(parent);
-// viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+ viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
contentProvider = new TreeContentProvider();
LabelProvider labelProvider = new LabelProvider();
viewer.setContentProvider(contentProvider);
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TreeViewerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TreeViewerTest.java
index dea4285fa2..2b57d5e83c 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TreeViewerTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TreeViewerTest.java
@@ -1,163 +1,162 @@
-// RAP [bm]: CellEditors
-///*******************************************************************************
-// * Copyright (c) 2007 IBM Corporation and others.
-// * All rights reserved. This program and the accompanying materials
-// * are 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
-// *
-// * Contributors:
-// * IBM Corporation - initial API and implementation
-// ******************************************************************************/
-//
-//package org.eclipse.jface.tests.viewers;
-//
-//import java.util.ArrayList;
-//
-////import org.eclipse.jface.viewers.CellEditor;
-//import org.eclipse.jface.viewers.ICellModifier;
-//import org.eclipse.jface.viewers.ITreeContentProvider;
-//import org.eclipse.jface.viewers.StructuredViewer;
-////import org.eclipse.jface.viewers.TextCellEditor;
-//import org.eclipse.jface.viewers.TreeViewer;
-//import org.eclipse.jface.viewers.Viewer;
-//import org.eclipse.swt.SWT;
-//import org.eclipse.swt.widgets.Composite;
-//import org.eclipse.swt.widgets.TreeColumn;
-//
-///**
-// * @since 3.3
-// *
-// */
-//public class Bug201002TreeViewerTest extends ViewerTestCase {
-// public class MyModel {
-// public MyModel parent;
-//
-// public ArrayList child = new ArrayList();
-//
-// public int counter;
-//
-// public MyModel(int counter, MyModel parent) {
-// this.parent = parent;
-// this.counter = counter;
-// }
-//
-// public String toString() {
-// String rv = "Item ";
-// if (parent != null) {
-// rv = parent.toString() + ".";
-// }
-//
-// rv += counter;
-//
-// return rv;
-// }
-// }
-// /**
-// * @param name
-// */
-// public Bug201002TreeViewerTest(String name) {
-// super(name);
-// // TODO Auto-generated constructor stub
-// }
-//
-// protected StructuredViewer createViewer(Composite parent) {
-// final TreeViewer treeViewer = new TreeViewer(parent, SWT.FULL_SELECTION);
-//
-// treeViewer.setContentProvider(new ITreeContentProvider() {
-//
-// public Object[] getElements(Object inputElement) {
-// return ((MyModel) inputElement).child.toArray();
-// }
-//
-// public void dispose() {
-//
-// }
-//
-// public void inputChanged(Viewer viewer, Object oldInput,
-// Object newInput) {
-//
-// }
-//
-// public Object[] getChildren(Object parentElement) {
-// return getElements(parentElement);
-// }
-//
-// public Object getParent(Object element) {
-// if (element == null) {
-// return null;
-// }
-//
-// return ((MyModel) element).parent;
-// }
-//
-// public boolean hasChildren(Object element) {
-// return ((MyModel) element).child.size() > 0;
-// }
-// });
-//
-// treeViewer.setCellEditors(new CellEditor[] { new TextCellEditor(
-// treeViewer.getTree()) });
-// treeViewer.setColumnProperties(new String[] { "0" });
-// treeViewer.setCellModifier(new ICellModifier() {
-// public boolean canModify(Object element, String property) {
-// return true;
-// }
-//
-// public Object getValue(Object element, String property) {
-// return "";
-// }
-//
-// public void modify(Object element, String property, Object value) {
-// }
-//
-// });
-//
-// new TreeColumn(treeViewer.getTree(), SWT.NONE).setWidth(200);
-//
-// return treeViewer;
-// }
-//
-// protected void setUpModel() {
-// // don't do anything here - we are not using the normal fModel and
-// // fRootElement
-// }
-//
-// protected void setInput() {
-// MyModel root = new MyModel(0, null);
-// root.counter = 0;
-//
-// MyModel tmp;
-// for (int i = 1; i < 100; i++) {
-// tmp = new MyModel(i, root);
-// root.child.add(tmp);
-// for (int j = 1; j < i; j++) {
-// tmp.child.add(new MyModel(j, tmp));
-// }
-// }
-//
-// getTreeViewer().setInput(root);
-// }
-//
-// private TreeViewer getTreeViewer() {
-// return (TreeViewer) fViewer;
-// }
-//
-// public void testBug201002() {
-// getTreeViewer().getTree().setTopItem(
-// getTreeViewer().getTree().getItem(0));
-// getTreeViewer().editElement(((MyModel)((MyModel)getTreeViewer().getInput()).child.get(90)).child.get(10), 0);
-//
-// // GTK-Issue where call to getTopItem() immediately
-// // afterwards will fail
-// while( getTreeViewer().getTree().getDisplay().readAndDispatch () ) {
-//
-// }
-//
-// assertEquals(true,
-// getTreeViewer().getTree().getTopItem() != getTreeViewer()
-// .getTree().getItem(0));
-// }
-//
-//
-//}
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.viewers;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TreeColumn;
+
+/**
+ * @since 3.3
+ *
+ */
+public class Bug201002TreeViewerTest extends ViewerTestCase {
+ public class MyModel {
+ public MyModel parent;
+
+ public ArrayList child = new ArrayList();
+
+ public int counter;
+
+ public MyModel(int counter, MyModel parent) {
+ this.parent = parent;
+ this.counter = counter;
+ }
+
+ public String toString() {
+ String rv = "Item ";
+ if (parent != null) {
+ rv = parent.toString() + ".";
+ }
+
+ rv += counter;
+
+ return rv;
+ }
+ }
+ /**
+ * @param name
+ */
+ public Bug201002TreeViewerTest(String name) {
+ super(name);
+ // TODO Auto-generated constructor stub
+ }
+
+ protected StructuredViewer createViewer(Composite parent) {
+ final TreeViewer treeViewer = new TreeViewer(parent, SWT.FULL_SELECTION);
+
+ treeViewer.setContentProvider(new ITreeContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ return ((MyModel) inputElement).child.toArray();
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ return getElements(parentElement);
+ }
+
+ public Object getParent(Object element) {
+ if (element == null) {
+ return null;
+ }
+
+ return ((MyModel) element).parent;
+ }
+
+ public boolean hasChildren(Object element) {
+ return ((MyModel) element).child.size() > 0;
+ }
+ });
+
+ treeViewer.setCellEditors(new CellEditor[] { new TextCellEditor(
+ treeViewer.getTree()) });
+ treeViewer.setColumnProperties(new String[] { "0" });
+ treeViewer.setCellModifier(new ICellModifier() {
+ public boolean canModify(Object element, String property) {
+ return true;
+ }
+
+ public Object getValue(Object element, String property) {
+ return "";
+ }
+
+ public void modify(Object element, String property, Object value) {
+ }
+
+ });
+
+ new TreeColumn(treeViewer.getTree(), SWT.NONE).setWidth(200);
+
+ return treeViewer;
+ }
+
+ protected void setUpModel() {
+ // don't do anything here - we are not using the normal fModel and
+ // fRootElement
+ }
+
+ protected void setInput() {
+ MyModel root = new MyModel(0, null);
+ root.counter = 0;
+
+ MyModel tmp;
+ for (int i = 1; i < 100; i++) {
+ tmp = new MyModel(i, root);
+ root.child.add(tmp);
+ for (int j = 1; j < i; j++) {
+ tmp.child.add(new MyModel(j, tmp));
+ }
+ }
+
+ getTreeViewer().setInput(root);
+ }
+
+ private TreeViewer getTreeViewer() {
+ return (TreeViewer) fViewer;
+ }
+
+ public void testBug201002() {
+ getTreeViewer().getTree().setTopItem(
+ getTreeViewer().getTree().getItem(0));
+ getTreeViewer().editElement(((MyModel)((MyModel)getTreeViewer().getInput()).child.get(90)).child.get(10), 0);
+
+ // GTK-Issue where call to getTopItem() immediately
+ // afterwards will fail
+ while( getTreeViewer().getTree().getDisplay().readAndDispatch () ) {
+
+ }
+
+ assertEquals(true,
+ getTreeViewer().getTree().getTopItem() != getTreeViewer()
+ .getTree().getItem(0));
+ }
+
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TableViewerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TableViewerTest.java
index 1f65155d67..5332a5001c 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TableViewerTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TableViewerTest.java
@@ -14,9 +14,12 @@ package org.eclipse.jface.tests.viewers;
import java.lang.reflect.Field;
import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
@@ -39,23 +42,22 @@ public class Bug203657TableViewerTest extends ViewerTestCase {
protected StructuredViewer createViewer(Composite parent) {
final TableViewer tableViewer = new TableViewer(parent, SWT.FULL_SELECTION);
tableViewer.setContentProvider(new ArrayContentProvider());
- // RAP [bm]:
-// tableViewer.setCellEditors(new CellEditor[] { new TextCellEditor(
-// tableViewer.getTable()) });
-// tableViewer.setColumnProperties(new String[] { "0" });
-// tableViewer.setCellModifier(new ICellModifier() {
-// public boolean canModify(Object element, String property) {
-// return true;
-// }
-//
-// public Object getValue(Object element, String property) {
-// return "";
-// }
-//
-// public void modify(Object element, String property, Object value) {
-// }
-//
-// });
+ tableViewer.setCellEditors(new CellEditor[] { new TextCellEditor(
+ tableViewer.getTable()) });
+ tableViewer.setColumnProperties(new String[] { "0" });
+ tableViewer.setCellModifier(new ICellModifier() {
+ public boolean canModify(Object element, String property) {
+ return true;
+ }
+
+ public Object getValue(Object element, String property) {
+ return "";
+ }
+
+ public void modify(Object element, String property, Object value) {
+ }
+
+ });
new TableColumn(tableViewer.getTable(), SWT.NONE).setWidth(200);
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TreeViewerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TreeViewerTest.java
index 24ece6dcbe..b5cab34def 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TreeViewerTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TreeViewerTest.java
@@ -14,9 +14,12 @@ package org.eclipse.jface.tests.viewers;
import java.lang.reflect.Field;
import java.util.ArrayList;
+import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerCell;
@@ -95,23 +98,22 @@ public class Bug203657TreeViewerTest extends ViewerTestCase {
}
});
- // RAP [bm]:
-// treeViewer.setCellEditors(new CellEditor[] { new TextCellEditor(
-// treeViewer.getTree()) });
-// treeViewer.setColumnProperties(new String[] { "0" });
-// treeViewer.setCellModifier(new ICellModifier() {
-// public boolean canModify(Object element, String property) {
-// return true;
-// }
-//
-// public Object getValue(Object element, String property) {
-// return "";
-// }
-//
-// public void modify(Object element, String property, Object value) {
-// }
-//
-// });
+ treeViewer.setCellEditors(new CellEditor[] { new TextCellEditor(
+ treeViewer.getTree()) });
+ treeViewer.setColumnProperties(new String[] { "0" });
+ treeViewer.setCellModifier(new ICellModifier() {
+ public boolean canModify(Object element, String property) {
+ return true;
+ }
+
+ public Object getValue(Object element, String property) {
+ return "";
+ }
+
+ public void modify(Object element, String property, Object value) {
+ }
+
+ });
new TreeColumn(treeViewer.getTree(), SWT.NONE).setWidth(200);
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java
index df7ce1cf3a..bfcdd8d660 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java
@@ -44,8 +44,7 @@ public class Bug205700TreeViewerTest extends TestCase {
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
-// shell = new Shell();
- shell = new Shell(SWT.TITLE);
+ shell = new Shell();
viewer = new TreeViewer(shell, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug256889TableViewerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug256889TableViewerTest.java
new file mode 100644
index 0000000000..4a91b3df03
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug256889TableViewerTest.java
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2009 CAS Software AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * Stefan Roeck, CAS Software AG - initial API and implementation (bug 256889)
+ *******************************************************************************/
+package org.eclipse.jface.tests.viewers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ILazyContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class Bug256889TableViewerTest extends ViewerTestCase {
+
+ private static final int ADD_ENTRIES = 100;
+ private static final int PREFETCH_TRESHOLD = 50;
+ private static final int MAX_ENTRIES = 205;
+
+ private int rowcounter = 0;
+
+ private List model = new ArrayList();
+ private Table table;
+ private TableViewer tableViewer;
+
+ /**
+ * @param name
+ */
+ public Bug256889TableViewerTest(String name) {
+ super(name);
+ initModel();
+ }
+
+ protected StructuredViewer createViewer(Composite parent) {
+ tableViewer = new TableViewer(parent, SWT.VIRTUAL | SWT.BORDER
+ | SWT.MULTI);
+ tableViewer.setContentProvider(new ILazyContentProvider() {
+
+ public void updateElement(int index) {
+ if (index >= 0 && index < tableViewer.getTable().getItemCount()) {
+ if (index > getModel().size() - PREFETCH_TRESHOLD
+ && (getModel().size() < MAX_ENTRIES)) {
+ // simulate loading the next page of data from db
+ int approxRecordCount = addElementsToModel();
+
+ System.out.println("approx. record count: "
+ + approxRecordCount);
+ tableViewer.setItemCount(approxRecordCount);
+ }
+ if (index < getModel().size()) {
+ tableViewer.replace(getModel().get(index), index);
+ } else {
+ System.out.println("invalid index " + index
+ + " model count " + getModel().size());
+ }
+ } else {
+ System.out.println("invalid index " + index
+ + " tableItemCount "
+ + tableViewer.getTable().getItemCount());
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+ }
+ });
+
+ String[] columnProperties = new String[] { "Spalte 1",
+ "Virtual Tables rock" };
+ tableViewer.setColumnProperties(columnProperties);
+
+ table = tableViewer.getTable();
+
+ TableColumn col = new TableColumn(table, SWT.NONE);
+ col.setText(columnProperties[0]);
+ col.setWidth(200);
+
+ col = new TableColumn(table, SWT.NONE);
+ col.setText(columnProperties[1]);
+ col.setWidth(400);
+
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ tableViewer.setItemCount(getModel().size());
+
+ return tableViewer;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.tests.viewers.ViewerTestCase#setInput()
+ */
+ protected void setInput() {
+ tableViewer.setInput(getModel());
+ tableViewer.setItemCount(getModel().size());
+
+ // The heigt is important, otherwise lazy fetching doesn't lead to the
+ // bug
+ fShell.setSize(300, 1000);
+ }
+
+ private void initModel() {
+ this.rowcounter = 0;
+ getModel().clear();
+ addElementsToModel();
+ }
+
+ // Methods returns an approximate record count which is always
+ // one page size larger than the actually fetched records, until
+ // all records have been fetched and the end of list has been reached.
+ protected int addElementsToModel() {
+ int approxRecordCount = 0;
+ int itemsToAdd;
+
+ if (getModel().size() + ADD_ENTRIES < MAX_ENTRIES) {
+ itemsToAdd = ADD_ENTRIES;
+ } else {
+ itemsToAdd = MAX_ENTRIES - getModel().size();
+ }
+
+ for (int i = 0; i < itemsToAdd; i++) {
+ getModel().add("Item " + this.rowcounter++);
+ }
+
+ if (getModel().size() == MAX_ENTRIES) {
+ approxRecordCount = MAX_ENTRIES;
+ } else {
+ approxRecordCount = getModel().size() + ADD_ENTRIES;
+ }
+
+ return approxRecordCount;
+ }
+
+ private List getModel() {
+ return this.model;
+ }
+
+ public void testBug256889() {
+ table.selectAll();
+ tableViewer.getSelection();
+
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug287765Test.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug287765Test.java
new file mode 100644
index 0000000000..889ef5afbe
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug287765Test.java
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Chris Horneck and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * Chris Horneck - initial API and implementation (bug 287765)
+ *******************************************************************************/
+package org.eclipse.jface.tests.viewers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @since 3.4
+ *
+ */
+public class Bug287765Test extends TestCase {
+ private TreeViewer treeViewer;
+ private Node root;
+
+ /**
+ * An element in the Tree. Knows about its children and parent.
+ */
+ private static class Node {
+ private final Node parent;
+ private final List children = new ArrayList();
+ private final int level;
+
+ private Node(Node parentNode, int nodeLevel) {
+ this.parent = parentNode;
+ this.level = nodeLevel;
+
+ if (parent != null) {
+ parent.children.add(this);
+ }
+ }
+ }
+
+ private final class SimpleTreeContentProvider implements
+ ITreeContentProvider, ILabelProvider {
+
+ public Image getImage(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getText(Object element) {
+ Node node = (Node) element;
+ return Integer.toString(node.level);
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ Node node = (Node) parentElement;
+ return node.children.toArray();
+ }
+
+ public boolean hasChildren(Object element) {
+ Node node = (Node) element;
+ return node.children.size() > 0;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ int depth = 4;
+
+ Node node = new Node(root, 1);
+
+ Node parentNode = node;
+ for (int i = 2; i <= depth; i++) {
+ Node newNode = new Node(parentNode, i);
+ parentNode = newNode;
+ }
+
+ return new Object[] { node };
+ }
+
+ public Object getParent(Object element) {
+ Node node = (Node) element;
+
+ return node.parent;
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ final Shell shell = new Shell();
+ shell.setLayout(new GridLayout());
+ shell.setSize(new Point(500, 200));
+
+ treeViewer = new TreeViewer(shell);
+ treeViewer.getControl().setLayoutData(
+ new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ /*
+ * This is a key element to reproducing this bug. It causes
+ * AbstractTreeViewer#disassociate to recurse when it is disassociating
+ * TreeItems. This causes the data field in all of the TreeItems to get
+ * cleared out.
+ */
+ treeViewer.setUseHashlookup(true);
+
+ SimpleTreeContentProvider provider = new SimpleTreeContentProvider();
+
+ treeViewer.setContentProvider(provider);
+ treeViewer.setLabelProvider(provider);
+
+ root = new Node(null, 0);
+
+ treeViewer.setInput(root);
+ shell.open();
+ }
+
+ protected void tearDown() throws Exception {
+ treeViewer.getControl().getShell().dispose();
+ treeViewer = null;
+ root = null;
+ super.tearDown();
+ }
+
+ /**
+ * Test to make the bug occur
+ */
+ public void testException() {
+ // Expand all the nodes
+ treeViewer.expandAll();
+
+ // Refresh the tree to generate new nodes
+ treeViewer.refresh();
+
+ // Retrieve the expanded paths
+ treeViewer.getExpandedTreePaths();
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckStateProviderTestsUtil.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckStateProviderTestsUtil.java
new file mode 100644
index 0000000000..7ef751ce9f
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckStateProviderTestsUtil.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.viewers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ICheckStateProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.viewers.ViewerSorter;
+
+/**
+ * Utilities for testing ICheckStateProviders.
+ * @since 3.5
+ */
+public class CheckStateProviderTestsUtil {
+ private static final int NUMBER_OF_STATES = 4;
+
+ /**
+ * An ICheckStateProvider which records whether
+ * its isChecked and isGrayed methods are invoked.
+ * @since 3.5
+ */
+ public static class TestMethodsInvokedCheckStateProvider implements ICheckStateProvider {
+ public List isCheckedInvokedOn = new ArrayList();
+ public List isGrayedInvokedOn = new ArrayList();
+
+ public boolean isChecked(Object element) {
+ isCheckedInvokedOn.add(element);
+ return true;
+ }
+
+ public boolean isGrayed(Object element) {
+ isGrayedInvokedOn.add(element);
+ return true;
+ }
+
+ public void reset() {
+ isCheckedInvokedOn = new ArrayList();
+ isGrayedInvokedOn = new ArrayList();
+ }
+ }
+
+ /**
+ * An ICheckStateProvider which provides a consistent
+ * variety of states for input elements based on the
+ * parameter provided in the constructor.
+ * @since 3.5
+ */
+ public static final class TestCheckStateProvider extends TestMethodsInvokedCheckStateProvider {
+ private int shift;
+
+ /**
+ * A value from 0 to 2 which will change the
+ * checkstate assignments.
+ * @param shift
+ */
+ public TestCheckStateProvider(int shift) {
+ this.shift = shift;
+ }
+
+ public boolean isChecked(Object element) {
+ super.isChecked(element);
+ return shouldBeChecked((TestElement)element, shift);
+ }
+
+ public boolean isGrayed(Object element) {
+ super.isGrayed(element);
+ return shouldBeGrayed((TestElement)element, shift);
+ }
+ }
+
+ /**
+ * A sorter for TestElements.
+ * @since 3.5
+ */
+ public static final class Sorter extends ViewerSorter {
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ return constructNumber((TestElement)e1) - constructNumber((TestElement)e2);
+ }
+ }
+
+ /**
+ * A filter for TestElements.
+ * @since 3.5
+ */
+ public static final class Filter extends ViewerFilter {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ return (constructNumber((TestElement)element) % (NUMBER_OF_STATES * 2 - 1)) == (NUMBER_OF_STATES - 1);
+ }
+ }
+ /**
+ * @param te
+ * @return a number between 0 and 3 based on <code>te</code>.
+ * Given the same TestElement, this function always returns the
+ * same value.
+ */
+ public static int constructNumber(TestElement te) {
+ String id = te.getID();
+ int number = Integer.parseInt(id.substring(id.lastIndexOf('-') + 1)) + id.length();
+ return number % NUMBER_OF_STATES;
+ }
+
+ /**
+ * @param te
+ * @param shift a parameter to change all check states
+ * to be different (use to simulate different
+ * providers over time)
+ * @return true iff <code>te</code> should be checked
+ */
+ public static boolean shouldBeChecked(TestElement te, int shift) {
+ return ((constructNumber(te) + shift) % NUMBER_OF_STATES) > 1;
+ }
+
+ /**
+ * @param te
+ * @param shift a parameter to change all check states
+ * to be different (use to simulate different
+ * providers over time)
+ * @return true iff <code>te</code> should be grayed
+ */
+ public static boolean shouldBeGrayed(TestElement te, int shift) {
+ return ((constructNumber(te) + shift) % NUMBER_OF_STATES) % 2 == 1;
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTableViewerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTableViewerTest.java
index e18165186a..bae8bbf8e6 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTableViewerTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTableViewerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,9 +10,16 @@
*******************************************************************************/
package org.eclipse.jface.tests.viewers;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.tests.viewers.CheckStateProviderTestsUtil.TestCheckStateProvider;
+import org.eclipse.jface.tests.viewers.CheckStateProviderTestsUtil.TestMethodsInvokedCheckStateProvider;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ColumnLayoutData;
import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TableLayout;
@@ -22,6 +29,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
public class CheckboxTableViewerTest extends TableViewerTest {
public static class CheckboxTableTestLabelProvider extends
@@ -45,6 +53,86 @@ public class CheckboxTableViewerTest extends TableViewerTest {
return null;
}
}
+ public static class DeprecatedConstructor extends CheckboxTableViewerTest {
+ public DeprecatedConstructor(String name) {
+ super(name);
+ }
+
+ protected StructuredViewer createViewer(Composite parent) {
+ TableViewer viewer = new CheckboxTableViewer(parent);
+
+ Table table = viewer.getTable();
+ table.setLinesVisible(true);
+ TableLayout layout = new TableLayout();
+ table.setLayout(layout);
+ table.setHeaderVisible(true);
+
+ String headers[] = { "column 1 header", "column 2 header" };
+
+ ColumnLayoutData layouts[] = { new ColumnWeightData(100),
+ new ColumnWeightData(100) };
+
+ final TableColumn columns[] = new TableColumn[headers.length];
+
+ for (int i = 0; i < headers.length; i++) {
+ layout.addColumnData(layouts[i]);
+ TableColumn tc = new TableColumn(table, SWT.NONE, i);
+ tc.setResizable(layouts[i].resizable);
+ tc.setText(headers[i]);
+ columns[i] = tc;
+ }
+
+ viewer.setContentProvider(new TestModelContentProvider());
+ viewer.setLabelProvider(new TableTestLabelProvider());
+ return viewer;
+ }
+
+ public void testViewerColumn() {
+ assertNull(getViewerColumn((TableViewer) fViewer, -1));
+ assertNotNull(getViewerColumn((TableViewer) fViewer, 0));
+ assertNotNull(getViewerColumn((TableViewer) fViewer, 1));
+ //due to CheckboxTableViewer.createTable, there is an
+ //extra column, so the next test looks for column 3
+ //instead of 2 -- a result of using deprecated code
+ assertNull(getViewerColumn((TableViewer) fViewer, 3));
+ }
+ }
+
+ public static class FactoryMethod extends CheckboxTableViewerTest {
+ public FactoryMethod(String name) {
+ super(name);
+ }
+
+ protected StructuredViewer createViewer(Composite parent) {
+ TableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.NONE);
+
+ Table table = viewer.getTable();
+ table.setLinesVisible(true);
+ TableLayout layout = new TableLayout();
+ table.setLayout(layout);
+ table.setHeaderVisible(true);
+
+ String headers[] = { "column 1 header", "column 2 header" };
+
+ ColumnLayoutData layouts[] = { new ColumnWeightData(100),
+ new ColumnWeightData(100) };
+
+ final TableColumn columns[] = new TableColumn[headers.length];
+
+ for (int i = 0; i < headers.length; i++) {
+ layout.addColumnData(layouts[i]);
+ TableColumn tc = new TableColumn(table, SWT.NONE, i);
+ tc.setResizable(layouts[i].resizable);
+ tc.setText(headers[i]);
+ columns[i] = tc;
+ }
+
+ viewer.setContentProvider(new TestModelContentProvider());
+ viewer.setLabelProvider(new TableTestLabelProvider());
+ return viewer;
+ }
+ }
+
public CheckboxTableViewerTest(String name) {
super(name);
@@ -142,4 +230,237 @@ public class CheckboxTableViewerTest extends TableViewerTest {
ctv.setAllGrayed(false);
}
+
+ public void testWithoutCheckProvider() {
+ //Check that without a provider, no exceptions are thrown
+ CheckboxTableViewer ctv = (CheckboxTableViewer)fViewer;
+ ctv.refresh();
+ }
+
+ public void testCheckProviderInvoked() {
+ //Check that a refresh successfully causes the provider's
+ //setChecked and setGrayed methods to be invoked.
+ CheckboxTableViewer ctv = (CheckboxTableViewer)fViewer;
+
+ TestMethodsInvokedCheckStateProvider provider = new TestMethodsInvokedCheckStateProvider();
+
+ ctv.setCheckStateProvider(provider);
+ assertTrue("isChecked should be invoked on a refresh", (!provider.isCheckedInvokedOn.isEmpty()));
+ assertTrue("isGrayed should be invoked on a refresh", (!provider.isGrayedInvokedOn.isEmpty()));
+
+ provider.reset();
+ ctv.refresh();
+ assertTrue("isChecked should be invoked on a refresh", (!provider.isCheckedInvokedOn.isEmpty()));
+ assertTrue("isGrayed should be invoked on a refresh", (!provider.isGrayedInvokedOn.isEmpty()));
+ }
+
+ public void testCheckedFalseGrayedFalse() {
+ testSpecificState(false, false);
+ }
+
+ public void testCheckedFalseGrayedTrue() {
+ testSpecificState(false, true);
+ }
+
+ public void testCheckedTrueGrayedFalse() {
+ testSpecificState(true, false);
+ }
+
+ public void testCheckedTrueGrayedTrue() {
+ testSpecificState(true, true);
+ }
+
+ private void testSpecificState(final boolean isChecked, final boolean isGrayed) {
+ CheckboxTableViewer ctv = (CheckboxTableViewer)fViewer;
+
+ ctv.setCheckStateProvider(new ICheckStateProvider() {
+ public boolean isChecked(Object element) { return isChecked; }
+ public boolean isGrayed(Object element) { return isGrayed; }
+ });
+
+ TableItem item = ctv.getTable().getItem(0);
+
+ assertEquals(item.getChecked(), isChecked);
+ assertEquals(item.getGrayed(), isGrayed);
+ }
+
+ public void testSetCheckProviderRefreshesItems() {
+ CheckboxTableViewer ctv = (CheckboxTableViewer)fViewer;
+
+ //First provider
+ //Should cause visible items' check state to adhere to provider
+ ctv.setCheckStateProvider(new TestCheckStateProvider(0));
+
+ //Check that all states are properly set
+ checkAllStates("Testing checkbox state after refresh", ctv, 0);
+
+ //Remove the check state provider
+ ctv.setCheckStateProvider(null);
+
+ //Test that an update doesn't fail
+ TestElement update = fRootElement.getChildAt(5);
+ ctv.update(update, null);
+
+ //Test that a refresh doesn't fail
+ ctv.refresh();
+ }
+
+ public void testCheckProviderWithSorter() {
+ CheckboxTableViewer ctv = (CheckboxTableViewer) fViewer;
+
+ ctv.setSorter(new CheckStateProviderTestsUtil.Sorter());
+
+ //First provider
+ //Should cause visible items' check state adhere to provider
+ ctv.setCheckStateProvider(new TestCheckStateProvider(0));
+
+ //Check that all states are properly set
+ checkAllStates("Testing checkbox state with a sorter", ctv, 0);
+ }
+
+ public void testCheckProviderWithFilter() {
+ CheckboxTableViewer ctv = (CheckboxTableViewer) fViewer;
+
+ final CheckStateProviderTestsUtil.Filter filter = new CheckStateProviderTestsUtil.Filter();
+ ctv.addFilter(filter);
+
+ //First provider
+ //Should cause visible items' check state adhere to provider
+ final TestCheckStateProvider checkStateProvider = new TestCheckStateProvider(0);
+ ctv.setCheckStateProvider(checkStateProvider);
+
+ //Check that all states are properly set
+ checkAllStates("Testing checkbox state with a sorter", ctv, 0);
+
+ //Check that the provider is only invoked on elements which pass the filter
+ for (Iterator i = checkStateProvider.isCheckedInvokedOn.iterator(); i.hasNext();) {
+ TestElement element = (TestElement) i.next();
+ assertTrue("The check provider should not be invoked on elements which did not get through the filter", filter.select(ctv, null, element));
+ }
+
+ for (Iterator i = checkStateProvider.isGrayedInvokedOn.iterator(); i.hasNext();) {
+ TestElement element = (TestElement) i.next();
+ assertTrue("The check provider should not be invoked on elements which did not get through the filter", filter.select(ctv, null, element));
+ }
+ }
+
+ public void testCheckProviderUpdate() {
+ CheckboxTableViewer ctv = (CheckboxTableViewer)fViewer;
+
+ //First provider
+ //Should cause visible items' check state to adhere to provider
+ ctv.setCheckStateProvider(new TestCheckStateProvider(0));
+
+ checkAllStates("Testing checkbox state after refresh", ctv, 0);
+
+ //Put in a new check state provider
+ ctv.setCheckStateProvider(new TestCheckStateProvider(1));
+
+ //Check that setting a new check provider caused a refresh,
+ //and thus all the items have their new appropriate check
+ //states.
+ checkAllStates("Testing checkbox state after refresh", ctv, 1);
+ }
+
+ private void checkAllStates(String comment, CheckboxTableViewer ctv, int shift) {
+ TableItem[] items = ctv.getTable().getItems();
+
+ //Check that actual states were set properly
+ for (int i = 0; i < items.length; i++) {
+ TableItem item = items[i];
+ TestElement element = (TestElement)items[i].getData();
+
+ checkState(comment, element, item, shift); //check in Table
+ checkState(comment, element, ctv, shift); //check in Viewer
+ }
+ }
+
+ /**
+ * Invokes the appropriate asserts to verify the state
+ * of a TestElement.
+ * @param te
+ * @param viewer the viewer <code>te</code> is in.
+ * @param shift the shift parameter being used
+ */
+ private void checkState(String comment, TestElement te, CheckboxTableViewer viewer, int shift) {
+ assertEquals(comment, CheckStateProviderTestsUtil.shouldBeChecked(te, shift), viewer.getChecked(te));
+ assertEquals(comment, CheckStateProviderTestsUtil.shouldBeGrayed(te, shift), viewer.getGrayed(te));
+ }
+
+ /**
+ * Invokes the appropriate asserts to verify the state
+ * of a TestElement's associated TableItem
+ * @param te
+ * @param item the item representing <code>te</code>
+ * @param shift the shift parameter being used
+ */
+ private void checkState(String comment, TestElement te, TableItem item, int shift) {
+ assertEquals("Wrong checkstate: " + comment, CheckStateProviderTestsUtil.shouldBeChecked(te, shift), item.getChecked());
+ assertEquals("Wrong checkstate: " + comment, CheckStateProviderTestsUtil.shouldBeGrayed(te, shift), item.getGrayed());
+ }
+
+ public void testGetCheckedElements() {
+ CheckboxTableViewer ctv = (CheckboxTableViewer) fViewer;
+
+ TestElement[] children = fRootElement.getChildren();
+
+ List checked = new ArrayList((children.length + 1) / 2);
+
+ for (int i = 0; i < children.length; i+=2) {
+ ctv.setChecked(children[i], true);
+ checked.add(children[i]);
+ }
+
+ Object[] actuallyChecked = ctv.getCheckedElements();
+
+ for (int i = 0; i < actuallyChecked.length; i++) {
+ assertTrue("getCheckedElements should include all checked elements", checked.remove(actuallyChecked[i]));
+ }
+
+ assertTrue("getCheckedElements should not include any unchecked elements", checked.isEmpty());
+ }
+
+ public void testSetCheckedElements() {
+ CheckboxTableViewer ctv = (CheckboxTableViewer) fViewer;
+
+ TestElement[] children = fRootElement.getChildren();
+
+ List toCheck = new ArrayList((children.length + 1) / 2);
+
+ for (int i = 0; i < children.length; i+=2) {
+ toCheck.add(children[i]);
+ }
+
+ ctv.setCheckedElements(toCheck.toArray());
+
+ for (int i = 0; i < children.length; i++) {
+ if(i % 2 == 0) {
+ assertTrue("an element passed through setCheckedElements should be checked", ctv.getChecked(children[i]));
+ } else {
+ assertFalse("an element not passed through setCheckedElements should be unchecked", ctv.getChecked(children[i]));
+ }
+ }
+ }
+
+ public void testSetGrayedElements() {
+ CheckboxTableViewer ctv = (CheckboxTableViewer) fViewer;
+
+ TestElement[] children = fRootElement.getChildren();
+
+ List toGray = new ArrayList((children.length + 1) / 2);
+
+ for (int i = 0; i < children.length; i+=2) {
+ toGray.add(children[i]);
+ }
+
+ ctv.setGrayedElements(toGray.toArray());
+
+ for (int i = 0; i < children.length; i++) {
+ if(i % 2 == 0) {
+ assertTrue("an element passed through setGrayedElements should be grayed", ctv.getGrayed(children[i]));
+ } else {
+ assertFalse("an element not passed through setGrayedElements should not be grayed", ctv.getGrayed(children[i]));
+ }
+ }
+ }
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerTest.java
index 661cf0cdf4..df4eb80bd5 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,11 +10,20 @@
*******************************************************************************/
package org.eclipse.jface.tests.viewers;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.tests.viewers.CheckStateProviderTestsUtil.TestCheckStateProvider;
+import org.eclipse.jface.tests.viewers.CheckStateProviderTestsUtil.TestMethodsInvokedCheckStateProvider;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TreeItem;
public class CheckboxTreeViewerTest extends TreeViewerTest {
public static class CheckboxTableTestLabelProvider extends
@@ -105,4 +114,320 @@ public class CheckboxTreeViewerTest extends TreeViewerTest {
assertTrue(elements[2] == firstfirstfirst);
ctv.setParentsGrayed(firstfirstfirst, false);
}
+
+ public void testWithoutCheckProvider() {
+ //Check that without a provider, no exceptions are thrown
+ CheckboxTreeViewer ctv = (CheckboxTreeViewer)fViewer;
+ ctv.expandAll();
+ ctv.refresh();
+ }
+
+ public void testCheckProviderInvoked() {
+ //Check that a refresh successfully causes the provider's
+ //setChecked and setGrayed methods to be invoked.
+ CheckboxTreeViewer ctv = (CheckboxTreeViewer)fViewer;
+
+ TestMethodsInvokedCheckStateProvider provider = new TestMethodsInvokedCheckStateProvider();
+
+ ctv.setCheckStateProvider(provider);
+ assertTrue("isChecked should be invoked on a refresh", (!provider.isCheckedInvokedOn.isEmpty()));
+ assertTrue("isGrayed should be invoked on a refresh", (!provider.isGrayedInvokedOn.isEmpty()));
+
+ provider.reset();
+ ctv.refresh();
+ assertTrue("isChecked should be invoked on a refresh", (!provider.isCheckedInvokedOn.isEmpty()));
+ assertTrue("isGrayed should be invoked on a refresh", (!provider.isGrayedInvokedOn.isEmpty()));
+
+ }
+
+ public void testCheckProviderLazilyInvoked() {
+ //Check that a refresh successfully causes the provider's
+ //setChecked and setGrayed methods to be invoked.
+ CheckboxTreeViewer ctv = (CheckboxTreeViewer)fViewer;
+
+ TestMethodsInvokedCheckStateProvider provider = new TestMethodsInvokedCheckStateProvider();
+
+ ctv.setCheckStateProvider(provider);
+ ctv.refresh();
+
+ TestElement[] expected = fRootElement.getChildren();
+
+ for (Iterator i = provider.isCheckedInvokedOn.iterator(); i.hasNext();) {
+ TestElement element = (TestElement) i.next();
+ boolean firstLevelElement = false;
+ for (int j = 0; j < expected.length && !firstLevelElement; j++) {
+ firstLevelElement = element.equals(expected[j]);
+ }
+ assertTrue("The check provider should only be invoked with visible elements", firstLevelElement);
+ }
+
+ for (Iterator i = provider.isGrayedInvokedOn.iterator(); i.hasNext();) {
+ TestElement element = (TestElement) i.next();
+ boolean firstLevelElement = false;
+ for (int j = 0; j < expected.length && !firstLevelElement; j++) {
+ firstLevelElement = element.equals(expected[j]);
+ }
+ assertTrue("The check provider should only be invoked with visible elements", firstLevelElement);
+ }
+ }
+
+ public void testCheckedFalseGrayedFalse() {
+ testSpecificState(false, false);
+ }
+
+ public void testCheckedFalseGrayedTrue() {
+ testSpecificState(false, true);
+ }
+
+ public void testCheckedTrueGrayedFalse() {
+ testSpecificState(true, false);
+ }
+
+ public void testCheckedTrueGrayedTrue() {
+ testSpecificState(true, true);
+ }
+
+ private void testSpecificState(final boolean isChecked, final boolean isGrayed) {
+ CheckboxTreeViewer ctv = (CheckboxTreeViewer)fViewer;
+
+ ctv.setCheckStateProvider(new ICheckStateProvider() {
+ public boolean isChecked(Object element) { return isChecked; }
+ public boolean isGrayed(Object element) { return isGrayed; }
+ });
+
+ TreeItem item = ctv.getTree().getItem(0);
+
+ assertEquals(item.getChecked(), isChecked);
+ assertEquals(item.getGrayed(), isGrayed);
+ }
+
+ public void testSetCheckProviderRefreshesItems() {
+ CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
+
+ //First provider
+ //Should cause visible items' check state adhere to provider
+ ctv.setCheckStateProvider(new TestCheckStateProvider(0));
+
+ ctv.expandAll();
+
+ //Check that all states are properly set
+ checkAllStates("Testing checkbox state after refresh", ctv, 0);
+
+ //Remove the check state provider
+ ctv.setCheckStateProvider(null);
+
+ //Test that an update doesn't fail
+ TestElement update = fRootElement.getFirstChild().getChildAt(5);
+ ctv.update(update, null);
+
+ //Test that a refresh doesn't fail
+ ctv.refresh();
+ }
+
+ public void testCheckProviderWithSorter() {
+ CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
+
+ ctv.setSorter(new CheckStateProviderTestsUtil.Sorter());
+
+ //First provider
+ //Should cause visible items' check state adhere to provider
+ ctv.setCheckStateProvider(new TestCheckStateProvider(0));
+ ctv.expandAll();
+
+ //Check that all states are properly set
+ checkAllStates("Testing checkbox state with a sorter", ctv, 0);
+ }
+
+ public void testCheckProviderWithFilter() {
+ CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
+
+ final CheckStateProviderTestsUtil.Filter filter = new CheckStateProviderTestsUtil.Filter();
+ ctv.addFilter(filter);
+
+ //First provider
+ //Should cause visible items' check state adhere to provider
+ final TestCheckStateProvider checkStateProvider = new TestCheckStateProvider(0);
+ ctv.setCheckStateProvider(checkStateProvider);
+ ctv.expandAll();
+
+ //Check that all states are properly set
+ checkAllStates("Testing checkbox state with a sorter", ctv, 0);
+
+ //Check that the provider is only invoked on elements which pass the filter
+ for (Iterator i = checkStateProvider.isCheckedInvokedOn.iterator(); i.hasNext();) {
+ TestElement element = (TestElement) i.next();
+ assertTrue("The check provider should not be invoked on elements which did not get through the filter", filter.select(ctv, null, element));
+ }
+
+ for (Iterator i = checkStateProvider.isGrayedInvokedOn.iterator(); i.hasNext();) {
+ TestElement element = (TestElement) i.next();
+ assertTrue("The check provider should not be invoked on elements which did not get through the filter", filter.select(ctv, null, element));
+ }
+ }
+
+ public void testSetNewCheckProvider() {
+ CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
+
+ //First provider
+ //Should cause visible items' check state to adhere to provider
+ ctv.setCheckStateProvider(new TestCheckStateProvider(0));
+ ctv.expandAll();
+
+ checkAllStates("Testing checkbox state after first refresh", ctv, 0);
+
+ //Put in a new check state provider
+ ctv.setCheckStateProvider(new TestCheckStateProvider(1));
+
+ //Check that setting a new check provider caused a refresh,
+ //and thus all the items have their new appropriate check
+ //states.
+ checkAllStates("Testing checkbox state after setting new check provider", ctv, 1);
+ }
+
+ private void collectElementsInBranch(TreeItem item, Collection treeItems, Collection testElements) {
+ treeItems.add(item);
+ testElements.add(item.getData());
+ TreeItem[] children = item.getItems();
+ for (int i = 0; i < children.length; i++) {
+ collectElementsInBranch(children[i], treeItems, testElements);
+ }
+ }
+
+ private void checkAllStates(String comment, CheckboxTreeViewer ctv, int shift) {
+ List items = new ArrayList();
+ List elements = new ArrayList();
+ collectElementsInBranch(ctv.getTree().getItem(0), items, elements);
+
+ //Check that actual states were set properly
+ for (Iterator i = items.iterator(), j = elements.iterator(); i.hasNext();) {
+ TreeItem item = (TreeItem)i.next();
+ TestElement element = (TestElement)j.next();
+
+ checkState(comment, element, item, shift); //check in Tree
+ checkState(comment, element, ctv, shift); //check in Viewer
+ }
+ }
+
+ /**
+ * Invokes the appropriate asserts to verify the state
+ * of a TestElement.
+ * @param te
+ * @param viewer the viewer <code>te</code> is in.
+ * @param shift the shift parameter being used
+ */
+ private void checkState(String comment, TestElement te, CheckboxTreeViewer viewer, int shift) {
+ assertEquals(comment, CheckStateProviderTestsUtil.shouldBeChecked(te, shift), viewer.getChecked(te));
+ assertEquals(comment, CheckStateProviderTestsUtil.shouldBeGrayed(te, shift), viewer.getGrayed(te));
+ }
+
+ /**
+ * Invokes the appropriate asserts to verify the state
+ * of a TestElement's associated TreeItem
+ * @param te
+ * @param item the item representing <code>te</code>
+ * @param shift the shift parameter being used
+ */
+ private void checkState(String comment, TestElement te, TreeItem item, int shift) {
+ assertEquals("Wrong checkstate: " + comment, CheckStateProviderTestsUtil.shouldBeChecked(te, shift), item.getChecked());
+ assertEquals("Wrong checkstate: " + comment, CheckStateProviderTestsUtil.shouldBeGrayed(te, shift), item.getGrayed());
+ }
+
+ public void testGetCheckedElements() {
+ CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
+
+ TestElement[] children = fRootElement.getChildren();
+
+ List checked = new ArrayList((children.length + 1) / 2);
+
+ for (int i = 0; i < children.length; i+=2) {
+ ctv.setChecked(children[i], true);
+ checked.add(children[i]);
+ }
+
+ Object[] actuallyChecked = ctv.getCheckedElements();
+
+ for (int i = 0; i < actuallyChecked.length; i++) {
+ assertTrue("getCheckedElements should include all checked elements", checked.remove(actuallyChecked[i]));
+ }
+
+ assertTrue("getCheckedElements should not include any unchecked elements", checked.isEmpty());
+ }
+
+ public void testSetCheckedElements() {
+ CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
+
+ TestElement[] children = fRootElement.getChildren();
+
+ List toCheck = new ArrayList((children.length + 1) / 2);
+
+ for (int i = 0; i < children.length; i+=2) {
+ toCheck.add(children[i]);
+ }
+
+ ctv.setCheckedElements(toCheck.toArray());
+
+ for (int i = 0; i < children.length; i++) {
+ if(i % 2 == 0) {
+ assertTrue("an element passed through setCheckedElements should be checked", ctv.getChecked(children[i]));
+ } else {
+ assertFalse("an element not passed through setCheckedElements should be unchecked", ctv.getChecked(children[i]));
+ }
+ }
+ }
+
+ public void testSetGrayedElements() {
+ CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
+
+ TestElement[] children = fRootElement.getChildren();
+
+ List toGray = new ArrayList((children.length + 1) / 2);
+
+ for (int i = 0; i < children.length; i+=2) {
+ toGray.add(children[i]);
+ }
+
+ ctv.setGrayedElements(toGray.toArray());
+
+ for (int i = 0; i < children.length; i++) {
+ if(i % 2 == 0) {
+ assertTrue("an element passed through setGrayedElements should be grayed", ctv.getGrayed(children[i]));
+ } else {
+ assertFalse("an element not passed through setGrayedElements should not be grayed", ctv.getGrayed(children[i]));
+ }
+ }
+ }
+
+ public void testSetAllChecked() {
+ CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
+
+ ctv.expandToLevel(2);
+
+ ctv.setAllChecked(true);
+ Object[] expandedElements = ctv.getExpandedElements();
+
+ for (int i = 0; i < expandedElements.length; i++) {
+ assertTrue("all expanded items should be checked", ctv.getChecked(expandedElements[i]));
+ }
+
+ ctv.setAllChecked(false);
+
+ for (int i = 0; i < expandedElements.length; i++) {
+ assertFalse("all expanded items should be unchecked", ctv.getChecked(expandedElements[i]));
+ }
+ }
+
+ public void testSetGrayChecked() {
+ CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
+
+ TestElement[] children = fRootElement.getChildren();
+
+ ctv.setGrayChecked(children[0], true);
+ ctv.setGrayChecked(children[1], false);
+
+ assertTrue("an item invoked with setGrayChecked(true) should be checked", ctv.getChecked(children[0]));
+ assertTrue("an item invoked with setGrayChecked(true) should be grayed", ctv.getGrayed(children[0]));
+
+ assertFalse("an item invoked with setGrayChecked(false) should be unchecked", ctv.getChecked(children[1]));
+ assertFalse("an item invoked with setGrayChecked(false) should not be grayed", ctv.getGrayed(children[1]));
+ }
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java
index 45afa17e08..1c8c3384d4 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Brad Reynolds.
+ * Copyright (c) 2006, 2007 Brad Reynolds.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java
index ebaa678bc7..a547459aac 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java
index 45e217b2e2..e1ce675cde 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -116,8 +116,8 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
processEvents();
Tree tree = getTreeViewer().getTree();
getTreeViewer().expandToLevel("R-0", 1);
- // force redrawing the tree - this will trigger the SetData event
- tree.update();
+ // redraw the tree - this will trigger the SetData event
+ processEvents();
assertEquals(NUM_CHILDREN, tree.getItem(0).getItemCount());
TreeItem treeItem = tree.getItem(0).getItem(3);
expandAndNotify(treeItem);
@@ -137,7 +137,7 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
Event event = new Event();
event.item = treeItem;
event.type = SWT.Expand;
-// tree.(SWT.Expand, event);
+ tree.notifyListeners(SWT.Expand, event);
} finally {
// callbacksEnabled = true;
tree.setRedraw(true);
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java
index b4dc395db5..8ea3831de0 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -190,6 +190,106 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
assertTrue("unfiltered count", getItemCount() == 10);
}
+ public void testSetAndGetData() {
+
+ //get with no data
+ assertNull("get with no data", fViewer.getData("foo"));
+
+ //remove with no data
+ fViewer.setData("foo", null);
+
+ //get with no data after remove
+ assertNull("get with no data after remove", fViewer.getData("foo"));
+
+ //set
+ fViewer.setData("foo", "bar");
+
+ //remove key which does not exist
+ fViewer.setData("baz", null);
+
+ //get key which does not exist
+ assertNull("get key which does not exist", fViewer.getData("baz"));
+
+ //get value instead of key
+ assertNull("get value instead of key", fViewer.getData("bar"));
+
+ //get single value
+ assertEquals("get single value", "bar", fViewer.getData("foo"));
+
+ //set new value
+ fViewer.setData("foo", "baz");
+
+ //get overridden value
+ assertEquals("get overridden value", "baz", fViewer.getData("foo"));
+
+ //add more values
+ fViewer.setData("alpha", "1");
+ fViewer.setData("beta", "2");
+ fViewer.setData("delta", "3");
+
+ //get multiple values
+ assertEquals("get multiple values", "baz", fViewer.getData("foo"));
+ assertEquals("get multiple values", "1", fViewer.getData("alpha"));
+ assertEquals("get multiple values", "2", fViewer.getData("beta"));
+ assertEquals("get multiple values", "3", fViewer.getData("delta"));
+
+ //override with multiple values
+ fViewer.setData("alpha", "10");
+
+ //get overridden value
+ assertEquals("get overridden value", "10", fViewer.getData("alpha"));
+
+ //add more values
+ fViewer.setData("gamma", "4");
+ fViewer.setData("epsilon", "5");
+
+ //remove first value
+ fViewer.setData("foo", null);
+
+ //check remaining values
+ assertEquals("get after remove", null, fViewer.getData("foo"));
+ assertEquals("get after remove", "10", fViewer.getData("alpha"));
+ assertEquals("get after remove", "2", fViewer.getData("beta"));
+ assertEquals("get after remove", "3", fViewer.getData("delta"));
+ assertEquals("get after remove", "4", fViewer.getData("gamma"));
+ assertEquals("get after remove", "5", fViewer.getData("epsilon"));
+
+ //remove middle value
+ fViewer.setData("delta", null);
+
+ //check remaining values
+ assertEquals("get after remove", null, fViewer.getData("foo"));
+ assertEquals("get after remove", "10", fViewer.getData("alpha"));
+ assertEquals("get after remove", "2", fViewer.getData("beta"));
+ assertEquals("get after remove", null, fViewer.getData("delta"));
+ assertEquals("get after remove", "4", fViewer.getData("gamma"));
+ assertEquals("get after remove", "5", fViewer.getData("epsilon"));
+
+ //remove last value
+ fViewer.setData("epsilon", null);
+
+ //check remaining values
+ assertEquals("get after remove", null, fViewer.getData("foo"));
+ assertEquals("get after remove", "10", fViewer.getData("alpha"));
+ assertEquals("get after remove", "2", fViewer.getData("beta"));
+ assertEquals("get after remove", null, fViewer.getData("delta"));
+ assertEquals("get after remove", "4", fViewer.getData("gamma"));
+ assertEquals("get after remove", null, fViewer.getData("epsilon"));
+
+ //remove remaining values
+ fViewer.setData("alpha", null);
+ fViewer.setData("beta", null);
+ fViewer.setData("gamma", null);
+
+ //check final values
+ assertEquals("get after remove", null, fViewer.getData("foo"));
+ assertEquals("get after remove", null, fViewer.getData("alpha"));
+ assertEquals("get after remove", null, fViewer.getData("beta"));
+ assertEquals("get after remove", null, fViewer.getData("delta"));
+ assertEquals("get after remove", null, fViewer.getData("gamma"));
+ assertEquals("get after remove", null, fViewer.getData("epsilon"));
+ }
+
public void testInsertChild() {
TestElement first = fRootElement.getFirstChild();
TestElement newElement = first.addChild(TestModelChange.INSERT);
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeManagerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeManagerTest.java
new file mode 100644
index 0000000000..288617eae3
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeManagerTest.java
@@ -0,0 +1,654 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jface.tests.viewers;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ui.internal.dialogs.TreeManager;
+import org.eclipse.ui.internal.dialogs.TreeManager.TreeItem;
+
+public class TreeManagerTest extends TestCase {
+
+ private static final List STATE_NAMES;
+
+ private static final int CHECKSTATE_UNCHECKED = 0;
+ private static final int CHECKSTATE_GRAY = 1;
+ private static final int CHECKSTATE_CHECKED = 2;
+
+ static {
+ STATE_NAMES = new ArrayList();
+ STATE_NAMES.add(CHECKSTATE_UNCHECKED, "unchecked");
+ STATE_NAMES.add(CHECKSTATE_GRAY, "gray");
+ STATE_NAMES.add(CHECKSTATE_CHECKED, "checked");
+ }
+
+ private static String getName(int checkstate) {
+ return (String)STATE_NAMES.get(checkstate);
+ }
+
+ private static void assertState(TreeItem item, int expectedState) throws Exception {
+ Field checkStateField = TreeItem.class.getDeclaredField("checkState");
+ checkStateField.setAccessible(true);
+ int checkState = checkStateField.getInt(item);
+
+ assertEquals("For TreeItem " + item.getLabel() + ", expected " +
+ getName(expectedState) + " but was " + getName(checkState) + ";",
+ expectedState, checkState);
+ }
+
+ public void testSingleEntry() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem item = manager.new TreeItem("item");
+
+ item.setCheckState(true);
+ assertState(item, CHECKSTATE_CHECKED);
+
+ item.setCheckState(true);
+ assertState(item, CHECKSTATE_CHECKED);
+
+ item.setCheckState(false);
+ assertState(item, CHECKSTATE_UNCHECKED);
+
+ item.setCheckState(true);
+ assertState(item, CHECKSTATE_CHECKED);
+
+ item.setCheckState(false);
+ assertState(item, CHECKSTATE_UNCHECKED);
+
+ item.setCheckState(false);
+ assertState(item, CHECKSTATE_UNCHECKED);
+ }
+
+ public void testSingleChildAffectsParent() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem parent = manager.new TreeItem("parent");
+ TreeItem child = manager.new TreeItem("child");
+ parent.addChild(child);
+
+ child.setCheckState(true);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(child, CHECKSTATE_CHECKED);
+
+ child.setCheckState(true);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(child, CHECKSTATE_CHECKED);
+
+ child.setCheckState(false);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(child, CHECKSTATE_UNCHECKED);
+
+ child.setCheckState(true);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(child, CHECKSTATE_CHECKED);
+
+ child.setCheckState(false);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(child, CHECKSTATE_UNCHECKED);
+
+ child.setCheckState(false);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(child, CHECKSTATE_UNCHECKED);
+ }
+
+ public void testTwoChildrenAffectParent() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem parent = manager.new TreeItem("parent");
+ TreeItem son = manager.new TreeItem("son");
+ TreeItem daughter = manager.new TreeItem("daughter");
+ parent.addChild(son);
+ parent.addChild(daughter);
+
+ son.setCheckState(true);
+ daughter.setCheckState(false);
+ assertState(parent, CHECKSTATE_GRAY);
+ assertState(son, CHECKSTATE_CHECKED);
+ assertState(daughter, CHECKSTATE_UNCHECKED);
+
+ daughter.setCheckState(true);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(son, CHECKSTATE_CHECKED);
+ assertState(daughter, CHECKSTATE_CHECKED);
+
+ son.setCheckState(false);
+ assertState(parent, CHECKSTATE_GRAY);
+ assertState(son, CHECKSTATE_UNCHECKED);
+ assertState(daughter, CHECKSTATE_CHECKED);
+
+ daughter.setCheckState(false);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(son, CHECKSTATE_UNCHECKED);
+ assertState(daughter, CHECKSTATE_UNCHECKED);
+ }
+
+ public void testCheckUncheckChildAt3Deep() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem grandparent = manager.new TreeItem("grandparent");
+ TreeItem parent = manager.new TreeItem("parent");
+ TreeItem child = manager.new TreeItem("child");
+ grandparent.addChild(parent);
+ parent.addChild(child);
+
+ child.setCheckState(true);
+ assertState(grandparent, CHECKSTATE_CHECKED);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(child, CHECKSTATE_CHECKED);
+
+ child.setCheckState(true);
+ assertState(grandparent, CHECKSTATE_CHECKED);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(child, CHECKSTATE_CHECKED);
+
+ child.setCheckState(false);
+ assertState(grandparent, CHECKSTATE_UNCHECKED);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(child, CHECKSTATE_UNCHECKED);
+
+ child.setCheckState(true);
+ assertState(grandparent, CHECKSTATE_CHECKED);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(child, CHECKSTATE_CHECKED);
+
+ child.setCheckState(false);
+ assertState(grandparent, CHECKSTATE_UNCHECKED);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(child, CHECKSTATE_UNCHECKED);
+
+ child.setCheckState(false);
+ assertState(grandparent, CHECKSTATE_UNCHECKED);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(child, CHECKSTATE_UNCHECKED);
+ }
+
+ public void testCauseGrayAt3Deep() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem grandparent = manager.new TreeItem("grandparent");
+ TreeItem parent = manager.new TreeItem("parent");
+ TreeItem child1 = manager.new TreeItem("child1");
+ TreeItem child2 = manager.new TreeItem("child2");
+ grandparent.addChild(parent);
+ parent.addChild(child1);
+ parent.addChild(child2);
+
+ child1.setCheckState(true);
+ child2.setCheckState(false);
+ assertState(grandparent, CHECKSTATE_GRAY);
+ assertState(parent, CHECKSTATE_GRAY);
+ assertState(child1, CHECKSTATE_CHECKED);
+ assertState(child2, CHECKSTATE_UNCHECKED);
+
+ child2.setCheckState(true);
+ assertState(grandparent, CHECKSTATE_CHECKED);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(child1, CHECKSTATE_CHECKED);
+ assertState(child2, CHECKSTATE_CHECKED);
+
+ child1.setCheckState(false);
+ assertState(grandparent, CHECKSTATE_GRAY);
+ assertState(parent, CHECKSTATE_GRAY);
+ assertState(child1, CHECKSTATE_UNCHECKED);
+ assertState(child2, CHECKSTATE_CHECKED);
+
+ child2.setCheckState(false);
+ assertState(grandparent, CHECKSTATE_UNCHECKED);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(child1, CHECKSTATE_UNCHECKED);
+ assertState(child2, CHECKSTATE_UNCHECKED);
+ }
+
+ public void testCheckUncheckChildAt5Deep() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem items[] = new TreeItem[5];
+ for(int i = 0; i < items.length; i++) {
+ items[i] = manager.new TreeItem("item" + i);
+ if(i > 0)
+ items[i-1].addChild(items[i]);
+ }
+
+ items[4].setCheckState(true);
+ for(int i = 0; i < items.length; i++)
+ assertState(items[i], CHECKSTATE_CHECKED);
+
+ items[4].setCheckState(false);
+ for(int i = 0; i < items.length; i++)
+ assertState(items[i], CHECKSTATE_UNCHECKED);
+ }
+
+ public void testCauseGrayAt5Deep() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem items[] = new TreeItem[4];
+ for(int i = 0; i < items.length; i++) {
+ items[i] = manager.new TreeItem("item" + i);
+ if(i > 0)
+ items[i-1].addChild(items[i]);
+ }
+ TreeItem child1 = manager.new TreeItem("child1");
+ TreeItem child2 = manager.new TreeItem("child2");
+ items[3].addChild(child1);
+ items[3].addChild(child2);
+
+ child1.setCheckState(true);
+ child2.setCheckState(false);
+ for(int i = 0; i < items.length; i++)
+ assertState(items[i], CHECKSTATE_GRAY);
+ assertState(child1, CHECKSTATE_CHECKED);
+ assertState(child2, CHECKSTATE_UNCHECKED);
+
+ child2.setCheckState(true);
+ for(int i = 0; i < items.length; i++)
+ assertState(items[i], CHECKSTATE_CHECKED);
+ assertState(child1, CHECKSTATE_CHECKED);
+ assertState(child2, CHECKSTATE_CHECKED);
+
+ child1.setCheckState(false);
+ for(int i = 0; i < items.length; i++)
+ assertState(items[i], CHECKSTATE_GRAY);
+ assertState(child1, CHECKSTATE_UNCHECKED);
+ assertState(child2, CHECKSTATE_CHECKED);
+
+ child2.setCheckState(false);
+ for(int i = 0; i < items.length; i++)
+ assertState(items[i], CHECKSTATE_UNCHECKED);
+ assertState(child1, CHECKSTATE_UNCHECKED);
+ assertState(child2, CHECKSTATE_UNCHECKED);
+ }
+
+ public void testChildrenInMultipleBranchesAffectAncestors() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem root = manager.new TreeItem("root");
+ TreeItem itemA = manager.new TreeItem("itemA");
+ TreeItem itemA1 = manager.new TreeItem("itemA1");
+ TreeItem itemA2 = manager.new TreeItem("itemA2");
+ TreeItem itemB = manager.new TreeItem("itemB");
+ TreeItem itemB1 = manager.new TreeItem("itemB1");
+ TreeItem itemB2 = manager.new TreeItem("itemB2");
+
+ root.addChild(itemA);
+ root.addChild(itemB);
+ itemA.addChild(itemA1);
+ itemA.addChild(itemA2);
+ itemB.addChild(itemB1);
+ itemB.addChild(itemB2);
+
+ itemA1.setCheckState(true);
+ itemA2.setCheckState(false);
+ itemB1.setCheckState(false);
+ itemB2.setCheckState(false);
+
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(itemA, CHECKSTATE_GRAY);
+ assertState(itemA1, CHECKSTATE_CHECKED);
+ assertState(itemA2, CHECKSTATE_UNCHECKED);
+ assertState(itemB, CHECKSTATE_UNCHECKED);
+ assertState(itemB1, CHECKSTATE_UNCHECKED);
+ assertState(itemB2, CHECKSTATE_UNCHECKED);
+
+ itemB2.setCheckState(true);
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(itemA, CHECKSTATE_GRAY);
+ assertState(itemA1, CHECKSTATE_CHECKED);
+ assertState(itemA2, CHECKSTATE_UNCHECKED);
+ assertState(itemB, CHECKSTATE_GRAY);
+ assertState(itemB1, CHECKSTATE_UNCHECKED);
+ assertState(itemB2, CHECKSTATE_CHECKED);
+
+ itemA1.setCheckState(false);
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(itemA, CHECKSTATE_UNCHECKED);
+ assertState(itemA1, CHECKSTATE_UNCHECKED);
+ assertState(itemA2, CHECKSTATE_UNCHECKED);
+ assertState(itemB, CHECKSTATE_GRAY);
+ assertState(itemB1, CHECKSTATE_UNCHECKED);
+ assertState(itemB2, CHECKSTATE_CHECKED);
+
+ itemB1.setCheckState(true);
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(itemA, CHECKSTATE_UNCHECKED);
+ assertState(itemA1, CHECKSTATE_UNCHECKED);
+ assertState(itemA2, CHECKSTATE_UNCHECKED);
+ assertState(itemB, CHECKSTATE_CHECKED);
+ assertState(itemB1, CHECKSTATE_CHECKED);
+ assertState(itemB2, CHECKSTATE_CHECKED);
+
+ itemA1.setCheckState(true);
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(itemA, CHECKSTATE_GRAY);
+ assertState(itemA1, CHECKSTATE_CHECKED);
+ assertState(itemA2, CHECKSTATE_UNCHECKED);
+ assertState(itemB, CHECKSTATE_CHECKED);
+ assertState(itemB1, CHECKSTATE_CHECKED);
+ assertState(itemB2, CHECKSTATE_CHECKED);
+
+ itemA2.setCheckState(true);
+ assertState(root, CHECKSTATE_CHECKED);
+ assertState(itemA, CHECKSTATE_CHECKED);
+ assertState(itemA1, CHECKSTATE_CHECKED);
+ assertState(itemA2, CHECKSTATE_CHECKED);
+ assertState(itemB, CHECKSTATE_CHECKED);
+ assertState(itemB1, CHECKSTATE_CHECKED);
+ assertState(itemB2, CHECKSTATE_CHECKED);
+
+ itemB2.setCheckState(false);
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(itemA, CHECKSTATE_CHECKED);
+ assertState(itemA1, CHECKSTATE_CHECKED);
+ assertState(itemA2, CHECKSTATE_CHECKED);
+ assertState(itemB, CHECKSTATE_GRAY);
+ assertState(itemB1, CHECKSTATE_CHECKED);
+ assertState(itemB2, CHECKSTATE_UNCHECKED);
+
+ itemA1.setCheckState(false);
+ itemA2.setCheckState(false);
+ itemB1.setCheckState(false);
+ assertState(root, CHECKSTATE_UNCHECKED);
+ assertState(itemA, CHECKSTATE_UNCHECKED);
+ assertState(itemA1, CHECKSTATE_UNCHECKED);
+ assertState(itemA2, CHECKSTATE_UNCHECKED);
+ assertState(itemB, CHECKSTATE_UNCHECKED);
+ assertState(itemB1, CHECKSTATE_UNCHECKED);
+ assertState(itemB2, CHECKSTATE_UNCHECKED);
+ }
+
+ public void testMultipleChildrenInOneBranchAffectParent() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem root = manager.new TreeItem("root");
+ TreeItem items[] = new TreeItem[5];
+ for(int i = 0; i < items.length; i++) {
+ items[i] = manager.new TreeItem("child" + i);
+ root.addChild(items[i]);
+ items[i].setCheckState(false);
+ }
+
+ items[0].setCheckState(true);
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(items[0], CHECKSTATE_CHECKED);
+ assertState(items[1], CHECKSTATE_UNCHECKED);
+ assertState(items[2], CHECKSTATE_UNCHECKED);
+ assertState(items[3], CHECKSTATE_UNCHECKED);
+ assertState(items[4], CHECKSTATE_UNCHECKED);
+
+ items[1].setCheckState(true);
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(items[0], CHECKSTATE_CHECKED);
+ assertState(items[1], CHECKSTATE_CHECKED);
+ assertState(items[2], CHECKSTATE_UNCHECKED);
+ assertState(items[3], CHECKSTATE_UNCHECKED);
+ assertState(items[4], CHECKSTATE_UNCHECKED);
+
+ items[0].setCheckState(false);
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(items[0], CHECKSTATE_UNCHECKED);
+ assertState(items[1], CHECKSTATE_CHECKED);
+ assertState(items[2], CHECKSTATE_UNCHECKED);
+ assertState(items[3], CHECKSTATE_UNCHECKED);
+ assertState(items[4], CHECKSTATE_UNCHECKED);
+
+ items[2].setCheckState(true);
+ items[3].setCheckState(true);
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(items[0], CHECKSTATE_UNCHECKED);
+ assertState(items[1], CHECKSTATE_CHECKED);
+ assertState(items[2], CHECKSTATE_CHECKED);
+ assertState(items[3], CHECKSTATE_CHECKED);
+ assertState(items[4], CHECKSTATE_UNCHECKED);
+
+ items[0].setCheckState(true);
+ items[4].setCheckState(true);
+ assertState(root, CHECKSTATE_CHECKED);
+ assertState(items[0], CHECKSTATE_CHECKED);
+ assertState(items[1], CHECKSTATE_CHECKED);
+ assertState(items[2], CHECKSTATE_CHECKED);
+ assertState(items[3], CHECKSTATE_CHECKED);
+ assertState(items[4], CHECKSTATE_CHECKED);
+
+ items[2].setCheckState(false);
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(items[0], CHECKSTATE_CHECKED);
+ assertState(items[1], CHECKSTATE_CHECKED);
+ assertState(items[2], CHECKSTATE_UNCHECKED);
+ assertState(items[3], CHECKSTATE_CHECKED);
+ assertState(items[4], CHECKSTATE_CHECKED);
+
+ items[0].setCheckState(false);
+ items[1].setCheckState(false);
+ items[3].setCheckState(false);
+ items[4].setCheckState(false);
+ assertState(root, CHECKSTATE_UNCHECKED);
+ assertState(items[0], CHECKSTATE_UNCHECKED);
+ assertState(items[1], CHECKSTATE_UNCHECKED);
+ assertState(items[2], CHECKSTATE_UNCHECKED);
+ assertState(items[3], CHECKSTATE_UNCHECKED);
+ assertState(items[4], CHECKSTATE_UNCHECKED);
+ }
+
+ public void testParentAffectsSingleChild() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem parent = manager.new TreeItem("parent");
+ TreeItem child = manager.new TreeItem("child");
+ parent.addChild(child);
+
+ parent.setCheckState(true);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(child, CHECKSTATE_CHECKED);
+
+ parent.setCheckState(true);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(child, CHECKSTATE_CHECKED);
+
+ parent.setCheckState(false);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(child, CHECKSTATE_UNCHECKED);
+
+ parent.setCheckState(true);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(child, CHECKSTATE_CHECKED);
+
+ parent.setCheckState(false);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(child, CHECKSTATE_UNCHECKED);
+
+ parent.setCheckState(false);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(child, CHECKSTATE_UNCHECKED);
+ }
+
+ public void testParentAffectsTwoChildren() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem parent = manager.new TreeItem("parent");
+ TreeItem son = manager.new TreeItem("son");
+ TreeItem daughter = manager.new TreeItem("daughter");
+ parent.addChild(son);
+ parent.addChild(daughter);
+
+ parent.setCheckState(true);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(son, CHECKSTATE_CHECKED);
+ assertState(daughter, CHECKSTATE_CHECKED);
+
+ parent.setCheckState(true);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(son, CHECKSTATE_CHECKED);
+ assertState(daughter, CHECKSTATE_CHECKED);
+
+ parent.setCheckState(false);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(son, CHECKSTATE_UNCHECKED);
+ assertState(daughter, CHECKSTATE_UNCHECKED);
+
+ parent.setCheckState(true);
+ assertState(parent, CHECKSTATE_CHECKED);
+ assertState(son, CHECKSTATE_CHECKED);
+ assertState(daughter, CHECKSTATE_CHECKED);
+
+ parent.setCheckState(false);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(son, CHECKSTATE_UNCHECKED);
+ assertState(daughter, CHECKSTATE_UNCHECKED);
+
+ parent.setCheckState(false);
+ assertState(parent, CHECKSTATE_UNCHECKED);
+ assertState(son, CHECKSTATE_UNCHECKED);
+ assertState(daughter, CHECKSTATE_UNCHECKED);
+ }
+
+ public void testParentAffectsMultipleChildrenInOneBranch() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem root = manager.new TreeItem("root");
+ TreeItem items[] = new TreeItem[5];
+ for(int i = 0; i < items.length; i++) {
+ items[i] = manager.new TreeItem("child" + i);
+ root.addChild(items[i]);
+ items[i].setCheckState(false);
+ }
+
+ root.setCheckState(true);
+ assertState(root, CHECKSTATE_CHECKED);
+ assertState(items[0], CHECKSTATE_CHECKED);
+ assertState(items[1], CHECKSTATE_CHECKED);
+ assertState(items[2], CHECKSTATE_CHECKED);
+ assertState(items[3], CHECKSTATE_CHECKED);
+ assertState(items[4], CHECKSTATE_CHECKED);
+
+ root.setCheckState(false);
+ assertState(root, CHECKSTATE_UNCHECKED);
+ assertState(items[0], CHECKSTATE_UNCHECKED);
+ assertState(items[1], CHECKSTATE_UNCHECKED);
+ assertState(items[2], CHECKSTATE_UNCHECKED);
+ assertState(items[3], CHECKSTATE_UNCHECKED);
+ assertState(items[4], CHECKSTATE_UNCHECKED);
+ }
+
+ public void testParentAffectsDescendantsInMultipleBranches() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem root = manager.new TreeItem("root");
+ TreeItem itemA = manager.new TreeItem("itemA");
+ TreeItem itemA1 = manager.new TreeItem("itemA1");
+ TreeItem itemA2 = manager.new TreeItem("itemA2");
+ TreeItem itemB = manager.new TreeItem("itemB");
+ TreeItem itemB1 = manager.new TreeItem("itemB1");
+ TreeItem itemB2 = manager.new TreeItem("itemB2");
+
+ root.addChild(itemA);
+ root.addChild(itemB);
+ itemA.addChild(itemA1);
+ itemA.addChild(itemA2);
+ itemB.addChild(itemB1);
+ itemB.addChild(itemB2);
+
+ root.setCheckState(true);
+ assertState(root, CHECKSTATE_CHECKED);
+ assertState(itemA, CHECKSTATE_CHECKED);
+ assertState(itemA1, CHECKSTATE_CHECKED);
+ assertState(itemA2, CHECKSTATE_CHECKED);
+ assertState(itemB, CHECKSTATE_CHECKED);
+ assertState(itemB1, CHECKSTATE_CHECKED);
+ assertState(itemB2, CHECKSTATE_CHECKED);
+
+ root.setCheckState(false);
+ assertState(root, CHECKSTATE_UNCHECKED);
+ assertState(itemA, CHECKSTATE_UNCHECKED);
+ assertState(itemA1, CHECKSTATE_UNCHECKED);
+ assertState(itemA2, CHECKSTATE_UNCHECKED);
+ assertState(itemB, CHECKSTATE_UNCHECKED);
+ assertState(itemB1, CHECKSTATE_UNCHECKED);
+ assertState(itemB2, CHECKSTATE_UNCHECKED);
+ }
+
+ public void testCheckUncheckParentWithDescendants5Deep() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem items[] = new TreeItem[5];
+ for(int i = 0; i < items.length; i++) {
+ items[i] = manager.new TreeItem("item" + i);
+ if(i > 0)
+ items[i-1].addChild(items[i]);
+ }
+
+ items[0].setCheckState(true);
+ for(int i = 0; i < items.length; i++)
+ assertState(items[i], CHECKSTATE_CHECKED);
+
+ items[0].setCheckState(false);
+ for(int i = 0; i < items.length; i++)
+ assertState(items[i], CHECKSTATE_UNCHECKED);
+ }
+
+ public void testChangeOnGray() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem root = manager.new TreeItem("root");
+ TreeItem itemA = manager.new TreeItem("itemA");
+ TreeItem itemA1 = manager.new TreeItem("itemA1");
+ TreeItem itemA2 = manager.new TreeItem("itemA2");
+ TreeItem itemB = manager.new TreeItem("itemB");
+
+ root.addChild(itemA);
+ root.addChild(itemB);
+ itemA.addChild(itemA1);
+ itemA.addChild(itemA2);
+
+ root.setCheckState(true);
+ assertState(root, CHECKSTATE_CHECKED);
+ assertState(itemA, CHECKSTATE_CHECKED);
+ assertState(itemA1, CHECKSTATE_CHECKED);
+ assertState(itemA2, CHECKSTATE_CHECKED);
+ assertState(itemB, CHECKSTATE_CHECKED);
+
+ itemA.setCheckState(false);
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(itemA, CHECKSTATE_UNCHECKED);
+ assertState(itemA1, CHECKSTATE_UNCHECKED);
+ assertState(itemA2, CHECKSTATE_UNCHECKED);
+ assertState(itemB, CHECKSTATE_CHECKED);
+
+ itemA1.setCheckState(true);
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(itemA, CHECKSTATE_GRAY);
+ assertState(itemA1, CHECKSTATE_CHECKED);
+ assertState(itemA2, CHECKSTATE_UNCHECKED);
+ assertState(itemB, CHECKSTATE_CHECKED);
+
+ itemA.setCheckState(false);
+ assertState(root, CHECKSTATE_GRAY);
+ assertState(itemA, CHECKSTATE_UNCHECKED);
+ assertState(itemA1, CHECKSTATE_UNCHECKED);
+ assertState(itemA2, CHECKSTATE_UNCHECKED);
+ assertState(itemB, CHECKSTATE_CHECKED);
+
+ itemA.setCheckState(true);
+ assertState(root, CHECKSTATE_CHECKED);
+ assertState(itemA, CHECKSTATE_CHECKED);
+ assertState(itemA1, CHECKSTATE_CHECKED);
+ assertState(itemA2, CHECKSTATE_CHECKED);
+ assertState(itemB, CHECKSTATE_CHECKED);
+ }
+
+ public void testCheckUncheckItemWithAncestorsAndDescendants() throws Exception {
+ TreeManager manager = new TreeManager();
+ TreeItem items[] = new TreeItem[5];
+ for(int i = 0; i < items.length; i++) {
+ items[i] = manager.new TreeItem("item" + i);
+ if(i > 0)
+ items[i-1].addChild(items[i]);
+ }
+
+ items[3].setCheckState(true);
+ for(int i = 0; i < items.length; i++)
+ assertState(items[i], CHECKSTATE_CHECKED);
+
+ items[3].setCheckState(false);
+ for(int i = 0; i < items.length; i++)
+ assertState(items[i], CHECKSTATE_UNCHECKED);
+ }
+
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ConcurrentTableTestView.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ConcurrentTableTestView.java
index 3dbc286830..fec0999339 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ConcurrentTableTestView.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ConcurrentTableTestView.java
@@ -54,10 +54,8 @@ public class ConcurrentTableTestView extends ViewPart {
int delay = 2; // Time to spin the CPU for (milliseconds)
// Do some work to occupy time
- int counter = 0;
long timestamp = System.currentTimeMillis();
while (System.currentTimeMillis() < timestamp + delay) {
- counter++;
}
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyVirtualTableView.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyVirtualTableView.java
index 9508a64d8a..0206c112e9 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyVirtualTableView.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyVirtualTableView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.jface.tests.viewers.interactive;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ILazyContentProvider;
import org.eclipse.jface.viewers.Viewer;
@@ -20,11 +23,24 @@ import org.eclipse.jface.viewers.Viewer;
*/
public class LazyVirtualTableView extends VirtualTableView {
+ private List elements;
+
/**
* Create a new instance of the receiver.
*/
public LazyVirtualTableView() {
super();
+ initElements();
+ }
+
+ /**
+ *
+ */
+ private void initElements() {
+ elements = new ArrayList();
+ for (int i = 0; i < itemCount; i++) {
+ elements.add("Element " + String.valueOf(i));
+ }
}
/* (non-Javadoc)
@@ -37,7 +53,7 @@ public class LazyVirtualTableView extends VirtualTableView {
* @see org.eclipse.jface.viewers.ILazyContentProvider#updateElements(int, int)
*/
public void updateElement(int index) {
- viewer.replace("Element " + String.valueOf(index), index);
+ viewer.replace(elements.get(index), index);
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
@@ -54,6 +70,17 @@ public class LazyVirtualTableView extends VirtualTableView {
}
};
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.tests.viewers.interactive.VirtualTableView#doRemove(java.lang.Object[])
+ */
+ protected void doRemove(Object[] selection, int[] selectionIndices) {
+ for (int i = 0; i < selectionIndices.length; i++) {
+ int index = selectionIndices[i];
+ elements.remove(index);
+ }
+ super.doRemove(selection, selectionIndices);
+ }
/* (non-Javadoc)
* @see org.eclipse.jface.tests.viewers.interactive.VirtualTableView#resetInput()
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/StyledCellLabelProviderTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/StyledCellLabelProviderTests.java
new file mode 100644
index 0000000000..b886fe5b80
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/StyledCellLabelProviderTests.java
@@ -0,0 +1,329 @@
+///*******************************************************************************
+// * Copyright (c) 2007, 2008 IBM Corporation and others.
+// * All rights reserved. This program and the accompanying materials
+// * are 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
+// *
+// * Contributors:
+// * IBM Corporation - initial API and implementation
+// * Michael Krkoska - initial API and implementation (bug 188333)
+// *******************************************************************************/
+//package org.eclipse.jface.tests.viewers.interactive;
+//
+//import java.text.DecimalFormat;
+//import java.text.MessageFormat;
+//
+//import org.eclipse.jface.preference.JFacePreferences;
+//import org.eclipse.jface.resource.JFaceResources;
+//import org.eclipse.jface.viewers.IStructuredContentProvider;
+//import org.eclipse.jface.viewers.StyledCellLabelProvider;
+//import org.eclipse.jface.viewers.StyledString;
+//import org.eclipse.jface.viewers.TableViewer;
+//import org.eclipse.jface.viewers.Viewer;
+//import org.eclipse.jface.viewers.ViewerCell;
+//import org.eclipse.jface.viewers.StyledString.Styler;
+//import org.eclipse.swt.SWT;
+//import org.eclipse.swt.events.SelectionAdapter;
+//import org.eclipse.swt.events.SelectionEvent;
+//import org.eclipse.swt.graphics.Font;
+//import org.eclipse.swt.graphics.FontData;
+//import org.eclipse.swt.graphics.Image;
+//import org.eclipse.swt.graphics.RGB;
+//import org.eclipse.swt.graphics.TextStyle;
+//import org.eclipse.swt.layout.GridData;
+//import org.eclipse.swt.layout.GridLayout;
+//import org.eclipse.swt.widgets.Button;
+//import org.eclipse.swt.widgets.Composite;
+//import org.eclipse.swt.widgets.Control;
+//import org.eclipse.swt.widgets.Display;
+//import org.eclipse.swt.widgets.Event;
+//import org.eclipse.swt.widgets.Label;
+//import org.eclipse.swt.widgets.Shell;
+//
+///**
+// * Using a {@link StyledCellLabelProvider} on table viewer.
+// */
+//
+//public class StyledCellLabelProviderTests {
+//
+// private static int IMAGE_SIZE= 16;
+//
+// private static Image IMAGE1;
+// private static Image IMAGE2;
+//
+// public static void main(String[] args) {
+//
+// Display display = new Display();
+//
+// JFaceResources.getColorRegistry().put(JFacePreferences.COUNTER_COLOR, new RGB(0,127,174));
+//
+// IMAGE1= new Image(display, display.getSystemImage(SWT.ICON_WARNING).getImageData().scaledTo(IMAGE_SIZE, IMAGE_SIZE));
+// IMAGE2= new Image(display, display.getSystemImage(SWT.ICON_ERROR).getImageData().scaledTo(IMAGE_SIZE, IMAGE_SIZE));
+//
+// Shell shell= new Shell(display , SWT.CLOSE | SWT.RESIZE);
+// shell.setSize(400, 600);
+// shell.setLayout(new GridLayout(1, false));
+//
+// StyledCellLabelProviderTests example= new StyledCellLabelProviderTests();
+// Control composite= example.createPartControl(shell);
+// composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+//
+// shell.open();
+//
+// while (!shell.isDisposed()) {
+// if (!display.readAndDispatch()) {
+// display.sleep();
+// }
+// }
+// display.dispose();
+// }
+//
+// protected boolean useBold;
+//
+// public StyledCellLabelProviderTests() {
+// }
+//
+// public Composite createPartControl(Composite parent) {
+// Composite composite= new Composite(parent, SWT.NONE);
+//
+// composite.setLayout(new GridLayout(1, true));
+//
+// final Label label= new Label(composite, SWT.NONE);
+// label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
+// label.setText("Operations per second: xxxxx"); //$NON-NLS-1$
+//
+// final Runnable[] operation = new Runnable[1];
+//
+// final Button timeButton = new Button(composite, SWT.CHECK);
+// timeButton.setText("Time");
+// timeButton.addSelectionListener(new SelectionAdapter(){
+// public void widgetSelected(SelectionEvent e) {
+// setTimer(timeButton.getDisplay(), timeButton.getSelection(), operation, label);
+// }
+// });
+//
+// final Button stylingButton = new Button(composite, SWT.CHECK);
+// stylingButton.setText("enable styling");
+// stylingButton.setSelection(true);
+//
+// final Button boldButton = new Button(composite, SWT.CHECK);
+// boldButton.setText("use bold");
+//
+// final TableViewer tableViewer= new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+//
+// boldButton.addSelectionListener(new SelectionAdapter(){
+// public void widgetSelected(SelectionEvent e) {
+// useBold = boldButton.getSelection();
+// tableViewer.refresh();
+// }
+// });
+//
+// operation[0] = new Runnable(){
+// public void run() {
+// tableViewer.refresh();
+// }
+// };
+//
+// FontData[] boldFontData= getModifiedFontData(tableViewer.getTable().getFont().getFontData(), SWT.BOLD);
+//
+// Font boldFont = new Font(Display.getCurrent(), boldFontData);
+// final ExampleLabelProvider labelProvider= new ExampleLabelProvider(boldFont);
+// TestContentProvider contentProvider= new TestContentProvider();
+//
+// tableViewer.setContentProvider(contentProvider);
+// tableViewer.setLabelProvider(labelProvider);
+//
+// stylingButton.addSelectionListener(new SelectionAdapter(){
+// public void widgetSelected(SelectionEvent e) {
+// labelProvider.setOwnerDrawEnabled(stylingButton.getSelection());
+// tableViewer.refresh();
+// }
+// });
+//
+//
+// GridData data= new GridData(GridData.FILL, GridData.FILL, true, true);
+// tableViewer.getControl().setLayoutData(data);
+// tableViewer.setInput(new Object());
+//
+// return composite;
+// }
+//
+// boolean timerOn = false;
+// long startTime;
+// int numOperations;
+// DecimalFormat decimalFormat = new DecimalFormat("##.#");
+//
+// protected void setTimer(final Display display, boolean selection, final Runnable[] operation, final Label resultLabel) {
+// timerOn = selection;
+// if (timerOn) {
+// startTime = System.currentTimeMillis();
+// numOperations = 0;
+// display.asyncExec(new Runnable() {
+// public void run() {
+// if (display.isDisposed() || resultLabel.isDisposed()) {
+// return;
+// }
+// if (operation[0] != null) {
+// operation[0].run();
+// }
+// numOperations++;
+// long currentTime = System.currentTimeMillis();
+// long elapsedTime = currentTime - startTime;
+// if (elapsedTime >= 1000) {
+// double timePerOperation = elapsedTime / 1000.0 / numOperations;
+// double operationsPerSecond = 1.0/timePerOperation;
+// resultLabel.setText("Operations per second: " + decimalFormat.format(operationsPerSecond));
+// numOperations = 0;
+// startTime = System.currentTimeMillis();
+// }
+// if (timerOn) {
+// display.asyncExec(this);
+// }
+// }
+// });
+// } else {
+// resultLabel.setText("Operations per second: xxxx");
+// }
+// }
+//
+// private static FontData[] getModifiedFontData(FontData[] originalData, int additionalStyle) {
+// FontData[] styleData = new FontData[originalData.length];
+// for (int i = 0; i < styleData.length; i++) {
+// FontData base = originalData[i];
+// styleData[i] = new FontData(base.getName(), base.getHeight(), base.getStyle() | additionalStyle);
+// }
+// return styleData;
+// }
+//
+// private class ExampleLabelProvider extends StyledCellLabelProvider {
+//
+// private final Styler fBoldStyler;
+//
+// public ExampleLabelProvider(final Font boldFont) {
+// fBoldStyler= new Styler() {
+// public void applyStyles(TextStyle textStyle) {
+// textStyle.font= boldFont;
+// }
+// };
+// }
+//
+// public void update(ViewerCell cell) {
+// Object element= cell.getElement();
+//
+// if (element instanceof File) {
+// File file= (File) element;
+//
+// Styler style= file.isDirectory() && useBold ? fBoldStyler: null;
+// StyledString styledString= new StyledString(file.getName(), style);
+// String decoration = MessageFormat.format(" ({0} bytes)", new Object[] { new Long(file.length()) }); //$NON-NLS-1$
+// styledString.append(decoration, StyledString.COUNTER_STYLER);
+//
+// cell.setText(styledString.toString());
+// cell.setStyleRanges(styledString.getStyleRanges());
+//
+// if (file.isDirectory()) {
+// cell.setImage(IMAGE1);
+// } else {
+// cell.setImage(IMAGE2);
+// }
+// } else {
+// cell.setText("Unknown element"); //$NON-NLS-1$
+// }
+//
+// super.update(cell);
+// }
+//
+// protected void measure(Event event, Object element) {
+// super.measure(event, element);
+// }
+// }
+//
+// static class File {
+//
+// private final String name;
+// private final int length;
+// private final boolean dir;
+//
+// File(String name, int length, boolean dir) {
+// this.name = name;
+// this.length = length;
+// this.dir = dir;
+// }
+//
+// public int length() {
+// return length;
+// }
+//
+// public String getName() {
+// return name;
+// }
+//
+// boolean isDirectory() {
+// return dir;
+// }
+//
+// }
+//
+// private static class TestContentProvider implements IStructuredContentProvider {
+//
+// public Object[] getElements(Object element) {
+// return new File[]{
+// new File("asdfkjghfasdkjasdfhjgasdfkjhg", 2348, false),
+// new File("sdafkuyasdfkljh", 2348, false),
+// new File("asdklufhalsdkhlkjhnklj hlh", 2348, true),
+// new File("asdfasdf asdf ", 2348, false),
+// new File("fds sdf", 2348, true),
+// new File(" sdafuh lsdfahj alsdfk hl", 2348, false),
+// new File("sdfahj sdfajk hsdfjkh", 2348, false),
+// new File("sdafkja sdfjkh asdfkhj", 2348, false),
+// new File("sdfakj hasdfljkha sdfljkh sdfa", 348, true),
+// new File("hj ka g", 1334, true),
+// new File("asdfjk hsdfaljkh", 2348, false),
+// new File("asdh gasdflhg ", 3348, true),
+// new File("asd ghasdfkjg sdfkyug ", 4345, false),
+// new File("asdf hjasdflkjh sdfal", 5345, false),
+// new File("asdlfuh afsdhjg fdsalhj", 6648, false),
+// new File("uiy viuh vhj v", 7448, true),
+// new File("sdfauighsdvpyu ghasjkn", 8848, true),
+// new File("asduih cuia ;nac", 9548, false),
+// new File("chju kljhuuklh jk;", 348, false),
+// new File("cdailukhu l;hj .n", 448, false),
+// new File("auihy akl;h l;j", 2348, false),
+// new File("caiugh j l;kjlh jcd", 2328, true),
+// new File("auio;h jkh lhjl h ljjhbvj", 2348, true),
+// new File("ajklkja kj lkjh jklh ", 2248, false),
+// new File("asdfkjghfasdkjasdfhjgasdfkjhg", 2348, true),
+// new File("sdafkuyasdfkljh", 2348, false),
+// new File("asdklufhalsdkhlkjhnklj hlh", 2348, true),
+// new File("asdfasdf asdf ", 2348, false),
+// new File("fds sdf", 2348, true),
+// new File(" sdafuh lsdfahj alsdfk hl", 2348, true),
+// new File("sdfahj sdfajk hsdfjkh", 2348, false),
+// new File("sdafkja sdfjkh asdfkhj", 2348, true),
+// new File("sdfakj hasdfljkha sdfljkh sdfa", 348, true),
+// new File("hj ka g", 1334, false),
+// new File("asdfjk hsdfaljkh", 2348, false),
+// new File("asdh gasdflhg ", 3348, true),
+// new File("asd ghasdfkjg sdfkyug ", 4345, true),
+// new File("asdf hjasdflkjh sdfal", 5345, true),
+// new File("asdlfuh afsdhjg fdsalhj", 6648, false),
+// new File("uiy viuh vhj v", 7448, false),
+// new File("sdfauighsdvpyu ghasjkn", 8848, true),
+// new File("asduih cuia ;nac", 9548, false),
+// new File("chju kljhuuklh jk;", 348, true),
+// new File("cdailukhu l;hj .n", 448, true),
+// new File("auihy akl;h l;j", 2348, false),
+// new File("caiugh j l;kjlh jcd", 2328, true),
+// new File("auio;h jkh lhjl h ljjhbvj", 2348, false),
+// new File("ajklkja kj lkjh jklh ", 2248, true),
+// };
+// }
+//
+// public void dispose() {
+// }
+//
+// public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+// }
+// }
+//}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/VirtualTableView.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/VirtualTableView.java
index 5d5800d68e..8dff268743 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/VirtualTableView.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/VirtualTableView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -73,13 +73,17 @@ public class VirtualTableView extends ViewPart {
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
public void widgetSelected(SelectionEvent e) {
-
- viewer.remove(((IStructuredSelection) viewer.getSelection()).toArray());
+ Object[] selection = ((IStructuredSelection) viewer.getSelection()).toArray();
+ doRemove(selection, viewer.getTable().getSelectionIndices());
}
});
}
+ protected void doRemove(Object[] selection, int[] selectionIndices) {
+ viewer.remove(selection);
+ }
+
/**
* Get the content provider for the receiver.
*
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/ButtonAlignmentTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/ButtonAlignmentTest.java
new file mode 100644
index 0000000000..37794db67d
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/ButtonAlignmentTest.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.wizards;
+
+import junit.framework.TestCase;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+
+public class ButtonAlignmentTest extends TestCase {
+
+ private TheTestWizard wizard;
+ private TheTestWizardDialog dialog;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // ensure we've initialized a display for this thread
+ Display.getDefault();
+ }
+
+ protected void tearDown() throws Exception {
+ if (dialog != null && dialog.getShell() != null
+ && !dialog.getShell().isDisposed()) {
+ dialog.close();
+ }
+
+ super.tearDown();
+ }
+
+ public ButtonAlignmentTest() {
+ super("ButtonAlignmentTest");
+ }
+
+ public void testButtonAlignment() {
+ wizard = new TheTestWizard();
+ dialog = new TheTestWizardDialog(null, wizard);
+ dialog.create();
+ dialog.open();
+
+ // retrieve the parent control for the button bar
+ Composite parent = dialog.getFinishedButton().getParent();
+ Control[] children = parent.getChildren();
+ assertEquals(
+ "There should be three children, a composite for back/next buttons, the finish button, and the cancel button", //$NON-NLS-1$
+ 3, children.length);
+
+ // first children should be the Composite holding the 'Back' and 'Next'
+ // buttons
+ assertTrue(children[0] instanceof Composite);
+ Composite backNextParent = (Composite) children[0];
+
+ // retrieve its children and verify its contents
+ Control[] backNextChildren = backNextParent.getChildren();
+ assertEquals("Back button should be the first button", dialog //$NON-NLS-1$
+ .getBackButton(), backNextChildren[0]);
+ assertEquals("Next button should be the second button", dialog //$NON-NLS-1$
+ .getNextButton(), backNextChildren[1]);
+
+ // verify button alignment based on the platform's dismissal alignment
+ int finishIndex = parent.getDisplay().getDismissalAlignment() == SWT.LEFT ? 1
+ : 2;
+ int cancelIndex = parent.getDisplay().getDismissalAlignment() == SWT.LEFT ? 2
+ : 1;
+
+ assertEquals(
+ "Finish button's alignment is off", dialog.getFinishedButton(), children[finishIndex]); //$NON-NLS-1$
+ assertEquals(
+ "Cancel button's alignment is off", dialog.getCancelButton(), children[cancelIndex]); //$NON-NLS-1$
+ }
+
+ public void testButtonAlignmentWithoutBackNextButtons() {
+ wizard = new TheTestWizard() {
+ public void addPages() {
+ // only add one page so there are no 'Back' or 'Next' buttons
+ addPage(new TheTestWizardPage(page1Name));
+ }
+ };
+ dialog = new TheTestWizardDialog(null, wizard);
+ dialog.create();
+ dialog.open();
+
+ // retrieve the parent control for the button bar
+ Composite parent = dialog.getFinishedButton().getParent();
+ Control[] children = parent.getChildren();
+ assertEquals(
+ "There should be two children, the finish button, and the cancel button", //$NON-NLS-1$
+ 2, children.length);
+
+ // verify button alignment based on the platform's dismissal alignment
+ int finishIndex = parent.getDisplay().getDismissalAlignment() == SWT.LEFT ? 0
+ : 1;
+ int cancelIndex = parent.getDisplay().getDismissalAlignment() == SWT.LEFT ? 1
+ : 0;
+
+ assertEquals(
+ "Finish button's alignment is off", dialog.getFinishedButton(), children[finishIndex]); //$NON-NLS-1$
+ assertEquals(
+ "Cancel button's alignment is off", dialog.getCancelButton(), children[cancelIndex]); //$NON-NLS-1$
+ }
+
+ public void testBug270174() {
+ wizard = new TheTestWizard() {
+ public boolean canFinish() {
+ // make sure the wizard can't finish early, this will ensure
+ // that the 'Next' button is the default button
+ return false;
+ }
+ };
+ dialog = new TheTestWizardDialog(null, wizard);
+ dialog.create();
+ dialog.open();
+
+ // retrieve the parent control for the button bar
+ Composite parent = dialog.getFinishedButton().getParent();
+ Control[] children = parent.getChildren();
+ assertEquals(
+ "There should be three children, a composite for back/next buttons, the finish button, and the cancel button", //$NON-NLS-1$
+ 3, children.length);
+
+ // first children should be the Composite holding the 'Back' and 'Next'
+ // buttons
+ assertTrue(children[0] instanceof Composite);
+ Composite backNextParent = (Composite) children[0];
+
+ // retrieve its children and verify its contents
+ Control[] backNextChildren = backNextParent.getChildren();
+ assertEquals("Back button should be the first button", dialog //$NON-NLS-1$
+ .getBackButton(), backNextChildren[0]);
+ assertEquals("Next button should be the second button", dialog //$NON-NLS-1$
+ .getNextButton(), backNextChildren[1]);
+
+ // verify button alignment based on the platform's dismissal alignment
+ int finishIndex = parent.getDisplay().getDismissalAlignment() == SWT.LEFT ? 1
+ : 2;
+ int cancelIndex = parent.getDisplay().getDismissalAlignment() == SWT.LEFT ? 2
+ : 1;
+
+ assertEquals(
+ "Finish button's alignment is off", dialog.getFinishedButton(), children[finishIndex]); //$NON-NLS-1$
+ assertEquals(
+ "Cancel button's alignment is off", dialog.getCancelButton(), children[cancelIndex]); //$NON-NLS-1$
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/TheTestWizard.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/TheTestWizard.java
new file mode 100644
index 0000000000..f67fb29283
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/TheTestWizard.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jface.tests.wizards;
+
+import org.eclipse.jface.wizard.Wizard;
+
+
+public class TheTestWizard extends Wizard {
+ public TheTestWizardPage page1;
+ public TheTestWizardPage page2;
+ public TheTestWizardPage page3;
+ public final String page1Name = "PAGE1";
+ public final String page2Name = "PAGE2";
+ public final String page3Name = "PAGE3";
+ private boolean throwExceptionOnDispose;
+
+ public TheTestWizard() {
+ super();
+ setNeedsProgressMonitor(true);
+ }
+
+
+ /**
+ * Adding the page to the wizard.
+ */
+
+ public void addPages() {
+ page1 = new TheTestWizardPage(page1Name);
+ addPage(page1);
+ page2 = new TheTestWizardPage(page2Name);
+ addPage(page2);
+ page3 = new TheTestWizardPage(page3Name);
+ addPage(page3);
+ }
+
+ /**
+ * This method is called when 'Finish' button is pressed in
+ * the wizard.
+ */
+ public boolean performFinish() {
+ WizardTest.DID_FINISH = true;
+ return true;
+ }
+
+ /**
+ * @param throwExceptionOnDispose The throwExceptionOnDispose to set.
+ */
+ public void setThrowExceptionOnDispose(boolean throwExceptionOnDispose) {
+ this.throwExceptionOnDispose = throwExceptionOnDispose;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ if(throwExceptionOnDispose)
+ throw new NullPointerException();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/TheTestWizardDialog.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/TheTestWizardDialog.java
new file mode 100644
index 0000000000..aec2b72168
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/TheTestWizardDialog.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.wizards;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * The purpose of this class is to expose WizardDialog internals for testing
+ */
+public class TheTestWizardDialog extends WizardDialog {
+
+ /**
+ * @param parentShell
+ * @param newWizard
+ */
+ public TheTestWizardDialog(Shell parentShell, IWizard newWizard) {
+ super(parentShell, newWizard);
+ setBlockOnOpen(false);
+ }
+
+ public Button getFinishedButton() {
+ return getButton(IDialogConstants.FINISH_ID);
+ }
+
+ public Button getCancelButton() {
+ return getButton(IDialogConstants.CANCEL_ID);
+ }
+
+ public Button getBackButton() {
+ return getButton(IDialogConstants.BACK_ID);
+ }
+
+ public Button getNextButton() {
+ return getButton(IDialogConstants.NEXT_ID);
+ }
+
+ public void finishPressed() {
+ super.finishPressed();
+ }
+ public void cancelPressed() {
+ super.cancelPressed();
+ }
+ public void backPressed() {
+ super.backPressed();
+ }
+ public void nextPressed() {
+ super.nextPressed();
+ }
+ public void buttonPressed(int buttonId) {
+ super.buttonPressed(buttonId);
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/TheTestWizardPage.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/TheTestWizardPage.java
new file mode 100644
index 0000000000..5222beeb3e
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/TheTestWizardPage.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.wizards;
+
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class TheTestWizardPage extends WizardPage {
+ public static final String BAD_TEXT_FIELD_CONTENTS = "BAD VALUE";
+ public static final String BAD_TEXT_FIELD_STATUS = "A bad value was entered";
+ public static final String GOOD_TEXT_FIELD_CONTENTS = "GOOD VALUE";
+ public Text textInputField;
+ private boolean throwExceptionOnDispose;
+
+ public TheTestWizardPage(String name) {
+ super(name);
+ }
+
+ /**
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 2;
+ layout.verticalSpacing = 9;
+ Label label = new Label(container, SWT.NULL);
+ label.setText(getName());
+
+ textInputField = new Text(container, SWT.BORDER | SWT.SINGLE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ textInputField.setLayoutData(gd);
+ textInputField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ dialogChanged();
+ }
+ });
+
+ initialize();
+ dialogChanged();
+ setControl(container);
+ }
+
+ private void initialize() {}
+
+
+ /**
+ * Handle dialog values changing
+ */
+
+ private void dialogChanged() {
+ if (textInputField.getText().equals(BAD_TEXT_FIELD_CONTENTS)) {
+ setPageComplete(false);
+ updateStatus(BAD_TEXT_FIELD_STATUS);
+ return;
+ }
+ //any other value, including no value, is good
+ setPageComplete(true);
+ updateStatus(null);
+ }
+
+ private void updateStatus(String message) {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+ /**
+ * @param throwExceptionOnDispose The throwExceptionOnDispose to set.
+ */
+ public void setThrowExceptionOnDispose(boolean throwExceptionOnDispose) {
+ this.throwExceptionOnDispose = throwExceptionOnDispose;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ if(throwExceptionOnDispose)
+ throw new NullPointerException();
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/WizardProgressMonitorTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/WizardProgressMonitorTest.java
new file mode 100644
index 0000000000..8a72ce5f0f
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/WizardProgressMonitorTest.java
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Remy Chi Jian Suen and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * Remy Chi Jian Suen <remy.suen@gmail.com> - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.wizards;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.ProgressMonitorPart;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Layout;
+
+public class WizardProgressMonitorTest extends TestCase {
+
+ private ProgressMonitoringWizardDialog dialog;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ // initialize a display
+ Display.getDefault();
+ dialog = new ProgressMonitoringWizardDialog(new TheTestWizard());
+ dialog.setBlockOnOpen(false);
+ }
+
+ protected void tearDown() throws Exception {
+ if (dialog != null) {
+ dialog.close();
+ }
+ dialog = null;
+ super.tearDown();
+ }
+
+ /**
+ * This test ensures that the labels of a progress monitor are cleared
+ * in-between calls to the wizard dialog's run(boolean, boolean,
+ * IRunnableWithProgress) method. If they are not cleared in between runs,
+ * they end up spilling over to the successive call and causes flickering of
+ * text in the label.
+ */
+ public void testProgressLabelsClearedBug271530() throws Exception {
+ // make up some random task names
+ final String[] taskNames = { "Task A", "Task B" }; //$NON-NLS-1$ //$NON-NLS-2$
+
+ // normal "stop button" behavior
+ dialog.useStopButton = true;
+
+ // open the dialog
+ dialog.open();
+
+ // run task A, we don't fork so we can make a UI call within the
+ // runnable
+ dialog.run(false, true, getRunnable(taskNames[0]));
+
+ performAsserts();
+
+ // run task B now, again, we don't fork so we can make a UI call within
+ // the runnable
+ dialog.run(false, true, getRunnable(taskNames[1]));
+
+ // check that the label has been cleared
+ performAsserts();
+ }
+
+ protected void performAsserts() {
+
+ assertEquals("The progress monitor's label should have been cleared", //$NON-NLS-1$
+ "", dialog.getProgressMonitorLabelText()); //$NON-NLS-1$
+
+ String subTask = dialog.getProgressMonitorSubTaskText();
+ if(subTask !=null && subTask.length() != 0)
+ fail("The progress monitor's subtask should have been cleared"); //$NON-NLS-1$
+ }
+
+
+ protected IRunnableWithProgress getRunnable(final String taskName) {
+ return new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+
+ // check that the label is empty
+ assertEquals(
+ "The progress monitor's label is not initially empty", //$NON-NLS-1$
+ "", dialog.getProgressMonitorLabelText()); //$NON-NLS-1$
+
+ // check the subtask as well
+ String subTask = dialog.getProgressMonitorSubTaskText();
+ if(subTask !=null && subTask.length() != 0)
+ fail("The progress monitor's subtask is not initially empty"); //$NON-NLS-1$
+
+ monitor.beginTask(taskName, 1);
+ monitor.subTask("some sub task"); //$NON-NLS-1$
+ }
+ };
+ }
+
+ /**
+ * A wizard dialog that leverages ProgressMonitorPartSubclass to expose the
+ * progress monitor's label text.
+ */
+ class ProgressMonitoringWizardDialog extends WizardDialog {
+
+ boolean useStopButton;
+
+ ProgressMonitoringWizardDialog(IWizard newWizard) {
+ super(null, newWizard);
+ }
+
+ protected ProgressMonitorPart createProgressMonitorPart(
+ Composite composite, GridLayout pmlayout) {
+ return new ProgressMonitorPartSubclass(composite, pmlayout, useStopButton);
+ }
+
+ public String getProgressMonitorLabelText() {
+ ProgressMonitorPartSubclass monitor = (ProgressMonitorPartSubclass) getProgressMonitor();
+ return monitor.getLabelText();
+ }
+
+ public String getProgressMonitorSubTaskText() {
+ ProgressMonitorPartSubclass monitor = (ProgressMonitorPartSubclass) getProgressMonitor();
+ return monitor.getSubTaskText();
+ }
+
+ }
+
+ /**
+ * A special subclass of the ProgressMonitorPart that exposes this monitor's
+ * label's text.
+ */
+ class ProgressMonitorPartSubclass extends ProgressMonitorPart {
+
+ ProgressMonitorPartSubclass(Composite parent, Layout layout, boolean useStopButton) {
+ super(parent, layout, useStopButton);
+ }
+
+ public String getLabelText() {
+ return fLabel.getText();
+ }
+
+ public String getSubTaskText() {
+ return fSubTaskName;
+ }
+
+ }
+
+ /**
+ * This test ensures that a wizard dialog subclass which overrides the
+ * #getProgressMonitorPart method and returns a monitor without the stop button
+ * will fail gracefully. That is, the runnable will run as expected.
+ * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=287887#c57
+ */
+ public void testProgressMonitorWithoutStopButtonBug287887() throws Exception {
+ // make up some random task names
+ final String[] taskNames = { "Task A", "Task B" }; //$NON-NLS-1$ //$NON-NLS-2$
+
+ // no stop button, this is an invalid configuration
+ dialog.useStopButton = false;
+
+ // open the dialog
+ dialog.open();
+
+ // run task A, we don't fork so we can make a UI call within the
+ // runnable
+ dialog.run(false, true, getRunnable(taskNames[0]));
+
+ performAsserts();
+
+ // run task B now, again, we don't fork so we can make a UI call within
+ // the runnable
+ dialog.run(false, true, getRunnable(taskNames[1]));
+
+ // check that the label has been cleared
+ performAsserts();
+
+ // we are successful simply by getting here without exception
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/WizardTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/WizardTest.java
new file mode 100644
index 0000000000..d3f78d572a
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/WizardTest.java
@@ -0,0 +1,294 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.jface.tests.wizards;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+//import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IPageChangedListener;
+import org.eclipse.jface.dialogs.IPageChangingListener;
+import org.eclipse.jface.dialogs.PageChangedEvent;
+import org.eclipse.jface.dialogs.PageChangingEvent;
+//import org.eclipse.jface.util.ILogger;
+//import org.eclipse.jface.util.Policy;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+public class WizardTest extends TestCase {
+ /**
+ *
+ */
+ protected static final int NUM_PAGES = 3;
+
+ static boolean DID_FINISH = false; //accessed from this test AND wizard
+
+ protected final static String WIZARD_TITLE = "TEST WIZARD TITLE";
+ protected final static String PAGE_TITLE = "TEST PAGE TITLE";
+ protected RGB color1;
+ protected RGB color2;
+
+ protected TheTestWizard wizard;
+ protected TheTestWizardDialog dialog;
+
+ boolean pageChanged = false;
+ boolean pageChangingFired = false;
+
+
+ public WizardTest() {
+ super("NewWizardTest");
+ }
+
+
+ public void testEndingWithFinish() throws IOException {
+ //test page count
+ assertEquals("Wizard has wrong number of pages", NUM_PAGES, wizard.getPageCount());
+
+ //test page name
+ assertEquals("WizardPage.getName() returned wrong name", wizard.page1Name, wizard.page1.getName());
+
+ //test getPage()
+ assertSame("Wizard.getPage() returned wrong page", wizard.getPage(wizard.page1Name), wizard.page1);
+
+ //test title
+ wizard.setWindowTitle(WIZARD_TITLE);
+ assertEquals("Wizard has wrong title", wizard.getWindowTitle(), WIZARD_TITLE);
+ wizard.page1.setTitle(PAGE_TITLE);
+ assertEquals("Wizard has wrong title", wizard.page1.getTitle(), PAGE_TITLE);
+
+ //set+test color twice to ensure initial color didn't happen to be color1
+ wizard.setTitleBarColor(color1);
+ assertEquals("Wizard has wrong title color", wizard.getTitleBarColor(), color1);
+ wizard.setTitleBarColor(color2);
+ assertEquals("Wizard has wrong title color", wizard.getTitleBarColor(), color2);
+
+ //test on starting page
+ assertSame("Wizard has wrong starting page", wizard.page1, wizard.getStartingPage());
+ assertSame("Wizard not on starting page", wizard.page1, dialog.getCurrentPage());
+
+ //test getMessage()
+ assertSame("WizardPage error message should be null", null, wizard.page1.getErrorMessage());
+ wizard.page1.textInputField.setText(TheTestWizardPage.BAD_TEXT_FIELD_CONTENTS);
+ assertEquals("WizardPage error message set correctly", TheTestWizardPage.BAD_TEXT_FIELD_STATUS, wizard.page1.getErrorMessage());
+
+ //test page completion
+ wizard.page1.textInputField.setText(TheTestWizardPage.GOOD_TEXT_FIELD_CONTENTS);
+ assertEquals("Page should be completed", true, wizard.page1.canFlipToNextPage());
+ //Setting good value should've cleared the error message
+ assertSame("WizardPage error message should be null", null, wizard.page1.getErrorMessage());
+
+ //test getNextPage() without page changes
+ assertSame("WizardPage.getNexPage() wrong page", wizard.page2, wizard.page1.getNextPage());
+ assertSame("Wizard.getNexPage() wrong page", wizard.page2, wizard.getNextPage(wizard.page1));
+ assertSame("WizardPage.getPreviousPage() wrong page", wizard.page1, wizard.page2.getPreviousPage());
+ assertSame("Wizard.getPreviousPage() wrong page", wizard.page1, wizard.getPreviousPage(wizard.page2));
+ assertSame("WizardPage.getNexPage() wrong page", wizard.page3, wizard.page2.getNextPage());
+ assertSame("Wizard.getPreviousPage() wrong page", wizard.page2, wizard.getPreviousPage(wizard.page3));
+
+ //test canFinish()
+ wizard.page2.textInputField.setText(TheTestWizardPage.BAD_TEXT_FIELD_CONTENTS);
+ assertEquals("Wizard should not be able to finish", false, wizard.canFinish());
+ wizard.page2.textInputField.setText(TheTestWizardPage.GOOD_TEXT_FIELD_CONTENTS);
+ assertEquals("Wizard should be able to finish", true, wizard.canFinish());
+
+ //test simulated Finish button hit
+ //TheTestWizard's performFinish() sets DID_FINISH to true
+ dialog.finishPressed();
+ assertEquals("Wizard didn't perform finish", true, DID_FINISH);
+ }
+
+ public void testEndingWithCancel() throws IOException {
+ assertSame("Wizard not on starting page", wizard.page1, dialog.getCurrentPage());
+
+ //TheTestWizard's performFinish() sets DID_FINISH to true, ensure it was not called
+ wizard.performCancel();
+ assertEquals("Wizard finished but should not have", false, DID_FINISH);
+
+ dialog.cancelPressed();
+ assertEquals("Wizard performed finished but should not have", false, DID_FINISH);
+ }
+
+ public void testPageChanging() throws IOException {
+ //initially on first page
+ assertSame("Wizard started on wrong page", wizard.page1, dialog.getCurrentPage());
+ assertEquals("Back button should be disabled on first page", false, dialog.getBackButton().getEnabled());
+ assertEquals("Next button should be enabled on first page", true, dialog.getNextButton().getEnabled());
+
+ //move to middle page 2
+ dialog.nextPressed();
+ assertSame("Wizard.nextPressed() set wrong page", wizard.page2, dialog.getCurrentPage());
+ assertEquals("Back button should be enabled on middle page", true, dialog.getBackButton().getEnabled());
+ assertEquals("Next button should be enabled on middle page", true, dialog.getNextButton().getEnabled());
+
+ //test that can't complete by inserting bad value to be validated
+ wizard.page2.textInputField.setText(TheTestWizardPage.BAD_TEXT_FIELD_CONTENTS);
+ assertEquals("Finish should be disabled when bad field value", false, dialog.getFinishedButton().getEnabled());
+ assertEquals("Cancel should always be enabled", true, dialog.getCancelButton().getEnabled());
+
+ //test that can complete by inserting good value to be validated
+ wizard.page2.textInputField.setText(TheTestWizardPage.GOOD_TEXT_FIELD_CONTENTS);
+ assertEquals("Finish should be enabled when good field value", true, dialog.getFinishedButton().getEnabled());
+
+ //move to last page 3
+ dialog.nextPressed();
+ assertSame("Wizard.nextPressed() set wrong page", wizard.page3, dialog.getCurrentPage());
+ assertEquals("Back button should be enabled on last page", true, dialog.getBackButton().getEnabled());
+ assertEquals("Next button should be disenabled on last page", false, dialog.getNextButton().getEnabled());
+
+ //move back to page 2
+ dialog.backPressed();
+ assertSame("Wizard.backPressed() set wrong page", wizard.page2, dialog.getCurrentPage());
+ assertEquals("Back button should be enabled on middle page", true, dialog.getBackButton().getEnabled());
+ assertEquals("Next button should be enabled on middle page", true, dialog.getNextButton().getEnabled());
+
+ //move back to page 1
+ dialog.backPressed();
+ assertSame("Wizard.backPressed() set wrong page", wizard.page1, dialog.getCurrentPage());
+ assertEquals("Back button should be disabled on first page", false, dialog.getBackButton().getEnabled());
+ assertEquals("Next button should be enabled on first page", true, dialog.getNextButton().getEnabled());
+
+ //move Next to page 2
+ dialog.buttonPressed(IDialogConstants.NEXT_ID);
+ assertSame("Wizard.backPressed() set wrong page", wizard.page2, dialog.getCurrentPage());
+ //move Back to page 1
+ dialog.buttonPressed(IDialogConstants.BACK_ID);
+ assertSame("Wizard.backPressed() set wrong page", wizard.page1, dialog.getCurrentPage());
+ }
+
+ public void testShowPage() throws IOException {
+ //move to page 3
+ dialog.nextPressed();
+ dialog.nextPressed();
+ assertSame("Wizard.nextPressed() set wrong page", wizard.page3, dialog.getCurrentPage());
+
+ //showPage() back to page 1
+ dialog.showPage(wizard.page1);
+
+ assertSame("Wizard.showPage() set wrong page", wizard.page1, dialog.getCurrentPage());
+
+ //TODO Next test fails due to bug #249369
+// assertEquals("Back button should be disabled on first page", false, dialog.getBackButton().getEnabled());
+ assertEquals("Next button should be enabled on first page", true, dialog.getNextButton().getEnabled());
+ }
+
+ public void testPageChangeListening() throws IOException {
+ pageChanged = false;
+ pageChangingFired = false;
+
+ IPageChangedListener changedListener = new IPageChangedListener() {
+ public void pageChanged(PageChangedEvent event) {
+ pageChanged = true;
+ }
+
+ };
+
+ IPageChangingListener changingListener = new IPageChangingListener() {
+ public void handlePageChanging(PageChangingEvent event) {
+ assertEquals("Page should not have changed yet", false, pageChanged);
+ pageChangingFired = true;
+ }
+
+ };
+
+ //test that listener notifies us of page change
+ dialog.addPageChangedListener(changedListener);
+ dialog.addPageChangingListener(changingListener); //assert is in the listener
+ assertEquals("Page change notified unintentially", false, pageChanged);
+ //change to page 2
+ dialog.nextPressed();
+ assertEquals("Wasn't notified of page change", true, pageChanged);
+ assertEquals("Wasn't notified of page changing", true, pageChangingFired);
+
+ dialog.removePageChangingListener(changingListener); //if not removed, its assert will fail on next nextPressed()
+ //change to page 2
+ dialog.nextPressed();
+
+ //test with listener removed
+ pageChanged = false;
+ dialog.removePageChangedListener(changedListener);
+ //change to page 3
+ dialog.nextPressed();
+ assertEquals("Page change notified unintentially", false, pageChanged);
+ }
+
+
+// public void testWizardDispose() {
+// wizard = new TheTestWizard();
+// wizard.setThrowExceptionOnDispose(true);
+// dialog = new TheTestWizardDialog(null, wizard);
+// dialog.create();
+//
+// final boolean logged[] = new boolean[1];
+// Policy.setLog(new ILogger() {
+// public void log(IStatus status) {
+// logged[0] = true;
+// }
+// });
+// dialog.close();
+//
+// assertTrue(logged[0]);
+//
+// }
+
+// public void testWizardPageDispose() {
+// wizard = new TheTestWizard();
+// dialog = new TheTestWizardDialog(null, wizard);
+// dialog.create();
+// wizard.page2.setThrowExceptionOnDispose(true);
+// final boolean logged[] = new boolean[1];
+// Policy.setLog(new ILogger() {
+// public void log(IStatus status) {
+// logged[0] = true;
+// }
+// });
+// dialog.close();
+//
+// assertTrue(logged[0]);
+// assertTrue(wizard.page1.getControl().isDisposed());
+// assertTrue(wizard.page3.getControl().isDisposed());
+//
+// }
+
+ //----------------------------------------------------
+
+
+ protected void setUp() throws Exception {
+ // TODO Auto-generated method stub
+ super.setUp();
+ DID_FINISH = false;
+ color1 = new RGB(255, 0, 0);
+ color2 = new RGB(0, 255, 0);
+
+ createWizardDialog();
+ }
+
+ protected void tearDown() throws Exception {
+ if(dialog.getShell() != null && ! dialog.getShell().isDisposed()) {
+ dialog.close();
+ }
+ }
+
+ //Create and open the wizard
+ protected void createWizardDialog() {
+ //ensure we've initialized a display for this thread
+ Display.getDefault();
+
+ wizard = new TheTestWizard();
+ dialog = new TheTestWizardDialog(null, wizard);
+ dialog.create();
+
+ dialog.open();
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/WizardTestSuite.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/WizardTestSuite.java
new file mode 100644
index 0000000000..1658bc4f5d
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/wizards/WizardTestSuite.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jface.tests.wizards;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class WizardTestSuite extends TestSuite {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite() {
+ return new WizardTestSuite();
+ }
+
+ public WizardTestSuite() {
+ addTestSuite(ButtonAlignmentTest.class);
+ addTestSuite(WizardTest.class);
+ addTestSuite(WizardProgressMonitorTest.class);
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/RCPSessionApplication.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/RCPSessionApplication.java
new file mode 100644
index 0000000000..b6dcccd395
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/RCPSessionApplication.java
@@ -0,0 +1,55 @@
+///*******************************************************************************
+// * Copyright (c) 2008, 2010 IBM Corporation and others.
+// * All rights reserved. This program and the accompanying materials
+// * are 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
+// *
+// * Contributors:
+// * IBM Corporation - initial API and implementation
+// *******************************************************************************/
+//package org.eclipse.ui.tests;
+//
+//import org.eclipse.equinox.app.IApplication;
+//import org.eclipse.equinox.app.IApplicationContext;
+//import org.eclipse.swt.widgets.Display;
+//import org.eclipse.ui.IWorkbench;
+//import org.eclipse.ui.PlatformUI;
+//import org.eclipse.ui.tests.harness.util.RCPTestWorkbenchAdvisor;
+//
+//public class RCPSessionApplication implements IApplication {
+//
+// private boolean windowlessApp = false;
+//
+// public Object start(IApplicationContext context) throws Exception {
+// Display display = PlatformUI.createDisplay();
+// try {
+// PlatformUI.createAndRunWorkbench(display, new RCPTestWorkbenchAdvisor(windowlessApp));
+// } finally {
+// if (display != null)
+// display.dispose();
+// }
+// return EXIT_OK;
+// }
+//
+// public void stop() {
+// final IWorkbench workbench = PlatformUI.getWorkbench();
+// if (workbench == null)
+// return;
+// final Display display = workbench.getDisplay();
+// display.syncExec(new Runnable() {
+// public void run() {
+// if (!display.isDisposed())
+// workbench.close();
+// }
+// });
+// }
+//
+// /**
+// * @param windowlessApp The windowlessApp to set.
+// */
+// public void setWindowlessApp(boolean windowlessApp) {
+// this.windowlessApp = windowlessApp;
+// }
+//
+//} \ No newline at end of file
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/WindowlessRCPApplication.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/WindowlessRCPApplication.java
new file mode 100644
index 0000000000..790214e0ac
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/WindowlessRCPApplication.java
@@ -0,0 +1,20 @@
+///*******************************************************************************
+// * Copyright (c) 2010 IBM Corporation and others.
+// * All rights reserved. This program and the accompanying materials
+// * are 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
+// *
+// * Contributors:
+// * IBM Corporation - initial API and implementation
+// *******************************************************************************/
+//package org.eclipse.ui.tests;
+//
+//
+//public class WindowlessRCPApplication extends RCPSessionApplication {
+//
+// public WindowlessRCPApplication() {
+// setWindowlessApp(true);
+// }
+//
+//} \ No newline at end of file
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/commands/DefaultHandler.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/commands/DefaultHandler.java
new file mode 100644
index 0000000000..7cc898a89f
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/commands/DefaultHandler.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+
+/**
+ *
+ * @author Prakash G.R.
+ * @since 3.6
+ *
+ */
+public class DefaultHandler extends AbstractHandler{
+
+ public Object execute(ExecutionEvent event){
+ // does nothing
+ return null;
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/session/NonRestorableView.java b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/session/NonRestorableView.java
new file mode 100644
index 0000000000..d6e5a5bbde
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse JFace Tests/org/eclipse/ui/tests/session/NonRestorableView.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Versant Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * Versant Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.session;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+public class NonRestorableView extends ViewPart {
+ public static final String ID ="org.eclipse.ui.tests.session.NonRestorableView";
+
+ public NonRestorableView() { }
+
+ public void createPartControl(Composite parent) {}
+
+ public void setFocus() { }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/UiTestSuite.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/UiTestSuite.java
index 77e40a6d67..e15fe71066 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/UiTestSuite.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/UiTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,7 +21,7 @@ import org.eclipse.ui.tests.commands.CommandsTestSuite;
import org.eclipse.ui.tests.concurrency.ConcurrencyTestSuite;
import org.eclipse.ui.tests.contexts.ContextsTestSuite;
//import org.eclipse.ui.tests.datatransfer.DataTransferTestSuite;
-//import org.eclipse.ui.tests.decorators.DecoratorsTestSuite;
+import org.eclipse.ui.tests.decorators.DecoratorsTestSuite;
import org.eclipse.ui.tests.dialogs.UIAutomatedSuite;
//import org.eclipse.ui.tests.dnd.DragTestSuite;
//import org.eclipse.ui.tests.dynamicplugins.DynamicPluginsTestSuite;
@@ -43,7 +43,7 @@ import org.eclipse.ui.tests.preferences.PreferencesTestSuite;
import org.eclipse.ui.tests.propertysheet.PropertySheetTestSuite;
//import org.eclipse.ui.tests.quickaccess.QuickAccessTestSuite;
import org.eclipse.ui.tests.services.ServicesTestSuite;
-//import org.eclipse.ui.tests.statushandlers.StatusHandlingTestSuite;
+import org.eclipse.ui.tests.statushandlers.StatusHandlingTestSuite;
//import org.eclipse.ui.tests.systeminplaceeditor.OpenSystemInPlaceEditorTest;
import org.eclipse.ui.tests.themes.ThemesTestSuite;
//import org.eclipse.ui.tests.zoom.ZoomTestSuite;
@@ -76,7 +76,7 @@ public class UiTestSuite extends TestSuite {
// addTest(new NavigatorTestSuite());
// All test in DecoratorsTestSuite failed with ResourceException:
// Resource '/TestProject' already exist.
-// addTest(new DecoratorsTestSuite());
+ addTest(new DecoratorsTestSuite());
addTest(new AdaptableTestSuite());
// addTest(new ZoomTestSuite());
// addTest(new DataTransferTestSuite());
@@ -101,7 +101,7 @@ public class UiTestSuite extends TestSuite {
// addTest(new MultiEditorTestSuite());
addTest(new TestSuite(FilteredTreeTests.class));
addTest(new ServicesTestSuite());
-// addTest(new StatusHandlingTestSuite());
+ addTest(new StatusHandlingTestSuite());
// addTest(OpenSystemInPlaceEditorTest.suite());
}
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/ActivitiesTestSuite.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/ActivitiesTestSuite.java
index c1ffefd3f9..5747c9ae60 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/ActivitiesTestSuite.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/ActivitiesTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java
index ec4bf69a18..2fb76f2c9d 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,15 +10,41 @@
*******************************************************************************/
package org.eclipse.ui.tests.activities;
+//import java.io.ByteArrayInputStream;
+//import java.io.InputStream;
+//import java.io.UnsupportedEncodingException;
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.ui.activities.*;
+//import org.eclipse.core.internal.registry.ExtensionRegistry;
+//import org.eclipse.core.runtime.ContributorFactoryOSGi;
+//import org.eclipse.core.runtime.IContributor;
+//import org.eclipse.core.runtime.RegistryFactory;
+//import org.eclipse.swt.widgets.Display;
+//import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.activities.ActivityEvent;
+import org.eclipse.ui.activities.ActivityManagerEvent;
+import org.eclipse.ui.activities.CategoryEvent;
+import org.eclipse.ui.activities.IActivity;
+import org.eclipse.ui.activities.IActivityListener;
+import org.eclipse.ui.activities.IActivityManagerListener;
+//import org.eclipse.ui.activities.IActivityPatternBinding;
+//import org.eclipse.ui.activities.IActivityRequirementBinding;
+import org.eclipse.ui.activities.ICategory;
+//import org.eclipse.ui.activities.ICategoryActivityBinding;
+import org.eclipse.ui.activities.ICategoryListener;
+import org.eclipse.ui.activities.IIdentifier;
+import org.eclipse.ui.activities.IIdentifierListener;
+//import org.eclipse.ui.activities.IWorkbenchActivitySupport;
+import org.eclipse.ui.activities.IdentifierEvent;
+import org.eclipse.ui.activities.NotDefinedException;
+import org.eclipse.ui.activities.WorkbenchTriggerPointAdvisor;
import org.eclipse.ui.internal.activities.MutableActivityManager;
+//import org.eclipse.ui.tests.TestPlugin;
import org.eclipse.ui.tests.harness.util.UITestCase;
/**
- *
+ *
* The dynamic test manipualtes the categories, activities and their definitions
* and ensures that their content and their listeners are behaving properly.
*/
@@ -50,12 +76,12 @@ public class DynamicTest extends UITestCase {
static final int ACTIVITY_ACTIVITY_BINDINGS_CHANGED = 9;
static final int DESCRIPTION_CHANGED = 10;
-
+
static final int DEFAULT_ENABLED_CHANGED = 11;
/**
* Constructor.
- *
+ *
* @param testName
* Test's name.
*/
@@ -63,13 +89,12 @@ public class DynamicTest extends UITestCase {
super(testName);
fixedModelRegistry = new DynamicModelActivityRegistry();
activityManager = new MutableActivityManager(new WorkbenchTriggerPointAdvisor(), fixedModelRegistry);
-// activityManager = new MutableActivityManager(fixedModelRegistry);
listenerType = -1;
}
/**
* Test sizes of what has been read.
- *
+ *
*/
public void testSizes() {
assertTrue(activityManager.getDefinedCategoryIds().size() == 6);
@@ -79,7 +104,7 @@ public class DynamicTest extends UITestCase {
/**
* Test activity bindings.
- *
+ *
*/
public void testActivityPatternBindings() {
IActivity first_activity = activityManager
@@ -101,7 +126,7 @@ public class DynamicTest extends UITestCase {
/**
* Test the enabled activities.
- *
+ *
*/
public void testEnabledActivities() {
// Add an enabled activity
@@ -120,7 +145,7 @@ public class DynamicTest extends UITestCase {
/**
* Test the identifier listener.
- *
+ *
*/
public void testIdentifiersListener() {
final IIdentifier enabledIdentifier = activityManager
@@ -178,7 +203,7 @@ public class DynamicTest extends UITestCase {
/**
* Test the activity manager listener.
- *
+ *
*/
public void testActivityManagerListener() {
activityManager
@@ -197,7 +222,7 @@ public class DynamicTest extends UITestCase {
case DEFINED_ACTIVITYIDS_CHANGED:
assertTrue(activityManagerEvent
.haveDefinedActivityIdsChanged());
- break;
+ break;
}
listenerType = -1;
}
@@ -235,7 +260,7 @@ public class DynamicTest extends UITestCase {
/**
* Test the activity listener.
- *
+ *
*/
public void testActivityListener() {
final IActivity activity_to_listen = activityManager
@@ -335,7 +360,7 @@ public class DynamicTest extends UITestCase {
} catch (NotDefinedException e1) {
fail(e1.getMessage());
}
-
+
listenerType = DEFAULT_ENABLED_CHANGED;
fixedModelRegistry.removeDefaultEnabledActivity(activity_to_listen.getId());
assertTrue(listenerType == -1);
@@ -348,7 +373,7 @@ public class DynamicTest extends UITestCase {
/**
* Test the category listener.
- *
+ *
*/
public void testCategoryListener() {
final ICategory category_to_listen = activityManager
@@ -420,4 +445,112 @@ public class DynamicTest extends UITestCase {
}
assertTrue(listenerType == -1);
}
+
+// RAP [if] This test hang in RAP
+// /**
+// * Tests to ensure dynamism with regard to the extension registry.
+// */
+// public void testDynamicRegistry() {
+// IWorkbenchActivitySupport was = PlatformUI.getWorkbench()
+// .getActivitySupport();
+// IActivity activity = was.getActivityManager().getActivity(
+// "dynamic.activity");
+// ICategory category = was.getActivityManager().getCategory(
+// "dynamic.category");
+// assertFalse(activity.isDefined());
+// assertFalse(category.isDefined());
+// // set to true when the activity/category in question have had an event
+// // fired
+// final boolean[] registryChanged = new boolean[] { false, false };
+// activity.addActivityListener(new IActivityListener() {
+//
+// public void activityChanged(ActivityEvent activityEvent) {
+// registryChanged[0] = true;
+//
+// }
+// });
+// category.addCategoryListener(new ICategoryListener() {
+//
+// public void categoryChanged(CategoryEvent categoryEvent) {
+// System.err.println("categoryChanged");
+// registryChanged[1] = true;
+//
+// }
+// });
+//
+// try {
+// String ACTIVITY = "<plugin><extension point=\"org.eclipse.ui.activities\">"
+// + "<category id=\"dynamic.category\" name=\"Dynamic Activity Category\"/>"
+// + "<activity id=\"dynamic.activity\" name=\"Dynamic Activity\"/>"
+// + "<activity id=\"dynamic.parent\" name=\"Dynamic Parent Activity\"/>"
+// + "<activityRequirementBinding requiredActivityId = \"dynamic.parent\" activityId = \"dynamic.activity\" />"
+// + "<categoryActivityBinding categoryId = \"dynamic.category\" activityId = \"dynamic.activity\" />"
+// + "<activityPatternBinding activityId=\"dynamic.activity\" pattern=\"dynamic.activity/.*\"/>"
+// + "<defaultEnablement id=\"dynamic.activity\"/>"
+// + "</extension></plugin>";
+// byte[] bytes = ACTIVITY.toString().getBytes("UTF-8");
+// InputStream is = new ByteArrayInputStream(bytes);
+// IContributor contrib = ContributorFactoryOSGi
+// .createContributor(TestPlugin.getDefault().getBundle());
+// ExtensionRegistry registry = (ExtensionRegistry) RegistryFactory
+// .getRegistry();
+// if (!registry.addContribution(is, contrib, false, null, null,
+// registry.getTemporaryUserToken()))
+// throw new RuntimeException();
+// } catch (UnsupportedEncodingException e) {
+// fail(e.getMessage(), e);
+// }
+//
+// // spin the event loop and ensure that the changes come down the pipe.
+// // 20 seconds should be more than enough
+// long endTime = System.currentTimeMillis() + 20000;
+// while (!(registryChanged[0] && registryChanged[1])
+// && System.currentTimeMillis() < endTime) {
+//
+// Display display = PlatformUI.getWorkbench().getDisplay();
+// if (display != null && !display.isDisposed())
+// while (display.readAndDispatch())
+// ;
+// display.sleep();
+//
+// }
+//
+// assertTrue("Activity Listener not called", registryChanged[0]);
+// assertTrue("Category Listener not called", registryChanged[1]);
+//
+// assertTrue(activity.isDefined());
+// Set patternBindings = activity.getActivityPatternBindings();
+// assertEquals(1, patternBindings.size());
+//
+// IActivityPatternBinding patternBinding = (IActivityPatternBinding) patternBindings
+// .iterator().next();
+//
+// assertEquals("dynamic.activity/.*", patternBinding.getPattern()
+// .pattern());
+// assertEquals("dynamic.activity", patternBinding.getActivityId());
+//
+// try {
+// assertTrue(activity.isDefaultEnabled());
+// } catch (NotDefinedException e) {
+// fail(e.getMessage(), e);
+// }
+//
+// Set requirementBindings = activity.getActivityRequirementBindings();
+// assertEquals(1, requirementBindings.size());
+//
+// IActivityRequirementBinding requirementBinding = (IActivityRequirementBinding) requirementBindings
+// .iterator().next();
+// assertEquals("dynamic.parent", requirementBinding
+// .getRequiredActivityId());
+// assertEquals("dynamic.activity", requirementBinding.getActivityId());
+//
+// assertTrue(category.isDefined());
+// Set categoryBindings = category.getCategoryActivityBindings();
+// assertEquals(1, categoryBindings.size());
+// ICategoryActivityBinding categoryBinding = (ICategoryActivityBinding) categoryBindings
+// .iterator().next();
+// assertEquals("dynamic.activity", categoryBinding.getActivityId());
+// assertEquals("dynamic.category", categoryBinding.getCategoryId());
+//
+// }
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/StaticTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/StaticTest.java
index 395a7dd1e5..0da96c185c 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/StaticTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/StaticTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,13 +14,13 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.activities.IActivity;
import org.eclipse.ui.activities.IActivityManager;
import org.eclipse.ui.activities.IActivityPatternBinding;
import org.eclipse.ui.activities.ICategory;
import org.eclipse.ui.activities.IIdentifier;
import org.eclipse.ui.activities.NotDefinedException;
-import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.internal.activities.ActivityRequirementBinding;
import org.eclipse.ui.internal.activities.CategoryActivityBinding;
import org.eclipse.ui.tests.harness.util.UITestCase;
@@ -47,7 +47,7 @@ public class StaticTest extends UITestCase {
*/
public StaticTest(String testName) {
super(testName);
- activityManager = Workbench.getInstance().getActivitySupport()
+ activityManager = PlatformUI.getWorkbench().getActivitySupport()
.getActivityManager();
populateIds();
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/UtilTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/UtilTest.java
index cfdf245db7..5765ab4eae 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/UtilTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/UtilTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.ui.tests.activities;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
@@ -20,6 +22,7 @@ import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.EvaluationResult;
import org.eclipse.core.internal.expressions.TestExpression;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.ui.AbstractSourceProvider;
import org.eclipse.ui.IPluginContribution;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.activities.IActivity;
@@ -28,6 +31,9 @@ import org.eclipse.ui.activities.IActivityPatternBinding;
import org.eclipse.ui.activities.IIdentifier;
import org.eclipse.ui.activities.IWorkbenchActivitySupport;
import org.eclipse.ui.activities.WorkbenchActivityHelper;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+import org.eclipse.ui.services.IEvaluationService;
/**
* Tests various utility methods on WorkbenchActivityHelper as well as other misc. activities functionality.
@@ -320,6 +326,66 @@ public class UtilTest extends TestCase {
testPropertyTester2(context, activityManager);
}
+
+ public static final String EXPRESSION_ACTIVITY_ID = "org.eclipse.ui.tests.filter1.enabled";
+ public static final String EXPRESSION_ACTIVITY_ID_2 = "org.eclipse.ui.tests.filter2.enabled";
+ public static final String EXPRESSION_ACTIVITY_ID_3 = "org.eclipse.ui.tests.filter3.enabled";
+ public static final String EXPRESSION_ACTIVITY_ID_4 = "org.eclipse.ui.tests.filter4.enabled";
+ public static final String EXPRESSION_ACTIVITY_ID_5 = "org.eclipse.ui.tests.filter5.enabled";
+ public static final String EXPRESSION_ACTIVITY_ID_6 = "org.eclipse.ui.tests.filter6.enabled";
+ public static final String EXPRESSION_ACTIVITY_ID_7 = "org.eclipse.ui.tests.filter7.enabled";
+
+ public static final String EXPRESSION_VALUE = "org.eclipse.ui.command.contexts.enablement_test1";
+
+ class TestSourceProvider extends AbstractSourceProvider {
+ public static final String VARIABLE = "arbitraryVariable";
+ public static final String VALUE = "arbitraryValue";
+
+ private Map sourceState = new HashMap(1);
+
+ public TestSourceProvider() {
+ super();
+ clearVariable();
+ }
+
+ public Map getCurrentState() {
+ return sourceState;
+ }
+
+ public String[] getProvidedSourceNames() {
+ return new String[] { VARIABLE };
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.ISourceProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /**
+ * @see {@link #fireSourceChanged(int, Map)}
+ */
+ public void fireSourceChanged() {
+ fireSourceChanged(0, sourceState);
+ }
+
+ /**
+ * Sets variable to value. Triggers no fireSourceChanged() update.
+ */
+ public void setVariable() {
+ sourceState.put(VARIABLE, VALUE);
+ }
+
+ /**
+ * Clears variable to empty string. Triggers no fireSourceChanged()
+ * update.
+ */
+ public void clearVariable() {
+ sourceState.put(VARIABLE, "");
+ }
+ };
+
public void testExpressionEnablement() throws Exception {
IPluginContribution filterExp = new IPluginContribution() {
public String getLocalId() {
@@ -329,6 +395,14 @@ public class UtilTest extends TestCase {
return "org";
}
};
+ IPluginContribution filterExp2 = new IPluginContribution() {
+ public String getLocalId() {
+ return "filter2";
+ }
+ public String getPluginId() {
+ return "org";
+ }
+ };
IPluginContribution noExp = new IPluginContribution() {
public String getLocalId() {
return "donotfilter";
@@ -339,11 +413,92 @@ public class UtilTest extends TestCase {
};
assertTrue(WorkbenchActivityHelper.filterItem(filterExp));
assertTrue(WorkbenchActivityHelper.filterItem(noExp));
-// assertTrue(WorkbenchActivityHelper.restrictUseOf(filterExp));
-// assertFalse(WorkbenchActivityHelper.restrictUseOf(noExp));
+ assertTrue(WorkbenchActivityHelper.restrictUseOf(filterExp));
+ assertFalse(WorkbenchActivityHelper.restrictUseOf(noExp));
+
+ // The EXPRESSION_ACTIVITY_ID_3 is always true, and therefore it must
+ // be in the enabledActivityIds list - right from the beginning.
+ IWorkbenchActivitySupport support = PlatformUI.getWorkbench()
+ .getActivitySupport();
+ Set enabledActivityIds = support.getActivityManager()
+ .getEnabledActivityIds();
+ assertTrue(enabledActivityIds.contains(EXPRESSION_ACTIVITY_ID_3));
+
+ // Test activityRequirmentBinding ignored on expression controlled
+ // activities.
+ // Test conventional activity depends on expression activity.
+ assertFalse(enabledActivityIds.contains(EXPRESSION_ACTIVITY_ID_4));
+ assertFalse(enabledActivityIds.contains(EXPRESSION_ACTIVITY_ID_5));
+ enabledActivityIds = new HashSet(enabledActivityIds);
+ enabledActivityIds.add(EXPRESSION_ACTIVITY_ID_5);
+ support.setEnabledActivityIds(enabledActivityIds);
+ enabledActivityIds = support.getActivityManager()
+ .getEnabledActivityIds();
+ assertFalse(enabledActivityIds.contains(EXPRESSION_ACTIVITY_ID_4));
+ assertTrue(enabledActivityIds.contains(EXPRESSION_ACTIVITY_ID_5));
+
+ // Test expression activity depends on conventional activity.
+ assertFalse(enabledActivityIds.contains(EXPRESSION_ACTIVITY_ID_6));
+ assertTrue(enabledActivityIds.contains(EXPRESSION_ACTIVITY_ID_7));
+
+
// need to enable the normal activity, org.eclipse.ui.tests.filter1.normal
// and change the context to enable org.eclipse.ui.tests.filter1.enabled:
// context: org.eclipse.ui.command.contexts.enablement_test1
+
+ IContextService localService = (IContextService) PlatformUI
+ .getWorkbench().getService(IContextService.class);
+ IContextActivation activation = localService.activateContext(EXPRESSION_VALUE);
+ try {
+ // Not restricted anymore.
+ assertFalse(WorkbenchActivityHelper.restrictUseOf(filterExp));
+
+ // Test recognition of disabled expression which is already filtered.
+ localService.deactivateContext(activation);
+ assertTrue(WorkbenchActivityHelper.restrictUseOf(filterExp));
+
+ //
+ // Testing with an arbitrary self-declared test variable.
+ //
+ TestSourceProvider testSourceProvider = new TestSourceProvider();
+ IEvaluationService evalService = (IEvaluationService) PlatformUI
+ .getWorkbench().getService(IEvaluationService.class);
+ evalService.addSourceProvider(testSourceProvider);
+ testSourceProvider.fireSourceChanged();
+
+ // Non-set variable.
+ assertTrue(WorkbenchActivityHelper.restrictUseOf(filterExp2));
+
+ // Set variable.
+ testSourceProvider.setVariable();
+ testSourceProvider.fireSourceChanged();
+ assertFalse(WorkbenchActivityHelper.restrictUseOf(filterExp2));
+
+ //------------------------
+ // Rerun last test with a "twist" - "twist" described in next comment.
+ //------------------------
+ // Clear variable again.
+ testSourceProvider.clearVariable();
+ testSourceProvider.fireSourceChanged();
+
+ // Put the activity in the enabledActivity list, so it would run into
+ // problems if it not correctly recognizes the difference when already
+ // marked as enabled (by being in the list) while the expression, which
+ // controls the activity, becomes in reality only later enabled.
+ Set set = new HashSet(support.getActivityManager().getEnabledActivityIds());
+ set.add(EXPRESSION_ACTIVITY_ID_2);
+ support.setEnabledActivityIds(set);
+
+ // Set variable again.
+ testSourceProvider.setVariable();
+ testSourceProvider.fireSourceChanged();
+ assertFalse(WorkbenchActivityHelper.restrictUseOf(filterExp2));
+
+ evalService.removeSourceProvider(testSourceProvider);
+ }
+ finally {
+ localService.deactivateContext(activation);
+ }
}
/**
@@ -388,22 +543,21 @@ public class UtilTest extends TestCase {
return PlatformUI.getWorkbench()
.getActivitySupport().getActivityManager();
}
-
-
-// /**
-// * Tests non-regular Expression Pattern bindings.
-// */
+
+ /**
+ * Tests non-regular Expression Pattern bindings.
+ */
public void testNonRegExpressionPattern() {
final String ACTIVITY_NON_REG_EXP = "org.eclipse.activityNonRegExp";
// Check Activity -> Binding connection.
IActivityManager manager = getActivityManager();
IActivity activity = manager.getActivity(ACTIVITY_NON_REG_EXP);
- Set bindings = activity.getActivityPatternBindings();
+ Set bindings = activity.getActivityPatternBindings();
assertTrue(bindings.size() == 1);
IActivityPatternBinding binding =
(IActivityPatternBinding)bindings.iterator().next();
-// assertTrue(binding.isEqualityPattern());
+ assertTrue(binding.isEqualityPattern());
// Check Binding -> Activity connection.
final String IDENTIFIER = "org.eclipse.ui.tests.activity{No{Reg(Exp[^d]";
@@ -420,6 +574,47 @@ public class UtilTest extends TestCase {
Pattern.compile("\\Q" + IDENTIFIER + "\\E").pattern()));
}
+ /**
+ * Tests to ensure that setting enabled of an activity disabled by
+ * expression and setting disabled of an activity enabled by expression both
+ * behave as expected. Ie: it's a no-op.
+ */
+ public void testSetEnabledExpressionActivity() {
+ try {
+ TestSourceProvider testSourceProvider = new TestSourceProvider();
+ IEvaluationService evalService = (IEvaluationService) PlatformUI
+ .getWorkbench().getService(IEvaluationService.class);
+ evalService.addSourceProvider(testSourceProvider);
+ testSourceProvider.fireSourceChanged();
+
+
+ IWorkbenchActivitySupport support = PlatformUI.getWorkbench()
+ .getActivitySupport();
+ support.setEnabledActivityIds(new HashSet());
+ Set set = new HashSet(support.getActivityManager().getEnabledActivityIds());
+ Set previousSet = new HashSet(support.getActivityManager().getEnabledActivityIds());
+ set.add(EXPRESSION_ACTIVITY_ID_2);
+ support.setEnabledActivityIds(set);
+ assertEquals(previousSet, support.getActivityManager().getEnabledActivityIds());
+
+ testSourceProvider.setVariable();
+ testSourceProvider.fireSourceChanged();
+
+ set = new HashSet(support.getActivityManager().getEnabledActivityIds());
+ assertFalse(set.equals(previousSet));
+
+ set.remove(EXPRESSION_ACTIVITY_ID_2);
+ support.setEnabledActivityIds(set);
+
+ assertFalse(support.getActivityManager().getEnabledActivityIds().equals(previousSet));
+
+ evalService.removeSourceProvider(testSourceProvider);
+ }
+ finally {
+
+ }
+ }
+
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ApiTestSuite.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ApiTestSuite.java
index 827a058067..37b8fe7a83 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ApiTestSuite.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ApiTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -64,6 +64,8 @@ public class ApiTestSuite extends TestSuite {
addTest(new TestSuite(ISelectionServiceTest.class));
addTest(new TestSuite(IWorkingSetTest.class));
addTest(new TestSuite(IWorkingSetManagerTest.class));
+ addTest(new TestSuite(IWorkingSetElementAdapterTests.class));
+ addTest(new TestSuite(IAggregateWorkingSetTest.class));
addTest(new TestSuite(MockWorkingSetTest.class));
addTest(new TestSuite(Bug42616Test.class));
// addTest(new TestSuite(StickyViewTest.class));
@@ -76,7 +78,6 @@ public class ApiTestSuite extends TestSuite {
// addTest(new TestSuite(FileEditorInputTest.class));
// addTest(new TestSuite(IEditorMatchingStrategyTest.class));
addTest(new TestSuite(XMLMementoTest.class));
-// addTest(new TestSuite(TrimLayoutTest.class));
// addTest(new TestSuite(IWorkbenchPartTestableTests.class));
addTest(new TestSuite(ArbitraryPropertyTest.class));
addTest(new TestSuite(LifecycleViewTest.class));
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/BadElementFactory.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/BadElementFactory.java
index 8517078c0b..8952c14b39 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/BadElementFactory.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/BadElementFactory.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package org.eclipse.ui.tests.api;
import org.eclipse.core.runtime.IAdaptable;
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/DummyService.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/DummyService.java
new file mode 100644
index 0000000000..c5dc4bd7e6
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/DummyService.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.tests.api;
+
+import org.eclipse.ui.internal.services.INestable;
+
+/**
+ *
+ * @since 3.5
+ * @author Prakash G.R.
+ *
+ */
+public class DummyService implements INestable {
+
+ private boolean active;
+
+
+ public boolean isActive() {
+ return active;
+ }
+
+ public void activate() {
+ active = true;
+ }
+
+
+ public void deactivate() {
+ active = false;
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/DummyServiceFactory.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/DummyServiceFactory.java
new file mode 100644
index 0000000000..da6f60c20c
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/DummyServiceFactory.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.api;
+
+import org.eclipse.ui.services.AbstractServiceFactory;
+import org.eclipse.ui.services.IServiceLocator;
+
+/**
+ *
+ * @since 3.5
+ * @author Prakash G.R.
+ *
+ */
+public class DummyServiceFactory extends AbstractServiceFactory {
+
+ public Object create(Class serviceInterface, IServiceLocator parentLocator,
+ IServiceLocator locator) {
+ if(serviceInterface.equals(DummyService.class))
+ return new DummyService();
+ return null;
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IActionBarsTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IActionBarsTest.java
index 703adb6e54..926b311836 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IActionBarsTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IActionBarsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.ui.tests.api;
+//import org.eclipse.core.commands.NotEnabledException;
+//import org.eclipse.core.commands.NotHandledException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
@@ -19,6 +21,10 @@ import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
+//import org.eclipse.ui.actions.ActionFactory;
+//import org.eclipse.ui.handlers.IHandlerService;
+//import org.eclipse.ui.internal.handlers.IActionCommandMappingService;
+//import org.eclipse.ui.tests.harness.util.ActionUtil;
import org.eclipse.ui.tests.harness.util.UITestCase;
/**
@@ -86,8 +92,8 @@ public class IActionBarsTest extends UITestCase {
}
public void testGetGlobalActionHandler() throws Throwable {
- // From Javadoc: "Returns the global action handler for
- // the action with the given id.
+ // From Javadoc: "Returns the global action handler for
+ // the action with the given id.
IViewPart part = fPage.showView(MockViewPart.ID);
IActionBars bars = part.getViewSite().getActionBars();
@@ -117,68 +123,84 @@ public class IActionBarsTest extends UITestCase {
assertEquals(undo, bars
.getGlobalActionHandler(IWorkbenchActionConstants.UNDO));
}
-
+
// RAP [if] Commented as it fails with RAP X
-// RAP [hs] Fails because the EDIT menu is filled by the IDE bundle
-// public void testSetGlobalActionHandler() throws Throwable {
-// // From Javadoc: "Returns the global action handler for
-// // the action with the given id.
+// RAP [hs] Fails because the EDIT menu is filled by the IDE bundle
+// public void testSetGlobalActionHandler() throws Throwable {
+// // From Javadoc: "Returns the global action handler for
+// // the action with the given id.
+//
+// IViewPart part = fPage.showView(MockViewPart.ID);
+// IActionBars bars = part.getViewSite().getActionBars();
+// assertNotNull(bars);
+//
+// // Create actions.
+// MockAction cut = new MockAction();
+// MockAction copy = new MockAction();
+// MockAction undo = new MockAction();
+//
+// // Set actions.
+// bars.setGlobalActionHandler(IWorkbenchActionConstants.CUT, cut);
+// bars.setGlobalActionHandler(IWorkbenchActionConstants.COPY, copy);
+// bars.setGlobalActionHandler(IWorkbenchActionConstants.UNDO, undo);
+// bars.updateActionBars();
//
-// IViewPart part = fPage.showView(MockViewPart.ID);
-// IActionBars bars = part.getViewSite().getActionBars();
-// assertNotNull(bars);
+// // Run the real workbench actions.
+// // Verify the actions are invoked.
+// cut.hasRun = copy.hasRun = undo.hasRun = false;
//
-// // Create actions.
-// MockAction cut = new MockAction();
-// MockAction copy = new MockAction();
-// MockAction undo = new MockAction();
+// // anything that has been converted from a RetargetAction in
+// // WorkbenchActionBuilder must be run as a command
+// runMatchingCommand(fWindow, ActionFactory.CUT.getId());
//
-// // Set actions.
-// bars.setGlobalActionHandler(IWorkbenchActionConstants.CUT, cut);
-// bars.setGlobalActionHandler(IWorkbenchActionConstants.COPY, copy);
-// bars.setGlobalActionHandler(IWorkbenchActionConstants.UNDO, undo);
-// bars.updateActionBars();
+// ActionUtil.runActionUsingPath(this, fWindow,
+// IWorkbenchActionConstants.M_EDIT + '/'
+// + IWorkbenchActionConstants.UNDO);
+// assertTrue(cut.hasRun);
+// assertTrue(!copy.hasRun);
+// assertTrue(undo.hasRun);
//
-// // Run the real workbench actions.
-// // Verify the actions are invoked.
-// cut.hasRun = copy.hasRun = undo.hasRun = false;
-// ActionUtil.runActionUsingPath(this, fWindow,
-// IWorkbenchActionConstants.M_EDIT + '/'
-// + IWorkbenchActionConstants.CUT);
-// ActionUtil.runActionUsingPath(this, fWindow,
-// IWorkbenchActionConstants.M_EDIT + '/'
-// + IWorkbenchActionConstants.UNDO);
-// assertTrue(cut.hasRun);
-// assertTrue(!copy.hasRun);
-// assertTrue(undo.hasRun);
+// // Now create a second view and run the actions again.
+// // Our global actions should not be invoked.
+// fPage.showView(MockViewPart.ID2);
+// cut.hasRun = copy.hasRun = undo.hasRun = false;
+// runMatchingCommand(fWindow, ActionFactory.CUT.getId());
+// ActionUtil.runActionUsingPath(this, fWindow,
+// IWorkbenchActionConstants.M_EDIT + '/'
+// + IWorkbenchActionConstants.UNDO);
+// assertTrue(!cut.hasRun);
+// assertTrue(!copy.hasRun);
+// assertTrue(!undo.hasRun);
//
-// // Now create a second view and run the actions again.
-// // Our global actions should not be invoked.
-// fPage.showView(MockViewPart.ID2);
-// cut.hasRun = copy.hasRun = undo.hasRun = false;
-// ActionUtil.runActionUsingPath(this, fWindow,
-// IWorkbenchActionConstants.M_EDIT + '/'
-// + IWorkbenchActionConstants.CUT);
-// ActionUtil.runActionUsingPath(this, fWindow,
-// IWorkbenchActionConstants.M_EDIT + '/'
-// + IWorkbenchActionConstants.UNDO);
-// assertTrue(!cut.hasRun);
-// assertTrue(!copy.hasRun);
-// assertTrue(!undo.hasRun);
+// // Reactivate test view and run actions again.
+// // This time our global actions should be invoked.
+// fPage.activate(part);
+// cut.hasRun = copy.hasRun = undo.hasRun = false;
+// runMatchingCommand(fWindow, ActionFactory.CUT.getId());
+// ActionUtil.runActionUsingPath(this, fWindow,
+// IWorkbenchActionConstants.M_EDIT + '/'
+// + IWorkbenchActionConstants.UNDO);
+// assertTrue(cut.hasRun);
+// assertTrue(!copy.hasRun);
+// assertTrue(undo.hasRun);
+// }
//
-// // Reactivate test view and run actions again.
-// // This time our global actions should be invoked.
-// fPage.activate(part);
-// cut.hasRun = copy.hasRun = undo.hasRun = false;
-// ActionUtil.runActionUsingPath(this, fWindow,
-// IWorkbenchActionConstants.M_EDIT + '/'
-// + IWorkbenchActionConstants.CUT);
-// ActionUtil.runActionUsingPath(this, fWindow,
-// IWorkbenchActionConstants.M_EDIT + '/'
-// + IWorkbenchActionConstants.UNDO);
-// assertTrue(cut.hasRun);
-// assertTrue(!copy.hasRun);
-// assertTrue(undo.hasRun);
+// private void runMatchingCommand(IWorkbenchWindow window, String actionId) {
+// IHandlerService hs = (IHandlerService) window.getService(IHandlerService.class);
+// IActionCommandMappingService ms = (IActionCommandMappingService) window.getService(IActionCommandMappingService.class);
+// String commandId = ms.getCommandId(actionId);
+// assertNotNull(commandId);
+// try {
+// hs.executeCommand(commandId, null);
+// } catch (NotHandledException e) {
+// // this is not a failure, just a condition to be checked by
+// // the test
+// } catch (NotEnabledException e) {
+// // this is not a failure, just a condition to be checked by
+// // the test
+// } catch (Exception e) {
+// fail("Failed to run " + commandId, e);
+// }
// }
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IAggregateWorkingSetTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IAggregateWorkingSetTest.java
new file mode 100644
index 0000000000..84a24f3226
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IAggregateWorkingSetTest.java
@@ -0,0 +1,334 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.api;
+
+import java.lang.reflect.Method;
+
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.IAggregateWorkingSet;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.XMLMemento;
+import org.eclipse.ui.internal.AbstractWorkingSet;
+import org.eclipse.ui.internal.AbstractWorkingSetManager;
+import org.eclipse.ui.internal.AggregateWorkingSet;
+import org.eclipse.ui.internal.IWorkbenchConstants;
+import org.eclipse.ui.tests.harness.util.ArrayUtil;
+import org.eclipse.ui.tests.harness.util.UITestCase;
+
+public class IAggregateWorkingSetTest extends UITestCase {
+
+ final static String WORKING_SET_NAME = "testws";
+ final static String AGGREGATE_WORKING_SET_NAME_ = "testaggregatews";
+ final static String WSET_PAGE_ID="org.eclipse.ui.resourceWorkingSetPage";
+ IWorkspace fWorkspace;
+
+ IWorkingSet[] components;
+ IAggregateWorkingSet fWorkingSet;
+
+ public IAggregateWorkingSetTest(String testName) {
+ super(testName);
+ }
+
+ protected void doSetUp() throws Exception {
+ super.doSetUp();
+ IWorkingSetManager workingSetManager = fWorkbench
+ .getWorkingSetManager();
+
+ fWorkspace = ResourcesPlugin.getWorkspace();
+ components = new IWorkingSet[4];
+ for (int i = 0; i < 4; i++) {
+ components[i] = workingSetManager.createWorkingSet(WORKING_SET_NAME
+ + i, new IAdaptable[] {});
+ workingSetManager.addWorkingSet(components[i]);
+ }
+ fWorkingSet = (IAggregateWorkingSet) workingSetManager
+ .createAggregateWorkingSet(AGGREGATE_WORKING_SET_NAME_,
+ AGGREGATE_WORKING_SET_NAME_, components);
+
+ workingSetManager.addWorkingSet(fWorkingSet);
+ }
+ protected void doTearDown() throws Exception {
+ IWorkingSetManager workingSetManager = fWorkbench.getWorkingSetManager();
+ workingSetManager.removeWorkingSet(fWorkingSet);
+ for (int i = 0; i < components.length; i++) {
+ workingSetManager.removeWorkingSet(components[i]);
+ }
+ super.doTearDown();
+ }
+
+ public void testSaveWSet() throws Throwable {
+ //<possible client code>
+ IWorkingSetManager workingSetManager = fWorkbench
+ .getWorkingSetManager();
+ IWorkingSet set=workingSetManager.getWorkingSet(AGGREGATE_WORKING_SET_NAME_);
+ if(set.isAggregateWorkingSet()){
+ IWorkingSet[] sets=((IAggregateWorkingSet)set).getComponents();
+ if(sets.length>=1){
+ sets[0]=null; //client fails to pay enough attention to specs or unknowingly does this
+ }
+ }
+ //</possible client code>
+ //error makes it look like it comes from workingsets api, with no clue about the actual culprit
+ IMemento memento=XMLMemento.createWriteRoot(IWorkbenchConstants.TAG_WORKING_SET);
+ set.saveState(memento);
+ }
+ public void testGetElemets() throws Throwable {
+ //<possible client code>
+ IWorkingSetManager workingSetManager = fWorkbench
+ .getWorkingSetManager();
+ IWorkingSet set=workingSetManager.getWorkingSet(AGGREGATE_WORKING_SET_NAME_);
+ if(set.isAggregateWorkingSet()){
+ IWorkingSet[] sets=((IAggregateWorkingSet)set).getComponents();
+ if(sets.length>1){
+ //code 2 fails to pay enough attention to specs or unknowingly does this
+ sets[0]=workingSetManager.createWorkingSet(WORKING_SET_NAME, new IAdaptable[] { fWorkspace.getRoot() });
+ //code 1 part removes a workingset
+ workingSetManager.removeWorkingSet(sets[1]);
+ }
+ }
+ //</possible client code>
+
+ //unexpected
+ assertTrue(ArrayUtil.equals(
+ new IAdaptable[] {},
+ fWorkingSet.getElements()));
+ }
+
+ /**
+ * Core of the problem: while Eclipse is running, name collisions among working sets
+ * don't matter. However, on save and restart names will be used to identify working
+ * sets, which could possibly lead to cycles in aggregate working sets.
+ *
+ * Bottom line: if there are multiple aggregate working sets with the same name, expect
+ * trouble on restart.
+ *
+ * To create a cycle we have to be creative:
+ * - create an aggregate1 with an ID = "testCycle"
+ * - create an aggregate2 with an ID = "testCycle" containing aggregate1
+ * - save it into IMemento
+ *
+ * Now the IMememnto creates a self reference:
+ *
+ * <workingSet name="testCycle" label="testCycle" aggregate="true">
+ * <workingSet IMemento.internal.id="testCycle" />
+ * </workingSet>
+ *
+ * All we have to do to emulate stack overflow is to create a working set based on this IMemento.
+ *
+ * @throws Throwable
+ */
+ public void testWorkingSetCycle() throws Throwable {
+ IWorkingSetManager manager = fWorkbench.getWorkingSetManager();
+
+ // create an IMemento with a cycle in it
+ IAggregateWorkingSet aggregate = (IAggregateWorkingSet) manager
+ .createAggregateWorkingSet("testCycle","testCycle", new IWorkingSet[0]);
+
+ IAggregateWorkingSet aggregate2 = (IAggregateWorkingSet) manager
+ .createAggregateWorkingSet("testCycle","testCycle", new IWorkingSet[] {aggregate});
+
+ IMemento memento=XMLMemento.createWriteRoot(IWorkbenchConstants.TAG_WORKING_SET);
+ aggregate2.saveState(memento);
+
+ // load the IMemento
+ IAggregateWorkingSet aggregateReloaded = null;
+ try {
+ aggregateReloaded = (IAggregateWorkingSet) manager.createWorkingSet(memento);
+ manager.addWorkingSet(aggregateReloaded);
+ aggregateReloaded.getComponents();
+ } catch (StackOverflowError e) {
+ e.printStackTrace();
+ fail("Stack overflow for self-referenced aggregate working set", e);
+ } finally {
+ if (aggregateReloaded != null)
+ manager.removeWorkingSet(aggregateReloaded);
+ }
+ }
+
+ /**
+ * Tests cleanup of the cycle from an aggregate working set.
+ * @throws Throwable
+ */
+ public void testCycleCleanup() throws Throwable {
+ IWorkingSetManager manager = fWorkbench.getWorkingSetManager();
+
+ // create an IMemento with a cycle in it: { good, good, cycle, good, good }
+ IAggregateWorkingSet aggregateSub0 = (IAggregateWorkingSet) manager
+ .createAggregateWorkingSet("testCycle0","testCycle0", new IWorkingSet[0]);
+
+ IAggregateWorkingSet aggregateSub1 = (IAggregateWorkingSet) manager
+ .createAggregateWorkingSet("testCycle1","testCycle1", new IWorkingSet[0]);
+
+ IAggregateWorkingSet aggregateSub2 = (IAggregateWorkingSet) manager
+ .createAggregateWorkingSet("testCycle","testCycle", new IWorkingSet[0]); // cycle
+
+ IAggregateWorkingSet aggregateSub3 = (IAggregateWorkingSet) manager
+ .createAggregateWorkingSet("testCycle3","testCycle3", new IWorkingSet[0]);
+
+ IAggregateWorkingSet aggregateSub4 = (IAggregateWorkingSet) manager
+ .createAggregateWorkingSet("testCycle4","testCycle4", new IWorkingSet[0]);
+
+
+ IAggregateWorkingSet aggregate = (IAggregateWorkingSet) manager
+ .createAggregateWorkingSet("testCycle","testCycle", new IWorkingSet[] {aggregateSub0,
+ aggregateSub1, aggregateSub2, aggregateSub3, aggregateSub4});
+
+ manager.addWorkingSet(aggregateSub0);
+ manager.addWorkingSet(aggregateSub1);
+ manager.addWorkingSet(aggregateSub3);
+ manager.addWorkingSet(aggregateSub4);
+
+ IMemento memento=XMLMemento.createWriteRoot(IWorkbenchConstants.TAG_WORKING_SET);
+ aggregate.saveState(memento);
+
+ // load the IMemento
+ IAggregateWorkingSet aggregateReloaded = null;
+ try {
+ aggregateReloaded = (IAggregateWorkingSet) manager.createWorkingSet(memento);
+ manager.addWorkingSet(aggregateReloaded);
+ IWorkingSet[] aggregates = aggregateReloaded.getComponents();
+ assertNotNull(aggregates);
+ assertEquals(4, aggregates.length);
+ for(int i = 0; i < aggregates.length; i++)
+ assertFalse("testCycle".equals(aggregates[i].getName()));
+ } catch (StackOverflowError e) {
+ e.printStackTrace();
+ fail("Stack overflow for self-referenced aggregate working set", e);
+ } finally {
+ if (aggregateReloaded != null)
+ manager.removeWorkingSet(aggregateReloaded);
+ }
+ }
+
+ /*
+ * Test related to Bug 217955.The initial fix made changes that caused
+ * save/restore to fail due to early restore and forward reference in
+ * memento of aggregates
+ */
+ public void testWorkingSetSaveRestoreAggregates() throws Throwable {
+ IWorkingSetManager manager = fWorkbench.getWorkingSetManager();
+ String nameA = "A";
+ String nameB = "B";
+ String nameC = "C";
+
+ IWorkingSet wSetA = manager
+ .createWorkingSet(nameA, new IAdaptable[] {});
+ manager.addWorkingSet(wSetA);
+
+ IAggregateWorkingSet wSetB = (IAggregateWorkingSet) manager
+ .createAggregateWorkingSet(nameB, nameB, new IWorkingSet[] {});
+ manager.addWorkingSet(wSetB);
+
+ IAggregateWorkingSet wSetC = (IAggregateWorkingSet) manager
+ .createAggregateWorkingSet(nameC, nameC, new IWorkingSet[0]);
+ manager.addWorkingSet(wSetC);
+
+ try {
+ assertEquals("Failed to add workingset" + nameA, wSetA, manager
+ .getWorkingSet(nameA));
+
+ assertEquals("Failed to add workingset" + nameC, wSetC, manager
+ .getWorkingSet(nameC));
+
+ assertEquals("Failed to add workingset" + nameB, wSetB, manager
+ .getWorkingSet(nameB));
+
+ invokeMethod(AggregateWorkingSet.class, "setComponents", wSetB,
+ new Object[] { new IWorkingSet[] {
+ wSetA, wSetC } },
+ new Class[] { new IWorkingSet[] {}.getClass() });
+
+ saveRestoreWorkingSetManager();
+
+ IAggregateWorkingSet restoredB = (IAggregateWorkingSet) manager
+ .getWorkingSet(nameB);
+ assertTrue("Unable to save/restore correctly", restoredB!=null);
+
+ IAggregateWorkingSet restoredC = (IAggregateWorkingSet) manager
+ .getWorkingSet(nameC);
+ assertTrue("Unable to save/restore correctly", restoredC!=null);
+
+ IWorkingSet[] componenets1=wSetB.getComponents();
+ IWorkingSet[] componenets2=((IAggregateWorkingSet) manager
+ .getWorkingSet(nameB)).getComponents();
+
+ if (componenets1.length != componenets2.length)
+ fail(nameB + " has lost data in the process of save/restore");
+ else {
+ for (int i = 0; i < componenets1.length; i++)
+ if (!componenets1[i].equals(componenets2[i]))
+ fail(nameB + " has lost data in the process of save/restore");
+ }
+
+ } finally {
+ // restore
+ IWorkingSet set = manager.getWorkingSet(nameA);
+ if (set != null) {
+ manager.removeWorkingSet(set);
+ }
+ set = manager.getWorkingSet(nameB);
+ if (set != null) {
+ manager.removeWorkingSet(set);
+ }
+ set = manager.getWorkingSet(nameC);
+ if (set != null) {
+ manager.removeWorkingSet(set);
+ }
+ }
+ }
+
+ private void saveRestoreWorkingSetManager() {
+ IMemento managerMemento = XMLMemento
+ .createWriteRoot(IWorkbenchConstants.TAG_WORKING_SET_MANAGER);
+ IWorkingSetManager manager = fWorkbench.getWorkingSetManager();
+ IWorkingSet[] sets = manager.getAllWorkingSets();
+ for (int i = 0; i < sets.length; i++) {
+ if(sets[i].getId()==null){
+ //set default id as set by factory
+ sets[i].setId(WSET_PAGE_ID);
+ }
+ }
+ invokeMethod(AbstractWorkingSetManager.class, "saveWorkingSetState",
+ manager, new Object[] { managerMemento },
+ new Class[] { IMemento.class });
+ invokeMethod(AbstractWorkingSetManager.class, "saveMruList", manager,
+ new Object[] { managerMemento }, new Class[] { IMemento.class });
+ for (int i = 0; i < sets.length; i++) {
+ ((AbstractWorkingSet) sets[i]).disconnect();
+ }
+ for (int i = 0; i < sets.length; i++) {
+ manager.removeWorkingSet(sets[i]);
+ }
+ //manager.dispose(); //not needed, also cause problems
+ invokeMethod(AbstractWorkingSetManager.class, "restoreWorkingSetState",
+ manager, new Object[] { managerMemento },
+ new Class[] { IMemento.class });
+ invokeMethod(AbstractWorkingSetManager.class, "restoreMruList",
+ manager, new Object[] { managerMemento },
+ new Class[] { IMemento.class });
+ }
+
+ private Object invokeMethod(Class clazz, String methodName,
+ Object instance, Object[] args, Class[] argsClasses) {
+ try {
+ Method method = clazz.getDeclaredMethod(methodName, argsClasses);
+ method.setAccessible(true);
+ return method.invoke(instance, args);
+ } catch (Exception e) {
+ fail("Failure in invoking " + clazz.getName() + methodName, e);
+ }
+ return null;
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorRegistryTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorRegistryTest.java
index 4263161ca0..fae1d91c59 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorRegistryTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorRegistryTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,6 +22,7 @@ import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.IFileEditorMapping;
import org.eclipse.ui.PlatformUI;
+//import org.eclipse.ui.internal.registry.EditorDescriptor;
import org.eclipse.ui.internal.registry.EditorRegistry;
import org.eclipse.ui.internal.registry.FileEditorMapping;
import org.eclipse.ui.tests.TestPlugin;
@@ -206,7 +207,7 @@ public class IEditorRegistryTest extends TestCase {
// }
assertEquals(image1, image2);
assertEquals(image2, fReg.getImageDescriptor(file.getName()));
-
+
}
public void testAddPropertyListener() throws Throwable {
@@ -327,7 +328,7 @@ public class IEditorRegistryTest extends TestCase {
}
// RAP [if] Commented as it fails with RAP X
-// RAP [hs] fails because it uses stuff from org.eclipse.core.runtime.content
+// RAP [hs] fails because it uses stuff from org.eclipse.core.runtime.content
// /**
// * Assert that in the absence of content type, choose the content type
// * editor based on content type guess.
@@ -396,4 +397,101 @@ public class IEditorRegistryTest extends TestCase {
}
+// public void testSwitchDefaultToExternalBug236104() {
+// IEditorDescriptor htmlDescriptor = fReg.getDefaultEditor("test.html");
+// assertNotNull(htmlDescriptor);
+//
+// IFileEditorMapping[] src = fReg.getFileEditorMappings();
+// FileEditorMapping[] maps = new FileEditorMapping[src.length];
+// System.arraycopy(src, 0, maps, 0, src.length);
+// FileEditorMapping map = null;
+//
+// for (int i = 0; i < maps.length; i++) {
+// if (maps[i].getExtension().equals("html")) {
+// map = maps[i];
+// break;
+// }
+// }
+//
+// assertNotNull(map);
+//
+// EditorDescriptor replacementDescriptor = EditorDescriptor
+// .createForProgram("notepad.exe");
+//
+// try {
+// map.setDefaultEditor(replacementDescriptor);
+//
+// // invoke the same code that FileEditorsPreferencePage does
+// ((EditorRegistry) fReg).setFileEditorMappings(maps);
+// ((EditorRegistry) fReg).saveAssociations();
+// PrefUtil.savePrefs();
+//
+// IEditorDescriptor newDescriptor = fReg
+// .getDefaultEditor("test.html");
+//
+// assertEquals(replacementDescriptor, newDescriptor);
+// assertFalse(replacementDescriptor.equals(htmlDescriptor));
+// } finally {
+// src = fReg.getFileEditorMappings();
+// maps = new FileEditorMapping[src.length];
+// System.arraycopy(src, 0, maps, 0, src.length);
+// map = null;
+//
+// for (int i = 0; i < maps.length; i++) {
+// if (maps[i].getExtension().equals("html")) {
+// map = maps[i];
+// break;
+// }
+// }
+//
+// assertNotNull(map);
+//
+// map.setDefaultEditor((EditorDescriptor) htmlDescriptor);
+// ((EditorRegistry) fReg).setFileEditorMappings(maps);
+// ((EditorRegistry) fReg).saveAssociations();
+// PrefUtil.savePrefs();
+// }
+// }
+//
+// public void testBug308894() throws Throwable {
+// FileEditorMapping newMapping = new FileEditorMapping("*.abc");
+// assertNull(newMapping.getDefaultEditor());
+//
+// FileEditorMapping[] src = (FileEditorMapping[]) fReg.getFileEditorMappings();
+// FileEditorMapping[] maps = new FileEditorMapping[src.length + 1];
+// System.arraycopy(src, 0, maps, 0, src.length);
+// maps[maps.length - 1] = newMapping;
+//
+// final Throwable[] thrownException = new Throwable[1];
+// ILogListener listener = new ILogListener() {
+// public void logging(IStatus status, String plugin) {
+// Throwable throwable = status.getException();
+// if (throwable == null) {
+// thrownException[0] = new CoreException(status);
+// } else {
+// thrownException[0] = throwable;
+// }
+// }
+// };
+// Platform.addLogListener(listener);
+//
+// try {
+// // invoke the same code that FileEditorsPreferencePage does
+// ((EditorRegistry) fReg).setFileEditorMappings(maps);
+// ((EditorRegistry) fReg).saveAssociations();
+// PrefUtil.savePrefs();
+// } finally {
+// // undo the change
+// ((EditorRegistry) fReg).setFileEditorMappings(src);
+// ((EditorRegistry) fReg).saveAssociations();
+// PrefUtil.savePrefs();
+//
+// Platform.removeLogListener(listener);
+//
+// if (thrownException[0] != null) {
+// throw thrownException[0];
+// }
+// }
+// }
+
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IFileEditorMappingTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IFileEditorMappingTest.java
index 9b72de94e1..5198add668 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IFileEditorMappingTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IFileEditorMappingTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -39,8 +39,8 @@ public class IFileEditorMappingTest extends TestCase {
for (int i = 0; i < fMappings.length; i++) {
label = fMappings[i].getLabel();
assertNotNull(label);
- assertTrue(label.equals(fMappings[i].getName() + "."
- + fMappings[i].getExtension()));
+ assertEquals(label, fMappings[i].getName() + "."
+ + fMappings[i].getExtension());
}
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPageListenerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPageListenerTest.java
index 66b6f3cb14..aad58340d5 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPageListenerTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPageListenerTest.java
@@ -128,7 +128,7 @@ public class IPageListenerTest extends UITestCase implements IPageListener {
*/
public void pageActivated(IWorkbenchPage page) {
if (pageMask == null || page == pageMask)
- eventsReceived |= ACTIVATE;
+ eventsReceived = eventsReceived | ACTIVATE;
}
/**
@@ -136,7 +136,7 @@ public class IPageListenerTest extends UITestCase implements IPageListener {
*/
public void pageClosed(IWorkbenchPage page) {
if (pageMask == null || page == pageMask)
- eventsReceived |= CLOSE;
+ eventsReceived = eventsReceived | CLOSE;
}
/**
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPartServiceTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPartServiceTest.java
index f8903d710a..0995a0c99e 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPartServiceTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPartServiceTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,13 +23,13 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.internal.PartSite;
-//import org.eclipse.ui.internal.SlavePartService;
+import org.eclipse.ui.internal.tweaklets.Tweaklets;
//import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.tests.harness.util.CallHistory;
import org.eclipse.ui.tests.harness.util.EmptyPerspective;
//import org.eclipse.ui.tests.harness.util.FileUtil;
import org.eclipse.ui.tests.harness.util.UITestCase;
+import org.eclipse.ui.tests.helpers.TestFacade;
/**
* Tests the IPartService, IPartListener and IPartListener2 interfaces.
@@ -122,6 +122,8 @@ public class IPartServiceTest extends UITestCase {
private CallHistory history2 = new CallHistory(partListener2);
+ private TestFacade facade;
+
public IPartServiceTest(String testName) {
super(testName);
}
@@ -140,10 +142,11 @@ public class IPartServiceTest extends UITestCase {
super.doSetUp();
fWindow = openTestWindow();
fPage = fWindow.getActivePage();
+ facade = (TestFacade) Tweaklets.get(TestFacade.KEY);
}
private IWorkbenchPartReference getRef(IWorkbenchPart part) {
- return ((PartSite) part.getSite()).getPartReference();
+ return fPage.getReference(part);
}
/**
@@ -176,11 +179,11 @@ public class IPartServiceTest extends UITestCase {
assertTrue(history2.verifyOrder(new String[] { "partDeactivated",
"partHidden", "partClosed" }));
assertEquals(getRef(view), eventPartRef);
-
+
fPage.removePartListener(partListener);
fPage.removePartListener(partListener2);
}
-
+
// public void testLocalPartService() throws Throwable {
// IPartService service = (IPartService) fWindow
// .getService(IPartService.class);
@@ -215,7 +218,7 @@ public class IPartServiceTest extends UITestCase {
// fPage.hideView(view2);
// assertTrue(history.verifyOrder(new String[] { "partDeactivated",
// "partActivated", "partClosed" }));
-//
+//
// // Hide view, listeners should be disposed
// fPage.hideView(view);
// clearEventState();
@@ -255,7 +258,7 @@ public class IPartServiceTest extends UITestCase {
assertTrue(history2.verifyOrder(new String[] { "partDeactivated",
"partHidden", "partClosed" }));
assertEquals(getRef(view), eventPartRef);
-
+
service.removePartListener(partListener);
service.removePartListener(partListener2);
}
@@ -331,7 +334,7 @@ public class IPartServiceTest extends UITestCase {
/**
* Tests the partHidden method by closing a view when it is shared with another perspective.
- * Includes regression test for:
+ * Includes regression test for:
* Bug 60039 [ViewMgmt] (regression) IWorkbenchPage#findView returns non-null value after part has been closed
*/
public void testPartHiddenWhenClosedAndShared() throws Throwable {
@@ -445,7 +448,7 @@ public class IPartServiceTest extends UITestCase {
* @throws Throwable
*/
public void testPartHiddenBeforeClosing() throws Throwable {
-
+
final boolean[] eventReceived = {false, false};
IPartListener2 listener = new TestPartListener2() {
public void partHidden(IWorkbenchPartReference ref) {
@@ -480,7 +483,7 @@ public class IPartServiceTest extends UITestCase {
assertTrue(eventReceived[0]);
assertTrue(eventReceived[1]);
}
-
+
/**
* Tests the partVisible method by activating a view obscured by
* another view in the same folder.
@@ -506,15 +509,15 @@ public class IPartServiceTest extends UITestCase {
fPage.removePartListener(listener);
assertTrue(eventReceived[0]);
}
-
+
// /**
// * Tests that when a partOpened is received for a view being shown,
// * the view is available via findView, findViewReference, getViews and getViewReferences.
-// *
+// *
// * @since 3.1
// */
// This does not work as expected. See bug 93784.
-//
+//
// public void testViewFoundWhenOpened() throws Throwable {
// final String viewId = MockViewPart.ID;
// final boolean[] eventReceived = { false, false };
@@ -556,7 +559,7 @@ public class IPartServiceTest extends UITestCase {
// /**
// * Tests that when a partOpened is received for an editor being opened,
// * the editor is available via findEditor, getEditors, and getEditorReferences.
-// *
+// *
// * @since 3.1
// */
// public void testEditorFoundWhenOpened() throws Throwable {
@@ -564,7 +567,7 @@ public class IPartServiceTest extends UITestCase {
// IProject proj = FileUtil.createProject("IPartServiceTest");
// IFile file = FileUtil.createFile("testEditorFoundWhenOpened.txt", proj);
// final IEditorInput editorInput = new FileEditorInput(file);
-//
+//
// final boolean[] eventReceived = { false, false };
// IPartListener listener = new TestPartListener() {
// public void partOpened(IWorkbenchPart part) {
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPerspectiveListenerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPerspectiveListenerTest.java
index 3fee6e29d3..9cac930ab8 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPerspectiveListenerTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPerspectiveListenerTest.java
@@ -80,7 +80,7 @@ public class IPerspectiveListenerTest extends UITestCase implements
public void perspectiveActivated(IWorkbenchPage page,
IPerspectiveDescriptor perspective) {
if (page == fPageMask && perspective == fPerMask)
- fEvent |= ACTIVATED;
+ fEvent = fEvent | ACTIVATED;
}
/**
@@ -89,7 +89,7 @@ public class IPerspectiveListenerTest extends UITestCase implements
public void perspectiveChanged(IWorkbenchPage page,
IPerspectiveDescriptor perspective, String changeId) {
if (page == fPageMask && perspective == fPerMask)
- fEvent |= CHANGED;
+ fEvent = fEvent | CHANGED;
}
public static boolean isOpen(int bits) {
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ISelectionServiceTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ISelectionServiceTest.java
index 642c65e03b..73f180fe50 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ISelectionServiceTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ISelectionServiceTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPageTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPageTest.java
index 0da3605d5e..71218e824b 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPageTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPageTest.java
@@ -1,5 +1,5 @@
///*******************************************************************************
-// * Copyright (c) 2000, 2007 IBM Corporation and others.
+// * Copyright (c) 2000, 2010 IBM Corporation and others.
// * All rights reserved. This program and the accompanying materials
// * are made available under the terms of the Eclipse Public License v1.0
// * which accompanies this distribution, and is available at
@@ -28,6 +28,10 @@
//import org.eclipse.core.resources.IProject;
//import org.eclipse.core.resources.IResource;
//import org.eclipse.core.runtime.IAdaptable;
+//import org.eclipse.core.runtime.ILogListener;
+//import org.eclipse.core.runtime.IStatus;
+//import org.eclipse.core.runtime.Platform;
+//import org.eclipse.jface.text.IDocument;
//import org.eclipse.jface.util.IPropertyChangeListener;
//import org.eclipse.jface.util.PropertyChangeEvent;
//import org.eclipse.ui.IEditorInput;
@@ -35,11 +39,14 @@
//import org.eclipse.ui.IEditorReference;
//import org.eclipse.ui.IMemento;
//import org.eclipse.ui.IPageLayout;
+//import org.eclipse.ui.IPartListener2;
//import org.eclipse.ui.IPerspectiveDescriptor;
//import org.eclipse.ui.IPerspectiveRegistry;
//import org.eclipse.ui.IViewPart;
//import org.eclipse.ui.IViewReference;
+//import org.eclipse.ui.IWorkbenchCommandConstants;
//import org.eclipse.ui.IWorkbenchPage;
+//import org.eclipse.ui.IWorkbenchPartReference;
//import org.eclipse.ui.IWorkbenchWindow;
//import org.eclipse.ui.IWorkingSet;
//import org.eclipse.ui.IWorkingSetManager;
@@ -48,18 +55,23 @@
//import org.eclipse.ui.WorkbenchException;
//import org.eclipse.ui.XMLMemento;
//import org.eclipse.ui.commands.ICommandService;
+//import org.eclipse.ui.editors.text.EditorsUI;
+//import org.eclipse.ui.editors.text.TextEditor;
//import org.eclipse.ui.handlers.IHandlerService;
//import org.eclipse.ui.ide.IDE;
-//import org.eclipse.ui.internal.SaveableHelper;
-//import org.eclipse.ui.internal.WorkbenchPage;
//import org.eclipse.ui.internal.WorkbenchPlugin;
-//import org.eclipse.ui.internal.registry.IActionSetDescriptor;
+//import org.eclipse.ui.internal.tweaklets.Tweaklets;
+//import org.eclipse.ui.internal.util.Util;
+//import org.eclipse.ui.navigator.resources.ProjectExplorer;
//import org.eclipse.ui.part.FileEditorInput;
-//import org.eclipse.ui.tests.PerspectiveState;
+//import org.eclipse.ui.part.IPage;
//import org.eclipse.ui.tests.harness.util.CallHistory;
//import org.eclipse.ui.tests.harness.util.EmptyPerspective;
//import org.eclipse.ui.tests.harness.util.FileUtil;
//import org.eclipse.ui.tests.harness.util.UITestCase;
+//import org.eclipse.ui.tests.helpers.TestFacade;
+//import org.eclipse.ui.texteditor.ITextEditor;
+//import org.eclipse.ui.views.contentoutline.ContentOutline;
//
//public class IWorkbenchPageTest extends UITestCase {
//
@@ -69,6 +81,61 @@
//
// private IProject proj;
//
+// private int logCount;
+// private IStatus logStatus;
+// String getMessage() {
+// return logStatus==null?"No message":logStatus.getMessage();
+// }
+// ILogListener openAndHideListener = new ILogListener() {
+// public void logging(IStatus status, String plugin) {
+// logStatus = status;
+// logCount++;
+// }
+// };
+//
+//
+// private int partHiddenCount = 0;
+// private IWorkbenchPartReference partHiddenRef = null;
+// private int partVisibleCount = 0;
+// private IWorkbenchPartReference partVisibleRef = null;
+// private int partActiveCount = 0;
+// private IWorkbenchPartReference partActiveRef = null;
+// IPartListener2 partListener2 = new IPartListener2() {
+// public void partActivated(IWorkbenchPartReference partRef) {
+// partActiveCount++;
+// partActiveRef = partRef;
+// }
+//
+// public void partBroughtToTop(IWorkbenchPartReference partRef) {
+// }
+//
+// public void partClosed(IWorkbenchPartReference partRef) {
+// }
+//
+// public void partDeactivated(IWorkbenchPartReference partRef) {
+// }
+//
+// public void partHidden(IWorkbenchPartReference partRef) {
+// partHiddenCount++;
+// partHiddenRef = partRef;
+// }
+//
+// public void partInputChanged(IWorkbenchPartReference partRef) {
+// }
+//
+// public void partOpened(IWorkbenchPartReference partRef) {
+// }
+//
+// public void partVisible(IWorkbenchPartReference partRef) {
+// partVisibleCount++;
+// partVisibleRef = partRef;
+// }
+// };
+//
+// private TestFacade facade;
+//
+//
+//
// public IWorkbenchPageTest(String testName) {
// super(testName);
// }
@@ -77,6 +144,10 @@
// super.doSetUp();
// fWin = openTestWindow();
// fActivePage = fWin.getActivePage();
+// logStatus = null;
+// logCount = 0;
+// facade = (TestFacade) Tweaklets.get(TestFacade.KEY);
+// Platform.addLogListener(openAndHideListener);
// }
//
// protected void doTearDown() throws Exception {
@@ -85,11 +156,12 @@
// FileUtil.deleteProject(proj);
// proj = null;
// }
+// Platform.removeLogListener(openAndHideListener);
// }
//
// /**
// * Tests the new working set API.
-// *
+// *
// * @since 3.2
// */
// public void testWorkingSets1() {
@@ -143,7 +215,7 @@
//
// /**
// * Tests the new working set API.
-// *
+// *
// * @since 3.2
// */
// public void testWorkingSets2() {
@@ -155,7 +227,7 @@
//
// /**
// * Tests the working set listeners.
-// *
+// *
// * @since 3.2
// */
// public void testWorkingSets3() {
@@ -201,31 +273,26 @@
// * stack that does not contain the active view. Ensures that the created
// * view is not the active part but is the top part in its stack.
// */
-// public void testView_VISIBLE2() {
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
-// try {
-// page.setPerspective(WorkbenchPlugin.getDefault()
-// .getPerspectiveRegistry().findPerspectiveWithId(
-// "org.eclipse.ui.tests.api.ViewPerspective"));
+// public void testView_VISIBLE2() throws PartInitException {
+// fActivePage.setPerspective(WorkbenchPlugin.getDefault()
+// .getPerspectiveRegistry().findPerspectiveWithId(
+// "org.eclipse.ui.tests.api.ViewPerspective"));
//
-// // create a part to be active
-// IViewPart activePart = page.showView(MockViewPart.ID3);
+// // create a part to be active
+// IViewPart activePart = fActivePage.showView(MockViewPart.ID3);
//
-// IViewPart createdPart = page.showView(MockViewPart.ID2, null,
-// IWorkbenchPage.VIEW_VISIBLE);
+// IViewPart createdPart = fActivePage.showView(MockViewPart.ID2, null,
+// IWorkbenchPage.VIEW_VISIBLE);
//
-// IViewPart[] stack = page.getViewStack(createdPart);
-// assertEquals(2, stack.length);
+// IViewPart[] stack = fActivePage.getViewStack(createdPart);
+// assertEquals(2, stack.length);
//
-// assertEquals(createdPart, stack[0]);
-// assertEquals(page.findView(MockViewPart.ID), stack[1]);
+// assertEquals(createdPart, stack[0]);
+// assertEquals(fActivePage.findView(MockViewPart.ID), stack[1]);
//
-// assertTrue(page.isPartVisible(createdPart));
+// assertTrue(fActivePage.isPartVisible(createdPart));
//
-// assertEquals(activePart, page.getActivePart());
-// } catch (PartInitException e) {
-// fail(e.getMessage());
-// }
+// assertEquals(activePart, fActivePage.getActivePart());
// }
//
// /**
@@ -627,6 +694,33 @@
// assertEquals(listenerCall.contains("partActivated"), true);
// }
//
+// /**
+// * Tests that the marker's value for the <code>IDE.EDITOR_ID_ATTR</code>
+// * attribute.
+// */
+// public void testOpenEditor7_Bug203640() throws Throwable {
+// proj = FileUtil.createProject("testOpenEditor");
+// IFile file = FileUtil.createFile("aa.mock2", proj);
+// IMarker marker = file.createMarker(
+// IMarker.TASK);
+// marker.setAttribute(IDE.EDITOR_ID_ATTR, MockEditorPart.ID1);
+//
+// // open a regular text editor
+// IEditorPart regularEditor = fActivePage.openEditor(new FileEditorInput(file), EditorsUI.DEFAULT_TEXT_EDITOR_ID);
+// assertNotNull(regularEditor);
+// assertTrue(regularEditor instanceof TextEditor);
+//
+// // open the registered editor for the marker resource
+// IEditorPart markerEditor = IDE.openEditor(fActivePage, marker);
+// assertNotNull(markerEditor);
+// assertTrue(markerEditor instanceof MockEditorPart);
+//
+// // these shouldn't be the same, if they are it's a bug
+// assertFalse(markerEditor == regularEditor);
+// assertFalse(markerEditor.equals(regularEditor));
+// assertEquals(2, fActivePage.getEditorReferences().length);
+// }
+//
// public void testGetPerspective() throws Throwable {
// assertNotNull(fActivePage.getPerspective());
//
@@ -698,11 +792,64 @@
// assertEquals(callTrace.contains("partBroughtToTop"), true);
// }
//
+// /**
+// * Test to ensure that a minimized view can be brought to the top and
+// * consequently made visible.
+// *
+// * @param hasEditors whether there should be editors open or not
+// */
+// private void testBringToTop_MinimizedViewBug292966(boolean hasEditors) throws Throwable {
+// // first show the view we're going to test
+// IViewPart propertiesView = fActivePage.showView(IPageLayout.ID_PROP_SHEET);
+// assertNotNull(propertiesView);
+//
+// proj = FileUtil.createProject("testOpenEditor");
+// // open an editor
+// IEditorPart editor = IDE.openEditor(fActivePage, FileUtil.createFile(
+// "a.mock1", proj));
+// assertNotNull("The editor could not be opened", editor); //$NON-NLS-1$
+// assertTrue("The editor is not visible", fActivePage.isPartVisible(editor)); //$NON-NLS-1$
+//
+// if (!hasEditors) {
+// // close editors if we don't want them opened for this test
+// fActivePage.closeAllEditors(false);
+// assertEquals("All the editors should have been closed", 0, fActivePage.getEditorReferences().length); //$NON-NLS-1$
+// }
+//
+// // minimize the view we're testing
+// fActivePage.setPartState(fActivePage.getReference(propertiesView), IWorkbenchPage.STATE_MINIMIZED);
+// assertFalse("A minimized view should not be visible", fActivePage.isPartVisible(propertiesView)); //$NON-NLS-1$
+//
+// // open another view so that it now becomes the active part container
+// IViewPart projectExplorer = fActivePage.showView(IPageLayout.ID_PROJECT_EXPLORER);
+// // get the list of views that shares the stack with this other view
+// IViewPart[] viewStack = fActivePage.getViewStack(projectExplorer);
+// // make sure that we didn't inadvertently bring back the test view by mistake
+// for (int i = 0; i < viewStack.length; i++) {
+// assertFalse("The properties view should not be on the same stack as the project explorer", //$NON-NLS-1$
+// viewStack[i].getSite().getId().equals(IPageLayout.ID_PROP_SHEET));
+// }
+//
+// // bring the test view back from its minimized state
+// fActivePage.bringToTop(propertiesView);
+// // the view should be visible
+// assertTrue("Invoking bringToTop(IWorkbenchPart) should cause the part to be visible", //$NON-NLS-1$
+// fActivePage.isPartVisible(propertiesView));
+// }
+//
+// public void testBringToTop_MinimizedViewWithEditorsBug292966() throws Throwable {
+// testBringToTop_MinimizedViewBug292966(false);
+// }
+//
+// public void testBringToTop_MinimizedViewWithoutEditorsBug292966() throws Throwable {
+// testBringToTop_MinimizedViewBug292966(true);
+// }
+//
// public void testGetWorkbenchWindow() {
// /*
// * Commented out because until test case can be updated to work with new
// * window/page/perspective implementation
-// *
+// *
// * assertEquals(fActivePage.getWorkbenchWindow(), fWin); IWorkbenchPage
// * page = openTestPage(fWin); assertEquals(page.getWorkbenchWindow(),
// * fWin);
@@ -823,17 +970,16 @@
// new String[] { "init", "createPartControl", "setFocus" }));
// assertTrue(!view.equals(view2));
//
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
-// IViewReference ref = (IViewReference) page.getReference(view);
-// IViewReference ref2 = (IViewReference) page.getReference(view2);
-// page.addFastView(ref);
-// page.addFastView(ref2);
+// IViewReference ref = (IViewReference) fActivePage.getReference(view);
+// IViewReference ref2 = (IViewReference) fActivePage.getReference(view2);
+// facade.addFastView(fActivePage, ref);
+// facade.addFastView(fActivePage, ref2);
//
-// page.activate(view);
-// assertEquals(view, page.getActivePart());
+// fActivePage.activate(view);
+// assertEquals(view, fActivePage.getActivePart());
//
-// page.activate(view2);
-// assertEquals(view2, page.getActivePart());
+// fActivePage.activate(view2);
+// assertEquals(view2, fActivePage.getActivePart());
// }
//
// /**
@@ -848,14 +994,13 @@
// MockViewPart view2 = (MockViewPart) fActivePage.showView(
// MockViewPart.IDMULT, "2", IWorkbenchPage.VIEW_ACTIVATE);
//
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
-// IViewReference ref = (IViewReference) page.getReference(view);
-// IViewReference ref2 = (IViewReference) page.getReference(view2);
-// page.addFastView(ref);
-// page.addFastView(ref2);
+// IViewReference ref = (IViewReference) fActivePage.getReference(view);
+// IViewReference ref2 = (IViewReference) fActivePage.getReference(view2);
+// facade.addFastView(fActivePage, ref);
+// facade.addFastView(fActivePage, ref2);
//
// IMemento memento = XMLMemento.createWriteRoot("page");
-// page.saveState(memento);
+// facade.saveState(fActivePage, memento);
// IMemento persps = memento.getChild("perspectives");
// IMemento persp = persps.getChildren("perspective")[0];
// IMemento[] fastViews = persp.getChild("fastViews").getChildren("view");
@@ -938,7 +1083,7 @@
// assertEquals(fActivePage.findView(viewId), null);
//
// try {
-// SaveableHelper.testSetAutomatedResponse(1); // No
+// facade.saveableHelperSetAutomatedResponse(1); // No
// view = (SaveableMockViewPart) fActivePage.showView(viewId);
// view.setDirty(true);
// fActivePage.hideView(view);
@@ -948,7 +1093,7 @@
// assertTrue(callTrace.contains("dispose"));
// assertEquals(fActivePage.findView(viewId), null);
//
-// SaveableHelper.testSetAutomatedResponse(2); // Cancel
+// facade.saveableHelperSetAutomatedResponse(2); // Cancel
// view = (SaveableMockViewPart) fActivePage.showView(viewId);
// view.setDirty(true);
// fActivePage.hideView(view);
@@ -958,7 +1103,7 @@
// assertFalse(callTrace.contains("dispose"));
// assertEquals(fActivePage.findView(viewId), view);
//
-// SaveableHelper.testSetAutomatedResponse(0); // Yes
+// facade.saveableHelperSetAutomatedResponse(0); // Yes
// view = (SaveableMockViewPart) fActivePage.showView(viewId);
// view.setDirty(true);
// fActivePage.hideView(view);
@@ -971,7 +1116,7 @@
// // don't leave the view showing, or the UI will block on window
// // close
// } finally {
-// SaveableHelper.testSetAutomatedResponse(-1); // restore default
+// facade.saveableHelperSetAutomatedResponse(-1); // restore default
// // (prompt)
// }
// }
@@ -979,7 +1124,7 @@
// /**
// * Tests that a close will fall back to the default if the view returns
// * ISaveable2.DEFAULT.
-// *
+// *
// * @throws Throwable
// */
// public void testCloseWithSaveNeeded() throws Throwable {
@@ -996,7 +1141,7 @@
// assertEquals(fActivePage.findView(UserSaveableMockViewPart.ID), null);
//
// try {
-// SaveableHelper.testSetAutomatedResponse(3); // DEFAULT
+// facade.saveableHelperSetAutomatedResponse(3); // DEFAULT
// view = (UserSaveableMockViewPart) fActivePage.showView(viewId);
// view.setDirty(true);
// view2 = (UserSaveableMockViewPart) fActivePage.showView(viewId,
@@ -1004,8 +1149,7 @@
// assertNotNull(view2);
// view2.setDirty(true);
//
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
-// page.getEditorManager().saveAll(true, false, false);
+// fActivePage.saveAllEditors(true);
//
// assertFalse(view.isDirty());
// assertFalse(view2.isDirty());
@@ -1021,8 +1165,8 @@
// // don't leave the view showing, or the UI will block on window
// // close
// } finally {
-// SaveableHelper
-// .testSetAutomatedResponse(SaveableHelper.USER_RESPONSE); // restore
+// facade
+// .saveableHelperSetAutomatedResponse(-1); // restore
// // default
// // (prompt)
// }
@@ -1031,7 +1175,7 @@
// /**
// * Tests that a close will fall back to the default if the view returns
// * ISaveable2.DEFAULT.
-// *
+// *
// * @throws Throwable
// */
// public void testSaveEffectsSharedModel() throws Throwable {
@@ -1043,7 +1187,7 @@
// assertEquals(fActivePage.findView(UserSaveableSharedViewPart.ID), null);
//
// try {
-// SaveableHelper.testSetAutomatedResponse(3); // DEFAULT
+// facade.saveableHelperSetAutomatedResponse(3); // DEFAULT
// UserSaveableSharedViewPart.SharedModel model = new UserSaveableSharedViewPart.SharedModel();
// view = (UserSaveableSharedViewPart) fActivePage.showView(viewId);
// view.setSharedModel(model);
@@ -1053,8 +1197,7 @@
// assertNotNull(view2);
// view2.setSharedModel(model);
//
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
-// page.getEditorManager().saveAll(true, false, false);
+// fActivePage.saveAllEditors(true);
//
// assertFalse(view.isDirty());
// assertFalse(view2.isDirty());
@@ -1074,8 +1217,8 @@
// // don't leave the view showing, or the UI will block on window
// // close
// } finally {
-// SaveableHelper
-// .testSetAutomatedResponse(SaveableHelper.USER_RESPONSE); // restore
+// facade
+// .saveableHelperSetAutomatedResponse(-1); // restore
// // default
// // (prompt)
// fActivePage.hideView(view);
@@ -1146,7 +1289,7 @@
// * It is possible that some action may query the isDirty value of the
// * editor to update its enabled state. There is nothing wrong in doing
// * that, so do not test for no isDirty call here.
-// *
+// *
// * assertEquals(callTrace.contains( "isDirty"), false);
// */
// assertEquals(callTrace.contains("doSave"), false);
@@ -1474,54 +1617,36 @@
//
// public void testShowActionSet() {
// String id = MockActionDelegate.ACTION_SET_ID;
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
//
-// int totalBefore = page.getActionSets().length;
+// int totalBefore = facade.getActionSetCount(fActivePage);
// fActivePage.showActionSet(id);
//
-// IActionSetDescriptor[] sets = ((WorkbenchPage) fActivePage)
-// .getActionSets();
-// boolean found = false;
-// for (int i = 0; i < sets.length; i++)
-// if (id.equals(sets[i].getId()))
-// found = true;
-// assertEquals(found, true);
+// facade.assertActionSetId(fActivePage, id, true);
//
// // check that the method does not add an invalid action set to itself
// id = IConstants.FakeID;
// fActivePage.showActionSet(id);
//
-// sets = ((WorkbenchPage) fActivePage).getActionSets();
-// found = false;
-// for (int i = 0; i < sets.length; i++)
-// if (id.equals(sets[i].getId()))
-// found = true;
-// assertEquals(found, false);
-// assertEquals(page.getActionSets().length, totalBefore + 1);
+// facade.assertActionSetId(fActivePage, id, false);
+// assertEquals(facade.getActionSetCount(fActivePage), totalBefore + 1);
// }
//
// public void testHideActionSet() {
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
-// int totalBefore = page.getActionSets().length;
+// int totalBefore = facade.getActionSetCount(fActivePage);
//
// String id = MockWorkbenchWindowActionDelegate.SET_ID;
// fActivePage.showActionSet(id);
-// assertEquals(page.getActionSets().length, totalBefore + 1);
+// assertEquals(facade.getActionSetCount(fActivePage), totalBefore + 1);
//
// fActivePage.hideActionSet(id);
-// assertEquals(page.getActionSets().length, totalBefore);
+// assertEquals(facade.getActionSetCount(fActivePage), totalBefore);
//
-// IActionSetDescriptor[] sets = page.getActionSets();
-// boolean found = false;
-// for (int i = 0; i < sets.length; i++)
-// if (id.equals(sets[i].getId()))
-// found = true;
-// assertEquals(found, false);
+// facade.assertActionSetId(fActivePage, id, false);
// }
//
// /**
// * Return whether or not the editor exists in the current page.
-// *
+// *
// * @param editor
// * @return boolean
// */
@@ -1536,7 +1661,7 @@
//
// /**
// * Return whether or not the view exists in the current page.
-// *
+// *
// * @param editor
// * @return boolean
// */
@@ -1549,140 +1674,117 @@
// return false;
// }
//
-// public void testStackOrder() {
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
-// try {
-// IViewPart part1 = page.showView(MockViewPart.ID);
-// IViewPart part2 = page.showView(MockViewPart.ID2);
-// IViewPart part3 = page.showView(MockViewPart.ID3);
-// IViewPart part4 = page.showView(MockViewPart.ID4);
-//
-// IViewPart[] stack = page.getViewStack(part1);
-// assertTrue(stack.length == 4);
-// assertTrue(stack[0] == part4);
-// assertTrue(stack[1] == part3);
-// assertTrue(stack[2] == part2);
-// assertTrue(stack[3] == part1);
-//
-// page.activate(part2);
-// stack = page.getViewStack(part1);
-// assertTrue(stack.length == 4);
-// assertTrue(stack[0] == part2);
-// assertTrue(stack[1] == part4);
-// assertTrue(stack[2] == part3);
-// assertTrue(stack[3] == part1);
-//
-// page.activate(part1);
-// stack = page.getViewStack(part1);
-// assertTrue(stack.length == 4);
-// assertTrue(stack[0] == part1);
-// assertTrue(stack[1] == part2);
-// assertTrue(stack[2] == part4);
-// assertTrue(stack[3] == part3);
-//
-// page.activate(part3);
-// stack = page.getViewStack(part1);
-// assertTrue(stack.length == 4);
-// assertTrue(stack[0] == part3);
-// assertTrue(stack[1] == part1);
-// assertTrue(stack[2] == part2);
-// assertTrue(stack[3] == part4);
-// } catch (PartInitException e) {
-// fail(e.getMessage());
-// }
+// public void testStackOrder() throws PartInitException {
+// IViewPart part1 = fActivePage.showView(MockViewPart.ID);
+// IViewPart part2 = fActivePage.showView(MockViewPart.ID2);
+// IViewPart part3 = fActivePage.showView(MockViewPart.ID3);
+// IViewPart part4 = fActivePage.showView(MockViewPart.ID4);
+//
+// IViewPart[] stack = fActivePage.getViewStack(part1);
+// assertTrue(stack.length == 4);
+// assertTrue(stack[0] == part4);
+// assertTrue(stack[1] == part3);
+// assertTrue(stack[2] == part2);
+// assertTrue(stack[3] == part1);
+//
+// fActivePage.activate(part2);
+// stack = fActivePage.getViewStack(part1);
+// assertTrue(stack.length == 4);
+// assertTrue(stack[0] == part2);
+// assertTrue(stack[1] == part4);
+// assertTrue(stack[2] == part3);
+// assertTrue(stack[3] == part1);
+//
+// fActivePage.activate(part1);
+// stack = fActivePage.getViewStack(part1);
+// assertTrue(stack.length == 4);
+// assertTrue(stack[0] == part1);
+// assertTrue(stack[1] == part2);
+// assertTrue(stack[2] == part4);
+// assertTrue(stack[3] == part3);
+//
+// fActivePage.activate(part3);
+// stack = fActivePage.getViewStack(part1);
+// assertTrue(stack.length == 4);
+// assertTrue(stack[0] == part3);
+// assertTrue(stack[1] == part1);
+// assertTrue(stack[2] == part2);
+// assertTrue(stack[3] == part4);
// }
//
// /**
// * Test the VIEW_CREATE parameter for showView. Ensures that the created
// * view is not the active part.
-// *
+// *
// */
-// public void testView_CREATE1() {
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
-// try {
-//
-// page.setPerspective(WorkbenchPlugin.getDefault()
-// .getPerspectiveRegistry().findPerspectiveWithId(
+// public void testView_CREATE1() throws PartInitException {
+// fActivePage.setPerspective(fActivePage.getWorkbenchWindow().getWorkbench()
+// .getPerspectiveRegistry().findPerspectiveWithId(
// "org.eclipse.ui.tests.api.ViewPerspective"));
//
-// // create a part to be active
-// IViewPart activePart = page.showView(MockViewPart.ID);
-// IViewPart createdPart = page.showView(MockViewPart.ID2, null,
-// IWorkbenchPage.VIEW_CREATE);
+// // create a part to be active
+// IViewPart activePart = fActivePage.showView(MockViewPart.ID);
+// IViewPart createdPart = fActivePage.showView(MockViewPart.ID2, null,
+// IWorkbenchPage.VIEW_CREATE);
//
-// IViewPart[] stack = page.getViewStack(activePart);
-// assertEquals(2, stack.length);
+// IViewPart[] stack = fActivePage.getViewStack(activePart);
+// assertEquals(2, stack.length);
//
-// assertEquals(activePart, stack[0]);
-// assertEquals(createdPart, stack[1]);
+// assertEquals(activePart, stack[0]);
+// assertEquals(createdPart, stack[1]);
//
-// assertFalse(page.isPartVisible(createdPart));
+// assertFalse(fActivePage.isPartVisible(createdPart));
//
-// assertEquals(activePart, page.getActivePart());
-// } catch (PartInitException e) {
-// fail(e.getMessage());
-// }
+// assertEquals(activePart, fActivePage.getActivePart());
// }
//
// /**
// * Test the VIEW_CREATE parameter for showView. Ensures that the created
// * view is not the active part and is not visible
// */
-// public void testView_CREATE2() {
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
-// try {
-//
-// page.setPerspective(WorkbenchPlugin.getDefault()
-// .getPerspectiveRegistry().findPerspectiveWithId(
-// "org.eclipse.ui.tests.api.ViewPerspective"));
+// public void testView_CREATE2() throws PartInitException {
+// fActivePage.setPerspective(fActivePage.getWorkbenchWindow().getWorkbench()
+// .getPerspectiveRegistry().findPerspectiveWithId(
+// "org.eclipse.ui.tests.api.ViewPerspective"));
//
-// // create a part to be active
-// IViewPart activePart = page.showView(MockViewPart.ID3);
-// IViewPart createdPart = page.showView(MockViewPart.ID2, null,
-// IWorkbenchPage.VIEW_CREATE);
+// // create a part to be active
+// IViewPart activePart = fActivePage.showView(MockViewPart.ID3);
+// IViewPart createdPart = fActivePage.showView(MockViewPart.ID2, null,
+// IWorkbenchPage.VIEW_CREATE);
//
-// IViewPart[] stack = page.getViewStack(createdPart);
-// assertEquals(2, stack.length);
+// IViewPart[] stack = fActivePage.getViewStack(createdPart);
+// assertEquals(2, stack.length);
//
-// assertEquals(page.findView(MockViewPart.ID), stack[0]);
-// assertEquals(createdPart, stack[1]);
+// assertEquals(fActivePage.findView(MockViewPart.ID), stack[0]);
+// assertEquals(createdPart, stack[1]);
//
-// assertFalse(page.isPartVisible(createdPart));
+// assertFalse(fActivePage.isPartVisible(createdPart));
//
-// assertEquals(activePart, page.getActivePart());
-// } catch (PartInitException e) {
-// fail(e.getMessage());
-// }
+// assertEquals(activePart, fActivePage.getActivePart());
// }
//
// /**
// * Test the VIEW_CREATE parameter for showView. Ensures that the created
// * view is not the active part and is visible.
// */
-// public void testView_CREATE3() {
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
-// try {
-//
-// page.setPerspective(WorkbenchPlugin.getDefault()
-// .getPerspectiveRegistry().findPerspectiveWithId(
-// "org.eclipse.ui.tests.api.ViewPerspective"));
+// public void testView_CREATE3() throws PartInitException {
+// fActivePage.setPerspective(fActivePage.getWorkbenchWindow().getWorkbench()
+// .getPerspectiveRegistry().findPerspectiveWithId(
+// "org.eclipse.ui.tests.api.ViewPerspective"));
//
-// // create a part to be active
-// IViewPart activePart = page.showView(MockViewPart.ID3);
-// IViewPart createdPart = page.showView(MockViewPart.ID4, null,
-// IWorkbenchPage.VIEW_CREATE);
+// // create a part to be active
+// IViewPart activePart = fActivePage.showView(MockViewPart.ID3);
+// IViewPart createdPart = fActivePage.showView(MockViewPart.ID4, null,
+// IWorkbenchPage.VIEW_CREATE);
//
-// IViewPart[] stack = page.getViewStack(createdPart);
-// assertEquals(1, stack.length);
+// IViewPart[] stack = fActivePage.getViewStack(createdPart);
+// assertEquals(1, stack.length);
//
-// assertEquals(createdPart, stack[0]);
+// assertEquals(createdPart, stack[0]);
//
-// assertTrue(page.isPartVisible(createdPart));
+// assertTrue(fActivePage.isPartVisible(createdPart));
//
-// assertEquals(activePart, page.getActivePart());
-// } catch (PartInitException e) {
-// fail(e.getMessage());
-// }
+// assertEquals(activePart, fActivePage.getActivePart());
// }
//
// /**
@@ -1690,29 +1792,24 @@
// * stack containing the active view. Ensures that the created view is not
// * the active part and is not visible.
// */
-// public void testView_VISIBLE1() {
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
-// try {
-// page.setPerspective(WorkbenchPlugin.getDefault()
-// .getPerspectiveRegistry().findPerspectiveWithId(
-// "org.eclipse.ui.tests.api.ViewPerspective"));
+// public void testView_VISIBLE1() throws PartInitException {
+// fActivePage.setPerspective(fActivePage.getWorkbenchWindow().getWorkbench()
+// .getPerspectiveRegistry().findPerspectiveWithId(
+// "org.eclipse.ui.tests.api.ViewPerspective"));
//
-// // create a part to be active
-// IViewPart activePart = page.showView(MockViewPart.ID);
-// IViewPart createdPart = page.showView(MockViewPart.ID2, null,
-// IWorkbenchPage.VIEW_VISIBLE);
-// IViewPart[] stack = page.getViewStack(activePart);
-// assertEquals(2, stack.length);
+// // create a part to be active
+// IViewPart activePart = fActivePage.showView(MockViewPart.ID);
+// IViewPart createdPart = fActivePage.showView(MockViewPart.ID2, null,
+// IWorkbenchPage.VIEW_VISIBLE);
+// IViewPart[] stack = fActivePage.getViewStack(activePart);
+// assertEquals(2, stack.length);
//
-// assertEquals(activePart, stack[0]);
-// assertEquals(createdPart, stack[1]);
+// assertEquals(activePart, stack[0]);
+// assertEquals(createdPart, stack[1]);
//
-// assertFalse(page.isPartVisible(createdPart));
+// assertFalse(fActivePage.isPartVisible(createdPart));
//
-// assertEquals(activePart, page.getActivePart());
-// } catch (PartInitException e) {
-// fail(e.getMessage());
-// }
+// assertEquals(activePart, fActivePage.getActivePart());
// }
//
// /**
@@ -1720,36 +1817,30 @@
// * stack. Ensures that the created view is not active part but is the top
// * part in its stack.
// */
-// public void testView_VISIBLE3() {
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
-// try {
-// page.setPerspective(WorkbenchPlugin.getDefault()
+// public void testView_VISIBLE3() throws PartInitException {
+// fActivePage.setPerspective(fActivePage.getWorkbenchWindow().getWorkbench()
// .getPerspectiveRegistry().findPerspectiveWithId(
// "org.eclipse.ui.tests.api.ViewPerspective"));
//
-// // create a part to be active
-// IViewPart activePart = page.showView(MockViewPart.ID3);
+// // create a part to be active
+// IViewPart activePart = fActivePage.showView(MockViewPart.ID3);
//
-// IViewPart createdPart = page.showView(MockViewPart.ID4, null,
-// IWorkbenchPage.VIEW_VISIBLE);
-// IViewPart[] stack = page.getViewStack(createdPart);
-// assertEquals(1, stack.length);
+// IViewPart createdPart = fActivePage.showView(MockViewPart.ID4, null,
+// IWorkbenchPage.VIEW_VISIBLE);
+// IViewPart[] stack = fActivePage.getViewStack(createdPart);
+// assertEquals(1, stack.length);
//
-// assertEquals(createdPart, stack[0]);
+// assertEquals(createdPart, stack[0]);
//
-// assertTrue(page.isPartVisible(createdPart));
+// assertTrue(fActivePage.isPartVisible(createdPart));
//
-// assertEquals(activePart, page.getActivePart());
-// } catch (PartInitException e) {
-// fail(e.getMessage());
-// }
+// assertEquals(activePart, fActivePage.getActivePart());
// }
//
// /**
// * Test opening a perspective with a fast view.
// */
// public void testOpenPerspectiveWithFastView() {
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
//
// try {
// fWin.getWorkbench().showPerspective(
@@ -1758,22 +1849,23 @@
// fail("Unexpected WorkbenchException: " + e);
// }
//
-// assertEquals(page.getFastViews().length, 1);
-// assertEquals(page.getFastViews()[0].getId(),
+// IViewReference[] fastViews = facade.getFastViews(fActivePage);
+// assertEquals(fastViews.length, 1);
+// assertEquals(fastViews[0].getId(),
// "org.eclipse.ui.views.ResourceNavigator");
-// assertEquals(page.getViewReferences().length, 1);
-// assertTrue(page.getViewReferences()[0].isFastView());
-//
-// IPerspectiveDescriptor persp = page.getPerspective();
-//
+// assertEquals(fActivePage.getViewReferences().length, 1);
+// assertTrue(fActivePage.getViewReferences()[0].isFastView());
+//
+// IPerspectiveDescriptor persp = fActivePage.getPerspective();
+//
// ICommandService commandService = (ICommandService) fWorkbench.getService(ICommandService.class);
// Command command = commandService.getCommand("org.eclipse.ui.window.closePerspective");
-//
+//
// HashMap parameters = new HashMap();
-// parameters.put("org.eclipse.ui.window.closePerspective.perspectiveId", persp.getId());
-//
+// parameters.put(IWorkbenchCommandConstants.WINDOW_CLOSE_PERSPECTIVE_PARM_ID, persp.getId());
+//
// ParameterizedCommand pCommand = ParameterizedCommand.generateCommand(command, parameters);
-//
+//
// IHandlerService handlerService = (IHandlerService) fWorkbench
// .getService(IHandlerService.class);
// try {
@@ -1789,11 +1881,10 @@
// /**
// * Test opening a perspective with placeholders for multi instance views.
// * The placeholders are added at top level (not in any folder).
-// *
+// *
// * @since 3.1
// */
// public void testOpenPerspectiveWithMultiViewPlaceholdersAtTopLevel() {
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
//
// try {
// fWin.getWorkbench().showPerspective(
@@ -1803,8 +1894,7 @@
// fail("Unexpected WorkbenchException: " + e);
// }
//
-// PerspectiveState state = new PerspectiveState(page);
-// ArrayList partIds = state.getPartIds(null);
+// ArrayList partIds = facade.getPerspectivePartIds(fActivePage, null);
// assertTrue(partIds.contains("*"));
// assertTrue(partIds.contains(MockViewPart.IDMULT));
// assertTrue(partIds.contains(MockViewPart.IDMULT + ":secondaryId"));
@@ -1816,11 +1906,10 @@
// * The placeholders are added in a placeholder folder. This is a regression
// * test for bug 72383 [Perspectives] Placeholder folder error with multiple
// * instance views
-// *
+// *
// * @since 3.1
// */
// public void testOpenPerspectiveWithMultiViewPlaceholdersInPlaceholderFolder() {
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
//
// try {
// fWin
@@ -1832,8 +1921,7 @@
// fail("Unexpected WorkbenchException: " + e);
// }
//
-// PerspectiveState state = new PerspectiveState(page);
-// ArrayList partIds = state.getPartIds("placeholderFolder");
+// ArrayList partIds = facade.getPerspectivePartIds(fActivePage,"placeholderFolder");
// assertTrue(partIds.contains("*"));
// assertTrue(partIds.contains(MockViewPart.IDMULT));
// assertTrue(partIds.contains(MockViewPart.IDMULT + ":secondaryId"));
@@ -1843,12 +1931,10 @@
// /**
// * Test opening a perspective with placeholders for multi instance views.
// * The placeholders are added at top level (not in any folder).
-// *
+// *
// * @since 3.1
// */
// public void testOpenPerspectiveWithMultiViewPlaceholdersInFolder() {
-// WorkbenchPage page = (WorkbenchPage) fActivePage;
-//
// try {
// fWin
// .getWorkbench()
@@ -1859,8 +1945,7 @@
// fail("Unexpected WorkbenchException: " + e);
// }
//
-// PerspectiveState state = new PerspectiveState(page);
-// ArrayList partIds = state.getPartIds("folder");
+// ArrayList partIds = facade.getPerspectivePartIds(fActivePage,"folder");
// assertTrue(partIds.contains("*"));
// assertTrue(partIds.contains(MockViewPart.IDMULT));
// assertTrue(partIds.contains(MockViewPart.IDMULT + ":secondaryId"));
@@ -1869,7 +1954,7 @@
//
// /**
// * Tests the getNewWizardShortcuts() method.
-// *
+// *
// * @since 3.1
// */
// public void testGetNewWizardShortcuts() {
@@ -1887,7 +1972,7 @@
//
// /**
// * Tests the getShowViewShortcuts() method.
-// *
+// *
// * @since 3.1
// */
// public void testGetShowViewShortcuts() {
@@ -1899,7 +1984,7 @@
// IWorkbenchPage page = win.getActivePage();
// shortcuts = page.getShowViewShortcuts();
// List shortcutList = Arrays.asList(shortcuts);
-// assertTrue(shortcutList.contains(IPageLayout.ID_RES_NAV));
+// assertTrue(shortcutList.contains(ProjectExplorer.VIEW_ID));
// assertTrue(shortcutList.contains(IPageLayout.ID_OUTLINE));
// assertTrue(shortcutList.contains(IPageLayout.ID_PROP_SHEET));
// assertTrue(shortcutList.contains(IPageLayout.ID_PROBLEM_VIEW));
@@ -1907,7 +1992,7 @@
//
// /**
// * Tests the getPerspectiveShortcuts() method.
-// *
+// *
// * @since 3.1
// */
// public void testGetPerspectiveShortcuts() {
@@ -1919,7 +2004,7 @@
//
// /**
// * Tests the getOpenPerspectives() method.
-// *
+// *
// * @since 3.1
// */
// public void testGetOpenPerspectives() {
@@ -1955,7 +2040,7 @@
//
// /**
// * Tests the getSortedPerspectives() method.
-// *
+// *
// * @since 3.1
// */
// public void testGetSortedPerspectives() {
@@ -1992,7 +2077,7 @@
//
// /**
// * Tests the closePerspective method.
-// *
+// *
// * @since 3.1
// */
// public void testClosePerspective() {
@@ -2028,9 +2113,81 @@
// assertNull(fWin.getActivePage()); // page closed
// }
//
+// /**
+// * This tests that closing a perspective will not bring a prompt up for
+// * {@link org.eclipse.ui.ISaveablePart ISaveablePart} implementations that
+// * are returning false for their
+// * {@link org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded()
+// * isSaveOnCloseNeeded()} implementation.
+// *
+// * @see #testCloseAllPerspectivesDoesNotPromptBug272070()
+// */
+// public void testClosePerspectiveDoesNotPromptBug272070() throws Exception {
+// try {
+// facade.saveableHelperSetAutomatedResponse(2);
+// proj = FileUtil
+// .createProject("testClosePerspectiveDoesNotPromptBug272070");
+//
+// IPerspectiveRegistry reg = fWorkbench.getPerspectiveRegistry();
+// IPerspectiveDescriptor resourcePersp = reg
+// .findPerspectiveWithId(IDE.RESOURCE_PERSPECTIVE_ID);
+//
+// // close all perspectives so we start fresh
+// fActivePage.closeAllPerspectives(false, false);
+// // set the page to the 'Resource' perspective
+// fActivePage.setPerspective(resourcePersp);
+//
+// // create a file and show an editor
+// IEditorInput input = new FileEditorInput(FileUtil.createFile(
+// "test.mock1", proj));
+// MockEditorPart editor = (MockEditorPart) fActivePage.openEditor(
+// input, MockEditorPart.ID1);
+//
+// // mark the editor as being dirty but not requiring saving when
+// // closed
+// editor.setDirty(true);
+// editor.setSaveNeeded(false);
+//
+// // close the perspective
+// fActivePage.closePerspective(resourcePersp, true, false);
+// // mark the editor as not dirty, this is important because if the
+// // editor is not closed, the test will fail and when JUnit tries to
+// // tear down the workbench it will not shutdown because it will
+// // prompt about the editor being dirty
+// editor.setDirty(false);
+// // the editor should have been closed when the perspective was
+// // closed
+// assertFalse("The editor should've been closed", fActivePage
+// .isPartVisible(editor));
+//
+// // set the page to the 'Resource' perspective
+// fActivePage.setPerspective(resourcePersp);
+//
+// // show a view
+// SaveableMockViewPart view = (SaveableMockViewPart) fActivePage
+// .showView(SaveableMockViewPart.ID);
+//
+// // mark the view as being dirty but not requiring saving when closed
+// view.setDirty(true);
+// view.setSaveNeeded(false);
+//
+// // close the perspective
+// fActivePage.closePerspective(resourcePersp, true, false);
+// // like the editor above, we need to mark the view as not being
+// // dirty for the same reasons
+// view.setDirty(false);
+// // the view should have been hidden when the perspective was closed
+// assertFalse("The view should be hidden", fActivePage
+// .isPartVisible(view));
+// } finally {
+// facade
+// .saveableHelperSetAutomatedResponse(-1);
+// }
+// }
+//
// /**
// * Tests the closeAllPerspectives method.
-// *
+// *
// * @since 3.1
// */
// public void testCloseAllPerspectives() {
@@ -2061,6 +2218,79 @@
// assertNull(fWin.getActivePage()); // page closed
// }
//
+// /**
+// * This tests that closing all perspectives will not bring a prompt up for
+// * {@link org.eclipse.ui.ISaveablePart ISaveablePart} implementations that
+// * are returning false for their
+// * {@link org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded()
+// * isSaveOnCloseNeeded()} implementation.
+// *
+// * @see #testClosePerspectiveDoesNotPromptBug272070()
+// */
+// public void testCloseAllPerspectivesDoesNotPromptBug272070()
+// throws Exception {
+// try {
+// facade.saveableHelperSetAutomatedResponse(2);
+// proj = FileUtil
+// .createProject("testCloseAllPerspectivesDoesNotPromptBug272070");
+//
+// IPerspectiveRegistry reg = fWorkbench.getPerspectiveRegistry();
+// IPerspectiveDescriptor resourcePersp = reg
+// .findPerspectiveWithId(IDE.RESOURCE_PERSPECTIVE_ID);
+//
+// // close all perspectives so we start fresh
+// fActivePage.closeAllPerspectives(false, false);
+// // set the page to the 'Resource' perspective
+// fActivePage.setPerspective(resourcePersp);
+//
+// // create a file and show an editor
+// IEditorInput input = new FileEditorInput(FileUtil.createFile(
+// "test.mock1", proj));
+// MockEditorPart editor = (MockEditorPart) fActivePage.openEditor(
+// input, MockEditorPart.ID1);
+//
+// // mark the editor as being dirty but not requiring saving when
+// // closed
+// editor.setDirty(true);
+// editor.setSaveNeeded(false);
+//
+// // close all perspectives
+// fActivePage.closeAllPerspectives(true, false);
+// // mark the editor as not dirty, this is important because if the
+// // editor is not closed, the test will fail and when JUnit tries to
+// // tear down the workbench it will not shutdown because it will
+// // prompt about the editor being dirty
+// editor.setDirty(false);
+// // the editor should have been closed when the perspective was
+// // closed
+// assertFalse("The editor should've been closed", fActivePage
+// .isPartVisible(editor));
+//
+// // set the page to the 'Resource' perspective
+// fActivePage.setPerspective(resourcePersp);
+//
+// // show a view
+// SaveableMockViewPart view = (SaveableMockViewPart) fActivePage
+// .showView(SaveableMockViewPart.ID);
+//
+// // mark the view as being dirty but not requiring saving when closed
+// view.setDirty(true);
+// view.setSaveNeeded(false);
+//
+// // close all perspectives
+// fActivePage.closeAllPerspectives(true, false);
+// // like the editor above, we need to mark the view as not being
+// // dirty for the same reasons
+// view.setDirty(false);
+// // the view should have been hidden when the perspective was closed
+// assertFalse("The view should be hidden", fActivePage
+// .isPartVisible(view));
+// } finally {
+// facade
+// .saveableHelperSetAutomatedResponse(-1);
+// }
+// }
+//
// /**
// * Regression test for Bug 76285 [Presentations] Folder tab does not
// * indicate current view. Tests that, when switching between perspectives,
@@ -2099,7 +2329,7 @@
// * Tests that IShowEditorInput.showEditorInput is called when a matching
// * editor is found during openEditor, and is not called when a new editor is
// * opened.
-// *
+// *
// * @since 3.1
// */
// public void testShowEditorInput() throws Exception {
@@ -2117,7 +2347,7 @@
// /**
// * Tests that the openEditor and findEditor variants that accepts match
// * flags work as expected.
-// *
+// *
// * @since 3.2
// */
// public void testOpenAndFindEditorWithMatchFlags() throws Exception {
@@ -2223,4 +2453,553 @@
// assertEquals(1, refs.length);
// assertEquals(part4, refs[0].getPart(true));
// }
+//
+//
+// /**
+// * Create and hide a single editor, and check it is reflected in the
+// * editor references. Check that close still works.
+// *
+// * @throws Exception
+// */
+// public void testOpenAndHideEditor1() throws Exception {
+// proj = FileUtil.createProject("testOpenAndHideEditor");
+// IFile file1 = FileUtil.createFile("a.mock1", proj);
+// IEditorPart editor = IDE.openEditor(fActivePage, file1);
+// assertTrue(editor instanceof MockEditorPart);
+// IEditorReference editorRef = (IEditorReference) fActivePage
+// .getReference(editor);
+// fActivePage.hideEditor(editorRef);
+// assertEquals(0, fActivePage.getEditorReferences().length);
+// fActivePage.showEditor(editorRef);
+// assertEquals(1, fActivePage.getEditorReferences().length);
+// fActivePage.closeAllEditors(true);
+// assertEquals(0, fActivePage.getEditorReferences().length);
+// assertEquals(getMessage(), 0, logCount);
+// }
+//
+// /**
+// * Create and remove 2 editors. Check that the removed editor
+// * is not returned in the list of references. Check that
+// * close still works.
+// *
+// * @throws Exception
+// */
+// public void testOpenAndHideEditor2() throws Exception {
+// proj = FileUtil.createProject("testOpenAndHideEditor");
+// IFile file1 = FileUtil.createFile("a.mock1", proj);
+// IFile file2 = FileUtil.createFile("a.mock2", proj);
+// IEditorPart editor = IDE.openEditor(fActivePage, file1);
+// assertTrue(editor instanceof MockEditorPart);
+// IEditorReference editorRef = (IEditorReference) fActivePage
+// .getReference(editor);
+// IEditorPart editor2 = IDE.openEditor(fActivePage, file2);
+// assertTrue(editor2 instanceof MockEditorPart);
+// IEditorReference editorRef2 = (IEditorReference) fActivePage.getReference(editor2);
+//
+// fActivePage.hideEditor(editorRef);
+// IEditorReference[] refs = fActivePage.getEditorReferences();
+// assertEquals(1, refs.length);
+// assertEquals(editorRef2, refs[0]);
+// fActivePage.showEditor(editorRef);
+// refs = fActivePage.getEditorReferences();
+// assertEquals(2, refs.length);
+//
+// fActivePage.hideEditor(editorRef2);
+// refs = fActivePage.getEditorReferences();
+// assertEquals(1, refs.length);
+// fActivePage.hideEditor(editorRef);
+// refs = fActivePage.getEditorReferences();
+// assertEquals(0, refs.length);
+// fActivePage.showEditor(editorRef);
+// refs = fActivePage.getEditorReferences();
+// assertEquals(editorRef, refs[0]);
+// fActivePage.showEditor(editorRef2);
+// refs = fActivePage.getEditorReferences();
+// assertEquals(2, refs.length);
+//
+// fActivePage.closeAllEditors(true);
+// refs = fActivePage.getEditorReferences();
+// assertEquals(0, refs.length);
+// assertEquals(getMessage(), 0, logCount);
+// }
+//
+// /**
+// * Create 2 editors and hide one. When added back and then closed, there
+// * should only be one editor. Adding back the closed editor should
+// * generate a log message and not effect the list of editors.
+// *
+// * @throws Exception
+// */
+// public void testOpenAndHideEditor3() throws Exception {
+// proj = FileUtil.createProject("testOpenAndHideEditor");
+// IFile file1 = FileUtil.createFile("a.mock1", proj);
+// IFile file2 = FileUtil.createFile("a.mock2", proj);
+// IEditorPart editor = IDE.openEditor(fActivePage, file1);
+// assertTrue(editor instanceof MockEditorPart);
+// IEditorReference editorRef = (IEditorReference) fActivePage
+// .getReference(editor);
+// IEditorPart editor2 = IDE.openEditor(fActivePage, file2);
+// assertTrue(editor2 instanceof MockEditorPart);
+// IEditorReference editorRef2 = (IEditorReference) fActivePage.getReference(editor2);
+//
+// fActivePage.hideEditor(editorRef2);
+// IEditorReference[] refs = fActivePage.getEditorReferences();
+// assertEquals(1, refs.length);
+// assertEquals(editorRef, refs[0]);
+// fActivePage.showEditor(editorRef2);
+// fActivePage.closeEditors(new IEditorReference[] { editorRef2 }, true);
+// refs = fActivePage.getEditorReferences();
+// assertEquals(1, refs.length);
+// fActivePage.showEditor(editorRef2);
+// assertEquals(1, refs.length);
+// assertEquals(getMessage(), 1, logCount);
+// assertNotNull(getMessage());
+// assertTrue(getMessage().startsWith("adding a disposed part"));
+// }
+//
+// /**
+// * Create 2 editors, and remove and show one of them. Trying to
+// * add it a second time should not effect the list of editor references.
+// *
+// * @throws Exception
+// */
+// public void testOpenAndHideEditor4() throws Exception {
+// proj = FileUtil.createProject("testOpenAndHideEditor");
+// IFile file1 = FileUtil.createFile("a.mock1", proj);
+// IFile file2 = FileUtil.createFile("a.mock2", proj);
+// IEditorPart editor = IDE.openEditor(fActivePage, file1);
+// assertTrue(editor instanceof MockEditorPart);
+// IEditorReference editorRef = (IEditorReference) fActivePage
+// .getReference(editor);
+// IEditorPart editor2 = IDE.openEditor(fActivePage, file2);
+// assertTrue(editor2 instanceof MockEditorPart);
+// IEditorReference editorRef2 = (IEditorReference) fActivePage.getReference(editor2);
+//
+// fActivePage.hideEditor(editorRef2);
+// IEditorReference[] refs = fActivePage.getEditorReferences();
+// assertEquals(1, refs.length);
+// assertEquals(editorRef, refs[0]);
+// fActivePage.showEditor(editorRef2);
+// refs = fActivePage.getEditorReferences();
+// assertEquals(2, refs.length);
+// fActivePage.showEditor(editorRef2);
+// refs = fActivePage.getEditorReferences();
+// assertEquals(2, refs.length);
+// assertEquals(getMessage(), 0, logCount);
+// }
+//
+// /**
+// * Create 2 editors that effect the Content Outline view. Make
+// * sure that hiding and showing the active editor effects the
+// * outline view.
+// *
+// * @throws Exception
+// */
+// public void testOpenAndHideEditor5() throws Exception {
+// proj = FileUtil.createProject("testOpenAndHideEditor");
+// IFile file1 = FileUtil.createFile("a1.java", proj);
+// IFile file2 = FileUtil.createFile("a2.java", proj);
+// IEditorPart editor = IDE.openEditor(fActivePage, file1);
+// assertTrue(editor.getClass().getName().endsWith("CompilationUnitEditor"));
+// IEditorReference editorRef = (IEditorReference) fActivePage
+// .getReference(editor);
+// IEditorPart editor2 = IDE.openEditor(fActivePage, file2);
+// assertTrue(editor2.getClass().getName().endsWith("CompilationUnitEditor"));
+//
+// ContentOutline outline = (ContentOutline) fActivePage.showView(IPageLayout.ID_OUTLINE);
+// IPage page2 = outline.getCurrentPage();
+// fActivePage.activate(editor);
+// processEvents();
+// IPage page = outline.getCurrentPage();
+// assertFalse(page2==page);
+//
+// assertEquals(getMessage(), 0, logCount);
+//
+// fActivePage.hideEditor(editorRef);
+// assertEquals(page2, outline.getCurrentPage());
+// assertEquals(getMessage(), 0, logCount);
+//
+// fActivePage.showEditor(editorRef);
+// assertEquals(page2, outline.getCurrentPage());
+// assertEquals(getMessage(), 0, logCount);
+//
+// fActivePage.activate(editor);
+// assertEquals(page, outline.getCurrentPage());
+// assertEquals(getMessage(), 0, logCount);
+// }
+//
+// /**
+// * Create one editor. Make sure hiding and showing it effects
+// * the outline view, and that when hidden the outline view
+// * reflects the default page.
+// *
+// * @throws Exception
+// */
+// public void testOpenAndHideEditor6() throws Exception {
+// proj = FileUtil.createProject("testOpenAndHideEditor");
+// IFile file1 = FileUtil.createFile("a1.java", proj);
+// IEditorPart editor = IDE.openEditor(fActivePage, file1);
+// assertTrue(editor.getClass().getName().endsWith("CompilationUnitEditor"));
+// IEditorReference editorRef = (IEditorReference) fActivePage
+// .getReference(editor);
+//
+// ContentOutline outline = (ContentOutline) fActivePage.showView(IPageLayout.ID_OUTLINE);
+// IPage defaultPage = outline.getDefaultPage();
+// assertNotNull(defaultPage);
+//
+// processEvents();
+// IPage page = outline.getCurrentPage();
+// assertFalse(defaultPage==page);
+//
+// assertEquals(getMessage(), 0, logCount);
+// assertEquals(0, partHiddenCount);
+// fActivePage.addPartListener(partListener2);
+// fActivePage.hideEditor(editorRef);
+// processEvents();
+//
+// assertEquals(1, partHiddenCount);
+// assertEquals(editorRef, partHiddenRef);
+//
+// assertEquals(defaultPage, outline.getCurrentPage());
+// //assertEquals(page, outline.getCurrentPage());
+// assertEquals(getMessage(), 0, logCount);
+//
+// assertEquals(0, partVisibleCount);
+// fActivePage.showEditor(editorRef);
+// processEvents();
+// assertEquals(page, outline.getCurrentPage());
+// assertEquals(getMessage(), 0, logCount);
+// assertEquals(1, partVisibleCount);
+// assertEquals(editorRef, partVisibleRef);
+//
+// fActivePage.activate(editor);
+// assertEquals(page, outline.getCurrentPage());
+// assertEquals(getMessage(), 0, logCount);
+// }
+//
+// /**
+// * Create one editor. Make sure hiding the editor updates
+// * the window title.
+// *
+// * @throws Exception
+// */
+// public void testOpenAndHideEditor7() throws Exception {
+// proj = FileUtil.createProject("testOpenAndHideEditor");
+// IFile file1 = FileUtil.createFile("a1.java", proj);
+// IEditorPart editor = IDE.openEditor(fActivePage, file1);
+// assertTrue(editor.getClass().getName().endsWith("CompilationUnitEditor"));
+// IEditorReference editorRef = (IEditorReference) fActivePage
+// .getReference(editor);
+//
+// processEvents();
+//
+// String firstTitle = fWin.getShell().getText();
+//
+// assertEquals(getMessage(), 0, logCount);
+// assertEquals(0, partHiddenCount);
+// fActivePage.addPartListener(partListener2);
+// fActivePage.hideEditor(editorRef);
+// processEvents();
+//
+// assertEquals(1, partHiddenCount);
+// assertEquals(editorRef, partHiddenRef);
+//
+// String nextTitle = fWin.getShell().getText();
+// String tooltip = editor.getTitleToolTip();
+// assertNotNull(tooltip);
+// String[] split = Util.split(nextTitle, '-');
+// assertEquals(2, split.length);
+// String nextTitleRebuilt = split[0] + "- " + tooltip + " -" + split[1];
+// assertEquals(firstTitle, nextTitleRebuilt);
+//
+// assertEquals(0, partVisibleCount);
+// fActivePage.showEditor(editorRef);
+// processEvents();
+// assertEquals(getMessage(), 0, logCount);
+// assertEquals(1, partVisibleCount);
+// assertEquals(editorRef, partVisibleRef);
+// nextTitle = fWin.getShell().getText();
+// assertEquals(firstTitle, nextTitle);
+//
+// fActivePage.activate(editor);
+// assertEquals(getMessage(), 0, logCount);
+// }
+//
+// /**
+// * Create one editor. Make sure hiding the editor that is the active part
+// * causes another part to become active.
+// *
+// * @throws Exception
+// */
+// public void testOpenAndHideEditor8() throws Exception {
+// proj = FileUtil.createProject("testOpenAndHideEditor");
+// IFile file1 = FileUtil.createFile("a1.java", proj);
+// IEditorPart editor = IDE.openEditor(fActivePage, file1);
+// assertTrue(editor.getClass().getName().endsWith("CompilationUnitEditor"));
+// IEditorReference editorRef = (IEditorReference) fActivePage
+// .getReference(editor);
+//
+// ContentOutline outline = (ContentOutline) fActivePage.showView(IPageLayout.ID_OUTLINE);
+// IPage defaultPage = outline.getDefaultPage();
+// assertNotNull(defaultPage);
+// fActivePage.activate(editor);
+//
+// processEvents();
+// IPage page = outline.getCurrentPage();
+// assertFalse(defaultPage==page);
+//
+// partActiveCount = 0;
+// partActiveRef = null;
+// assertEquals(getMessage(), 0, logCount);
+// assertEquals(0, partHiddenCount);
+// fActivePage.addPartListener(partListener2);
+// fActivePage.hideEditor(editorRef);
+// processEvents();
+//
+// assertEquals(1, partHiddenCount);
+// assertEquals(editorRef, partHiddenRef);
+// assertEquals(1, partActiveCount);
+// assertFalse(partActiveRef == editorRef);
+//
+// fActivePage.showEditor(editorRef);
+//
+// assertEquals(getMessage(), 0, logCount);
+// }
+//
+// /**
+// * Create a java editor. Make a change. Validate the enabled state
+// * of some commands.
+// *
+// * @throws Exception
+// */
+// public void testOpenAndHideEditor9() throws Exception {
+// proj = FileUtil.createProject("testOpenAndHideEditor");
+// IFile file1 = FileUtil.createFile("a1.java", proj);
+// IEditorPart editor = IDE.openEditor(fActivePage, file1);
+// assertTrue(editor.getClass().getName()
+// .endsWith("CompilationUnitEditor"));
+// IEditorReference editorRef = (IEditorReference) fActivePage
+// .getReference(editor);
+//
+// fActivePage.activate(editor);
+//
+// processEvents();
+// ICommandService cs = (ICommandService) fActivePage.getWorkbenchWindow()
+// .getService(ICommandService.class);
+// Command undo = cs.getCommand("org.eclipse.ui.edit.undo");
+// assertTrue(undo.isDefined());
+//
+// assertFalse(undo.isEnabled());
+//
+// ITextEditor textEditor = (ITextEditor) editor;
+// IDocument doc = textEditor.getDocumentProvider().getDocument(
+// textEditor.getEditorInput());
+// doc.replace(0, 1, " ");
+// fActivePage.saveEditor(editor, false);
+//
+// processEvents();
+// assertTrue(undo.isEnabled());
+//
+// assertEquals(getMessage(), 0, logCount);
+// fActivePage.hideEditor(editorRef);
+// processEvents();
+//
+// assertFalse(undo.isEnabled());
+//
+// fActivePage.showEditor(editorRef);
+//
+// assertTrue(undo.isEnabled());
+//
+// assertEquals(getMessage(), 0, logCount);
+// }
+//
+// /**
+// * Create and hide a single editor, and check it is reflected in the
+// * editor references. Check that closing the hidden editor still works.
+// *
+// * @throws Exception
+// */
+// public void testOpenAndHideEditor10() throws Exception {
+// proj = FileUtil.createProject("testOpenAndHideEditor");
+// IFile file1 = FileUtil.createFile("a.mock1", proj);
+// IEditorPart editor = IDE.openEditor(fActivePage, file1);
+// assertTrue(editor instanceof MockEditorPart);
+// IEditorReference editorRef = (IEditorReference) fActivePage
+// .getReference(editor);
+// fActivePage.hideEditor(editorRef);
+// assertEquals(0, fActivePage.getEditorReferences().length);
+// fActivePage.showEditor(editorRef);
+// assertEquals(1, fActivePage.getEditorReferences().length);
+// fActivePage.hideEditor(editorRef);
+// processEvents();
+// fActivePage.closeAllEditors(false);
+// assertEquals(getMessage(), 0, logCount);
+// assertEquals(0, fActivePage.getEditorReferences().length);
+// }
+//
+// /**
+// * Test opening multiple editors for an edge case: one input.
+// *
+// * openEditors(IWorkbenchPage page, IFile[] inputs)
+// */
+// public void testOpenEditors1() throws Throwable {
+// proj = FileUtil.createProject("testOpenEditors");
+// IFile[] inputs = new IFile[1];
+// String fileName0 = "test0.txt";
+// inputs[0] = FileUtil.createFile(fileName0, proj);
+//
+// // Check: editor references are returned for each file
+// IEditorReference[] refs = IDE.openEditors(fActivePage, inputs);
+// assertNotNull(refs);
+// assertEquals(1, refs.length);
+// assertNotNull(refs[0]);
+//
+// // Check: the editor is materialized
+// IEditorPart editor0 = refs[0].getEditor(false);
+// assertNotNull(editor0);
+//
+// // Check: the first file corresponds to the active editor
+// assertEquals(fActivePage.getActiveEditor(), editor0);
+//
+// // Check: created editor match its input
+// assertEquals(editor0.getSite().getId(), fWorkbench.getEditorRegistry()
+// .getDefaultEditor(inputs[0].getName()).getId());
+//
+// // Check: reference's title matches the file name
+// assertEquals(fileName0, refs[0].getTitle());
+// }
+//
+// /**
+// * Test opening multiple editors for three inputs. Only first editor
+// * should be materialized; it also should be the active editor.
+// *
+// * openEditors(IWorkbenchPage page, IFile[] inputs)
+// */
+// public void testOpenEditors3() throws Throwable {
+// proj = FileUtil.createProject("testOpenEditors");
+// IFile[] inputs = new IFile[3];
+// String fileName1 = "test1.txt";
+// String fileName2 = "test2.txt";
+// String fileName3 = "test3.txt";
+// inputs[0] = FileUtil.createFile(fileName1, proj);
+// inputs[1] = FileUtil.createFile(fileName2, proj);
+// inputs[2] = FileUtil.createFile(fileName3, proj);
+//
+// // Check: editor references are returned for each file
+// IEditorReference[] refs = IDE.openEditors(fActivePage, inputs);
+// assertNotNull(refs);
+// assertEquals(3, refs.length);
+// assertNotNull(refs[0]);
+// assertNotNull(refs[1]);
+// assertNotNull(refs[2]);
+//
+// // Check: the first file got an editor materialized, rest of the files did not
+// IEditorPart editor0 = refs[0].getEditor(false);
+// assertNotNull(editor0);
+// assertNull(refs[1].getEditor(false));
+// assertNull(refs[2].getEditor(false));
+//
+// // Check: the first file corresponds to the active editor
+// assertEquals(fActivePage.getActiveEditor(), editor0);
+//
+// // Check: created editors match their inputs
+// assertEquals(editor0.getSite().getId(), fWorkbench.getEditorRegistry()
+// .getDefaultEditor(inputs[0].getName()).getId());
+//
+// // Check: rest of the editors can be materialized
+// IEditorPart editor1 = refs[1].getEditor(true);
+// assertNotNull(editor1);
+//
+// // Check: those editors match their inputs too
+// assertEquals(editor1.getSite().getId(), fWorkbench.getEditorRegistry()
+// .getDefaultEditor(inputs[1].getName()).getId());
+//
+// // Check: reference's title matches the file name
+// assertEquals(fileName1, refs[0].getTitle());
+// assertEquals(fileName2, refs[1].getTitle());
+// assertEquals(fileName3, refs[2].getTitle());
+// }
+//
+// /**
+// * Test editor reuse when opening multiple editors. The internal editors
+// * with matching {id, input} should be reused.
+// *
+// * openEditors(IWorkbenchPage page, IFile[] inputs)
+// */
+// public void testOpenEditorsReuse() throws Throwable {
+// proj = FileUtil.createProject("testOpenEditors");
+//
+// String fileName1 = "test1.txt";
+// String fileName2 = "test2.txt";
+// String fileName3 = "test3.txt";
+// int flag = IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID; // use both matches
+//
+// // open three files
+// IFile[] inputs = new IFile[3];
+// inputs[0] = FileUtil.createFile(fileName1, proj);
+// inputs[1] = FileUtil.createFile(fileName2, proj);
+// inputs[2] = FileUtil.createFile(fileName3, proj);
+// IEditorReference[] refs = IDE.openEditors(fActivePage, inputs);
+//
+// // open two of the same files in mixed order, 1st (materialized) and 3rd (not materialized)
+// String editorID = fWorkbench.getEditorRegistry().getDefaultEditor(inputs[0].getName()).getId();
+// IEditorInput[] inputs2 = new IEditorInput[] {
+// new FileEditorInput(inputs[1]),
+// new FileEditorInput(inputs[0]) };
+// String[] editorIDs2 = new String [] { editorID, editorID} ;
+//
+// IEditorReference[] refs2 = fActivePage.openEditors(inputs2, editorIDs2, flag);
+// assertNotNull(refs2);
+// assertEquals(2, refs2.length);
+//
+// // now input1 is materialized and has focus
+// IEditorPart editor = refs2[0].getEditor(false);
+// assertNotNull(editor);
+// assertEquals(fActivePage.getActiveEditor(), editor);
+//
+// // check that the same editor was created
+// assertEquals(refs2[0].getEditor(true), refs[1].getEditor(true));
+// assertEquals(refs2[1].getEditor(true), refs[0].getEditor(true));
+//
+// // open a file with different editor IDs, materialized (input0) and non-materialzed (input3)
+// String editorIDAlt = fWorkbench.getEditorRegistry().getDefaultEditor("abc.log").getId();
+// IEditorInput[] inputs3 = new IEditorInput[] {
+// new FileEditorInput(inputs[0]),
+// new FileEditorInput(inputs[2]) };
+// String[] editorIDs3 = new String [] { editorIDAlt, editorIDAlt} ;
+//
+// IEditorReference[] refs3 = fActivePage.openEditors(inputs3, editorIDs3, flag);
+// assertNotNull(refs3);
+// assertEquals(2, refs3.length);
+//
+// assertFalse(refs2[0].equals(refs[0]));
+// assertFalse(refs2[1].equals(refs[2]));
+// }
+//
+// /**
+// * A generic test to validate IWorkbenchPage's
+// * {@link IWorkbenchPage#setPartState(IWorkbenchPartReference, int)
+// * setPartState(IWorkbenchPartReference, int)} method which ensures the
+// * prevention of regressing on bug 209333.
+// */
+// public void testSetPartState() throws Exception {
+// // show a view
+// IViewPart view = fActivePage.showView(MockViewPart.ID);
+//
+// // now minimize it
+// IViewReference reference = (IViewReference) fActivePage
+// .getReference(view);
+// fActivePage.setPartState(reference, IWorkbenchPage.STATE_MINIMIZED);
+//
+// // since it's minimized, it should be a fast view
+// assertTrue("A minimized view should be a fast view", facade
+// .isFastView(fActivePage, reference));
+//
+// // try to restore it
+// fActivePage.setPartState(reference, IWorkbenchPage.STATE_RESTORED);
+// // since it's maximized, it should not be a fast view
+// assertFalse("A restored view should not be a fast view", facade
+// .isFastView(fActivePage, reference));
+// }
+//
//}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPartSiteTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPartSiteTest.java
index 0526bd0d0e..7c29f124e9 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPartSiteTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPartSiteTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -39,7 +39,7 @@ public abstract class IWorkbenchPartSiteTest extends UITestCase {
}
public void testGetId() throws Throwable {
- // From Javadoc: "Returns the part registry extension id for
+ // From Javadoc: "Returns the part registry extension id for
// this workbench site's part."
IWorkbenchPart part = createTestPart(fPage);
@@ -48,7 +48,7 @@ public abstract class IWorkbenchPartSiteTest extends UITestCase {
}
public void testGetPage() throws Throwable {
- // From Javadoc: "Returns the page containing this workbench
+ // From Javadoc: "Returns the page containing this workbench
// site's part."
IWorkbenchPart part = createTestPart(fPage);
@@ -57,7 +57,7 @@ public abstract class IWorkbenchPartSiteTest extends UITestCase {
}
public void testGetPluginId() throws Throwable {
- // From Javadoc: "Returns the unique identifier of the
+ // From Javadoc: "Returns the unique identifier of the
// plug-in that defines this workbench site's part."
IWorkbenchPart part = createTestPart(fPage);
@@ -66,7 +66,7 @@ public abstract class IWorkbenchPartSiteTest extends UITestCase {
}
public void testGetRegisteredName() throws Throwable {
- // From Javadoc: "Returns the registered name for this
+ // From Javadoc: "Returns the registered name for this
// workbench site's part."
IWorkbenchPart part = createTestPart(fPage);
@@ -75,7 +75,7 @@ public abstract class IWorkbenchPartSiteTest extends UITestCase {
}
public void testGetShell() throws Throwable {
- // From Javadoc: "Returns the shell containing this
+ // From Javadoc: "Returns the shell containing this
// workbench site's part"
IWorkbenchPart part = createTestPart(fPage);
@@ -84,7 +84,7 @@ public abstract class IWorkbenchPartSiteTest extends UITestCase {
}
public void testGetWorkbenchWindow() throws Throwable {
- // From Javadoc: "Returns the workbench window
+ // From Javadoc: "Returns the workbench window
// containing this workbench site's part."
IWorkbenchPart part = createTestPart(fPage);
@@ -93,8 +93,8 @@ public abstract class IWorkbenchPartSiteTest extends UITestCase {
}
public void testGetSelectionProvider() throws Throwable {
- // From Javadoc: "'Get' returns the selection provider
- // for this workbench site's part.
+ // From Javadoc: "'Get' returns the selection provider
+ // for this workbench site's part.
IWorkbenchPart part = createTestPart(fPage);
IWorkbenchPartSite site = part.getSite();
@@ -118,8 +118,23 @@ public abstract class IWorkbenchPartSiteTest extends UITestCase {
assertEquals(provider, site.getSelectionProvider());
}
+// public void testINestableService() throws Throwable {
+// IWorkbenchPart part = createTestPart(fPage);
+// IWorkbenchPartSite site = part.getSite();
+// DummyService service = (DummyService) site.getService(DummyService.class);
+//
+// assertTrue(service.isActive());
+// if(part instanceof IViewPart)
+// fPage.hideView((IViewPart) part);
+// else
+// fPage.closeEditor((IEditorPart) part, false);
+// assertFalse(service.isActive());
+//
+// }
+
+
/**
- * Creates a test part in the page.
+ * Creates a test part in the page.
*/
abstract protected IWorkbenchPart createTestPart(IWorkbenchPage page)
throws Throwable;
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchTest.java
index 7ca146cf7e..0f5615e1cb 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -54,10 +54,12 @@ public class IWorkbenchTest extends UITestCase {
// Test set focus.
win1.getShell().forceFocus();
+ processEvents();
assertEquals(win1, fWorkbench.getActiveWorkbenchWindow());
// Test set focus.
win2.getShell().forceFocus();
+ processEvents();
assertEquals(win2, fWorkbench.getActiveWorkbenchWindow());
// Cleanup in tearDown.
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetElementAdapterTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetElementAdapterTests.java
new file mode 100644
index 0000000000..d761d85109
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetElementAdapterTests.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.tests.api;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.BasicWorkingSetElementAdapter;
+import org.eclipse.ui.tests.menus.ObjectContributionClasses;
+
+/**
+ * Tests BasicWorkingSetElementAdapter.
+ *
+ * @since 3.5
+ *
+ */
+public class IWorkingSetElementAdapterTests extends TestCase {
+
+ String data = "org.eclipse.ui.tests.menus.ObjectContributionClasses$ICommon;adapt=true,org.eclipse.ui.tests.menus.ObjectContributionClasses$IF;adapt=true";
+ BasicWorkingSetElementAdapter adapter;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ adapter = new BasicWorkingSetElementAdapter();
+ adapter.setInitializationData(null, "class", data);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ adapter.dispose();
+ }
+
+ public void testBasicWorkingSetElementAdapter_Direct() {
+ IAdaptable [] result = adapter.adaptElements(null, new IAdaptable[] {new ObjectContributionClasses.Common()});
+ assertEquals(1, result.length);
+ assertEquals(ObjectContributionClasses.Common.class, result[0].getClass());
+ }
+
+ public void testBasicWorkingSetElementAdapter_Inheritance() {
+ IAdaptable [] result = adapter.adaptElements(null, new IAdaptable[] {new ObjectContributionClasses.D()});
+ assertEquals(1, result.length);
+ assertEquals(ObjectContributionClasses.D.class, result[0].getClass());
+ }
+
+// RAP [if] This test failed in RAP
+// public void testBasicWorkingSetElementAdapter_IAdaptable() {
+// IAdaptable[] result = adapter.adaptElements(null,
+// new IAdaptable[] { new ObjectContributionClasses.E() });
+// assertEquals(1, result.length);
+// assertEquals(ObjectContributionClasses.F.class, result[0].getClass());
+// }
+
+ public void testBasicWorkingSetElementAdapter_AdapterManager() {
+ IAdaptable[] result = adapter.adaptElements(null,
+ new IAdaptable[] { new ObjectContributionClasses.E1() });
+ assertEquals(1, result.length);
+ assertEquals(ObjectContributionClasses.Common.class, result[0].getClass());
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetManagerTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetManagerTest.java
index c9b759c221..da477e0bdf 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetManagerTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetManagerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -281,6 +281,17 @@ public class IWorkingSetManagerTest extends UITestCase {
assertEquals(fWorkingSet, sets[0]);
assertEquals(workingSet2, sets[2]);
assertEquals(workingSet3, sets[1]);
+
+ IWorkingSet workingSet3a = fWorkingSetManager.createWorkingSet(
+ WORKING_SET_NAME_2 + "\u200b", new IAdaptable[] { fWorkspace.getRoot() });
+ workingSet3.setLabel(WORKING_SET_NAME_2); // reset the label - it
+
+ fWorkingSetManager.addWorkingSet(workingSet3a);
+ assertFalse(workingSet3a.equals(workingSet3));
+
+ sets = fWorkingSetManager.getWorkingSets();
+ assertEquals(4, sets.length);
+
}
public void testRemovePropertyChangeListener() throws Throwable {
@@ -310,6 +321,35 @@ public class IWorkingSetManagerTest extends UITestCase {
fWorkingSetManager.getWorkingSets()));
}
+ public void testRemoveWorkingSetAfterRename() throws Throwable {
+ /* get workingSetManager */
+ IWorkingSetManager workingSetManager =
+ fWorkbench.getWorkingSetManager();
+
+ workingSetManager.addWorkingSet(fWorkingSet);
+ String origName=fWorkingSet.getName();
+
+ /* check that workingSetManager contains "fWorkingSet"*/
+ assertTrue(ArrayUtil.equals(
+ new IWorkingSet[] { fWorkingSet },
+ workingSetManager.getWorkingSets()));
+
+ fWorkingSet.setName(" ");
+ assertEquals(" ", fWorkingSet.getName());
+
+ /* remove "fWorkingSet" from working set manager */
+ workingSetManager.removeWorkingSet(fWorkingSet);
+
+ /* check that "fWorkingSet" was removed after rename*/
+ if(!ArrayUtil.equals(new IWorkingSet[] {},
+ workingSetManager.getWorkingSets())){
+ /*Test Failure, report after restoring state*/
+ fWorkingSet.setName(origName);
+ workingSetManager.removeWorkingSet(fWorkingSet);
+ fail("expected that fWorkingSet has been removed");
+ }
+
+ }
/**
* Tests to ensure that a misbehaving listener does not bring down the manager.
*
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ListView.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ListView.java
index 6ddfba15fc..f4d6505f44 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ListView.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ListView.java
@@ -117,7 +117,7 @@ public class ListView extends MockViewPart implements IMenuListener {
public void addElement(ListElement el) {
input.add(el);
viewer.refresh();
-// viewer.getControl().update();
+ viewer.getControl().update();
}
public void selectElement(ListElement el) {
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/MockReusableEditorPart.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/MockReusableEditorPart.java
new file mode 100644
index 0000000000..9dfa4b777c
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/MockReusableEditorPart.java
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.api;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IReusableEditor;
+import org.eclipse.ui.IShowEditorInput;
+import org.eclipse.ui.PartInitException;
+//import org.eclipse.ui.ide.IGotoMarker;
+
+public class MockReusableEditorPart extends MockWorkbenchPart implements IEditorPart,
+// IGotoMarker,
+ IShowEditorInput, IReusableEditor {
+
+ private static final String BASE = "org.eclipse.ui.tests.api.MockReusableEditorPart";
+
+ public static final String ID1 = BASE + "1";
+
+ public static final String ID2 = BASE + "2";
+
+ public static final String NAME = "Mock Reusable Editor 1";
+
+ private IEditorInput input;
+
+ private boolean dirty = false;
+
+ private boolean saveNeeded = true;
+
+ private boolean saveAsAllowed = false;
+
+ public MockReusableEditorPart() {
+ super();
+ }
+
+ public void createPartControl(Composite parent) {
+ super.createPartControl(parent);
+
+ final Button dirtyToggle = new Button(parent, SWT.CHECK);
+ dirtyToggle.setText("Dirty");
+ dirtyToggle.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setDirty(dirtyToggle.getSelection());
+ }
+ });
+ dirtyToggle.setSelection(isDirty());
+
+ final Button saveNeededToggle = new Button(parent, SWT.CHECK);
+ saveNeededToggle.setText("Save on close");
+ saveNeededToggle.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setSaveNeeded(saveNeededToggle.getSelection());
+ }
+ });
+ saveNeededToggle.setSelection(saveNeeded);
+
+ final Button saveAsToggle = new Button(parent, SWT.CHECK);
+ saveAsToggle.setText("Save as allowed");
+ saveAsToggle.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setSaveAsAllowed(saveAsToggle.getSelection());
+ }
+ });
+ saveAsToggle.setSelection(saveAsAllowed);
+ }
+ /**
+ * @see IEditorPart#doSave(IProgressMonitor)
+ */
+ public void doSave(IProgressMonitor monitor) {
+ setDirty(false);
+ callTrace.add("doSave");
+ }
+
+ /**
+ * @see IEditorPart#doSaveAs()
+ */
+ public void doSaveAs() {
+ }
+
+ /**
+ * @see IEditorPart#getEditorInput()
+ */
+ public IEditorInput getEditorInput() {
+ return input;
+ }
+
+ /**
+ * @see IEditorPart#getEditorSite()
+ */
+ public IEditorSite getEditorSite() {
+ return (IEditorSite) getSite();
+ }
+
+ /**
+ * @see org.eclipse.ui.ide.IGotoMarker
+ */
+ public void gotoMarker(IMarker marker) {
+ callTrace.add("gotoMarker");
+ }
+
+ /**
+ * @see IEditorPart#init(IEditorSite, IEditorInput)
+ */
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+ this.input = input;
+ setSite(site);
+ callTrace.add("init");
+ setSiteInitialized();
+ }
+
+ /**
+ * @see IEditorPart#isDirty()
+ */
+ public boolean isDirty() {
+ callTrace.add("isDirty");
+ return dirty;
+ }
+
+ public void setDirty(boolean value) {
+ dirty = value;
+ firePropertyChange(PROP_DIRTY);
+ }
+
+ /**
+ * @see IEditorPart#isSaveAsAllowed()
+ */
+ public boolean isSaveAsAllowed() {
+ callTrace.add("isSaveAsAllowed");
+ return saveAsAllowed;
+ }
+
+ /**
+ * @see IEditorPart#isSaveOnCloseNeeded()
+ */
+ public boolean isSaveOnCloseNeeded() {
+ callTrace.add("isSaveOnCloseNeeded");
+ return saveNeeded;
+ }
+
+ public void setSaveAsAllowed(boolean isSaveAsAllowed) {
+ this.saveAsAllowed = isSaveAsAllowed;
+ }
+
+ public void setSaveNeeded(boolean value) {
+ saveNeeded = value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.tests.api.MockWorkbenchPart#getActionBars()
+ */
+ protected IActionBars getActionBars() {
+ return getEditorSite().getActionBars();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IShowEditorInput#showEditorInput(org.eclipse.ui.IEditorInput)
+ */
+ public void showEditorInput(IEditorInput editorInput) {
+ callTrace.add("showEditorInput");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IReusableEditor#setInput(org.eclipse.ui.IEditorInput)
+ */
+ public void setInput(IEditorInput input) {
+ this.input = input;
+ firePropertyChange(PROP_INPUT);
+ }
+}
+
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/SaveableMockViewPart.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/SaveableMockViewPart.java
index fd8306f5f1..105d496676 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/SaveableMockViewPart.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/SaveableMockViewPart.java
@@ -10,6 +10,11 @@
*******************************************************************************/
package org.eclipse.ui.tests.api;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -17,6 +22,9 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.ISaveablePart;
+import org.eclipse.ui.ISaveablesSource;
+import org.eclipse.ui.Saveable;
+import org.eclipse.ui.internal.DefaultSaveable;
/**
* Mock view part that implements ISaveablePart.
@@ -25,7 +33,7 @@ import org.eclipse.ui.ISaveablePart;
* @since 3.0.1
*/
public class SaveableMockViewPart extends MockViewPart implements
- ISaveablePart {
+ ISaveablePart, ISaveablesSource {
public static String ID = "org.eclipse.ui.tests.api.SaveableMockViewPart";
@@ -35,6 +43,8 @@ public class SaveableMockViewPart extends MockViewPart implements
private boolean saveNeeded = true;
+ private boolean adapt;
+
public void createPartControl(Composite parent) {
super.createPartControl(parent);
@@ -47,6 +57,14 @@ public class SaveableMockViewPart extends MockViewPart implements
});
dirtyToggle.setSelection(isDirty());
+ final Button adaptToggle = new Button(parent, SWT.CHECK);
+ adaptToggle.setText("Adapt to resource");
+ adaptToggle.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setAdapt(adaptToggle.getSelection());
+ }
+ });
+
final Button saveNeededToggle = new Button(parent, SWT.CHECK);
saveNeededToggle.setText("Save on close");
saveNeededToggle.addSelectionListener(new SelectionAdapter() {
@@ -66,6 +84,13 @@ public class SaveableMockViewPart extends MockViewPart implements
saveAsToggle.setSelection(saveAsAllowed);
}
+ /**
+ * @param selection
+ */
+ protected void setAdapt(boolean selection) {
+ this.adapt = selection;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor)
*/
@@ -116,4 +141,46 @@ public class SaveableMockViewPart extends MockViewPart implements
public void setSaveNeeded(boolean isSaveOnCloseNeeded) {
this.saveNeeded = isSaveOnCloseNeeded;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISaveablesSource#getActiveSaveables()
+ */
+ public Saveable[] getActiveSaveables() {
+ // TODO Auto-generated method stub
+ return getSaveables();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISaveablesSource#getSaveables()
+ */
+ public Saveable[] getSaveables() {
+ Saveable[] result = new Saveable[1];
+ result[0] = new DefaultSaveable(this){
+ public Object getAdapter(Class c) {
+ final IFile[] someFile = {null};
+ try {
+ ResourcesPlugin.getWorkspace().getRoot().accept(new IResourceVisitor() {
+
+ public boolean visit(IResource resource) throws CoreException {
+ if (someFile[0] != null) {
+ return false;
+ }
+ if (resource.getType() == IResource.FILE) {
+ someFile[0] = (IFile) resource;
+ return false;
+ }
+ return true;
+ }
+ });
+ } catch (CoreException e) {
+ throw new RuntimeException(e);
+ }
+ if (adapt && someFile[0] != null && c.equals(IFile.class)) {
+ return someFile[0];
+ }
+ return super.getAdapter(c);
+ };
+ };
+ return result ;
+ }
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/StickyViewTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/StickyViewTest.java
index 4741c491c4..ddc65318f6 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/StickyViewTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/StickyViewTest.java
@@ -1,5 +1,5 @@
///*******************************************************************************
-// * Copyright (c) 2004, 2007 IBM Corporation and others.
+// * Copyright (c) 2004, 2010 IBM Corporation and others.
// * All rights reserved. This program and the accompanying materials
// * are made available under the terms of the Eclipse Public License v1.0
// * which accompanies this distribution, and is available at
@@ -14,6 +14,7 @@
//
//import org.eclipse.core.resources.IFile;
//import org.eclipse.core.resources.IProject;
+//import org.eclipse.jface.action.IContributionItem;
//import org.eclipse.jface.preference.IPreferenceStore;
//import org.eclipse.swt.widgets.Menu;
//import org.eclipse.swt.widgets.MenuItem;
@@ -28,24 +29,21 @@
//import org.eclipse.ui.IWorkbenchPreferenceConstants;
//import org.eclipse.ui.IWorkbenchWindow;
//import org.eclipse.ui.PartInitException;
-//import org.eclipse.ui.internal.FastViewBar;
-//import org.eclipse.ui.internal.FastViewBarContextMenuContribution;
-//import org.eclipse.ui.internal.PartSite;
-//import org.eclipse.ui.internal.ViewPane;
-//import org.eclipse.ui.internal.WorkbenchPage;
+//import org.eclipse.ui.PlatformUI;
//import org.eclipse.ui.internal.WorkbenchPlugin;
-//import org.eclipse.ui.internal.WorkbenchWindow;
+//import org.eclipse.ui.internal.tweaklets.Tweaklets;
//import org.eclipse.ui.internal.util.PrefUtil;
//import org.eclipse.ui.part.FileEditorInput;
//import org.eclipse.ui.tests.harness.util.FileUtil;
//import org.eclipse.ui.tests.harness.util.UITestCase;
+//import org.eclipse.ui.tests.helpers.TestFacade;
//import org.eclipse.ui.views.IStickyViewDescriptor;
//
///**
// * @since 3.0
// */
//public class StickyViewTest extends UITestCase {
-//
+//
// /**
// * Allow tests to run just in this class.
// * @return the TestSuite to run.
@@ -53,11 +51,13 @@
// public static TestSuite suite() {
// return new TestSuite(StickyViewTest.class);
// }
-//
+//
// private IWorkbenchWindow window;
//
// private IWorkbenchPage page;
//
+// private TestFacade facade;
+//
// /**
// * @param testName
// */
@@ -146,9 +146,9 @@
// testMoveable("org.eclipse.ui.tests.api.StickyViewLeft1", true);
// }
//
-// /**
+// /**
// * Tests whether a sticky view with the given id is moveable or not.
-// *
+// *
// * @param id the id
// * @param expectation the expected moveable state
// */
@@ -158,8 +158,8 @@
// assertNotNull(part);
// assertTrue(ViewUtils.isSticky(part));
//
-// //tests to ensure that the XML was read correctly
-// IStickyViewDescriptor[] descs = WorkbenchPlugin.getDefault()
+// //tests to ensure that the XML was read correctly
+// IStickyViewDescriptor[] descs = PlatformUI.getWorkbench()
// .getViewRegistry().getStickyViews();
// for (int i = 0; i < descs.length; i++) {
// if (descs[i].getId().equals(id)) {
@@ -174,9 +174,9 @@
// }
// }
//
-// /**
+// /**
// * Tests whether a sticky view with the given id is closeable or not.
-// *
+// *
// * @param id the id
// * @param expectation the expected closeable state
// */
@@ -186,8 +186,8 @@
// assertNotNull(part);
// assertTrue(ViewUtils.isSticky(part));
//
-// //tests to ensure that the XML was read correctly
-// IStickyViewDescriptor[] descs = WorkbenchPlugin.getDefault()
+// //tests to ensure that the XML was read correctly
+// IStickyViewDescriptor[] descs = PlatformUI.getWorkbench()
// .getViewRegistry().getStickyViews();
// for (int i = 0; i < descs.length; i++) {
// if (descs[i].getId().equals(id)) {
@@ -231,11 +231,11 @@
// fail(e.getMessage());
// }
// }
-//
+//
// /**
// * Test that closing a stand-alone view remove the editor stack and
// * doesn't throw an NPE.
-// *
+// *
// * @throws Throwable on error
// * @since 3.2
// */
@@ -254,10 +254,10 @@
// page.closePerspective(page.getPerspective(), false, false);
// }
// }
-//
+//
// /**
// * Test that a view marked as non-closable cannot be closed as a fast view.
-// *
+// *
// * @throws Throwable
// * @since 3.1.1
// */
@@ -276,37 +276,35 @@
// IViewReference viewRef = page
// .findViewReference(PerspectiveViewsBug88345.NORMAL_VIEW_ID);
//
-// WorkbenchPage wpage = (WorkbenchPage) page;
-// assertFalse(wpage.isFastView(stickyRef));
+// assertFalse(facade.isFastView(page, stickyRef));
+//
+// facade.addFastView(page, stickyRef);
+// assertTrue(facade.isFastView(page, stickyRef));
+//
+// facade.addFastView(page, viewRef);
+// assertTrue(facade.isFastView(page, viewRef));
//
-// wpage.addFastView(stickyRef);
-// assertTrue(wpage.isFastView(stickyRef));
//
-// wpage.addFastView(viewRef);
-// assertTrue(wpage.isFastView(viewRef));
//
-// FastViewBar fastViewBar = ((WorkbenchWindow) page
-// .getWorkbenchWindow()).getFastViewBar();
-// FastViewBarContextMenuContribution menuContribution = fastViewBar
-// .testContextMenu();
+// IContributionItem menuContribution = facade.getFVBContribution(page);
//
// // set the target of a normal view that is now a fast view
// // close should be enabled
-// menuContribution.setTarget(viewRef);
-// checkEnabledMenuItem(wpage, menuContribution, "Close", true);
+// facade.setFVBTarget(menuContribution, viewRef);
+// checkEnabledMenuItem(page, menuContribution, "Close", true);
//
// // set the target of our non-closeable fast view
// // close should not be enabled
-// menuContribution.setTarget(stickyRef);
-// checkEnabledMenuItem(wpage, menuContribution, "Close", false);
+// facade.setFVBTarget(menuContribution, stickyRef);
+// checkEnabledMenuItem(page, menuContribution, "Close", false);
// } finally {
// page.closePerspective(page.getPerspective(), false, false);
// }
// }
-//
+//
// /**
// * Test that a fast view marked as non-moveable cannot be docked.
-// *
+// *
// * @throws Throwable
// * @since 3.1.1
// */
@@ -323,27 +321,23 @@
// IViewReference viewRef = page
// .findViewReference(PerspectiveViewsBug88345.NORMAL_VIEW_ID);
//
-// WorkbenchPage wpage = (WorkbenchPage) page;
-// assertFalse(wpage.isFastView(viewRef));
-// assertTrue(wpage.isFastView(stickyRef));
+// assertFalse(facade.isFastView(page, viewRef));
+// assertTrue(facade.isFastView(page, stickyRef));
//
-// wpage.addFastView(viewRef);
-// assertTrue(wpage.isFastView(viewRef));
+// facade.addFastView(page, viewRef);
+// assertTrue(facade.isFastView(page, viewRef));
//
-// FastViewBar fastViewBar = ((WorkbenchWindow) page
-// .getWorkbenchWindow()).getFastViewBar();
-// FastViewBarContextMenuContribution menuContribution = fastViewBar
-// .testContextMenu();
+// IContributionItem menuContribution = facade.getFVBContribution(page);
//
// // set the target of a normal view that is now a fast view
// // Fast View should be enabled
-// menuContribution.setTarget(viewRef);
-// checkEnabledMenuItem(wpage, menuContribution, "Fast View", true);
+// facade.setFVBTarget(menuContribution, viewRef);
+// checkEnabledMenuItem(page, menuContribution, "Fast View", true);
//
// // set the target of our non-closeable fast view
// // Fast View should not be enabled
-// menuContribution.setTarget(stickyRef);
-// checkEnabledMenuItem(wpage, menuContribution, "Fast View", false);
+// facade.setFVBTarget(menuContribution, stickyRef);
+// checkEnabledMenuItem(page, menuContribution, "Fast View", false);
// } finally {
// page.closePerspective(page.getPerspective(), false, false);
// }
@@ -351,14 +345,14 @@
//
// /**
// * Find the supplied menu item and make sure it's enabled/disabled.
-// *
+// *
// * @param wpage the workbench page
// * @param menuContribution the fast bar menu contribution item
// * @param isEnabled should the item be enabled
// * @since 3.1.1
// */
-// private void checkEnabledMenuItem(WorkbenchPage wpage,
-// FastViewBarContextMenuContribution menuContribution,
+// private void checkEnabledMenuItem(IWorkbenchPage wpage,
+// IContributionItem menuContribution,
// String itemName,
// boolean isEnabled) {
// Menu m = new Menu(wpage.getWorkbenchWindow().getShell());
@@ -383,7 +377,7 @@
// /**
// * Test that the view toolbar visibility matches the presentation
// * visibility for a view.
-// *
+// *
// * @throws Throwable on an error
// * @since 3.2
// */
@@ -393,7 +387,7 @@
// IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
// boolean oldMinMaxState = apiStore.getBoolean(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
// apiStore.setValue(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX, false);
-//
+//
// IPerspectiveDescriptor perspective = WorkbenchPlugin.getDefault()
// .getPerspectiveRegistry().findPerspectiveWithId(
// PerspectiveViewsBug88345.PERSP_ID);
@@ -416,12 +410,10 @@
// // make sure the view is active
// assertNotNull("The view must exist", viewRef.getPart(true));
// page.activate(viewRef.getPart(true));
-// PartSite site = (PartSite) viewRef.getPart(true).getSite();
-// ViewPane pane = (ViewPane) site.getPane();
//
-// assertTrue(pane.isVisible());
-// assertNotNull("This view must have a toolbar", pane.getToolBar());
-// assertTrue(pane.getToolBar().isVisible());
+//
+// assertTrue(facade.isViewPaneVisible(viewRef));
+// assertTrue(facade.isViewToolbarVisible(viewRef));
//
// // open the editor and zoom it.
// editor = page.openEditor(new FileEditorInput(test01), registry
@@ -430,21 +422,21 @@
//
// IWorkbenchPartReference ref = page.getReference(editor);
// page.toggleZoom(ref);
-// assertFalse(pane.isVisible());
-// assertFalse(pane.getToolBar().isVisible());
+// assertFalse(facade.isViewPaneVisible(viewRef));
+// assertFalse(facade.isViewToolbarVisible(viewRef));
//
// // switch to another perspective, and then switch back.
// page.setPerspective(secondPerspective);
//
-// assertFalse(pane.isVisible());
-// assertFalse(pane.getToolBar().isVisible());
+// assertFalse(facade.isViewPaneVisible(viewRef));
+// assertFalse(facade.isViewToolbarVisible(viewRef));
//
// page.setPerspective(perspective);
// processEvents();
//
// // both the view and the toolbar must be not visible
-// assertFalse(pane.isVisible());
-// assertFalse(pane.getToolBar().isVisible());
+// assertFalse(facade.isViewPaneVisible(viewRef));
+// assertFalse(facade.isViewToolbarVisible(viewRef));
//
// } finally {
// if (editor != null) {
@@ -460,11 +452,12 @@
//
// /*
// * (non-Javadoc)
-// *
+// *
// * @see org.eclipse.ui.tests.util.UITestCase#doSetUp()
// */
// protected void doSetUp() throws Exception {
// window = openTestWindow();
// page = window.getActivePage();
+// facade = (TestFacade) Tweaklets.get(TestFacade.KEY);
// }
//}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ViewUtils.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ViewUtils.java
index 95ffa11ca7..b6495466bf 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ViewUtils.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/ViewUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,9 +12,10 @@ package org.eclipse.ui.tests.api;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.internal.ViewSite;
-import org.eclipse.ui.internal.WorkbenchPage;
-import org.eclipse.ui.internal.WorkbenchPlugin;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.tweaklets.Tweaklets;
+import org.eclipse.ui.tests.helpers.TestFacade;
import org.eclipse.ui.views.IStickyViewDescriptor;
/**
@@ -33,24 +34,20 @@ public final class ViewUtils {
}
public static boolean isCloseable(IViewPart part) {
- ViewSite viewSite = (ViewSite) part.getSite();
- String id = viewSite.getId();
- IViewReference ref = viewSite.getPage().findViewReference(id);
- return ((WorkbenchPage) viewSite.getPage()).getActivePerspective()
- .isCloseable(ref);
+ IWorkbenchPartSite viewSite = part.getSite();
+ IViewReference ref = (IViewReference) viewSite.getPage().getReference(part);
+ return ((TestFacade)Tweaklets.get(TestFacade.KEY)).isClosableInPerspective(ref);
}
public static boolean isMoveable(IViewPart part) {
- ViewSite viewSite = (ViewSite) part.getSite();
- String id = viewSite.getId();
- IViewReference ref = viewSite.getPage().findViewReference(id);
- return ((WorkbenchPage) viewSite.getPage()).getActivePerspective()
- .isMoveable(ref);
+ IWorkbenchPartSite viewSite = part.getSite();
+ IViewReference ref = (IViewReference) viewSite.getPage().getReference(part);
+ return ((TestFacade)Tweaklets.get(TestFacade.KEY)).isMoveableInPerspective(ref);
}
public static boolean isSticky(IViewPart part) {
String id = part.getSite().getId();
- IStickyViewDescriptor[] descs = WorkbenchPlugin.getDefault()
+ IStickyViewDescriptor[] descs = PlatformUI.getWorkbench()
.getViewRegistry().getStickyViews();
for (int i = 0; i < descs.length; i++) {
if (descs[i].getId().equals(id))
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ArbitraryPropertyTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ArbitraryPropertyTest.java
index c76b525c2c..aa6eca373b 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ArbitraryPropertyTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ArbitraryPropertyTest.java
@@ -20,8 +20,8 @@ import org.eclipse.jface.util.PropertyChangeEvent;
//import org.eclipse.ui.IFileEditorInput;
//import org.eclipse.ui.IPersistableElement;
import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.internal.WorkbenchPage;
-import org.eclipse.ui.internal.WorkbenchWindow;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.tests.harness.util.UITestCase;
/**
@@ -47,9 +47,9 @@ public class ArbitraryPropertyTest extends UITestCase {
super(testName);
}
- WorkbenchWindow window;
+ IWorkbenchWindow window;
- WorkbenchPage page;
+ IWorkbenchPage page;
/*
* (non-Javadoc)
@@ -58,8 +58,8 @@ public class ArbitraryPropertyTest extends UITestCase {
*/
protected void doSetUp() throws Exception {
super.doSetUp();
- window = (WorkbenchWindow) openTestWindow();
- page = (WorkbenchPage) window.getActivePage();
+ window = openTestWindow();
+ page = window.getActivePage();
}
/*
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/HeavyResourceView.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/HeavyResourceView.java
index 4408120802..de428650e9 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/HeavyResourceView.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/HeavyResourceView.java
@@ -69,11 +69,9 @@ public class HeavyResourceView extends ViewPart {
public void useAll() {
releaseAll();
tempShell = new Shell(Display.getCurrent(), SWT.NONE);
- int count = 0;
try {
for(;;) {
new Composite(tempShell, SWT.NONE);
- count++;
}
} catch (SWTError e) {
TestPlugin.getDefault().getLog().log(WorkbenchPlugin.getStatus(e));
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/LifecycleView.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/LifecycleView.java
index 2d3dad1977..c7a99d8b92 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/LifecycleView.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/LifecycleView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,7 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.ui.tests.api.workbenchpart;
@@ -19,8 +19,8 @@ import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.internal.services.IWorkbenchLocationService;
import org.eclipse.ui.part.ViewPart;
/**
@@ -79,7 +79,9 @@ public class LifecycleView extends ViewPart {
* @see org.eclipse.ui.part.WorkbenchPart#dispose()
*/
public void dispose() {
- if (getSite().getService(IWorkbenchPartSite.class) == null) {
+ IWorkbenchLocationService wls = (IWorkbenchLocationService) getSite()
+ .getService(IWorkbenchLocationService.class);
+ if (wls.getPartSite() == null) {
callSiteDispose = true;
}
callPartDispose = true;
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/OverriddenTitleTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/OverriddenTitleTest.java
index 715bd33527..30221d02b4 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/OverriddenTitleTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/OverriddenTitleTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,10 +13,10 @@ package org.eclipse.ui.tests.api.workbenchpart;
import junit.framework.Assert;
import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart2;
import org.eclipse.ui.IWorkbenchPartConstants;
-import org.eclipse.ui.internal.WorkbenchPage;
-import org.eclipse.ui.internal.WorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.tests.harness.util.UITestCase;
/**
@@ -30,9 +30,9 @@ public class OverriddenTitleTest extends UITestCase {
super(testName);
}
- WorkbenchWindow window;
+ IWorkbenchWindow window;
- WorkbenchPage page;
+ IWorkbenchPage page;
OverriddenTitleView view;
@@ -63,8 +63,8 @@ public class OverriddenTitleTest extends UITestCase {
protected void doSetUp() throws Exception {
super.doSetUp();
- window = (WorkbenchWindow) openTestWindow();
- page = (WorkbenchPage) window.getActivePage();
+ window = openTestWindow();
+ page = window.getActivePage();
view = (OverriddenTitleView) page
.showView("org.eclipse.ui.tests.workbenchpart.OverriddenTitleView");
view.addPropertyListener(propertyListener);
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/RawIViewPartTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/RawIViewPartTest.java
index b2b000b5e3..effb4390f2 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/RawIViewPartTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/RawIViewPartTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,11 +13,11 @@ package org.eclipse.ui.tests.api.workbenchpart;
import junit.framework.Assert;
import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartConstants;
import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.internal.WorkbenchPage;
-import org.eclipse.ui.internal.WorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.tests.harness.util.UITestCase;
/**
@@ -31,9 +31,9 @@ public class RawIViewPartTest extends UITestCase {
super(testName);
}
- WorkbenchWindow window;
+ IWorkbenchWindow window;
- WorkbenchPage page;
+ IWorkbenchPage page;
RawIViewPart view;
@@ -66,8 +66,8 @@ public class RawIViewPartTest extends UITestCase {
protected void doSetUp() throws Exception {
super.doSetUp();
- window = (WorkbenchWindow) openTestWindow();
- page = (WorkbenchPage) window.getActivePage();
+ window = openTestWindow();
+ page = window.getActivePage();
view = (RawIViewPart) page
.showView("org.eclipse.ui.tests.workbenchpart.RawIViewPart");
ref = page
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ViewPartTitleTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ViewPartTitleTest.java
index 23eaf216d3..40d13423fc 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ViewPartTitleTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/workbenchpart/ViewPartTitleTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,11 +13,11 @@ package org.eclipse.ui.tests.api.workbenchpart;
import junit.framework.Assert;
import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart2;
import org.eclipse.ui.IWorkbenchPartConstants;
import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.internal.WorkbenchPage;
-import org.eclipse.ui.internal.WorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.tests.harness.util.UITestCase;
/**
@@ -34,9 +34,9 @@ public class ViewPartTitleTest extends UITestCase {
super(testName);
}
- WorkbenchWindow window;
+ IWorkbenchWindow window;
- WorkbenchPage page;
+ IWorkbenchPage page;
EmptyView view;
@@ -69,8 +69,8 @@ public class ViewPartTitleTest extends UITestCase {
protected void doSetUp() throws Exception {
super.doSetUp();
- window = (WorkbenchWindow) openTestWindow();
- page = (WorkbenchPage) window.getActivePage();
+ window = openTestWindow();
+ page = window.getActivePage();
String viewId = "org.eclipse.ui.tests.workbenchpart.EmptyView";
view = (EmptyView) page.showView(viewId);
ref = page.findViewReference(viewId);
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java
index 0c1e205978..de3fe5228a 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,11 +11,21 @@
package org.eclipse.ui.tests.commands;
+//import java.io.ByteArrayInputStream;
+//import java.io.InputStream;
+
+//import org.eclipse.core.commands.NotHandledException;
+//import org.eclipse.core.resources.IFile;
+//import org.eclipse.core.resources.IProject;
+//import org.eclipse.core.runtime.NullProgressMonitor;
+//import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.IHandlerService;
+//import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.tests.api.workbenchpart.MenuContributionHarness;
+//import org.eclipse.ui.tests.harness.util.FileUtil;
import org.eclipse.ui.tests.harness.util.UITestCase;
/**
@@ -24,11 +34,15 @@ import org.eclipse.ui.tests.harness.util.UITestCase;
*/
public class ActionDelegateProxyTest extends UITestCase {
/**
- *
+ *
*/
+ private static final String DELEGATE_ACTION_SET_ID = "org.eclipse.ui.tests.delegateActionSet";
private static final String INC_COMMAND = "org.eclipse.ui.tests.incMenuHarness";
private static final String VIEW_ID = "org.eclipse.ui.tests.api.MenuTestHarness";
+ private static final String GO_COMMAND = "org.eclipse.ui.tests.simplyGo";
+ private static final String STAY_COMMAND = "org.eclipse.ui.tests.simplyStay";
+
/**
* @param testName
*/
@@ -50,7 +64,7 @@ public class ActionDelegateProxyTest extends UITestCase {
assertEquals(1, mch.getCount());
service.executeCommand(INC_COMMAND, null);
assertEquals(2, mch.getCount());
-
+
page.hideView(view);
IViewPart view2 = page.showView(VIEW_ID);
assertFalse(view==view2);
@@ -64,4 +78,57 @@ public class ActionDelegateProxyTest extends UITestCase {
service.executeCommand(INC_COMMAND, null);
assertEquals(2, mch.getCount());
}
+
+// public void testWWActionDelegate() throws Exception {
+// IWorkbenchWindow window = openTestWindow();
+// window.getActivePage().showActionSet(DELEGATE_ACTION_SET_ID);
+// IHandlerService service = (IHandlerService) window.getService(IHandlerService.class);
+// assertFalse(SimplyGoActionDelegate.executed);
+// service.executeCommand(GO_COMMAND, null);
+// assertTrue(SimplyGoActionDelegate.executed);
+// }
+
+ private static final String contents = "one\ntwo\nthree\n";
+
+// public void testEditorActionDelegate() throws Exception {
+// IWorkbenchWindow window = openTestWindow();
+// window.getActivePage().closeAllEditors(false);
+// IHandlerService service = (IHandlerService) window.getService(IHandlerService.class);
+// assertFalse(EditorActionDelegate.executed);
+// EditorActionDelegate.part = null;
+// try {
+// service.executeCommand(STAY_COMMAND, null);
+// fail("the command is not yet handled");
+// } catch (NotHandledException e) {
+// // good
+// }
+// assertFalse(EditorActionDelegate.executed);
+// assertNull(EditorActionDelegate.part);
+//
+// IProject proj = FileUtil.createProject(GO_COMMAND);
+// IFile file = FileUtil.createFile("test.txt", proj);
+// InputStream in = new ByteArrayInputStream(contents.getBytes());
+// file.setContents(in, true, false, new NullProgressMonitor());
+// IEditorPart editor1 = IDE.openEditor(window.getActivePage(), file);
+// assertNotNull(editor1);
+// assertEquals("org.eclipse.ui.DefaultTextEditor", editor1.getSite().getId());
+//
+// file = FileUtil.createFile("test2.txt", proj);
+// in = new ByteArrayInputStream(contents.getBytes());
+// file.setContents(in, true, false, new NullProgressMonitor());
+// IEditorPart editor2 = IDE.openEditor(window.getActivePage(), file);
+// assertNotNull(editor2);
+// assertEquals("org.eclipse.ui.DefaultTextEditor", editor2.getSite().getId());
+//
+// service.executeCommand(STAY_COMMAND, null);
+// assertTrue(EditorActionDelegate.executed);
+// assertEquals(editor2, EditorActionDelegate.part);
+//
+// window.getActivePage().activate(editor1);
+// processEvents();
+// service.executeCommand(STAY_COMMAND, null);
+// assertTrue(EditorActionDelegate.executed);
+// assertEquals(editor1, EditorActionDelegate.part);
+//
+// }
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java
index 6c0b085f6c..a5b0a51a67 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,10 +7,13 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.ui.tests.commands;
+import java.lang.reflect.Field;
+import java.util.Map;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.CommandEvent;
@@ -26,10 +29,13 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.ISources;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.contexts.IContextActivation;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -38,6 +44,10 @@ import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.internal.handlers.HandlerProxy;
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
import org.eclipse.ui.internal.services.WorkbenchSourceProvider;
+import org.eclipse.ui.menus.CommandContributionItem;
+import org.eclipse.ui.menus.IMenuService;
+import org.eclipse.ui.menus.MenuUtil;
+import org.eclipse.ui.menus.UIElement;
import org.eclipse.ui.services.IEvaluationService;
import org.eclipse.ui.services.ISourceProviderService;
import org.eclipse.ui.tests.harness.util.UITestCase;
@@ -52,12 +62,14 @@ public class CommandEnablementTest extends UITestCase {
private static final String CONTEXT_TEST1 = "org.eclipse.ui.command.contexts.enablement_test1";
private static final String PREFIX = "tests.commands.CCT.";
private static final String CMD1_ID = PREFIX + "cmd1";
+ private static final String CMD3_ID = PREFIX + "cmd3";
private ICommandService commandService;
private IHandlerService handlerService;
private IContextService contextService;
private Command cmd1;
+ private Command cmd3;
private DefaultHandler normalHandler1;
private IHandlerActivation activation1;
private DefaultHandler normalHandler2;
@@ -94,6 +106,7 @@ public class CommandEnablementTest extends UITestCase {
evalService = (IEvaluationService) fWorkbench
.getService(IEvaluationService.class);
cmd1 = commandService.getCommand(CMD1_ID);
+ cmd3 = commandService.getCommand(CMD3_ID);
normalHandler1 = new DefaultHandler();
normalHandler2 = new DefaultHandler();
disabledHandler1 = new DisabledHandler();
@@ -196,8 +209,6 @@ public class CommandEnablementTest extends UITestCase {
private static class CheckContextHandler extends AbstractHandler {
- private String lastActivePartId;
-
/*
* (non-Javadoc)
*
@@ -230,6 +241,89 @@ public class CommandEnablementTest extends UITestCase {
}
}
+ class UpdatingHandler extends AbstractHandler implements IElementUpdater {
+
+ private final String text;
+
+ public UpdatingHandler(String text) {
+ this.text = text;
+ }
+
+ public void updateElement(UIElement element, Map parameters) {
+ element.setText(text);
+ }
+
+ public Object execute(ExecutionEvent event) {
+ return null;
+ }
+
+ }
+
+ public void testRestoreContributedUI() throws Exception {
+
+ Field iconField = CommandContributionItem.class.getDeclaredField("icon");
+ iconField.setAccessible(true);
+
+ Field labelField = CommandContributionItem.class.getDeclaredField("label");
+ labelField.setAccessible(true);
+
+ String menuId = "org.eclipse.ui.tests.Bug275126";
+ MenuManager manager = new MenuManager(null, menuId);
+ IMenuService menuService = (IMenuService) fWorkbench.getService(IMenuService.class);
+ menuService.populateContributionManager(manager, MenuUtil.menuUri(menuId));
+ IContributionItem[] items = manager.getItems();
+ assertTrue(items.length ==1);
+ assertTrue(items[0] instanceof CommandContributionItem);
+ CommandContributionItem item = (CommandContributionItem) items[0];
+
+ String text1 = "text1";
+ String text2 = "text2";
+
+ // contributed from plugin.xml
+ String contributedLabel = "Contributed Label";
+
+ // default handler
+ assertTrue(cmd3.getHandler() instanceof HandlerProxy);
+ assertEquals(contributedLabel, labelField.get(item));
+ assertNotNull(iconField.get(item));
+
+ UpdatingHandler handler1 = new UpdatingHandler(text1);
+ activation1 = handlerService.activateHandler(CMD3_ID, handler1, new ActiveContextExpression(CONTEXT_TEST1,
+ new String[] { ISources.ACTIVE_CONTEXT_NAME }));
+ UpdatingHandler handler2 = new UpdatingHandler(text2);
+ activation2 = handlerService.activateHandler(CMD3_ID, handler2, new ActiveContextExpression(CONTEXT_TEST2,
+ new String[] { ISources.ACTIVE_CONTEXT_NAME }));
+
+ contextActivation1 = contextService.activateContext(CONTEXT_TEST1);
+ assertEquals(handler1, cmd3.getHandler());
+ assertEquals(text1, labelField.get(item));
+ assertNotNull(iconField.get(item));
+
+ contextService.deactivateContext(contextActivation1);
+ // back to default handler state
+ assertTrue(cmd3.getHandler() instanceof HandlerProxy);
+ assertEquals(contributedLabel, labelField.get(item));
+ assertNotNull(iconField.get(item));
+
+ contextActivation2 = contextService.activateContext(CONTEXT_TEST2);
+ assertEquals(handler2, cmd3.getHandler());
+ assertEquals(text2, labelField.get(item));
+ assertNotNull(iconField.get(item));
+
+ // activate both context
+ contextActivation1 = contextService.activateContext(CONTEXT_TEST1);
+
+ // both handler activations eval to true, no handler set
+ assertNull(cmd3.getHandler());
+ assertEquals(contributedLabel, labelField.get(item));
+ assertNotNull(iconField.get(item));
+
+ contextService.deactivateContext(contextActivation1);
+ contextService.deactivateContext(contextActivation2);
+
+ }
+
+
public void testEnablementForNormalHandlers() throws Exception {
activation1 = handlerService.activateHandler(CMD1_ID, normalHandler1,
new ActiveContextExpression(CONTEXT_TEST1,
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandParameterTypeTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandParameterTypeTest.java
index 4020fb1748..5914e479e2 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandParameterTypeTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandParameterTypeTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Benjamin Muskalla - bug 222861 [Commands] ParameterizedCommand#equals broken
*******************************************************************************/
package org.eclipse.ui.tests.commands;
@@ -18,6 +19,7 @@ import org.eclipse.core.commands.ParameterValueConversionException;
import org.eclipse.core.commands.Parameterization;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.commands.common.CommandException;
+import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.tests.harness.util.UITestCase;
@@ -264,4 +266,31 @@ public class CommandParameterTypeTest extends UITestCase {
}
return null;
}
+
+ /**
+ * Test {@link ParameterizedCommand}, making sure the order of
+ * the parameters is not important.
+ */
+ public void testUnrelevantOrder() throws NotDefinedException {
+ ICommandService commandService = getCommandService();
+ Command command = commandService.getCommand(SUBTRACT);
+
+ IParameter sub = command.getParameter(SUBTRAHEND);
+ IParameter min = command.getParameter(MINUEND);
+ Parameterization param1 = new Parameterization(sub, "5");
+ Parameterization param2 = new Parameterization(min, "3");
+
+ Parameterization[] params = new Parameterization[2];
+ params[0] = param1;
+ params[1] = param2;
+
+ Parameterization[] params1 = new Parameterization[2];
+ params1[0] = param2;
+ params1[1] = param1;
+
+ ParameterizedCommand pCommand1 = new ParameterizedCommand(command, params);
+ ParameterizedCommand pCommand2 = new ParameterizedCommand(command, params1);
+
+ assertTrue(pCommand1.equals(pCommand2));
+ }
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandsTestSuite.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandsTestSuite.java
index f46d7ca964..67939e2dc3 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandsTestSuite.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandsTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * Copyright (c) 2003, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -46,5 +46,7 @@ public final class CommandsTestSuite extends TestSuite {
addTest(new TestSuite(CommandEnablementTest.class));
addTest(new TestSuite(CommandActionTest.class));
// addTest(new TestSuite(ActionDelegateProxyTest.class));
+ addTest(new TestSuite(ToggleStateTest.class));
+ addTest(new TestSuite(RadioStateTest.class));
}
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/EditorActionDelegate.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/EditorActionDelegate.java
new file mode 100644
index 0000000000..449a3d49a0
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/EditorActionDelegate.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.tests.commands;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * @since 3.5
+ *
+ */
+public class EditorActionDelegate implements IEditorActionDelegate {
+
+ static boolean executed = false;
+ static IEditorPart part = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
+ */
+ public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+ part = targetEditor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ executed = true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ExceptionThrowingHandler.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ExceptionThrowingHandler.java
new file mode 100644
index 0000000000..ca7ca340a4
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ExceptionThrowingHandler.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+/**
+ * @since 3.5
+ * @author Prakash G.R.
+ *
+ */
+public class ExceptionThrowingHandler extends AbstractHandler{
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ throw new ExecutionException("");
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HandlerActivationTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HandlerActivationTest.java
index 33c0a625be..badbfa5136 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HandlerActivationTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HandlerActivationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,7 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.ui.tests.commands;
@@ -260,6 +260,19 @@ public class HandlerActivationTest extends UITestCase {
CMD_ID, currentHandler, expression));
}
+
+ public void testExceptionThrowingHandler(){
+
+ try {
+ handlerService.executeCommand("org.eclipse.ui.tests.command.handlerException", null);
+ fail("An exception should be thrown for this handler");
+ } catch (Exception e) {
+ if(!(e instanceof ExecutionException))
+ fail("Unexpected exception while executing command", e);
+ }
+ }
+
+
public void testBasicHandler() throws Exception {
createHandlerActivation(C1_ID, H1,
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HelpContextIdTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HelpContextIdTest.java
index 52a5bc7674..62aa3eada1 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HelpContextIdTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HelpContextIdTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 2006, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,7 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.ui.tests.commands;
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/RadioStateHandler.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/RadioStateHandler.java
new file mode 100644
index 0000000000..cc4504ce5c
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/RadioStateHandler.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.handlers.RadioState;
+
+/**
+ * @since 3.5
+ * @author Prakash G.R.
+ */
+public class RadioStateHandler extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ if(HandlerUtil.matchesRadioState(event))
+ return null; // do nothing when we are in right state
+
+ // else update the state
+ String currentState = event.getParameter(RadioState.PARAMETER_ID);
+ HandlerUtil.updateRadioState(event.getCommand(), currentState);
+
+ return null;
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/RadioStateTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/RadioStateTest.java
new file mode 100644
index 0000000000..d8663c7a27
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/RadioStateTest.java
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.tests.commands;
+
+import org.eclipse.core.commands.Command;
+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;
+
+/**
+ * @since 3.5
+ * @author Prakash G.R.
+ *
+ */
+public class RadioStateTest extends UITestCase {
+
+ private ICommandService commandService;
+ private IHandlerService handlerService;
+
+ public RadioStateTest(String testName) {
+ super(testName);
+ }
+
+ protected void doSetUp() throws Exception {
+ super.doSetUp();
+ commandService = (ICommandService) fWorkbench
+ .getService(ICommandService.class);
+ handlerService = (IHandlerService) fWorkbench
+ .getService(IHandlerService.class);
+ }
+
+ public void testRadioValues() throws Exception {
+
+ Command command1 = commandService
+ .getCommand("org.eclipse.ui.tests.radioStateCommand1");
+
+ // check the initial values
+ assertState(command1, "value2");
+
+ // execute with value1
+ Parameterization radioParam = new Parameterization(command1
+ .getParameter(RadioState.PARAMETER_ID), "value1");
+ ParameterizedCommand parameterizedCommand = new ParameterizedCommand(
+ command1, new Parameterization[] { radioParam });
+ handlerService.executeCommand(parameterizedCommand, null);
+
+ // check if updated
+ assertState(command1, "value1");
+
+ handlerService.executeCommand(parameterizedCommand, null);
+ assertState(command1, "value1");
+
+ Parameterization radioParam2 = new Parameterization(command1
+ .getParameter(RadioState.PARAMETER_ID), "value2");
+ ParameterizedCommand parameterizedCommand2 = new ParameterizedCommand(
+ command1, new Parameterization[] { radioParam2 });
+ 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();
+ assertTrue(value instanceof String);
+ assertEquals(expectedValue, value);
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/SimplyGoActionDelegate.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/SimplyGoActionDelegate.java
new file mode 100644
index 0000000000..299f76c3e6
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/SimplyGoActionDelegate.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.tests.commands;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+/**
+ * @since 3.5
+ *
+ */
+public class SimplyGoActionDelegate implements IWorkbenchWindowActionDelegate {
+ static boolean executed = false;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+ */
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void init(IWorkbenchWindow window) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ executed = true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/StateTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/StateTest.java
index fb7c449ee6..5e6f2881a6 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/StateTest.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/StateTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,7 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.ui.tests.commands;
@@ -17,9 +17,14 @@ import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.IStateListener;
import org.eclipse.core.commands.State;
import org.eclipse.core.commands.common.CommandException;
+import org.eclipse.jface.commands.PersistentState;
+import org.eclipse.jface.menus.TextState;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerActivation;
import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.handlers.RegistryRadioState;
+import org.eclipse.ui.tests.TestPlugin;
import org.eclipse.ui.tests.harness.util.UITestCase;
/**
@@ -29,10 +34,16 @@ import org.eclipse.ui.tests.harness.util.UITestCase;
*/
public class StateTest extends UITestCase {
+ /**
+ *
+ */
+ private static final String TEXT_HELLO = "hello";
+
private static final class ObjectStateHandler extends
AbstractHandlerWithState {
Object currentValue;
+ String textValue;
public final Object execute(final ExecutionEvent event) {
getState(OBJECT_STATE_ID).setValue(OBJECT_CHANGED);
@@ -43,18 +54,23 @@ public class StateTest extends UITestCase {
final Object oldValue) {
if (OBJECT_STATE_ID.equals(state.getId())) {
currentValue = state.getValue();
+ } else if (TEXT_STATE_ID.equals(state.getId())) {
+ textValue = (String) state.getValue();
}
}
}
private static final class StateListener implements IStateListener {
Object currentValue;
+ String textValue;
public final void handleStateChange(final State state,
final Object oldValue) {
if (OBJECT_STATE_ID.equals(state.getId())) {
currentValue = state.getValue();
+ } else if (TEXT_STATE_ID.equals(state.getId())) {
+ textValue = (String) state.getValue();
}
}
}
@@ -80,6 +96,11 @@ public class StateTest extends UITestCase {
private static final String OBJECT_STATE_ID = "OBJECT";
/**
+ * The identifier of the state storing some text.
+ */
+ private static final String TEXT_STATE_ID = "TEXT";
+
+ /**
* The object state handler.
*/
private ObjectStateHandler handler;
@@ -105,6 +126,7 @@ public class StateTest extends UITestCase {
.getService(ICommandService.class);
final Command command = commandService.getCommand(COMMAND_ID);
command.getState(OBJECT_STATE_ID).setValue(OBJECT_INITIAL);
+ command.getState(TEXT_STATE_ID).setValue(null);
// Register the object state handler.
handler = new ObjectStateHandler();
@@ -208,5 +230,65 @@ public class StateTest extends UITestCase {
"The state on the command after the handler changed was not correct",
OBJECT_CHANGED, handler.currentValue);
}
+
+ public final void testTextState() {
+ assertNull(handler.textValue);
+ final ICommandService commandService = (ICommandService) fWorkbench
+ .getService(ICommandService.class);
+ final Command command = commandService.getCommand(COMMAND_ID);
+ command.getState(TEXT_STATE_ID).setValue(TEXT_HELLO);
+ assertEquals(TEXT_HELLO, handler.textValue);
+ }
+
+ public final void testTextStateListener() {
+ assertNull(handler.textValue);
+ final ICommandService commandService = (ICommandService) fWorkbench
+ .getService(ICommandService.class);
+ final Command command = commandService.getCommand(COMMAND_ID);
+ State state = command.getState(TEXT_STATE_ID);
+ final StateListener listener = new StateListener();
+ assertNull(state.getValue());
+ assertNull(listener.textValue);
+ assertNull(handler.textValue);
+
+ state.addListener(listener);
+ state.setValue(TEXT_HELLO);
+ assertEquals(TEXT_HELLO, handler.textValue);
+ assertEquals(TEXT_HELLO, listener.textValue);
+ }
+
+ public final void testTextPreference() {
+ final ICommandService commandService = (ICommandService) fWorkbench
+ .getService(ICommandService.class);
+ final Command command = commandService.getCommand(COMMAND_ID);
+ State state = command.getState(TEXT_STATE_ID);
+ state.setValue(TEXT_HELLO);
+ assertTrue(state instanceof PersistentState);
+ PersistentState pstate = (PersistentState) state;
+ IPreferenceStore preferenceStore = TestPlugin.getDefault().getPreferenceStore();
+ pstate.save(preferenceStore, COMMAND_ID
+ + "." + TEXT_STATE_ID);
+ TextState nstate = new TextState();
+ assertNull(nstate.getValue());
+ nstate.load(preferenceStore, COMMAND_ID
+ + "." + TEXT_STATE_ID);
+ assertEquals(TEXT_HELLO, nstate.getValue());
+ }
+
+ public final void testRadioState() {
+ RegistryRadioState state1 = new RegistryRadioState();
+ state1.setInitializationData(null, "class", COMMAND_ID);
+ assertEquals(Boolean.FALSE, state1.getValue());
+ RegistryRadioState state2 = new RegistryRadioState();
+ state2.setInitializationData(null, "class", COMMAND_ID);
+ assertEquals(Boolean.FALSE, state2.getValue());
+
+ state1.setValue(Boolean.TRUE);
+ assertEquals(Boolean.TRUE, state1.getValue());
+ assertEquals(Boolean.FALSE, state2.getValue());
+
+ state2.setValue(Boolean.TRUE);
+ assertEquals(Boolean.FALSE, state1.getValue());
+ assertEquals(Boolean.TRUE, state2.getValue());
+ }
}
-
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ToggleStateHandler.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ToggleStateHandler.java
new file mode 100644
index 0000000000..fabcd77891
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ToggleStateHandler.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class ToggleStateHandler extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ boolean oldValue = HandlerUtil.toggleCommandState(event.getCommand());
+ return new Boolean(oldValue);
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ToggleStateTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ToggleStateTest.java
new file mode 100644
index 0000000000..e310d29b80
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ToggleStateTest.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.tests.commands;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionException;
+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.RegistryToggleState;
+import org.eclipse.ui.menus.UIElement;
+import org.eclipse.ui.services.IServiceLocator;
+import org.eclipse.ui.tests.harness.util.UITestCase;
+
+/**
+ * @since 3.5
+ * @author Prakash G.R.
+ *
+ */
+public class ToggleStateTest extends UITestCase {
+
+ private ICommandService commandService;
+ private IHandlerService handlerService;
+
+
+ public ToggleStateTest(String testName) {
+ super(testName);
+ }
+
+
+ protected void doSetUp() throws Exception {
+ super.doSetUp();
+ commandService = (ICommandService) fWorkbench.getService(ICommandService.class);
+ handlerService = (IHandlerService) fWorkbench.getService(IHandlerService.class);
+ }
+
+ public void testDefaultValues() throws Exception {
+
+ Command command1 = commandService.getCommand("org.eclipse.ui.tests.toggleStateCommand1");
+ Command command2 = commandService.getCommand("org.eclipse.ui.tests.toggleStateCommand2");
+
+ // check the initial values
+ assertState(command1, true);
+ assertState(command2, false);
+
+ // execute and check the values have changed or not
+ handlerService.executeCommand(command1.getId(), null);
+ handlerService.executeCommand(command2.getId(), null);
+
+ assertState(command1, false);
+ assertState(command2, true);
+
+ }
+
+ public void testExceptionThrown() throws Exception {
+
+ Command command3 = commandService.getCommand("org.eclipse.ui.tests.toggleStateCommand3");
+ try {
+ handlerService.executeCommand(command3.getId(), null);
+ fail("Command3 doesn't have any state. An exception must be thrown from the handler, when trying to change that");
+ } catch (Exception e) {
+ if(!(e instanceof ExecutionException))
+ throw e;
+ }
+ }
+
+ 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;
+ }
+
+ }
+
+ public void testMultipleContributions() throws Exception{
+
+ Command command1 = commandService.getCommand("org.eclipse.ui.tests.toggleStateCommand1");
+ ParameterizedCommand parameterizedCommand = new ParameterizedCommand(command1, new Parameterization[0]);
+
+ MyUIElement element1 = new MyUIElement(fWorkbench);
+ MyUIElement element2 = new MyUIElement(fWorkbench);
+
+ IElementReference reference1 = commandService.registerElementForCommand(parameterizedCommand, element1);
+ IElementReference reference2 = commandService.registerElementForCommand(parameterizedCommand, element2);
+
+ try{
+
+ commandService.refreshElements(command1.getId(), null);
+ assertEquals(element1.isChecked(), element2.isChecked());
+
+ Boolean oldValue = (Boolean) handlerService.executeCommand(command1.getId(), null);
+ //value should have changed
+ assertEquals(!oldValue.booleanValue(), element1.isChecked());
+ //and changed in both places
+ assertEquals(element1.isChecked(), element2.isChecked());
+
+ }finally {
+ commandService.unregisterElement(reference1);
+ commandService.unregisterElement(reference2);
+ }
+
+ }
+
+ private void assertState(Command command1, boolean expectedValue) {
+ State state = command1.getState(RegistryToggleState.STATE_ID);
+ Object value = state.getValue();
+ assertTrue(value instanceof Boolean);
+ assertEquals(expectedValue, ((Boolean)value).booleanValue());
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/Bug_262032.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/Bug_262032.java
new file mode 100644
index 0000000000..6e588e28fa
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/Bug_262032.java
@@ -0,0 +1,117 @@
+///*******************************************************************************
+// * Copyright (c) 2010 Broadcom Corporation and others.
+// * All rights reserved. This program and the accompanying materials
+// * are 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
+// *
+// * Contributors:
+// * James Blackburn (Broadcom Corp.) - initial API and implementation
+// *******************************************************************************/
+//package org.eclipse.ui.tests.concurrency;
+//
+//import junit.framework.Test;
+//import junit.framework.TestCase;
+//import junit.framework.TestSuite;
+//
+//import org.eclipse.core.runtime.IProgressMonitor;
+//import org.eclipse.core.runtime.IStatus;
+//import org.eclipse.core.runtime.Status;
+//import org.eclipse.core.runtime.jobs.ILock;
+//import org.eclipse.core.runtime.jobs.ISchedulingRule;
+//import org.eclipse.core.runtime.jobs.Job;
+//import org.eclipse.core.tests.harness.TestBarrier;
+//import org.eclipse.swt.widgets.Display;
+//
+///**
+// * Test for an issue where a lock, held by the UI thread
+// * is released while the UI thread is actually performing work
+// * having acquired it...
+// */
+//public class Bug_262032 extends TestCase {
+//
+// ISchedulingRule identityRule = new ISchedulingRule() {
+// public boolean isConflicting(ISchedulingRule rule) {
+// return rule == this;
+// }
+// public boolean contains(ISchedulingRule rule) {
+// return rule == this;
+// }
+// };
+//
+// public static Test suite() {
+// return new TestSuite(Bug_262032.class);
+// }
+//
+// volatile boolean concurrentAccess = false;
+//
+// /**
+// * Threads: UI(+asyncExec), j
+// * Locks: lock, IDRule
+// *
+// * j holds identity Rule
+// * ui tries to acquire rule => block and performs asyncMessages
+// * asyncExec run and acquire()s lock
+// * j then attempts to acquire lock.
+// *
+// * Deadlock manager believes that UI is waiting for IDrule while holding
+// * lock, and Job holds IDRule while attempting lock. Scheduling rules
+// * are never released by the Deadlock detector, so the lock is yielded!
+// *
+// * The expectation is that when threads are 'waiting' they're sat
+// * in the ordered lock acquire which can give the locks safely to whoever
+// * is deemed to need it. In this case that's not true as the UI
+// * is running an async exec.
+// *
+// * The result is concurrent running in a locked region.
+// */
+// public void testBug262032() {
+// final ILock lock = Job.getJobManager().newLock();
+// final TestBarrier tb1 = new TestBarrier(-1);
+//
+// // Job hols scheduling rule
+// Job j = new Job ("Deadlocking normal Job") {
+// protected IStatus run(IProgressMonitor monitor) {
+// tb1.setStatus(TestBarrier.STATUS_WAIT_FOR_START);
+// tb1.waitForStatus(TestBarrier.STATUS_RUNNING);
+// lock.acquire();
+// //test that we haven't both acquired the lock...
+// assertTrue(!concurrentAccess);
+// lock.release();
+//
+// tb1.setStatus(TestBarrier.STATUS_WAIT_FOR_DONE);
+// return Status.OK_STATUS;
+// };
+// };
+// j.setRule(identityRule);
+// j.schedule();
+//
+// // Wait for the job with scheduling rule to start
+// tb1.waitForStatus(TestBarrier.STATUS_WAIT_FOR_START);
+//
+// // asyncExec job that wants the lock
+// Display.getDefault().asyncExec(new Runnable() {
+// public void run() {
+// lock.acquire();
+// concurrentAccess = true;
+// tb1.setStatus(TestBarrier.STATUS_RUNNING);
+// // Sleep to test for concurrent access
+// try {
+// Thread.sleep(1000); } catch (InterruptedException e) {/*don't care*/}
+// concurrentAccess = false;
+// lock.release();
+// }
+// });
+//
+// // This will block, but the UI will continue to service async requests...
+// Job.getJobManager().beginRule(identityRule, null);
+// Job.getJobManager().endRule(identityRule);
+//
+// try {
+// j.join();
+// tb1.waitForStatus(TestBarrier.STATUS_WAIT_FOR_DONE);
+// assertEquals(Status.OK_STATUS, j.getResult());
+// } catch (InterruptedException e) {fail();}
+// }
+//
+//}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/ConcurrencyTestSuite.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/ConcurrencyTestSuite.java
index 473a8603bd..672e08c588 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/ConcurrencyTestSuite.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/ConcurrencyTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,7 +15,7 @@ import junit.framework.TestSuite;
/**
* The suite of tests related to concurrency and deadlock.
- *
+ *
* @since 3.1
*/
public final class ConcurrencyTestSuite extends TestSuite {
@@ -32,10 +32,15 @@ public final class ConcurrencyTestSuite extends TestSuite {
* the relevant test cases.
*/
public ConcurrencyTestSuite() {
-// addTestSuite(NestedSyncExecDeadlockTest.class);
-// addTestSuite(TestBug98621.class);
+ addTestSuite(ModalContextCrashTest.class);
+// addTestSuite(NestedSyncExecDeadlockTest.class);
+// addTestSuite(SyncExecWhileUIThreadWaitsForRuleTest.class);
+// addTestSuite(SyncExecWhileUIThreadWaitsForLock.class);
+// addTestSuite(TestBug105491.class);
// addTestSuite(TestBug108162.class);
addTestSuite(TestBug138695.class);
+// addTestSuite(TestBug98621.class);
addTestSuite(TransferRuleTest.class);
+// addTestSuite(Bug_262032.class);
}
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/ModalContextCrashTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/ModalContextCrashTest.java
new file mode 100644
index 0000000000..2157f1c87c
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/ModalContextCrashTest.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.concurrency;
+
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.operation.IThreadListener;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Makes ModalContext thread crash and hang the IDE
+ */
+public class ModalContextCrashTest extends TestCase {
+
+ public void testCrash() throws Exception {
+ IRunnableWithProgress operation = new CrashingRunnable();
+ try{
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(true, false, operation);
+ fail("Should have an invocation target exception");
+ }
+ catch (InvocationTargetException e){
+ //We should get this
+ }
+ }
+
+ private static final class CrashingRunnable implements IRunnableWithProgress, IThreadListener {
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ }
+
+ public void threadChange(Thread thread) {
+ // only throw the exception in the finally block
+ // of ModalContextThread
+ if (Display.findDisplay(thread) != null)
+ throw new RuntimeException("Simulated exception during threadChange");
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/SyncExecWhileUIThreadWaitsForLock.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/SyncExecWhileUIThreadWaitsForLock.java
new file mode 100644
index 0000000000..5c9a08113d
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/SyncExecWhileUIThreadWaitsForLock.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.tests.concurrency;
+
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.core.runtime.jobs.ILock;
+
+import org.eclipse.core.runtime.jobs.Job;
+
+import junit.framework.TestCase;
+
+/**
+ * This tests the simple traditional deadlock of a thread holding a lock trying
+ * to perform a syncExec, while the UI thread is waiting for that lock.
+ * UISynchronizer and UILockListener conspire to prevent deadlock in this case.
+ */
+public class SyncExecWhileUIThreadWaitsForLock extends TestCase {
+ public void testDeadlock() {
+ final ILock lock = Job.getJobManager().newLock();
+ final boolean[] blocked = new boolean[] {false};
+ final boolean[] lockAcquired= new boolean[] {false};
+ Thread locking = new Thread("SyncExecWhileUIThreadWaitsForLock") {
+ public void run() {
+ try {
+ //first make sure this background thread owns the lock
+ lock.acquire();
+ //spawn an asyncExec that will cause the UI thread to be blocked
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ blocked[0] = true;
+ lock.acquire();
+ lock.release();
+ blocked[0] = false;
+ }
+ });
+ //wait until the UI thread is blocked waiting for the lock
+ while (!blocked[0]) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ }
+ }
+ //now attempt to do a syncExec that also acquires the lock
+ //this should succeed even while the above asyncExec is blocked, thanks to UISynchronizer
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ try {
+ //use a timeout to avoid deadlock in case of regression
+ if (lock.acquire(60000)) {
+ //this flag is used to verify that we actually acquired the lock
+ lockAcquired[0] = true;
+ lock.release();
+ }
+ } catch (InterruptedException e) {
+ }
+ }
+ });
+ } finally {
+ lock.release();
+ }
+ }
+ };
+ locking.start();
+ //wait until we succeeded to acquire the lock in the UI thread
+ long waitStart = System.currentTimeMillis();
+ Display display = Display.getDefault();
+ while (!lockAcquired[0]) {
+ //spin event loop so that asyncExed above gets run
+ if (!display.readAndDispatch())
+ display.sleep();
+ //if we waited too long, fail the test
+ if (System.currentTimeMillis()-waitStart > 60000)
+ assertTrue("Deadlock occurred", false);
+ }
+ //if we get here, the test succeeded
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/SyncExecWhileUIThreadWaitsForRuleTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/SyncExecWhileUIThreadWaitsForRuleTest.java
new file mode 100644
index 0000000000..426266d0e2
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/concurrency/SyncExecWhileUIThreadWaitsForRuleTest.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.tests.concurrency;
+
+import junit.framework.TestCase;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * This tests the simple traditional deadlock of a thread holding a scheduling rule trying
+ * to perform a syncExec, while the UI thread is waiting for that scheduling rule.
+ * UISynchronizer and UILockListener conspire to prevent deadlock in this case.
+ * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=296056.
+ */
+public class SyncExecWhileUIThreadWaitsForRuleTest extends TestCase {
+ class TestRule implements ISchedulingRule {
+ public boolean contains(ISchedulingRule rule) {
+ return rule == this;
+ }
+
+ public boolean isConflicting(ISchedulingRule rule) {
+ return rule == this;
+ }
+ }
+
+ public void testDeadlock() {
+ final ISchedulingRule rule = new TestRule();
+ final boolean[] blocked = new boolean[] {false};
+ final boolean[] lockAcquired = new boolean[] {false};
+ final SubMonitor beginRuleMonitor = SubMonitor.convert(null);
+ Thread locking = new Thread("SyncExecWhileUIThreadWaitsForRuleTest") {
+ public void run() {
+ try {
+ //first make sure this background thread owns the lock
+ Job.getJobManager().beginRule(rule, null);
+ //spawn an asyncExec that will cause the UI thread to be blocked
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ blocked[0] = true;
+ Job.getJobManager().beginRule(rule, beginRuleMonitor);
+ Job.getJobManager().endRule(rule);
+ blocked[0] = false;
+ }
+ });
+ //wait until the UI thread is blocked waiting for the lock
+ while (!blocked[0]) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ //now attempt to do a syncExec that also acquires the lock
+ //this should succeed even while the above asyncExec is blocked, thanks to UISynchronizer
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ //use a timeout to avoid deadlock in case of regression
+ Job.getJobManager().beginRule(rule, null);
+ lockAcquired[0] = true;
+ Job.getJobManager().endRule(rule);
+ }
+ });
+ } finally {
+ Job.getJobManager().endRule(rule);
+ }
+ }
+ };
+ locking.start();
+ //create a thread that will cancel the monitor after 60 seconds so we don't hang the tests
+ final long waitStart = System.currentTimeMillis();
+ Thread canceler = new Thread("Canceler") {
+ public void run() {
+ while (true) {
+ if (System.currentTimeMillis() - waitStart > 60000) {
+ beginRuleMonitor.setCanceled(true);
+ break;
+ }
+ }
+
+ }
+ };
+ canceler.start();
+ //wait until we succeeded to acquire the lock in the UI thread
+ Display display = Display.getDefault();
+ while (!lockAcquired[0]) {
+ //spin event loop so that asyncExed above gets run
+ try {
+ if (!display.readAndDispatch())
+ display.sleep();
+ } catch (SWTException e) {
+ fail("Deadlock occurred");
+ }
+ }
+ //if the monitor was canceled then we got a deadlock
+ assertFalse("deadlock occurred", beginRuleMonitor.isCanceled());
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/DataTransferTestSuite.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/DataTransferTestSuite.java
index 598d44121c..c66a590539 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/DataTransferTestSuite.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/DataTransferTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorsTestSuite.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorsTestSuite.java
index ebee5e4a00..878c357627 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorsTestSuite.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorsTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,12 +27,12 @@ public class DecoratorsTestSuite extends TestSuite {
* Construct the test suite.
*/
public DecoratorsTestSuite() {
- addTest(new TestSuite(ExceptionDecoratorTestCase.class));
+// addTest(new TestSuite(ExceptionDecoratorTestCase.class));
addTest(new TestSuite(DecoratorTestCase.class));
addTest(new TestSuite(LightweightDecoratorTestCase.class));
addTest(new TestSuite(BadIndexDecoratorTestCase.class));
- addTest(new TestSuite(DecoratorTreeTest.class));
- addTest(new TestSuite(DecoratorTableTest.class));
+// addTest(new TestSuite(DecoratorTreeTest.class));
+// addTest(new TestSuite(DecoratorTableTest.class));
// addTest(new TestSuite(DecoratorTableTreeTest.class));
addTest(new TestSuite(DecoratorAdaptableTests.class));
// addTest(new TestSuite(DecoratorCacheTest.class));
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIDialogs.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIDialogs.java
index 4bca0c21a1..061175c3f9 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIDialogs.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIDialogs.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -159,6 +159,18 @@ public class UIDialogs extends TestCase {
// DialogCheck.assertDialog(dialog, this);
// }
+// // see bug 211350
+// public void testLoadNotExistingPerspective() throws IOException{
+// final String fakePerspectivID = "fakeperspetive";
+// PerspectiveRegistry reg = (PerspectiveRegistry) WorkbenchPlugin
+// .getDefault().getPerspectiveRegistry();
+// try {
+// reg.getCustomPersp(fakePerspectivID);
+// } catch (WorkbenchException e) {
+// assertTrue(e.getStatus().getMessage().indexOf(fakePerspectivID) != -1);
+// }
+// }
+
public void testSelectPerspective() {
Dialog dialog = new SelectPerspectiveDialog(getShell(), PlatformUI
.getWorkbench().getPerspectiveRegistry());
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIDialogsAuto.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIDialogsAuto.java
index 4ef4395402..5e1b7ab10d 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIDialogsAuto.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIDialogsAuto.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -82,6 +82,12 @@ public class UIDialogsAuto extends TestCase {
// DialogCheck.assertDialogTexts(dialog, this);
// }
+// public void testCopyMoveResource() {
+// Dialog dialog = new ContainerSelectionDialog(getShell(), null, true,
+// "Copy Resources");
+// DialogCheck.assertDialogTexts(dialog, this);
+// }
+
public void testEditActionSetsDialog() {
// @issue need to uncomment this once customize persp dialog fixed up
/*
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ActionSetTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ActionSetTests.java
index c77346090d..4e171cc1ce 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ActionSetTests.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ActionSetTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicContributionTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicContributionTest.java
new file mode 100644
index 0000000000..a90ed90f16
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicContributionTest.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.tests.dynamicplugins;
+
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
+import org.eclipse.ui.internal.util.BundleUtility;
+import org.eclipse.ui.menus.IMenuService;
+
+/**
+ * @since 3.5
+ */
+public class DynamicContributionTest extends DynamicTestCase {
+
+ public DynamicContributionTest(String testName) {
+ super(testName);
+ }
+
+ public void testMenuContribution() throws Exception {
+ IWorkbenchWindow window = openTestWindow();
+ IMenuService menus = (IMenuService) window
+ .getService(IMenuService.class);
+ MenuManager manager = new MenuManager();
+ try {
+ menus.populateContributionManager(manager,
+ "popup:org.eclipse.newDynamicMenuContribution");
+ assertEquals(0, manager.getSize());
+ getBundle();
+ assertEquals(1, manager.getSize());
+ assertFalse(BundleUtility
+ .isActive("org.eclipse.newDynamicMenuContribution"));
+ manager.createContextMenu(window.getShell());
+ manager.updateAll(true);
+ assertTrue(BundleUtility
+ .isActive("org.eclipse.newDynamicMenuContribution"));
+ } finally {
+ menus.releaseContributions(manager);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.tests.dynamicplugins.DynamicTestCase#getExtensionId()
+ */
+ protected String getExtensionId() {
+ return "menu.dynamic.contribution";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.tests.dynamicplugins.DynamicTestCase#getExtensionPoint()
+ */
+ protected String getExtensionPoint() {
+ return IWorkbenchRegistryConstants.PL_MENUS;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.tests.dynamicplugins.DynamicTestCase#getInstallLocation()
+ */
+ protected String getInstallLocation() {
+ return "data/org.eclipse.newDynamicMenuContribution";
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicInvalidContributionTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicInvalidContributionTest.java
new file mode 100644
index 0000000000..06f8f38ae8
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicInvalidContributionTest.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.tests.dynamicplugins;
+
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
+
+/**
+ * @since 3.5
+ */
+public class DynamicInvalidContributionTest extends DynamicTestCase {
+
+ public DynamicInvalidContributionTest(String testName) {
+ super(testName);
+ }
+
+ public void testInvalidMenuContribution() throws Exception {
+ // open a window
+ IWorkbenchWindow window = openTestWindow();
+ // start up our bundle
+ getBundle();
+ // open another window, now that our invalid contribution is there, it
+ // should be parsed and loaded, this ensures the workbench window can
+ // still go up even if someone is contributing an invalid contribution
+ fWorkbench.openWorkbenchWindow(window.getActivePage().getPerspective().getId(), null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.tests.dynamicplugins.DynamicTestCase#getExtensionId()
+ */
+ protected String getExtensionId() {
+ return "menu.invalid.menu.contribution";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.tests.dynamicplugins.DynamicTestCase#getExtensionPoint()
+ */
+ protected String getExtensionPoint() {
+ return IWorkbenchRegistryConstants.PL_MENUS;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.tests.dynamicplugins.DynamicTestCase#getInstallLocation()
+ */
+ protected String getInstallLocation() {
+ return "data/org.eclipse.newInvalidMenuContribution1";
+ }
+
+}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicPluginsTestSuite.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicPluginsTestSuite.java
index f5fee13198..67850b61d3 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicPluginsTestSuite.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicPluginsTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -56,5 +56,7 @@ public class DynamicPluginsTestSuite extends TestSuite {
addTest(new TestSuite(ObjectContributionTests.class));
addTest(new TestSuite(WorkingSetTests.class));
addTest(new TestSuite(DynamicSupportTests.class));
+ addTest(new TestSuite(DynamicContributionTest.class));
+ addTest(new TestSuite(DynamicInvalidContributionTest.class));
}
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/EditorTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/EditorTests.java
index 8aee381fca..624e004b73 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/EditorTests.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/EditorTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,10 +21,10 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IEditorDescriptor;
//import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorRegistry;
+//import org.eclipse.ui.IEditorRegistry;
//import org.eclipse.ui.IWorkbenchWindow;
//import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.internal.WorkbenchPlugin;
+//import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
//import org.eclipse.ui.tests.leaks.LeakTests;
@@ -61,12 +61,12 @@ public class EditorTests extends DynamicTestCase {
protected String getInstallLocation() {
return "data/org.eclipse.newEditor1";
}
-
+
// public void testEditorClosure() throws CoreException {
// IWorkbenchWindow window = openTestWindow(IDE.RESOURCE_PERSPECTIVE_ID);
// IFile file = getFile();
// getBundle();
-//
+//
// ReferenceQueue queue = new ReferenceQueue();
// IEditorPart part = IDE.openEditor(window.getActivePage(), file, EDITOR_ID);
// WeakReference ref = new WeakReference(part, queue);
@@ -78,30 +78,38 @@ public class EditorTests extends DynamicTestCase {
// LeakTests.checkRef(queue, ref);
// } catch (Exception e) {
// fail(e.getMessage());
-// }
-//
-// assertEquals(0, window.getActivePage().getEditors().length);
+// }
+//
+// assertEquals(0, window.getActivePage().getEditors().length);
+// }
+
+// public void testEditorProperties() throws Exception {
+// IEditorRegistry registry = WorkbenchPlugin.getDefault().getEditorRegistry();
+//
+// assertNull(registry.findEditor(EDITOR_ID));
+// getBundle();
+//
+// IFile file = getFile("test.xml");
+// IContentType contentType = IDE.getContentType(file);
+// IEditorDescriptor desc = registry.findEditor(EDITOR_ID);
+// assertNotNull(desc);
+//
+// testEditorProperties(desc);
+//
+// IEditorDescriptor descriptor = registry.getDefaultEditor(file.getName(), contentType);
+// // should not get our editor since it is not the default
+// assertFalse(desc.equals(descriptor));
+//
+// removeBundle();
+// assertNull(registry.findEditor(EDITOR_ID));
+// try {
+// testEditorProperties(desc);
+// fail();
+// }
+// catch (RuntimeException e) {
+// }
// }
- public void testEditorProperties() {
- IEditorRegistry registry = WorkbenchPlugin.getDefault().getEditorRegistry();
-
- assertNull(registry.findEditor(EDITOR_ID));
- getBundle();
- IEditorDescriptor desc = registry.findEditor(EDITOR_ID);
- assertNotNull(desc);
-
- testEditorProperties(desc);
- removeBundle();
- assertNull(registry.findEditor(EDITOR_ID));
- try {
- testEditorProperties(desc);
- fail();
- }
- catch (RuntimeException e) {
- }
- }
-
/**
* @param desc
*/
@@ -111,21 +119,25 @@ public class EditorTests extends DynamicTestCase {
assertNotNull(desc.getImageDescriptor());
}
+ private IFile getFile() throws CoreException {
+ return getFile("someFile");
+ }
+
/**
- *
+ *
*/
- private IFile getFile() throws CoreException {
+ private IFile getFile(String fileName) throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject testProject = workspace.getRoot().getProject(getName());
testProject.create(null);
- testProject.open(null);
+ testProject.open(null);
- IFile iFile = testProject.getFile("someFile");
+ IFile iFile = testProject.getFile(fileName);
iFile.create(new ByteArrayInputStream(new byte[] { '\n' }), true, null);
return iFile;
- }
-
-
+ }
+
+
protected String getMarkerClass() {
return "org.eclipse.ui.dynamic.DynamicEditor";
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ViewTests.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ViewTests.java
index fe41110517..248c9ed2a3 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ViewTests.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/ViewTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,16 +13,15 @@ package org.eclipse.ui.tests.dynamicplugins;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
-import org.eclipse.core.commands.Command;
+//import org.eclipse.core.commands.Command;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.commands.ICommandService;
+//import org.eclipse.ui.commands.ICommandService;
//import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
-import org.eclipse.ui.internal.registry.ViewDescriptor;
import org.eclipse.ui.internal.registry.ViewRegistry;
import org.eclipse.ui.tests.leaks.LeakTests;
import org.eclipse.ui.views.IStickyViewDescriptor;
@@ -38,16 +37,16 @@ public class ViewTests extends DynamicTestCase {
private static final String VIEW_ID1 = "org.eclipse.newView1.newView1";
private static final String VIEW_ID2 = "org.eclipse.newView1.newView2";
private static final String CATEGORY_ID = "org.eclipse.newView1.newCategory1";
-
+
public ViewTests(String testName) {
super(testName);
}
-
+
public void testViewClosure() throws CoreException {
//IWorkbenchWindow window = openTestWindow(IDE.RESOURCE_PERSPECTIVE_ID);
IWorkbenchWindow window = openTestWindow(RESOURCE_PERSPECTIVE_ID);
getBundle();
-
+
ReferenceQueue queue = new ReferenceQueue();
IViewPart part = window.getActivePage().showView(VIEW_ID1);
// we need to ensure that the view is closed in all open perspectives but this is not currently possible.
@@ -61,139 +60,122 @@ public class ViewTests extends DynamicTestCase {
LeakTests.checkRef(queue, ref);
} catch (Exception e) {
fail(e.getMessage());
- }
-
- assertNull(window.getActivePage().findView(VIEW_ID1));
+ }
+
+ assertNull(window.getActivePage().findView(VIEW_ID1));
}
-
- /**
- * Tests to ensure that the showView handler is removed when the plugin is unloaded.
- */
- public void testHandlerRemoval() {
- IViewRegistry registry = WorkbenchPlugin.getDefault().getViewRegistry();
-
- assertNull(registry.find(VIEW_ID1));
- getBundle();
- ViewDescriptor desc = (ViewDescriptor) registry.find(VIEW_ID1);
- assertNotNull(desc);
- final ICommandService commandService = (ICommandService) fWorkbench.getAdapter(ICommandService.class);
- final Command command = commandService.getCommand(desc.getId());
- assertTrue(command.isHandled());
- removeBundle();
- assertFalse(command.isHandled());
- }
-
+
public void testViewWithoutCategory() {
IViewRegistry registry = WorkbenchPlugin.getDefault().getViewRegistry();
-
+
assertNull(registry.find(VIEW_ID2));
getBundle();
IViewDescriptor desc = registry.find(VIEW_ID2);
assertNotNull(desc);
-
+
testViewProperties(desc);
- removeBundle();
+ removeBundle();
assertNull(registry.find(VIEW_ID2));
try {
testViewProperties(desc);
- fail();
+ fail();
}
- catch (RuntimeException e) {
+ catch (RuntimeException e) {
// no-op
}
}
public void testViewWithCategory() {
IViewRegistry registry = WorkbenchPlugin.getDefault().getViewRegistry();
-
+
assertNull(registry.find(VIEW_ID1));
getBundle();
IViewDescriptor desc = registry.find(VIEW_ID1);
assertNotNull(desc);
-
+
testViewProperties(desc);
- removeBundle();
+ removeBundle();
assertNull(registry.find(VIEW_ID1));
try {
testViewProperties(desc);
- fail();
+ fail();
}
- catch (RuntimeException e) {
+ catch (RuntimeException e) {
// no-op
}
}
-
+
public void testStickyViewProperties() {
ViewRegistry registry = (ViewRegistry)WorkbenchPlugin.getDefault().getViewRegistry();
IStickyViewDescriptor [] descs = registry.getStickyViews();
for (int i = 0; i < descs.length; i++) {
assertFalse(VIEW_ID1.equals(descs[i].getId()));
}
-
+
getBundle();
-
+
descs = registry.getStickyViews();
IStickyViewDescriptor desc = null;
for (int i = 0; i < descs.length; i++) {
if (VIEW_ID1.equals(descs[i].getId())) {
desc = descs[i];
break;
- }
+ }
}
assertNotNull(desc);
testStickyViewProperties(desc);
- removeBundle();
-
+ removeBundle();
+
descs = registry.getStickyViews();
for (int i = 0; i < descs.length; i++) {
assertFalse(VIEW_ID1.equals(descs[i].getId()));
}
-
+
try {
testStickyViewProperties(desc);
- fail();
+ fail();
}
- catch (RuntimeException e) {
+ catch (RuntimeException e) {
// no-op
- }
+ }
}
-
+
private void testStickyViewProperties(IStickyViewDescriptor desc) {
assertNotNull(desc.getId());
assertFalse(desc.isMoveable());
assertFalse(desc.isCloseable());
- assertEquals(IPageLayout.BOTTOM, desc.getLocation());
+ assertEquals(IPageLayout.BOTTOM, desc.getLocation());
}
public void testCategoryViewContainmentProperties() {
ViewRegistry registry = (ViewRegistry)WorkbenchPlugin.getDefault().getViewRegistry();
-
+
assertNull(registry.find(VIEW_ID1));
assertNull(registry.findCategory(CATEGORY_ID));
getBundle();
-
+
IViewDescriptor desc = registry.find(VIEW_ID1);
- assertNotNull(desc);
+ assertNotNull(desc);
IViewCategory category = registry.findCategory(CATEGORY_ID);
assertNotNull(category);
-
+
testCategoryProperties(category);
assertTrue(category.getViews()[0] == desc);
- removeBundle();
+ removeBundle();
assertNull(registry.find(VIEW_ID1));
assertNull(registry.findCategory(CATEGORY_ID));
try {
testCategoryProperties(category);
fail();
}
- catch (RuntimeException e) {
+ catch (RuntimeException e) {
// no-op
}
-
- }
-
+
+ }
+
/**
* @param category
*/
@@ -211,8 +193,8 @@ public class ViewTests extends DynamicTestCase {
assertNotNull(desc.getLabel());
assertNotNull(desc.getImageDescriptor());
assertNotNull(desc.getDescription());
- }
-
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.tests.dynamicplugins.DynamicTestCase#getExtensionId()
*/
@@ -232,8 +214,8 @@ public class ViewTests extends DynamicTestCase {
*/
protected String getInstallLocation() {
return "data/org.eclipse.newView1";
- }
-
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.tests.dynamicplugins.DynamicTestCase#getMarkerClass()
*/
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/AbstractContentAssistCommandAdapterTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/AbstractContentAssistCommandAdapterTest.java
new file mode 100644
index 0000000000..e10fce3aea
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/AbstractContentAssistCommandAdapterTest.java
@@ -0,0 +1,114 @@
+///*******************************************************************************
+// * Copyright (c) 2009 Remy Chi Jian Suen and others.
+// * All rights reserved. This program and the accompanying materials
+// * are 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
+// *
+// * Contributors:
+// * Remy Chi Jian Suen <remy.suen@gmail.com> - initial API and implementation
+// * IBM - ongoing development
+//******************************************************************************/
+//
+//package org.eclipse.ui.tests.fieldassist;
+//
+//import org.eclipse.jface.tests.fieldassist.AbstractFieldAssistTestCase;
+//import org.eclipse.swt.SWT;
+//import org.eclipse.ui.IWorkbenchCommandConstants;
+//import org.eclipse.ui.PlatformUI;
+//import org.eclipse.ui.handlers.IHandlerService;
+//
+//public abstract class AbstractContentAssistCommandAdapterTest extends
+// AbstractFieldAssistTestCase {
+//
+// protected void executeContentAssistHandler() throws Exception {
+// // retrieve the content assist handler and run it
+// IHandlerService handlerService = (IHandlerService) PlatformUI
+// .getWorkbench().getService(IHandlerService.class);
+// handlerService.executeCommand(
+// IWorkbenchCommandConstants.EDIT_CONTENT_ASSIST, null);
+// }
+//
+// public void testHandlerPromptsPopup() throws Exception {
+// getFieldAssistWindow().open();
+//
+// sendFocusInToControl();
+// executeContentAssistHandler();
+//
+// assertTwoShellsUp();
+// }
+//
+// /**
+// * Tests that a ContentAssistCommandAdapter that has no autoactivation
+// * characters set will not have its proposals disappear when a user invokes
+// * content assist and then subsequently inserts a character that matches the
+// * first character of a suggested proposal.
+// * <p>
+// * <ol>
+// * <li>User invokes content assist</li>
+// * <li>"one", "two", "three"...shows up</li>
+// * <li>User hits the 'O' key</li>
+// * <li>The list shows up (the bug was reporting that the list disappeared)</li>
+// * </ol>
+// */
+// public void testBug271339EmptyAutoActivationCharacters() throws Exception {
+// getFieldAssistWindow().open();
+//
+// sendFocusInToControl();
+// executeContentAssistHandler();
+//
+// assertTwoShellsUp();
+//
+// sendKeyDownToControl('o');
+// assertTwoShellsUp();
+// }
+//
+// /**
+// * Tests that a ContentAssistCommandAdapter that has no autoactivation
+// * characters set will not have its proposals appear when a user inserts a
+// * character that matches the first character of a suggested proposal.
+// * <p>
+// * <ol>
+// * <li>User hits the 'O' key</li>
+// * <li>While "one" matches, the proposals should not appear as no
+// * autoactivation characters have been set</li>
+// * </ol>
+// */
+// public void testBug271339EmptyAutoActivationCharacters2() throws Exception {
+// getFieldAssistWindow().open();
+//
+// sendFocusInToControl();
+// sendKeyDownToControl('o');
+//
+// assertOneShellUp();
+// }
+//
+// /**
+// * Tests that a ContentAssistCommandAdapter that has no autoactivation
+// * characters set will stay open if the user backspaces over a narrowing
+// * proposal character.
+// * <p>
+// * <ol>
+// * <li>User invokes content assist</li>
+// * <li>"one", "two", "three"...shows up</li>
+// * <li>User hits the 'O' key</li>
+// * <li>The list narrows</li>
+// * <li>user hits backspace</li>
+// * <li>the popup should remain open</li>
+// * </ol>
+// */
+// public void testBug271339EmptyAutoActivationCharacters3() throws Exception {
+// getFieldAssistWindow().open();
+//
+// sendFocusInToControl();
+// executeContentAssistHandler();
+//
+// assertTwoShellsUp();
+//
+// sendKeyDownToControl('o');
+// assertTwoShellsUp();
+//
+// sendKeyDownToControl(SWT.BS);
+// assertTwoShellsUp();
+// }
+//}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/ComboCommandFieldAssistWindow.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/ComboCommandFieldAssistWindow.java
new file mode 100644
index 0000000000..e323130c6b
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/ComboCommandFieldAssistWindow.java
@@ -0,0 +1,28 @@
+///*******************************************************************************
+// * Copyright (c) 2009 Remy Chi Jian Suen and others.
+// * All rights reserved. This program and the accompanying materials
+// * are 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
+// *
+// * Contributors:
+// * Remy Chi Jian Suen <remy.suen@gmail.com> - initial API and implementation
+// * IBM - ongoing development
+// ******************************************************************************/
+//package org.eclipse.ui.tests.fieldassist;
+//
+//import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+//import org.eclipse.jface.tests.fieldassist.ComboFieldAssistWindow;
+//import org.eclipse.swt.widgets.Control;
+//import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
+//
+//public class ComboCommandFieldAssistWindow extends ComboFieldAssistWindow {
+//
+// protected ContentProposalAdapter createContentProposalAdapter(
+// Control control) {
+// return new ContentAssistCommandAdapter(control,
+// getControlContentAdapter(), getContentProposalProvider(), null,
+// getAutoActivationCharacters());
+// }
+//
+//}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/ComboContentAssistCommandAdapterTest.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/ComboContentAssistCommandAdapterTest.java
new file mode 100644
index 0000000000..36f1c1e5ad
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/ComboContentAssistCommandAdapterTest.java
@@ -0,0 +1,39 @@
+///*******************************************************************************
+// * Copyright (c) 2009 Remy Chi Jian Suen and others.
+// * All rights reserved. This program and the accompanying materials
+// * are 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
+// *
+// * Contributors:
+// * Remy Chi Jian Suen <remy.suen@gmail.com> - initial API and implementation
+// * IBM - ongoing development
+// ******************************************************************************/
+//package org.eclipse.ui.tests.fieldassist;
+//
+//import org.eclipse.jface.tests.fieldassist.AbstractFieldAssistWindow;
+//import org.eclipse.swt.widgets.Combo;
+//
+//public class ComboContentAssistCommandAdapterTest extends
+// AbstractContentAssistCommandAdapterTest {
+//
+// protected AbstractFieldAssistWindow createFieldAssistWindow() {
+// return new ComboCommandFieldAssistWindow();
+// }
+//
+// private Combo getCombo() {
+// return (Combo)getFieldAssistWindow().getFieldAssistControl();
+// }
+//
+// public void testBug243612() throws Exception {
+// getFieldAssistWindow().open();
+//
+// sendFocusInToControl();
+// executeContentAssistHandler();
+//
+// assertTwoShellsUp();
+//
+// assertFalse(getCombo().getListVisible());
+// }
+//
+//}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/FieldAssistTestSuite.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/FieldAssistTestSuite.java
index 53535bbc8d..a3d9f3d0ac 100644
--- a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/FieldAssistTestSuite.java
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/FieldAssistTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -30,5 +30,8 @@ public class FieldAssistTestSuite extends TestSuite {
*/
public FieldAssistTestSuite() {
// addTest(new TestSuite(FieldAssistAPITest.class));
+ // temporarily disabling tests, see bug 275393
+ // addTest(new TestSuite(ComboContentAssistCommandAdapterTest.class));
+ // addTest(new TestSuite(TextContentAssistCommandAdapterTest.class));
}
}
diff --git a/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/TextCommandFieldAssistWindow.java b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/TextCommandFieldAssistWindow.java
new file mode 100644
index 0000000000..8b6459279f
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/TextCommandFieldAssistWindow.java
@@ -0,0 +1,28 @@
+///*******************************************************************************
+// * Copyright (c) 2009 Remy Chi Jian Suen and others.
+// * All rights reserved. This program and the accompanying materials
+// * are 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
+// *
+// * Contributors:
+// * Remy Chi Jian Suen <remy.suen@gmail.com> - initial API and implementation
+// * IBM - ongoing development
+// ******************************************************************************/
+//package org.eclipse.ui.tests.fieldassist;
+//
+//import org.eclipse.jface.fieldassist.ContentPro