Skip to content

tests: Remove obsolete API calls from tests #2006

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Sep 7, 2023
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.appium.java_client.android;

import com.google.common.collect.ImmutableMap;
import io.appium.java_client.AppiumBy;
import io.appium.java_client.functions.ActionSupplier;
import io.appium.java_client.touch.offset.ElementOption;
Expand Down Expand Up @@ -46,8 +47,7 @@ public class AndroidAbilityToUseSupplierTest extends BaseAndroidTest {
.release();

@Test public void horizontalSwipingWithSupplier() {
Activity activity = new Activity("io.appium.android.apis", ".view.Gallery1");
driver.startActivity(activity);
startActivity(".view.Gallery1");
WebElement gallery = driver.findElement(By.id("io.appium.android.apis:id/gallery"));
List<WebElement> images = gallery.findElements(AppiumBy.className("android.widget.ImageView"));
int originalImageCount = images.size();
Expand All @@ -59,7 +59,8 @@ public class AndroidAbilityToUseSupplierTest extends BaseAndroidTest {
}

@Test public void verticalSwipingWithSupplier() throws Exception {
driver.resetApp();
driver.executeScript("mobile: terminateApp", ImmutableMap.of("appId", APP_ID));
driver.executeScript("mobile: activateApp", ImmutableMap.of("appId", APP_ID));
driver.findElement(AppiumBy.accessibilityId("Views")).click();

Point originalLocation = driver.findElement(AppiumBy.accessibilityId("Gallery")).getLocation();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
public class AndroidContextTest extends BaseAndroidTest {

@BeforeAll public static void beforeClass2() throws Exception {
Activity activity = new Activity("io.appium.android.apis", ".view.WebView1");
driver.startActivity(activity);
startActivity(".view.WebView1");
Thread.sleep(20000);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.appium.java_client.android;

import com.google.common.collect.ImmutableMap;
import io.appium.java_client.appmanagement.ApplicationState;
import org.apache.commons.io.FileUtils;
import org.hamcrest.Matchers;
Expand Down Expand Up @@ -148,8 +149,8 @@ public void isAppNotInstalledTest() {

@Test
public void closeAppTest() {
driver.closeApp();
driver.launchApp();
driver.executeScript("mobile: terminateApp", ImmutableMap.of("appId", APP_ID));
driver.executeScript("mobile: activateApp", ImmutableMap.of("appId", APP_ID));
assertEquals(".ApiDemos", driver.currentActivity());
}

Expand Down Expand Up @@ -241,11 +242,6 @@ public void pullFileTest() {
assert (data.length > 0);
}

@Test
public void resetTest() {
driver.resetApp();
}

@Test
public void deviceDetailsAndKeyboardTest() {
assertFalse(driver.isKeyboardShown());
Expand All @@ -255,7 +251,7 @@ public void deviceDetailsAndKeyboardTest() {

@Test
public void getSupportedPerformanceDataTypesTest() {
driver.startActivity(new Activity(APP_ID, ".ApiDemos"));
startActivity(".ApiDemos");

List<String> dataTypes = new ArrayList<>();
dataTypes.add("cpuinfo");
Expand All @@ -270,13 +266,11 @@ public void getSupportedPerformanceDataTypesTest() {
for (int i = 0; i < supportedPerformanceDataTypes.size(); ++i) {
assertEquals(dataTypes.get(i), supportedPerformanceDataTypes.get(i));
}


}

@Test
public void getPerformanceDataTest() {
driver.startActivity(new Activity(APP_ID, ".ApiDemos"));
startActivity(".ApiDemos");

List<String> supportedPerformanceDataTypes = driver.getSupportedPerformanceDataTypes();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
public class AndroidElementTest extends BaseAndroidTest {

@BeforeEach public void setup() {
Activity activity = new Activity("io.appium.android.apis", ".ApiDemos");
driver.startActivity(activity);
startActivity(".ApiDemos");
}


Expand All @@ -57,8 +56,7 @@ public class AndroidElementTest extends BaseAndroidTest {
@Test public void replaceValueTest() {
String originalValue = "original value";

Activity activity = new Activity("io.appium.android.apis", ".view.Controls1");
driver.startActivity(activity);
startActivity(".view.Controls1");
WebElement editElement = driver
.findElement(AppiumBy.androidUIAutomator("resourceId(\"io.appium.android.apis:id/edit\")"));
editElement.sendKeys(originalValue);
Expand All @@ -81,8 +79,7 @@ public class AndroidElementTest extends BaseAndroidTest {
@Test public void setValueTest() {
String value = "new value";

Activity activity = new Activity("io.appium.android.apis", ".view.Controls1");
driver.startActivity(activity);
startActivity(".view.Controls1");
WebElement editElement = driver
.findElement(AppiumBy.androidUIAutomator("resourceId(\"io.appium.android.apis:id/edit\")"));
editElement.sendKeys(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public class AndroidFunctionTest extends BaseAndroidTest {
@BeforeAll
public static void startWebViewActivity() {
if (driver != null) {
Activity activity = new Activity("io.appium.android.apis", ".view.WebView1");
driver.startActivity(activity);
startActivity(".view.WebView1");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public class AndroidScreenRecordTest extends BaseAndroidTest {

@BeforeEach
public void setUp() {
Activity activity = new Activity("io.appium.android.apis", ".ApiDemos");
driver.startActivity(activity);
startActivity(".ApiDemos");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public class AndroidSearchingTest extends BaseAndroidTest {

@BeforeEach
public void setup() {
Activity activity = new Activity("io.appium.android.apis", ".ApiDemos");
driver.startActivity(activity);
startActivity(".ApiDemos");
}

@Test public void findByAccessibilityIdTest() {
Expand Down
34 changes: 13 additions & 21 deletions src/test/java/io/appium/java_client/android/AndroidTouchTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.appium.java_client.android;

import com.google.common.collect.ImmutableMap;
import io.appium.java_client.AppiumBy;
import io.appium.java_client.MultiTouchAction;
import io.appium.java_client.TouchAction;
Expand All @@ -25,12 +26,12 @@ public class AndroidTouchTest extends BaseAndroidTest {

@BeforeEach
public void setUp() {
driver.resetApp();
driver.executeScript("mobile: terminateApp", ImmutableMap.of("appId", APP_ID));
driver.executeScript("mobile: activateApp", ImmutableMap.of("appId", APP_ID));
}

@Test public void dragNDropByElementTest() {
Activity activity = new Activity("io.appium.android.apis", ".view.DragAndDropDemo");
driver.startActivity(activity);
startActivity(".view.DragAndDropDemo");
WebElement dragDot1 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_1"));
WebElement dragDot3 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_3"));

Expand All @@ -46,8 +47,7 @@ public void setUp() {
}

@Test public void dragNDropByElementAndDurationTest() {
Activity activity = new Activity("io.appium.android.apis", ".view.DragAndDropDemo");
driver.startActivity(activity);
startActivity(".view.DragAndDropDemo");
WebElement dragDot1 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_1"));
WebElement dragDot3 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_3"));

Expand All @@ -65,8 +65,7 @@ public void setUp() {
}

@Test public void dragNDropByCoordinatesTest() {
Activity activity = new Activity("io.appium.android.apis", ".view.DragAndDropDemo");
driver.startActivity(activity);
startActivity(".view.DragAndDropDemo");
WebElement dragDot1 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_1"));
WebElement dragDot3 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_3"));

Expand All @@ -85,8 +84,7 @@ public void setUp() {
}

@Test public void dragNDropByCoordinatesAndDurationTest() {
Activity activity = new Activity("io.appium.android.apis", ".view.DragAndDropDemo");
driver.startActivity(activity);
startActivity(".view.DragAndDropDemo");
WebElement dragDot1 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_1"));
WebElement dragDot3 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_3"));

Expand All @@ -107,8 +105,7 @@ public void setUp() {
}

@Test public void pressByCoordinatesTest() {
Activity activity = new Activity("io.appium.android.apis", ".view.Buttons1");
driver.startActivity(activity);
startActivity(".view.Buttons1");
Point point = driver.findElement(By.id("io.appium.android.apis:id/button_toggle")).getLocation();
new TouchAction(driver)
.press(point(point.x + 20, point.y + 30))
Expand All @@ -119,8 +116,7 @@ public void setUp() {
}

@Test public void pressByElementTest() {
Activity activity = new Activity("io.appium.android.apis", ".view.Buttons1");
driver.startActivity(activity);
startActivity(".view.Buttons1");
new TouchAction(driver)
.press(element(driver.findElement(By.id("io.appium.android.apis:id/button_toggle"))))
.waitAction(waitOptions(ofSeconds(1)))
Expand All @@ -130,8 +126,7 @@ public void setUp() {
}

@Test public void tapActionTestByElement() throws Exception {
Activity activity = new Activity("io.appium.android.apis", ".view.ChronometerDemo");
driver.startActivity(activity);
startActivity(".view.ChronometerDemo");
WebElement chronometer = driver.findElement(By.id("io.appium.android.apis:id/chronometer"));

TouchAction startStop = new TouchAction(driver)
Expand All @@ -148,8 +143,7 @@ public void setUp() {
}

@Test public void tapActionTestByCoordinates() throws Exception {
Activity activity = new Activity("io.appium.android.apis", ".view.ChronometerDemo");
driver.startActivity(activity);
startActivity(".view.ChronometerDemo");
WebElement chronometer = driver.findElement(By.id("io.appium.android.apis:id/chronometer"));

Point center1 = getCenter(driver.findElement(By.id("io.appium.android.apis:id/start")));
Expand All @@ -166,8 +160,7 @@ public void setUp() {
}

@Test public void horizontalSwipingTest() {
Activity activity = new Activity("io.appium.android.apis", ".view.Gallery1");
driver.startActivity(activity);
startActivity(".view.Gallery1");

WebElement gallery = driver.findElement(By.id("io.appium.android.apis:id/gallery"));
List<WebElement> images = gallery.findElements(AppiumBy.className("android.widget.ImageView"));
Expand All @@ -186,8 +179,7 @@ public void setUp() {
}

@Test public void multiTouchTest() {
Activity activity = new Activity("io.appium.android.apis", ".view.Buttons1");
driver.startActivity(activity);
startActivity(".view.Buttons1");
TouchAction press = new TouchAction(driver)
.press(element(driver.findElement(By.id("io.appium.android.apis:id/button_toggle"))))
.waitAction(waitOptions(ofSeconds(1)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.appium.java_client.android;

import com.google.common.collect.ImmutableMap;
import io.appium.java_client.android.options.UiAutomator2Options;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
Expand Down Expand Up @@ -59,4 +60,13 @@ public class BaseAndroidTest {
service.stop();
}
}

public static void startActivity(String name) {
driver.executeScript(
"mobile: startActivity",
ImmutableMap.of(
"component", String.format("%s/%s", APP_ID, name)
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.appium.java_client.android;

import com.google.common.collect.ImmutableMap;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -24,7 +25,8 @@
public class ClipboardTest extends BaseAndroidTest {

@BeforeEach public void setUp() {
driver.resetApp();
driver.executeScript("mobile: terminateApp", ImmutableMap.of("appId", APP_ID));
driver.executeScript("mobile: activateApp", ImmutableMap.of("appId", APP_ID));
}

@Test public void verifySetAndGetClipboardText() {
Expand Down
Loading