Skip to content
Closed
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
1 change: 1 addition & 0 deletions archive/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Jul 23 20:09:50 IST 2016
#Sat Jan 28 15:49:01 KST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
4 changes: 4 additions & 0 deletions java-client.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
path.variable.kotlin_bundled=/Applications/IntelliJ IDEA.app/Contents/plugins/Kotlin/kotlinc
path.variable.maven_repository=/Users/hwangheeseon/.m2/repository
jdk.home.1.8=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
javac2.instrumentation.includeJavaRuntime=false
346 changes: 346 additions & 0 deletions java-client.xml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions java-client_Sat_Jan_28_12-54-25_KST_2017.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
path.variable.kotlin_bundled=/Applications/IntelliJ IDEA 15.app/Contents/plugins/Kotlin/kotlinc
path.variable.maven_repository=/Users/hwangheeseon/.m2/repository
jdk.home.1.8=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
javac2.instrumentation.includeJavaRuntime=false
345 changes: 345 additions & 0 deletions java-client_Sat_Jan_28_12-54-25_KST_2017.xml

Large diffs are not rendered by default.

330 changes: 330 additions & 0 deletions module_java-client.xml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/main/java/io/appium/java_client/MobileCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class MobileCommand {
protected static final String GET_PERFORMANCE_DATA;
protected static final String GET_SUPPORTED_PERFORMANCE_DATA_TYPES;

protected static final String START_RECORDING_SCREEN;
protected static final String STOP_RECORDING_SCREEN;

protected static final String HIDE_KEYBOARD;
protected static final String LOCK;
Expand Down Expand Up @@ -102,6 +104,9 @@ public class MobileCommand {
GET_PERFORMANCE_DATA = "getPerformanceData";
GET_SUPPORTED_PERFORMANCE_DATA_TYPES = "getSuppportedPerformanceDataTypes";

START_RECORDING_SCREEN = "startRecordingScreen";
STOP_RECORDING_SCREEN = "stopRecordingScreen";

HIDE_KEYBOARD = "hideKeyboard";
LOCK = "lock";
SHAKE = "shake";
Expand Down Expand Up @@ -153,6 +158,11 @@ public class MobileCommand {
commandRepository.put(GET_PERFORMANCE_DATA,
postC("/session/:sessionId/appium/getPerformanceData"));

commandRepository.put(START_RECORDING_SCREEN,
postC("/session/:sessionId/appium/startRecordingScreen"));
commandRepository.put(STOP_RECORDING_SCREEN,
postC("/session/:sessionId/appium/stopRecordingScreen"));

//iOS
commandRepository.put(SHAKE, postC("/session/:sessionId/appium/device/shake"));
commandRepository.put(TOUCH_ID, postC("/session/:sessionId/appium/simulator/touch_id"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@
public class AndroidDriver<T extends WebElement>
extends AppiumDriver<T>
implements PressesKeyCode, HasNetworkConnection, PushesFiles, StartsActivity,
FindsByAndroidUIAutomator<T>, LocksAndroidDevice, HasAndroidSettings, HasDeviceDetails,
HasSupportedPerformanceDataType {
FindsByAndroidUIAutomator<T>, LocksAndroidDevice, HasSettings, HasDeviceDetails,
HasSupportedPerformanceDataType, RecordScreen {


private static final String ANDROID_PLATFORM = MobilePlatform.ANDROID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,48 @@ public class AndroidMobileCommandHelper extends MobileCommand {
GET_PERFORMANCE_DATA, prepareArguments(parameters, values));
}

/**
* record the display of devices running Android 4.4 (API level 19) and higher.
* It records screen activity to an MPEG-4 file. Audio is not recorded with the video file.
*
* @param filePath the video file name
* for example, "/sdcard/demo.mp4"
* @param videoSize the format is widthxheight.
* The default value is the device's native display resolution (if supported),
* 1280x720 if not. For best results,
* use a size supported by your device's Advanced Video Coding (AVC) encoder.
* for example, "1280x720"
* @param timeLimit the maximum recording time, in seconds. The default and maximum value is 180 (3 minutes).
* @param bitRate the video bit rate for the video, in megabits per second.
* The default value is 4Mbps. You can increase the bit rate to improve video quality,
* but doing so results in larger movie files.
* for example, 6000000
* @throws Exception if devices running is less than Android 4.4 (API level 19), or
* running is on emulator,
* thows Error
*/
public static Map.Entry<String, Map<String, ?>> startRecordingScreenCommand(
String filePath, String videoSize, int timeLimit, int bitRate)
throws Exception {
String[] parameters = new String[] {"filePath", "videoSize", "timeLimit", "bitRate"};
Object[] values = new Object[] {filePath, videoSize, timeLimit, bitRate};

return new AbstractMap.SimpleEntry<>(START_RECORDING_SCREEN, prepareArguments(parameters, values));

}

/**
* stop recording the screen.
* @throws Exception if devices running is less than Android 4.4 (API level 19), or
* running is on emulator,
* thows Error
*/
public static Map.Entry<String, Map<String, ?>> stopRecordingScreenCommand()
throws Exception {
return new AbstractMap.SimpleEntry<>(STOP_RECORDING_SCREEN, ImmutableMap.<String, Object>of());

}

/**
* This method forms a {@link java.util.Map} of parameters to
* Retrieve the display density of the Android device.
Expand Down
78 changes: 78 additions & 0 deletions src/main/java/io/appium/java_client/android/RecordScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.appium.java_client.android;

import static io.appium.java_client.android.AndroidMobileCommandHelper.startRecordingScreenCommand;
import static io.appium.java_client.android.AndroidMobileCommandHelper.stopRecordingScreenCommand;

import io.appium.java_client.CommandExecutionHelper;
import io.appium.java_client.ExecutesMethod;

public interface RecordScreen extends ExecutesMethod {
/**
* record the display of devices running Android 4.4 (API level 19) and higher.
* It records screen activity to an MPEG-4 file. Audio is not recorded with the video file.
*
* @param filePath the video file name
* for example, "/sdcard/demo.mp4"
* @param videoSize the format is widthxheight.
* if it is "default", the default value is the device's native display resolution (if supported),
* 1280x720 if not. For best results,
* use a size supported by your device's Advanced Video Coding (AVC) encoder.
* for example, "1280x720"
* @param timeLimit the maximum recording time, in seconds. if it is -1,
* the default and maximum value is 180 (3 minutes).
* @param bitRate the video bit rate for the video, in megabits per second.
* if it is -1, the default value is 4Mbps. You can increase the bit rate to improve video quality,
* but doing so results in larger movie files.
* for example, 6000000
*
*/
default void startRecordingScreen(String filePath, String videoSize, int timeLimit, int bitRate) throws Exception {
CommandExecutionHelper.execute(this, startRecordingScreenCommand( filePath, videoSize, timeLimit, bitRate ));
}

/**
* record the display of devices running Android 4.4 (API level 19) and higher.
* It records screen activity to an MPEG-4 file. Audio is not recorded with the video file.
* The video size has the default value which is the device's native display resolution (if supported).
* The maximum recording time has the default value which is 180 (3 minutes).
* The video bit rate has the default value which is 4Mbps.
*
* @param filePath the video file name
* for example, "/sdcard/demo.mp4"
* @throws Exception if devices running is less than Android 4.4 (API level 19), or
* running is on emulator,
* thows Error
*
*/
default void startRecordingScreen(String filePath) throws Exception {
CommandExecutionHelper.execute(this, startRecordingScreenCommand( filePath, "default", -1, -1 ));
}

/**
* stop recording the screen.
*
* @throws Exception if devices running is less than Android 4.4 (API level 19), or
* running is on emulator,
* thows Error
*/
default void stopRecordingScreen() throws Exception {
CommandExecutionHelper.execute(this, stopRecordingScreenCommand());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public class AndroidDriverTest extends BaseAndroidTest {
}

@Test public void getSupportedPerformanceDataTypesTest() {

driver.startActivity(new Activity("io.appium.android.apis", ".ApiDemos"));

List<String> dataTypes = new ArrayList<String>();
Expand Down Expand Up @@ -181,6 +182,44 @@ public class AndroidDriverTest extends BaseAndroidTest {

}

@Test public void getStartRecordingScreenTest() {
driver.startActivity(new Activity("io.appium.android.apis", ".ApiDemos"));

String filePath = "/sdcard/demo321.mp4";

try {
driver.startRecordingScreen(filePath);
assertTrue(false);
} catch (Exception e) {
}

try {
driver.stopRecordingScreen();
assertTrue(false);
} catch (Exception e) {
}
}

@Test public void getStopRecordingScreenTest() {
driver.startActivity(new Activity("io.appium.android.apis", ".ApiDemos"));

String filePath = "/sdcard/demo321.mp4";

try {
driver.startRecordingScreen(filePath);
assertTrue(false);
} catch (Exception e) {
}


try {
driver.stopRecordingScreen();
} catch (Exception e) {
e.printStackTrace();
}

}

@Test public void getCurrentPackageTest() {
assertEquals("io.appium.android.apis",driver.getCurrentPackage());
}
Expand Down