Esempio n. 1
0
        public void ExecuteCommand(Command command)
        {
            _command = command;

            TestApp.Log(string.Format("\tEXECUTING METHOD: [{0}.{1}]", _command.ClassName, _command.MethodName));

            try
            {
                switch (_command.MethodName)
                {
                case "testOptions": TestOptions(); break;

                case "config": Config(); break;

                case "start": Start(); break;

                case "event": Event(); break;

                case "trackEvent": TrackEvent(); break;

                case "resume": Resume(); break;

                case "pause": Pause(); break;

                case "setEnabled": SetEnabled(); break;

                case "setReferrer": SetReferrer(); break;

                case "setOfflineMode": SetOfflineMode(); break;

                case "sendFirstPackages": SendFirstPackages(); break;

                case "addSessionCallbackParameter": AddSessionCallbackParameter(); break;

                case "addSessionPartnerParameter": AddSessionPartnerParameter(); break;

                case "removeSessionCallbackParameter": RemoveSessionCallbackParameter(); break;

                case "removeSessionPartnerParameter": RemoveSessionPartnerParameter(); break;

                case "resetSessionCallbackParameters": ResetSessionCallbackParameters(); break;

                case "resetSessionPartnerParameters": ResetSessionPartnerParameters(); break;

                case "setPushToken": SetPushToken(); break;

                case "openDeeplink": OpenDeepLink(); break;

                case "sendReferrer": SetReferrer(); break;

                case "gdprForgetMe": GdprForgetMe(); break;

                case "trackAdRevenue": TrackAdRevenue(); break;

                case "disableThirdPartySharing": DisableThirdPartySharing(); break;

                case "trackSubscription": TrackSubscription(); break;

                default: CommandNotFound(_command.ClassName, _command.MethodName); break;
                }
            }
            catch (Exception ex)
            {
                TestApp.LogError(string.Format("{0} -- {1}",
                                               "executeCommand: failed to parse command. Check commands' syntax", ex.ToString()));
            }
        }
Esempio n. 2
0
 private void CommandNotFound(string className, string methodName)
 {
     TestApp.Log("Adjust Test: Method '" + methodName + "' not found for class '" + className + "'");
 }
Esempio n. 3
0
 public void StartTestSession()
 {
     TestApp.Log("TestLibrary -> StartTestSession()");
     TestLibraryBridgeiOS.StartTestSession(Adjust.getSdkVersion());
 }
Esempio n. 4
0
        private void Config()
        {
            var configNumber = 0;

            if (_command.ContainsParameter("configName"))
            {
                var configName = _command.GetFirstParameterValue("configName");
                configNumber = int.Parse(configName.Substring(configName.Length - 1));
            }

            AdjustConfig   adjustConfig;
            AdjustLogLevel?logLevel = null;

            if (_command.ContainsParameter("logLevel"))
            {
                var logLevelString = _command.GetFirstParameterValue("logLevel");
                switch (logLevelString)
                {
                case "verbose":
                    logLevel = AdjustLogLevel.Verbose;
                    break;

                case "debug":
                    logLevel = AdjustLogLevel.Debug;
                    break;

                case "info":
                    logLevel = AdjustLogLevel.Info;
                    break;

                case "warn":
                    logLevel = AdjustLogLevel.Warn;
                    break;

                case "error":
                    logLevel = AdjustLogLevel.Error;
                    break;

                case "assert":
                    logLevel = AdjustLogLevel.Assert;
                    break;

                case "suppress":
                    logLevel = AdjustLogLevel.Suppress;
                    break;
                }

                TestApp.Log(string.Format("TestApp LogLevel = {0}", logLevel));
            }

            if (_savedConfigs.ContainsKey(configNumber))
            {
                adjustConfig = _savedConfigs[configNumber];
            }
            else
            {
                var environmentString = _command.GetFirstParameterValue("environment");
                var environment       = environmentString == "sandbox" ? AdjustEnvironment.Sandbox : AdjustEnvironment.Production;
                var appToken          = _command.GetFirstParameterValue("appToken");

                if (!string.IsNullOrEmpty(appToken))
                {
                    if (appToken == "null")
                    {
                        adjustConfig = new AdjustConfig(null, environment);
                    }
                    else
                    {
                        adjustConfig = new AdjustConfig(appToken, environment);
                    }
                }
                else
                {
                    adjustConfig = new AdjustConfig(null, environment);
                }

                if (logLevel.HasValue)
                {
                    adjustConfig.setLogLevel(logLevel.Value);
                }

#if (UNITY_WSA || UNITY_WP8)
                adjustConfig.logDelegate = msg => Debug.Log(msg);
#endif
                _savedConfigs.Add(configNumber, adjustConfig);
            }

            if (_command.ContainsParameter("sdkPrefix"))
            {
                // SDK prefix not tested for non natives.
            }

            if (_command.ContainsParameter("defaultTracker"))
            {
                adjustConfig.setDefaultTracker(_command.GetFirstParameterValue("defaultTracker"));
            }

            if (_command.ContainsParameter("externalDeviceId"))
            {
                adjustConfig.setExternalDeviceId(_command.GetFirstParameterValue("externalDeviceId"));
            }

            if (_command.ContainsParameter("delayStart"))
            {
                var delayStartStr = _command.GetFirstParameterValue("delayStart");
                var delayStart    = double.Parse(delayStartStr);
                adjustConfig.setDelayStart(delayStart);
            }

            if (_command.ContainsParameter("appSecret"))
            {
                var appSecretList = _command.Parameters["appSecret"];
                if (!string.IsNullOrEmpty(appSecretList[0]) && appSecretList.Count == 5)
                {
                    long secretId, info1, info2, info3, info4;
                    long.TryParse(appSecretList[0], out secretId);
                    long.TryParse(appSecretList[1], out info1);
                    long.TryParse(appSecretList[2], out info2);
                    long.TryParse(appSecretList[3], out info3);
                    long.TryParse(appSecretList[4], out info4);

                    adjustConfig.setAppSecret(secretId, info1, info2, info3, info4);
                }
            }

            if (_command.ContainsParameter("deviceKnown"))
            {
                var deviceKnownS = _command.GetFirstParameterValue("deviceKnown");
                var deviceKnown  = deviceKnownS.ToLower() == "true";
                adjustConfig.setIsDeviceKnown(deviceKnown);
            }

            if (_command.ContainsParameter("eventBufferingEnabled"))
            {
                var eventBufferingEnabledS = _command.GetFirstParameterValue("eventBufferingEnabled");
                var eventBufferingEnabled  = eventBufferingEnabledS.ToLower() == "true";
                adjustConfig.setEventBufferingEnabled(eventBufferingEnabled);
            }

            if (_command.ContainsParameter("sendInBackground"))
            {
                var sendInBackgroundS = _command.GetFirstParameterValue("sendInBackground");
                var sendInBackground  = sendInBackgroundS.ToLower() == "true";
                adjustConfig.sendInBackground = sendInBackground;
            }

            if (_command.ContainsParameter("allowiAdInfoReading"))
            {
                var allowiAdInfoReadingS = _command.GetFirstParameterValue("allowiAdInfoReading");
                var allowiAdInfoReading  = allowiAdInfoReadingS.ToLower() == "true";
                adjustConfig.allowiAdInfoReading = allowiAdInfoReading;
            }

            if (_command.ContainsParameter("allowIdfaReading"))
            {
                var allowIdfaReadingS = _command.GetFirstParameterValue("allowIdfaReading");
                var allowIdfaReading  = allowIdfaReadingS.ToLower() == "true";
                adjustConfig.allowIdfaReading = allowIdfaReading;
            }

            if (_command.ContainsParameter("userAgent"))
            {
                var userAgent = _command.GetFirstParameterValue("userAgent");
                if (userAgent.Equals("null"))
                {
                    adjustConfig.setUserAgent(null);
                }
                else
                {
                    adjustConfig.setUserAgent(userAgent);
                }
            }

            if (_command.ContainsParameter("deferredDeeplinkCallback"))
            {
                bool launchDeferredDeeplink = _command.GetFirstParameterValue("deferredDeeplinkCallback") == "true";
                adjustConfig.setLaunchDeferredDeeplink(launchDeferredDeeplink);
                string localExtraPath = ExtraPath;
                adjustConfig.setDeferredDeeplinkDelegate(uri =>
                {
                    _testLibrary.AddInfoToSend("deeplink", uri);
                    _testLibrary.SendInfoToServer(localExtraPath);
                });
            }

            if (_command.ContainsParameter("attributionCallbackSendAll"))
            {
                string localExtraPath = ExtraPath;
                adjustConfig.setAttributionChangedDelegate(attribution =>
                {
                    _testLibrary.AddInfoToSend("trackerToken", attribution.trackerToken);
                    _testLibrary.AddInfoToSend("trackerName", attribution.trackerName);
                    _testLibrary.AddInfoToSend("network", attribution.network);
                    _testLibrary.AddInfoToSend("campaign", attribution.campaign);
                    _testLibrary.AddInfoToSend("adgroup", attribution.adgroup);
                    _testLibrary.AddInfoToSend("creative", attribution.creative);
                    _testLibrary.AddInfoToSend("clickLabel", attribution.clickLabel);
                    _testLibrary.AddInfoToSend("adid", attribution.adid);
                    _testLibrary.SendInfoToServer(localExtraPath);
                });
            }

            if (_command.ContainsParameter("sessionCallbackSendSuccess"))
            {
                string localExtraPath = ExtraPath;
                adjustConfig.setSessionSuccessDelegate(sessionSuccessResponseData =>
                {
                    _testLibrary.AddInfoToSend("message", sessionSuccessResponseData.Message);
                    _testLibrary.AddInfoToSend("timestamp", sessionSuccessResponseData.Timestamp);
                    _testLibrary.AddInfoToSend("adid", sessionSuccessResponseData.Adid);
                    if (sessionSuccessResponseData.JsonResponse != null)
                    {
                        _testLibrary.AddInfoToSend("jsonResponse", sessionSuccessResponseData.GetJsonResponse());
                    }
                    _testLibrary.SendInfoToServer(localExtraPath);
                });
            }

            if (_command.ContainsParameter("sessionCallbackSendFailure"))
            {
                string localExtraPath = ExtraPath;
                adjustConfig.setSessionFailureDelegate(sessionFailureResponseData =>
                {
                    _testLibrary.AddInfoToSend("message", sessionFailureResponseData.Message);
                    _testLibrary.AddInfoToSend("timestamp", sessionFailureResponseData.Timestamp);
                    _testLibrary.AddInfoToSend("adid", sessionFailureResponseData.Adid);
                    _testLibrary.AddInfoToSend("willRetry", sessionFailureResponseData.WillRetry.ToString().ToLower());
                    if (sessionFailureResponseData.JsonResponse != null)
                    {
                        _testLibrary.AddInfoToSend("jsonResponse", sessionFailureResponseData.GetJsonResponse());
                    }
                    _testLibrary.SendInfoToServer(localExtraPath);
                });
            }

            if (_command.ContainsParameter("eventCallbackSendSuccess"))
            {
                string localExtraPath = ExtraPath;
                adjustConfig.setEventSuccessDelegate(eventSuccessResponseData =>
                {
                    _testLibrary.AddInfoToSend("message", eventSuccessResponseData.Message);
                    _testLibrary.AddInfoToSend("timestamp", eventSuccessResponseData.Timestamp);
                    _testLibrary.AddInfoToSend("adid", eventSuccessResponseData.Adid);
                    _testLibrary.AddInfoToSend("eventToken", eventSuccessResponseData.EventToken);
                    _testLibrary.AddInfoToSend("callbackId", eventSuccessResponseData.CallbackId);
                    if (eventSuccessResponseData.JsonResponse != null)
                    {
                        _testLibrary.AddInfoToSend("jsonResponse", eventSuccessResponseData.GetJsonResponse());
                    }
                    _testLibrary.SendInfoToServer(localExtraPath);
                });
            }

            if (_command.ContainsParameter("eventCallbackSendFailure"))
            {
                string localExtraPath = ExtraPath;
                adjustConfig.setEventFailureDelegate(eventFailureResponseData =>
                {
                    _testLibrary.AddInfoToSend("message", eventFailureResponseData.Message);
                    _testLibrary.AddInfoToSend("timestamp", eventFailureResponseData.Timestamp);
                    _testLibrary.AddInfoToSend("adid", eventFailureResponseData.Adid);
                    _testLibrary.AddInfoToSend("eventToken", eventFailureResponseData.EventToken);
                    _testLibrary.AddInfoToSend("callbackId", eventFailureResponseData.CallbackId);
                    _testLibrary.AddInfoToSend("willRetry", eventFailureResponseData.WillRetry.ToString().ToLower());
                    if (eventFailureResponseData.JsonResponse != null)
                    {
                        _testLibrary.AddInfoToSend("jsonResponse", eventFailureResponseData.GetJsonResponse());
                    }
                    _testLibrary.SendInfoToServer(localExtraPath);
                });
            }
        }
Esempio n. 5
0
        private void TestOptions()
        {
            TestApp.Log("Configuring and setting Testing Options...");

            Dictionary <string, string> testOptions = new Dictionary <string, string>();

            testOptions[AdjustUtils.KeyTestOptionsBaseUrl] = _baseUrl;
            testOptions[AdjustUtils.KeyTestOptionsGdprUrl] = _gdprUrl;

            if (_command.ContainsParameter("basePath"))
            {
                BasePath = _command.GetFirstParameterValue("basePath");
                GdprPath = _command.GetFirstParameterValue("basePath");
            }
            if (_command.ContainsParameter("timerInterval"))
            {
                testOptions[AdjustUtils.KeyTestOptionsTimerIntervalInMilliseconds] = _command.GetFirstParameterValue("timerInterval");
            }
            if (_command.ContainsParameter("timerStart"))
            {
                testOptions[AdjustUtils.KeyTestOptionsTimerStartInMilliseconds] = _command.GetFirstParameterValue("timerStart");
            }
            if (_command.ContainsParameter("sessionInterval"))
            {
                testOptions[AdjustUtils.KeyTestOptionsSessionIntervalInMilliseconds] = _command.GetFirstParameterValue("sessionInterval");
            }
            if (_command.ContainsParameter("subsessionInterval"))
            {
                testOptions[AdjustUtils.KeyTestOptionsSubsessionIntervalInMilliseconds] = _command.GetFirstParameterValue("subsessionInterval");
            }
            if (_command.ContainsParameter("noBackoffWait"))
            {
                testOptions[AdjustUtils.KeyTestOptionsNoBackoffWait] = _command.GetFirstParameterValue("noBackoffWait");
            }
            testOptions [AdjustUtils.KeyTestOptionsiAdFrameworkEnabled] = "false";  // false - iAd will not be used in test app by default
            if (_command.ContainsParameter("iAdFrameworkEnabled"))
            {
                testOptions[AdjustUtils.KeyTestOptionsiAdFrameworkEnabled] = _command.GetFirstParameterValue("iAdFrameworkEnabled");
            }
            if (_command.ContainsParameter("teardown"))
            {
                List <string> teardownOptions = _command.Parameters["teardown"];
                foreach (string teardownOption in teardownOptions)
                {
                    if (teardownOption == "resetSdk")
                    {
                        testOptions[AdjustUtils.KeyTestOptionsTeardown] = "true";
                        testOptions[AdjustUtils.KeyTestOptionsBasePath] = BasePath;
                        testOptions[AdjustUtils.KeyTestOptionsGdprPath] = GdprPath;
                        testOptions[AdjustUtils.KeyTestOptionsUseTestConnectionOptions] = "true";
                    }
                    if (teardownOption == "deleteState")
                    {
                        testOptions[AdjustUtils.KeyTestOptionsDeleteState] = "true";
                    }
                    if (teardownOption == "resetTest")
                    {
                        _savedEvents  = new Dictionary <int, AdjustEvent>();
                        _savedConfigs = new Dictionary <int, AdjustConfig>();
                        testOptions[AdjustUtils.KeyTestOptionsTimerIntervalInMilliseconds]      = "-1";
                        testOptions[AdjustUtils.KeyTestOptionsSessionIntervalInMilliseconds]    = "-1";
                        testOptions[AdjustUtils.KeyTestOptionsTimerStartInMilliseconds]         = "-1";
                        testOptions[AdjustUtils.KeyTestOptionsSubsessionIntervalInMilliseconds] = "-1";
                    }
                    if (teardownOption == "sdk")
                    {
                        testOptions[AdjustUtils.KeyTestOptionsTeardown] = "true";
                        testOptions[AdjustUtils.KeyTestOptionsBasePath] = null;
                        testOptions[AdjustUtils.KeyTestOptionsGdprPath] = null;
                        testOptions[AdjustUtils.KeyTestOptionsUseTestConnectionOptions] = "false";
                    }
                    if (teardownOption == "test")
                    {
                        _savedEvents  = null;
                        _savedConfigs = null;
                        testOptions[AdjustUtils.KeyTestOptionsTimerIntervalInMilliseconds]      = "-1";
                        testOptions[AdjustUtils.KeyTestOptionsTimerStartInMilliseconds]         = "-1";
                        testOptions[AdjustUtils.KeyTestOptionsSessionIntervalInMilliseconds]    = "-1";
                        testOptions[AdjustUtils.KeyTestOptionsSubsessionIntervalInMilliseconds] = "-1";
                    }
                }
            }

            Adjust.SetTestOptions(testOptions);
        }
Esempio n. 6
0
        private void TestOptions()
        {
            TestApp.Log("Configuring and setting Testing Options...");

            AdjustTestOptions testOptions = new AdjustTestOptions();

            testOptions.BaseUrl = _baseUrl;
            testOptions.GdprUrl = _gdprUrl;

            if (_command.ContainsParameter("basePath"))
            {
                BasePath = _command.GetFirstParameterValue("basePath");
                GdprPath = _command.GetFirstParameterValue("basePath");
            }

            if (_command.ContainsParameter("timerInterval"))
            {
                long timerInterval = long.Parse(_command.GetFirstParameterValue("timerInterval"));
                testOptions.TimerIntervalInMilliseconds = timerInterval;
            }

            if (_command.ContainsParameter("timerStart"))
            {
                long timerStart = long.Parse(_command.GetFirstParameterValue("timerStart"));
                testOptions.TimerStartInMilliseconds = timerStart;
            }

            if (_command.ContainsParameter("sessionInterval"))
            {
                long sessionInterval = long.Parse(_command.GetFirstParameterValue("sessionInterval"));
                testOptions.SessionIntervalInMilliseconds = sessionInterval;
            }

            if (_command.ContainsParameter("subsessionInterval"))
            {
                long subsessionInterval = long.Parse(_command.GetFirstParameterValue("subsessionInterval"));
                testOptions.SubsessionIntervalInMilliseconds = subsessionInterval;
            }

            if (_command.ContainsParameter("teardown"))
            {
                List <string> teardownOptions = _command.Parameters["teardown"];
                foreach (string teardownOption in teardownOptions)
                {
                    if (teardownOption == "resetSdk")
                    {
                        testOptions.Teardown = true;
                        testOptions.BasePath = BasePath;
                        testOptions.GdprPath = GdprPath;
                        testOptions.UseTestConnectionOptions = true;
                    }
                    if (teardownOption == "deleteState")
                    {
                        testOptions.DeleteState = true;
                    }
                    if (teardownOption == "resetTest")
                    {
                        _savedEvents  = new Dictionary <int, AdjustEvent>();
                        _savedConfigs = new Dictionary <int, AdjustConfig>();
                        testOptions.TimerIntervalInMilliseconds      = -1;
                        testOptions.TimerStartInMilliseconds         = -1;
                        testOptions.SessionIntervalInMilliseconds    = -1;
                        testOptions.SubsessionIntervalInMilliseconds = -1;
                    }
                    if (teardownOption == "sdk")
                    {
                        testOptions.Teardown = true;
                        testOptions.BasePath = null;
                        testOptions.GdprPath = null;
                        testOptions.UseTestConnectionOptions = false;
                    }
                    if (teardownOption == "test")
                    {
                        _savedEvents  = null;
                        _savedConfigs = null;
                        testOptions.TimerIntervalInMilliseconds      = -1;
                        testOptions.TimerStartInMilliseconds         = -1;
                        testOptions.SessionIntervalInMilliseconds    = -1;
                        testOptions.SubsessionIntervalInMilliseconds = -1;
                    }
                }
            }

            Adjust.SetTestOptions(testOptions);
        }
Esempio n. 7
0
 public void StartTestSession()
 {
     TestApp.Log("TestLibrary -> StartTestSession()");
     _testLibraryInterface.StartTestSession(Adjust.getSdkVersion());
 }
Esempio n. 8
0
 public void StartTestSession()
 {
     TestApp.Log("TestFactory -> StartTestSession()");
     TestLibraryBridgeiOS.StartTestSession(TestApp.CLIENT_SDK);
 }
 public void StartTestSession()
 {
     TestApp.Log("TestFactory -> StartTestSession()");
     _testLibraryInterface.StartTestSession(TestApp.CLIENT_SDK);
 }