Fix test compilation and run test with success
Using command `./gradlew connectedAndroidTest` on an API 21 emulator
This commit is contained in:
parent
4d2522a65c
commit
1694f15ffb
8 changed files with 119 additions and 120 deletions
|
@ -19,4 +19,5 @@
|
||||||
#systemProp.https.proxyHost=batproxy
|
#systemProp.https.proxyHost=batproxy
|
||||||
#systemProp.http.proxyPort=8080
|
#systemProp.http.proxyPort=8080
|
||||||
|
|
||||||
|
android.useAndroidX=true
|
||||||
org.gradle.configureondemand=false
|
org.gradle.configureondemand=false
|
||||||
|
|
|
@ -6,9 +6,14 @@ android {
|
||||||
compileSdkVersion 30
|
compileSdkVersion 30
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 11
|
minSdkVersion 14
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
// The following argument makes the Android Test Orchestrator run its
|
||||||
|
// "pm clear" command after each test invocation. This command ensures
|
||||||
|
// that the app's state is completely cleared between tests.
|
||||||
|
testInstrumentationRunnerArguments clearPackageData: 'true'
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
|
@ -118,6 +123,8 @@ dependencies {
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'junit:junit:4.13.2'
|
androidTestImplementation 'junit:junit:4.13.2'
|
||||||
|
|
||||||
|
androidTestImplementation 'androidx.test:core:1.3.0'
|
||||||
androidTestImplementation 'androidx.test:runner:1.3.0'
|
androidTestImplementation 'androidx.test:runner:1.3.0'
|
||||||
androidTestImplementation 'androidx.test:rules:1.3.0'
|
androidTestImplementation 'androidx.test:rules:1.3.0'
|
||||||
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
package org.matrix.olm;
|
package org.matrix.olm;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import org.json.JSONObject;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -41,7 +41,6 @@ import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static android.support.test.InstrumentationRegistry.getInstrumentation;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
@ -65,7 +64,7 @@ public class OlmAccountTest {
|
||||||
|
|
||||||
String olmLibVersion = mOlmManager.getOlmLibVersion();
|
String olmLibVersion = mOlmManager.getOlmLibVersion();
|
||||||
assertNotNull(olmLibVersion);
|
assertNotNull(olmLibVersion);
|
||||||
String olmSdkVersion = mOlmManager.getDetailedVersion(getInstrumentation().getContext());
|
String olmSdkVersion = mOlmManager.getDetailedVersion(ApplicationProvider.getApplicationContext());
|
||||||
assertNotNull(olmLibVersion);
|
assertNotNull(olmLibVersion);
|
||||||
Log.d(LOG_TAG, "## setUpClass(): Versions - Android Olm SDK = " + olmSdkVersion + " Olm lib =" + olmLibVersion);
|
Log.d(LOG_TAG, "## setUpClass(): Versions - Android Olm SDK = " + olmSdkVersion + " Olm lib =" + olmLibVersion);
|
||||||
}
|
}
|
||||||
|
@ -298,7 +297,7 @@ public class OlmAccountTest {
|
||||||
assertNotNull(oneTimeKeysRef);
|
assertNotNull(oneTimeKeysRef);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Context context = getInstrumentation().getContext();
|
Context context = ApplicationProvider.getApplicationContext();
|
||||||
//context.getFilesDir();
|
//context.getFilesDir();
|
||||||
fileOutput = context.openFileOutput(FILE_NAME, Context.MODE_PRIVATE);
|
fileOutput = context.openFileOutput(FILE_NAME, Context.MODE_PRIVATE);
|
||||||
|
|
||||||
|
@ -329,23 +328,19 @@ public class OlmAccountTest {
|
||||||
|
|
||||||
accountRef.releaseAccount();
|
accountRef.releaseAccount();
|
||||||
accountDeserial.releaseAccount();
|
accountDeserial.releaseAccount();
|
||||||
}
|
} catch (FileNotFoundException e) {
|
||||||
catch (FileNotFoundException e) {
|
|
||||||
Log.e(LOG_TAG, "## test13Serialization(): Exception FileNotFoundException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test13Serialization(): Exception FileNotFoundException Msg==" + e.getMessage());
|
||||||
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
||||||
}
|
} catch (ClassNotFoundException e) {
|
||||||
catch (ClassNotFoundException e) {
|
|
||||||
Log.e(LOG_TAG, "## test13Serialization(): Exception ClassNotFoundException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test13Serialization(): Exception ClassNotFoundException Msg==" + e.getMessage());
|
||||||
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e) {
|
|
||||||
Log.e(LOG_TAG, "## test13Serialization(): Exception IOException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test13Serialization(): Exception IOException Msg==" + e.getMessage());
|
||||||
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
/*catch (OlmException e) {
|
/*catch (OlmException e) {
|
||||||
Log.e(LOG_TAG, "## test13Serialization(): Exception OlmException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test13Serialization(): Exception OlmException Msg==" + e.getMessage());
|
||||||
}*/
|
}*/ catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
Log.e(LOG_TAG, "## test13Serialization(): Exception Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test13Serialization(): Exception Msg==" + e.getMessage());
|
||||||
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
assertTrue("test13Serialization failed " + e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,12 @@
|
||||||
package org.matrix.olm;
|
package org.matrix.olm;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -36,7 +38,6 @@ import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
import static android.support.test.InstrumentationRegistry.getInstrumentation;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
@ -223,7 +224,7 @@ public class OlmGroupSessionTest {
|
||||||
|
|
||||||
|
|
||||||
// serialize alice session
|
// serialize alice session
|
||||||
Context context = getInstrumentation().getContext();
|
Context context = ApplicationProvider.getApplicationContext();
|
||||||
try {
|
try {
|
||||||
FileOutputStream fileOutput = context.openFileOutput(FILE_NAME_SERIAL_OUT_SESSION, Context.MODE_PRIVATE);
|
FileOutputStream fileOutput = context.openFileOutput(FILE_NAME_SERIAL_OUT_SESSION, Context.MODE_PRIVATE);
|
||||||
ObjectOutputStream objectOutput = new ObjectOutputStream(fileOutput);
|
ObjectOutputStream objectOutput = new ObjectOutputStream(fileOutput);
|
||||||
|
@ -312,7 +313,7 @@ public class OlmGroupSessionTest {
|
||||||
assertNotNull(bobInboundGroupSessionRef);
|
assertNotNull(bobInboundGroupSessionRef);
|
||||||
|
|
||||||
// serialize alice session
|
// serialize alice session
|
||||||
Context context = getInstrumentation().getContext();
|
Context context = ApplicationProvider.getApplicationContext();
|
||||||
try {
|
try {
|
||||||
FileOutputStream fileOutput = context.openFileOutput(FILE_NAME_SERIAL_IN_SESSION, Context.MODE_PRIVATE);
|
FileOutputStream fileOutput = context.openFileOutput(FILE_NAME_SERIAL_IN_SESSION, Context.MODE_PRIVATE);
|
||||||
ObjectOutputStream objectOutput = new ObjectOutputStream(fileOutput);
|
ObjectOutputStream objectOutput = new ObjectOutputStream(fileOutput);
|
||||||
|
|
|
@ -16,20 +16,18 @@
|
||||||
|
|
||||||
package org.matrix.olm;
|
package org.matrix.olm;
|
||||||
|
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.MethodSorters;
|
import org.junit.runners.MethodSorters;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
|
|
||||||
package org.matrix.olm;
|
package org.matrix.olm;
|
||||||
|
|
||||||
|
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -18,11 +18,12 @@
|
||||||
package org.matrix.olm;
|
package org.matrix.olm;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -37,7 +38,6 @@ import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static android.support.test.InstrumentationRegistry.getInstrumentation;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
@ -601,6 +601,7 @@ public class OlmSessionTest {
|
||||||
// ********************************************************
|
// ********************************************************
|
||||||
// ************* SERIALIZATION TEST ***********************
|
// ************* SERIALIZATION TEST ***********************
|
||||||
// ********************************************************
|
// ********************************************************
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as {@link #test02AliceToBobBackAndForth()}, but alice's session
|
* Same as {@link #test02AliceToBobBackAndForth()}, but alice's session
|
||||||
* is serialized and de-serialized before performing the final
|
* is serialized and de-serialized before performing the final
|
||||||
|
@ -745,7 +746,7 @@ public class OlmSessionTest {
|
||||||
assertNotNull(encryptedMsg3);
|
assertNotNull(encryptedMsg3);
|
||||||
|
|
||||||
// serialize alice session
|
// serialize alice session
|
||||||
Context context = getInstrumentation().getContext();
|
Context context = ApplicationProvider.getApplicationContext();
|
||||||
try {
|
try {
|
||||||
FileOutputStream fileOutput = context.openFileOutput(FILE_NAME_SERIAL_SESSION, Context.MODE_PRIVATE);
|
FileOutputStream fileOutput = context.openFileOutput(FILE_NAME_SERIAL_SESSION, Context.MODE_PRIVATE);
|
||||||
ObjectOutputStream objectOutput = new ObjectOutputStream(fileOutput);
|
ObjectOutputStream objectOutput = new ObjectOutputStream(fileOutput);
|
||||||
|
@ -793,23 +794,19 @@ public class OlmSessionTest {
|
||||||
assertTrue(bobSession.isReleased());
|
assertTrue(bobSession.isReleased());
|
||||||
assertTrue(aliceSession.isReleased());
|
assertTrue(aliceSession.isReleased());
|
||||||
assertTrue(aliceSessionDeserial.isReleased());
|
assertTrue(aliceSessionDeserial.isReleased());
|
||||||
}
|
} catch (FileNotFoundException e) {
|
||||||
catch (FileNotFoundException e) {
|
|
||||||
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception FileNotFoundException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception FileNotFoundException Msg==" + e.getMessage());
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
} catch (ClassNotFoundException e) {
|
||||||
catch (ClassNotFoundException e) {
|
|
||||||
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception ClassNotFoundException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception ClassNotFoundException Msg==" + e.getMessage());
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e) {
|
|
||||||
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception IOException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception IOException Msg==" + e.getMessage());
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
/*catch (OlmException e) {
|
/*catch (OlmException e) {
|
||||||
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception OlmException Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception OlmException Msg==" + e.getMessage());
|
||||||
}*/
|
}*/ catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception Msg==" + e.getMessage());
|
Log.e(LOG_TAG, "## test03SessionSerialization(): Exception Msg==" + e.getMessage());
|
||||||
assertTrue(e.getMessage(), false);
|
assertTrue(e.getMessage(), false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
|
|
||||||
package org.matrix.olm;
|
package org.matrix.olm;
|
||||||
|
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
Loading…
Reference in a new issue