Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2008-12-15 21:23:24 +0000
committerSusan Franklin2008-12-15 21:23:24 +0000
commit264a3cbdc56c8ef4e2b2a82756348b13e861a36c (patch)
tree56c8574051b2492f0c8174f1fb3c61007a14275a /bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs
parent7f1a15c3a25cc097524ba73f0aa1f6dace3d6863 (diff)
downloadrt.equinox.p2-264a3cbdc56c8ef4e2b2a82756348b13e861a36c.tar.gz
rt.equinox.p2-264a3cbdc56c8ef4e2b2a82756348b13e861a36c.tar.xz
rt.equinox.p2-264a3cbdc56c8ef4e2b2a82756348b13e861a36c.zip
expand wizard tests to perform resolution, check for parallel operations
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java85
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UninstallWizardTest.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java40
3 files changed, 135 insertions, 26 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 d2ecf801b..b4bdcc815 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
@@ -10,14 +10,23 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.dialogs;
-import org.eclipse.equinox.internal.p2.ui.dialogs.*;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
-import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
+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.ResolutionWizardPage;
+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.ui.*;
import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.AvailableIUGroup;
import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.InstallWizard;
+import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.statushandlers.StatusManager;
/**
* Tests for the install wizard
@@ -25,14 +34,19 @@ import org.eclipse.jface.wizard.WizardDialog;
public class InstallWizardTest extends AbstractProvisioningUITest {
private static final String AVAILABLE_SOFTWARE_PAGE = "AvailableSoftwarePage";
- private static final String RESOLUTION_PAGE = "InstallWizardPage";
- private static final String LICENSE_PAGE = "AcceptLicenses";
+ private static final String BROKEN_IU = "RCP_Browser_Example.feature.group";
/**
* Tests the wizard
*/
public void testWizard() {
- InstallWizard wizard = new InstallWizard(Policy.getDefault(), IProfileRegistry.SELF, null, null, null);
+ QueryableMetadataRepositoryManager manager = new QueryableMetadataRepositoryManager(Policy.getDefault(), false);
+ manager.loadAll(getMonitor());
+
+ Policy policy = Policy.getDefault();
+ IUViewQueryContext context = policy.getQueryContext();
+ context.setViewType(IUViewQueryContext.AVAILABLE_VIEW_FLAT);
+ InstallWizard wizard = new InstallWizard(policy, TESTPROFILE, null, null, manager);
WizardDialog dialog = new WizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.create();
@@ -41,26 +55,63 @@ public class InstallWizardTest extends AbstractProvisioningUITest {
try {
AvailableIUsPage page1 = (AvailableIUsPage) wizard.getPage(AVAILABLE_SOFTWARE_PAGE);
- InstallWizardPage page2 = (InstallWizardPage) wizard.getPage(RESOLUTION_PAGE);
- AcceptLicensesWizardPage page3 = (AcceptLicensesWizardPage) wizard.getPage(LICENSE_PAGE);
// test initial wizard state
assertTrue(page1.getSelectedIUs().length == 0);
assertFalse(page1.isPageComplete());
- // resolution page not created
- assertNull(page2);
+ // Start reaching in...
+ AvailableIUGroup group = page1.testGetAvailableIUGroup();
+ // Now manipulate the tree itself. we are reaching way in.
+ DeferredQueryContentProvider provider = (DeferredQueryContentProvider) group.getCheckboxTreeViewer().getContentProvider();
+ provider.setSynchronous(true);
+ group.getCheckboxTreeViewer().refresh();
+ Tree tree = (Tree) group.getCheckboxTreeViewer().getControl();
+ TreeItem[] items = tree.getItems();
+ HashSet ids = new HashSet();
+ ids.add(BROKEN_IU);
+ for (int i = 0; i < items.length; i++) {
+ Object element = items[i].getData();
+ if (element != null && element instanceof IIUElement) {
+ IInstallableUnit iu = ((IIUElement) element).getIU();
+ if (iu != null && !ids.contains(iu.getId())) {
+ ids.add(iu.getId());
+ group.getCheckboxTreeViewer().setChecked(element, true);
+ }
+ }
+ }
+ // must be done this way to force notification of listeners
+ group.setChecked(group.getCheckboxTreeViewer().getCheckedElements());
- // no license page created yet
- assertNull(page3);
+ ResolutionWizardPage page2 = (ResolutionWizardPage) wizard.getNextPage(page1);
+ assertTrue(group.getCheckedLeafIUs().length > 0);
+ dialog.showPage(page2);
+ assertNotNull(page2.getCurrentPlan());
- // Test the API. Note we aren't testing much about correctness since
- // there is not a lot of API to test the state of the UI. However
- // this does let us get better code coverage and find exceptions/breakage.
- AvailableIUGroup group = page1.testGetAvailableIUGroup();
+ // if another operation is scheduled for this profile, we should not be allowed to proceed
+ // Note this test is timing dependent, as it relies on a 1 second operation not
+ // completing before the assertion.
+ Job job = ProvisioningOperationRunner.schedule(getLongTestOperation(), null, StatusManager.LOG);
+ assertTrue("Investigate timing problem in test", page1.isPageComplete());
+
+ // causes recalculation of plan and status
+ dialog.showPage(page1);
+ wizard.getNextPage(page1);
+ assertTrue(page1.isPageComplete());
+ assertFalse(page2.isPageComplete());
+ job.cancel();
+ // relies on immediate response from job
+ wizard.getNextPage(page1);
+ assertTrue(page1.isPageComplete());
+ assertTrue(page2.isPageComplete());
+
+ // this doesn't test much, it's just calling group API to flesh out NPE's, etc.
group.refresh();
- // Now manipulate the tree itself. we are reaching way in.
+ group.getCheckedLeafIUs();
+ group.getDefaultFocusControl();
+ group.getSelectedIUElements();
+ group.getSelectedIUs();
} finally {
dialog.close();
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UninstallWizardTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UninstallWizardTest.java
index 966c09903..8ee14b154 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UninstallWizardTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UninstallWizardTest.java
@@ -10,33 +10,61 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.dialogs;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.equinox.internal.p2.ui.dialogs.ResolutionWizardPage;
+import org.eclipse.equinox.internal.p2.ui.dialogs.SelectableIUsPage;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
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.UninstallWizard;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.statushandlers.StatusManager;
/**
* Tests for the install wizard
*/
public class UninstallWizardTest extends AbstractProvisioningUITest {
+ private static final String SELECTION_PAGE = "IUSelectionPage";
+
/**
* Tests the wizard
*/
public void testWizard() {
// This test is pretty useless right now but at least it opens the wizard
- UninstallWizard wizard = new UninstallWizard(Policy.getDefault(), IProfileRegistry.SELF, new IInstallableUnit[0], null);
+ UninstallWizard wizard = new UninstallWizard(Policy.getDefault(), TESTPROFILE, new IInstallableUnit[] {top1, top2}, null);
WizardDialog dialog = new WizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.setBlockOnOpen(false);
dialog.create();
dialog.open();
try {
- // reach in and perform tests
- assertFalse(wizard.canFinish());
+ SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE);
+ assertTrue(page1.isPageComplete());
+ assertTrue(page1.canFlipToNextPage());
+ ResolutionWizardPage page2 = (ResolutionWizardPage) wizard.getNextPage(page1);
+ dialog.showPage(page2);
+ assertTrue(page2.isPageComplete());
+
+ // if another operation is scheduled for this profile, we should not be allowed to proceed
+ // Note this test is timing dependent, as it relies on a 1 second operation not
+ // completing before the assertion.
+ Job job = ProvisioningOperationRunner.schedule(getLongTestOperation(), null, StatusManager.LOG);
+ assertTrue("Investigate timing problem in test", page1.isPageComplete());
+ // causes recalculation of plan and status
+ wizard.getNextPage(page1);
+ assertFalse(page2.isPageComplete());
+ job.cancel();
+ // relies on immediate response from job
+
+ wizard.getNextPage(page1);
+ assertTrue(page1.isPageComplete());
+ assertTrue("Investigate timing problem in test", page2.isPageComplete());
+
+ // no licenses
+ assertTrue(wizard.canFinish());
} finally {
dialog.getShell().close();
}
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 fb3ada508..65134145d 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
@@ -10,33 +10,63 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.dialogs;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.equinox.internal.p2.ui.dialogs.ResolutionWizardPage;
+import org.eclipse.equinox.internal.p2.ui.dialogs.SelectableIUsPage;
+import org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement;
import org.eclipse.equinox.internal.p2.ui.model.IUElementListRoot;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
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.UpdateWizard;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.statushandlers.StatusManager;
/**
* Tests for the install wizard
*/
public class UpdateWizardTest extends AbstractProvisioningUITest {
+ private static final String SELECTION_PAGE = "IUSelectionPage";
+
/**
* Tests the wizard
*/
public void testWizard() {
- // this test is fairly useless until we seed it with real data and some mock profile, but
- // at least we open the wizard up.
- UpdateWizard wizard = new UpdateWizard(Policy.getDefault(), IProfileRegistry.SELF, new IUElementListRoot(), new Object[0], null);
+ IUElementListRoot root = new IUElementListRoot();
+ AvailableUpdateElement element = new AvailableUpdateElement(root, upgrade, top1, TESTPROFILE, true);
+ root.setChildren(new Object[] {element});
+
+ UpdateWizard wizard = new UpdateWizard(Policy.getDefault(), TESTPROFILE, root, new Object[] {element}, null);
WizardDialog dialog = new WizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.setBlockOnOpen(false);
dialog.open();
try {
- assertFalse(wizard.canFinish());
+ SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE);
+ assertTrue(page1.isPageComplete());
+ assertTrue(page1.canFlipToNextPage());
+ ResolutionWizardPage page2 = (ResolutionWizardPage) wizard.getNextPage(page1);
+ dialog.showPage(page2);
+ assertTrue(page2.isPageComplete());
+
+ // if another operation is scheduled for this profile, we should not be allowed to proceed
+ // Note this test is timing dependent, as it relies on a 1 second operation not
+ // completing before the assertion.
+ Job job = ProvisioningOperationRunner.schedule(getLongTestOperation(), null, StatusManager.LOG);
+ assertTrue("Investigate timing problem in test", page1.isPageComplete());
+ // causes recalculation of plan and status
+ wizard.getNextPage(page1);
+ assertFalse(page2.isPageComplete());
+ job.cancel();
+ // relies on immediate cancel response from job
+ wizard.getNextPage(page1);
+ assertTrue(page1.isPageComplete());
+ assertTrue("Investigate timing problem in test", page2.isPageComplete());
+ // no licenses
+ assertTrue(wizard.canFinish());
} finally {
dialog.getShell().close();
}

Back to the top