Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed useExternalBrowser #794

Open
wants to merge 2 commits into
base: 3.0.0-official-branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
public class PrebidMobile {

public static boolean isCoppaEnabled = false;
public static boolean useExternalBrowser = false;

/**
* If true, the SDK sends "af=3,5", indicating support for MRAID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ private void setCommonImpValues(Imp imp, String uuid) {
//Send 1 for interstitial/interstitial video and 0 for banners
imp.instl = isInterstitial ? 1 : 0;
// 0 == embedded, 1 == native
imp.clickBrowser = !PrebidMobile.useExternalBrowser && browserActivityAvailable ? 0 : 1;
imp.clickBrowser = browserActivityAvailable ? 0 : 1;
//set secure=1 for https or secure=0 for http
if (!adConfiguration.isAdType(AdFormat.VAST)) {
imp.secure = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public static void startBrowser(Context context, String url, int broadcastId,
intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
}

if (!PrebidMobile.useExternalBrowser && isActivityCallable(context, intent)) {
if (isActivityCallable(context, intent)) {
startActivity(context, intent);
notifyBrowserActionSuccess(BrowserActionResult.INTERNAL_BROWSER, onBrowserActionResultListener);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public void cleanup() throws Exception {
TargetingParams.setOmidPartnerVersion(null);

PrebidMobile.sendMraidSupportParams = true;
PrebidMobile.useExternalBrowser = false;
PrebidMobile.isCoppaEnabled = false;
PrebidMobile.clearStoredBidResponses();
PrebidMobile.setStoredAuctionResponse(null);
Expand Down Expand Up @@ -635,7 +634,6 @@ public void whenAppendParametersAndUseExternalBrowserFalseAndBrowserActivityAvai
adConfiguration.setAdFormat(AdFormat.BANNER);
adConfiguration.addSize(new AdSize(320, 50));

PrebidMobile.useExternalBrowser = false;

BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration,
context.getResources(),
Expand All @@ -648,33 +646,12 @@ public void whenAppendParametersAndUseExternalBrowserFalseAndBrowserActivityAvai
assertEquals(0, actualImp.clickBrowser.intValue());
}

@Test
public void whenAppendParametersAndUseExternalBrowserTrueAndBrowserActivityAvailable_ClickBrowserEqualsOne() {
AdUnitConfiguration adConfiguration = new AdUnitConfiguration();
adConfiguration.setAdFormat(AdFormat.BANNER);
adConfiguration.addSize(new AdSize(320, 50));

PrebidMobile.useExternalBrowser = true;

BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration,
context.getResources(),
browserActivityAvailable
);
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);

Imp actualImp = adRequestInput.getBidRequest().getImp().get(0);
assertEquals(1, actualImp.clickBrowser.intValue());
}

@Test
public void whenAppendParametersAndUseExternalBrowserFalseAndBrowserActivityNotAvailable_ClickBrowserEqualsOne() {
AdUnitConfiguration adConfiguration = new AdUnitConfiguration();
adConfiguration.setAdFormat(AdFormat.BANNER);
adConfiguration.addSize(new AdSize(320, 50));

PrebidMobile.useExternalBrowser = false;

BasicParameterBuilder builder = new BasicParameterBuilder(adConfiguration, context.getResources(), false);
AdRequestInput adRequestInput = new AdRequestInput();
builder.appendBuilderParameters(adRequestInput);
Expand Down Expand Up @@ -1149,7 +1126,7 @@ private Imp getExpectedImp(AdUnitConfiguration adConfiguration, String uuid) {
imp.instl = isInterstitial ? 1 : 0;

// 0 == embedded, 1 == native
imp.clickBrowser = !PrebidMobile.useExternalBrowser && browserActivityAvailable ? 0 : 1;
imp.clickBrowser = browserActivityAvailable ? 0 : 1;
imp.id = uuid;
imp.getExt().put("prebid", Prebid.getJsonObjectForImp(adConfiguration));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}

@After
public void tearDown() throws Exception {
PrebidMobile.useExternalBrowser = false;
}

@Test
public void whenIsActivityCallableAndContextOrIntentNull_ReturnFalse() {
assertFalse(ExternalViewerUtils.isActivityCallable(null, null));
Expand Down Expand Up @@ -107,7 +102,6 @@ public void whenLaunchApplicationUrl_StartActivity() throws ActionNotResolvedExc

@Test
public void whenStartBrowserAndUseExternalBrowserFalseAndActivityCallable_NotifyInternalBrowserSuccess() {
PrebidMobile.useExternalBrowser = false;
PackageManager mockManager = mock(PackageManager.class);
List<ResolveInfo> mockList = Collections.singletonList(mock(ResolveInfo.class));
when(mockManager.queryIntentActivities(any(Intent.class), anyInt())).thenReturn(mockList);
Expand All @@ -120,7 +114,6 @@ public void whenStartBrowserAndUseExternalBrowserFalseAndActivityCallable_Notify

@Test
public void whenStartBrowserAndUseExternalBrowserFalseAndActivityNotCallable_NotifyExternalBrowserSuccess() {
PrebidMobile.useExternalBrowser = false;
PackageManager mockManager = mock(PackageManager.class);
List<ResolveInfo> mockList = Collections.singletonList(mock(ResolveInfo.class));
when(mockManager.queryIntentActivities(any(Intent.class), anyInt())).thenReturn(mockList);
Expand All @@ -130,13 +123,4 @@ public void whenStartBrowserAndUseExternalBrowserFalseAndActivityNotCallable_Not
verify(mockContext).startActivity(any(Intent.class));
verify(mockResultListener).onSuccess(OnBrowserActionResultListener.BrowserActionResult.INTERNAL_BROWSER);
}

@Test
public void whenStartBrowserAndUseExternalBrowserTrue_NotifyExternalBrowserSuccess() {
PrebidMobile.useExternalBrowser = true;

ExternalViewerUtils.startBrowser(mockContext, "https://url.com", true, mockResultListener);
verify(mockContext).startActivity(any(Intent.class));
verify(mockResultListener).onSuccess(OnBrowserActionResultListener.BrowserActionResult.EXTERNAL_BROWSER);
}
}