Skip to content

Commit 431c2fc

Browse files
authored
Display "Other Libraries" label for non-App Engine libraries group (#3581)
1 parent d01a8d0 commit 431c2fc

File tree

3 files changed

+80
-4
lines changed
  • plugins
    • com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject
    • com.google.cloud.tools.eclipse.appengine.newproject/src/com/google/cloud/tools/eclipse/appengine/newproject
    • com.google.cloud.tools.eclipse.test.util/src/com/google/cloud/tools/eclipse/test/util/ui

3 files changed

+80
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright 2019 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.tools.eclipse.appengine.newproject;
18+
19+
import static org.junit.Assert.assertEquals;
20+
21+
import com.google.cloud.tools.eclipse.appengine.libraries.ui.CloudLibrariesSelectionPage;
22+
import com.google.cloud.tools.eclipse.test.util.ui.CompositeUtil;
23+
import com.google.cloud.tools.eclipse.test.util.ui.ShellTestResource;
24+
import org.eclipse.core.runtime.IAdaptable;
25+
import org.eclipse.swt.widgets.Composite;
26+
import org.eclipse.swt.widgets.Group;
27+
import org.junit.Rule;
28+
import org.junit.Test;
29+
30+
public class AppEngineProjectWizardTest {
31+
32+
@Rule public ShellTestResource shellResource = new ShellTestResource();
33+
34+
@Test
35+
public void testLibrariesSelectionPage_appEngineLibrariesGroup() {
36+
verifySupportedLibrariesGroupLabel("appengine", "App Engine Standard Libraries");
37+
}
38+
39+
@Test
40+
public void testLibrariesSelectionPage_nonAppEngineLibrariesGroup() {
41+
verifySupportedLibrariesGroupLabel("some libraries group", "Other Libraries");
42+
}
43+
44+
private void verifySupportedLibrariesGroupLabel(
45+
String supportedLibrariesGroup, String expectedLabel) {
46+
AppEngineWizardPage wizardPage = new AppEngineWizardPage() {
47+
@Override
48+
public void setHelp(Composite container) {}
49+
50+
@Override
51+
protected String getSupportedLibrariesGroup() {
52+
return supportedLibrariesGroup;
53+
}
54+
};
55+
56+
AppEngineProjectWizard wizard = new AppEngineProjectWizard(wizardPage) {
57+
@Override
58+
public CreateAppEngineWtpProject getAppEngineProjectCreationOperation(
59+
AppEngineProjectConfig config, IAdaptable uiInfoAdapter) {
60+
return null;
61+
}
62+
};
63+
64+
CloudLibrariesSelectionPage librariesPage =
65+
(CloudLibrariesSelectionPage) wizard.getPage("cloudPlatformLibrariesPage");
66+
librariesPage.createControl(shellResource.getShell());
67+
68+
Group group = CompositeUtil.findControl((Composite) librariesPage.getControl(), Group.class);
69+
assertEquals(expectedLabel, group.getText());
70+
}
71+
}

plugins/com.google.cloud.tools.eclipse.appengine.newproject/src/com/google/cloud/tools/eclipse/appengine/newproject/AppEngineProjectWizard.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ public abstract class AppEngineProjectWizard extends Wizard implements INewWizar
4242

4343
public AppEngineProjectWizard(AppEngineWizardPage appEngineWizardPage) {
4444
appEnginePage = Preconditions.checkNotNull(appEngineWizardPage);
45-
45+
4646
Map<String, String> groups = new LinkedHashMap<>();
47-
groups.put(appEngineWizardPage.getSupportedLibrariesGroup(),
48-
Messages.getString("appengine-title")); //$NON-NLS-1$
47+
48+
String supportedLibrariesGroup = appEngineWizardPage.getSupportedLibrariesGroup();
49+
if (CloudLibraries.APP_ENGINE_STANDARD_GROUP.equals(supportedLibrariesGroup)) {
50+
groups.put(supportedLibrariesGroup, Messages.getString("appengine-title")); //$NON-NLS-1$
51+
} else {
52+
groups.put(supportedLibrariesGroup, Messages.getString("non-appengine-title")); //$NON-NLS-1$
53+
}
4954
groups.put(CloudLibraries.CLIENT_APIS_GROUP,
5055
Messages.getString("clientapis-title")); //$NON-NLS-1$
5156

plugins/com.google.cloud.tools.eclipse.test.util/src/com/google/cloud/tools/eclipse/test/util/ui/CompositeUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class CompositeUtil {
2626

2727
@SuppressWarnings("unchecked")
2828
public static <T> T findControl(Composite composite, final Class<T> type) {
29-
return (T) findControl(composite, control -> type.isInstance(control));
29+
return (T) findControl(composite, type::isInstance);
3030
}
3131

3232
public static Button findButton(Composite composite, final String text) {

0 commit comments

Comments
 (0)