diff --git a/.gitignore b/.gitignore index de914dde..3d4d6ebf 100644 --- a/.gitignore +++ b/.gitignore @@ -39,9 +39,9 @@ DerivedData *.dSYM *.a *.pfx -ext/iOS/AdjustSdk.framework -ext/iOS/src/AdjustExtension/include/Adjust/AdjustSdk.framework -ext/Android/adjust-android.jar +ext/ios/AdjustSdk.framework +ext/ios/src/AdjustExtension/include/Adjust/AdjustSdk.framework +ext/android/adjust-android.jar ### Android Studio ### local.properties diff --git a/CHANGELOG.md b/CHANGELOG.md index 71e1d5b3..3603108f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +### Version 4.18.0 (26th November 2019) +#### Added +- Added 64-bit support to ANE for Android platform. +- Added `trackAdRevenue` method to `Adjust` interface to allow tracking of ad revenue. With this release added support for `MoPub` ad revenue tracking. + +#### Native SDKs +- [iOS@v4.18.3][ios_sdk_v4.18.3] +- [Android@v4.18.4][android_sdk_v4.18.4] + +--- + ### Version 4.17.2 (21st February 2019) #### Changed - Increased **ios_version_min** to **8.0** from **6.0** (for reference: https://github.com/adjust/adobe_air_sdk/issues/46). @@ -407,6 +418,7 @@ [ios_sdk_v4.13.0]: https://github.com/adjust/ios_sdk/tree/v4.13.0 [ios_sdk_v4.14.1]: https://github.com/adjust/ios_sdk/tree/v4.14.1 [ios_sdk_v4.17.1]: https://github.com/adjust/ios_sdk/tree/v4.17.1 +[ios_sdk_v4.18.3]: https://github.com/adjust/ios_sdk/tree/v4.18.3 [android_sdk_v2.1.3]: https://github.com/adjust/android_sdk/tree/v2.1.3 [android_sdk_v2.1.4]: https://github.com/adjust/android_sdk/tree/v2.1.4 @@ -426,3 +438,4 @@ [android_sdk_v4.13.0]: https://github.com/adjust/android_sdk/tree/v4.13.0 [android_sdk_v4.14.0]: https://github.com/adjust/android_sdk/tree/v4.14.0 [android_sdk_v4.17.0]: https://github.com/adjust/android_sdk/tree/v4.17.0 +[android_sdk_v4.18.4]: https://github.com/adjust/android_sdk/tree/v4.18.4 diff --git a/VERSION b/VERSION index 1c8fd19f..b30c4dcb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.17.2 +4.18.0 diff --git a/default/src/com/adjust/sdk/Adjust.as b/default/src/com/adjust/sdk/Adjust.as index 5630de80..bcf249a2 100644 --- a/default/src/com/adjust/sdk/Adjust.as +++ b/default/src/com/adjust/sdk/Adjust.as @@ -96,6 +96,10 @@ package com.adjust.sdk { trace("Adjust: gdprForgetMe called"); } + public static function trackAdRevenue(source:String, payload:String):void { + trace("Adjust: trackAdRevenue called"); + } + public static function setTestOptions(testOptions:AdjustTestOptions):void { trace("Adjust: setTestOptions called"); } diff --git a/doc/migrate.md b/doc/migrate.md index cf4909a5..4b81faa8 100644 --- a/doc/migrate.md +++ b/doc/migrate.md @@ -1,4 +1,4 @@ -## Migrate your adjust SDK for Adobe AIR to 4.17.2 from 3.4.3 +## Migrate your adjust SDK for Adobe AIR to 4.18.0 from 3.4.3 ### SDK initialization diff --git a/example/Main-app.xml b/example/Main-app.xml index 1443eeb4..f17d2805 100644 --- a/example/Main-app.xml +++ b/example/Main-app.xml @@ -1,7 +1,7 @@ - + com.adjust.examples - 4.17.2 + 4.18.0 Adjust AIR SDK Demo @@ -56,11 +56,6 @@ - - - getFunctions() { functions.put(AdjustContext.GetAttribution, new AdjustFunction(AdjustContext.GetAttribution)); functions.put(AdjustContext.GetSdkVersion, new AdjustFunction(AdjustContext.GetSdkVersion)); functions.put(AdjustContext.GdprForgetMe, new AdjustFunction(AdjustContext.GdprForgetMe)); + functions.put(AdjustContext.TrackAdRevenue, new AdjustFunction(AdjustContext.TrackAdRevenue)); // iOS methods. functions.put(AdjustContext.GetIdfa, new AdjustFunction(AdjustContext.GetIdfa)); // Test methods. diff --git a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/AdjustEvent.java b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/AdjustEvent.java index fe81aab5..0586f179 100644 --- a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/AdjustEvent.java +++ b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/AdjustEvent.java @@ -77,8 +77,8 @@ private static boolean checkEventToken(String eventToken, ILogger logger) { logger.error("Missing Event Token"); return false; } - if (eventToken.length() != 6) { - logger.error("Malformed Event Token '%s'", eventToken); + if (eventToken.length() <= 0) { + logger.error("Event Token can't be empty"); return false; } return true; diff --git a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/AdjustFunction.java b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/AdjustFunction.java index bb5a1cf6..da4bf79b 100644 --- a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/AdjustFunction.java +++ b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/AdjustFunction.java @@ -12,6 +12,7 @@ import com.adobe.fre.*; import android.net.Uri; import android.util.Log; +import org.json.JSONObject; public class AdjustFunction implements FREFunction, OnAttributionChangedListener, @@ -88,6 +89,9 @@ public FREObject call(FREContext freContext, FREObject[] freObjects) { if (functionName == AdjustContext.SendFirstPackages) { return SendFirstPackages(freContext, freObjects); } + if (functionName == AdjustContext.TrackAdRevenue) { + return TrackAdRevenue(freContext, freObjects); + } if (functionName == AdjustContext.GetAdid) { return GetAdid(freContext, freObjects); } @@ -449,6 +453,19 @@ private FREObject SendFirstPackages(FREContext freContext, FREObject[] freObject return null; } + private FREObject TrackAdRevenue(FREContext freContext, FREObject[] freObjects) { + try { + String source = freObjects[0].getAsString(); + String payload = freObjects[1].getAsString(); + JSONObject jsonPayload = new JSONObject(payload); + Adjust.trackAdRevenue(source, jsonPayload); + } catch (Exception e) { + Log.e(AdjustExtension.LogTag, e.getMessage()); + } + + return null; + } + private FREObject SetOfflineMode(FREContext freContext, FREObject[] freObjects) { try { Boolean isOffline = freObjects[0].getAsBool(); diff --git a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/AdjustInstance.java b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/AdjustInstance.java index 512c4132..9baf5b65 100644 --- a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/AdjustInstance.java +++ b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/AdjustInstance.java @@ -3,6 +3,8 @@ import android.net.Uri; import android.content.Context; +import org.json.JSONObject; + import java.util.List; import java.util.ArrayList; @@ -387,6 +389,19 @@ public void gdprForgetMe(final Context context) { } } + /** + * Track ad revenue from a source provider + * + * @param source Source of ad revenue information, see AdjustConfig.AD_REVENUE_* for some possible sources + * @param adRevenueJson JsonObject content of the ad revenue information + */ + public void trackAdRevenue(String source, JSONObject adRevenueJson) { + if (!checkActivityHandler()) { + return; + } + activityHandler.trackAdRevenue(source, adRevenueJson); + } + /** * Called to get value of unique Adjust device identifier. * diff --git a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/Constants.java b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/Constants.java index 7d815c41..3c0b5c3e 100644 --- a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/Constants.java +++ b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/Constants.java @@ -30,7 +30,7 @@ public interface Constants { String GDPR_URL = "https://gdpr.adjust.com"; String SCHEME = "https"; String AUTHORITY = "app.adjust.com"; - String CLIENT_SDK = "android4.17.0"; + String CLIENT_SDK = "android4.18.4"; String LOGTAG = "Adjust"; String REFTAG = "reftag"; String INSTALL_REFERRER = "install_referrer"; diff --git a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/DeviceInfo.java b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/DeviceInfo.java index 3cb9656a..e2671d2c 100644 --- a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/DeviceInfo.java +++ b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/DeviceInfo.java @@ -1,9 +1,11 @@ package com.adjust.sdk; +import android.annotation.SuppressLint; import android.content.ContentResolver; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.content.pm.Signature; import android.content.res.Configuration; import android.content.res.Resources; import android.database.Cursor; @@ -27,6 +29,26 @@ * Created by pfms on 06/11/14. */ class DeviceInfo { + + private static final String OFFICIAL_FACEBOOK_SIGNATURE = + "30820268308201d102044a9c4610300d06092a864886f70d0101040500307a310b3009060355040613" + + "025553310b3009060355040813024341311230100603550407130950616c6f20416c746f31" + + "183016060355040a130f46616365626f6f6b204d6f62696c653111300f060355040b130846" + + "616365626f6f6b311d301b0603550403131446616365626f6f6b20436f72706f726174696f" + + "6e3020170d3039303833313231353231365a180f32303530303932353231353231365a307a" + + "310b3009060355040613025553310b30090603550408130243413112301006035504071309" + + "50616c6f20416c746f31183016060355040a130f46616365626f6f6b204d6f62696c653111" + + "300f060355040b130846616365626f6f6b311d301b0603550403131446616365626f6f6b20" + + "436f72706f726174696f6e30819f300d06092a864886f70d010101050003818d0030818902" + + "818100c207d51df8eb8c97d93ba0c8c1002c928fab00dc1b42fca5e66e99cc3023ed2d214d" + + "822bc59e8e35ddcf5f44c7ae8ade50d7e0c434f500e6c131f4a2834f987fc46406115de201" + + "8ebbb0d5a3c261bd97581ccfef76afc7135a6d59e8855ecd7eacc8f8737e794c60a761c536" + + "b72b11fac8e603f5da1a2d54aa103b8a13c0dbc10203010001300d06092a864886f70d0101" + + "040500038181005ee9be8bcbb250648d3b741290a82a1c9dc2e76a0af2f2228f1d9f9c4007" + + "529c446a70175c5a900d5141812866db46be6559e2141616483998211f4a673149fb2232a1" + + "0d247663b26a9031e15f84bc1c74d141ff98a02d76f85b2c8ab2571b6469b232d8e768a7f7" + + "ca04f7abe4a775615916c07940656b58717457b42bd928a2"; + String playAdId; String playAdIdSource; Boolean isTrackingEnabled; @@ -294,6 +316,20 @@ private String getMacShortMd5(String macAddress) { private String getFacebookAttributionId(final Context context) { try { + @SuppressLint("PackageManagerGetSignatures") + Signature[] signatures = context.getPackageManager().getPackageInfo( + "com.facebook.katana", + PackageManager.GET_SIGNATURES).signatures; + if (signatures == null || signatures.length != 1) { + // Unable to find the correct signatures for this APK + return null; + } + Signature facebookApkSignature = signatures[0]; + if (!OFFICIAL_FACEBOOK_SIGNATURE.equals(facebookApkSignature.toCharsString())) { + // not the official Facebook application + return null; + } + final ContentResolver contentResolver = context.getContentResolver(); final Uri uri = Uri.parse("content://com.facebook.katana.provider.AttributionIdProvider"); final String columnName = "aid"; diff --git a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/IActivityHandler.java b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/IActivityHandler.java index bf506a65..e366ecb9 100644 --- a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/IActivityHandler.java +++ b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/IActivityHandler.java @@ -3,6 +3,8 @@ import android.content.Context; import android.net.Uri; +import org.json.JSONObject; + /** * Created by pfms on 15/12/14. */ @@ -61,6 +63,8 @@ public interface IActivityHandler { void gdprForgetMe(); + void trackAdRevenue(String source, JSONObject adRevenueJson); + void gotOptOutResponse(); Context getContext(); diff --git a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/PackageBuilder.java b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/PackageBuilder.java index 71e47a4c..4ef1b5a1 100644 --- a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/PackageBuilder.java +++ b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/PackageBuilder.java @@ -135,6 +135,16 @@ ActivityPackage buildGdprPackage() { return gdprPackage; } + ActivityPackage buildAdRevenuePackage(String source, JSONObject adRevenueJson) { + Map parameters = getAdRevenueParameters(source, adRevenueJson); + ActivityPackage adRevenuePackage = getDefaultActivityPackage(ActivityKind.AD_REVENUE); + adRevenuePackage.setPath("/ad_revenue"); + adRevenuePackage.setSuffix(""); + adRevenuePackage.setParameters(parameters); + return adRevenuePackage; + + } + private Map getSessionParameters(boolean isInDelay) { ContentResolver contentResolver = adjustConfig.context.getContentResolver(); Map parameters = new HashMap(); @@ -145,6 +155,12 @@ private Map getSessionParameters(boolean isInDelay) { parameters.putAll(imeiParameters); } + // Check if oaid plugin is used and if yes, add the parameter + Map oaidParameters = Reflection.getOaidParameters(adjustConfig.context, logger); + if (oaidParameters != null) { + parameters.putAll(oaidParameters); + } + // Callback and partner parameters. if (!isInDelay) { PackageBuilder.addMapJson(parameters, "callback_params", this.sessionParameters.callbackParameters); @@ -225,6 +241,12 @@ public Map getEventParameters(AdjustEvent event, boolean isInDel parameters.putAll(imeiParameters); } + // Check if oaid plugin is used and if yes, add the parameter + Map oaidParameters = Reflection.getOaidParameters(adjustConfig.context, logger); + if (oaidParameters != null) { + parameters.putAll(oaidParameters); + } + // Callback and partner parameters. if (!isInDelay) { PackageBuilder.addMapJson(parameters, "callback_params", Util.mergeParameters(this.sessionParameters.callbackParameters, event.callbackParameters, "Callback")); @@ -306,6 +328,12 @@ private Map getInfoParameters(String source) { parameters.putAll(imeiParameters); } + // Check if oaid plugin is used and if yes, add the parameter + Map oaidParameters = Reflection.getOaidParameters(adjustConfig.context, logger); + if (oaidParameters != null) { + parameters.putAll(oaidParameters); + } + // Device identifiers. deviceInfo.reloadPlayIds(adjustConfig.context); PackageBuilder.addString(parameters, "android_uuid", activityStateCopy.uuid); @@ -350,6 +378,12 @@ private Map getClickParameters(String source) { parameters.putAll(imeiParameters); } + // Check if oaid plugin is used and if yes, add the parameter + Map oaidParameters = Reflection.getOaidParameters(adjustConfig.context, logger); + if (oaidParameters != null) { + parameters.putAll(oaidParameters); + } + // Device identifiers. deviceInfo.reloadPlayIds(adjustConfig.context); PackageBuilder.addString(parameters, "android_uuid", activityStateCopy.uuid); @@ -442,6 +476,12 @@ private Map getAttributionParameters(String initiatedBy) { parameters.putAll(imeiParameters); } + // Check if oaid plugin is used and if yes, add the parameter + Map oaidParameters = Reflection.getOaidParameters(adjustConfig.context, logger); + if (oaidParameters != null) { + parameters.putAll(oaidParameters); + } + // Device identifiers. deviceInfo.reloadPlayIds(adjustConfig.context); PackageBuilder.addString(parameters, "android_uuid", activityStateCopy.uuid); @@ -493,6 +533,12 @@ private Map getGdprParameters() { parameters.putAll(imeiParameters); } + // Check if oaid plugin is used and if yes, add the parameter + Map oaidParameters = Reflection.getOaidParameters(adjustConfig.context, logger); + if (oaidParameters != null) { + parameters.putAll(oaidParameters); + } + // Device identifiers. deviceInfo.reloadPlayIds(adjustConfig.context); PackageBuilder.addString(parameters, "android_uuid", activityStateCopy.uuid); @@ -533,6 +579,57 @@ private Map getGdprParameters() { return parameters; } + private Map getAdRevenueParameters(String source, JSONObject adRevenueJson) { + ContentResolver contentResolver = adjustConfig.context.getContentResolver(); + Map parameters = new HashMap(); + Map imeiParameters = Reflection.getImeiParameters(adjustConfig.context, logger); + + // Check if plugin is used and if yes, add read parameters. + if (imeiParameters != null) { + parameters.putAll(imeiParameters); + } + + // Check if oaid plugin is used and if yes, add the parameter + Map oaidParameters = Reflection.getOaidParameters(adjustConfig.context, logger); + if (oaidParameters != null) { + parameters.putAll(oaidParameters); + } + + // Device identifiers. + deviceInfo.reloadPlayIds(adjustConfig.context); + PackageBuilder.addString(parameters, "android_uuid", activityStateCopy.uuid); + PackageBuilder.addBoolean(parameters, "tracking_enabled", deviceInfo.isTrackingEnabled); + PackageBuilder.addString(parameters, "gps_adid", deviceInfo.playAdId); + PackageBuilder.addString(parameters, "gps_adid_src", deviceInfo.playAdIdSource); + + if (!containsPlayIds(parameters)) { + logger.warn("Google Advertising ID not detected, fallback to non Google Play identifiers will take place"); + deviceInfo.reloadNonPlayIds(adjustConfig.context); + PackageBuilder.addString(parameters, "mac_sha1", deviceInfo.macSha1); + PackageBuilder.addString(parameters, "mac_md5", deviceInfo.macShortMd5); + PackageBuilder.addString(parameters, "android_id", deviceInfo.androidId); + } + + // Rest of the parameters. + PackageBuilder.addString(parameters, "app_secret", adjustConfig.appSecret); + PackageBuilder.addString(parameters, "app_token", adjustConfig.appToken); + PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); + PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); + PackageBuilder.addBoolean(parameters, "device_known", adjustConfig.deviceKnown); + PackageBuilder.addString(parameters, "environment", adjustConfig.environment); + PackageBuilder.addBoolean(parameters, "event_buffering_enabled", adjustConfig.eventBufferingEnabled); + PackageBuilder.addString(parameters, "fire_adid", Util.getFireAdvertisingId(contentResolver)); + PackageBuilder.addBoolean(parameters, "fire_tracking_enabled", Util.getFireTrackingEnabled(contentResolver)); + PackageBuilder.addBoolean(parameters, "needs_response_details", true); + PackageBuilder.addString(parameters, "push_token", activityStateCopy.pushToken); + PackageBuilder.addString(parameters, "secret_id", adjustConfig.secretId); + PackageBuilder.addString(parameters, "source", source); + PackageBuilder.addJsonObject(parameters, "payload", adRevenueJson); + + checkDeviceIds(parameters); + return parameters; + } + private ActivityPackage getDefaultActivityPackage(ActivityKind activityKind) { ActivityPackage activityPackage = new ActivityPackage(activityKind); activityPackage.setClientSdk(deviceInfo.clientSdk); @@ -554,6 +651,14 @@ public static void addBoolean(Map parameters, String key, Boolea PackageBuilder.addLong(parameters, key, intValue); } + static void addJsonObject(Map parameters, String key, JSONObject jsonObject) { + if (jsonObject == null) { + return; + } + + PackageBuilder.addString(parameters, key, jsonObject.toString()); + } + static void addMapJson(Map parameters, String key, Map map) { if (map == null) { return; diff --git a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/Reflection.java b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/Reflection.java index 1a58095b..5505d62b 100644 --- a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/Reflection.java +++ b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/Reflection.java @@ -30,6 +30,19 @@ static Map getImeiParameters(Context context, ILogger logger) { return null; } + static Map getOaidParameters(Context context, ILogger logger) { + Object oaidParameters = null; + try { + oaidParameters = invokeStaticMethod("com.adjust.sdk.oaid.Util", "getOaidParameters", new Class[]{Context.class, ILogger.class}, context, logger); + Class> stringStringMapClass = (Class>) (Class) Map.class; + if (oaidParameters != null && stringStringMapClass.isInstance(oaidParameters)) { + return (Map) oaidParameters; + } + } catch (Exception e) { + } + return null; + } + public static String getPlayAdId(Context context) { try { Object AdvertisingInfoObject = getAdvertisingInfoObject(context); diff --git a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/Util.java b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/Util.java index fc1ea0a6..6b5108a3 100644 --- a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/Util.java +++ b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/Util.java @@ -14,6 +14,8 @@ import android.content.pm.PackageManager; import android.content.res.Configuration; import android.net.ConnectivityManager; +import android.net.Network; +import android.net.NetworkCapabilities; import android.net.NetworkInfo; import android.net.Uri; import android.os.AsyncTask; @@ -496,17 +498,69 @@ public static Boolean getFireTrackingEnabled(ContentResolver contentResolver) { } public static int getConnectivityType(Context context) { - int connectivityType = -1; // default value that will not be send - try { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); - connectivityType = activeNetwork.getType(); + + if (cm == null) { + return -1; + } + + // for api 22 or lower, still need to get raw type + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); + return activeNetwork.getType(); + } + + // .getActiveNetwork() is only available from api 23 + Network activeNetwork = cm.getActiveNetwork(); + if (activeNetwork == null) { + return -1; + } + + NetworkCapabilities activeNetworkCapabilities = cm.getNetworkCapabilities(activeNetwork); + if (activeNetworkCapabilities == null) { + return -1; + } + + // check each network capability available from api 23 + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) { + return NetworkCapabilities.TRANSPORT_WIFI; + } + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) { + return NetworkCapabilities.TRANSPORT_CELLULAR; + } + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) { + return NetworkCapabilities.TRANSPORT_ETHERNET; + } + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)) { + return NetworkCapabilities.TRANSPORT_VPN; + } + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH)) { + return NetworkCapabilities.TRANSPORT_BLUETOOTH; + } + + // only after api 26, that more transport capabilities were added + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { + return -1; + } + + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI_AWARE)) { + return NetworkCapabilities.TRANSPORT_WIFI_AWARE; + } + + // and then after api 27, that more transport capabilities were added + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O_MR1) { + return -1; + } + + if (activeNetworkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_LOWPAN)) { + return NetworkCapabilities.TRANSPORT_LOWPAN; + } } catch (Exception e) { getLogger().warn("Couldn't read connectivity type (%s)", e.getMessage()); } - return connectivityType; + return -1; } public static int getNetworkType(Context context) { diff --git a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/UtilNetworking.java b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/UtilNetworking.java index e159dd37..84f5a05b 100644 --- a/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/UtilNetworking.java +++ b/ext/android/src/AdjustExtension/extension/src/main/java/com/adjust/sdk/UtilNetworking.java @@ -318,6 +318,12 @@ private static Map getSignature( String deviceIdentifierName = getValidIdentifier(parameters); String deviceIdentifier = parameters.get(deviceIdentifierName); + String sourceName = "source"; + String sourceValue = parameters.get(sourceName); + + String payloadName = "payload"; + String payloadValue = parameters.get(payloadName); + Map signatureParams = new HashMap(); signatureParams.put("app_secret", appSecret); @@ -325,6 +331,14 @@ private static Map getSignature( signatureParams.put(activityKindName, activityKindValue); signatureParams.put(deviceIdentifierName, deviceIdentifier); + if (sourceValue != null) { + signatureParams.put(sourceName, sourceValue); + } + + if (payloadValue != null) { + signatureParams.put(payloadName, payloadValue); + } + String fields = ""; String clearSignature = ""; diff --git a/ext/android/src/AdjustExtension/gradle/wrapper/gradle-wrapper.properties b/ext/android/src/AdjustExtension/gradle/wrapper/gradle-wrapper.properties index dfbc6167..a56213f8 100644 --- a/ext/android/src/AdjustExtension/gradle/wrapper/gradle-wrapper.properties +++ b/ext/android/src/AdjustExtension/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/ext/ios/sdk b/ext/ios/sdk index ace81b8f..46cddbab 160000 --- a/ext/ios/sdk +++ b/ext/ios/sdk @@ -1 +1 @@ -Subproject commit ace81b8fafeb66285c51dac19562eef03bda94d4 +Subproject commit 46cddbab63baae4593d0a4757f2308144596c0cd diff --git a/ext/ios/src/AdjustExtension/AdjustExtension/AdjustFunction.h b/ext/ios/src/AdjustExtension/AdjustExtension/AdjustFunction.h index 5875f390..93a23a67 100644 --- a/ext/ios/src/AdjustExtension/AdjustExtension/AdjustFunction.h +++ b/ext/ios/src/AdjustExtension/AdjustExtension/AdjustFunction.h @@ -32,6 +32,7 @@ FREObject ADJgetAdid(FREContext ctx, void* funcData, uint32_t argc, FREObject ar FREObject ADJgetAttribution(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]); FREObject ADJgetSdkVersion(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]); FREObject ADJgdprForgetMe(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]); +FREObject ADJtrackAdRevenue(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]); // Android methods. FREObject ADJonResume(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]); FREObject ADJonPause(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]); diff --git a/ext/ios/src/AdjustExtension/AdjustExtension/AdjustFunction.m b/ext/ios/src/AdjustExtension/AdjustExtension/AdjustFunction.m index c93f4b8a..3f9b647e 100644 --- a/ext/ios/src/AdjustExtension/AdjustExtension/AdjustFunction.m +++ b/ext/ios/src/AdjustExtension/AdjustExtension/AdjustFunction.m @@ -548,6 +548,27 @@ FREObject ADJgdprForgetMe(FREContext ctx, void* funcData, uint32_t argc, FREObje return return_value; } +FREObject ADJtrackAdRevenue(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) { + if (argc == 2) { + NSString *source = nil; + NSString *payload = nil; + if (argv[0] != nil) { + FREGetObjectAsNativeString(argv[0], &source); + } + if (argv[1] != nil) { + FREGetObjectAsNativeString(argv[1], &payload); + } + NSData *dataPayload = [payload dataUsingEncoding:NSUTF8StringEncoding]; + [Adjust trackAdRevenue:source payload:dataPayload]; + } else { + NSLog(@"AdjustFunction: Bridge trackAdRevenue method triggered with wrong number of arguments"); + } + + FREObject return_value; + FRENewObjectFromBool(true, &return_value); + return return_value; +} + FREObject ADJsetTestOptions(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) { if (argc == 13) { AdjustTestOptions * testOptions = [[AdjustTestOptions alloc] init]; diff --git a/ext/scripts b/ext/scripts index e8ce5468..f21a31ff 160000 --- a/ext/scripts +++ b/ext/scripts @@ -1 +1 @@ -Subproject commit e8ce54686e3e9f4df06d8e9b7b0c8a36f4a75230 +Subproject commit f21a31ff8a5e4d975dd09779ddae4d6c99d7e4da diff --git a/src/com/adjust/sdk/Adjust.as b/src/com/adjust/sdk/Adjust.as index 658072ab..2c51f9ae 100644 --- a/src/com/adjust/sdk/Adjust.as +++ b/src/com/adjust/sdk/Adjust.as @@ -4,7 +4,7 @@ package com.adjust.sdk { import flash.external.ExtensionContext; public class Adjust extends EventDispatcher { - private static var sdkPrefix:String = "adobe_air4.17.2"; + private static var sdkPrefix:String = "adobe_air4.18.0"; private static var errorMessage:String = "Adjust: SDK not started. Start it manually using the 'start' method"; private static var hasSdkStarted:Boolean = false; @@ -200,6 +200,10 @@ package com.adjust.sdk { getExtensionContext().call("gdprForgetMe"); } + public static function trackAdRevenue(source:String, payload:String):void { + getExtensionContext().call("trackAdRevenue", source, payload); + } + public static function setTestOptions(testOptions:AdjustTestOptions):void { getExtensionContext().call("setTestOptions", testOptions.hasContext, diff --git a/src/extension.xml b/src/extension.xml index ef0ad42c..97970476 100644 --- a/src/extension.xml +++ b/src/extension.xml @@ -1,6 +1,6 @@ com.adjust.sdk - 4.17.2 + 4.18.0 @@ -8,6 +8,12 @@ com.adjust.sdk.AdjustExtension + + + adjust-android.jar + com.adjust.sdk.AdjustExtension + + adjust-android.jar diff --git a/src/platformoptions.xml b/src/platformoptions_ios.xml similarity index 100% rename from src/platformoptions.xml rename to src/platformoptions_ios.xml diff --git a/test/app/AdjustCommandExecutor.as b/test/app/AdjustCommandExecutor.as index 5d919654..d6151576 100644 --- a/test/app/AdjustCommandExecutor.as +++ b/test/app/AdjustCommandExecutor.as @@ -107,6 +107,7 @@ package { case "openDeeplink" : this.openDeeplink(command.params); break; case "sendReferrer" : this.sendReferrer(command.params); break; case "gdprForgetMe" : this.gdprForgetMe(command.params); break; + case "trackAdRevenue" : this.trackAdRevenue(command.params); break; } this.nextToSendCounter++; @@ -429,6 +430,12 @@ package { Adjust.gdprForgetMe(); } + private function trackAdRevenue(params:Object):void { + var source:String = getFirstParameterValue(params, 'adRevenueSource'); + var payload:String = getFirstParameterValue(params, 'adRevenueJsonString'); + Adjust.trackAdRevenue(source, payload); + } + private function attributionCallbackDelegate(attribution:AdjustAttribution):void { AdjustTest.addInfoToSend("trackerToken", attribution.getTrackerToken()); AdjustTest.addInfoToSend("trackerName", attribution.getTrackerName()); diff --git a/test/app/Main-app.xml b/test/app/Main-app.xml index e291d860..4c78667f 100644 --- a/test/app/Main-app.xml +++ b/test/app/Main-app.xml @@ -1,7 +1,7 @@ - + com.adjust.examples - 4.17.2 + 4.18.0 Adjust AIR SDK Test diff --git a/test/app/Main.as b/test/app/Main.as index 8f24f919..81a082cf 100644 --- a/test/app/Main.as +++ b/test/app/Main.as @@ -6,21 +6,19 @@ package { import flash.system.Capabilities; public class Main extends Sprite { - // For Android testing: Make sure to use HTTPS with port 8443 with a physical device - // For iOS testing: Make sure to use HTTP with port 8080 with a physical device - // public static var baseUrl:String = 'https://192.168.9.228:8443'; - // public static var gdprUrl:String = 'https://192.168.9.228:8443'; - public static var baseUrl:String = 'http://192.168.9.228:8080'; - public static var gdprUrl:String = 'http://192.168.9.228:8080'; + // Android: Make sure to use HTTPS with port 8443 with a physical device. + // iOS: Make sure to use HTTP with port 8080 with a physical device. + public static var ipAddress:String = '192.168.9.235'; + public static var baseUrl:String = 'https://' + ipAddress + ':8443'; + public static var gdprUrl:String = 'https://' + ipAddress + ':8443'; + public static var controlUrl:String = 'ws://' + ipAddress + ':1987'; private static var commandExecutor:CommandExecutor; public function Main() { commandExecutor = new CommandExecutor(baseUrl); - - // AdjustTest.addTestDirectory("current/sessionEventCallbacks/"); - // AdjustTest.addTest("current/sessionEventCallbacks/Test_EventCallback_success"); - AdjustTest.startTestSession(baseUrl, Adjust.getSdkVersion(), testCommandCallbackDelegate); + trace('[ADJUST][TEST-APP]: Starting Adjust test application session!'); + AdjustTest.startTestSession(baseUrl, controlUrl, Adjust.getSdkVersion(), testCommandCallbackDelegate); } private static function testCommandCallbackDelegate(json:String):void { @@ -30,10 +28,11 @@ package { var params:Object = data.params; var order:int = parseInt(data.order); - trace('[ADJUST][TEST] className: ' + className); - trace('[ADJUST][TEST] functionName: ' + functionName); - trace('[ADJUST][TEST] params: ' + params); - trace('[ADJUST][TEST] order: ' + order); + trace('[ADJUST][TEST-APP]: Test command callback invoked!'); + trace('[ADJUST][TEST-APP]: className: ' + className); + trace('[ADJUST][TEST-APP]: functionName: ' + functionName); + trace('[ADJUST][TEST-APP]: params: ' + params); + trace('[ADJUST][TEST-APP]: order: ' + order); commandExecutor.scheduleCommand(className, functionName, params, order); } diff --git a/test/app/lib/AdjustTest-4.17.0.ane b/test/app/lib/AdjustTest-4.17.0.ane deleted file mode 100644 index 745e64c9..00000000 Binary files a/test/app/lib/AdjustTest-4.17.0.ane and /dev/null differ diff --git a/test/app/lib/AdjustTest-4.18.0.ane b/test/app/lib/AdjustTest-4.18.0.ane new file mode 100644 index 00000000..50146d1d Binary files /dev/null and b/test/app/lib/AdjustTest-4.18.0.ane differ diff --git a/test/plugin/android/adjust-android-test.jar b/test/plugin/android/adjust-android-test.jar index c61d98c9..7c0b1aaa 100644 Binary files a/test/plugin/android/adjust-android-test.jar and b/test/plugin/android/adjust-android-test.jar differ diff --git a/test/plugin/android/src/AdjustTestExtension/build.gradle b/test/plugin/android/src/AdjustTestExtension/build.gradle index ae9fbafb..5ea98810 100644 --- a/test/plugin/android/src/AdjustTestExtension/build.gradle +++ b/test/plugin/android/src/AdjustTestExtension/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.4.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/test/plugin/android/src/AdjustTestExtension/extension/build.gradle b/test/plugin/android/src/AdjustTestExtension/extension/build.gradle index fa0d2635..9a4d663d 100644 --- a/test/plugin/android/src/AdjustTestExtension/extension/build.gradle +++ b/test/plugin/android/src/AdjustTestExtension/extension/build.gradle @@ -19,18 +19,18 @@ android { } task makeDebugJar(type: Copy) { - dependsOn 'build' + dependsOn 'assembleDebug' - from('build/intermediates/intermediate-jars/debug/') + from('build/intermediates/packaged-classes/debug/') into('build/libs/debug/') include('classes.jar') rename('classes.jar', "adjust-android-test.jar") } task makeReleaseJar(type: Copy) { - dependsOn 'build' + dependsOn 'assembleRelease' - from('build/intermediates/intermediate-jars/release/') + from('build/intermediates/packaged-classes/debug/') into('build/libs/release/') include('classes.jar') rename('classes.jar', "adjust-android-test.jar") @@ -41,4 +41,5 @@ dependencies { implementation 'com.android.support:appcompat-v7:28.0.0' implementation files('libs/FlashRuntimeExtensions.jar') implementation files('libs/gson-2.8.0.jar') + implementation files('libs/Java-WebSocket-1.3.9.jar') } diff --git a/test/plugin/android/src/AdjustTestExtension/extension/libs/Java-WebSocket-1.3.9.jar b/test/plugin/android/src/AdjustTestExtension/extension/libs/Java-WebSocket-1.3.9.jar new file mode 100644 index 00000000..c0319475 Binary files /dev/null and b/test/plugin/android/src/AdjustTestExtension/extension/libs/Java-WebSocket-1.3.9.jar differ diff --git a/test/plugin/android/src/AdjustTestExtension/extension/src/main/AndroidManifest.xml b/test/plugin/android/src/AdjustTestExtension/extension/src/main/AndroidManifest.xml index ca69756f..8ab2e67e 100644 --- a/test/plugin/android/src/AdjustTestExtension/extension/src/main/AndroidManifest.xml +++ b/test/plugin/android/src/AdjustTestExtension/extension/src/main/AndroidManifest.xml @@ -1,10 +1,10 @@ + package="com.adjust.test"> + android:targetSdkVersion="28" /> diff --git a/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/AdjustTestFunction.java b/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/AdjustTestFunction.java index d6d48337..98c7b9ec 100644 --- a/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/AdjustTestFunction.java +++ b/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/AdjustTestFunction.java @@ -46,15 +46,15 @@ public FREObject call(FREContext freContext, FREObject[] freObjects) { private FREObject StartTestSession(FREContext freContext, FREObject[] freObjects) { try { String baseUrl = freObjects[0].getAsString(); - String clientSdk = freObjects[1].getAsString(); - testLibrary = new TestLibrary(baseUrl, new CommandListener()); + String controlUrl = freObjects[1].getAsString(); + String clientSdk = freObjects[2].getAsString(); + testLibrary = new TestLibrary(baseUrl, controlUrl, new CommandListener()); for (int i = 0; i < selectedTests.size(); i++) { testLibrary.addTest(selectedTests.get(i)); } for (int i = 0; i < selectedTestDirs.size(); i++) { testLibrary.addTestDirectory(selectedTestDirs.get(i)); } - Log.e("SDKVERSION", clientSdk); testLibrary.startTestSession(clientSdk); } catch (FRETypeMismatchException e) { Log.e(TAG, e.getMessage()); diff --git a/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/Constants.java b/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/Constants.java index 436ec136..e011f4d9 100644 --- a/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/Constants.java +++ b/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/Constants.java @@ -3,20 +3,20 @@ /** * Created by nonelse on 09.03.17. */ - public interface Constants { - int ONE_SECOND = 1000; - int ONE_MINUTE = 60 * ONE_SECOND; - + int ONE_SECOND = 1000; + int ONE_MINUTE = 60 * ONE_SECOND; String ENCODING = "UTF-8"; - String LOGTAG = "TestLibrary"; - String TEST_SCRIPT_HEADER = "TestScript"; - String BASE_PATH_HEADER = "BasePath"; - String TEST_SESSION_END_HEADER = "TestSessionEnd"; - String TEST_CANCELTEST_HEADER = "CancelTest"; - String TEST_ENDWAIT_HEADER = "EndWait"; + String LOGTAG = "TestLibrary"; String TEST_LIBRARY_CLASSNAME = "TestLibrary"; - String WAIT_FOR_CONTROL = "control"; - String WAIT_FOR_SLEEP = "sleep"; + String WAIT_FOR_CONTROL = "control"; + String WAIT_FOR_SLEEP = "sleep"; + String TEST_SESSION_ID_HEADER = "Test-Session-Id"; + + // web socket values + String SIGNAL_INFO = "info"; + String SIGNAL_INIT_TEST_SESSION = "init-test-session"; + String SIGNAL_END_WAIT = "end-wait"; + String SIGNAL_CANCEL_CURRENT_TEST = "cancel-current-test"; } diff --git a/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/ControlChannel.java b/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/ControlChannel.java deleted file mode 100644 index f54ba330..00000000 --- a/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/ControlChannel.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.adjust.test; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import static com.adjust.test.Constants.TEST_CANCELTEST_HEADER; -import static com.adjust.test.Constants.TEST_ENDWAIT_HEADER; -import static com.adjust.test.Utils.debug; -import static com.adjust.test.UtilsNetworking.sendPostI; - -/** - * Created by nonelse on 21.03.17. - */ - -public class ControlChannel { - private static final String CONTROL_START_PATH = "/control_start"; - private static final String CONTROL_CONTINUE_PATH = "/control_continue"; - - ExecutorService controlChannelExecutor = Executors.newCachedThreadPool(); - TestLibrary testLibrary; - private boolean closed = false; - - public ControlChannel(TestLibrary testLibrary) { - this.testLibrary = testLibrary; - sendControlRequest(CONTROL_START_PATH); - } - - public void teardown() { - if (controlChannelExecutor != null) { - debug("controlChannelExecutor shutdown"); - controlChannelExecutor.shutdown(); - } - - closed = true; - controlChannelExecutor = null; - } - - private void sendControlRequest(final String controlPath) { - controlChannelExecutor.submit(new Runnable() { - @Override - public void run() { - long timeBefore = System.nanoTime(); - debug("time before wait: %d", timeBefore); - - UtilsNetworking.HttpResponse httpResponse = sendPostI( - Utils.appendBasePath(testLibrary.currentBasePath, controlPath)); - - long timeAfter = System.nanoTime(); - long timeElapsedMillis = TimeUnit.NANOSECONDS.toMillis(timeAfter - timeBefore); - debug("time after wait: %d", timeAfter); - debug("time elapsed waiting in milli seconds: %d", timeElapsedMillis); - - readControlHeaders(httpResponse); - } - }); - } - - void readControlHeaders(UtilsNetworking.HttpResponse httpResponse) { - if (closed) { - debug("control channel already closed"); - return; - } - if (httpResponse.headerFields.containsKey(TEST_CANCELTEST_HEADER)) { - debug("Test canceled due to %s", httpResponse.headerFields.get(TEST_CANCELTEST_HEADER).get(0)); - testLibrary.resetTestLibrary(); - testLibrary.readResponse(httpResponse); - } - if (httpResponse.headerFields.containsKey(TEST_ENDWAIT_HEADER)) { - String waitEndReason = httpResponse.headerFields.get(TEST_ENDWAIT_HEADER).get(0); - sendControlRequest(CONTROL_CONTINUE_PATH); - endWait(waitEndReason); - } - } - - void endWait(String waitEndReason) { - debug("End wait from control channel due to %s", waitEndReason); - testLibrary.waitControlQueue.offer(waitEndReason); - debug("Wait ended from control channel due to %s", waitEndReason); - } -} diff --git a/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/TestLibrary.java b/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/TestLibrary.java index 1a486958..4ad54251 100644 --- a/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/TestLibrary.java +++ b/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/TestLibrary.java @@ -2,9 +2,11 @@ import android.os.SystemClock; +import com.adjust.test.ws.ControlWebSocketClient; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import java.net.URISyntaxException; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -15,10 +17,13 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; +import static com.adjust.test.Constants.ONE_SECOND; import static com.adjust.test.Constants.TEST_LIBRARY_CLASSNAME; +import static com.adjust.test.Constants.TEST_SESSION_ID_HEADER; import static com.adjust.test.Constants.WAIT_FOR_CONTROL; import static com.adjust.test.Constants.WAIT_FOR_SLEEP; import static com.adjust.test.Utils.debug; +import static com.adjust.test.Utils.error; import static com.adjust.test.UtilsNetworking.sendPostI; @@ -28,45 +33,59 @@ public class TestLibrary { static String baseUrl; - ExecutorService executor; - IOnExitListener onExitListener; - ICommandListener commandListener; - ICommandJsonListener commandJsonListener; - ICommandRawJsonListener commandRawJsonListener; - ControlChannel controlChannel; - String currentTestName; - String currentBasePath; - Gson gson = new Gson(); - BlockingQueue waitControlQueue; - Map infoToServer; - - StringBuilder testNames = new StringBuilder(); - boolean exitAfterEnd = true; - - public TestLibrary(String baseUrl, ICommandRawJsonListener commandRawJsonListener) { - this(baseUrl); + static String controlUrl; + private Gson gson = new Gson(); + private BlockingQueue waitControlQueue; + private ControlWebSocketClient controlClient; + private ExecutorService executor; + private IOnExitListener onExitListener; + private ICommandListener commandListener; + private ICommandJsonListener commandJsonListener; + private ICommandRawJsonListener commandRawJsonListener; + private String currentTestName; + private String currentBasePath; + private Map infoToServer; + private String testSessionId; + private StringBuilder currentTestNames = new StringBuilder(); + private boolean exitAfterEnd = true; + + public TestLibrary(String baseUrl, String controlUrl, ICommandRawJsonListener commandRawJsonListener) { + this(baseUrl, controlUrl); this.commandRawJsonListener = commandRawJsonListener; } - public TestLibrary(String baseUrl, ICommandJsonListener commandJsonListener) { - this(baseUrl); + public TestLibrary(String baseUrl, String controlUrl, ICommandJsonListener commandJsonListener) { + this(baseUrl, controlUrl); this.commandJsonListener = commandJsonListener; } - public TestLibrary(String baseUrl, ICommandListener commandListener) { - this(baseUrl); + public TestLibrary(String baseUrl, String controlUrl, ICommandListener commandListener) { + this(baseUrl, controlUrl); this.commandListener = commandListener; } - private TestLibrary(String baseUrl) { + private TestLibrary(String baseUrl, String controlUrl) { this.baseUrl = baseUrl; - debug("base url: %s", baseUrl); + this.controlUrl = controlUrl; + debug("> base url: \t%s", baseUrl); + debug("> control url: \t%s", controlUrl); + this.initializeWebSocket(controlUrl); + } + + private void initializeWebSocket(String controlUrl) { + try { + this.controlClient = new ControlWebSocketClient(this, controlUrl); + this.controlClient.connect(); + debug(" ---> control web socket client, connection state: " + this.controlClient.getReadyState()); + } catch (URISyntaxException e) { + debug(String.format("Error, cannot create/connect with server web socket: [%s]", e.getMessage())); + e.printStackTrace(); + } } // resets test library to initial state - void resetTestLibrary() { + private void resetTestLibrary() { teardown(true); - executor = Executors.newCachedThreadPool(); waitControlQueue = new LinkedBlockingQueue(); } @@ -83,75 +102,55 @@ private void teardown(boolean shutdownNow) { } } executor = null; - - clearTest(); - } - - // clear for each test - private void clearTest() { + infoToServer = null; if (waitControlQueue != null) { waitControlQueue.clear(); } waitControlQueue = null; - if (controlChannel != null) { - controlChannel.teardown(); - } - controlChannel = null; - infoToServer = null; - } - - // reset for each test - private void resetForNextTest() { - clearTest(); - - waitControlQueue = new LinkedBlockingQueue(); - controlChannel = new ControlChannel(this); } - public void addTestDirectory(String testDir) { - this.testNames.append(testDir); + public void startTestSession(final String clientSdk) { + resetTestLibrary(); - if(!testDir.endsWith("/") || !testDir.endsWith("/;")) { - this.testNames.append("/"); + // reconnect web socket client if disconnected + if (!this.controlClient.isOpen()) { + debug("reconnecting web socket client ..."); + this.initializeWebSocket(controlUrl); + // wait for WS to reconnect + SystemClock.sleep(ONE_SECOND); } - if(!testDir.endsWith(";")) { - this.testNames.append(";"); - } + executor.submit(new Runnable() { + @Override + public void run() { + startTestSessionI(clientSdk); + } + }); } - public void addTest(String testName) { - this.testNames.append(testName); - - if(!testName.endsWith(";")) { - this.testNames.append(";"); - } + public void setOnExitListener(IOnExitListener onExitListener) { + this.onExitListener = onExitListener; } - public void doNotExitAfterEnd() { - this.exitAfterEnd = false; + public void signalEndWait(String reason) { + this.waitControlQueue.offer(reason); } - public void startTestSession(final String clientSdk) { + public void cancelTestAndGetNext() { resetTestLibrary(); - executor.submit(new Runnable() { @Override public void run() { - sendTestSessionI(clientSdk); + UtilsNetworking.HttpResponse httpResponse = sendPostI(Utils.appendBasePath(currentBasePath, "/end_test_read_next")); + readResponseI(httpResponse); } }); } - public void setOnExitListener(IOnExitListener onExitListener) { - this.onExitListener = onExitListener; - } - public void addInfoToSend(String key, String value) { if (infoToServer == null) { infoToServer = new HashMap(); } - infoToServer.put(key, value); } @@ -164,17 +163,12 @@ public void run() { }); } - void readResponse(final UtilsNetworking.HttpResponse httpResponse) { - executor.submit(new Runnable() { - @Override - public void run() { - readResponseI(httpResponse); - } - }); - } - - private void sendTestSessionI(String clientSdk) { - UtilsNetworking.HttpResponse httpResponse = sendPostI("/init_session", clientSdk, testNames.toString()); + private void startTestSessionI(String clientSdk) { + UtilsNetworking.HttpResponse httpResponse = sendPostI("/init_session", clientSdk, currentTestNames.toString()); + this.testSessionId = httpResponse.headerFields.get(TEST_SESSION_ID_HEADER).get(0); + // set test session ID on the web socket object in Test Server, so it can be uniquely identified + this.controlClient.sendInitTestSessionSignal(this.testSessionId); + debug("starting new test session with ID: " + this.testSessionId); readResponseI(httpResponse); } @@ -189,6 +183,7 @@ public void readResponseI(UtilsNetworking.HttpResponse httpResponse) { debug("httpResponse is null"); return; } + List testCommands = Arrays.asList(gson.fromJson(httpResponse.response, TestCommand[].class)); try { execTestCommandsI(testCommands); @@ -197,13 +192,37 @@ public void readResponseI(UtilsNetworking.HttpResponse httpResponse) { } } + public void addTestDirectory(String testDir) { + this.currentTestNames.append(testDir); + + if(!testDir.endsWith("/") || !testDir.endsWith("/;")) { + this.currentTestNames.append("/"); + } + + if(!testDir.endsWith(";")) { + this.currentTestNames.append(";"); + } + } + + public void addTest(String testName) { + this.currentTestNames.append(testName); + + if(!testName.endsWith(";")) { + this.currentTestNames.append(";"); + } + } + + public void doNotExitAfterEnd() { + this.exitAfterEnd = false; + } + private void execTestCommandsI(List testCommands) throws InterruptedException { debug("testCommands: %s", testCommands); Gson gson = new GsonBuilder().disableHtmlEscaping().create(); for (TestCommand testCommand : testCommands) { if (Thread.interrupted()) { - debug("Thread interrupted"); + error("Thread interrupted"); return; } debug("ClassName: %s", testCommand.className); @@ -217,15 +236,17 @@ private void execTestCommandsI(List testCommands) throws Interrupte long timeBefore = System.nanoTime(); debug("time before %s %s: %d", testCommand.className, testCommand.functionName, timeBefore); + // execute TestLibrary command if (TEST_LIBRARY_CLASSNAME.equals(testCommand.className)) { executeTestLibraryCommandI(testCommand); long timeAfter = System.nanoTime(); long timeElapsedMillis = TimeUnit.NANOSECONDS.toMillis(timeAfter - timeBefore); debug("time after %s %s: %d", testCommand.className, testCommand.functionName, timeAfter); debug("time elapsed %s %s in milli seconds: %d", testCommand.className, testCommand.functionName, timeElapsedMillis); - continue; } + + // execute Adjust command if (commandListener != null) { commandListener.executeCommand(testCommand.className, testCommand.functionName, testCommand.params); } else if (commandJsonListener != null) { @@ -237,6 +258,7 @@ private void execTestCommandsI(List testCommands) throws Interrupte debug("commandRawJsonListener test command toJson: %s", toJsonCommand); commandRawJsonListener.executeCommand(toJsonCommand); } + long timeAfter = System.nanoTime(); long timeElapsedMillis = TimeUnit.NANOSECONDS.toMillis(timeAfter - timeBefore); debug("time after %s.%s: %d", testCommand.className, testCommand.functionName, timeAfter); @@ -247,7 +269,7 @@ private void execTestCommandsI(List testCommands) throws Interrupte private void executeTestLibraryCommandI(TestCommand testCommand) throws InterruptedException { switch (testCommand.functionName) { case "resetTest": resetTestI(testCommand.params); break; - case "endTestReadNext": endTestReadNext(); break; + case "endTestReadNext": endTestReadNextI(); break; case "endTestSession": endTestSessionI(); break; case "wait": waitI(testCommand.params); break; case "exit": exit(); break; @@ -259,22 +281,25 @@ private void resetTestI(Map> params) { currentBasePath = params.get("basePath").get(0); debug("current base path %s", currentBasePath); } - if (params.containsKey("testName")) { currentTestName = params.get("testName").get(0); debug("current test name %s", currentTestName); } - resetForNextTest(); + + if (waitControlQueue != null) { + waitControlQueue.clear(); + } + infoToServer = null; + waitControlQueue = new LinkedBlockingQueue(); } - private void endTestReadNext() { - // send end test request + private void endTestReadNextI() { UtilsNetworking.HttpResponse httpResponse = sendPostI(Utils.appendBasePath(currentBasePath, "/end_test_read_next")); - // and process the next in the response readResponseI(httpResponse); } private void endTestSessionI() { + debug(" ---> test session ended!"); teardown(false); if (exitAfterEnd) { exit(); @@ -291,7 +316,6 @@ private void waitI(Map> params) throws InterruptedException if (params.containsKey(WAIT_FOR_SLEEP)) { long millisToSleep = Long.parseLong(params.get(WAIT_FOR_SLEEP).get(0)); debug("sleep for %s", millisToSleep); - SystemClock.sleep(millisToSleep); debug("sleep ended"); } diff --git a/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/ws/ControlSignal.java b/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/ws/ControlSignal.java new file mode 100644 index 00000000..60f75b21 --- /dev/null +++ b/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/ws/ControlSignal.java @@ -0,0 +1,50 @@ +package com.adjust.test.ws; + +import static com.adjust.test.Constants.*; + +/** + * com.adjust.test.ws + * Created by 2beens on 08.02.19. + */ +public class ControlSignal { + private String type; + private String value; + + ControlSignal(SignalType type) { + this.type = getSignalTypeString(type); + this.value = "n/a"; + } + + ControlSignal(SignalType type, String value) { + this.type = getSignalTypeString(type); + this.value = value; + } + + public SignalType getType() { + return getSignalTypeByString(type); + } + + public String getValue() { + return this.value; + } + + private String getSignalTypeString(SignalType signalType) { + switch (signalType) { + case INFO: return SIGNAL_INFO; + case INIT_TEST_SESSION: return SIGNAL_INIT_TEST_SESSION; + case END_WAIT: return SIGNAL_END_WAIT; + case CANCEL_CURRENT_TEST: return SIGNAL_CANCEL_CURRENT_TEST; + default: return "unknown"; + } + } + + private SignalType getSignalTypeByString(String signalType) { + switch (signalType) { + case SIGNAL_INFO: return SignalType.INFO; + case SIGNAL_INIT_TEST_SESSION: return SignalType.INIT_TEST_SESSION; + case SIGNAL_END_WAIT: return SignalType.END_WAIT; + case SIGNAL_CANCEL_CURRENT_TEST: return SignalType.CANCEL_CURRENT_TEST; + default: return SignalType.UNKNOWN; + } + } +} diff --git a/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/ws/ControlWebSocketClient.java b/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/ws/ControlWebSocketClient.java new file mode 100644 index 00000000..99ccfc7c --- /dev/null +++ b/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/ws/ControlWebSocketClient.java @@ -0,0 +1,84 @@ +package com.adjust.test.ws; + +import com.adjust.test.TestLibrary; +import com.google.gson.Gson; + +import org.java_websocket.client.WebSocketClient; +import org.java_websocket.handshake.ServerHandshake; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.UUID; + +import static com.adjust.test.Utils.debug; +import static com.adjust.test.Utils.error; + +/** + * com.adjust.test.ws + * Created by 2beens on 07.02.19. + */ +public class ControlWebSocketClient extends WebSocketClient { + private TestLibrary testLibrary; + private Gson gson = new Gson(); + + public ControlWebSocketClient(TestLibrary testLibrary, String serverUri) throws URISyntaxException { + super(new URI(serverUri)); + this.testLibrary = testLibrary; + } + + @Override + public void onOpen(ServerHandshake handshakedata) { + debug("[WebSocket] connection opened with the server"); + } + + @Override + public void onMessage(String message) { + //debug(String.format("[WebSocket] onMessage, message [%s]", message)); + ControlSignal incomingSignal = this.parseControlSignal(message); + this.handleIncomingSignal(incomingSignal); + } + + private ControlSignal parseControlSignal(String message) { + ControlSignal incomingSignal; + try { + incomingSignal = gson.fromJson(message, ControlSignal.class); + } catch (Exception ex) { + if (message == null) { + message = "null"; + } + error(String.format("[WebSocket] onMessage Error! Cannot parse message [%s]. Details: [%s]", message, ex.getMessage())); + ex.printStackTrace(); + incomingSignal = new ControlSignal(SignalType.UNKNOWN); + } + return incomingSignal; + } + + private void handleIncomingSignal(ControlSignal incomingSignal) { + if (incomingSignal.getType() == SignalType.INFO) { + debug("[WebSocket] info from the server: " + incomingSignal.getValue()); + } else if (incomingSignal.getType() == SignalType.END_WAIT) { + debug("[WebSocket] end wait signal recevied, reason: " + incomingSignal.getValue()); + this.testLibrary.signalEndWait(incomingSignal.getValue()); + } else if (incomingSignal.getType() == SignalType.CANCEL_CURRENT_TEST) { + debug("[WebSocket] cancel test recevied, reason: " + incomingSignal.getValue()); + testLibrary.cancelTestAndGetNext(); + } else { + debug("[WebSocket] unknown signal received by the server. Value: " + incomingSignal.getValue()); + } + } + + @Override + public void onClose(int code, String reason, boolean remote) { + debug(String.format("[WebSocket] onClose, code [%d], reason [%s]", code, reason)); + } + + @Override + public void onError(Exception ex) { + debug(String.format("[WebSocket] onError [%s]", ex.getMessage())); + } + + public void sendInitTestSessionSignal(String testSessionId) { + ControlSignal initSignal = new ControlSignal(SignalType.INIT_TEST_SESSION, testSessionId); + send(gson.toJson(initSignal)); + } +} diff --git a/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/ws/SignalType.java b/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/ws/SignalType.java new file mode 100644 index 00000000..18de5207 --- /dev/null +++ b/test/plugin/android/src/AdjustTestExtension/extension/src/main/java/com/adjust/test/ws/SignalType.java @@ -0,0 +1,13 @@ +package com.adjust.test.ws; + +/** + * com.adjust.test.ws + * Created by 2beens on 08.02.19. + */ +public enum SignalType { + INFO, + INIT_TEST_SESSION, + END_WAIT, + CANCEL_CURRENT_TEST, + UNKNOWN +} diff --git a/test/plugin/android/src/AdjustTestExtension/gradle/wrapper/gradle-wrapper.properties b/test/plugin/android/src/AdjustTestExtension/gradle/wrapper/gradle-wrapper.properties index dfbc6167..8d3b972a 100644 --- a/test/plugin/android/src/AdjustTestExtension/gradle/wrapper/gradle-wrapper.properties +++ b/test/plugin/android/src/AdjustTestExtension/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip diff --git a/test/plugin/default/src/com/adjust/test/AdjustTest.as b/test/plugin/default/src/com/adjust/test/AdjustTest.as index d4cf87ce..a532b5fa 100644 --- a/test/plugin/default/src/com/adjust/test/AdjustTest.as +++ b/test/plugin/default/src/com/adjust/test/AdjustTest.as @@ -2,7 +2,7 @@ package com.adjust.test { import flash.events.*; public class AdjustTest extends EventDispatcher { - public static function startTestSession(baseUrl:String, clientSdk:String, testingCommandCallbackDelegate:Function):void { + public static function startTestSession(baseUrl:String, controlUrl:String, clientSdk:String, testingCommandCallbackDelegate:Function):void { trace("adjust_testing: startTestSession called"); } diff --git a/test/plugin/ios/AdjustTestLibrary.framework/AdjustTestLibrary b/test/plugin/ios/AdjustTestLibrary.framework/AdjustTestLibrary index ae9e5aab..e6fed85a 100644 Binary files a/test/plugin/ios/AdjustTestLibrary.framework/AdjustTestLibrary and b/test/plugin/ios/AdjustTestLibrary.framework/AdjustTestLibrary differ diff --git a/test/plugin/ios/AdjustTestLibrary.framework/Headers/ATLConstants.h b/test/plugin/ios/AdjustTestLibrary.framework/Headers/ATLConstants.h index d4d17ef1..52add012 100644 --- a/test/plugin/ios/AdjustTestLibrary.framework/Headers/ATLConstants.h +++ b/test/plugin/ios/AdjustTestLibrary.framework/Headers/ATLConstants.h @@ -9,15 +9,22 @@ #ifndef ATLConstants_h #define ATLConstants_h -static NSString * const TEST_SCRIPT_HEADER = @"TestScript"; -static NSString * const TEST_SESSION_END_HEADER = @"TestSessionEnd"; -static NSString * const TEST_CANCELTEST_HEADER = @"CancelTest"; -static NSString * const TEST_ENDWAIT_HEADER = @"EndWait"; -static NSString * const TEST_LIBRARY_CLASSNAME = @"TestLibrary"; -static NSString * const ADJUST_CLASSNAME = @"Adjust"; -static NSString * const WAIT_FOR_CONTROL = @"control"; -static NSString * const WAIT_FOR_SLEEP = @"sleep"; -static NSString * const BASE_PATH_PARAM = @"basePath"; -static NSString * const TEST_NAME_PARAM = @"basePath"; +static int const ONE_SECOND = 1000; +static int const ONE_MINUTE = 60 * ONE_SECOND; + +static NSString * const TEST_LIBRARY_CLASSNAME = @"TestLibrary"; +static NSString * const ADJUST_CLASSNAME = @"Adjust"; +static NSString * const WAIT_FOR_CONTROL = @"control"; +static NSString * const WAIT_FOR_SLEEP = @"sleep"; +static NSString * const BASE_PATH_PARAM = @"basePath"; +static NSString * const TEST_NAME_PARAM = @"basePath"; +static NSString * const TEST_SESSION_ID_HEADER = @"Test-Session-Id"; + +// web socket values +static NSString * const SIGNAL_INFO = @"info"; +static NSString * const SIGNAL_INIT_TEST_SESSION = @"init-test-session"; +static NSString * const SIGNAL_END_WAIT = @"end-wait"; +static NSString * const SIGNAL_CANCEL_CURRENT_TEST = @"cancel-current-test"; +static NSString * const SIGNAL_UNKNOWN = @"unknown"; #endif /* ATLConstants_h */ diff --git a/test/plugin/ios/AdjustTestLibrary.framework/Headers/ATLControlWebSocketClient.h b/test/plugin/ios/AdjustTestLibrary.framework/Headers/ATLControlWebSocketClient.h new file mode 100644 index 00000000..0dd5e21c --- /dev/null +++ b/test/plugin/ios/AdjustTestLibrary.framework/Headers/ATLControlWebSocketClient.h @@ -0,0 +1,26 @@ +// +// ATLControlWebSocketClient.h +// AdjustTestLibrary +// +// Created by Serj on 20.02.19. +// Copyright © 2019 adjust. All rights reserved. +// + +#import +#import "PocketSocket/PSWebSocket.h" +#import "ATLTestLibrary.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface ATLControlWebSocketClient : NSObject + +- (void)initializeWebSocketWithControlUrl:(NSString*)controlUrl + andTestLibrary:(ATLTestLibrary*)testLibrary; + +- (void)reconnectIfNeeded; + +- (void)sendInitTestSessionSignal:(NSString*)testSessionId; + +@end + +NS_ASSUME_NONNULL_END diff --git a/test/plugin/ios/AdjustTestLibrary.framework/Headers/ATLTestLibrary.h b/test/plugin/ios/AdjustTestLibrary.framework/Headers/ATLTestLibrary.h index 80948937..099414dd 100644 --- a/test/plugin/ios/AdjustTestLibrary.framework/Headers/ATLTestLibrary.h +++ b/test/plugin/ios/AdjustTestLibrary.framework/Headers/ATLTestLibrary.h @@ -25,7 +25,12 @@ @interface ATLTestLibrary : NSObject +- (NSString *)currentBasePath; + +- (ATLBlockingQueue *)waitControlQueue; + - (id)initWithBaseUrl:(NSString *)baseUrl + andControlUrl:(NSString *)controlUrl andCommandDelegate:(NSObject *)commandDelegate; - (void)addTest:(NSString *)testName; @@ -34,9 +39,6 @@ - (void)startTestSession:(NSString *)clientSdk; -- (NSString *)currentBasePath; -- (ATLBlockingQueue *)waitControlQueue; - - (void)resetTestLibrary; - (void)readResponse:(ATLHttpResponse *)httpResponse; @@ -46,8 +48,15 @@ - (void)sendInfoToServer:(NSString *)basePath; +- (void)signalEndWaitWithReason:(NSString *)reason; + +- (void)cancelTestAndGetNext; + +- (void)doNotExitAfterEnd; + + (ATLTestLibrary *)testLibraryWithBaseUrl:(NSString *)baseUrl -andCommandDelegate:(NSObject *)commandDelegate; + andControlUrl:(NSString *)controlUrl + andCommandDelegate:(NSObject *)commandDelegate; + (NSURL *)baseUrl; diff --git a/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/AdjustTestLibrary b/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/AdjustTestLibrary index ae9e5aab..e6fed85a 100644 Binary files a/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/AdjustTestLibrary and b/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/AdjustTestLibrary differ diff --git a/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/Headers/ATLConstants.h b/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/Headers/ATLConstants.h index d4d17ef1..52add012 100644 --- a/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/Headers/ATLConstants.h +++ b/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/Headers/ATLConstants.h @@ -9,15 +9,22 @@ #ifndef ATLConstants_h #define ATLConstants_h -static NSString * const TEST_SCRIPT_HEADER = @"TestScript"; -static NSString * const TEST_SESSION_END_HEADER = @"TestSessionEnd"; -static NSString * const TEST_CANCELTEST_HEADER = @"CancelTest"; -static NSString * const TEST_ENDWAIT_HEADER = @"EndWait"; -static NSString * const TEST_LIBRARY_CLASSNAME = @"TestLibrary"; -static NSString * const ADJUST_CLASSNAME = @"Adjust"; -static NSString * const WAIT_FOR_CONTROL = @"control"; -static NSString * const WAIT_FOR_SLEEP = @"sleep"; -static NSString * const BASE_PATH_PARAM = @"basePath"; -static NSString * const TEST_NAME_PARAM = @"basePath"; +static int const ONE_SECOND = 1000; +static int const ONE_MINUTE = 60 * ONE_SECOND; + +static NSString * const TEST_LIBRARY_CLASSNAME = @"TestLibrary"; +static NSString * const ADJUST_CLASSNAME = @"Adjust"; +static NSString * const WAIT_FOR_CONTROL = @"control"; +static NSString * const WAIT_FOR_SLEEP = @"sleep"; +static NSString * const BASE_PATH_PARAM = @"basePath"; +static NSString * const TEST_NAME_PARAM = @"basePath"; +static NSString * const TEST_SESSION_ID_HEADER = @"Test-Session-Id"; + +// web socket values +static NSString * const SIGNAL_INFO = @"info"; +static NSString * const SIGNAL_INIT_TEST_SESSION = @"init-test-session"; +static NSString * const SIGNAL_END_WAIT = @"end-wait"; +static NSString * const SIGNAL_CANCEL_CURRENT_TEST = @"cancel-current-test"; +static NSString * const SIGNAL_UNKNOWN = @"unknown"; #endif /* ATLConstants_h */ diff --git a/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/Headers/ATLControlWebSocketClient.h b/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/Headers/ATLControlWebSocketClient.h new file mode 100644 index 00000000..0dd5e21c --- /dev/null +++ b/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/Headers/ATLControlWebSocketClient.h @@ -0,0 +1,26 @@ +// +// ATLControlWebSocketClient.h +// AdjustTestLibrary +// +// Created by Serj on 20.02.19. +// Copyright © 2019 adjust. All rights reserved. +// + +#import +#import "PocketSocket/PSWebSocket.h" +#import "ATLTestLibrary.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface ATLControlWebSocketClient : NSObject + +- (void)initializeWebSocketWithControlUrl:(NSString*)controlUrl + andTestLibrary:(ATLTestLibrary*)testLibrary; + +- (void)reconnectIfNeeded; + +- (void)sendInitTestSessionSignal:(NSString*)testSessionId; + +@end + +NS_ASSUME_NONNULL_END diff --git a/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/Headers/ATLTestLibrary.h b/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/Headers/ATLTestLibrary.h index 80948937..099414dd 100644 --- a/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/Headers/ATLTestLibrary.h +++ b/test/plugin/ios/AdjustTestLibrary.framework/Versions/A/Headers/ATLTestLibrary.h @@ -25,7 +25,12 @@ @interface ATLTestLibrary : NSObject +- (NSString *)currentBasePath; + +- (ATLBlockingQueue *)waitControlQueue; + - (id)initWithBaseUrl:(NSString *)baseUrl + andControlUrl:(NSString *)controlUrl andCommandDelegate:(NSObject *)commandDelegate; - (void)addTest:(NSString *)testName; @@ -34,9 +39,6 @@ - (void)startTestSession:(NSString *)clientSdk; -- (NSString *)currentBasePath; -- (ATLBlockingQueue *)waitControlQueue; - - (void)resetTestLibrary; - (void)readResponse:(ATLHttpResponse *)httpResponse; @@ -46,8 +48,15 @@ - (void)sendInfoToServer:(NSString *)basePath; +- (void)signalEndWaitWithReason:(NSString *)reason; + +- (void)cancelTestAndGetNext; + +- (void)doNotExitAfterEnd; + + (ATLTestLibrary *)testLibraryWithBaseUrl:(NSString *)baseUrl -andCommandDelegate:(NSObject *)commandDelegate; + andControlUrl:(NSString *)controlUrl + andCommandDelegate:(NSObject *)commandDelegate; + (NSURL *)baseUrl; diff --git a/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/AdjustTestLibrary b/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/AdjustTestLibrary index ae9e5aab..e6fed85a 100644 Binary files a/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/AdjustTestLibrary and b/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/AdjustTestLibrary differ diff --git a/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/Headers/ATLConstants.h b/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/Headers/ATLConstants.h index d4d17ef1..52add012 100644 --- a/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/Headers/ATLConstants.h +++ b/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/Headers/ATLConstants.h @@ -9,15 +9,22 @@ #ifndef ATLConstants_h #define ATLConstants_h -static NSString * const TEST_SCRIPT_HEADER = @"TestScript"; -static NSString * const TEST_SESSION_END_HEADER = @"TestSessionEnd"; -static NSString * const TEST_CANCELTEST_HEADER = @"CancelTest"; -static NSString * const TEST_ENDWAIT_HEADER = @"EndWait"; -static NSString * const TEST_LIBRARY_CLASSNAME = @"TestLibrary"; -static NSString * const ADJUST_CLASSNAME = @"Adjust"; -static NSString * const WAIT_FOR_CONTROL = @"control"; -static NSString * const WAIT_FOR_SLEEP = @"sleep"; -static NSString * const BASE_PATH_PARAM = @"basePath"; -static NSString * const TEST_NAME_PARAM = @"basePath"; +static int const ONE_SECOND = 1000; +static int const ONE_MINUTE = 60 * ONE_SECOND; + +static NSString * const TEST_LIBRARY_CLASSNAME = @"TestLibrary"; +static NSString * const ADJUST_CLASSNAME = @"Adjust"; +static NSString * const WAIT_FOR_CONTROL = @"control"; +static NSString * const WAIT_FOR_SLEEP = @"sleep"; +static NSString * const BASE_PATH_PARAM = @"basePath"; +static NSString * const TEST_NAME_PARAM = @"basePath"; +static NSString * const TEST_SESSION_ID_HEADER = @"Test-Session-Id"; + +// web socket values +static NSString * const SIGNAL_INFO = @"info"; +static NSString * const SIGNAL_INIT_TEST_SESSION = @"init-test-session"; +static NSString * const SIGNAL_END_WAIT = @"end-wait"; +static NSString * const SIGNAL_CANCEL_CURRENT_TEST = @"cancel-current-test"; +static NSString * const SIGNAL_UNKNOWN = @"unknown"; #endif /* ATLConstants_h */ diff --git a/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/Headers/ATLControlWebSocketClient.h b/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/Headers/ATLControlWebSocketClient.h new file mode 100644 index 00000000..0dd5e21c --- /dev/null +++ b/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/Headers/ATLControlWebSocketClient.h @@ -0,0 +1,26 @@ +// +// ATLControlWebSocketClient.h +// AdjustTestLibrary +// +// Created by Serj on 20.02.19. +// Copyright © 2019 adjust. All rights reserved. +// + +#import +#import "PocketSocket/PSWebSocket.h" +#import "ATLTestLibrary.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface ATLControlWebSocketClient : NSObject + +- (void)initializeWebSocketWithControlUrl:(NSString*)controlUrl + andTestLibrary:(ATLTestLibrary*)testLibrary; + +- (void)reconnectIfNeeded; + +- (void)sendInitTestSessionSignal:(NSString*)testSessionId; + +@end + +NS_ASSUME_NONNULL_END diff --git a/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/Headers/ATLTestLibrary.h b/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/Headers/ATLTestLibrary.h index 80948937..099414dd 100644 --- a/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/Headers/ATLTestLibrary.h +++ b/test/plugin/ios/AdjustTestLibrary.framework/Versions/Current/Headers/ATLTestLibrary.h @@ -25,7 +25,12 @@ @interface ATLTestLibrary : NSObject +- (NSString *)currentBasePath; + +- (ATLBlockingQueue *)waitControlQueue; + - (id)initWithBaseUrl:(NSString *)baseUrl + andControlUrl:(NSString *)controlUrl andCommandDelegate:(NSObject *)commandDelegate; - (void)addTest:(NSString *)testName; @@ -34,9 +39,6 @@ - (void)startTestSession:(NSString *)clientSdk; -- (NSString *)currentBasePath; -- (ATLBlockingQueue *)waitControlQueue; - - (void)resetTestLibrary; - (void)readResponse:(ATLHttpResponse *)httpResponse; @@ -46,8 +48,15 @@ - (void)sendInfoToServer:(NSString *)basePath; +- (void)signalEndWaitWithReason:(NSString *)reason; + +- (void)cancelTestAndGetNext; + +- (void)doNotExitAfterEnd; + + (ATLTestLibrary *)testLibraryWithBaseUrl:(NSString *)baseUrl -andCommandDelegate:(NSObject *)commandDelegate; + andControlUrl:(NSString *)controlUrl + andCommandDelegate:(NSObject *)commandDelegate; + (NSURL *)baseUrl; diff --git a/test/plugin/ios/src/AdjustTestExtension/AdjustTestExtension/AdjustTestFunction.m b/test/plugin/ios/src/AdjustTestExtension/AdjustTestExtension/AdjustTestFunction.m index ce703704..cc03f18e 100644 --- a/test/plugin/ios/src/AdjustTestExtension/AdjustTestExtension/AdjustTestFunction.m +++ b/test/plugin/ios/src/AdjustTestExtension/AdjustTestExtension/AdjustTestFunction.m @@ -23,6 +23,7 @@ @implementation AdjustTestFunction FREObject ADJstartTestSession(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) { if (argc == 2) { NSString *baseUrl = nil; + NSString *controlUrl = nil; NSString *clientSdk = nil; adjustTestFREContext = ctx; @@ -30,11 +31,15 @@ FREObject ADJstartTestSession(FREContext ctx, void* funcData, uint32_t argc, FRE FREGetObjectAsNativeString(argv[0], &baseUrl); } if (argv[1] != nil) { - FREGetObjectAsNativeString(argv[1], &clientSdk); + FREGetObjectAsNativeString(argv[1], &controlUrl); + } + if (argv[2] != nil) { + FREGetObjectAsNativeString(argv[2], &clientSdk); } adjustCommandListener = [[AdjustTestCommandListener alloc] initWithContext:&adjustTestFREContext]; testLibrary = [ATLTestLibrary testLibraryWithBaseUrl:baseUrl + andControlUrl:controlUrl andCommandDelegate:adjustCommandListener]; for (id object in selectedTests) { diff --git a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/AdjustTestLibrary b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/AdjustTestLibrary index ae9e5aab..e6fed85a 100644 Binary files a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/AdjustTestLibrary and b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/AdjustTestLibrary differ diff --git a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Headers/ATLConstants.h b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Headers/ATLConstants.h index d4d17ef1..52add012 100644 --- a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Headers/ATLConstants.h +++ b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Headers/ATLConstants.h @@ -9,15 +9,22 @@ #ifndef ATLConstants_h #define ATLConstants_h -static NSString * const TEST_SCRIPT_HEADER = @"TestScript"; -static NSString * const TEST_SESSION_END_HEADER = @"TestSessionEnd"; -static NSString * const TEST_CANCELTEST_HEADER = @"CancelTest"; -static NSString * const TEST_ENDWAIT_HEADER = @"EndWait"; -static NSString * const TEST_LIBRARY_CLASSNAME = @"TestLibrary"; -static NSString * const ADJUST_CLASSNAME = @"Adjust"; -static NSString * const WAIT_FOR_CONTROL = @"control"; -static NSString * const WAIT_FOR_SLEEP = @"sleep"; -static NSString * const BASE_PATH_PARAM = @"basePath"; -static NSString * const TEST_NAME_PARAM = @"basePath"; +static int const ONE_SECOND = 1000; +static int const ONE_MINUTE = 60 * ONE_SECOND; + +static NSString * const TEST_LIBRARY_CLASSNAME = @"TestLibrary"; +static NSString * const ADJUST_CLASSNAME = @"Adjust"; +static NSString * const WAIT_FOR_CONTROL = @"control"; +static NSString * const WAIT_FOR_SLEEP = @"sleep"; +static NSString * const BASE_PATH_PARAM = @"basePath"; +static NSString * const TEST_NAME_PARAM = @"basePath"; +static NSString * const TEST_SESSION_ID_HEADER = @"Test-Session-Id"; + +// web socket values +static NSString * const SIGNAL_INFO = @"info"; +static NSString * const SIGNAL_INIT_TEST_SESSION = @"init-test-session"; +static NSString * const SIGNAL_END_WAIT = @"end-wait"; +static NSString * const SIGNAL_CANCEL_CURRENT_TEST = @"cancel-current-test"; +static NSString * const SIGNAL_UNKNOWN = @"unknown"; #endif /* ATLConstants_h */ diff --git a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Headers/ATLControlWebSocketClient.h b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Headers/ATLControlWebSocketClient.h new file mode 100644 index 00000000..0dd5e21c --- /dev/null +++ b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Headers/ATLControlWebSocketClient.h @@ -0,0 +1,26 @@ +// +// ATLControlWebSocketClient.h +// AdjustTestLibrary +// +// Created by Serj on 20.02.19. +// Copyright © 2019 adjust. All rights reserved. +// + +#import +#import "PocketSocket/PSWebSocket.h" +#import "ATLTestLibrary.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface ATLControlWebSocketClient : NSObject + +- (void)initializeWebSocketWithControlUrl:(NSString*)controlUrl + andTestLibrary:(ATLTestLibrary*)testLibrary; + +- (void)reconnectIfNeeded; + +- (void)sendInitTestSessionSignal:(NSString*)testSessionId; + +@end + +NS_ASSUME_NONNULL_END diff --git a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Headers/ATLTestLibrary.h b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Headers/ATLTestLibrary.h index 80948937..099414dd 100644 --- a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Headers/ATLTestLibrary.h +++ b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Headers/ATLTestLibrary.h @@ -25,7 +25,12 @@ @interface ATLTestLibrary : NSObject +- (NSString *)currentBasePath; + +- (ATLBlockingQueue *)waitControlQueue; + - (id)initWithBaseUrl:(NSString *)baseUrl + andControlUrl:(NSString *)controlUrl andCommandDelegate:(NSObject *)commandDelegate; - (void)addTest:(NSString *)testName; @@ -34,9 +39,6 @@ - (void)startTestSession:(NSString *)clientSdk; -- (NSString *)currentBasePath; -- (ATLBlockingQueue *)waitControlQueue; - - (void)resetTestLibrary; - (void)readResponse:(ATLHttpResponse *)httpResponse; @@ -46,8 +48,15 @@ - (void)sendInfoToServer:(NSString *)basePath; +- (void)signalEndWaitWithReason:(NSString *)reason; + +- (void)cancelTestAndGetNext; + +- (void)doNotExitAfterEnd; + + (ATLTestLibrary *)testLibraryWithBaseUrl:(NSString *)baseUrl -andCommandDelegate:(NSObject *)commandDelegate; + andControlUrl:(NSString *)controlUrl + andCommandDelegate:(NSObject *)commandDelegate; + (NSURL *)baseUrl; diff --git a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/AdjustTestLibrary b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/AdjustTestLibrary index ae9e5aab..e6fed85a 100644 Binary files a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/AdjustTestLibrary and b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/AdjustTestLibrary differ diff --git a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/Headers/ATLConstants.h b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/Headers/ATLConstants.h index d4d17ef1..52add012 100644 --- a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/Headers/ATLConstants.h +++ b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/Headers/ATLConstants.h @@ -9,15 +9,22 @@ #ifndef ATLConstants_h #define ATLConstants_h -static NSString * const TEST_SCRIPT_HEADER = @"TestScript"; -static NSString * const TEST_SESSION_END_HEADER = @"TestSessionEnd"; -static NSString * const TEST_CANCELTEST_HEADER = @"CancelTest"; -static NSString * const TEST_ENDWAIT_HEADER = @"EndWait"; -static NSString * const TEST_LIBRARY_CLASSNAME = @"TestLibrary"; -static NSString * const ADJUST_CLASSNAME = @"Adjust"; -static NSString * const WAIT_FOR_CONTROL = @"control"; -static NSString * const WAIT_FOR_SLEEP = @"sleep"; -static NSString * const BASE_PATH_PARAM = @"basePath"; -static NSString * const TEST_NAME_PARAM = @"basePath"; +static int const ONE_SECOND = 1000; +static int const ONE_MINUTE = 60 * ONE_SECOND; + +static NSString * const TEST_LIBRARY_CLASSNAME = @"TestLibrary"; +static NSString * const ADJUST_CLASSNAME = @"Adjust"; +static NSString * const WAIT_FOR_CONTROL = @"control"; +static NSString * const WAIT_FOR_SLEEP = @"sleep"; +static NSString * const BASE_PATH_PARAM = @"basePath"; +static NSString * const TEST_NAME_PARAM = @"basePath"; +static NSString * const TEST_SESSION_ID_HEADER = @"Test-Session-Id"; + +// web socket values +static NSString * const SIGNAL_INFO = @"info"; +static NSString * const SIGNAL_INIT_TEST_SESSION = @"init-test-session"; +static NSString * const SIGNAL_END_WAIT = @"end-wait"; +static NSString * const SIGNAL_CANCEL_CURRENT_TEST = @"cancel-current-test"; +static NSString * const SIGNAL_UNKNOWN = @"unknown"; #endif /* ATLConstants_h */ diff --git a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/Headers/ATLControlWebSocketClient.h b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/Headers/ATLControlWebSocketClient.h new file mode 100644 index 00000000..0dd5e21c --- /dev/null +++ b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/Headers/ATLControlWebSocketClient.h @@ -0,0 +1,26 @@ +// +// ATLControlWebSocketClient.h +// AdjustTestLibrary +// +// Created by Serj on 20.02.19. +// Copyright © 2019 adjust. All rights reserved. +// + +#import +#import "PocketSocket/PSWebSocket.h" +#import "ATLTestLibrary.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface ATLControlWebSocketClient : NSObject + +- (void)initializeWebSocketWithControlUrl:(NSString*)controlUrl + andTestLibrary:(ATLTestLibrary*)testLibrary; + +- (void)reconnectIfNeeded; + +- (void)sendInitTestSessionSignal:(NSString*)testSessionId; + +@end + +NS_ASSUME_NONNULL_END diff --git a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/Headers/ATLTestLibrary.h b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/Headers/ATLTestLibrary.h index 80948937..099414dd 100644 --- a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/Headers/ATLTestLibrary.h +++ b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/A/Headers/ATLTestLibrary.h @@ -25,7 +25,12 @@ @interface ATLTestLibrary : NSObject +- (NSString *)currentBasePath; + +- (ATLBlockingQueue *)waitControlQueue; + - (id)initWithBaseUrl:(NSString *)baseUrl + andControlUrl:(NSString *)controlUrl andCommandDelegate:(NSObject *)commandDelegate; - (void)addTest:(NSString *)testName; @@ -34,9 +39,6 @@ - (void)startTestSession:(NSString *)clientSdk; -- (NSString *)currentBasePath; -- (ATLBlockingQueue *)waitControlQueue; - - (void)resetTestLibrary; - (void)readResponse:(ATLHttpResponse *)httpResponse; @@ -46,8 +48,15 @@ - (void)sendInfoToServer:(NSString *)basePath; +- (void)signalEndWaitWithReason:(NSString *)reason; + +- (void)cancelTestAndGetNext; + +- (void)doNotExitAfterEnd; + + (ATLTestLibrary *)testLibraryWithBaseUrl:(NSString *)baseUrl -andCommandDelegate:(NSObject *)commandDelegate; + andControlUrl:(NSString *)controlUrl + andCommandDelegate:(NSObject *)commandDelegate; + (NSURL *)baseUrl; diff --git a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/AdjustTestLibrary b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/AdjustTestLibrary index ae9e5aab..e6fed85a 100644 Binary files a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/AdjustTestLibrary and b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/AdjustTestLibrary differ diff --git a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/Headers/ATLConstants.h b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/Headers/ATLConstants.h index d4d17ef1..52add012 100644 --- a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/Headers/ATLConstants.h +++ b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/Headers/ATLConstants.h @@ -9,15 +9,22 @@ #ifndef ATLConstants_h #define ATLConstants_h -static NSString * const TEST_SCRIPT_HEADER = @"TestScript"; -static NSString * const TEST_SESSION_END_HEADER = @"TestSessionEnd"; -static NSString * const TEST_CANCELTEST_HEADER = @"CancelTest"; -static NSString * const TEST_ENDWAIT_HEADER = @"EndWait"; -static NSString * const TEST_LIBRARY_CLASSNAME = @"TestLibrary"; -static NSString * const ADJUST_CLASSNAME = @"Adjust"; -static NSString * const WAIT_FOR_CONTROL = @"control"; -static NSString * const WAIT_FOR_SLEEP = @"sleep"; -static NSString * const BASE_PATH_PARAM = @"basePath"; -static NSString * const TEST_NAME_PARAM = @"basePath"; +static int const ONE_SECOND = 1000; +static int const ONE_MINUTE = 60 * ONE_SECOND; + +static NSString * const TEST_LIBRARY_CLASSNAME = @"TestLibrary"; +static NSString * const ADJUST_CLASSNAME = @"Adjust"; +static NSString * const WAIT_FOR_CONTROL = @"control"; +static NSString * const WAIT_FOR_SLEEP = @"sleep"; +static NSString * const BASE_PATH_PARAM = @"basePath"; +static NSString * const TEST_NAME_PARAM = @"basePath"; +static NSString * const TEST_SESSION_ID_HEADER = @"Test-Session-Id"; + +// web socket values +static NSString * const SIGNAL_INFO = @"info"; +static NSString * const SIGNAL_INIT_TEST_SESSION = @"init-test-session"; +static NSString * const SIGNAL_END_WAIT = @"end-wait"; +static NSString * const SIGNAL_CANCEL_CURRENT_TEST = @"cancel-current-test"; +static NSString * const SIGNAL_UNKNOWN = @"unknown"; #endif /* ATLConstants_h */ diff --git a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/Headers/ATLControlWebSocketClient.h b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/Headers/ATLControlWebSocketClient.h new file mode 100644 index 00000000..0dd5e21c --- /dev/null +++ b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/Headers/ATLControlWebSocketClient.h @@ -0,0 +1,26 @@ +// +// ATLControlWebSocketClient.h +// AdjustTestLibrary +// +// Created by Serj on 20.02.19. +// Copyright © 2019 adjust. All rights reserved. +// + +#import +#import "PocketSocket/PSWebSocket.h" +#import "ATLTestLibrary.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface ATLControlWebSocketClient : NSObject + +- (void)initializeWebSocketWithControlUrl:(NSString*)controlUrl + andTestLibrary:(ATLTestLibrary*)testLibrary; + +- (void)reconnectIfNeeded; + +- (void)sendInitTestSessionSignal:(NSString*)testSessionId; + +@end + +NS_ASSUME_NONNULL_END diff --git a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/Headers/ATLTestLibrary.h b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/Headers/ATLTestLibrary.h index 80948937..099414dd 100644 --- a/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/Headers/ATLTestLibrary.h +++ b/test/plugin/ios/src/AdjustTestExtension/AdjustTestLibrary.framework/Versions/Current/Headers/ATLTestLibrary.h @@ -25,7 +25,12 @@ @interface ATLTestLibrary : NSObject +- (NSString *)currentBasePath; + +- (ATLBlockingQueue *)waitControlQueue; + - (id)initWithBaseUrl:(NSString *)baseUrl + andControlUrl:(NSString *)controlUrl andCommandDelegate:(NSObject *)commandDelegate; - (void)addTest:(NSString *)testName; @@ -34,9 +39,6 @@ - (void)startTestSession:(NSString *)clientSdk; -- (NSString *)currentBasePath; -- (ATLBlockingQueue *)waitControlQueue; - - (void)resetTestLibrary; - (void)readResponse:(ATLHttpResponse *)httpResponse; @@ -46,8 +48,15 @@ - (void)sendInfoToServer:(NSString *)basePath; +- (void)signalEndWaitWithReason:(NSString *)reason; + +- (void)cancelTestAndGetNext; + +- (void)doNotExitAfterEnd; + + (ATLTestLibrary *)testLibraryWithBaseUrl:(NSString *)baseUrl -andCommandDelegate:(NSObject *)commandDelegate; + andControlUrl:(NSString *)controlUrl + andCommandDelegate:(NSObject *)commandDelegate; + (NSURL *)baseUrl; diff --git a/test/plugin/src/com/adjust/test/AdjustTest.as b/test/plugin/src/com/adjust/test/AdjustTest.as index 60f8078d..5bd29ae4 100644 --- a/test/plugin/src/com/adjust/test/AdjustTest.as +++ b/test/plugin/src/com/adjust/test/AdjustTest.as @@ -5,7 +5,7 @@ package com.adjust.test { public class AdjustTest extends EventDispatcher { private static var mExtensionContext:ExtensionContext = null; - private static var mTestingCommandCallbackDelegate:Function; + private static var mTestCommandCallback:Function; private static function getExtensionContext():ExtensionContext { if (mExtensionContext != null) { @@ -14,13 +14,20 @@ package com.adjust.test { return mExtensionContext = ExtensionContext.createExtensionContext("com.adjust.test", null); } - public static function startTestSession(baseUrl:String, clientSdk:String, testingCommandCallbackDelegate:Function):void { - mTestingCommandCallbackDelegate = testingCommandCallbackDelegate; - getExtensionContext().addEventListener(StatusEvent.STATUS, extensionResponseDelegate); - getExtensionContext().call("startTestSession", baseUrl, clientSdk); + public static function startTestSession(baseUrl:String, controlUrl:String, clientSdk:String, testCommandCallback:Function):void { + trace("[AdjustTest]: 'startTestSession' invoked!"); + trace("[AdjustTest]: 'baseUrl' = " + baseUrl); + trace("[AdjustTest]: 'controlUrl' = " + controlUrl); + trace("[AdjustTest]: 'clientSdk' = " + clientSdk); + mTestCommandCallback = testCommandCallback; + getExtensionContext().addEventListener(StatusEvent.STATUS, extensionResponseCallback); + getExtensionContext().call("startTestSession", baseUrl, controlUrl, clientSdk); } public static function addInfoToSend(key:String, value:String):void { + trace("[AdjustTest]: 'addInfoToSend' invoked!"); + trace("[AdjustTest]: 'key' = " + key); + trace("[AdjustTest]: 'value' = " + value); if ("null" != value) { getExtensionContext().call("addInfoToSend", key, value); } else { @@ -29,23 +36,29 @@ package com.adjust.test { } public static function sendInfoToServer(basePath:String):void { + trace("[AdjustTest]: 'sendInfoToServer' invoked!"); + trace("[AdjustTest]: 'basePath' = " + basePath); getExtensionContext().call("sendInfoToServer", basePath); } public static function addTest(testToAdd:String):void { + trace("[AdjustTest]: 'addTest' invoked!"); + trace("[AdjustTest]: 'testToAdd' = " + testToAdd); getExtensionContext().call("addTest", testToAdd); } public static function addTestDirectory(testDirToAdd:String):void { + trace("[AdjustTest]: 'addTestDirectory' invoked!"); + trace("[AdjustTest]: 'testDirToAdd' = " + testDirToAdd); getExtensionContext().call("addTestDirectory", testDirToAdd); } - private static function extensionResponseDelegate(statusEvent:StatusEvent):void { - trace("[AdjustTest] Receiving event: "); - trace(statusEvent) - trace(statusEvent.level) + private static function extensionResponseCallback(statusEvent:StatusEvent):void { + trace("[AdjustTest]: Received event!"); + trace("[AdjustTest]: 'statusEvent' = " + statusEvent) + trace("[AdjustTest]: 'statusEvent.level' = " + statusEvent.level) if (statusEvent.code == "adjust_test_command") { - mTestingCommandCallbackDelegate(statusEvent.level); + mTestCommandCallback(statusEvent.level); } } } diff --git a/test/plugin/src/extension.xml b/test/plugin/src/extension.xml index d1452b89..618c5c45 100644 --- a/test/plugin/src/extension.xml +++ b/test/plugin/src/extension.xml @@ -1,6 +1,6 @@ com.adjust.test - 4.17.2 + 4.18.0 @@ -8,6 +8,12 @@ com.adjust.test.AdjustTestExtension + + + adjust-android-test.jar + com.adjust.test.AdjustTestExtension + + adjust-android-test.jar