diff options
author | Susan Franklin | 2009-05-20 21:56:28 +0000 |
---|---|---|
committer | Susan Franklin | 2009-05-20 21:56:28 +0000 |
commit | 57dc72423eeb9c5a15cbe98a0d479611394b0099 (patch) | |
tree | d7c06b127230097ef1587b55b45867f171818a31 | |
parent | 18ba9d915ec90acb59a47a1de7261c66b4195075 (diff) | |
download | rt.equinox.p2-57dc72423eeb9c5a15cbe98a0d479611394b0099.tar.gz rt.equinox.p2-57dc72423eeb9c5a15cbe98a0d479611394b0099.tar.xz rt.equinox.p2-57dc72423eeb9c5a15cbe98a0d479611394b0099.zip |
Bug 276356 - [ui] check the wizard and page completion logic for AcceptLicensesWizardPage
4 files changed, 189 insertions, 25 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. diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java index cf39d0cd4..e47a0445e 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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: + * 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.equinox.internal.p2.ui.dialogs; @@ -74,6 +74,8 @@ public abstract class ProvisioningOperationWizard extends Wizard { public void addPages() { mainPage = createMainPage(root, planSelections); addPage(mainPage); + if (resolutionOperation != null) + planChanged(); } protected abstract IResolutionErrorReportingPage getErrorReportingPage(); diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/ProvisioningWizardDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/ProvisioningWizardDialog.java index ec4bd5179..e5282c000 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/ProvisioningWizardDialog.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/ProvisioningWizardDialog.java @@ -16,6 +16,7 @@ import org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningOperationWizard; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Shell; /** @@ -50,4 +51,13 @@ public class ProvisioningWizardDialog extends WizardDialog { } return super.close(); } + + /** + * This method is provided only for automated testing. + * + * @noreference This method is not intended to be referenced by clients. + */ + public Button testGetButton(int id) { + return getButton(id); + } } |