diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/AbstractMarketplaceWizardBotTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/AbstractMarketplaceWizardBotTest.java index 3bfe7a1e..965fd4b3 100644 --- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/AbstractMarketplaceWizardBotTest.java +++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/AbstractMarketplaceWizardBotTest.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.epp.mpc.tests.ui.wizard; +import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf; import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType; import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive; import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.junit.Assert.assertEquals; @@ -64,6 +64,7 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Widget; import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; @@ -73,6 +74,7 @@ import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; import org.eclipse.swtbot.swt.finder.junit.ScreenshotCaptureListener; +import org.eclipse.swtbot.swt.finder.matchers.WithRegex; import org.eclipse.swtbot.swt.finder.results.ArrayResult; import org.eclipse.swtbot.swt.finder.results.Result; import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants; @@ -469,7 +471,8 @@ protected SWTBotText searchField() { protected SWTBotBrowser marketplaceBrowser() { SWTWorkbenchBot wbBot = new SWTWorkbenchBot(); - Matcher marketplaceBrowserMatch = allOf(WidgetMatcherFactory. withPartId("org.eclipse.ui.browser.editor"), WidgetMatcherFactory + Matcher marketplaceBrowserMatch = Matchers.allOf(WidgetMatcherFactory + . withPartId("org.eclipse.ui.browser.editor"), WidgetMatcherFactory . withTitle(containsString("Marketplace"))); SWTBotEditor browserEditor = wbBot.editor(marketplaceBrowserMatch); SWTBotBrowser browser = browserEditor.bot().browser(); @@ -598,7 +601,9 @@ protected SWTBotLink selectedSolutionsLink(int count) { linkText = String.format("%s solutions selected", count); } String linkContent = String.format("%s", linkText); - return bot.link(linkContent); + + Matcher matcher = allOf(widgetOfType(Link.class), WithRegex.withRegex("\\Q" + linkContent + "\\E")); + return new SWTBotLink(bot.widget(matcher, 0), matcher); } protected void tryWaitForBrowser(SWTBotBrowser browser) { diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/MarketplaceWizardTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/MarketplaceWizardTest.java index d295af58..28117046 100644 --- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/MarketplaceWizardTest.java +++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/MarketplaceWizardTest.java @@ -13,9 +13,14 @@ *******************************************************************************/ package org.eclipse.epp.mpc.tests.ui.wizard; -import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.*; +import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf; +import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType; +import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withId; +import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withText; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.util.List; @@ -66,6 +71,7 @@ public void testSearch() { itemBot(NodeMatcher.withNameRegex(".*Snipmatch.*")); } + @Ignore //Tags are currently disabled in the REST API @Test public void testSearchTag() { Matcher widgetOfType = widgetOfType(StyledText.class); @@ -170,7 +176,7 @@ private void checkMarketplaceBrowser() { @Test public void testNews() { - bot.tabItemWithId(MarketplacePage.WIDGET_ID_KEY, MarketplacePage.WIDGET_ID_TAB_NEWS).activate(); + bot.cTabItemWithId(MarketplacePage.WIDGET_ID_KEY, MarketplacePage.WIDGET_ID_TAB_NEWS).activate(); bot.sleep(500); tryWaitForBrowser(bot.browser()); String url = bot.browser().getUrl(); @@ -179,21 +185,24 @@ public void testNews() { @Test public void testRecentBackToSearch() { - bot.tabItem("Recent").activate(); + bot.cTabItem("Recent").activate(); waitForWizardProgress(); - testSearchTag(); + bot.cTabItem("Search").activate(); + waitForWizardProgress(); + searchField(); + assertTrue(bot.label("Featured").isVisible()); } @Test public void testRecent() { - bot.tabItem("Recent").activate(); + bot.cTabItem("Recent").activate(); waitForWizardProgress(); //TODO test something useful } @Test public void testPopular() { - bot.tabItem("Popular").activate(); + bot.cTabItem("Popular").activate(); waitForWizardProgress(); //TODO test something useful } diff --git a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/MarketplacePage.java b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/MarketplacePage.java index 5aca2afa..70fe7ee3 100644 --- a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/MarketplacePage.java +++ b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/MarketplacePage.java @@ -280,7 +280,8 @@ public void selectionChanged(SelectionChangedEvent event) { if (!event.getSelection().isEmpty()) { if (previousSelectionSize == 0 && newSelectionSize > 0 - && selectionModel.computeProvisioningOperationViableForFeatureSelection()) { + && selectionModel.computeProvisioningOperationViableForFeatureSelection() + && getWizard().canProceedInstallation()) { showNextPage(); } } diff --git a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/MarketplaceWizard.java b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/MarketplaceWizard.java index 6ede3cb3..ab8c9e11 100644 --- a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/MarketplaceWizard.java +++ b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/MarketplaceWizard.java @@ -214,6 +214,7 @@ public void setProceedWithInstallation(Boolean proceedWithInstallation) { private Set operationNewInstallItems; + private boolean inInitialSelectionInitializer; private boolean initialSelectionInitialized; private Set addedRepositoryLocations; @@ -282,21 +283,27 @@ void initializeInitialSelection() throws CoreException { throw new IllegalStateException(); } initialSelectionInitialized = true; - initializeCatalog(); - if (getConfiguration().getInitialState() != null || getConfiguration().getInitialOperations() != null) { - SelectionModelStateSerializer serializer = new SelectionModelStateSerializer(getCatalog(), - getSelectionModel()); - try { - getContainer().run(true, true, - monitor -> serializer.deserialize(getConfiguration().getInitialState(), - getConfiguration().getInitialOperations(), monitor)); - } catch (InvocationTargetException e) { - throw new CoreException(MarketplaceClientCore.computeStatus(e, Messages.MarketplaceViewer_unexpectedException)); - } catch (InterruptedException e) { - // user canceled - throw new CoreException(Status.CANCEL_STATUS); + inInitialSelectionInitializer = true; + try { + initializeCatalog(); + if (getConfiguration().getInitialState() != null || getConfiguration().getInitialOperations() != null) { + SelectionModelStateSerializer serializer = new SelectionModelStateSerializer(getCatalog(), + getSelectionModel()); + try { + getContainer().run(true, true, + monitor -> serializer.deserialize(getConfiguration().getInitialState(), + getConfiguration().getInitialOperations(), monitor)); + } catch (InvocationTargetException e) { + throw new CoreException( + MarketplaceClientCore.computeStatus(e, Messages.MarketplaceViewer_unexpectedException)); + } catch (InterruptedException e) { + // user canceled + throw new CoreException(Status.CANCEL_STATUS); + } + updateSelection(serializer); } - updateSelection(serializer); + } finally { + inInitialSelectionInitializer = false; } } @@ -1253,4 +1260,9 @@ public static void resumeWizard(Display display, Object state, boolean proceedWi IProvisioningPlan getAdditionalVerificationPlan() { return this.currentJREPlan; } + + protected boolean canProceedInstallation() { + return !inInitialSelectionInitializer || getInitialState() == null + || !Boolean.FALSE.equals(getInitialState().getProceedWithInstallation()); + } }