Skip to content

Commit

Permalink
Release 4.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
runner authored and runner committed Sep 28, 2023
1 parent 4f6c0f6 commit 9030d0c
Show file tree
Hide file tree
Showing 183 changed files with 2,793 additions and 2,330 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.unity3d.ads.example"
minSdkVersion 19
targetSdkVersion 33
versionCode = 4800
versionName = "4.8.0"
versionCode = 4900
versionName = "4.9.0"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.unity3d.ads.IUnityAdsInitializationListener;
import com.unity3d.ads.IUnityAdsLoadListener;
import com.unity3d.ads.IUnityAdsShowListener;
import com.unity3d.ads.UnityAds;
import com.unity3d.ads.UnityAdsShowOptions;
import com.unity3d.ads.*;
import com.unity3d.ads.example.R;
import com.unity3d.ads.metadata.MediationMetaData;
import com.unity3d.ads.metadata.MetaData;
Expand Down Expand Up @@ -68,6 +64,7 @@ public void onBannerShown(BannerView bannerAdView) {
@Override
public void onBannerFailedToLoad(BannerView bannerAdView, BannerErrorInfo errorInfo) {
Log.e(LOGTAG, "Unity Ads failed to load banner for " + bannerAdView.getPlacementId() + " with error: [" + errorInfo.errorCode + "] " + errorInfo.errorMessage);
enableButton(showBannerButton);
}

@Override
Expand Down Expand Up @@ -203,6 +200,7 @@ public void onClick(View v) {
this.showBannerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
disableButton(showBannerButton);
bottomBanner = new BannerView((Activity)v.getContext(), "bannerads", new UnityBannerSize(320, 50));
bottomBanner.setListener(bannerListener);
bottomBanner.load();
Expand All @@ -213,11 +211,12 @@ public void onClick(View v) {
hideBannerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bottomBanner.removeAllViews();
if (bottomBanner != null) {
bottomBanner.removeAllViews();
bottomBanner = null;
}
showBannerButton.setEnabled(true);
enableButton(showBannerButton);
disableButton(hideBannerButton);
}
});

Expand Down
2 changes: 0 additions & 2 deletions fatAar.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ project.tasks.whenTaskAdded { Task theTask ->
}
if (tasksDependentOnScar("${buildType}").any { theTask.name == it }) {
theTask.dependsOn(":unity-scaradapter-common:copyJars${buildType}")
theTask.dependsOn(":unity-scaradapter-1920:copyJars${buildType}")
theTask.dependsOn(":unity-scaradapter-1950:copyJars${buildType}")
theTask.dependsOn(":unity-scaradapter-2000:copyJars${buildType}")
theTask.dependsOn(":unity-scaradapter-2100:copyJars${buildType}")
}
Expand Down
2 changes: 0 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include ':unity-scaradapter-1920'
include ':unity-scaradapter-1950'
include ':unity-scaradapter-2000'
include ':unity-scaradapter-2100'
include ':unity-scaradapter-common'
Expand Down
9 changes: 3 additions & 6 deletions unity-ads/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ if (project.rootProject.file('local.properties').exists()) {
ext {
GROUP_ID = "com.unity3d.ads"
ARTIFACT_ID = "unity-ads"
VERSION_ID = "4.8.0"
VERSION_CODE = 4800
VERSION_ID = "4.9.0"
VERSION_CODE = 4900
SIGN_AAR = properties.getProperty("SIGN_AAR") ?: false
}

android {
namespace = GROUP_ID
compileSdk 33
compileSdkExtension 5
DdmPreferences.setLogLevel("verbose")
DdmPreferences.setTimeOut(10 * 60000)

Expand Down Expand Up @@ -82,8 +83,6 @@ dependencies {
implementation "com.google.android.gms:play-services-cronet:$play_services_cronet"
androidTestCompileOnly project(':unity-scaradapter-2100')
androidTestCompileOnly project(':unity-scaradapter-2000')
androidTestCompileOnly project(':unity-scaradapter-1950')
androidTestCompileOnly project(':unity-scaradapter-1920')
androidTestCompileOnly project(':unity-scaradapter-common')
androidTestImplementation 'junit:junit:4.13.2'
androidTestImplementation 'org.mockito:mockito-core:2.28.2'
Expand All @@ -98,8 +97,6 @@ dependencies {
compileOnly 'com.google.ar:core:1.0.0'
compileOnly project(':unity-scaradapter-2100')
compileOnly project(':unity-scaradapter-2000')
compileOnly project(':unity-scaradapter-1950')
compileOnly project(':unity-scaradapter-1920')
compileOnly project(':unity-scaradapter-common')
testImplementation 'junit:junit:4.13.2'
testImplementation "org.jetbrains.kotlin:kotlin-stdlib"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
import android.app.Activity;
import android.content.Context;

import android.widget.RelativeLayout;
import com.unity3d.scar.adapter.common.IScarAdapter;
import com.unity3d.scar.adapter.common.IScarBannerAdListenerWrapper;
import com.unity3d.scar.adapter.common.IScarInterstitialAdListenerWrapper;
import com.unity3d.scar.adapter.common.IScarRewardedAdListenerWrapper;
import com.unity3d.scar.adapter.common.scarads.ScarAdMetadata;
import com.unity3d.scar.adapter.common.scarads.UnityAdFormat;
import com.unity3d.scar.adapter.common.signals.ISignalCollectionListener;
import com.unity3d.services.ads.gmascar.GMAScarAdapterBridge;
import com.unity3d.services.ads.gmascar.adapters.ScarAdapterFactory;
Expand Down Expand Up @@ -64,19 +67,19 @@ public class GMAScarAdapterBridgeTest {
private static final ScarAdapterVersion VERSION = ScarAdapterVersion.V21;
private GMAScarAdapterBridge gmaScarAdapterBridge;
private IScarAdapter scarAdapter;
private boolean isBannerSignalEnabled = true;

@Before
public void setup() {
scarAdapter = new IScarAdapter() {
@Override
public void getSCARSignals(Context context, String[] strings,
String[] strings1,
ISignalCollectionListener iSignalCollectionListener) {
public void getSCARSignal(Context context, String placementId, UnityAdFormat adFormat, ISignalCollectionListener signalCompletionListener) {

}

@Override
public void getSCARBiddingSignals(Context context,
boolean isBannerEnabled,
ISignalCollectionListener iSignalCollectionListener) {
iSignalCollectionListener.onSignalsCollected(SIGNAL);
}
Expand All @@ -95,6 +98,11 @@ public void loadRewardedAd(Context context,

}

@Override
public void loadBannerAd(Context context, RelativeLayout bannerView, ScarAdMetadata scarAdMetadata, int width, int height, IScarBannerAdListenerWrapper adListener) {

}

@Override
public void show(Activity activity, String s, String s1) {

Expand Down Expand Up @@ -189,7 +197,7 @@ public void testSignalsCollectedWhenGetScarBiddingSignalsCalled() {
gmaEventSenderMock
);

gmaScarAdapterBridge.getSCARBiddingSignals(handler);
gmaScarAdapterBridge.getSCARBiddingSignals(isBannerSignalEnabled, handler);
verify(handler, times(0)).onSignalsCollectionFailed(anyString());
verify(handler, times(1)).onSignalsCollected(SIGNAL);
}
Expand All @@ -208,7 +216,7 @@ public void testFailToCollectSignalsWhenNoBiddingSupport() {
gmaEventSenderMock
);

gmaScarAdapterBridge.getSCARBiddingSignals(handler);
gmaScarAdapterBridge.getSCARBiddingSignals(isBannerSignalEnabled, handler);
verify(handler, times(0)).onSignalsCollected(anyString());
verify(handler, times(1)).onSignalsCollectionFailed("SCAR bidding unsupported.");
}
Expand All @@ -228,7 +236,7 @@ public void testFailToCollectSignalsWhenAdapterCannotBeCreated() {
gmaEventSenderMock
);

gmaScarAdapterBridge.getSCARBiddingSignals(handler);
gmaScarAdapterBridge.getSCARBiddingSignals(isBannerSignalEnabled, handler);
verify(handler, times(0)).onSignalsCollected(SIGNAL);
verify(handler, times(1)).onSignalsCollectionFailed("Could not create SCAR adapter object.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,6 @@ public class ScarAdapterFactoryTest {

private final ScarAdapterFactory _scarAdapterFactory = new ScarAdapterFactory();

@Test
public void testScarAdapterFactory1920() {
IScarAdapter adapter = _scarAdapterFactory.createScarAdapter(ScarAdapterVersion.V192, adsErrorHandlerMock);
Assert.assertTrue(adapter instanceof com.unity3d.scar.adapter.v1920.ScarAdapter);
}

@Test
public void testScarAdapterFactory1950() {
IScarAdapter adapter = _scarAdapterFactory.createScarAdapter(ScarAdapterVersion.V195, adsErrorHandlerMock);
Assert.assertTrue(adapter instanceof com.unity3d.scar.adapter.v1950.ScarAdapter);
}

@Test
public void testScarAdapterFactory2000() {
IScarAdapter adapter = _scarAdapterFactory.createScarAdapter(ScarAdapterVersion.V20, adsErrorHandlerMock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,6 @@ public void testMobileAdsBridgeV21GetVersion() {
Assert.assertTrue(String.format("Minor version 223712000 is not found in %s", versionString), versionString.contains("223712000"));
}

@Test
public void testGetAdapterVersionWhen192() {
MobileAdsBridgeLegacy mobileAdsBridge = new MobileAdsBridgeLegacy();
ScarAdapterVersion adapterVersion = mobileAdsBridge.getAdapterVersion(MobileAdsBridgeLegacy.CODE_19_2);
Assert.assertEquals(ScarAdapterVersion.V192, adapterVersion);
}

@Test
public void testGetAdapterVersionWhen195() {
MobileAdsBridgeLegacy mobileAdsBridge = new MobileAdsBridgeLegacy();
ScarAdapterVersion adapterVersion = mobileAdsBridge.getAdapterVersion(MobileAdsBridgeLegacy.CODE_19_5);
Assert.assertEquals(ScarAdapterVersion.V195, adapterVersion);
}

@Test
public void testGetAdapterVersionWhen198() {
MobileAdsBridgeLegacy mobileAdsBridge = new MobileAdsBridgeLegacy();
ScarAdapterVersion adapterVersion = mobileAdsBridge.getAdapterVersion(MobileAdsBridgeLegacy.CODE_19_8);
Assert.assertEquals(ScarAdapterVersion.V195, adapterVersion);
}

@Test
public void testGetAdapterVersionWhen20() {
MobileAdsBridgeLegacy mobileAdsBridge = new MobileAdsBridgeLegacy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public void setup() {
public void testScarVersionFinderWithMobileAdsBridgeLegacy() {
doCallRealMethod().when(mobileAdsBridgeMock).getVersionCodeIndex();

Mockito.when(mobileAdsBridgeMock.getVersionString()).thenReturn("afma-sdk-a-v204890999.203404000.1");
Mockito.when(mobileAdsBridgeMock.getVersionString()).thenReturn("afma-sdk-a-v204890999.210402000.1");
ScarVersionFinder scarVersionFinder = new ScarVersionFinder(mobileAdsBridgeMock, presenceDetector, gmaInitializer, new GMAEventSender());
long versionCode = scarVersionFinder.getVersionCode();
Assert.assertEquals(MobileAdsBridgeLegacy.CODE_19_5, versionCode);
Assert.assertEquals(MobileAdsBridgeLegacy.CODE_20_0, versionCode);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@ public class BiddingSignalsHandlerTest {

@Test
public void testSignalsAreSetAfterOnSignalsCollectedWithValidMap() {
String map = "{\"gmaScarBiddingRewardedSignal\": \"rvSig\",\"gmaScarBiddingInterstitialSignal\": \"inSig\"}";
String map = "{\"gmaScarBiddingRewardedSignal\": \"rvSig\",\"gmaScarBiddingInterstitialSignal\": \"inSig\", \"gmaScarBiddingBannerSignal\": \"bnSig\"}";
gmaScarBiddingSignalsListener = spy(new IBiddingSignalsListener() {
@Override
public void onSignalsReady(BiddingSignals signals) {
assertEquals("rvSig", signals.getRvSignal());
assertEquals("inSig", signals.getInterstitialSignal());
assertEquals("bnSig", signals.getBannerSignal());
}

@Override
public void onSignalsFailure(String msg) {
fail();
}
});
biddingSignalsHandler = new BiddingSignalsHandler(gmaScarBiddingSignalsListener);
biddingSignalsHandler = new BiddingSignalsHandler(true, gmaScarBiddingSignalsListener);

biddingSignalsHandler.onSignalsCollected(map);
verify(gmaScarBiddingSignalsListener, times(1)).onSignalsReady(
Expand All @@ -44,21 +45,70 @@ public void onSignalsFailure(String msg) {

@Test
public void testNoInterstitialSignalSetAfterOnSignalsCollectedWithMissingInterstitial() {
String map = "{\"gmaScarBiddingRewardedSignal\": \"rvSig\",\"asdfasdfasf\": \"inSig\"}";
String map = "{\"gmaScarBiddingRewardedSignal\": \"rvSig\", \"gmaScarBiddingBannerSignal\": \"bnSig\"}";

gmaScarBiddingSignalsListener = spy(new IBiddingSignalsListener() {
@Override
public void onSignalsReady(BiddingSignals signals) {
assertEquals("rvSig", signals.getRvSignal());
assertEquals("", signals.getInterstitialSignal());
assertEquals("bnSig", signals.getBannerSignal());
}

@Override
public void onSignalsFailure(String msg) {
fail();
}
});
biddingSignalsHandler = new BiddingSignalsHandler(true, gmaScarBiddingSignalsListener);

biddingSignalsHandler.onSignalsCollected(map);
verify(gmaScarBiddingSignalsListener, times(1)).onSignalsReady(
isA(BiddingSignals.class));
}

@Test
public void testNoBannerSignalSetAfterOnSignalsCollectedWithBannerDisabled() {
String map = "{\"gmaScarBiddingRewardedSignal\": \"rvSig\",\"gmaScarBiddingInterstitialSignal\": \"inSig\"}";

gmaScarBiddingSignalsListener = spy(new IBiddingSignalsListener() {
@Override
public void onSignalsReady(BiddingSignals signals) {
assertEquals("rvSig", signals.getRvSignal());
assertEquals("inSig", signals.getInterstitialSignal());
assertEquals("", signals.getBannerSignal());
}

@Override
public void onSignalsFailure(String msg) {
fail();
}
});
biddingSignalsHandler = new BiddingSignalsHandler(false, gmaScarBiddingSignalsListener);

biddingSignalsHandler.onSignalsCollected(map);
verify(gmaScarBiddingSignalsListener, times(1)).onSignalsReady(
isA(BiddingSignals.class));
}

@Test
public void testNoBannerSignalSetAfterOnSignalsCollectedWithBannerPresent() {
String map = "{\"gmaScarBiddingRewardedSignal\": \"rvSig\",\"gmaScarBiddingInterstitialSignal\": \"inSig\", \"gmaScarBiddingBannerSignal\": \"bnSig\"}";

gmaScarBiddingSignalsListener = spy(new IBiddingSignalsListener() {
@Override
public void onSignalsReady(BiddingSignals signals) {
assertEquals("rvSig", signals.getRvSignal());
assertEquals("inSig", signals.getInterstitialSignal());
assertEquals("", signals.getBannerSignal());
}

@Override
public void onSignalsFailure(String msg) {
fail();
}
});
biddingSignalsHandler = new BiddingSignalsHandler(gmaScarBiddingSignalsListener);
biddingSignalsHandler = new BiddingSignalsHandler(false, gmaScarBiddingSignalsListener);

biddingSignalsHandler.onSignalsCollected(map);
verify(gmaScarBiddingSignalsListener, times(1)).onSignalsReady(
Expand All @@ -80,7 +130,7 @@ public void onSignalsFailure(String msg) {
fail();
}
});
biddingSignalsHandler = new BiddingSignalsHandler(gmaScarBiddingSignalsListener);
biddingSignalsHandler = new BiddingSignalsHandler(false, gmaScarBiddingSignalsListener);

biddingSignalsHandler.onSignalsCollected(map);
verify(gmaScarBiddingSignalsListener, times(1)).onSignalsReady(
Expand Down
Loading

0 comments on commit 9030d0c

Please sign in to comment.