Skip to content

Commit

Permalink
Release 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
runner authored and runner committed Mar 21, 2022
1 parent adcf7af commit bec9f80
Show file tree
Hide file tree
Showing 117 changed files with 4,601 additions and 277 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 30
versionCode = 4010
versionName = "4.0.1"
versionCode = 4100
versionName = "4.1.0"
}

buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildscript {

dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'org.jacoco:org.jacoco.core:0.8.1'
classpath 'org.jacoco:org.jacoco.core:0.8.5'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.20.0'
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
}
Expand Down
4 changes: 2 additions & 2 deletions unity-ads/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ if (project.rootProject.file('local.properties').exists()) {
ext {
GROUP_ID = "com.unity3d.ads"
ARTIFACT_ID = "unity-ads"
VERSION_ID = "4.0.1"
VERSION_CODE = 4010
VERSION_ID = "4.1.0"
VERSION_CODE = 4100
SIGN_AAR = properties.getProperty("SIGN_AAR") ?: false
}

Expand Down
2 changes: 1 addition & 1 deletion unity-ads/jacoco.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'jacoco'

jacoco {
toolVersion = '0.8.1'
toolVersion = '0.8.5'
}

tasks.withType(Test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,22 @@
import com.unity3d.ads.test.instrumentation.services.ads.webplayer.WebPlayerViewCacheTest;
import com.unity3d.ads.test.instrumentation.services.ads.webplayer.WebPlayerViewSettingsCacheTest;
import com.unity3d.ads.test.instrumentation.services.banners.BannerViewCacheTests;
import com.unity3d.ads.test.instrumentation.services.core.configuration.ExperimentsTest;
import com.unity3d.ads.test.instrumentation.services.core.configuration.InitializationNotificationCenterTest;
import com.unity3d.ads.test.instrumentation.services.core.device.AsyncTokenStorageTest;
import com.unity3d.ads.test.instrumentation.services.core.device.DeviceInfoReaderCompressorTest;
import com.unity3d.ads.test.instrumentation.services.core.device.DeviceInfoReaderFilterProviderTest;
import com.unity3d.ads.test.instrumentation.services.core.device.DeviceInfoReaderTest;
import com.unity3d.ads.test.instrumentation.services.core.device.DeviceInfoReaderUrlEncoderTest;
import com.unity3d.ads.test.instrumentation.services.core.device.DeviceInfoReaderWithFilterTest;
import com.unity3d.ads.test.instrumentation.services.core.device.DeviceInfoReaderWithPIITest;
import com.unity3d.ads.test.instrumentation.services.core.device.DeviceInfoReaderWithStorageInfoTest;
import com.unity3d.ads.test.instrumentation.services.core.device.NativeTokenGeneratorTest;
import com.unity3d.ads.test.instrumentation.services.core.device.pii.PiiDataSelectorTest;
import com.unity3d.ads.test.instrumentation.services.core.device.pii.PiiDecisionDataTest;
import com.unity3d.ads.test.instrumentation.services.core.device.pii.PiiTrackingStatusReaderTest;
import com.unity3d.ads.test.instrumentation.services.core.misc.JsonFlattenerTest;
import com.unity3d.ads.test.instrumentation.services.core.webview.WebViewUrlBuilderTest;
import com.unity3d.ads.test.instrumentation.services.core.webview.bridge.WebViewBridgeSharedObjectTests;
import com.unity3d.ads.test.instrumentation.services.core.webview.bridge.invocation.WebViewBridgeInvocationRunnableTests;
import com.unity3d.ads.test.instrumentation.services.core.webview.bridge.invocation.WebViewBridgeInvocationTests;
Expand All @@ -27,6 +42,8 @@
UnityAnalyticsTest.class,
AcquisitionTypeTest.class,
InitializationNotificationCenterTest.class,
ExperimentsTest.class,
WebViewUrlBuilderTest.class,
WebPlayerViewSettingsCacheTest.class,
WebPlayerViewCacheTest.class,
BannerViewCacheTests.class,
Expand All @@ -41,7 +58,20 @@
AdOperationTests.class,
ShowModuleTests.class,
ConfigurationTest.class,
GmaScarTestSuite.class
GmaScarTestSuite.class,
AsyncTokenStorageTest.class,
NativeTokenGeneratorTest.class,
PiiTrackingStatusReaderTest.class,
PiiDecisionDataTest.class,
PiiDataSelectorTest.class,
DeviceInfoReaderTest.class,
DeviceInfoReaderCompressorTest.class,
DeviceInfoReaderUrlEncoderTest.class,
DeviceInfoReaderFilterProviderTest.class,
DeviceInfoReaderWithStorageInfoTest.class,
DeviceInfoReaderWithPIITest.class,
DeviceInfoReaderWithFilterTest.class,
JsonFlattenerTest.class
})

public class InstrumentationTestSuite {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import com.unity3d.services.ads.operation.load.LoadModule;
import com.unity3d.services.ads.operation.load.LoadOperation;
import com.unity3d.services.ads.operation.load.LoadOperationState;
import com.unity3d.services.core.request.ISDKMetricSender;
import com.unity3d.services.core.request.SDKMetricEvents;
import com.unity3d.services.core.request.metrics.ISDKMetricSender;
import com.unity3d.services.core.request.metrics.SDKMetricEvents;
import com.unity3d.services.core.webview.bridge.IWebViewBridgeInvoker;
import com.unity3d.services.core.webview.bridge.invocation.IWebViewBridgeInvocation;

Expand Down Expand Up @@ -72,7 +72,7 @@ public Object answer(InvocationOnMock invocation) {
loadModule.executeAdOperation(webViewBridgeInvokerMock, loadOperationState);

Mockito.verify(loadListenerMock, timeout(maxWaitTime).times(1)).onUnityAdsFailedToLoad(placementId, UnityAds.UnityAdsLoadError.INTERNAL_ERROR, "[UnityAds] Internal communication failure");
Mockito.verify(sdkMetricSender, times(1)).SendSDKMetricEventWithTag(SDKMetricEvents.native_load_callback_error, new HashMap<String, String> (){{
Mockito.verify(sdkMetricSender, times(1)).sendSDKMetricEventWithTag(SDKMetricEvents.native_load_callback_error, new HashMap<String, String> (){{
put("cbs", "invocationFailure");
}});
}
Expand All @@ -91,7 +91,7 @@ public Object answer(InvocationOnMock invocation) {
loadModule.executeAdOperation(webViewBridgeInvokerMock, loadOperationState);

Mockito.verify(loadListenerMock, timeout(maxWaitTime).times(1)).onUnityAdsFailedToLoad(placementId, UnityAds.UnityAdsLoadError.INTERNAL_ERROR, "[UnityAds] Internal communication timeout");
Mockito.verify(sdkMetricSender, times(1)).SendSDKMetricEvent(eq(SDKMetricEvents.native_load_callback_timeout));
Mockito.verify(sdkMetricSender, times(1)).sendSDKMetricEvent(eq(SDKMetricEvents.native_load_callback_timeout));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.unity3d.services.ads.operation.show.ShowModule;
import com.unity3d.services.ads.operation.show.ShowModuleDecoratorTimeout;
import com.unity3d.services.ads.operation.show.ShowOperationState;
import com.unity3d.services.core.request.ISDKMetricSender;
import com.unity3d.services.core.request.metrics.ISDKMetricSender;
import com.unity3d.services.core.webview.bridge.CallbackStatus;
import com.unity3d.services.core.webview.bridge.IWebViewBridgeInvoker;
import com.unity3d.services.core.webview.bridge.invocation.WebViewBridgeInvocationRunnable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import com.unity3d.services.ads.operation.show.ShowModule;
import com.unity3d.services.ads.operation.show.ShowOperation;
import com.unity3d.services.ads.operation.show.ShowOperationState;
import com.unity3d.services.core.request.ISDKMetricSender;
import com.unity3d.services.core.request.SDKMetricEvents;
import com.unity3d.services.core.request.metrics.ISDKMetricSender;
import com.unity3d.services.core.request.metrics.SDKMetricEvents;
import com.unity3d.services.core.webview.bridge.IWebViewBridgeInvoker;
import com.unity3d.services.core.webview.bridge.invocation.IWebViewBridgeInvocation;

Expand Down Expand Up @@ -75,7 +75,7 @@ public Object answer(InvocationOnMock invocation) {
_showModule.executeAdOperation(_webViewBridgeInvokerMock, showOperationState);

Mockito.verify((_showListenerMock), timeout(maxWaitTime).times(1)).onUnityAdsShowFailure(placementId, UnityAds.UnityAdsShowError.INTERNAL_ERROR, "WebViewBridgeInvocationRunnable:run: invokeMethod failure");
Mockito.verify(_sdkMetricSender, timeout(maxWaitTime).times(1)).SendSDKMetricEventWithTag(SDKMetricEvents.native_show_callback_error, new HashMap<String, String> (){{
Mockito.verify(_sdkMetricSender, timeout(maxWaitTime).times(1)).sendSDKMetricEventWithTag(SDKMetricEvents.native_show_callback_error, new HashMap<String, String> (){{
put("cbs", "invocationFailure");
}});
}
Expand All @@ -94,7 +94,7 @@ public Object answer(InvocationOnMock invocation) {
_showModule.executeAdOperation(_webViewBridgeInvokerMock, showOperationState);

Mockito.verify((_showListenerMock), timeout(maxWaitTime).times(1)).onUnityAdsShowFailure(placementId, UnityAds.UnityAdsShowError.INTERNAL_ERROR, "[UnityAds] Show Invocation Timeout");
Mockito.verify(_sdkMetricSender, timeout(maxWaitTime).times(1)).SendSDKMetricEvent(eq(SDKMetricEvents.native_show_callback_timeout));
Mockito.verify(_sdkMetricSender, timeout(maxWaitTime).times(1)).sendSDKMetricEvent(eq(SDKMetricEvents.native_show_callback_timeout));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.unity3d.ads.test.instrumentation.services.core.configuration;

import com.unity3d.services.core.configuration.Configuration;
import com.unity3d.services.core.configuration.ConfigurationRequestFactory;
import com.unity3d.services.core.configuration.Experiments;
import com.unity3d.services.core.device.reader.IDeviceInfoReader;
import com.unity3d.services.core.request.WebRequest;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;

import java.net.MalformedURLException;
import java.util.List;
import java.util.Map;

@RunWith(MockitoJUnitRunner.class)
public class ConfigurationRequestFactoryTest {

@Mock
Experiments _experimentsMock;

@Mock
Configuration _configurationMock;

@Mock
IDeviceInfoReader _deviceInfoReaderMock;

static final String CONFIG_URL = "http://configurl/";

@Test
public void testConfigurationRequestFactoryPost() throws MalformedURLException {
Mockito.when(_experimentsMock.isTwoStageInitializationEnabled()).thenReturn(true);
Mockito.when(_experimentsMock.isPOSTMethodInConfigRequestEnabled()).thenReturn(true);
Mockito.when(_configurationMock.getExperiments()).thenReturn(_experimentsMock);

ConfigurationRequestFactory configurationRequestFactory = new ConfigurationRequestFactory(_configurationMock, _deviceInfoReaderMock, CONFIG_URL);
WebRequest webRequest = configurationRequestFactory.getWebRequest();
Assert.assertEquals("POST", webRequest.getRequestType());
Map<String, List<String>> headers = webRequest.getHeaders();
Assert.assertEquals("gzip", headers.get("Content-Encoding").get(0));
}

@Test
public void testConfigurationRequestFactoryGetIfTsiDisabled() throws MalformedURLException {
Mockito.when(_experimentsMock.isTwoStageInitializationEnabled()).thenReturn(false);
Mockito.when(_experimentsMock.isPOSTMethodInConfigRequestEnabled()).thenReturn(true);
Mockito.when(_configurationMock.getExperiments()).thenReturn(_experimentsMock);

ConfigurationRequestFactory configurationRequestFactory = new ConfigurationRequestFactory(_configurationMock, _deviceInfoReaderMock, CONFIG_URL);
WebRequest webRequest = configurationRequestFactory.getWebRequest();
Assert.assertEquals("GET", webRequest.getRequestType());
Assert.assertTrue("ts missing from query", webRequest.getQuery().contains("ts"));
Assert.assertTrue("sdkVersion missing from query", webRequest.getQuery().contains("sdkVersion"));
Assert.assertTrue("sdkVersionName missing from query", webRequest.getQuery().contains("sdkVersionName"));
Assert.assertTrue("gameId missing from query", webRequest.getQuery().contains("gameId"));
}

@Test
public void testConfigurationRequestFactoryGetIfTsiEnabled() throws MalformedURLException {
Mockito.when(_experimentsMock.isTwoStageInitializationEnabled()).thenReturn(true);
Mockito.when(_experimentsMock.isPOSTMethodInConfigRequestEnabled()).thenReturn(false);
Mockito.when(_configurationMock.getExperiments()).thenReturn(_experimentsMock);

ConfigurationRequestFactory configurationRequestFactory = new ConfigurationRequestFactory(_configurationMock, _deviceInfoReaderMock, CONFIG_URL);
WebRequest webRequest = configurationRequestFactory.getWebRequest();
Assert.assertEquals("GET", webRequest.getRequestType());
Assert.assertEquals("c=H4sIAAAAAAAAAKuuBQBDv6ajAgAAAA%3D%3D", webRequest.getQuery());
}

@Test
public void testConfigurationRequestFactoryGetIfPostDisabled() throws MalformedURLException {
Mockito.when(_experimentsMock.isTwoStageInitializationEnabled()).thenReturn(true);
Mockito.when(_experimentsMock.isPOSTMethodInConfigRequestEnabled()).thenReturn(false);
Mockito.when(_configurationMock.getExperiments()).thenReturn(_experimentsMock);

ConfigurationRequestFactory configurationRequestFactory = new ConfigurationRequestFactory(_configurationMock, _deviceInfoReaderMock, CONFIG_URL);
WebRequest webRequest = configurationRequestFactory.getWebRequest();
Assert.assertEquals("GET", webRequest.getRequestType());
}

@Test
public void testConfigurationRequestFactoryGetNullExperiments() throws MalformedURLException {
Mockito.when(_configurationMock.getExperiments()).thenReturn(null);

ConfigurationRequestFactory configurationRequestFactory = new ConfigurationRequestFactory(_configurationMock, _deviceInfoReaderMock, CONFIG_URL);
WebRequest webRequest = configurationRequestFactory.getWebRequest();
Assert.assertEquals("GET", webRequest.getRequestType());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.unity3d.ads.test.instrumentation.services.core.configuration;

import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.unity3d.services.core.configuration.Experiments;

import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public class ExperimentsTest {

@Test
public void testExperimentsWithData() throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.put("fff", false);
jsonObject.put("tsi", false);
jsonObject.put("tsi_dc", true);
jsonObject.put("tsi_epii", false);
jsonObject.put("tsi_p", false);

Experiments experiments = new Experiments(jsonObject);
Assert.assertTrue(experiments.isHandleDeveloperConsent());
Assert.assertFalse(experiments.isTwoStageInitializationEnabled());
}

@Test
public void testExperimentsWithMissingData() throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.put("fff", false);

Experiments experiments = new Experiments(jsonObject);
Assert.assertFalse(experiments.isHandleDeveloperConsent());
}

@Test
public void testExperimentsWithEmptyData() {
JSONObject jsonObject = new JSONObject();

Experiments experiments = new Experiments(jsonObject);
Assert.assertFalse(experiments.isHandleDeveloperConsent());
}

@Test
public void testExperimentsWithNullData() {
Experiments experiments = new Experiments(null);
Assert.assertFalse(experiments.isHandleDeveloperConsent());
}

@Test
public void testExperimentsDefault() {
Experiments experiments = new Experiments();
Assert.assertFalse(experiments.isHandleDeveloperConsent());
}

}
Loading

0 comments on commit bec9f80

Please sign in to comment.