Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add an optional format argument to getDeviceTime and update the documentation #939

Merged
merged 3 commits into from
Jun 13, 2018
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
24 changes: 22 additions & 2 deletions src/main/java/io/appium/java_client/HasDeviceTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,31 @@

import static io.appium.java_client.MobileCommand.GET_DEVICE_TIME;

import com.google.common.collect.ImmutableMap;

import org.openqa.selenium.remote.Response;

public interface HasDeviceTime extends ExecutesMethod {
/*
Gets device date and time for both iOS(Supports only real device) and Android devices

/**
* Gets device date and time for both iOS(host time is returned for simulators) and Android devices.
*
* @param format The set of format specifiers. Read
* https://momentjs.com/docs/ to get the full list of supported
* datetime format specifiers. The default format is
* `YYYY-MM-DDTHH:mm:ssZ`, which complies to ISO-8601
* @return Device time string
*/
default String getDeviceTime(String format) {
Response response = execute(GET_DEVICE_TIME, ImmutableMap.of("format", format));
return response.getValue().toString();
}

/**
* Gets device date and time for both iOS(host time is returned for simulators) and Android devices.
* The default format since Appium 1.8.2 is `YYYY-MM-DDTHH:mm:ssZ`, which complies to ISO-8601.
*
* @return Device time string
*/
default String getDeviceTime() {
Response response = execute(GET_DEVICE_TIME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public class AndroidDriverTest extends BaseAndroidTest {

@Test public void getDeviceTimeTest() {
String time = driver.getDeviceTime();
assertTrue(time.length() == 28);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import statement can also be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which import?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's still used by isAppInstalledTest and lockTest. Codacy usually highlights such cases automatically.

assertFalse(time.isEmpty());
}

@Test public void isAppInstalledTest() {
Expand Down
5 changes: 2 additions & 3 deletions src/test/java/io/appium/java_client/ios/IOSDriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@

public class IOSDriverTest extends AppIOSTest {

//TODO There is no ability to check this function usibg simulators.
// When CI will have been set up then this test will be returned
@Test
public void getDeviceTimeTest() {
String time = driver.getDeviceTime();
assertTrue(time.length() == 28);
assertFalse(time.isEmpty());
}

@Test public void resetTest() {
Expand Down