Skip to content

Commit d4b2056

Browse files
committed
Release 2.0.0-rc1
1 parent ee9cd2f commit d4b2056

File tree

9 files changed

+96
-23
lines changed

9 files changed

+96
-23
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "com.unity3d.ads.example"
99
minSdkVersion 9
1010
targetSdkVersion 23
11-
versionCode = 2000
12-
versionName = "2.0.0-beta5"
11+
versionCode = 2001
12+
versionName = "2.0.0-rc1"
1313
}
1414
buildTypes {
1515
release {

app/src/main/java/com/unity3d/ads/example/UnityAdsExample.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public void onClick(View v) {
8686

8787
SharedPreferences preferences = getSharedPreferences("Settings", MODE_PRIVATE);
8888
gameIdEdit.setText(preferences.getString("gameId", defaultGameId));
89+
testModeCheckbox.setChecked(true);
8990

9091
initializeButton.setOnClickListener(new View.OnClickListener() {
9192
@Override
@@ -236,4 +237,4 @@ private void toast(String callback, String msg) {
236237
Toast.makeText(getApplicationContext(), callback + ": " + msg, Toast.LENGTH_SHORT).show();
237238
}
238239
}
239-
}
240+
}

lib/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
defaultConfig {
1313
minSdkVersion 9
1414
targetSdkVersion 23
15-
versionCode = 2000
16-
versionName = "2.0.0-beta5"
15+
versionCode = 2001
16+
versionName = "2.0.0-rc1"
1717

1818
setProperty("archivesBaseName", "unity-ads")
1919

lib/src/androidTest/java/com/unity3d/ads/test/UnitTestSuite.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,31 @@
99
@Suite.SuiteClasses({
1010
AdUnitActivityTest.class,
1111
AdvertisingIdentifierTest.class,
12-
InvocationTest.class,
12+
BroadcastTest.class,
1313
CacheTest.class,
1414
ClientPropertiesTest.class,
15+
ConnectivityTest.class,
1516
DeviceTest.class,
1617
EventIdTest.class,
1718
EnvironmentCheckTest.class,
19+
EventIdTest.class,
1820
InitializeThreadTest.class,
21+
InvocationTest.class,
22+
MetaDataTest.class,
1923
NativeCallbackTest.class,
2024
PackageManagerTest.class,
25+
PlacementTest.class,
2126
PublicApiTest.class,
27+
RequestTest.class,
2228
SdkPropertiesTest.class,
2329
StorageDiskTest.class,
2430
StorageGeneralTest.class,
2531
StorageMemoryTest.class,
26-
RequestTest.class,
2732
VideoViewTest.class,
2833
WebRequestTest.class,
2934
WebViewAppTest.class,
3035
WebViewBridgeInterfaceTest.class,
3136
WebViewBridgeTest.class,
32-
WebViewCallbackTest.class,
33-
PlacementTest.class,
34-
BroadcastTest.class
37+
WebViewCallbackTest.class
3538
})
3639
public class UnitTestSuite {}

lib/src/androidTest/java/com/unity3d/ads/test/unit/CacheTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ public void eventCache(CacheEvent eventId, Object... params) {
400400
break;
401401

402402
case DOWNLOAD_PROGRESS:
403-
if(REMOTE_VIDEO.equals(params[0]) && (Long)params[1] > minDownloadBytes) {
403+
if(REMOTE_VIDEO.equals(params[0]) && (Long)params[1] > 1) {
404404
setFlag("cancelInvoked");
405405
Invocation invocation = new Invocation();
406406
WebViewCallback callback = new WebViewCallback("1234", invocation.getId());
@@ -416,7 +416,7 @@ public void eventCache(CacheEvent eventId, Object... params) {
416416

417417
case DOWNLOAD_STOPPED:
418418
// params: url, total bytes
419-
if(REMOTE_VIDEO.equals(params[0]) && (Long)params[1] > minDownloadBytes) {
419+
if(REMOTE_VIDEO.equals(params[0]) && (Long)params[1] > 1) {
420420
setFlag("stopEventReceived");
421421
downloadPosition = (long)params[1];
422422
cacheCv.open();
@@ -438,7 +438,7 @@ public void eventCache(CacheEvent eventId, Object... params) {
438438

439439
Invocation invocation = new Invocation();
440440
WebViewCallback callback = new WebViewCallback("1234", invocation.getId());
441-
CacheThread.setProgressInterval(10);
441+
CacheThread.setProgressInterval(2);
442442
Cache.download(REMOTE_VIDEO, REMOTE_VIDEO_FILE_ID, callback);
443443
invocation.sendInvocationCallback();
444444

lib/src/androidTest/java/com/unity3d/ads/test/unit/ConnectivityTest.java

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
package com.unity3d.ads.test.unit;
22

3+
import android.os.ConditionVariable;
4+
import android.os.Handler;
5+
import android.os.Looper;
36
import android.support.test.InstrumentationRegistry;
47
import android.support.test.runner.AndroidJUnit4;
8+
import android.view.ViewGroup;
59

610
import com.unity3d.ads.api.Connectivity;
711
import com.unity3d.ads.api.DeviceInfo;
812
import com.unity3d.ads.connectivity.ConnectivityEvent;
913
import com.unity3d.ads.connectivity.ConnectivityMonitor;
1014
import com.unity3d.ads.connectivity.IConnectivityListener;
15+
import com.unity3d.ads.log.DeviceLog;
1116
import com.unity3d.ads.properties.ClientProperties;
17+
import com.unity3d.ads.video.VideoPlayerView;
1218
import com.unity3d.ads.webview.WebViewApp;
1319
import com.unity3d.ads.webview.WebViewEventCategory;
1420
import com.unity3d.ads.webview.bridge.CallbackStatus;
@@ -72,28 +78,65 @@ public void testWebappEvents() {
7278
// Make sure connectivity monitor thinks it's connected when test starts
7379
ConnectivityMonitor.connected();
7480

75-
MockWebViewApp webapp = new MockWebViewApp();
81+
final MockWebViewApp webapp = new MockWebViewApp();
7682
WebViewApp.setCurrentApp(webapp);
7783
WebViewApp.getCurrentApp().setWebAppLoaded(true);
7884

79-
Connectivity.setConnectionMonitoring(true, webapp.getCallback());
85+
Handler handler = new Handler(Looper.getMainLooper());
86+
ConditionVariable cv = new ConditionVariable();
87+
handler.post(new Runnable() {
88+
@Override
89+
public void run() {
90+
Connectivity.setConnectionMonitoring(true, webapp.getCallback());
91+
webapp.getInvocation().sendInvocationCallback();
92+
93+
}
94+
});
95+
boolean success = cv.block(1000);
96+
8097
assertTrue("Connectivity MockWebViewApp did not respond with success callback", webapp.getCallbackInvoked());
8198

82-
ConnectivityMonitor.disconnected();
99+
cv = new ConditionVariable();
100+
handler.post(new Runnable() {
101+
@Override
102+
public void run() {
103+
ConnectivityMonitor.disconnected();
104+
}
105+
});
106+
success = cv.block(1000);
107+
83108
assertEquals("Connectivity MockWebViewApp did not get one disconnect event", 1, webapp.getDisconnectedEvents());
84109

85-
ConnectivityMonitor.connected();
86-
assertEquals("Connectivity MockWebViewApp did not get one connect event", 1, webapp.getConnectedEvents());
110+
cv = new ConditionVariable();
111+
handler.post(new Runnable() {
112+
@Override
113+
public void run() {
114+
ConnectivityMonitor.connected();
115+
}
116+
});
117+
success = cv.block(1000);
118+
119+
assertTrue("Connectivity MockWebViewApp did not get connect event", webapp.getConnectedEvents() > 0);
87120
}
88121

89122
private class MockWebViewApp extends WebViewApp {
90123
private int _disconnectedEvents = 0;
91124
private int _connectedEvents = 0;
92125
boolean _callbackInvoked = false;
126+
Invocation _invocation = null;
127+
ConditionVariable _cv = null;
93128

94129
public WebViewCallback getCallback() {
95-
Invocation invocation = new Invocation();
96-
return new WebViewCallback("1234", invocation.getId());
130+
_invocation = new Invocation();
131+
return new WebViewCallback("1234", _invocation.getId());
132+
}
133+
134+
public Invocation getInvocation() {
135+
return _invocation;
136+
}
137+
138+
public void setCV(ConditionVariable cv) {
139+
_cv = cv;
97140
}
98141

99142
@Override
@@ -104,26 +147,43 @@ public boolean invokeCallback(Invocation invocation) {
104147
_callbackInvoked = true;
105148
}
106149

107-
return super.invokeCallback(invocation);
150+
openCVAndReset();
151+
152+
return true;
108153
}
109154

110155
public boolean getCallbackInvoked() {
111156
return _callbackInvoked;
112157
}
113158

159+
public void openCVAndReset () {
160+
if (_cv != null) {
161+
DeviceLog.debug("Opening CV");
162+
_cv.open();
163+
_cv = null;
164+
}
165+
if (_invocation != null) {
166+
_invocation = null;
167+
}
168+
}
169+
114170
@Override
115171
public boolean sendEvent(Enum eventCategory, Enum eventId, Object... params) {
116172
if(eventCategory != WebViewEventCategory.CONNECTIVITY) {
117173
throw new IllegalArgumentException("Event category not CONNECTIVITY");
118174
}
119175

176+
DeviceLog.debug("EVENT: " + eventId.name());
177+
120178
switch((ConnectivityEvent)eventId) {
121179
case CONNECTED:
122180
_connectedEvents++;
181+
openCVAndReset();
123182
break;
124183

125184
case DISCONNECTED:
126185
_disconnectedEvents++;
186+
openCVAndReset();
127187
break;
128188

129189
case NETWORK_CHANGE:

lib/src/androidTest/java/com/unity3d/ads/test/unit/MetaDataTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void testPlayerMetaData () throws Exception {
5959

6060
HashMap<String, Object> params = (HashMap<String, Object>)((MetaDataWebApp)WebViewApp.getCurrentApp()).PARAMS[1];
6161

62-
assertEquals("Metadata doesn't have correct amount of values", params.size(), 4 * 2);
62+
assertEquals("Metadata doesn't have correct amount of values", params.size(), 1 * 2);
6363

6464
HashMap<String, Object> metadataEntries = (HashMap<String, Object>)metaData.getEntries();
6565
for (String k : params.keySet()) {

lib/src/androidTest/java/com/unity3d/ads/test/unit/VideoViewTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,18 @@ public void run() {
458458

459459
assertTrue("Condition Variable was not opened: VIDEO PROGRESS or PREPARE ERROR event was not received", success);
460460

461+
int failedIntervals = 0;
462+
461463
for (int idx = 0; idx < EVENT_POSITIONS.size(); idx++) {
462464
if (idx + 1 < EVENT_POSITIONS.size()) {
463465
long interval = Math.abs(300 - (EVENT_POSITIONS.get(idx + 1) - EVENT_POSITIONS.get(idx)));
464466
DeviceLog.debug("Interval is: " + interval);
465-
assertFalse("Interval of the events weren't as accurate as expected (threshold of 70ms, was: " + interval + ")", interval > 70);
467+
468+
if (interval > 80) {
469+
failedIntervals++;
470+
}
471+
472+
assertFalse("Too many intervals failed to arrive in 80ms threshold (" + failedIntervals + ")", failedIntervals > 3);
466473
}
467474
}
468475

lib/src/main/java/com/unity3d/ads/UnityAds.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public static void initialize(final Activity activity, final String gameId, fina
133133
DeviceLog.info("Initializing Unity Ads " + SdkProperties.getVersionName() + " (" + SdkProperties.getVersionCode() + ") with game id " + gameId + " in production mode");
134134
}
135135

136+
setDebugMode(_debugMode);
137+
136138
ClientProperties.setGameId(gameId);
137139
ClientProperties.setListener(listener);
138140
ClientProperties.setApplicationContext(activity.getApplicationContext());

0 commit comments

Comments
 (0)