Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mykola Mokhnach committed Jan 30, 2018
1 parent 52dd573 commit 96d8eff
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package io.appium.java_client.android;

import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriverException;

import java.time.Duration;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.isEmptyString;
import static org.hamcrest.Matchers.not;

public class AndroidScreenRecordTest extends BaseAndroidTest {

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

@Test
public void verifyBasicScreenRecordingWorks() throws InterruptedException {
try {
driver.startRecordingScreen(
new AndroidStartScreenRecordingOptions()
.withTimeLimit(Duration.ofSeconds(5))
);
} catch (WebDriverException e) {
if (e.getMessage().toLowerCase().contains("emulator")) {
// screen recording only works on real devices
return;
}
}
Thread.sleep(5000);
String result = driver.stopRecordingScreen();
assertThat(result, not(isEmptyString()));
}

}
24 changes: 24 additions & 0 deletions src/test/java/io/appium/java_client/ios/IOSScreenRecordTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.appium.java_client.ios;

import org.junit.Test;

import java.time.Duration;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.isEmptyString;
import static org.hamcrest.Matchers.not;

public class IOSScreenRecordTest extends AppIOSTest {

@Test
public void verifyBasicScreenRecordingWorks() throws InterruptedException {
driver.startRecordingScreen(
new IOSStartScreenRecordingOptions()
.withTimeLimit(Duration.ofSeconds(10))
);
Thread.sleep(5000);
String result = driver.stopRecordingScreen();
assertThat(result, not(isEmptyString()));
}

}

0 comments on commit 96d8eff

Please sign in to comment.