Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2010-01-18 23:44:48 +0000
committerSusan Franklin2010-01-18 23:44:48 +0000
commitd2fba4d3e1022bf39466607e697f130dfcd96b1b (patch)
tree039a71b61c85c733718478406d8dc90eee474f4c /bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse
parent0578211b36a65b86d19b09f9be4464eaf25b5a5a (diff)
downloadrt.equinox.p2-d2fba4d3e1022bf39466607e697f130dfcd96b1b.tar.gz
rt.equinox.p2-d2fba4d3e1022bf39466607e697f130dfcd96b1b.tar.xz
rt.equinox.p2-d2fba4d3e1022bf39466607e697f130dfcd96b1b.zip
Bug 262446 - [ui] Check that nested categories still workv20100118
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AllTests.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryProviderTests.java79
2 files changed, 80 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AllTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AllTests.java
index 0fd24d7c5..60b4705d1 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AllTests.java
@@ -25,6 +25,7 @@ public class AllTests extends TestCase {
suite.addTestSuite(TranslationSupportTests.class);
suite.addTestSuite(LatestIUVersionElementWrapperTest.class);
suite.addTestSuite(QueryDescriptorTest.class);
+ suite.addTestSuite(QueryProviderTests.class);
suite.addTestSuite(QueryableMetadataRepositoryManagerTest.class);
// This must come after QueryableMetadataRepositoryManager or it causes side-effects in those tests.
suite.addTestSuite(QueryableArtifactRepositoryManagerTest.class);
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryProviderTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryProviderTests.java
new file mode 100644
index 000000000..064f85a62
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryProviderTests.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.equinox.p2.tests.ui.query;
+
+import java.util.HashMap;
+import org.eclipse.equinox.internal.p2.ui.model.*;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.operations.InstallOperation;
+import org.eclipse.equinox.p2.query.IQueryable;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
+
+public class QueryProviderTests extends AbstractProvisioningUITest {
+ IInstallableUnit category, nestedCategory;
+ IInstallableUnit a, b, c;
+ static final String CAT = "Category";
+ static final String NESTED = "NestedCategory";
+ static final String A = "A";
+ static final String B = "B";
+ static final String C = "C";
+ IMetadataRepository testRepo;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ HashMap categoryProperties = new HashMap();
+ categoryProperties.put("org.eclipse.equinox.p2.type.category", "true");
+ HashMap groupProperties = new HashMap();
+ groupProperties.put("org.eclipse.equinox.p2.type.group", "true");
+ category = createIU(CAT, Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, NESTED), categoryProperties, true);
+ nestedCategory = createIU(NESTED, Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, A), categoryProperties, true);
+ a = createIU(A, Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, B), groupProperties, true);
+ b = createIU(B, Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, C), groupProperties, true);
+ c = createIU(C, Version.create("1.0.0"), NO_REQUIRES, NO_PROPERTIES, true);
+ testRepo = createTestMetdataRepository(new IInstallableUnit[] {category, nestedCategory, a, b, c});
+ }
+
+ public void testNestedCategories() throws ProvisionException {
+ MetadataRepositoryElement element = new MetadataRepositoryElement(null, testRepo.getLocation(), true);
+ Object[] children = element.getChildren(element);
+ assertEquals("1.1", 1, children.length); // the nested category should get removed from the list
+ assertTrue("1.2", children[0] instanceof CategoryElement);
+ CategoryElement cat = (CategoryElement) children[0];
+ children = cat.getChildren(cat);
+ boolean foundNestedCategory = false;
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] instanceof CategoryElement) {
+ if (((CategoryElement) children[i]).getIU().equals(nestedCategory)) {
+ foundNestedCategory = true;
+ break;
+ }
+ }
+ }
+ assertTrue("1.3", foundNestedCategory);
+ }
+
+ public void testInstallDrilldown() throws ProvisionException {
+ IUElementListRoot root = new IUElementListRoot();
+ AvailableIUElement element = new AvailableIUElement(root, a, TESTPROFILE, getPolicy().getShowDrilldownRequirements());
+ root.setChildren(new Object[] {element});
+ InstallOperation op = new InstallOperation(getSession(), new IInstallableUnit[] {a});
+ op.setProfileId(TESTPROFILE);
+ op.resolveModal(getMonitor());
+ IQueryable queryable = op.getProvisioningPlan().getAdditions();
+ element.setQueryable(queryable);
+ Object[] children = element.getChildren(element);
+ assertTrue("1.1", children.length == 1);
+ }
+
+}

Back to the top