diff options
19 files changed, 114 insertions, 4 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.verifier/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests.verifier/META-INF/MANIFEST.MF index c9a77e199..5e61517f5 100644 --- a/bundles/org.eclipse.equinox.p2.tests.verifier/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.tests.verifier/META-INF/MANIFEST.MF @@ -6,7 +6,9 @@ Bundle-Version: 1.0.100.qualifier Bundle-Activator: org.eclipse.equinox.internal.p2.tests.verifier.Activator Export-Package: org.eclipse.equinox.internal.p2.tests.verifier;x-internal:=true Require-Bundle: org.eclipse.core.runtime, - org.eclipse.equinox.p2.core + org.eclipse.equinox.p2.core, + org.eclipse.equinox.p2.ui.sdk.scheduler;bundle-version="1.2.0", + org.eclipse.swt;bundle-version="3.102.0" Bundle-RequiredExecutionEnvironment: J2SE-1.5 Import-Package: org.eclipse.equinox.internal.p2.core.helpers, org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration, diff --git a/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/VerifierApplication.java b/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/VerifierApplication.java index 2527e5f64..70b8b7b49 100644 --- a/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/VerifierApplication.java +++ b/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/VerifierApplication.java @@ -12,6 +12,7 @@ package org.eclipse.equinox.internal.p2.tests.verifier; import java.io.*; +import java.net.URI; import java.util.*; import java.util.Map.Entry; import org.eclipse.core.runtime.*; @@ -21,6 +22,7 @@ import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; +import org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration.ImportFromInstallationWizard_c; import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.equinox.p2.engine.IProfileRegistry; @@ -29,6 +31,7 @@ import org.eclipse.equinox.p2.query.QueryUtil; import org.eclipse.osgi.framework.internal.core.Constants; import org.eclipse.osgi.service.resolver.*; import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Display; import org.osgi.framework.Bundle; import org.osgi.service.packageadmin.PackageAdmin; @@ -327,9 +330,23 @@ public class VerifierApplication implements IApplication { result.merge(temp); assumeMigrated(); + + handleWizardCancellation(); return result; } + private void handleWizardCancellation() { + if (properties.getProperty("checkMigration.cancelAnswer") == null) + return; + new Display(); + IProfileRegistry reg = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); + IProfile profile = reg.getProfile(IProfileRegistry.SELF); + + ImportFromInstallationWizard_c wizardPage = new ImportFromInstallationWizard_c(profile, new URI[0]); + int cancelAnswer = Integer.parseInt(properties.getProperty("checkMigration.cancelAnswer")); + wizardPage.rememberCancellationDecision(cancelAnswer); + } + private IStatus checkSystemProperties() { final String ABSENT_SYS_PROPERTY = "not.sysprop."; final String PRESENT_SYS_PROPERTY = "sysprop."; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/AllTests.java index 53d6479ad..1d76fe129 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/AllTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/AllTests.java @@ -24,6 +24,7 @@ public class AllTests extends TestCase { suite.addTestSuite(NeedsMigration.class); suite.addTest(BaseChange.suite()); suite.addTest(BaseChangeWithoutUserChange.suite()); + suite.addTest(Cancellation.suite()); suite.addTest(DoubleBaseChange.suite()); suite.addTest(MultipleChanges.suite()); suite.addTest(InstallInUserSpace.suite()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/Cancellation.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/Cancellation.java new file mode 100644 index 000000000..ec14372c4 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/Cancellation.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2013 Ericsson AB 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: + * Ericsson AB - initial API and implementation + ******************************************************************************/ +package org.eclipse.equinox.p2.tests.sharedinstall; + +import java.util.Properties; +import junit.framework.Test; +import junit.framework.TestSuite; +import org.eclipse.core.runtime.Platform; +import org.eclipse.equinox.p2.tests.reconciler.dropins.ReconcilerTestSuite; + +public class Cancellation extends AbstractSharedInstallTest { + + public static Test suite() { + TestSuite suite = new ReconcilerTestSuite(); + suite.setName(Cancellation.class.getName()); + suite.addTest(new Cancellation("testCancellation")); + return suite; + } + + public Cancellation(String name) { + super(name); + } + + public void testCancellation() { + if (!Platform.getOS().equals(Platform.OS_WIN32)) + return; + assertInitialized(); + setupReadOnlyInstall(); + System.out.println(readOnlyBase); + System.out.println(userBase); + + { //install verifier and something else in user and checks there are there + installFeature1AndVerifierInUser(); + Properties verificationProperties = new Properties(); + + //no wizard should get opened + verificationProperties.setProperty("checkMigrationWizard", "true"); + verificationProperties.setProperty("checkMigrationWizard.open", "false"); + executeVerifier(verificationProperties); + } + + { //Now change the base. Install the verifier in the base, and run the verifier as a user + installVerifierInBase(); + + Properties verificationProperties = new Properties(); + verificationProperties.setProperty("checkMigrationWizard", "true"); + verificationProperties.setProperty("checkMigrationWizard.open", "true"); + verificationProperties.setProperty("checkMigration.cancelAnswer", "1"); //Cancel, but do later + executeVerifier(verificationProperties); + } + + { + //Check again that the wizard opens, and this time tell it to not prompt again + Properties verificationProperties = new Properties(); + verificationProperties.setProperty("checkMigrationWizard", "true"); + verificationProperties.setProperty("checkMigrationWizard.open", "true"); + verificationProperties.setProperty("checkMigration.cancelAnswer", "0"); //Don't prompt for migration again + executeVerifier(verificationProperties); + } + + { + //Check again that we are not prompted anymore + Properties verificationProperties = new Properties(); + verificationProperties.setProperty("checkMigrationWizard", "true"); + verificationProperties.setProperty("checkMigrationWizard.open", "false"); + executeVerifier(verificationProperties); + } + + { //install something in the user, then install something in the base and verify that the wizard is opened again + installFeature1InUser(); + installFeature2InBase(); + + Properties verificationProperties = new Properties(); + verificationProperties.setProperty("checkMigrationWizard", "true"); + verificationProperties.setProperty("checkMigrationWizard.open", "true"); + executeVerifier(verificationProperties); + } + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/artifacts.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/artifacts.jar Binary files differindex a1c4cdbfd..1e39046c5 100644 --- a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/artifacts.jar +++ b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/artifacts.jar diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/content.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/content.jar Binary files differindex 0f6ab9228..87057b61e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/content.jar +++ b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/content.jar diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/Verifier_1.0.0.201304051618.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/Verifier_1.0.0.201304051618.jar Binary files differdeleted file mode 100644 index 80687d324..000000000 --- a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/Verifier_1.0.0.201304051618.jar +++ /dev/null diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/Verifier_1.0.0.201304052215.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/Verifier_1.0.0.201304052215.jar Binary files differnew file mode 100644 index 000000000..81c140e8c --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/Verifier_1.0.0.201304052215.jar diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/p2TestFeature1_1.0.0.201304051618.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/p2TestFeature1_1.0.0.201304051618.jar Binary files differdeleted file mode 100644 index edda04e2a..000000000 --- a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/p2TestFeature1_1.0.0.201304051618.jar +++ /dev/null diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/p2TestFeature1_1.0.0.201304052215.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/p2TestFeature1_1.0.0.201304052215.jar Binary files differnew file mode 100644 index 000000000..ca707abce --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/p2TestFeature1_1.0.0.201304052215.jar diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/p2TestFeature2_1.0.0.201304051618.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/p2TestFeature2_1.0.0.201304051618.jar Binary files differdeleted file mode 100644 index c8065beac..000000000 --- a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/p2TestFeature2_1.0.0.201304051618.jar +++ /dev/null diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/p2TestFeature2_1.0.0.201304052215.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/p2TestFeature2_1.0.0.201304052215.jar Binary files differnew file mode 100644 index 000000000..30f098731 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/features/p2TestFeature2_1.0.0.201304052215.jar diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/org.eclipse.equinox.p2.tests.verifier_1.0.100.201304051618.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/org.eclipse.equinox.p2.tests.verifier_1.0.100.201304051618.jar Binary files differdeleted file mode 100644 index e368ff1f9..000000000 --- a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/org.eclipse.equinox.p2.tests.verifier_1.0.100.201304051618.jar +++ /dev/null diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/org.eclipse.equinox.p2.tests.verifier_1.0.100.201304052215.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/org.eclipse.equinox.p2.tests.verifier_1.0.100.201304052215.jar Binary files differnew file mode 100644 index 000000000..26486ffd5 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/org.eclipse.equinox.p2.tests.verifier_1.0.100.201304052215.jar diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/p2TestBundle1_1.0.0.201304051618.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/p2TestBundle1_1.0.0.201304051618.jar Binary files differdeleted file mode 100644 index 46536481f..000000000 --- a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/p2TestBundle1_1.0.0.201304051618.jar +++ /dev/null diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/p2TestBundle1_1.0.0.201304052215.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/p2TestBundle1_1.0.0.201304052215.jar Binary files differnew file mode 100644 index 000000000..a26f71bd4 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/p2TestBundle1_1.0.0.201304052215.jar diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/p2TestBundle2_1.0.0.201304051618.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/p2TestBundle2_1.0.0.201304051618.jar Binary files differdeleted file mode 100644 index d1287756d..000000000 --- a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/p2TestBundle2_1.0.0.201304051618.jar +++ /dev/null diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/p2TestBundle2_1.0.0.201304052215.jar b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/p2TestBundle2_1.0.0.201304052215.jar Binary files differnew file mode 100644 index 000000000..c5dbbe617 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/sharedInstall/repo/plugins/p2TestBundle2_1.0.0.201304052215.jar diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationWizard_c.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationWizard_c.java index 1c4c7e7b7..623ba4c7d 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationWizard_c.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/ImportFromInstallationWizard_c.java @@ -142,11 +142,15 @@ public class ImportFromInstallationWizard_c extends InstallWizard implements IIm } public boolean performCancel() { - boolean result = false; String[] buttons = new String[] {IDialogConstants.YES_LABEL, ProvUIMessages.ImportFromInstallationPag_LATER_BUTTON, IDialogConstants.NO_LABEL}; MessageDialog dialog = new MessageDialog(getShell(), ProvUIMessages.ImportFromInstallationPage_CONFIRMATION_TITLE, null, ProvUIMessages.ImportFromInstallationPage_CONFIRMATION_DIALOG, MessageDialog.QUESTION, buttons, 2); - int answer = dialog.open(); + return rememberCancellationDecision(dialog.open()); + } + + //Method public for test + public boolean rememberCancellationDecision(int answer) { + boolean result = false; switch (answer) { case -1 : // if the user closes the dialog without clicking any button. break; @@ -164,6 +168,6 @@ public class ImportFromInstallationWizard_c extends InstallWizard implements IIm break; } return result; - } + } |