use of org.prebid.mobile.rendering.views.interstitial.InterstitialManager in project prebid-mobile-android by prebid.
the class AdBrowserActivityTest method browserControlsTest.
@Test
public void browserControlsTest() throws IllegalAccessException {
WebView mockWebView = mock(WebView.class);
when(mockWebView.getUrl()).thenReturn("url");
when(mockWebView.canGoForward()).thenReturn(true);
when(mockWebView.canGoBack()).thenReturn(true);
InterstitialManager mockManager = mock(InterstitialManager.class);
when(mockManager.getInterstitialDisplayDelegate()).thenReturn(null);
WhiteBox.field(AdBrowserActivity.class, "mShouldFireEvents").set(mAdBrowserActivity, true);
WhiteBox.field(AdBrowserActivity.class, "mWebView").set(mAdBrowserActivity, mockWebView);
BrowserControlsEventsListener eventsListener = ((BrowserControls) WhiteBox.field(AdBrowserActivity.class, "mBrowserControls").get(mAdBrowserActivity)).getBrowserControlsEventsListener();
eventsListener.onRelaod();
verify(mockWebView).reload();
eventsListener.onGoForward();
verify(mockWebView).goForward();
eventsListener.onGoBack();
verify(mockWebView).goBack();
assertEquals("url", eventsListener.getCurrentURL());
assertTrue(eventsListener.canGoBack());
assertTrue(eventsListener.canGoForward());
// TODO: 2/10/21 verify broadcast
eventsListener.closeBrowser();
}
use of org.prebid.mobile.rendering.views.interstitial.InterstitialManager in project prebid-mobile-android by prebid.
the class AdInterstitialDialogTest method handleCloseClick.
@Test
public void handleCloseClick() throws IllegalAccessException {
InterstitialManager interstitialManager = mock(InterstitialManager.class);
Field interstitialManagerField = WhiteBox.field(AdInterstitialDialog.class, "mInterstitialManager");
interstitialManagerField.set(mAdInterstitialDialog, interstitialManager);
mAdInterstitialDialog.handleCloseClick();
verify(interstitialManager).interstitialClosed(mMockWebViewBase);
}
use of org.prebid.mobile.rendering.views.interstitial.InterstitialManager in project prebid-mobile-android by prebid.
the class TransactionTest method testTransactionInit.
@Test
public void testTransactionInit() throws Exception {
List<CreativeModel> creativeModels = new ArrayList<>();
CreativeModel mockCreativeModel = mock(CreativeModel.class);
creativeModels.add(mockCreativeModel);
Transaction.Listener mockOxTransactionListener = mock(Transaction.Listener.class);
// Valid
InterstitialManager mockInterstitialManager = mock(InterstitialManager.class);
Transaction transaction = Transaction.createTransaction(mMockContext, createModelResult(creativeModels, "ts"), mockInterstitialManager, mockOxTransactionListener);
assertNotNull(transaction);
// No context
boolean hasException = false;
try {
Transaction.createTransaction(null, createModelResult(creativeModels, "ts"), mockInterstitialManager, mockOxTransactionListener);
} catch (AdException e) {
hasException = true;
}
assertTrue(hasException);
// No creative models
hasException = false;
try {
Transaction.createTransaction(mMockContext, createModelResult(null, "ts"), mockInterstitialManager, mockOxTransactionListener);
} catch (AdException e) {
hasException = true;
}
assertTrue(hasException);
// Empty creative models
hasException = false;
try {
Transaction.createTransaction(mMockContext, createModelResult(new ArrayList<>(), "ts"), mockInterstitialManager, mockOxTransactionListener);
} catch (AdException e) {
hasException = true;
}
assertTrue(hasException);
// No listener
hasException = false;
try {
Transaction.createTransaction(mMockContext, createModelResult(creativeModels, "ts"), mockInterstitialManager, null);
} catch (AdException e) {
hasException = true;
}
assertTrue(hasException);
}
use of org.prebid.mobile.rendering.views.interstitial.InterstitialManager in project prebid-mobile-android by prebid.
the class PrebidWebViewBannerTest method preloadedTest.
@Test
public void preloadedTest() {
WebViewDelegate mockDelegate = mock(WebViewDelegate.class);
InterstitialManager mockManager = mock(InterstitialManager.class);
mBanner.mWebViewDelegate = mockDelegate;
mBanner.mInterstitialManager = mockManager;
MraidEvent mockEvent = mock(MraidEvent.class);
when(mMockWebViewBanner.getMraidEvent()).thenReturn(mockEvent);
mBanner.preloaded(null);
verify(mockDelegate).webViewFailedToLoad(any(AdException.class));
mMockWebViewBanner.mMRAIDBridgeName = "twopart";
mBanner.preloaded(mMockWebViewBanner);
verify(mockManager).displayPrebidWebViewForMraid(eq(mMockWebViewBanner), eq(true));
mMockWebViewBanner.mMRAIDBridgeName = "else";
mBanner.preloaded(mMockWebViewBanner);
// verify render
verify(mMockWebViewBanner).setAdWidth(anyInt());
when(mMockWebViewBanner.getParent()).thenReturn(mock(ViewGroup.class));
mBanner.preloaded(mMockWebViewBanner);
verify(mMockWebViewBanner).bringToFront();
verify(mockDelegate, times(3)).webViewReadyToDisplay();
}
use of org.prebid.mobile.rendering.views.interstitial.InterstitialManager in project prebid-mobile-android by prebid.
the class ViewPoolTest method getUnoccupiedViewTest.
@Test
public void getUnoccupiedViewTest() throws AdException {
VideoCreativeViewListener mockVideoCreativeViewListener = mock(VideoCreativeViewListener.class);
AdConfiguration.AdUnitIdentifierType adType = AdConfiguration.AdUnitIdentifierType.BANNER;
InterstitialManager mockInterstitialManager = mock(InterstitialManager.class);
View result = mViewPool.getUnoccupiedView(mContext, mockVideoCreativeViewListener, adType, mockInterstitialManager);
assertEquals(mUnoccupiedView, result);
assertEquals(2, mViewPool.sizeOfOccupied());
assertEquals(0, mViewPool.sizeOfUnoccupied());
result = mViewPool.getUnoccupiedView(mContext, mockVideoCreativeViewListener, adType, mockInterstitialManager);
assertThat(result, instanceOf(PrebidWebViewBanner.class));
assertEquals(3, mViewPool.sizeOfOccupied());
assertEquals(0, mViewPool.sizeOfUnoccupied());
adType = AdConfiguration.AdUnitIdentifierType.VAST;
result = mViewPool.getUnoccupiedView(mContext, mock(VideoCreative.class), adType, mockInterstitialManager);
assertThat(result, instanceOf(ExoPlayerView.class));
assertEquals(4, mViewPool.sizeOfOccupied());
assertEquals(0, mViewPool.sizeOfUnoccupied());
adType = AdConfiguration.AdUnitIdentifierType.INTERSTITIAL;
result = mViewPool.getUnoccupiedView(mContext, mockVideoCreativeViewListener, adType, mockInterstitialManager);
assertThat(result, instanceOf(PrebidWebViewInterstitial.class));
assertEquals(5, mViewPool.sizeOfOccupied());
assertEquals(0, mViewPool.sizeOfUnoccupied());
}
Aggregations