@Test public void isNativeAdViewValid_negative7() { FrameLayout container = new FrameLayout(context); NativeMediaView nativeMediaView = new NativeMediaView(context); container.addView(nativeMediaView); Button callToAction = new Button(context); Set<View> clickableViews = new HashSet<>(); clickableViews.add(callToAction); boolean result = nativeAdObject.isNativeAdViewValid( container, null, nativeMediaView, clickableViews); assertFalse(result); }
@VisibleForTesting boolean isNativeAdViewValid(@Nullable ViewGroup nativeAdView, @Nullable View imageView, @Nullable NativeMediaView nativeMediaView, @Nullable Set<View> clickableViews) { if (nativeAdView == null) { Logger.log("NativeAdView cannot be null. NativeAd is NOT registered"); return false; } if (imageView == null && nativeMediaView == null) { Logger.log("ImageView or NativeMediaView cannot be null. NativeAd is NOT registered"); return false; } else { if (imageView != null && !ViewHelper.belongTo(nativeAdView, imageView)) { Logger.log("ImageView should belong to NativeAdView. NativeAd is NOT registered"); return false; } if (nativeMediaView != null && !ViewHelper.belongTo(nativeAdView, nativeMediaView)) { Logger.log("NativeMediaView should belong to NativeAdView. NativeAd is NOT registered"); return false; } } if (clickableViews != null) { for (View view : clickableViews) { if (view != null && !ViewHelper.belongTo(nativeAdView, view)) { Logger.log( "All clickable views should belong to NativeAdView. NativeAd is NOT registered"); return false; } } } return true; }
NativeAdObject extends AdObjectImpl<NativeRequest, AdObjectParams, UnifiedNativeAd, UnifiedNativeAdCallback, UnifiedNativeAdRequestParams> implements NativeData, NativeMediaPrivateData, NativeContainer, NativeInteractor, View.OnClickListener { @VisibleForTesting boolean isNativeAdViewValid(@Nullable ViewGroup nativeAdView, @Nullable View imageView, @Nullable NativeMediaView nativeMediaView, @Nullable Set<View> clickableViews) { if (nativeAdView == null) { Logger.log("NativeAdView cannot be null. NativeAd is NOT registered"); return false; } if (imageView == null && nativeMediaView == null) { Logger.log("ImageView or NativeMediaView cannot be null. NativeAd is NOT registered"); return false; } else { if (imageView != null && !ViewHelper.belongTo(nativeAdView, imageView)) { Logger.log("ImageView should belong to NativeAdView. NativeAd is NOT registered"); return false; } if (nativeMediaView != null && !ViewHelper.belongTo(nativeAdView, nativeMediaView)) { Logger.log("NativeMediaView should belong to NativeAdView. NativeAd is NOT registered"); return false; } } if (clickableViews != null) { for (View view : clickableViews) { if (view != null && !ViewHelper.belongTo(nativeAdView, view)) { Logger.log( "All clickable views should belong to NativeAdView. NativeAd is NOT registered"); return false; } } } return true; } }
NativeAdObject extends AdObjectImpl<NativeRequest, AdObjectParams, UnifiedNativeAd, UnifiedNativeAdCallback, UnifiedNativeAdRequestParams> implements NativeData, NativeMediaPrivateData, NativeContainer, NativeInteractor, View.OnClickListener { @VisibleForTesting boolean isNativeAdViewValid(@Nullable ViewGroup nativeAdView, @Nullable View imageView, @Nullable NativeMediaView nativeMediaView, @Nullable Set<View> clickableViews) { if (nativeAdView == null) { Logger.log("NativeAdView cannot be null. NativeAd is NOT registered"); return false; } if (imageView == null && nativeMediaView == null) { Logger.log("ImageView or NativeMediaView cannot be null. NativeAd is NOT registered"); return false; } else { if (imageView != null && !ViewHelper.belongTo(nativeAdView, imageView)) { Logger.log("ImageView should belong to NativeAdView. NativeAd is NOT registered"); return false; } if (nativeMediaView != null && !ViewHelper.belongTo(nativeAdView, nativeMediaView)) { Logger.log("NativeMediaView should belong to NativeAdView. NativeAd is NOT registered"); return false; } } if (clickableViews != null) { for (View view : clickableViews) { if (view != null && !ViewHelper.belongTo(nativeAdView, view)) { Logger.log( "All clickable views should belong to NativeAdView. NativeAd is NOT registered"); return false; } } } return true; } NativeAdObject(@NonNull ContextProvider contextProvider,
                   @NonNull AdProcessCallback processCallback,
                   @NonNull NativeRequest adRequest,
                   @NonNull AdObjectParams adObjectParams,
                   @NonNull UnifiedNativeAd unifiedAd); }
NativeAdObject extends AdObjectImpl<NativeRequest, AdObjectParams, UnifiedNativeAd, UnifiedNativeAdCallback, UnifiedNativeAdRequestParams> implements NativeData, NativeMediaPrivateData, NativeContainer, NativeInteractor, View.OnClickListener { @VisibleForTesting boolean isNativeAdViewValid(@Nullable ViewGroup nativeAdView, @Nullable View imageView, @Nullable NativeMediaView nativeMediaView, @Nullable Set<View> clickableViews) { if (nativeAdView == null) { Logger.log("NativeAdView cannot be null. NativeAd is NOT registered"); return false; } if (imageView == null && nativeMediaView == null) { Logger.log("ImageView or NativeMediaView cannot be null. NativeAd is NOT registered"); return false; } else { if (imageView != null && !ViewHelper.belongTo(nativeAdView, imageView)) { Logger.log("ImageView should belong to NativeAdView. NativeAd is NOT registered"); return false; } if (nativeMediaView != null && !ViewHelper.belongTo(nativeAdView, nativeMediaView)) { Logger.log("NativeMediaView should belong to NativeAdView. NativeAd is NOT registered"); return false; } } if (clickableViews != null) { for (View view : clickableViews) { if (view != null && !ViewHelper.belongTo(nativeAdView, view)) { Logger.log( "All clickable views should belong to NativeAdView. NativeAd is NOT registered"); return false; } } } return true; } NativeAdObject(@NonNull ContextProvider contextProvider,
                   @NonNull AdProcessCallback processCallback,
                   @NonNull NativeRequest adRequest,
                   @NonNull AdObjectParams adObjectParams,
                   @NonNull UnifiedNativeAd unifiedAd); @Nullable @Override String getTitle(); @Nullable @Override String getDescription(); @Nullable @Override String getCallToAction(); @Override float getRating(); @Nullable @Override String getIconUrl(); @Nullable @Override String getImageUrl(); @Nullable @Override String getClickUrl(); @Nullable @Override String getVideoUrl(); @Nullable @Override String getVideoAdm(); @Override void setIconBitmap(@Nullable Bitmap iconBitmap); @Override void setIconUri(@Nullable Uri iconUri); @Override @Nullable Uri getIconUri(); @Nullable @Override Bitmap getIconBitmap(); @Override void setImageUri(@Nullable Uri imageUri); @Override @Nullable Uri getImageUri(); @Override void setImageBitmap(@Nullable Bitmap imageBitmap); @Nullable @Override Bitmap getImageBitmap(); @Override void setVideoUri(@Nullable Uri videoUri); @Nullable @Override Uri getVideoUri(); @Override void setVastRequest(@Nullable VastRequest vastRequest); @Override @Nullable VastRequest getVastRequest(); @Override boolean hasVideo(); @NonNull @Override UnifiedNativeAdCallback createUnifiedCallback(@NonNull AdProcessCallback processCallback); @Nullable @Override View getProviderView(Context context); @Override void registerView(@Nullable ViewGroup nativeAdView,
                             @Nullable View imageView,
                             @Nullable NativeMediaView nativeMediaView,
                             @Nullable Set<View> clickableViews); @Override void unregisterView(); @Override void onDestroy(); @Override boolean isViewRegistered(); @Override void dispatchShown(); @Override void onClick(View view); @Override void onClicked(); @Override void dispatchClick(); @Override void dispatchImpression(); @Override void dispatchVideoPlayFinished(); }
NativeAdObject extends AdObjectImpl<NativeRequest, AdObjectParams, UnifiedNativeAd, UnifiedNativeAdCallback, UnifiedNativeAdRequestParams> implements NativeData, NativeMediaPrivateData, NativeContainer, NativeInteractor, View.OnClickListener { @VisibleForTesting boolean isNativeAdViewValid(@Nullable ViewGroup nativeAdView, @Nullable View imageView, @Nullable NativeMediaView nativeMediaView, @Nullable Set<View> clickableViews) { if (nativeAdView == null) { Logger.log("NativeAdView cannot be null. NativeAd is NOT registered"); return false; } if (imageView == null && nativeMediaView == null) { Logger.log("ImageView or NativeMediaView cannot be null. NativeAd is NOT registered"); return false; } else { if (imageView != null && !ViewHelper.belongTo(nativeAdView, imageView)) { Logger.log("ImageView should belong to NativeAdView. NativeAd is NOT registered"); return false; } if (nativeMediaView != null && !ViewHelper.belongTo(nativeAdView, nativeMediaView)) { Logger.log("NativeMediaView should belong to NativeAdView. NativeAd is NOT registered"); return false; } } if (clickableViews != null) { for (View view : clickableViews) { if (view != null && !ViewHelper.belongTo(nativeAdView, view)) { Logger.log( "All clickable views should belong to NativeAdView. NativeAd is NOT registered"); return false; } } } return true; } NativeAdObject(@NonNull ContextProvider contextProvider,
                   @NonNull AdProcessCallback processCallback,
                   @NonNull NativeRequest adRequest,
                   @NonNull AdObjectParams adObjectParams,
                   @NonNull UnifiedNativeAd unifiedAd); @Nullable @Override String getTitle(); @Nullable @Override String getDescription(); @Nullable @Override String getCallToAction(); @Override float getRating(); @Nullable @Override String getIconUrl(); @Nullable @Override String getImageUrl(); @Nullable @Override String getClickUrl(); @Nullable @Override String getVideoUrl(); @Nullable @Override String getVideoAdm(); @Override void setIconBitmap(@Nullable Bitmap iconBitmap); @Override void setIconUri(@Nullable Uri iconUri); @Override @Nullable Uri getIconUri(); @Nullable @Override Bitmap getIconBitmap(); @Override void setImageUri(@Nullable Uri imageUri); @Override @Nullable Uri getImageUri(); @Override void setImageBitmap(@Nullable Bitmap imageBitmap); @Nullable @Override Bitmap getImageBitmap(); @Override void setVideoUri(@Nullable Uri videoUri); @Nullable @Override Uri getVideoUri(); @Override void setVastRequest(@Nullable VastRequest vastRequest); @Override @Nullable VastRequest getVastRequest(); @Override boolean hasVideo(); @NonNull @Override UnifiedNativeAdCallback createUnifiedCallback(@NonNull AdProcessCallback processCallback); @Nullable @Override View getProviderView(Context context); @Override void registerView(@Nullable ViewGroup nativeAdView,
                             @Nullable View imageView,
                             @Nullable NativeMediaView nativeMediaView,
                             @Nullable Set<View> clickableViews); @Override void unregisterView(); @Override void onDestroy(); @Override boolean isViewRegistered(); @Override void dispatchShown(); @Override void onClick(View view); @Override void onClicked(); @Override void dispatchClick(); @Override void dispatchImpression(); @Override void dispatchVideoPlayFinished();  }