Search in sources :

Example 11 with Bid

use of org.prebid.mobile.rendering.bidding.data.bid.Bid 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 12 with Bid

use of org.prebid.mobile.rendering.bidding.data.bid.Bid 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 13 with Bid

use of org.prebid.mobile.rendering.bidding.data.bid.Bid 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 14 with Bid

use of org.prebid.mobile.rendering.bidding.data.bid.Bid 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)

Example 15 with Bid

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

the class DisplayViewTest method setup.

@Before
public void setup() throws Exception {
    MockitoAnnotations.initMocks(DisplayViewTest.this);
    mContext = Robolectric.buildActivity(Activity.class).create().get();
    mAdUnitConfiguration = new AdConfiguration();
    mAdUnitConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    BidResponse mockResponse = mock(BidResponse.class);
    Bid mockBid = mock(Bid.class);
    when(mockBid.getAdm()).thenReturn("adm");
    when(mockResponse.getWinningBid()).thenReturn(mockBid);
    mDisplayView = new DisplayView(mContext, mMockDisplayViewListener, mAdUnitConfiguration, mockResponse);
    reset(mMockDisplayViewListener);
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) Activity(android.app.Activity) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) Before(org.junit.Before)

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