From 1991a8a0f9e4a3ff467dbb713cb5c51c8edc060f Mon Sep 17 00:00:00 2001 From: Sergey Tikhomirov Date: Fri, 22 Jun 2018 00:36:14 +0300 Subject: [PATCH] Fix codestyle issues --- .../java/io/appium/java_client/android/AndroidDriver.java | 5 +++++ src/main/java/io/appium/java_client/ios/IOSDriver.java | 5 +++++ .../element/generation/ios/IOSElementGenerationTest.java | 3 ++- src/test/java/io/appium/java_client/ios/AppIOSTest.java | 4 +--- src/test/java/io/appium/java_client/ios/BaseIOSTest.java | 6 ++++++ .../io/appium/java_client/ios/BaseIOSWebViewTest.java | 4 +--- .../java/io/appium/java_client/ios/BaseSafariTest.java | 4 +--- .../java/io/appium/java_client/ios/IOSDriverTest.java | 8 +++++--- .../java/io/appium/java_client/ios/UICatalogIOSTest.java | 4 +--- .../java_client/service/local/StartingAppLocallyTest.java | 2 +- 10 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/main/java/io/appium/java_client/android/AndroidDriver.java b/src/main/java/io/appium/java_client/android/AndroidDriver.java index 9ccaf716c..de15bc20c 100644 --- a/src/main/java/io/appium/java_client/android/AndroidDriver.java +++ b/src/main/java/io/appium/java_client/android/AndroidDriver.java @@ -199,6 +199,11 @@ public AndroidBatteryInfo getBatteryInfo() { "script", "mobile: batteryInfo", "args", Collections.emptyList())).getValue()); } + /** + * Returns capabilities that were provided on instantiation. + * + * @return given {@link Capabilities} + */ public Capabilities getCapabilities() { MutableCapabilities capabilities = (MutableCapabilities) super.getCapabilities(); capabilities.setCapability(PLATFORM_NAME, ANDROID_PLATFORM); diff --git a/src/main/java/io/appium/java_client/ios/IOSDriver.java b/src/main/java/io/appium/java_client/ios/IOSDriver.java index 5a9beb31f..6f1f5e72b 100644 --- a/src/main/java/io/appium/java_client/ios/IOSDriver.java +++ b/src/main/java/io/appium/java_client/ios/IOSDriver.java @@ -203,6 +203,11 @@ private class InnerTargetLocator extends RemoteTargetLocator { } } + /** + * Returns capabilities that were provided on instantiation. + * + * @return given {@link Capabilities} + */ public Capabilities getCapabilities() { MutableCapabilities capabilities = (MutableCapabilities) super.getCapabilities(); capabilities.setCapability(PLATFORM_NAME, IOS_PLATFORM); diff --git a/src/test/java/io/appium/java_client/appium/element/generation/ios/IOSElementGenerationTest.java b/src/test/java/io/appium/java_client/appium/element/generation/ios/IOSElementGenerationTest.java index d6f1f6251..2e5dd944b 100644 --- a/src/test/java/io/appium/java_client/appium/element/generation/ios/IOSElementGenerationTest.java +++ b/src/test/java/io/appium/java_client/appium/element/generation/ios/IOSElementGenerationTest.java @@ -74,7 +74,8 @@ public void whenIOSNativeAppIsLaunched() { IOSElement.class)); } - @Test @Ignore public void whenIOSHybridAppIsLaunched() { + @Ignore + @Test public void whenIOSHybridAppIsLaunched() { assertTrue(check(serverAppCapabilitiesSupplier, appFileSupplierFunction.apply(webViewApp), (by, aClass) -> { diff --git a/src/test/java/io/appium/java_client/ios/AppIOSTest.java b/src/test/java/io/appium/java_client/ios/AppIOSTest.java index 98272fdf9..c36c67dc7 100644 --- a/src/test/java/io/appium/java_client/ios/AppIOSTest.java +++ b/src/test/java/io/appium/java_client/ios/AppIOSTest.java @@ -18,8 +18,6 @@ public class AppIOSTest extends BaseIOSTest { @BeforeClass public static void beforeClass() throws UnknownHostException, MalformedURLException { - String ipAddress = startAppiumServer(); - if (service == null || !service.isRunning()) { throw new AppiumServerHasNotBeenStartedLocallyException("An appium server node is not started!"); } @@ -34,6 +32,6 @@ public static void beforeClass() throws UnknownHostException, MalformedURLExcept //sometimes environment has performance problems capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000); capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath()); - driver = new IOSDriver<>(new URL("http://" + ipAddress + ":" + PORT + "/wd/hub"), capabilities); + driver = new IOSDriver<>(new URL("http://" + startAppiumServer() + ":" + PORT + "/wd/hub"), capabilities); } } diff --git a/src/test/java/io/appium/java_client/ios/BaseIOSTest.java b/src/test/java/io/appium/java_client/ios/BaseIOSTest.java index ac1ce8fc4..f066bc057 100644 --- a/src/test/java/io/appium/java_client/ios/BaseIOSTest.java +++ b/src/test/java/io/appium/java_client/ios/BaseIOSTest.java @@ -29,6 +29,12 @@ public class BaseIOSTest { protected static IOSDriver driver; protected static final int PORT = 4723; + /** + * Starts a local server. + * + * @return ip of a local host + * @throws UnknownHostException when it is impossible to get ip address of a local host + */ public static String startAppiumServer() throws UnknownHostException { service = new AppiumServiceBuilder().usingPort(PORT).build(); service.start(); diff --git a/src/test/java/io/appium/java_client/ios/BaseIOSWebViewTest.java b/src/test/java/io/appium/java_client/ios/BaseIOSWebViewTest.java index 85376f623..16b28945a 100644 --- a/src/test/java/io/appium/java_client/ios/BaseIOSWebViewTest.java +++ b/src/test/java/io/appium/java_client/ios/BaseIOSWebViewTest.java @@ -30,8 +30,6 @@ public class BaseIOSWebViewTest extends BaseIOSTest { @BeforeClass public static void beforeClass() throws UnknownHostException, MalformedURLException { - String ipAddress = startAppiumServer(); - if (service == null || !service.isRunning()) { throw new AppiumServerHasNotBeenStartedLocallyException("An appium server node is not started!"); } @@ -45,7 +43,7 @@ public class BaseIOSWebViewTest extends BaseIOSTest { capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 8"); capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath()); - driver = new IOSDriver<>(new URL("http://" + ipAddress + ":" + PORT + "/wd/hub"), capabilities); + driver = new IOSDriver<>(new URL("http://" + startAppiumServer() + ":" + PORT + "/wd/hub"), capabilities); } protected void findAndSwitchToWebView() throws InterruptedException { diff --git a/src/test/java/io/appium/java_client/ios/BaseSafariTest.java b/src/test/java/io/appium/java_client/ios/BaseSafariTest.java index 3a4e09ca8..804c08abd 100644 --- a/src/test/java/io/appium/java_client/ios/BaseSafariTest.java +++ b/src/test/java/io/appium/java_client/ios/BaseSafariTest.java @@ -30,8 +30,6 @@ public class BaseSafariTest extends BaseIOSTest { @BeforeClass public static void beforeClass() throws UnknownHostException, MalformedURLException { - String ipAddress = startAppiumServer(); - if (service == null || !service.isRunning()) { throw new AppiumServerHasNotBeenStartedLocallyException("An appium server node is not started!"); } @@ -43,6 +41,6 @@ public class BaseSafariTest extends BaseIOSTest { //sometimes environment has performance problems capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 8"); - driver = new IOSDriver<>(new URL("http://" + ipAddress + ":" + PORT + "/wd/hub"), capabilities); + driver = new IOSDriver<>(new URL("http://" + startAppiumServer() + ":" + PORT + "/wd/hub"), capabilities); } } diff --git a/src/test/java/io/appium/java_client/ios/IOSDriverTest.java b/src/test/java/io/appium/java_client/ios/IOSDriverTest.java index 68dab0711..995ac4c58 100644 --- a/src/test/java/io/appium/java_client/ios/IOSDriverTest.java +++ b/src/test/java/io/appium/java_client/ios/IOSDriverTest.java @@ -28,8 +28,8 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import io.appium.java_client.appmanagement.ApplicationState; import io.appium.java_client.MobileElement; +import io.appium.java_client.appmanagement.ApplicationState; import io.appium.java_client.remote.HideKeyboardStrategy; import io.appium.java_client.remote.MobileCapabilityType; import org.junit.Ignore; @@ -62,7 +62,8 @@ public void getDeviceTimeTest() { driver.hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done"); } - @Test @Ignore public void geolocationTest() { + @Ignore + @Test public void geolocationTest() { Location location = new Location(45, 45, 100); try { driver.setLocation(location); @@ -132,7 +133,8 @@ public void getDeviceTimeTest() { driver.launchApp(); } - @Test @Ignore public void touchIdTest() { + @Ignore + @Test public void touchIdTest() { driver.toggleTouchIDEnrollment(true); driver.performTouchID(true); driver.performTouchID(false); diff --git a/src/test/java/io/appium/java_client/ios/UICatalogIOSTest.java b/src/test/java/io/appium/java_client/ios/UICatalogIOSTest.java index af69b4df9..4b9b4c09f 100644 --- a/src/test/java/io/appium/java_client/ios/UICatalogIOSTest.java +++ b/src/test/java/io/appium/java_client/ios/UICatalogIOSTest.java @@ -16,8 +16,6 @@ public class UICatalogIOSTest extends BaseIOSTest { @BeforeClass public static void beforeClass() throws UnknownHostException, MalformedURLException { - String ipAddress = startAppiumServer(); - if (service == null || !service.isRunning()) { throw new AppiumServerHasNotBeenStartedLocallyException( "An appium server node is not started!"); @@ -32,6 +30,6 @@ public static void beforeClass() throws UnknownHostException, MalformedURLExcept //sometimes environment has performance problems capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000); capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath()); - driver = new IOSDriver<>(new URL("http://" + ipAddress + ":" + PORT + "/wd/hub"), capabilities); + driver = new IOSDriver<>(new URL("http://" + startAppiumServer() + ":" + PORT + "/wd/hub"), capabilities); } } diff --git a/src/test/java/io/appium/java_client/service/local/StartingAppLocallyTest.java b/src/test/java/io/appium/java_client/service/local/StartingAppLocallyTest.java index 1fdd885b6..9536fcfe0 100644 --- a/src/test/java/io/appium/java_client/service/local/StartingAppLocallyTest.java +++ b/src/test/java/io/appium/java_client/service/local/StartingAppLocallyTest.java @@ -19,8 +19,8 @@ import static io.github.bonigarcia.wdm.WebDriverManager.chromedriver; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.ios.IOSDriver;