From 738e264224f7ba43c86f5139818300b2830a78b4 Mon Sep 17 00:00:00 2001 From: Ondrej Dockal Date: Fri, 10 Sep 2021 09:21:21 +0200 Subject: [PATCH] Add installation of one p2 site at once, fixes #2140 Signed-off-by: Ondrej Dockal --- .../pom.xml | 3 +- .../InstallSoftwareFromUpdateSiteTest.java | 19 +++++++++ .../AvailableSoftwareSitesPreferencePage.java | 42 +++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 tests/org.eclipse.reddeer.integration.test/src/org/eclipse/reddeer/integration/test/installation/common/preferences/AvailableSoftwareSitesPreferencePage.java diff --git a/tests/org.eclipse.reddeer.integration.test/pom.xml b/tests/org.eclipse.reddeer.integration.test/pom.xml index c9a82b31b3..3056a692cf 100644 --- a/tests/org.eclipse.reddeer.integration.test/pom.xml +++ b/tests/org.eclipse.reddeer.integration.test/pom.xml @@ -25,8 +25,9 @@ - -Dupdate.site=${update.site} + -Dupdate.site=${update.site} -Dp2.only=${p2.only} + epp.package.jee org.eclipse.platform.ide true diff --git a/tests/org.eclipse.reddeer.integration.test/src/org/eclipse/reddeer/integration/test/InstallSoftwareFromUpdateSiteTest.java b/tests/org.eclipse.reddeer.integration.test/src/org/eclipse/reddeer/integration/test/InstallSoftwareFromUpdateSiteTest.java index 74775e6dfb..144ff5d58c 100644 --- a/tests/org.eclipse.reddeer.integration.test/src/org/eclipse/reddeer/integration/test/InstallSoftwareFromUpdateSiteTest.java +++ b/tests/org.eclipse.reddeer.integration.test/src/org/eclipse/reddeer/integration/test/InstallSoftwareFromUpdateSiteTest.java @@ -19,8 +19,12 @@ import org.eclipse.reddeer.integration.test.installation.common.dialog.InstallNewSoftwareDialog; import org.eclipse.reddeer.integration.test.installation.common.page.AvailableSoftwarePage; +import org.eclipse.reddeer.integration.test.installation.common.preferences.AvailableSoftwareSitesPreferencePage; import org.eclipse.reddeer.integration.test.installation.common.util.InstallationOperator; +import org.eclipse.reddeer.jface.preference.PreferencePage; import org.eclipse.reddeer.junit.runner.RedDeerSuite; +import org.eclipse.reddeer.workbench.ui.dialogs.WorkbenchPreferenceDialog; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ErrorCollector; @@ -30,9 +34,24 @@ public class InstallSoftwareFromUpdateSiteTest { private static final String UPDATE_SITE = System.getProperty("update.site"); + private static final String P2_ONLY_PROP = "p2.only"; @Rule public ErrorCollector collector = new ErrorCollector(); + + @BeforeClass + public static void prepareTestEnv() { + if(Boolean.getBoolean(P2_ONLY_PROP)) { + System.out.println("System prop. p2.only: " + Boolean.getBoolean(P2_ONLY_PROP)); + WorkbenchPreferenceDialog dialog = new WorkbenchPreferenceDialog(); + dialog.open(); + AvailableSoftwareSitesPreferencePage page = new AvailableSoftwareSitesPreferencePage(dialog); + dialog.select(page); + page.getItems().stream().forEach(item -> System.out.println(item.getText())); + page.toggleAllItems(false); + dialog.ok(); + } + } @Test public void testInstallFromUpdateSite() { diff --git a/tests/org.eclipse.reddeer.integration.test/src/org/eclipse/reddeer/integration/test/installation/common/preferences/AvailableSoftwareSitesPreferencePage.java b/tests/org.eclipse.reddeer.integration.test/src/org/eclipse/reddeer/integration/test/installation/common/preferences/AvailableSoftwareSitesPreferencePage.java new file mode 100644 index 0000000000..e0cfccc6ec --- /dev/null +++ b/tests/org.eclipse.reddeer.integration.test/src/org/eclipse/reddeer/integration/test/installation/common/preferences/AvailableSoftwareSitesPreferencePage.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2017 Red Hat, Inc and others. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc - initial API and implementation + *******************************************************************************/ +package org.eclipse.reddeer.integration.test.installation.common.preferences; + +import java.util.List; + +import org.eclipse.reddeer.core.reference.ReferencedComposite; +import org.eclipse.reddeer.jface.preference.PreferencePage; +import org.eclipse.reddeer.swt.api.TableItem; +import org.eclipse.reddeer.swt.impl.table.DefaultTable; + +/** + * Represents a Install/Update -> Available Update Sites preference page. + * + * @author Ondrej Dockal + */ +public class AvailableSoftwareSitesPreferencePage extends PreferencePage { + + public AvailableSoftwareSitesPreferencePage(ReferencedComposite referencedComposite) { + super(referencedComposite, new String[] {"Install/Update", "Available Software Sites"}); + } + + public List getItems() { + return new DefaultTable().getItems(); + } + + public void toggleAllItems(boolean toggle) { + for(TableItem item: getItems()) { + item.setChecked(toggle); + } + } + +}