Skip to content

Commit

Permalink
Merge pull request #759 from prebid/669-remove-debug-configuration-in…
Browse files Browse the repository at this point in the history
…-mobilesdkpassthrough

Remove checks for debug
  • Loading branch information
jsligh authored Jun 10, 2024
2 parents 0b98a92 + 66850d6 commit c427d84
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ public class MobileSdkPassThrough {
public static MobileSdkPassThrough create(JSONObject extJson) {
try {
JSONObject rootJsonObject;
if (!BuildConfig.DEBUG) {
if (extJson.has("prebid")) {
rootJsonObject = extJson.getJSONObject("prebid");
} else return null;
} else {
rootJsonObject = extJson;
}
if (extJson.has("prebid")) {
rootJsonObject = extJson.getJSONObject("prebid");
} else return null;

if (rootJsonObject.has("passthrough")) {
JSONArray passThroughArray = rootJsonObject.getJSONArray("passthrough");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,134 +40,114 @@ public void create_putObjectWithoutAdConfigurationOrSDKConfig_returnNull() throw

@Test
public void create_putObjectWithEmptyAdConfiguration_returnEmptyObject() throws JSONException {
if (!BuildConfig.DEBUG) {
JSONObject jsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\", \"adconfiguration\":{}}]}}");

MobileSdkPassThrough subject = MobileSdkPassThrough.create(jsonObject);

assertNotNull(subject);

assertNull(subject.isMuted);
assertNull(subject.maxVideoDuration);
assertNull(subject.skipDelay);
assertNull(subject.skipButtonPosition);
assertNull(subject.skipButtonArea);
assertNull(subject.closeButtonArea);
assertNull(subject.closeButtonPosition);
}
JSONObject jsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\", \"adconfiguration\":{}}]}}");

MobileSdkPassThrough subject = MobileSdkPassThrough.create(jsonObject);

assertNotNull(subject);

assertNull(subject.isMuted);
assertNull(subject.maxVideoDuration);
assertNull(subject.skipDelay);
assertNull(subject.skipButtonPosition);
assertNull(subject.skipButtonArea);
assertNull(subject.closeButtonArea);
assertNull(subject.closeButtonPosition);
}

@Test
public void create_putObjectWithAdConfiguration_returnFullObject() throws JSONException {
if (!BuildConfig.DEBUG) {
JSONObject jsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\",\"adconfiguration\":{\n\"ismuted\": false,\n\"maxvideoduration\": 15,\n\"closebuttonarea\": 0.3,\n\"closebuttonposition\": \"topleft\",\n\"skipbuttonarea\": 0.3,\n\"skipbuttonposition\": \"topleft\",\n\"skipdelay\": 0}}]}}");

JSONObject jsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\",\"adconfiguration\":{\n\"ismuted\": false,\n\"maxvideoduration\": 15,\n\"closebuttonarea\": 0.3,\n\"closebuttonposition\": \"topleft\",\n\"skipbuttonarea\": 0.3,\n\"skipbuttonposition\": \"topleft\",\n\"skipdelay\": 0}}]}}");

MobileSdkPassThrough subject = MobileSdkPassThrough.create(jsonObject);
MobileSdkPassThrough subject = MobileSdkPassThrough.create(jsonObject);

assertNotNull(subject);
assertNotNull(subject);

assertEquals(false, subject.isMuted);
assertEquals((Integer) 15, subject.maxVideoDuration);
assertEquals((Integer) 0, subject.skipDelay);
assertEquals(Position.TOP_LEFT, subject.skipButtonPosition);
assertEquals((Double) 0.3, subject.skipButtonArea);
assertEquals((Double) 0.3, subject.closeButtonArea);
assertEquals(Position.TOP_LEFT, subject.closeButtonPosition);
}
assertEquals(false, subject.isMuted);
assertEquals((Integer) 15, subject.maxVideoDuration);
assertEquals((Integer) 0, subject.skipDelay);
assertEquals(Position.TOP_LEFT, subject.skipButtonPosition);
assertEquals((Double) 0.3, subject.skipButtonArea);
assertEquals((Double) 0.3, subject.closeButtonArea);
assertEquals(Position.TOP_LEFT, subject.closeButtonPosition);
}

@Test
public void modifyAdUnitConfiguration_putObjectWithAdConfiguration_getModifiedAdUnitConfiguration() throws JSONException {
if (!BuildConfig.DEBUG) {
JSONObject jsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\",\"adconfiguration\":{\n\"ismuted\": false,\n\"maxvideoduration\": 15,\n\"closebuttonarea\": 0.3,\n\"closebuttonposition\": \"topleft\",\n\"skipbuttonarea\": 0.3,\n\"skipbuttonposition\": \"topleft\",\n\"skipdelay\": 0}}]}}");

JSONObject jsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\",\"adconfiguration\":{\n\"ismuted\": false,\n\"maxvideoduration\": 15,\n\"closebuttonarea\": 0.3,\n\"closebuttonposition\": \"topleft\",\n\"skipbuttonarea\": 0.3,\n\"skipbuttonposition\": \"topleft\",\n\"skipdelay\": 0}}]}}");

MobileSdkPassThrough subject = MobileSdkPassThrough.create(jsonObject);
AdUnitConfiguration adUnitConfiguration = new AdUnitConfiguration();
MobileSdkPassThrough subject = MobileSdkPassThrough.create(jsonObject);
AdUnitConfiguration adUnitConfiguration = new AdUnitConfiguration();

assertNotNull(subject);
assertNotNull(subject);

subject.modifyAdUnitConfiguration(adUnitConfiguration);
subject.modifyAdUnitConfiguration(adUnitConfiguration);

assertFalse(adUnitConfiguration.isMuted());
assertEquals((Integer) 15, adUnitConfiguration.getMaxVideoDuration());
assertEquals(0, adUnitConfiguration.getSkipDelay());
assertEquals(Position.TOP_LEFT, adUnitConfiguration.getSkipButtonPosition());
assertEquals(0.3, adUnitConfiguration.getSkipButtonArea(), 0);
assertEquals(0.3, adUnitConfiguration.getCloseButtonArea(), 0);
assertEquals(Position.TOP_LEFT, adUnitConfiguration.getCloseButtonPosition());
}
assertFalse(adUnitConfiguration.isMuted());
assertEquals((Integer) 15, adUnitConfiguration.getMaxVideoDuration());
assertEquals(0, adUnitConfiguration.getSkipDelay());
assertEquals(Position.TOP_LEFT, adUnitConfiguration.getSkipButtonPosition());
assertEquals(0.3, adUnitConfiguration.getSkipButtonArea(), 0);
assertEquals(0.3, adUnitConfiguration.getCloseButtonArea(), 0);
assertEquals(Position.TOP_LEFT, adUnitConfiguration.getCloseButtonPosition());
}

@Test
public void combine_checkFromBidPriority() throws JSONException {
if (!BuildConfig.DEBUG) {
JSONObject fromBidJsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\",\"adconfiguration\":{\n\"ismuted\": false,\n\"closebuttonarea\": 0.1}}]}}");
JSONObject fromRootJsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\",\"adconfiguration\":{\n\"maxvideoduration\": 15,\n\"closebuttonarea\": 0.2}}]}}");
MobileSdkPassThrough fromBid = MobileSdkPassThrough.create(fromBidJsonObject);
MobileSdkPassThrough fromRoot = MobileSdkPassThrough.create(fromRootJsonObject);

MobileSdkPassThrough result = MobileSdkPassThrough.combine(fromBid, fromRoot);

assertNotNull(result);

/* Only in fromBid response */
assertFalse(result.isMuted);
/* Only in fromRoot response */
assertEquals((Integer) 15, result.maxVideoDuration);
/* In fromBid = 0.1, in fromRoot = 0.2, fromBid have higher priority, so must be 0.1 */
assertEquals((Double) 0.1, result.closeButtonArea);
}
JSONObject fromBidJsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\",\"adconfiguration\":{\n\"ismuted\": false,\n\"closebuttonarea\": 0.1}}]}}");
JSONObject fromRootJsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\",\"adconfiguration\":{\n\"maxvideoduration\": 15,\n\"closebuttonarea\": 0.2}}]}}");
MobileSdkPassThrough fromBid = MobileSdkPassThrough.create(fromBidJsonObject);
MobileSdkPassThrough fromRoot = MobileSdkPassThrough.create(fromRootJsonObject);

MobileSdkPassThrough result = MobileSdkPassThrough.combine(fromBid, fromRoot);

assertNotNull(result);

/* Only in fromBid response */
assertFalse(result.isMuted);
/* Only in fromRoot response */
assertEquals((Integer) 15, result.maxVideoDuration);
/* In fromBid = 0.1, in fromRoot = 0.2, fromBid have higher priority, so must be 0.1 */
assertEquals((Double) 0.1, result.closeButtonArea);
}

@Test
public void create_putObjectWithSdkConfiguration_returnFullObject() throws JSONException {
if (!BuildConfig.DEBUG) {
JSONObject jsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\", \n\"sdkconfiguration\": {\n\"cftbanner\": 7800, \n\"cftprerender\": 21000}}]}}");

JSONObject jsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\", \n\"sdkconfiguration\": {\n\"cftbanner\": 7800, \n\"cftprerender\": 21000}}]}}");

MobileSdkPassThrough subject = MobileSdkPassThrough.create(jsonObject);

assertNotNull(subject);
assertEquals((Integer) 7800, subject.bannerTimeout);
assertEquals((Integer) 21000, subject.preRenderTimeout);
MobileSdkPassThrough subject = MobileSdkPassThrough.create(jsonObject);

}
assertNotNull(subject);
assertEquals((Integer) 7800, subject.bannerTimeout);
assertEquals((Integer) 21000, subject.preRenderTimeout);
}

@Test
public void create_putObjectWithSdkConfiguration_onlyBannerTimeout() throws JSONException {
if (!BuildConfig.DEBUG) {

JSONObject jsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\", \n\"sdkconfiguration\": {\n\"cftbanner\": 7900}}]}}");
JSONObject jsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\", \n\"sdkconfiguration\": {\n\"cftbanner\": 7900}}]}}");

MobileSdkPassThrough subject = MobileSdkPassThrough.create(jsonObject);
MobileSdkPassThrough subject = MobileSdkPassThrough.create(jsonObject);

assertNotNull(subject);
assertEquals((Integer) 7900, subject.bannerTimeout);
}
assertNotNull(subject);
assertEquals((Integer) 7900, subject.bannerTimeout);
}

@Test
public void create_putObjectWithSdkConfiguration_onlyPreRenderTimeout() throws JSONException {
if (!BuildConfig.DEBUG) {

JSONObject jsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\", \n\"sdkconfiguration\": {\n\"cftprerender\": 22000}}]}}");
JSONObject jsonObject = new JSONObject(
"{\"prebid\":{\"passthrough\":[{\"type\":\"prebidmobilesdk\", \n\"sdkconfiguration\": {\n\"cftprerender\": 22000}}]}}");

MobileSdkPassThrough subject = MobileSdkPassThrough.create(jsonObject);
MobileSdkPassThrough subject = MobileSdkPassThrough.create(jsonObject);

assertNotNull(subject);
assertEquals((Integer) 22000, subject.preRenderTimeout);
}
assertNotNull(subject);
assertEquals((Integer) 22000, subject.preRenderTimeout);
}

}

0 comments on commit c427d84

Please sign in to comment.