summaryrefslogtreecommitdiff
path: root/app/src/test/java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2018-02-06 16:28:34 +0100
committercyBerta <cyberta@riseup.net>2018-02-06 16:28:34 +0100
commit3d827e7295d37ecb25332b39057338496f6f970d (patch)
treef8c5272e125ed9abae72fb3598d25b1c09f06f89 /app/src/test/java
parent646e2ec7b868920f71c29243d2bbeb13deb811e3 (diff)
parentedd34192484f4eb618fdcc2a68b18168c155d63c (diff)
Merge branch 'origin_0.9.8' into 8823_cw_tablet_layout
Diffstat (limited to 'app/src/test/java')
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/ConfigHelperTest.java4
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java16
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java (renamed from app/src/test/java/se/leap/bitmaskclient/testutils/TestSetupHelper.java)42
3 files changed, 13 insertions, 49 deletions
diff --git a/app/src/test/java/se/leap/bitmaskclient/ConfigHelperTest.java b/app/src/test/java/se/leap/bitmaskclient/ConfigHelperTest.java
index a9a5733d..84f38086 100644
--- a/app/src/test/java/se/leap/bitmaskclient/ConfigHelperTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/ConfigHelperTest.java
@@ -6,9 +6,9 @@ import org.junit.Before;
import org.junit.Test;
import se.leap.bitmaskclient.testutils.MockSharedPreferences;
-import se.leap.bitmaskclient.testutils.TestSetupHelper;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static se.leap.bitmaskclient.Constants.PROVIDER_CONFIGURED;
import static se.leap.bitmaskclient.testutils.TestSetupHelper.getInputAsString;
diff --git a/app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java b/app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java
index f04ec0eb..c23e4f49 100644
--- a/app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/eip/ProviderApiManagerTest.java
@@ -52,14 +52,14 @@ import static se.leap.bitmaskclient.ProviderAPI.RESULT_KEY;
import static se.leap.bitmaskclient.testutils.BackendMockResponses.BackendMockProvider.TestBackendErrorCase.ERROR_CASE_UPDATED_CERTIFICATE;
import static se.leap.bitmaskclient.testutils.BackendMockResponses.BackendMockProvider.TestBackendErrorCase.NO_ERROR;
import static se.leap.bitmaskclient.testutils.TestSetupHelper.getInputAsString;
-import static se.leap.bitmaskclient.testutils.TestSetupHelper.mockBundle;
-import static se.leap.bitmaskclient.testutils.TestSetupHelper.mockClientGenerator;
-import static se.leap.bitmaskclient.testutils.TestSetupHelper.mockFingerprintForCertificate;
-import static se.leap.bitmaskclient.testutils.TestSetupHelper.mockIntent;
-import static se.leap.bitmaskclient.testutils.TestSetupHelper.mockProviderApiConnector;
-import static se.leap.bitmaskclient.testutils.TestSetupHelper.mockResources;
-import static se.leap.bitmaskclient.testutils.TestSetupHelper.mockResultReceiver;
-import static se.leap.bitmaskclient.testutils.TestSetupHelper.mockTextUtils;
+import static se.leap.bitmaskclient.testutils.MockHelper.mockBundle;
+import static se.leap.bitmaskclient.testutils.MockHelper.mockClientGenerator;
+import static se.leap.bitmaskclient.testutils.MockHelper.mockFingerprintForCertificate;
+import static se.leap.bitmaskclient.testutils.MockHelper.mockIntent;
+import static se.leap.bitmaskclient.testutils.MockHelper.mockProviderApiConnector;
+import static se.leap.bitmaskclient.testutils.MockHelper.mockResources;
+import static se.leap.bitmaskclient.testutils.MockHelper.mockResultReceiver;
+import static se.leap.bitmaskclient.testutils.MockHelper.mockTextUtils;
/**
diff --git a/app/src/test/java/se/leap/bitmaskclient/testutils/TestSetupHelper.java b/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java
index f8f70eaf..8372c9bc 100644
--- a/app/src/test/java/se/leap/bitmaskclient/testutils/TestSetupHelper.java
+++ b/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java
@@ -1,20 +1,3 @@
-/**
- * Copyright (c) 2018 LEAP Encryption Access Project and contributers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
package se.leap.bitmaskclient.testutils;
import android.content.Intent;
@@ -30,10 +13,8 @@ import org.json.JSONObject;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
@@ -65,25 +46,10 @@ import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
/**
- * Created by cyberta on 08.10.17.
+ * Created by cyberta on 29.01.18.
*/
-public class TestSetupHelper {
-
-
-
- public static String getInputAsString(InputStream fileAsInputStream) throws IOException {
- BufferedReader br = new BufferedReader(new InputStreamReader(fileAsInputStream));
- StringBuilder sb = new StringBuilder();
- String line = br.readLine();
- while (line != null) {
- sb.append(line);
- line = br.readLine();
- }
-
- return sb.toString();
- }
-
+public class MockHelper {
@NonNull
public static Bundle mockBundle() {
final Map<String, Boolean> fakeBooleanBundle = new HashMap<>();
@@ -335,7 +301,6 @@ public class TestSetupHelper {
});
}
-
public static ResultReceiver mockResultReceiver(final int expectedResultCode, final Bundle expectedBundle) {
ResultReceiver resultReceiver = mock(ResultReceiver.class);
@@ -395,7 +360,7 @@ public class TestSetupHelper {
public static Resources mockResources(InputStream inputStream) throws IOException, JSONException {
Resources mockedResources = mock(Resources.class, RETURNS_DEEP_STUBS);
- JSONObject errorMessages = new JSONObject(getInputAsString(inputStream));
+ JSONObject errorMessages = new JSONObject(TestSetupHelper.getInputAsString(inputStream));
when(mockedResources.getString(R.string.warning_corrupted_provider_details)).
@@ -430,5 +395,4 @@ public class TestSetupHelper {
thenReturn(errorMessages.getString("warning_expired_provider_cert"));
return mockedResources;
}
-
}