|
| 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 | +} |
0 commit comments