Skip to content

Commit

Permalink
Version 2.0.0-beta2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ville Orkas committed Jun 8, 2016
1 parent c1b2dc1 commit 3e7e14b
Show file tree
Hide file tree
Showing 18 changed files with 221 additions and 286 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 9
targetSdkVersion 23
versionCode = 2000
versionName = "2.0.0-beta1"
versionName = "2.0.0-beta2"
}
buildTypes {
release {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/unityads_example_background.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:angle="90" android:startColor="#FF222222" android:endColor="#ff555555"/>
<gradient android:angle="135" android:startColor="#FFAA2C54" android:endColor="#FF232C37"/>
</shape>
Binary file added app/src/main/res/drawable/unityads_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions app/src/main/res/layout/unityads_example_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
android:layout_height="match_parent"
android:background="@drawable/unityads_example_background">

<TextView android:layout_width="wrap_content"
<ImageView android:layout_width="280dp"
android:layout_height="wrap_content"
android:text="@string/unityads_example_product_name"
android:src="@drawable/unityads_logo"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_marginTop="40dp"
android:textSize="45sp"
android:textColor="#FFFFFFFF"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:id="@+id/unityads_example_title_text" />

<LinearLayout
Expand Down Expand Up @@ -88,7 +88,7 @@
android:layout_below="@id/unityads_example_config_container"
android:layout_centerHorizontal="true">

<Button android:background="#FFff0066"
<Button android:background="#FF2196F3"
android:id="@+id/unityads_example_initialize_button"
android:layout_width="130dp"
android:layout_height="45dp"
Expand All @@ -98,7 +98,7 @@
android:layout_marginBottom="15dp"
android:layout_marginRight="15dp"/>

<Button android:background="#FF19e3b1"
<Button android:background="#FF2196F3"
android:id="@+id/unityads_example_interstitial_button"
android:layout_width="130dp"
android:layout_height="45dp"
Expand All @@ -110,7 +110,7 @@
android:layout_marginRight="15dp"/>

<Button
android:background="#FF19e3b1"
android:background="#FF2196F3"
android:id="@+id/unityads_example_incentivized_button"
android:layout_width="130dp"
android:layout_height="45dp"
Expand Down
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:2.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
minSdkVersion 9
targetSdkVersion 23
versionCode = 2000
versionName = "2.0.0-beta1"
versionName = "2.0.0-beta2"

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

@RunWith(AndroidJUnit4.class)
public class InitializeThreadTest {
private String _configUrl;
private static final String _testConfigUrl = "https://www.example.net/test/webview.html";
private String _testConfigHash = "12345";
private Class[] _apiClassList = {com.unity3d.ads.api.Sdk.class};
Expand All @@ -40,8 +39,7 @@ public class InitializeThreadTest {
@Before
public void setup() throws MalformedURLException, URISyntaxException {
ClientProperties.setApplicationContext(InstrumentationRegistry.getTargetContext());
_configUrl = TestUtilities.getTestServerAddress() + "/testconfig.json";
SdkProperties.setConfigUrl(_configUrl);
SdkProperties.setConfigUrl(TestUtilities.getTestServerAddress() + "/testconfig.json");
}

@Test
Expand All @@ -63,27 +61,50 @@ public void run() {
WebViewApp.getCurrentApp().setWebAppLoaded(true);
SdkProperties.setInitialized(true);

Configuration config = new Configuration();
config.setWebAppApiClassList(_apiClassList);
InitializeThread.InitializeStateReset state = new InitializeThread.InitializeStateReset(config);
Configuration initConfig = new Configuration();
initConfig.setWebAppApiClassList(_apiClassList);
InitializeThread.InitializeStateReset state = new InitializeThread.InitializeStateReset(initConfig);
Object nextState = state.execute();

assertFalse("Init state reset test: SDK is initialized after SDK was reset", SdkProperties.isInitialized());
assertFalse("Init state reset test: webapp is loaded after SDK was reset", WebViewApp.getCurrentApp().isWebAppLoaded());
assertTrue("Init state reset test: next state is not config", nextState instanceof InitializeThread.InitializeStateAdBlockerCheck);

Configuration config = ((InitializeThread.InitializeStateAdBlockerCheck)nextState).getConfiguration();

assertEquals("Init state reset test: next state config url is not set", config.getConfigUrl(), SdkProperties.getConfigUrl());
}

@Test
public void testInitializeStateAdBlockerCheck() {
Configuration goodConfig = new Configuration();
goodConfig.setConfigUrl("http://www.unity3d.com/test");
InitializeThread.InitializeStateAdBlockerCheck state = new InitializeThread.InitializeStateAdBlockerCheck(goodConfig);
Object nextState = state.execute();

assertFalse("Init state reset test: SDK is not initialized", SdkProperties.isInitialized());
assertFalse("Init state reset test: webapp is not loaded", WebViewApp.getCurrentApp().isWebAppLoaded());
assertTrue("Init state reset test: next state is config", nextState instanceof InitializeThread.InitializeStateConfig);
assertTrue("Init state ad blocker check test: next state is not load config", nextState instanceof InitializeThread.InitializeStateConfig);

Configuration badConfig = new Configuration();
badConfig.setConfigUrl("http://localhost/test");
InitializeThread.InitializeStateAdBlockerCheck state2 = new InitializeThread.InitializeStateAdBlockerCheck(badConfig);
Object nextState2 = state2.execute();

assertNull("Init state ad blocker check test: next state is not null", nextState2);
}

@Test
public void testInitializeStateConfig() {
InitializeThread.InitializeStateConfig state = new InitializeThread.InitializeStateConfig(new Configuration());
Configuration initConfig = new Configuration();
initConfig.setConfigUrl(SdkProperties.getConfigUrl());
InitializeThread.InitializeStateConfig state = new InitializeThread.InitializeStateConfig(initConfig);
Object nextState = state.execute();

assertTrue("Init state config test: next state is load cache", nextState instanceof InitializeThread.InitializeStateLoadCache);
assertTrue("Init state config test: next state is not load cache", nextState instanceof InitializeThread.InitializeStateLoadCache);

Configuration config = ((InitializeThread.InitializeStateLoadCache)nextState).getConfiguration();

assertEquals("Init state config test: config webview url matches url in testconfig.json", config.getWebViewUrl(), _testConfigUrl);
assertEquals("Init state config test: config webview hash matches hash in testconfig.json", config.getWebViewHash(), _testConfigHash);
assertEquals("Init state config test: config webview url does not match url in testconfig.json", config.getWebViewUrl(), _testConfigUrl);
assertEquals("Init state config test: config webview hash does not match hash in testconfig.json", config.getWebViewHash(), _testConfigHash);
}

// Test for cache load fail case, success case is handled in load web test
Expand All @@ -97,12 +118,12 @@ public void testInitializeStateLoadCache() {
InitializeThread.InitializeStateLoadCache state = new InitializeThread.InitializeStateLoadCache(bogusConfig);
Object nextState = state.execute();

assertTrue("Init state load cache test: bogus config means cached webview is not found and next state is load web ", nextState instanceof InitializeThread.InitializeStateLoadWeb);
assertTrue("Init state load cache test: init is not loading from web with bogus config ", nextState instanceof InitializeThread.InitializeStateLoadWeb);

Configuration webConfig = ((InitializeThread.InitializeStateLoadWeb)nextState).getConfiguration();

assertEquals("Init state load cache test: load web config url is correct", webConfig.getWebViewUrl(), _testConfigUrl);
assertEquals("Init state load cache test: load web config hash is correct", webConfig.getWebViewHash(), _testConfigHash);
assertEquals("Init state load cache test: load web config url is not correct", webConfig.getWebViewUrl(), _testConfigUrl);
assertEquals("Init state load cache test: load web config hash is not correct", webConfig.getWebViewHash(), _testConfigHash);
}

@Test
Expand All @@ -118,30 +139,30 @@ public void testInitializeStateLoadWeb() {
InitializeThread.InitializeStateLoadWeb state = new InitializeThread.InitializeStateLoadWeb(webConfig);
Object nextState = state.execute();

assertTrue("Init state load web test: next state is create", nextState instanceof InitializeThread.InitializeStateCreate);
assertTrue("Init state load web test: next state is not create", nextState instanceof InitializeThread.InitializeStateCreate);

Configuration createConfig = ((InitializeThread.InitializeStateCreate)nextState).getConfiguration();

assertEquals("Init state load web test: original webview url matches created url", webUrl, createConfig.getWebViewUrl());
assertEquals("Init state load web test: original webview hash matches created hash", webHash, createConfig.getWebViewHash());
assertEquals("Init state load web test: original webview url does not match created url", webUrl, createConfig.getWebViewUrl());
assertEquals("Init state load web test: original webview hash does not match created hash", webHash, createConfig.getWebViewHash());

String createWebData = ((InitializeThread.InitializeStateCreate)nextState).getWebData();

assertEquals("Init state load web test: original webview content matches created webview content", webData, createWebData);
assertEquals("Init state load web test: original webview content does not match created webview content", webData, createWebData);

InitializeThread.InitializeStateLoadCache state2 = new InitializeThread.InitializeStateLoadCache(webConfig);
Object nextState2 = state2.execute();

assertTrue("Init state load web test: webapp was successfully cached", nextState2 instanceof InitializeThread.InitializeStateCreate);
assertTrue("Init state load web test: webapp was not successfully cached", nextState2 instanceof InitializeThread.InitializeStateCreate);

Configuration createConfig2 = ((InitializeThread.InitializeStateCreate)nextState2).getConfiguration();

assertEquals("Init state load web test: cached webview url matches created url", webUrl, createConfig2.getWebViewUrl());
assertEquals("Init state load web test: cached webview hash matches created hash", webHash, createConfig2.getWebViewHash());
assertEquals("Init state load web test: cached webview url does not match created url", webUrl, createConfig2.getWebViewUrl());
assertEquals("Init state load web test: cached webview hash does not match created hash", webHash, createConfig2.getWebViewHash());

String createWebData2 = ((InitializeThread.InitializeStateCreate)nextState2).getWebData();

assertEquals("Init state load web test: cached webview content matches created webview content", webData, createWebData2);
assertEquals("Init state load web test: cached webview content does not match created webview content", webData, createWebData2);
}

@Test
Expand All @@ -163,15 +184,15 @@ public void testInitializeStateCreate() {
InitializeThread.InitializeStateCreate state = new InitializeThread.InitializeStateCreate(config, data);
Object nextState = state.execute();

assertTrue("Init state create test: next state is complete", nextState instanceof InitializeThread.InitializeStateComplete);
assertTrue("Init state create test: next state is not complete", nextState instanceof InitializeThread.InitializeStateComplete);
}

@Test
public void testInitializeStateComplete() {
InitializeThread.InitializeStateComplete state = new InitializeThread.InitializeStateComplete();
Object nextState = state.execute();

assertNull("Init state complete test: next step must be null", nextState);
assertNull("Init state complete test: next step is not null", nextState);
}

@Test
Expand Down
Loading

0 comments on commit 3e7e14b

Please sign in to comment.