Search in sources :

Example 1 with Bid

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

the class GamBannerEventHandlerTest 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);
    mBannerEventHandler.requestAdWithBid(mockBid);
    assertTrue(getExpectingAppEventStatus());
    when(mockBid.getPrice()).thenReturn(0.0);
    mBannerEventHandler.requestAdWithBid(mockBid);
    assertFalse(getExpectingAppEventStatus());
    mBannerEventHandler.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 2 with Bid

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

the class CreativeModelMakerBidsTest method whenMakeModelsAndBidRequestContainsAcjAd_CreateAcjModel.

@Test
public void whenMakeModelsAndBidRequestContainsAcjAd_CreateAcjModel() throws IOException {
    AdConfiguration configuration = new AdConfiguration();
    configuration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
    String responseString = ResourceUtils.convertResourceToString("bidding_response_obj.json");
    BidResponse bidResponse = new BidResponse(responseString);
    ArgumentCaptor<CreativeModelsMaker.Result> resultArgumentCaptor = ArgumentCaptor.forClass(CreativeModelsMaker.Result.class);
    mModelMakerBids.makeModels(configuration, bidResponse);
    verify(mMockLoadListener).onCreativeModelReady(resultArgumentCaptor.capture());
    CreativeModel creativeModel = resultArgumentCaptor.getValue().creativeModels.get(0);
    Bid bid = bidResponse.getSeatbids().get(0).getBids().get(0);
    assertEquals("HTML", creativeModel.getName());
    assertEquals(bid.getAdm(), creativeModel.getHtml());
    assertEquals(bid.getWidth(), creativeModel.getWidth());
    assertEquals(bid.getHeight(), creativeModel.getHeight());
    assertFalse(creativeModel.isRequireImpressionUrl());
}
Also used : BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) Test(org.junit.Test)

Example 3 with Bid

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

the class BaseInterstitialAdUnitTest method setUp.

@Before
public void setUp() throws Exception {
    Context context = Robolectric.buildActivity(Activity.class).create().get();
    mBaseInterstitialAdUnit = new BaseInterstitialAdUnit(context) {

        @Override
        void requestAdWithBid(@Nullable Bid bid) {
        }

        @Override
        void showGamAd() {
        }

        @Override
        void notifyAdEventListener(AdListenerEvent adListenerEvent) {
        }

        @Override
        void notifyErrorListener(AdException exception) {
        }
    };
    final AdConfiguration adUnitConfiguration = new AdConfiguration();
    mBaseInterstitialAdUnit.init(adUnitConfiguration);
    assertEquals(AdPosition.FULLSCREEN.getValue(), adUnitConfiguration.getAdPositionValue());
}
Also used : Context(android.content.Context) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) Bid(org.prebid.mobile.rendering.bidding.data.bid.Bid) AdException(org.prebid.mobile.rendering.errors.AdException) Before(org.junit.Before)

Example 4 with Bid

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

the class RewardedAdUnitTest method onFailedAndWithWinnerBid_ExecuteInterstitialControllerLoadAd.

@Test
public void onFailedAndWithWinnerBid_ExecuteInterstitialControllerLoadAd() throws IllegalAccessException {
    final BidResponse mockBidResponse = mock(BidResponse.class);
    final InterstitialController mockInterstitialController = mock(InterstitialController.class);
    final Bid mockBid = mock(Bid.class);
    final RewardedVideoEventListener spyEventListener = spy(getEventListener());
    when(mockBidResponse.getWinningBid()).thenReturn(mockBid);
    WhiteBox.setInternalState(mRewardedAdUnit, "mBidResponse", mockBidResponse);
    WhiteBox.setInternalState(mRewardedAdUnit, "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) RewardedVideoEventListener(org.prebid.mobile.rendering.bidding.listeners.RewardedVideoEventListener) AdException(org.prebid.mobile.rendering.errors.AdException) Test(org.junit.Test)

Example 5 with Bid

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

the class RewardedAdUnitTest 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(mMockRewardedEventHandler, times(1)).requestAdWithBid(eq(mockBid));
    assertEquals(LOADING, mRewardedAdUnit.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)

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