public static void SimulateApplicationResume()
 {
     WaitOneFrame(() => {
         Debug.Log("Simulating application resume.");
         MoPubManager.EmitConsentDialogDismissedIfApplicable(false);
     });
 }
Esempio n. 2
0
 private void OnDestroy()
 {
     if (Instance == this)
     {
         Instance = null;
     }
 }
        private static void TestEmitRewardedVideoReceivedRewardEvent(string adUnitId, string label, object amount,
                                                                     bool shouldFail = false)
        {
            const string successMessage = "OnRewardedVideoReceivedRewardEvent triggered.";
            Action <string, string, float> successHandler = (_adUnitId, _label, _amount) => {
                Assert.That(_adUnitId, Is.EqualTo(adUnitId));
                Assert.That(_label, Is.EqualTo(label));
                Assert.That(_amount, Is.EqualTo(amount));
                Debug.Log(successMessage);
            };

            const string            failureMessage = "OnRewardedVideoFailedEvent triggered.";
            Action <string, string> failureHandler = (_adUnitId, _error) => {
                Assert.That(_adUnitId, Is.EqualTo(adUnitId));
                Debug.Log(failureMessage);
            };

            MoPubManager.OnRewardedVideoReceivedRewardEvent += successHandler;
            MoPubManager.OnRewardedVideoFailedEvent         += failureHandler;
            try {
                var mpm = new MoPubManager();
                mpm.EmitRewardedVideoReceivedRewardEvent(MoPubUtils.EncodeArgs(adUnitId, label, amount.ToString()));
                LogAssert.Expect(LogType.Log, shouldFail ? failureMessage : successMessage);
            } finally {
                MoPubManager.OnRewardedVideoReceivedRewardEvent -= successHandler;
                MoPubManager.OnRewardedVideoFailedEvent         -= failureHandler;
            }
        }
        private static void TestEmitAdLoadedEvent(string adUnitId, object width, object height, bool shouldFail = false)
        {
            const string           successMessage = "OnAdLoadedEvent triggered.";
            Action <string, float> successHandler = (_adUnitId, _height) => {
                Assert.That(_adUnitId, Is.EqualTo(adUnitId));
                Assert.That(_height, Is.EqualTo(height));
                Debug.Log(successMessage);
            };

            const string            failureMessage = "OnAdFailedEvent triggered.";
            Action <string, string> failureHandler = (_adUnitId, _error) => {
                Assert.That(_adUnitId, Is.EqualTo(adUnitId));
                Debug.Log(failureMessage);
            };

            MoPubManager.OnAdLoadedEvent += successHandler;
            MoPubManager.OnAdFailedEvent += failureHandler;
            try {
                var mpm = new MoPubManager();
                mpm.EmitAdLoadedEvent(MoPubUtils.EncodeArgs(adUnitId, width.ToString(), height.ToString()));
                LogAssert.Expect(LogType.Log, shouldFail ? failureMessage : successMessage);
            } finally {
                MoPubManager.OnAdLoadedEvent -= successHandler;
                MoPubManager.OnAdFailedEvent -= failureHandler;
            }
        }
Esempio n. 5
0
 private void OnDestroy()
 {
     if (MoPubManager.Instance == this)
     {
         MoPubManager.Instance = null;
     }
 }
        public void DecodeArgsWithValueShouldYieldListWithValue()
        {
            var res = MoPubManager.DecodeArgs("[\"a\"]", 0);

            Assert.That(res, Is.Not.Null);
            Assert.That(res.Length, Is.EqualTo(1));
            Assert.That(res[0], Is.EqualTo("a"));
        }
        public void DecodeArgsWithInvalidShouldErrorAndYieldEmptyList()
        {
            var res = MoPubManager.DecodeArgs("{\"a\"]", 0);

            LogAssert.Expect(LogType.Error, "Invalid JSON data: {\"a\"]");
            Assert.That(res, Is.Not.Null);
            Assert.That(res.Length, Is.Zero);
        }
Esempio n. 8
0
        public void DecodeArgsWithNullShouldErrorAndYieldEmptyList()
        {
            var res = MoPubManager.DecodeArgs(null, 0);

            LogAssert.Expect(LogType.Error, "Invalid JSON data: ");
            Assert.That(res, Is.Not.Null);
            Assert.That(res.Length, Is.EqualTo(0));
        }
        public void DecodeArgsWithExpectedValuesShouldYieldListWithDesiredValues()
        {
            var res = MoPubManager.DecodeArgs("[\"a\", \"b\", \"c\"]", 3);

            Assert.That(res, Is.Not.Null);
            Assert.That(res.Length, Is.EqualTo(3));
            Assert.That(res[0], Is.EqualTo("a"));
            Assert.That(res[1], Is.EqualTo("b"));
            Assert.That(res[2], Is.EqualTo("c"));
        }
        public void DecodeArgsWithoutMinimumValuesShouldErrorAndYieldListWithDesiredLength()
        {
            var res = MoPubManager.DecodeArgs("[\"a\", \"b\"]", 3);

            LogAssert.Expect(LogType.Error, "Missing one or more values: [\"a\", \"b\"] (expected 3)");
            Assert.That(res, Is.Not.Null);
            Assert.That(res.Length, Is.EqualTo(3));
            Assert.That(res[0], Is.EqualTo("a"));
            Assert.That(res[1], Is.EqualTo("b"));
            Assert.That(res[2], Is.EqualTo(""));
        }
Esempio n. 11
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(this);
     }
 }
Esempio n. 12
0
 private void Awake()
 {
     if (MoPubManager.Instance == null)
     {
         MoPubManager.Instance = this;
         UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
     }
     else
     {
         UnityEngine.Object.Destroy(this);
     }
 }
 internal override void OnApplicationPause(bool paused)
 {
     MoPubManager.EmitConsentDialogDismissedIfApplicable(paused);
 }
Esempio n. 14
0
 internal override void OnApplicationPause(bool paused)
 {
     PluginClass.CallStatic("onApplicationPause", paused);
     MoPubManager.EmitConsentDialogDismissedIfApplicable(paused);
 }
Esempio n. 15
0
 void onRewardedVideoReceivedRewardEvent( MoPubManager.RewardedVideoData rewardedVideoData )
 {
     Debug.Log( "onRewardedVideoReceivedRewardEvent: " + rewardedVideoData );
 }