From 5b7af6cfc0a14029d2ddfe65d774ba2cbe39f73e Mon Sep 17 00:00:00 2001 From: Nathan Shayefar Date: Thu, 5 May 2016 12:55:48 -0700 Subject: [PATCH] Release: version 4.6.1 --- CHANGELOG.md | 3 + README.md | 5 +- mopub-sample/AndroidManifest.xml | 4 +- mopub-sample/build.gradle | 4 +- mopub-sdk/build.gradle | 4 +- .../src/main/java/com/mopub/common/MoPub.java | 2 +- .../mobileads/BaseInterstitialActivity.java | 2 - .../java/com/mopub/mobileads/BaseWebView.java | 76 +++++++++------ .../com/mopub/mobileads/MoPubActivity.java | 12 ++- .../com/mopub/mobileads/MraidActivity.java | 9 +- .../com/mopub/mobileads/util/WebViews.java | 19 ++-- .../com.mopub.sdk.android.mopub.properties | 2 +- .../com/mopub/mobileads/BaseWebViewTest.java | 14 +++ .../mopub/mobileads/MoPubActivityTest.java | 8 ++ .../mopub/mobileads/MraidActivityTest.java | 96 +++++++++++-------- 15 files changed, 167 insertions(+), 93 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5939f5d57..6900f89ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +#### Version 4.6.1 (May 5, 2016) +- Enhanced caching logic for HTML and MRAID interstitials. Resource-heavy interstitials will now render more quickly when MoPubInterstitial#show() is called. + ## Version 4.6.0 (April 21, 2016) - Certified Chartboost version 6.4.1 - Certified Tapjoy version 11.5.1 diff --git a/README.md b/README.md index e12355825..398e7328e 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ The MoPub SDK is available via: } dependencies { - compile('com.mopub:mopub-sdk:4.5.1@aar') { + compile('com.mopub:mopub-sdk:4.6.1@aar') { transitive = true } } @@ -62,8 +62,7 @@ The MoPub SDK is available via: ## New in this Version Please view the [changelog](https://github.com/mopub/mopub-android-sdk/blob/master/CHANGELOG.md) for a complete list of additions, fixes, and enhancements in the latest release. -- Certified Chartboost version 6.4.1 -- Certified Tapjoy version 11.5.1 +- Enhanced caching logic for HTML and MRAID interstitials. Resource-heavy interstitials will now render more quickly when MoPubInterstitial#show() is called. ## Requirements diff --git a/mopub-sample/AndroidManifest.xml b/mopub-sample/AndroidManifest.xml index 17fd03929..e6a264469 100644 --- a/mopub-sample/AndroidManifest.xml +++ b/mopub-sample/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="40" + android:versionName="4.6.1"> diff --git a/mopub-sample/build.gradle b/mopub-sample/build.gradle index 6f6feae85..8a9b4dabb 100644 --- a/mopub-sample/build.gradle +++ b/mopub-sample/build.gradle @@ -9,7 +9,7 @@ apply plugin: 'com.android.application' group = 'com.mopub' description = '''MoPub Sample App''' -version = '4.6.0' +version = '4.6.1' android { compileSdkVersion 23 @@ -17,7 +17,7 @@ android { lintOptions { abortOnError false } defaultConfig { - versionCode 39 + versionCode 40 versionName version minSdkVersion 9 targetSdkVersion 23 diff --git a/mopub-sdk/build.gradle b/mopub-sdk/build.gradle index df8570559..5b4b95a59 100644 --- a/mopub-sdk/build.gradle +++ b/mopub-sdk/build.gradle @@ -37,7 +37,7 @@ task wrapper(type: Wrapper) { group = 'com.mopub' description = '''MoPub Android SDK''' -version = '4.6.0' +version = '4.6.1' android { compileSdkVersion 23 @@ -46,7 +46,7 @@ android { useLibrary 'org.apache.http.legacy' defaultConfig { - versionCode 39 + versionCode 40 versionName version minSdkVersion 9 targetSdkVersion 23 diff --git a/mopub-sdk/src/main/java/com/mopub/common/MoPub.java b/mopub-sdk/src/main/java/com/mopub/common/MoPub.java index 1616eca6f..ca3a21c55 100644 --- a/mopub-sdk/src/main/java/com/mopub/common/MoPub.java +++ b/mopub-sdk/src/main/java/com/mopub/common/MoPub.java @@ -9,7 +9,7 @@ import com.mopub.mobileads.MoPubRewardedVideoManager.RequestParameters; public class MoPub { - public static final String SDK_VERSION = "4.6.0"; + public static final String SDK_VERSION = "4.6.1"; public enum LocationAwareness { NORMAL, TRUNCATED, DISABLED } diff --git a/mopub-sdk/src/main/java/com/mopub/mobileads/BaseInterstitialActivity.java b/mopub-sdk/src/main/java/com/mopub/mobileads/BaseInterstitialActivity.java index 1b1ddf216..122787a07 100644 --- a/mopub-sdk/src/main/java/com/mopub/mobileads/BaseInterstitialActivity.java +++ b/mopub-sdk/src/main/java/com/mopub/mobileads/BaseInterstitialActivity.java @@ -67,8 +67,6 @@ public void onClose() { mCloseableLayout.addView(adView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); setContentView(mCloseableLayout); - - } @Override diff --git a/mopub-sdk/src/main/java/com/mopub/mobileads/BaseWebView.java b/mopub-sdk/src/main/java/com/mopub/mobileads/BaseWebView.java index 9451faf63..84d1e820a 100644 --- a/mopub-sdk/src/main/java/com/mopub/mobileads/BaseWebView.java +++ b/mopub-sdk/src/main/java/com/mopub/mobileads/BaseWebView.java @@ -1,5 +1,6 @@ package com.mopub.mobileads; +import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Color; import android.graphics.PixelFormat; @@ -11,6 +12,7 @@ import android.webkit.WebSettings; import android.webkit.WebView; +import com.mopub.common.VisibleForTesting; import com.mopub.common.util.VersionCode; import com.mopub.common.util.Views; import com.mopub.mobileads.util.WebViews; @@ -25,30 +27,29 @@ public BaseWebView(Context context) { * an Activity context, as it will leak on Froyo devices and earlier. */ super(context.getApplicationContext()); - enablePlugins(false); + enablePlugins(false); + restrictDeviceContentAccess(); WebViews.setDisableJSChromeClient(this); if (!sDeadlockCleared) { clearWebViewDeadlock(getContext()); sDeadlockCleared = true; } + } - /* - * Disabling file access and content access prevents advertising creatives from - * detecting the presence of, or reading, files on the device filesystem. - */ - - getSettings().setAllowFileAccess(false); + @Override + public void destroy() { + mIsDestroyed = true; - if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { - getSettings().setAllowContentAccess(false); - } + // Needed to prevent receiving the following error on Android versions using WebViewClassic + // https://code.google.com/p/android/issues/detail?id=65833. + Views.removeFromParent(this); - if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { - getSettings().setAllowFileAccessFromFileURLs(false); - getSettings().setAllowUniversalAccessFromFileURLs(false); - } + // Even after removing from the parent, WebViewClassic can leak because of a static + // reference from HTML5VideoViewProcessor. Removing children fixes this problem. + removeAllViews(); + super.destroy(); } protected void enablePlugins(final boolean enabled) { @@ -64,23 +65,34 @@ protected void enablePlugins(final boolean enabled) { } } - @Override - public void destroy() { - mIsDestroyed = true; + /* + * Intended to be used with dummy WebViews to precache WebView javascript and assets. + */ + @SuppressLint("SetJavaScriptEnabled") + protected void enableJavascriptCaching() { + getSettings().setJavaScriptEnabled(true); + getSettings().setDomStorageEnabled(true); + getSettings().setAppCacheEnabled(true); + // Required for the Application Caches API to be enabled + // See: http://developer.android.com/reference/android/webkit/WebSettings.html#setAppCachePath(java.lang.String) + getSettings().setAppCachePath(getContext().getCacheDir().getAbsolutePath()); + } - // Needed to prevent receiving the following error on Android versions using WebViewClassic - // https://code.google.com/p/android/issues/detail?id=65833. - Views.removeFromParent(this); + /* + * Disabling file access and content access prevents advertising creatives from + * detecting the presence of, or reading, files on the device filesystem. + */ + private void restrictDeviceContentAccess() { + getSettings().setAllowFileAccess(false); - // Even after removing from the parent, WebViewClassic can leak because of a static - // reference from HTML5VideoViewProcessor. Removing children fixes this problem. - removeAllViews(); - super.destroy(); - } + if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { + getSettings().setAllowContentAccess(false); + } - @Deprecated // for testing - void setIsDestroyed(boolean isDestroyed) { - mIsDestroyed = isDestroyed; + if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { + getSettings().setAllowFileAccessFromFileURLs(false); + getSettings().setAllowUniversalAccessFromFileURLs(false); + } } /** @@ -96,7 +108,7 @@ void setIsDestroyed(boolean isDestroyed) { */ private void clearWebViewDeadlock(@NonNull final Context context) { if (VERSION.SDK_INT == VERSION_CODES.KITKAT) { - // Create an invisible webview + // Create an invisible WebView final WebView webView = new WebView(context.getApplicationContext()); webView.setBackgroundColor(Color.TRANSPARENT); @@ -120,5 +132,9 @@ private void clearWebViewDeadlock(@NonNull final Context context) { } } - + @VisibleForTesting + @Deprecated // for testing + void setIsDestroyed(boolean isDestroyed) { + mIsDestroyed = isDestroyed; + } } diff --git a/mopub-sdk/src/main/java/com/mopub/mobileads/MoPubActivity.java b/mopub-sdk/src/main/java/com/mopub/mobileads/MoPubActivity.java index bf0168d32..4e3a44802 100644 --- a/mopub-sdk/src/main/java/com/mopub/mobileads/MoPubActivity.java +++ b/mopub-sdk/src/main/java/com/mopub/mobileads/MoPubActivity.java @@ -67,15 +67,19 @@ static Intent createIntent(Context context, static void preRenderHtml(final Context context, final AdReport adReport, final CustomEventInterstitialListener customEventInterstitialListener, - String htmlData) { - HtmlInterstitialWebView dummyWebView = HtmlInterstitialWebViewFactory.create(context, adReport, customEventInterstitialListener, false, null, null); + final String htmlData) { + final HtmlInterstitialWebView dummyWebView = HtmlInterstitialWebViewFactory.create(context, + adReport, customEventInterstitialListener, false, null, null); + dummyWebView.enablePlugins(false); + dummyWebView.enableJavascriptCaching(); + dummyWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { - if (url.equals(MOPUB_FINISH_LOAD)) { + if (MOPUB_FINISH_LOAD.equals(url)) { customEventInterstitialListener.onInterstitialLoaded(); - } else if (url.equals(MOPUB_FAIL_LOAD)) { + } else if (MOPUB_FAIL_LOAD.equals(url)) { customEventInterstitialListener.onInterstitialFailed(null); } diff --git a/mopub-sdk/src/main/java/com/mopub/mobileads/MraidActivity.java b/mopub-sdk/src/main/java/com/mopub/mobileads/MraidActivity.java index d4debbbfd..9b21623f0 100644 --- a/mopub-sdk/src/main/java/com/mopub/mobileads/MraidActivity.java +++ b/mopub-sdk/src/main/java/com/mopub/mobileads/MraidActivity.java @@ -44,9 +44,16 @@ public class MraidActivity extends BaseInterstitialActivity { public static void preRenderHtml(@NonNull final Context context, @NonNull final CustomEventInterstitialListener customEventInterstitialListener, @NonNull final String htmlData) { - BaseWebView dummyWebView = new BaseWebView(context); + preRenderHtml(customEventInterstitialListener, htmlData, new BaseWebView(context)); + } + @VisibleForTesting + static void preRenderHtml( + @NonNull final CustomEventInterstitialListener customEventInterstitialListener, + @NonNull final String htmlData, @NonNull final BaseWebView dummyWebView) { dummyWebView.enablePlugins(false); + dummyWebView.enableJavascriptCaching(); + dummyWebView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(final WebView view, final String url) { diff --git a/mopub-sdk/src/main/java/com/mopub/mobileads/util/WebViews.java b/mopub-sdk/src/main/java/com/mopub/mobileads/util/WebViews.java index 57eb0f0c1..121707038 100644 --- a/mopub-sdk/src/main/java/com/mopub/mobileads/util/WebViews.java +++ b/mopub-sdk/src/main/java/com/mopub/mobileads/util/WebViews.java @@ -14,7 +14,7 @@ public class WebViews { @TargetApi(VERSION_CODES.HONEYCOMB) - public static void onResume(@NonNull WebView webView) { + public static void onResume(@NonNull final WebView webView) { if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { webView.onResume(); return; @@ -29,7 +29,7 @@ public static void onResume(@NonNull WebView webView) { } @TargetApi(VERSION_CODES.HONEYCOMB) - public static void onPause(@NonNull WebView webView, boolean isFinishing) { + public static void onPause(@NonNull final WebView webView, boolean isFinishing) { // XXX // We need to call WebView#stopLoading and WebView#loadUrl here due to an Android // bug where the audio of an HTML5 video will continue to play after the activity has been @@ -53,31 +53,36 @@ public static void onPause(@NonNull WebView webView, boolean isFinishing) { } } - public static void setDisableJSChromeClient(WebView webView) { + public static void setDisableJSChromeClient(@NonNull final WebView webView) { webView.setWebChromeClient(new WebChromeClient() { @Override - public boolean onJsAlert(WebView view, String url, String message, JsResult result) { + public boolean onJsAlert(@NonNull final WebView view, @NonNull final String url, + @NonNull final String message, @NonNull final JsResult result) { MoPubLog.d(message); result.confirm(); return true; } @Override - public boolean onJsConfirm(WebView view, String url, String message, JsResult result) { + public boolean onJsConfirm(@NonNull final WebView view, @NonNull final String url, + @NonNull final String message, @NonNull final JsResult result) { MoPubLog.d(message); result.confirm(); return true; } @Override - public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) { + public boolean onJsPrompt(@NonNull final WebView view, @NonNull final String url, + @NonNull final String message, @NonNull final String defaultValue, + @NonNull final JsPromptResult result) { MoPubLog.d(message); result.confirm(); return true; } @Override - public boolean onJsBeforeUnload(WebView view, String url, String message, JsResult result) { + public boolean onJsBeforeUnload(@NonNull final WebView view, @NonNull final String url, + @NonNull final String message, @NonNull final JsResult result) { MoPubLog.d(message); result.confirm(); return true; diff --git a/mopub-sdk/src/main/resources/fabric/com.mopub.sdk.android.mopub.properties b/mopub-sdk/src/main/resources/fabric/com.mopub.sdk.android.mopub.properties index ccca0c68c..bebee2711 100644 --- a/mopub-sdk/src/main/resources/fabric/com.mopub.sdk.android.mopub.properties +++ b/mopub-sdk/src/main/resources/fabric/com.mopub.sdk.android.mopub.properties @@ -1,3 +1,3 @@ fabric-identifier=com.mopub.sdk.android:mopub -fabric-version=4.6.0+kit +fabric-version=4.6.1+kit fabric-build-type=source diff --git a/mopub-sdk/src/test/java/com/mopub/mobileads/BaseWebViewTest.java b/mopub-sdk/src/test/java/com/mopub/mobileads/BaseWebViewTest.java index 97d297dd0..89eb11870 100644 --- a/mopub-sdk/src/test/java/com/mopub/mobileads/BaseWebViewTest.java +++ b/mopub-sdk/src/test/java/com/mopub/mobileads/BaseWebViewTest.java @@ -14,6 +14,7 @@ import org.robolectric.Robolectric; import org.robolectric.Shadows; import org.robolectric.annotation.Config; +import org.robolectric.fakes.RoboWebSettings; import org.robolectric.shadows.ShadowWebView; import static org.fest.assertions.api.Assertions.assertThat; @@ -81,6 +82,19 @@ public void atLeastJellybeanMr2_shouldPass() throws Exception { // pass } + @Test + public void enableJavascriptCaching_enablesJavascriptDomStorageAndAppCache() { + subject = new BaseWebView(context); + final RoboWebSettings settings = (RoboWebSettings) subject.getSettings(); + + subject.enableJavascriptCaching(); + + assertThat(settings.getJavaScriptEnabled()).isTrue(); + assertThat(settings.getDomStorageEnabled()).isTrue(); + assertThat(settings.getAppCacheEnabled()).isTrue(); + assertThat(settings.getAppCachePath()).isEqualTo(context.getCacheDir().getAbsolutePath()); + } + @Test public void destroy_shouldRemoveSelfFromParent_beforeCallingDestroy() throws Exception { subject = new BaseWebView(context); diff --git a/mopub-sdk/src/test/java/com/mopub/mobileads/MoPubActivityTest.java b/mopub-sdk/src/test/java/com/mopub/mobileads/MoPubActivityTest.java index 2164d891f..14308b955 100644 --- a/mopub-sdk/src/test/java/com/mopub/mobileads/MoPubActivityTest.java +++ b/mopub-sdk/src/test/java/com/mopub/mobileads/MoPubActivityTest.java @@ -104,6 +104,14 @@ public void preRenderHtml_shouldPreloadTheHtml() throws Exception { verify(htmlInterstitialWebView).loadHtmlResponse(htmlData); } + @Test + public void preRenderHtml_shouldEnableJavascriptCachingForDummyWebView() { + MoPubActivity.preRenderHtml(subject, mockAdReport, customEventInterstitialListener, + "html_data"); + + verify(htmlInterstitialWebView).enableJavascriptCaching(); + } + @Test public void preRenderHtml_shouldHaveAWebViewClientThatForwardsFinishLoad() throws Exception { MoPubActivity.preRenderHtml(subject, mockAdReport, customEventInterstitialListener, null); diff --git a/mopub-sdk/src/test/java/com/mopub/mobileads/MraidActivityTest.java b/mopub-sdk/src/test/java/com/mopub/mobileads/MraidActivityTest.java index e27325f18..dc0602f15 100644 --- a/mopub-sdk/src/test/java/com/mopub/mobileads/MraidActivityTest.java +++ b/mopub-sdk/src/test/java/com/mopub/mobileads/MraidActivityTest.java @@ -1,5 +1,6 @@ package com.mopub.mobileads; +import android.app.Activity; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -48,45 +49,64 @@ @Config(constants = BuildConfig.class) public class MraidActivityTest { static final String EXPECTED_SOURCE = "expected source"; + static final String HTML_DATA = "html_data"; - @Mock MraidWebView mraidWebView; + @Mock MraidWebView mockMraidWebView; @Mock MraidBridge mraidBridge; @Mock MraidController mraidController; @Mock CustomEventInterstitial.CustomEventInterstitialListener customEventInterstitialListener; @Mock BroadcastReceiver broadcastReceiver; + Context context; + + // These fields are relics of a previous version of this class (all tests using them have since + // been deprecated). + MraidActivity subject; + ActivityController activityController; + long testBroadcastIdentifier = 2222; - ActivityController activityController; - TestMraidActivity subject; + @Before + public void setUp() throws Exception { + context = Robolectric.buildActivity(Activity.class).create().get(); + } - // Make a concrete version of the abstract class for testing purposes. - private static class TestMraidActivity extends MraidActivity { - View mraidWebView; + @Test + public void preRenderHtml_shouldEnableJavascriptCachingForDummyWebView() { + MraidActivity.preRenderHtml(customEventInterstitialListener, HTML_DATA, mockMraidWebView); - @Override - public View getAdView() { - return mraidWebView; - } + verify(mockMraidWebView).enableJavascriptCaching(); } - @Before - public void setUp() throws Exception { - activityController = Robolectric.buildActivity(TestMraidActivity.class).start(); - subject = activityController.get(); - subject.mraidWebView = mraidWebView; - activityController.create(); + @Test + public void preRenderHtml_shouldDisablePluginsForDummyWebView() { + MraidActivity.preRenderHtml(customEventInterstitialListener, HTML_DATA, mockMraidWebView); + + verify(mockMraidWebView).enablePlugins(false); + } + + @Test + public void preRenderHtml_shouldLoadHtml() { + MraidActivity.preRenderHtml(customEventInterstitialListener, HTML_DATA, mockMraidWebView); + + verify(mockMraidWebView).loadDataWithBaseURL( + "http://ads.mopub.com/", + HTML_DATA, + "text/html", + "UTF-8", + null + ); } @Ignore("Mraid 2.0") @Test - public void preRenderHtml_shouldDisablePluginsSetListenersAndLoadHtml() throws Exception { + public void preRenderHtml_shouldSetWebViewClient() throws Exception { MraidActivity.preRenderHtml(subject, customEventInterstitialListener, "3:27"); - verify(mraidWebView).enablePlugins(eq(false)); + verify(mockMraidWebView).enablePlugins(eq(false)); verify(mraidController).setMraidListener(any(MraidListener.class)); - verify(mraidWebView).setWebViewClient(any(WebViewClient.class)); + verify(mockMraidWebView).setWebViewClient(any(WebViewClient.class)); verify(mraidBridge).setContentHtml(eq("3:27")); } @@ -124,7 +144,7 @@ public void preRenderHtml_whenWebViewClientShouldOverrideUrlLoading_shouldReturn MraidActivity.preRenderHtml(subject, customEventInterstitialListener, ""); ArgumentCaptor webViewClientArgumentCaptor = ArgumentCaptor.forClass(WebViewClient.class); - verify(mraidWebView).setWebViewClient(webViewClientArgumentCaptor.capture()); + verify(mockMraidWebView).setWebViewClient(webViewClientArgumentCaptor.capture()); WebViewClient webViewClient = webViewClientArgumentCaptor.getValue(); boolean consumeUrlLoading = webViewClient.shouldOverrideUrlLoading(null, null); @@ -141,7 +161,7 @@ public void preRenderHtml_shouldCallCustomEventInterstitialOnInterstitialLoaded_ MraidActivity.preRenderHtml(subject, customEventInterstitialListener, ""); ArgumentCaptor webViewClientArgumentCaptor = ArgumentCaptor.forClass(WebViewClient.class); - verify(mraidWebView).setWebViewClient(webViewClientArgumentCaptor.capture()); + verify(mockMraidWebView).setWebViewClient(webViewClientArgumentCaptor.capture()); WebViewClient webViewClient = webViewClientArgumentCaptor.getValue(); webViewClient.onPageFinished(null, null); @@ -162,7 +182,7 @@ public void onCreate_shouldSetContentView() throws Exception { public void onCreate_shouldSetupAnMraidView() throws Exception { subject.onCreate(null); - assertThat(getContentView().getChildAt(0)).isSameAs(mraidWebView); + assertThat(getContentView().getChildAt(0)).isSameAs(mockMraidWebView); verify(mraidController).setMraidListener(any(MraidListener.class)); verify(mraidBridge).setContentHtml(EXPECTED_SOURCE); @@ -175,7 +195,7 @@ public void onCreate_shouldSetLayoutOfMraidView() throws Exception { ArgumentCaptor captor = ArgumentCaptor.forClass( FrameLayout.LayoutParams.class); - verify(mraidWebView).setLayoutParams(captor.capture()); + verify(mockMraidWebView).setLayoutParams(captor.capture()); FrameLayout.LayoutParams actualLayoutParams = captor.getValue(); assertThat(actualLayoutParams.width).isEqualTo(FrameLayout.LayoutParams.MATCH_PARENT); @@ -213,18 +233,18 @@ public void onDestroy_DestroyMraidView() throws Exception { subject.onDestroy(); verify(broadcastReceiver).onReceive(any(Context.class), eq(expectedIntent)); - verify(mraidWebView).destroy(); + verify(mockMraidWebView).destroy(); assertThat(getContentView().getChildCount()).isEqualTo(0); } @Ignore("Mraid 2.0") @Test public void getAdView_shouldSetupOnReadyListener() throws Exception { - reset(mraidWebView); + reset(mockMraidWebView); ArgumentCaptor captor = ArgumentCaptor.forClass(MraidListener.class); View actualAdView = subject.getAdView(); - assertThat(actualAdView).isSameAs(mraidWebView); + assertThat(actualAdView).isSameAs(mockMraidWebView); verify(mraidController).setMraidListener(captor.capture()); subject.hideInterstitialCloseButton(); @@ -234,33 +254,33 @@ public void getAdView_shouldSetupOnReadyListener() throws Exception { @Ignore("Mraid 2.0") @Test public void baseMraidListenerOnReady_shouldFireJavascriptWebViewDidAppear() throws Exception { - reset(mraidWebView); + reset(mockMraidWebView); ArgumentCaptor captor = ArgumentCaptor.forClass(MraidListener.class); View actualAdView = subject.getAdView(); - assertThat(actualAdView).isSameAs(mraidWebView); + assertThat(actualAdView).isSameAs(mockMraidWebView); verify(mraidController).setMraidListener(captor.capture()); MraidListener baseMraidListener = captor.getValue(); baseMraidListener.onLoaded(null); - verify(mraidWebView).loadUrl(eq("javascript:webviewDidAppear();")); + verify(mockMraidWebView).loadUrl(eq("javascript:webviewDidAppear();")); } @Ignore("Mraid 2.0") @Test public void baseMraidListenerOnClose_shouldFireJavascriptWebViewDidClose() throws Exception { - reset(mraidWebView); + reset(mockMraidWebView); ArgumentCaptor captor = ArgumentCaptor.forClass(MraidListener.class); View actualAdView = subject.getAdView(); - assertThat(actualAdView).isSameAs(mraidWebView); + assertThat(actualAdView).isSameAs(mockMraidWebView); verify(mraidController).setMraidListener(captor.capture()); MraidListener baseMraidListener = captor.getValue(); baseMraidListener.onClose(); - verify(mraidWebView).loadUrl(eq("javascript:webviewDidClose();")); + verify(mockMraidWebView).loadUrl(eq("javascript:webviewDidClose();")); } @Ignore("Mraid 2.0") @@ -271,12 +291,12 @@ public void baseMraidListenerOnOpen_shouldBroadcastClickEvent() throws Exception new EventForwardingBroadcastReceiver(customEventInterstitialListener, testBroadcastIdentifier).getIntentFilter()); - reset(mraidWebView); + reset(mockMraidWebView); ArgumentCaptor captor = ArgumentCaptor.forClass(MraidListener.class); View actualAdView = subject.getAdView(); - assertThat(actualAdView).isSameAs(mraidWebView); + assertThat(actualAdView).isSameAs(mockMraidWebView); verify(mraidController).setMraidListener(captor.capture()); MraidListener baseMraidListener = captor.getValue(); @@ -288,11 +308,11 @@ public void baseMraidListenerOnOpen_shouldBroadcastClickEvent() throws Exception @Ignore("Mraid 2.0") @Test public void getAdView_shouldSetupOnCloseListener() throws Exception { - reset(mraidWebView); + reset(mockMraidWebView); ArgumentCaptor captor = ArgumentCaptor.forClass(MraidListener.class); View actualAdView = subject.getAdView(); - assertThat(actualAdView).isSameAs(mraidWebView); + assertThat(actualAdView).isSameAs(mockMraidWebView); verify(mraidController).setMraidListener(captor.capture()); captor.getValue().onClose(); @@ -305,7 +325,7 @@ public void getAdView_shouldSetupOnCloseListener() throws Exception { public void onPause_shouldOnPauseMraidView() throws Exception { activityController.pause(); - verify(mraidWebView).onPause(); + verify(mockMraidWebView).onPause(); } @Ignore("Mraid 2.0") @@ -314,7 +334,7 @@ public void onResume_shouldResumeMraidView() throws Exception { subject.onCreate(null); Shadows.shadowOf(subject).pauseAndThenResume(); - verify(mraidWebView).onResume(); + verify(mockMraidWebView).onResume(); } private Intent createMraidActivityIntent(String expectedSource) {