Search in sources :

Example 1 with InLine

use of org.prebid.mobile.rendering.video.vast.InLine in project prebid-mobile-android by prebid.

the class AdResponseParserVastTest method testGetCompanionAd.

@Test
public void testGetCompanionAd() {
    InLine mockInLine;
    ArrayList<Companion> companions;
    Companion mockCompanionA;
    Companion mockCompanionB;
    Companion result;
    // Null creatives
    mockInLine = setupInLine();
    mockInLine.setCreatives(null);
    result = AdResponseParserVast.getCompanionAd(mockInLine);
    assertNull(result);
    // Empty creatives list
    mockInLine = setupInLine();
    mockInLine.setCreatives(new ArrayList<>());
    result = AdResponseParserVast.getCompanionAd(mockInLine);
    assertNull(result);
    // Empty companion ad list
    mockInLine = setupInLine();
    mockInLine.getCreatives().get(0).setCompanionAds(new ArrayList<>());
    result = AdResponseParserVast.getCompanionAd(mockInLine);
    assertNull(result);
    // One companion
    mockInLine = setupInLine();
    companions = mockInLine.getCreatives().get(0).getCompanionAds();
    mockCompanionA = mock(Companion.class);
    companions.add(mockCompanionA);
    result = AdResponseParserVast.getCompanionAd(mockInLine);
    assertEquals(mockCompanionA, result);
    // Companion B format better than Companion A format
    mockInLine = setupInLine();
    companions = mockInLine.getCreatives().get(0).getCompanionAds();
    mockCompanionA = mock(Companion.class);
    when(mockCompanionA.getWidth()).thenReturn("2");
    when(mockCompanionA.getHeight()).thenReturn("2");
    when(mockCompanionA.getStaticResource()).thenReturn(mock(StaticResource.class));
    companions.add(mockCompanionA);
    mockCompanionB = mock(Companion.class);
    when(mockCompanionB.getWidth()).thenReturn("1");
    when(mockCompanionB.getHeight()).thenReturn("1");
    when(mockCompanionB.getHtmlResource()).thenReturn(mock(HTMLResource.class));
    companions.add(mockCompanionB);
    result = AdResponseParserVast.getCompanionAd(mockInLine);
    assertEquals(mockCompanionB, result);
    // Same format for Companion A & B, but B has better resolution
    mockInLine = setupInLine();
    companions = mockInLine.getCreatives().get(0).getCompanionAds();
    mockCompanionA = mock(Companion.class);
    when(mockCompanionA.getWidth()).thenReturn("1");
    when(mockCompanionA.getHeight()).thenReturn("1");
    when(mockCompanionA.getStaticResource()).thenReturn(mock(StaticResource.class));
    companions.add(mockCompanionA);
    mockCompanionB = mock(Companion.class);
    when(mockCompanionB.getWidth()).thenReturn("2");
    when(mockCompanionB.getHeight()).thenReturn("2");
    when(mockCompanionB.getStaticResource()).thenReturn(mock(StaticResource.class));
    companions.add(mockCompanionB);
    result = AdResponseParserVast.getCompanionAd(mockInLine);
    assertEquals(mockCompanionB, result);
}
Also used : Companion(org.prebid.mobile.rendering.video.vast.Companion) HTMLResource(org.prebid.mobile.rendering.video.vast.HTMLResource) StaticResource(org.prebid.mobile.rendering.video.vast.StaticResource) InLine(org.prebid.mobile.rendering.video.vast.InLine) Test(org.junit.Test)

Example 2 with InLine

use of org.prebid.mobile.rendering.video.vast.InLine in project prebid-mobile-android by prebid.

the class AdResponseParserVastTest method setupInLine.

private InLine setupInLine() {
    InLine mockInLine = mock(InLine.class);
    mockInLine.setCreatives(new ArrayList<>());
    Creative mockCreative = mock(Creative.class);
    when(mockCreative.getCompanionAds()).thenReturn(new ArrayList<>());
    ArrayList<Creative> creatives = new ArrayList<>();
    creatives.add(mockCreative);
    when(mockInLine.getCreatives()).thenReturn(creatives);
    return mockInLine;
}
Also used : Creative(org.prebid.mobile.rendering.video.vast.Creative) ArrayList(java.util.ArrayList) InLine(org.prebid.mobile.rendering.video.vast.InLine)

Aggregations

InLine (org.prebid.mobile.rendering.video.vast.InLine)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Companion (org.prebid.mobile.rendering.video.vast.Companion)1 Creative (org.prebid.mobile.rendering.video.vast.Creative)1 HTMLResource (org.prebid.mobile.rendering.video.vast.HTMLResource)1 StaticResource (org.prebid.mobile.rendering.video.vast.StaticResource)1