Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,10 @@ if (JavaVersion.current().isJava11Compatible()) {

checkstyle {
toolVersion = '10.6.0'
configFile = file("$projectDir/appium-style.xml")
configFile = configDirectory.file('appium-style.xml').get().getAsFile()
showViolations = true
ignoreFailures = false
}
checkstyleTest.enabled = false
}

javadoc {
Expand Down
5 changes: 5 additions & 0 deletions appium-style.xml → config/checkstyle/appium-style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,9 @@
<property name="max" value="120"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>

<module name="SuppressionFilter">
<property name="file" value="${config_loc}/suppressions.xml"/>
<property name="optional" value="false"/>
</module>
</module>
5 changes: 5 additions & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN" "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress checks="MissingJavadocMethod" files="(.*Test(s)?|/TestUtils|/EmptyWebDriver).java" />
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public void verifyLoggingCustomEvents() {
driver.logEvent(evt);
ServerEvents events = driver.getEvents();
boolean hasCustomEvent = events.events.stream().anyMatch((TimedEvent event) ->
event.name.equals("appium:funEvent") &&
event.occurrences.get(0).intValue() > 0
event.name.equals("appium:funEvent")
&& event.occurrences.get(0).intValue() > 0
);
boolean hasCommandName = events.commands.stream().anyMatch((CommandEvent event) ->
event.name.equals("logCustomEvent")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void canBuildEspressoOptions() {
"com.dep1:1.2.3",
"com.dep2:1.2.3"
))
);
);
assertEquals(Duration.ofSeconds(10), options.getNewCommandTimeout().orElse(null));
assertEquals("CN", options.getAppLocale().orElse(null).getCountry().orElse(null));
assertEquals(2, options.getEspressoBuildConfig().orElse(null)
Expand Down Expand Up @@ -172,7 +172,7 @@ public void canBuildSafariOptions() {
.setWebkitWebrtc(new WebrtcData()
.withDisableIceCandidateFiltering(true)
.withDisableInsecureMediaCapture(true)
);
);
assertEquals(Duration.ofSeconds(10), options.getNewCommandTimeout().orElse(null));
assertTrue(options.doesSafariUseSimulator().orElse(false));
assertTrue(options.getWebkitWebrtc().orElse(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.appium.java_client.internal;

import io.appium.java_client.ios.IOSDriver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public void addCustomCommandTest() {

@Test
public void addCustomCommandWithSessionIdTest() {
driver.addCommand(HttpMethod.POST, "/session/" + driver.getSessionId() + "/appium/app/launch", "launchApplication");
driver.addCommand(HttpMethod.POST, "/session/" + driver.getSessionId() + "/appium/app/launch",
"launchApplication");
final Response launchApplication = driver.execute("launchApplication");
assertNotNull(launchApplication.getSessionId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,41 +167,41 @@ public class AndroidPageObjectTest extends BaseAndroidTest {

@AndroidFindBy(id = "android:id/text1", priority = 2)
@AndroidFindAll(value = {
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
@AndroidBy(id = "android:id/fakeId")}, priority = 1)
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
@AndroidBy(id = "android:id/fakeId")}, priority = 1)
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")")
private WebElement androidElementViewFoundByMixedSearching;

@AndroidFindBy(id = "android:id/text1", priority = 2)
@AndroidFindAll(value = {
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
@AndroidBy(id = "android:id/fakeId")}, priority = 1)
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
@AndroidBy(id = "android:id/fakeId")}, priority = 1)
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")")
private List<WebElement> androidElementsViewFoundByMixedSearching;

@AndroidFindBys({
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")", priority = 1),
@AndroidBy(className = "android.widget.FrameLayout")})
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")", priority = 1),
@AndroidBy(className = "android.widget.FrameLayout")})
@AndroidFindBys({@AndroidBy(id = "android:id/text1", priority = 1),
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")")})
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")")})
private WebElement androidElementViewFoundByMixedSearching2;

@AndroidFindBys({
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")", priority = 1),
@AndroidBy(className = "android.widget.FrameLayout")})
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")", priority = 1),
@AndroidBy(className = "android.widget.FrameLayout")})
@AndroidFindBys({
@AndroidBy(id = "android:id/text1", priority = 1),
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")")})
@AndroidBy(id = "android:id/text1", priority = 1),
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")")})
private List<WebElement> androidElementsViewFoundByMixedSearching2;

@HowToUseLocators(androidAutomation = ALL_POSSIBLE)
@AndroidFindBy(id = "android:id/fakeId1")
@AndroidFindBy(id = "android:id/fakeId2", priority = 1)
@AndroidFindBys(value = {
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")", priority = 1),
@AndroidBy(id = "android:id/text1", priority = 3),
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")", priority = 2),
@AndroidBy(className = "android.widget.FrameLayout")}, priority = 2)
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")", priority = 1),
@AndroidBy(id = "android:id/text1", priority = 3),
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")", priority = 2),
@AndroidBy(className = "android.widget.FrameLayout")}, priority = 2)
@AndroidFindBy(id = "android:id/fakeId3", priority = 3)
@AndroidFindBy(id = "android:id/fakeId4", priority = 4)
private WebElement androidElementViewFoundByMixedSearching3;
Expand All @@ -210,10 +210,10 @@ public class AndroidPageObjectTest extends BaseAndroidTest {
@AndroidFindBy(id = "android:id/fakeId1")
@AndroidFindBy(id = "android:id/fakeId2", priority = 1)
@AndroidFindBys(value = {
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")", priority = 1),
@AndroidBy(id = "android:id/text1", priority = 3),
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")", priority = 2),
@AndroidBy(className = "android.widget.FrameLayout")}, priority = 2)
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")", priority = 1),
@AndroidBy(id = "android:id/text1", priority = 3),
@AndroidBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")", priority = 2),
@AndroidBy(className = "android.widget.FrameLayout")}, priority = 2)
@AndroidFindBy(id = "android:id/fakeId3", priority = 3)
@AndroidFindBy(id = "android:id/fakeId4", priority = 4)
private List<WebElement> androidElementsViewFoundByMixedSearching3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public class TimeoutTest {
private WebDriver driver;

@FindAll({
@FindBy(className = "ClassWhichDoesNotExist"),
@FindBy(className = "OneAnotherClassWhichDoesNotExist")})
@FindBy(className = "ClassWhichDoesNotExist"),
@FindBy(className = "OneAnotherClassWhichDoesNotExist")})
private List<WebElement> stubElements;

@WithTimeout(time = 5, chronoUnit = SECONDS)
@FindAll({@FindBy(className = "ClassWhichDoesNotExist"),
@FindBy(className = "OneAnotherClassWhichDoesNotExist")})
@FindBy(className = "OneAnotherClassWhichDoesNotExist")})
private List<WebElement> stubElements2;

private Duration timeOutDuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.params.provider.Arguments.arguments;
import static org.openqa.selenium.support.PageFactory.initElements;

@SuppressWarnings({"unused", "unchecked"})
Expand All @@ -31,29 +32,30 @@ public class CombinedAppTest {
*/
public static Stream<Arguments> data() {
return Stream.of(
Arguments.of(new CombinedApp(), new AbstractStubWebDriver.StubAndroidDriver(), DefaultAndroidWidget.class),
Arguments.of(new CombinedApp(), new AbstractStubWebDriver.StubIOSXCUITDriver(),
arguments(new CombinedApp(), new AbstractStubWebDriver.StubAndroidDriver(), DefaultAndroidWidget.class),
arguments(new CombinedApp(), new AbstractStubWebDriver.StubIOSXCUITDriver(),
DefaultIosXCUITWidget.class),
Arguments.of(new CombinedApp(), new AbstractStubWebDriver.StubWindowsDriver(), DefaultWindowsWidget.class),
Arguments.of(new CombinedApp(), new AbstractStubWebDriver.StubBrowserDriver(), DefaultFindByWidget.class),
Arguments.of(new CombinedApp(), new AbstractStubWebDriver.StubAndroidBrowserOrWebViewDriver(),
arguments(new CombinedApp(), new AbstractStubWebDriver.StubWindowsDriver(), DefaultWindowsWidget.class),
arguments(new CombinedApp(), new AbstractStubWebDriver.StubBrowserDriver(), DefaultFindByWidget.class),
arguments(new CombinedApp(), new AbstractStubWebDriver.StubAndroidBrowserOrWebViewDriver(),
DefaultFindByWidget.class),
Arguments.of(new PartiallyCombinedApp(), new AbstractStubWebDriver.StubAndroidDriver(),
arguments(new PartiallyCombinedApp(), new AbstractStubWebDriver.StubAndroidDriver(),
DefaultAndroidWidget.class),
Arguments.of(new PartiallyCombinedApp(), new AbstractStubWebDriver.StubIOSXCUITDriver(),
arguments(new PartiallyCombinedApp(), new AbstractStubWebDriver.StubIOSXCUITDriver(),
DefaultStubWidget.class),
Arguments.of(new PartiallyCombinedApp(), new AbstractStubWebDriver.StubWindowsDriver(),
arguments(new PartiallyCombinedApp(), new AbstractStubWebDriver.StubWindowsDriver(),
DefaultStubWidget.class),
Arguments.of(new PartiallyCombinedApp(), new AbstractStubWebDriver.StubBrowserDriver(),
arguments(new PartiallyCombinedApp(), new AbstractStubWebDriver.StubBrowserDriver(),
DefaultFindByWidget.class),
Arguments.of(new PartiallyCombinedApp(), new AbstractStubWebDriver.StubAndroidBrowserOrWebViewDriver(),
arguments(new PartiallyCombinedApp(), new AbstractStubWebDriver.StubAndroidBrowserOrWebViewDriver(),
DefaultFindByWidget.class)
);
}

@ParameterizedTest
@MethodSource("data")
void checkThatWidgetsAreCreatedCorrectly(AbstractApp app, WebDriver driver, Class<? extends DefaultStubWidget> widgetClass) {
void checkThatWidgetsAreCreatedCorrectly(AbstractApp app, WebDriver driver,
Class<? extends DefaultStubWidget> widgetClass) {
initElements(new AppiumFieldDecorator(driver), app);
assertThat("Expected widget class was " + widgetClass.getName(),
app.getWidget().getSelfReference().getClass(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public FakeIOSDriver(URL url, Capabilities caps) {
}

@Override
protected void startSession(Capabilities capabilities) {}
protected void startSession(Capabilities capabilities) {
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,21 +319,21 @@ void checkAbilityToStartServiceWithLogFileUsingShortFlag() {

@Test
void checkAbilityToStartServiceUsingValidBasePathWithMultiplePathParams() {
String baseUrl = String.format("http://%s:%d/", BROADCAST_IP_ADDRESS, DEFAULT_APPIUM_PORT);
String basePath = "wd/hub";
service = new AppiumServiceBuilder().withArgument(BASEPATH, basePath).build();
service.start();
assertTrue(service.isRunning());
String baseUrl = String.format("http://%s:%d/", BROADCAST_IP_ADDRESS, DEFAULT_APPIUM_PORT);
assertEquals(baseUrl + basePath + "/", service.getUrl().toString());
}

@Test
void checkAbilityToStartServiceUsingValidBasePathWithSinglePathParams() {
String baseUrl = String.format("http://%s:%d/", BROADCAST_IP_ADDRESS, DEFAULT_APPIUM_PORT);
String basePath = "/wd/";
service = new AppiumServiceBuilder().withArgument(BASEPATH, basePath).build();
service.start();
assertTrue(service.isRunning());
String baseUrl = String.format("http://%s:%d/", BROADCAST_IP_ADDRESS, DEFAULT_APPIUM_PORT);
assertEquals(baseUrl + basePath.substring(1), service.getUrl().toString());
}

Expand Down