-
-
Notifications
You must be signed in to change notification settings - Fork 765
add apis to read the performance data #562
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
Changes from 1 commit
500717b
26d7c1d
d5fcf64
c0f3f62
dd7885f
be76b26
e0ab11f
669f0a8
fb890a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| import org.openqa.selenium.internal.HasIdentity; | ||
|
|
||
| import java.util.AbstractMap; | ||
| import java.util.List; | ||
|
||
| import java.util.Map; | ||
|
|
||
| /** | ||
|
|
@@ -63,6 +64,55 @@ public class AndroidMobileCommandHelper extends MobileCommand { | |
| END_TEST_COVERAGE, prepareArguments(parameters, values)); | ||
| } | ||
|
|
||
| /** | ||
| * returns the information type of the system state which is supported to read | ||
| * as like cpu, memory, network traffic, and battery. | ||
| * @return output - array like below | ||
| * [cpuinfo, batteryinfo, networkinfo, memoryinfo] | ||
| * | ||
| */ | ||
| public static Map.Entry<String, Map<String, ?>> getSupportedPerformanceDataTypesCommand() { | ||
| return new AbstractMap.SimpleEntry<>( | ||
| GET_SUPPORTED_PERFORMANCE_DATA_TYPES, ImmutableMap.<String, Object>of()); | ||
| } | ||
|
|
||
| /** | ||
| * returns the resource usage information of the application. the resource is one of the system state | ||
| * which means cpu, memory, network traffic, and battery. | ||
| * | ||
| * @param packageName the package name of the application | ||
| * @param dataType the type of system state which wants to read. | ||
| * It should be one of the supported performance data types, | ||
| * the return value of the function "getSupportedPerformanceDataTypes" | ||
| * @param dataReadTimeout the number of attempts to read | ||
| * @return table of the performance data, The first line of the table represents the type of data. | ||
| * The remaining lines represent the values of the data. | ||
| * in case of battery info : [[power], [23]] | ||
| * in case of memory info : | ||
| * [[totalPrivateDirty, nativePrivateDirty, dalvikPrivateDirty, eglPrivateDirty, glPrivateDirty, | ||
| * totalPss, nativePss, dalvikPss, eglPss, glPss, nativeHeapAllocatedSize, nativeHeapSize], | ||
| * [18360, 8296, 6132, null, null, 42588, 8406, 7024, null, null, 26519, 10344]] | ||
| * in case of network info : | ||
| * [[bucketStart, activeTime, rxBytes, rxPackets, txBytes, txPackets, operations, bucketDuration,], | ||
| * [1478091600000, null, 1099075, 610947, 928, 114362, 769, 0, 3600000], | ||
| * [1478095200000, null, 1306300, 405997, 509, 46359, 370, 0, 3600000]] | ||
| * in case of network info : | ||
| * [[st, activeTime, rb, rp, tb, tp, op, bucketDuration], | ||
| * [1478088000, null, null, 32115296, 34291, 2956805, 25705, 0, 3600], | ||
| * [1478091600, null, null, 2714683, 11821, 1420564, 12650, 0, 3600], | ||
| * [1478095200, null, null, 10079213, 19962, 2487705, 20015, 0, 3600], | ||
| * [1478098800, null, null, 4444433, 10227, 1430356, 10493, 0, 3600]] | ||
| * in case of cpu info : [[user, kernel], [0.9, 1.3]] | ||
| * @throws if the performance data type is not supported, thows Error | ||
| */ | ||
| public static Map.Entry<String, Map<String, ?>> getPerformanceDataCommand( | ||
| String packageName, String dataType, int dataReadTimeout) { | ||
| String[] parameters = new String[] {"packageName", "dataType", "dataReadTimeout"}; | ||
| Object[] values = new Object[] {packageName, dataType, dataReadTimeout}; | ||
| return new AbstractMap.SimpleEntry<>( | ||
| GET_PERFORMANCE_DATA, prepareArguments(parameters, values)); | ||
| } | ||
|
|
||
| /** | ||
| * This method forms a {@link java.util.Map} of parameters to | ||
| * Retrieve the display density of the Android device. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ | |
|
|
||
| import java.io.File; | ||
| import java.util.Map; | ||
| import java.util.List; | ||
|
|
||
| public class AndroidDriverTest extends BaseAndroidTest { | ||
|
|
||
|
|
@@ -140,4 +141,33 @@ public class AndroidDriverTest extends BaseAndroidTest { | |
| assertNotNull(driver.getDisplayDensity()); | ||
| assertNotEquals(0, driver.getSystemBars().size()); | ||
| } | ||
|
|
||
| @Test public void getSupportedPerformanceDataTypesTest() { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok I used assertEquals |
||
| driver.startActivity("io.appium.android.apis", ".ApiDemos"); | ||
|
|
||
| List<String> supportedPerformanceDataTypes = driver.getSupportedPerformanceDataTypes(); | ||
| assert(supportedPerformanceDataTypes.size() == 4); | ||
|
||
|
|
||
| } | ||
|
|
||
| @Test public void getPerformanceDataTest() { | ||
| driver.startActivity("io.appium.android.apis", ".ApiDemos"); | ||
|
|
||
| List<String> supportedPerformanceDataTypes = driver.getSupportedPerformanceDataTypes(); | ||
|
|
||
| for(int i = 0 ; i < supportedPerformanceDataTypes.size() ; ++ i){ | ||
|
||
|
|
||
| String dataType = supportedPerformanceDataTypes.get(i); | ||
|
|
||
| List<List<Object>> valueTable = driver.getPerformanceData("com.example.android.apis", dataType, 60000); | ||
|
|
||
| int valueTableHeadLength = valueTable.get(0).size(); | ||
|
|
||
| for(int j = 1 ; j < valueTable.size() ; ++ j){ | ||
|
||
| assert(valueTableHeadLength == valueTable.get(j).size()); | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @heeseon
Everything is ok but... could you remove the code below and move java doc to the
HasSupportedPerformanceDataType? It is not necessary to duplicate code of API implemented by default. I think there is no specific details of the AndroidDriver behaviour.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heeseon ping