Search in sources :

Example 6 with Bid

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

the class BannerViewTest method onFailedAndWithWinnerBid_AdRequestStatusIsFinishedNotifyPrebidSdkWin.

@Test
public void onFailedAndWithWinnerBid_AdRequestStatusIsFinishedNotifyPrebidSdkWin() {
    changePrimaryAdServerRequestStatus(true);
    final BidResponse mockBidResponse = mock(BidResponse.class);
    final Bid mockBid = mock(Bid.class);
    final BannerEventListener spyEventListener = spy(getBannerEventListener());
    when(mockBidResponse.getWinningBid()).thenReturn(mockBid);
    when(mockBidResponse.getWinningBidWidthHeightPairDips(any())).thenReturn(Pair.create(0, 0));
    mBannerView.setBidResponse(mockBidResponse);
    spyEventListener.onAdFailed(new AdException(AdException.INTERNAL_ERROR, "Test"));
    assertFalse(mBannerView.isPrimaryAdServerRequestInProgress());
    verify(spyEventListener, times(1)).onPrebidSdkWin();
}
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) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Example 7 with Bid

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

the class InterstitialAdUnitTest method onFetchComplete_ChangeInterstitialStateToLoadingAndRequestAdWithBid.

// region ======================= BidRequestListener tests
@Test
public void onFetchComplete_ChangeInterstitialStateToLoadingAndRequestAdWithBid() {
    final BidResponse mockBidResponse = mock(BidResponse.class);
    final Bid mockBid = mock(Bid.class);
    when(mockBidResponse.getWinningBid()).thenReturn(mockBid);
    BidRequesterListener listener = getBidRequesterListener();
    listener.onFetchCompleted(mockBidResponse);
    verify(mMockInterstitialEventHandler, times(1)).requestAdWithBid(eq(mockBid));
    assertEquals(LOADING, mInterstitialAdUnit.getAdUnitState());
}
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 8 with Bid

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

the class GamInterstitialEventHandlerTest method requestAdWithDifferentBids_VerifyAdStatus.

@Test
public void requestAdWithDifferentBids_VerifyAdStatus() {
    final Bid mockBid = mock(Bid.class);
    final Prebid mockPrebid = mock(Prebid.class);
    when(mockPrebid.getTargeting()).thenReturn(new HashMap<>());
    when(mockBid.getPrebid()).thenReturn(mockPrebid);
    when(mockBid.getPrice()).thenReturn(0.2);
    mEventHandler.requestAdWithBid(mockBid);
    assertTrue(getExpectingAppEventStatus());
    when(mockBid.getPrice()).thenReturn(0.0);
    mEventHandler.requestAdWithBid(mockBid);
    assertFalse(getExpectingAppEventStatus());
    mEventHandler.requestAdWithBid(null);
    assertFalse(getExpectingAppEventStatus());
}
Also used : Prebid(org.prebid.mobile.rendering.bidding.data.bid.Prebid) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) Test(org.junit.Test)

Example 9 with Bid

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

the class GamRewardedEventHandlerTest method requestAdWithDifferentBids_VerifyAdStatus.

@Test
public void requestAdWithDifferentBids_VerifyAdStatus() {
    final Bid mockBid = mock(Bid.class);
    final Prebid mockPrebid = mock(Prebid.class);
    when(mockPrebid.getTargeting()).thenReturn(new HashMap<>());
    when(mockBid.getPrebid()).thenReturn(mockPrebid);
    when(mockBid.getPrice()).thenReturn(0.2);
    mEventHandler.requestAdWithBid(mockBid);
    assertTrue(getExpectingAppEventStatus());
    when(mockBid.getPrice()).thenReturn(0.0);
    mEventHandler.requestAdWithBid(mockBid);
    assertFalse(getExpectingAppEventStatus());
    mEventHandler.requestAdWithBid(null);
    assertFalse(getExpectingAppEventStatus());
}
Also used : Prebid(org.prebid.mobile.rendering.bidding.data.bid.Prebid) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) Test(org.junit.Test)

Example 10 with Bid

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

the class BannerViewTest method onError_NullifyWinnerBidAndRequestAdWitNullBid.

@Test
public void onError_NullifyWinnerBidAndRequestAdWitNullBid() {
    final BidResponse mockBidResponse = mock(BidResponse.class);
    final Bid mockBid = mock(Bid.class);
    when(mockBidResponse.getWinningBid()).thenReturn(mockBid);
    mBannerView.setBidResponse(mockBidResponse);
    BidRequesterListener listener = getBidRequesterListener();
    listener.onError(any());
    assertNull(mBannerView.getWinnerBid());
    assertNull(mBannerView.getBidResponse());
    verify(mMockEventHandler, times(1)).requestAdWithBid(eq(null));
}
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

Bid (org.prebid.mobile.rendering.bidding.data.bid.Bid)17 Test (org.junit.Test)14 BidResponse (org.prebid.mobile.rendering.bidding.data.bid.BidResponse)11 BidRequesterListener (org.prebid.mobile.rendering.bidding.listeners.BidRequesterListener)5 AdException (org.prebid.mobile.rendering.errors.AdException)4 Prebid (org.prebid.mobile.rendering.bidding.data.bid.Prebid)3 Before (org.junit.Before)2 InterstitialController (org.prebid.mobile.rendering.bidding.display.InterstitialController)2 BannerEventListener (org.prebid.mobile.rendering.bidding.listeners.BannerEventListener)2 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)2 Activity (android.app.Activity)1 Context (android.content.Context)1 HashMap (java.util.HashMap)1 JSONObject (org.json.JSONObject)1 InterstitialEventListener (org.prebid.mobile.rendering.bidding.listeners.InterstitialEventListener)1 RewardedVideoEventListener (org.prebid.mobile.rendering.bidding.listeners.RewardedVideoEventListener)1 MacrosModel (org.prebid.mobile.rendering.models.internal.MacrosModel)1 VastExtractorResult (org.prebid.mobile.rendering.models.internal.VastExtractorResult)1 OmEventTracker (org.prebid.mobile.rendering.video.OmEventTracker)1