diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests.ui')
2 files changed, 171 insertions, 19 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java index 9337a9f42..f4e39fc06 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java @@ -1,30 +1,35 @@ /******************************************************************************* - * 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 + * 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: + * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.equinox.p2.tests.ui.dialogs; import java.util.HashSet; import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.equinox.internal.p2.ui.dialogs.AvailableIUsPage; -import org.eclipse.equinox.internal.p2.ui.dialogs.IResolutionErrorReportingPage; +import org.eclipse.equinox.internal.p2.metadata.License; +import org.eclipse.equinox.internal.p2.ui.dialogs.*; import org.eclipse.equinox.internal.p2.ui.model.IIUElement; import org.eclipse.equinox.internal.p2.ui.viewers.DeferredQueryContentProvider; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +import org.eclipse.equinox.internal.provisional.p2.core.Version; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; import org.eclipse.equinox.internal.provisional.p2.ui.*; import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.*; +import org.eclipse.equinox.internal.provisional.p2.ui.operations.PlannerResolutionOperation; import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext; import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy; +import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.swt.widgets.*; import org.eclipse.ui.statushandlers.StatusManager; /** @@ -32,8 +37,43 @@ import org.eclipse.ui.statushandlers.StatusManager; */ public class InstallWizardTest extends WizardTest { + private static final String SELECTION_PAGE = "IUSelectionPage"; private static final String AVAILABLE_SOFTWARE_PAGE = "AvailableSoftwarePage"; private static final String BROKEN_IU = "RCP_Browser_Example.feature.group"; + private static final String MAIN_IU = "MainIU"; + + public void testInstallWizardResolved() throws ProvisionException { + InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription(); + iu.setId(MAIN_IU); + iu.setVersion(new Version(1, 0, 0)); + iu.setSingleton(true); + iu.setLicense(new License(null, "There is a license to accept!")); + iu.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, MAIN_IU, iu.getVersion())}); + IInstallableUnit toInstall = MetadataFactory.createInstallableUnit(iu); + ProfileChangeRequest request = new ProfileChangeRequest(profile); + request.addInstallableUnits(new IInstallableUnit[] {toInstall}); + PlannerResolutionOperation op = getResolvedOperation(request); + PreselectedIUInstallWizard wizard = new PreselectedIUInstallWizard(Policy.getDefault(), TESTPROFILE, new IInstallableUnit[] {toInstall}, op, null); + ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); + dialog.setBlockOnOpen(false); + dialog.open(); + + try { + SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE); + // should already have a plan + assertTrue("1.0", page1.isPageComplete()); + // simulate the next button by getting next page and showing + IWizardPage page = page1.getNextPage(); + dialog.showPage(page); + // license needs approval + assertFalse("1.1", wizard.canFinish()); + // finish button should be disabled + Button finishButton = dialog.testGetButton(IDialogConstants.FINISH_ID); + assertFalse("1.2", finishButton.isEnabled()); + } finally { + dialog.getShell().close(); + } + } /** * Tests the wizard diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java index d012926d8..a6c675586 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java @@ -1,22 +1,24 @@ /******************************************************************************* - * 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 + * 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: + * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.equinox.p2.tests.ui.dialogs; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.equinox.internal.p2.metadata.License; import org.eclipse.equinox.internal.p2.ui.dialogs.ResolutionResultsWizardPage; import org.eclipse.equinox.internal.p2.ui.dialogs.SelectableIUsPage; import org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +import org.eclipse.equinox.internal.provisional.p2.core.*; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI; import org.eclipse.equinox.internal.provisional.p2.ui.ProvisioningOperationRunner; import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.ProvisioningWizardDialog; @@ -24,7 +26,10 @@ import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.UpdateWizard; import org.eclipse.equinox.internal.provisional.p2.ui.model.IUElementListRoot; import org.eclipse.equinox.internal.provisional.p2.ui.operations.PlannerResolutionOperation; import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.widgets.Button; import org.eclipse.ui.statushandlers.StatusManager; /** @@ -33,6 +38,32 @@ import org.eclipse.ui.statushandlers.StatusManager; public class UpdateWizardTest extends WizardTest { private static final String SELECTION_PAGE = "IUSelectionPage"; + private static final String RESOLUTION_PAGE = "ResolutionPage"; + private static final String MAIN_IU = "MainIU"; + IInstallableUnit main, mainUpgrade1, mainUpgrade2, mainUpgradeWithLicense; + + protected void setUp() throws Exception { + super.setUp(); + InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription(); + iu.setId(MAIN_IU); + iu.setVersion(new Version(1, 0, 0)); + iu.setSingleton(true); + iu.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, MAIN_IU, iu.getVersion())}); + main = MetadataFactory.createInstallableUnit(iu); + install(main, true, false); + IUpdateDescriptor update = MetadataFactory.createUpdateDescriptor(MAIN_IU, new VersionRange("[1.0.0, 1.0.0]"), 0, "update description"); + mainUpgrade1 = createIU(MAIN_IU, new Version(2, 0, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, true, update, NO_REQUIRES); + update = MetadataFactory.createUpdateDescriptor(MAIN_IU, new VersionRange("[1.0.0, 1.0.0]"), 0, "update description"); + mainUpgrade2 = createIU(MAIN_IU, new Version(3, 0, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, true, update, NO_REQUIRES); + iu = new MetadataFactory.InstallableUnitDescription(); + iu.setId(MAIN_IU); + iu.setVersion(new Version(4, 0, 0)); + iu.setSingleton(true); + iu.setUpdateDescriptor(update); + iu.setLicense(new License(null, "Update Wizard Test License to Accept")); + iu.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, MAIN_IU, iu.getVersion())}); + mainUpgradeWithLicense = MetadataFactory.createInstallableUnit(iu); + } /** * Tests the wizard when a prior resolution has been done. @@ -73,6 +104,87 @@ public class UpdateWizardTest extends WizardTest { } } + public void testUpdateWizardResolvedWithLicense() throws ProvisionException { + IUElementListRoot root = new IUElementListRoot(); + AvailableUpdateElement element = new AvailableUpdateElement(root, mainUpgradeWithLicense, main, TESTPROFILE, true); + root.setChildren(new Object[] {element}); + ProfileChangeRequest request = new ProfileChangeRequest(profile); + request.removeInstallableUnits(new IInstallableUnit[] {main}); + request.addInstallableUnits(new IInstallableUnit[] {mainUpgradeWithLicense}); + PlannerResolutionOperation op = getResolvedOperation(request); + UpdateWizard wizard = new UpdateWizard(Policy.getDefault(), TESTPROFILE, root, new Object[] {element}, op, null); + ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); + dialog.setBlockOnOpen(false); + dialog.open(); + + try { + SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE); + // should already have a plan + assertTrue("1.0", page1.isPageComplete()); + // simulate the next button by getting next page and showing + IWizardPage page = page1.getNextPage(); + dialog.showPage(page); + // license needs approval + assertFalse("1.1", wizard.canFinish()); + // finish button should be disabled + Button finishButton = dialog.testGetButton(IDialogConstants.FINISH_ID); + assertFalse("1.2", finishButton.isEnabled()); + } finally { + dialog.getShell().close(); + } + } + + /** + * Tests the wizard when a prior resolution has been done, but is in error. + */ + public void testUpdateWizardResolvedError() throws ProvisionException { + IUElementListRoot root = new IUElementListRoot(); + AvailableUpdateElement element = new AvailableUpdateElement(root, mainUpgrade1, main, TESTPROFILE, true); + AvailableUpdateElement element2 = new AvailableUpdateElement(root, mainUpgrade2, main, TESTPROFILE, true); + root.setChildren(new Object[] {element, element2}); + ProfileChangeRequest request = new ProfileChangeRequest(profile); + request.removeInstallableUnits(new IInstallableUnit[] {main}); + request.addInstallableUnits(new IInstallableUnit[] {mainUpgrade1, mainUpgrade2}); + PlannerResolutionOperation op = getResolvedOperation(request); + UpdateWizard wizard = new UpdateWizard(Policy.getDefault(), TESTPROFILE, root, new Object[] {element, element2}, op, null); + wizard.setSkipSelectionsPage(true); + WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); + dialog.setBlockOnOpen(false); + dialog.open(); + + try { + assertNotNull("1.0", wizard.getStartingPage()); + } finally { + dialog.getShell().close(); + } + } + + /** + * Tests the wizard when we have a successful resolution and want to open + * directly on the resolution page + */ + public void testUpdateWizardResolvedSkipSelections() throws ProvisionException { + IUElementListRoot root = new IUElementListRoot(); + AvailableUpdateElement element = new AvailableUpdateElement(root, mainUpgrade1, main, TESTPROFILE, true); + root.setChildren(new Object[] {element}); + ProfileChangeRequest request = new ProfileChangeRequest(profile); + request.removeInstallableUnits(new IInstallableUnit[] {main}); + request.addInstallableUnits(new IInstallableUnit[] {mainUpgrade1}); + PlannerResolutionOperation op = getResolvedOperation(request); + UpdateWizard wizard = new UpdateWizard(Policy.getDefault(), TESTPROFILE, root, new Object[] {element}, op, null); + wizard.setSkipSelectionsPage(true); + WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); + dialog.setBlockOnOpen(false); + dialog.open(); + + try { + assertNotNull("1.0", wizard.getStartingPage()); + assertEquals("1.1", wizard.getStartingPage(), wizard.getPage(RESOLUTION_PAGE)); + } finally { + dialog.getShell().close(); + } + } + /** * Tests the wizard without a prior resolution being done. * This is not the SDK workflow, but should be supported. |