-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
618ce50
commit 73eee20
Showing
122 changed files
with
4,156 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ captures | |
testServerAddress.txt | ||
app/bin | ||
unity-ads/bin | ||
libs | ||
javadoc | ||
.settings | ||
.project | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
allprojects { | ||
repositories { | ||
google() | ||
jcenter() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
buildscript { | ||
repositories { | ||
jcenter() | ||
gradlePluginPortal() | ||
google() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:4.1.3' | ||
classpath 'com.android.tools.build:gradle:4.2.1' | ||
classpath 'org.jacoco:org.jacoco.core:0.8.1' | ||
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.20.0' | ||
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' | ||
} | ||
} | ||
|
||
apply from: 'nexusPublishing.gradle' | ||
apply from: 'nexusPublishing.gradle' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
include ':app', ':unity-ads' | ||
include ':unity-scaradapter-1920' | ||
include ':unity-scaradapter-1950' | ||
include ':unity-scaradapter-2000' | ||
include ':unity-scaradapter-common' | ||
include ':app', ':unity-ads' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...Test/java/com/unity3d/ads/test/instrumentation/services/ads/gmascar/GmaScarTestSuite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.unity3d.ads.test.instrumentation.services.ads.gmascar; | ||
|
||
import com.unity3d.ads.test.instrumentation.services.ads.gmascar.adapters.ScarAdapterFactoryTest; | ||
import com.unity3d.ads.test.instrumentation.services.ads.gmascar.finder.GMAInitializerTest; | ||
import com.unity3d.ads.test.instrumentation.services.ads.gmascar.finder.PresenceDetectorTest; | ||
import com.unity3d.ads.test.instrumentation.services.ads.gmascar.finder.ScarVersionFinderTest; | ||
import com.unity3d.ads.test.instrumentation.services.ads.gmascar.bridges.AdapterStatusBridgeTest; | ||
import com.unity3d.ads.test.instrumentation.services.ads.gmascar.bridges.InitializationStatusBridgeTest; | ||
import com.unity3d.ads.test.instrumentation.services.ads.gmascar.bridges.InitializeListenerBridgeTest; | ||
import com.unity3d.ads.test.instrumentation.services.ads.gmascar.bridges.MobileAdsBridgeTest; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Suite; | ||
|
||
@RunWith(Suite.class) | ||
@Suite.SuiteClasses({ | ||
ScarAdapterFactoryTest.class, | ||
GMAInitializerTest.class, | ||
PresenceDetectorTest.class, | ||
ScarVersionFinderTest.class, | ||
AdapterStatusBridgeTest.class, | ||
InitializationStatusBridgeTest.class, | ||
InitializeListenerBridgeTest.class, | ||
MobileAdsBridgeTest.class | ||
}) | ||
public class GmaScarTestSuite { | ||
} |
43 changes: 43 additions & 0 deletions
43
...nity3d/ads/test/instrumentation/services/ads/gmascar/adapters/ScarAdapterFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.unity3d.ads.test.instrumentation.services.ads.gmascar.adapters; | ||
|
||
import com.unity3d.scar.adapter.common.IAdsErrorHandler; | ||
import com.unity3d.scar.adapter.common.IScarAdapter; | ||
import com.unity3d.services.ads.gmascar.adapters.ScarAdapterFactory; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class ScarAdapterFactoryTest { | ||
@Mock | ||
private IAdsErrorHandler adsErrorHandlerMock; | ||
|
||
private ScarAdapterFactory _scarAdapterFactory = new ScarAdapterFactory(); | ||
|
||
@Test | ||
public void testScarAdapterFactory1920() { | ||
IScarAdapter adapter = _scarAdapterFactory.createScarAdapter(ScarAdapterFactory.CODE_19_2, adsErrorHandlerMock); | ||
Assert.assertTrue(adapter instanceof com.unity3d.scar.adapter.v1920.ScarAdapter); | ||
} | ||
|
||
@Test | ||
public void testScarAdapterFactory1950() { | ||
IScarAdapter adapter = _scarAdapterFactory.createScarAdapter(ScarAdapterFactory.CODE_19_5, adsErrorHandlerMock); | ||
Assert.assertTrue(adapter instanceof com.unity3d.scar.adapter.v1950.ScarAdapter); | ||
} | ||
|
||
@Test | ||
public void testScarAdapterFactory2000() { | ||
IScarAdapter adapter = _scarAdapterFactory.createScarAdapter(ScarAdapterFactory.CODE_20_0, adsErrorHandlerMock); | ||
Assert.assertTrue(adapter instanceof com.unity3d.scar.adapter.v2000.ScarAdapter); | ||
} | ||
|
||
@Test | ||
public void testScarAdapterFactoryUnsupported() { | ||
IScarAdapter adapter = _scarAdapterFactory.createScarAdapter(-1, adsErrorHandlerMock); | ||
Assert.assertNull(adapter); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...nity3d/ads/test/instrumentation/services/ads/gmascar/bridges/AdapterStatusBridgeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.unity3d.ads.test.instrumentation.services.ads.gmascar.bridges; | ||
|
||
import com.google.android.gms.ads.initialization.AdapterStatus; | ||
import com.unity3d.services.ads.gmascar.bridges.AdapterStatusBridge; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class AdapterStatusBridgeTest { | ||
|
||
@Test | ||
public void testAdapterStatusBridge() { | ||
AdapterStatusBridge adapterStatusBridge = new AdapterStatusBridge(); | ||
Object[] statesEnum = adapterStatusBridge.getAdapterStatesEnum(); | ||
Assert.assertEquals(AdapterStatus.State.values().length, statesEnum.length); | ||
Assert.assertEquals(AdapterStatus.State.NOT_READY, statesEnum[0]); | ||
Assert.assertEquals(AdapterStatus.State.READY, statesEnum[1]); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ads/test/instrumentation/services/ads/gmascar/bridges/InitializationStatusBridgeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.unity3d.ads.test.instrumentation.services.ads.gmascar.bridges; | ||
|
||
import com.unity3d.services.ads.gmascar.bridges.InitializationStatusBridge; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.Map; | ||
|
||
public class InitializationStatusBridgeTest { | ||
|
||
@Test | ||
public void testInitializationStatusBridgeNotInitialized() { | ||
InitializationStatusBridge initializationStatusBridge = new InitializationStatusBridge(); | ||
Map<String, Object> adapterStatusMap = initializationStatusBridge.getAdapterStatusMap(new Object()); | ||
Assert.assertNull(adapterStatusMap); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...d/ads/test/instrumentation/services/ads/gmascar/bridges/InitializeListenerBridgeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.unity3d.ads.test.instrumentation.services.ads.gmascar.bridges; | ||
|
||
import com.unity3d.services.ads.gmascar.bridges.InitializeListenerBridge; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class InitializeListenerBridgeTest { | ||
|
||
@Test | ||
public void testInitializeListenerBridge() { | ||
InitializeListenerBridge initializeListenerBridge = new InitializeListenerBridge(); | ||
Object listenerProxy = initializeListenerBridge.createInitializeListenerProxy(); | ||
Assert.assertNotNull(listenerProxy); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...om/unity3d/ads/test/instrumentation/services/ads/gmascar/bridges/MobileAdsBridgeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.unity3d.ads.test.instrumentation.services.ads.gmascar.bridges; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
|
||
import com.google.android.gms.ads.initialization.InitializationStatus; | ||
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener; | ||
import com.unity3d.services.ads.gmascar.bridges.MobileAdsBridge; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
import static org.mockito.Mockito.timeout; | ||
|
||
public class MobileAdsBridgeTest { | ||
|
||
@Test | ||
@Ignore("Have to ignore for now cause the bridge is stateful (underlying call to GMA static init depends on other tests") | ||
public void testMobileAdsBridgeGetVersionNotInitialized() { | ||
MobileAdsBridge mobileAdsBridge = new MobileAdsBridge(); | ||
String versionString = mobileAdsBridge.getVersionString(); | ||
Assert.assertEquals("0.0.0", versionString); | ||
} | ||
|
||
@Test | ||
public void testMobileAdsBridgeGetVersion() { | ||
OnInitializationCompleteListener initializationCompleteListener = Mockito.mock(OnInitializationCompleteListener.class); | ||
MobileAdsBridge mobileAdsBridge = new MobileAdsBridge(); | ||
mobileAdsBridge.initialize(InstrumentationRegistry.getInstrumentation().getContext(), initializationCompleteListener); | ||
Mockito.verify(initializationCompleteListener, timeout(1000).times(1)).onInitializationComplete(Mockito.any(InitializationStatus.class)); | ||
String versionString = mobileAdsBridge.getVersionString(); | ||
Assert.assertTrue(String.format("Minor version 203404000 is not found in %s", versionString), versionString.contains("203404000")); | ||
} | ||
|
||
@Test | ||
@Ignore("Cannot test this case since the underlying GMA call is static so test ordering impacts this result.") | ||
public void testMobileAdsBridgeGetInitStatusNotInitialized() { | ||
MobileAdsBridge mobileAdsBridge = new MobileAdsBridge(); | ||
Object initializationStatus = mobileAdsBridge.getInitializationStatus(); | ||
Assert.assertNull(initializationStatus); | ||
} | ||
|
||
@Test | ||
public void testMobileAdsBridgeGetInitStatus() { | ||
OnInitializationCompleteListener initializationCompleteListener = Mockito.mock(OnInitializationCompleteListener.class); | ||
MobileAdsBridge mobileAdsBridge = new MobileAdsBridge(); | ||
mobileAdsBridge.initialize(InstrumentationRegistry.getInstrumentation().getContext(), initializationCompleteListener); | ||
Object initializationStatus = mobileAdsBridge.getInitializationStatus(); | ||
Assert.assertTrue(InitializationStatus.class.isAssignableFrom(initializationStatus.getClass())); | ||
} | ||
} |
Oops, something went wrong.