Search in sources :

Example 21 with BidResponse

use of org.prebid.mobile.rendering.bidding.data.bid.BidResponse in project prebid-mobile-android by prebid.

the class BannerViewTest method onPrebidSdkWin_AdRequestStatusIsFinishedDisplayAdView.

@Test
public void onPrebidSdkWin_AdRequestStatusIsFinishedDisplayAdView() {
    changePrimaryAdServerRequestStatus(true);
    final BannerEventListener bannerEventListener = getBannerEventListener();
    final BidResponse mockBidResponse = mock(BidResponse.class);
    final Bid mockBid = mock(Bid.class);
    when(mockBidResponse.getWinningBid()).thenReturn(mockBid);
    when(mockBidResponse.getWinningBidWidthHeightPairDips(any())).thenReturn(Pair.create(0, 0));
    mBannerView.setBidResponse(mockBidResponse);
    bannerEventListener.onPrebidSdkWin();
    assertFalse(mBannerView.isPrimaryAdServerRequestInProgress());
}
Also used : BannerEventListener(org.prebid.mobile.rendering.bidding.listeners.BannerEventListener) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) Test(org.junit.Test)

Example 22 with BidResponse

use of org.prebid.mobile.rendering.bidding.data.bid.BidResponse in project prebid-mobile-android by prebid.

the class BannerViewTest method onFetchComplete_AssignWinningBidMarkPrimaryServerRequestInProgressRequestAdWithBid.

// region ======================= BidRequestListener tests
@Test
public void onFetchComplete_AssignWinningBidMarkPrimaryServerRequestInProgressRequestAdWithBid() {
    final BidResponse mockBidResponse = mock(BidResponse.class);
    final Bid mockBid = mock(Bid.class);
    when(mockBidResponse.getWinningBid()).thenReturn(mockBid);
    BidRequesterListener listener = getBidRequesterListener();
    listener.onFetchCompleted(mockBidResponse);
    Bid winningBid = mBannerView.getWinnerBid();
    BidResponse actualResponse = mBannerView.getBidResponse();
    assertEquals(winningBid, mockBid);
    assertEquals(mockBidResponse, actualResponse);
    verify(mMockEventHandler, times(1)).requestAdWithBid(eq(mockBid));
    assertTrue(mBannerView.isPrimaryAdServerRequestInProgress());
}
Also used : BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) BidRequesterListener(org.prebid.mobile.rendering.bidding.listeners.BidRequesterListener) Test(org.junit.Test)

Example 23 with BidResponse

use of org.prebid.mobile.rendering.bidding.data.bid.BidResponse in project prebid-mobile-android by prebid.

the class InterstitialAdUnitTest method onFailedAndWithWinnerBid_ExecuteInterstitialControllerLoadAd.

@Test
public void onFailedAndWithWinnerBid_ExecuteInterstitialControllerLoadAd() {
    final BidResponse mockBidResponse = mock(BidResponse.class);
    final InterstitialController mockInterstitialController = mock(InterstitialController.class);
    final Bid mockBid = mock(Bid.class);
    final InterstitialEventListener spyEventListener = spy(getEventListener());
    when(mockBidResponse.getWinningBid()).thenReturn(mockBid);
    WhiteBox.setInternalState(mInterstitialAdUnit, "mBidResponse", mockBidResponse);
    WhiteBox.setInternalState(mInterstitialAdUnit, "mInterstitialController", mockInterstitialController);
    spyEventListener.onAdFailed(new AdException(AdException.INTERNAL_ERROR, "Test"));
    verify(spyEventListener, times(1)).onPrebidSdkWin();
    verify(mockInterstitialController, times(1)).loadAd(any(), any());
}
Also used : InterstitialController(org.prebid.mobile.rendering.bidding.display.InterstitialController) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) InterstitialEventListener(org.prebid.mobile.rendering.bidding.listeners.InterstitialEventListener) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Example 24 with BidResponse

use of org.prebid.mobile.rendering.bidding.data.bid.BidResponse in project prebid-mobile-android by prebid.

the class BaseInterstitialAdUnitTest method loadAdWithError_BidResponseIsNull.

@Test
public void loadAdWithError_BidResponseIsNull() {
    BidResponse bidResponse = mBaseInterstitialAdUnit.getBidResponse();
    assertNull(bidResponse);
    final AdException adException = mock(AdException.class);
    BidRequesterListener listener = getBidRequesterListener();
    listener.onError(adException);
    mBaseInterstitialAdUnit.loadAd();
    bidResponse = mBaseInterstitialAdUnit.getBidResponse();
    assertNull(bidResponse);
}
Also used : BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) BidRequesterListener(org.prebid.mobile.rendering.bidding.listeners.BidRequesterListener) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Example 25 with BidResponse

use of org.prebid.mobile.rendering.bidding.data.bid.BidResponse in project prebid-mobile-android by prebid.

the class BaseInterstitialAdUnitTest method loadAd_BidResponseIsInitialized.

@Test
public void loadAd_BidResponseIsInitialized() {
    BidResponse bidResponse = mBaseInterstitialAdUnit.getBidResponse();
    assertNull(bidResponse);
    final BidResponse mockBidResponse = mock(BidResponse.class);
    final Bid mockBid = mock(Bid.class);
    when(mockBidResponse.getWinningBid()).thenReturn(mockBid);
    BidRequesterListener listener = getBidRequesterListener();
    listener.onFetchCompleted(mockBidResponse);
    mBaseInterstitialAdUnit.loadAd();
    BidResponse actualBidResponse = mBaseInterstitialAdUnit.getBidResponse();
    assertEquals(mockBidResponse, actualBidResponse);
}
Also used : BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) BidRequesterListener(org.prebid.mobile.rendering.bidding.listeners.BidRequesterListener) Test(org.junit.Test)

Aggregations

BidResponse (org.prebid.mobile.rendering.bidding.data.bid.BidResponse)30 Test (org.junit.Test)26 Bid (org.prebid.mobile.rendering.bidding.data.bid.Bid)12 AdException (org.prebid.mobile.rendering.errors.AdException)7 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)7 BidRequesterListener (org.prebid.mobile.rendering.bidding.listeners.BidRequesterListener)6 MoPubBannerMediationUtils (com.mopub.mediation.MoPubBannerMediationUtils)2 HashMap (java.util.HashMap)2 InterstitialController (org.prebid.mobile.rendering.bidding.display.InterstitialController)2 BannerEventListener (org.prebid.mobile.rendering.bidding.listeners.BannerEventListener)2 OnFetchCompleteListener (org.prebid.mobile.rendering.bidding.listeners.OnFetchCompleteListener)2 Activity (android.app.Activity)1 Nullable (androidx.annotation.Nullable)1 AdError (com.google.android.gms.ads.AdError)1 MoPubRewardedVideoMediationUtils (com.mopub.mediation.MoPubRewardedVideoMediationUtils)1 MoPubView (com.mopub.mobileads.MoPubView)1 Before (org.junit.Before)1 OpenMediationBaseAdUnit (org.prebid.mobile.mopub.mock.OpenMediationBaseAdUnit)1 OpenMediationRewardedVideoAdUnit (org.prebid.mobile.mopub.mock.OpenMediationRewardedVideoAdUnit)1 DisplayView (org.prebid.mobile.rendering.bidding.display.DisplayView)1