From d10e51e30b326619d646e91eea7267ac2c5f5de8 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Thu, 9 Feb 2017 16:46:15 +0000 Subject: [PATCH] UiAutomator: Updated to decode provided parameters from ParameterDict To prevent parameters having to be converted individually for each worload the getParams() function has been overridden to perform the required type and url decoding on the passed parameter bundle before passing the correctly typed bundle to the workloads. --- .../BaseUiAutomation$ActionLogger.class | Bin 1580 -> 1489 bytes wlauto/common/android/BaseUiAutomation.class | Bin 17711 -> 20359 bytes .../arm/wlauto/uiauto/BaseUiAutomation.java | 94 +++++++++++++++++- 3 files changed, 93 insertions(+), 1 deletion(-) diff --git a/wlauto/common/android/BaseUiAutomation$ActionLogger.class b/wlauto/common/android/BaseUiAutomation$ActionLogger.class index bde4b8f24948bef2add437c9ebd461b2d768618f..af21ee60de111735c45e0e2ebad6bc824fac3ff1 100644 GIT binary patch delta 637 zcmaiv%Tg0T6o$W^0eUjDAsLAn6^UR#hM^|p^-Os{+g zZ-}-un)m?T`4T>cam|)Q@3>jB)|xf{_pkZc^~tRK`2F=eFh)Ls$EeF*vNk&tC+BjO zF_&>BY-cjgl;)gEf~*ba<6Ll==AtcTY`EldnJaOwYOZT$xAO0mnrr-0Lz9O%Z0I9n z*vEcF&zqp~I;>RJ!g8=)3JaQf!wqg~ZW(TK$8dmyjcF${zQA3DUaQuEN^MYc&v2gy zh6NrP9`RW7#IVRyMW<*LWMZlD!Fk)AD2BDgTIFTAsK_*?V(EbyMenQNU63mUMZZ*=GT9+#zdzDM`P(@D zXp@+q^*UN~w%OA}Z$&Bt61`}4Nj@o0l4VhO#!>0}e>FJ9iMo^`7r|7NSsPB2o#d3@ z6lpR$_*Hpmr+ohl`XgyC{*A=*ZCt5iExJ4-p-p#-WQ(3QspWrWlA;AGXjU2KMP$TK zkL0Wqxl{}Z%854J71g^NDiGAVpb9&v|4FBXW>*>R6Pz!F!wARabfxKWjX~5OgMnLX diff --git a/wlauto/common/android/BaseUiAutomation.class b/wlauto/common/android/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h(iYx#Tlsl+NhECJXGck72yAC&2TyeJb7x89e*r0OXrurD diff --git a/wlauto/external/uiauto/src/com/arm/wlauto/uiauto/BaseUiAutomation.java b/wlauto/external/uiauto/src/com/arm/wlauto/uiauto/BaseUiAutomation.java index 1a234d52..d17eb258 100755 --- a/wlauto/external/uiauto/src/com/arm/wlauto/uiauto/BaseUiAutomation.java +++ b/wlauto/external/uiauto/src/com/arm/wlauto/uiauto/BaseUiAutomation.java @@ -84,7 +84,7 @@ public class BaseUiAutomation extends UiAutomatorTestCase { public ActionLogger(String testTag, Bundle parameters) { this.testTag = testTag; - this.enabled = Boolean.parseBoolean(parameters.getString("markers_enabled")); + this.enabled = parameters.getBoolean("markers_enabled"); } public void start() { @@ -619,4 +619,96 @@ public class BaseUiAutomation extends UiAutomatorTestCase { throw new UiObjectNotFoundException("Could not find folder : " + directory); } } + + // Override getParams function to decode a url encoded parameter bundle before + // passing it to workloads. + public Bundle getParams() { + // Get the original parameter bundle + Bundle parameters = super.getParams(); + + // Decode each parameter in the bundle, except null values and "jars", as this + // is automatically added and therefore not encoded. + for (String key : parameters.keySet()) { + String param = parameters.getString(key); + if (param != null && !key.equals("jars")) { + param = android.net.Uri.decode(param); + parameters = decode(parameters, key, param); + } + } + return parameters; + } + + // Helper function to decode a string and insert it as an appropriate type + // into a provided bundle with its key. + // Each bundle parameter will be a urlencoded string with 2 characters prefixed to the value + // used to store the original type information, e.g. 'fl' -> list of floats. + private Bundle decode(Bundle parameters, String key, String value) { + char value_type = value.charAt(0); + char value_dimension = value.charAt(1); + String param = value.substring(2); + + if (value_dimension == 's') { + if (value_type == 's') { + parameters.putString(key, param); + } else if (value_type == 'f') { + parameters.putFloat(key, Float.parseFloat(param)); + } else if (value_type == 'd') { + parameters.putDouble(key, Double.parseDouble(param)); + } else if (value_type == 'b') { + parameters.putBoolean(key, Boolean.parseBoolean(param)); + } else if (value_type == 'i') { + parameters.putInt(key, Integer.parseInt(param)); + } else if (value_type == 'n') { + parameters.putString(key, "None"); + } else { + throw new IllegalArgumentException("Error decoding:" + key + value + + " - unknown format"); + } + } else if (value_dimension == 'l') { + return decodeArray(parameters, key, value_type, param); + } else { + throw new IllegalArgumentException("Error decoding:" + key + value + + " - unknown format"); + } + return parameters; + } + + // Helper function to deal with decoding arrays and update the bundle with + // an appropriate array type. The string "0newelement0" is used to distinguish + // each element for each other in the array when encoded. + private Bundle decodeArray(Bundle parameters, String key, char type, String value) { + String[] string_list = value.split("0newelement0"); + if (type == 's') { + parameters.putStringArray(key, string_list); + } + else if (type == 'i') { + int[] int_list = new int[string_list.length]; + for (int i = 0; i < string_list.length; i++){ + int_list[i] = Integer.parseInt(string_list[i]); + } + parameters.putIntArray(key, int_list); + } else if (type == 'f') { + float[] float_list = new float[string_list.length]; + for (int i = 0; i < string_list.length; i++){ + float_list[i] = Float.parseFloat(string_list[i]); + } + parameters.putFloatArray(key, float_list); + } else if (type == 'd') { + double[] double_list = new double[string_list.length]; + for (int i = 0; i < string_list.length; i++){ + double_list[i] = Double.parseDouble(string_list[i]); + } + parameters.putDoubleArray(key, double_list); + } else if (type == 'b') { + boolean[] boolean_list = new boolean[string_list.length]; + for (int i = 0; i < string_list.length; i++){ + boolean_list[i] = Boolean.parseBoolean(string_list[i]); + } + parameters.putBooleanArray(key, boolean_list); + } else { + throw new IllegalArgumentException("Error decoding array: " + + value + " - unknown format"); + } + return parameters; + } }