MoPubView extends FrameLayout { @Override protected void onWindowVisibilityChanged(final int visibility) { if (Visibility.hasScreenVisibilityChanged(mScreenVisibility, visibility)) { mScreenVisibility = visibility; setAdVisibility(mScreenVisibility); } } MoPubView(Context context);  MoPubView(Context context, AttributeSet attrs); void loadAd(); void destroy(); void setAdUnitId(String adUnitId); String getAdUnitId(); void setKeywords(String keywords); String getKeywords(); void setLocation(Location location); Location getLocation(); void setTimeout(int milliseconds); int getAdWidth(); int getAdHeight(); String getResponseString(); @Deprecated void setClickthroughUrl(String url); String getClickTrackingUrl(); @Deprecated String getClickthroughUrl(); Activity getActivity(); void setBannerAdListener(BannerAdListener listener); BannerAdListener getBannerAdListener(); void setLocalExtras(Map<String, Object> localExtras); Map<String, Object> getLocalExtras(); void setAutorefreshEnabled(boolean enabled); boolean getAutorefreshEnabled(); void setAdContentView(View view); void setTesting(boolean testing); boolean getTesting(); void forceRefresh(); AdFormat getAdFormat(); @Deprecated void setLocationAwareness(LocationAwareness locationAwareness); @Deprecated LocationAwareness getLocationAwareness(); @Deprecated void setLocationPrecision(int precision); @Deprecated int getLocationPrecision(); @Deprecated void setOnAdWillLoadListener(OnAdWillLoadListener listener); @Deprecated void setOnAdLoadedListener(OnAdLoadedListener listener); @Deprecated void setOnAdFailedListener(OnAdFailedListener listener); @Deprecated void setOnAdPresentedOverlayListener(OnAdPresentedOverlayListener listener); @Deprecated void setOnAdClosedListener(OnAdClosedListener listener); @Deprecated void setOnAdClickedListener(OnAdClickedListener listener); @Deprecated void customEventDidLoadAd(); @Deprecated void customEventDidFailToLoadAd(); @Deprecated void customEventActionWillBegin(); @Deprecated void setFacebookSupported(boolean enabled); @Deprecated boolean isFacebookSupported(); static final int DEFAULT_LOCATION_PRECISION; }
@Test public void screenStateBroadcastReceiver_whenAdInBackground_shouldDoNothing() throws Exception { subject.onWindowVisibilityChanged(View.INVISIBLE); reset(adViewController); broadcastIntent(new Intent(Intent.ACTION_USER_PRESENT)); verify(adViewController, never()).unpauseRefresh(); broadcastIntent(new Intent(Intent.ACTION_SCREEN_OFF)); verify(adViewController, never()).pauseRefresh(); }
@Test public void onWindowVisibilityChanged_fromVisibleToInvisible_shouldPauseRefresh() throws Exception { subject.onWindowVisibilityChanged(View.INVISIBLE); verify(adViewController).pauseRefresh(); verify(adViewController, never()).unpauseRefresh(); }
@Test public void onWindowVisibilityChanged_fromInvisibleToVisible_shouldUnpauseRefresh() throws Exception { subject.onWindowVisibilityChanged(View.INVISIBLE); reset(adViewController); subject.onWindowVisibilityChanged(View.VISIBLE); verify(adViewController, never()).pauseRefresh(); verify(adViewController).unpauseRefresh(); }
@Test public void onWindowVisibilityChanged_fromVisibleToVisible_shouldDoNothing() throws Exception { subject.onWindowVisibilityChanged(View.VISIBLE); verify(adViewController, never()).pauseRefresh(); verify(adViewController, never()).unpauseRefresh(); }
@Test public void onWindowVisibilityChanged_fromInvisibleToGone_shouldDoNothing() throws Exception { subject.onWindowVisibilityChanged(View.INVISIBLE); reset(adViewController); subject.onWindowVisibilityChanged(View.GONE); verify(adViewController, never()).pauseRefresh(); verify(adViewController, never()).unpauseRefresh(); }
@Test public void onWindowVisibilityChanged_fromGoneToInvisible_shouldDoNothing() throws Exception { subject.onWindowVisibilityChanged(View.GONE); reset(adViewController); subject.onWindowVisibilityChanged(View.INVISIBLE); verify(adViewController, never()).pauseRefresh(); verify(adViewController, never()).unpauseRefresh(); }