Bug 1433322 - 2. Mass move GeckoView unit tests to under geckoview/; r=nalexander draft
authorJim Chen <nchen@mozilla.com>
Thu, 01 Feb 2018 16:48:38 -0500
changeset 750311 05e73da3a9d4192d2f72184f1b86a7fe32083787
parent 750310 359ecf316af4527caa11541848c2bf40399b3265
child 750312 4d14b4cef0d98d0156ca4971d6c4de24d25db543
push id97617
push userbmo:nchen@mozilla.com
push dateThu, 01 Feb 2018 21:49:08 +0000
reviewersnalexander
bugs1433322
milestone60.0a1
Bug 1433322 - 2. Mass move GeckoView unit tests to under geckoview/; r=nalexander These tests involve GeckoView classes, so move them to under geckoview/. We use a custom test runner for Fennec unit tests, but I didn't notice any problems when using standard test runners (e.g. MockitoJUnitRunner), so I changed these tests to use standard runners. MozReview-Commit-ID: 7JMhqJqahTC
mobile/android/app/src/test/java/org/mozilla/gecko/permissions/TestPermissions.java
mobile/android/app/src/test/java/org/mozilla/gecko/util/NetworkUtilsTest.java
mobile/android/app/src/test/java/org/mozilla/gecko/util/TestContextUtils.java
mobile/android/app/src/test/java/org/mozilla/gecko/util/TestDateUtil.java
mobile/android/app/src/test/java/org/mozilla/gecko/util/TestFileUtils.java
mobile/android/app/src/test/java/org/mozilla/gecko/util/TestFloatUtils.java
mobile/android/app/src/test/java/org/mozilla/gecko/util/TestIntentUtils.java
mobile/android/app/src/test/java/org/mozilla/gecko/util/TestStringUtils.java
mobile/android/app/src/test/java/org/mozilla/gecko/util/TestUUIDUtil.java
mobile/android/geckoview/src/test/java/org/mozilla/gecko/permissions/TestPermissions.java
mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/NetworkUtilsTest.java
mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestContextUtils.java
mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestDateUtil.java
mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestFileUtils.java
mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestFloatUtils.java
mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestIntentUtils.java
mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestStringUtils.java
mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestUUIDUtil.java
rename from mobile/android/app/src/test/java/org/mozilla/gecko/permissions/TestPermissions.java
rename to mobile/android/geckoview/src/test/java/org/mozilla/gecko/permissions/TestPermissions.java
--- a/mobile/android/app/src/test/java/org/mozilla/gecko/permissions/TestPermissions.java
+++ b/mobile/android/geckoview/src/test/java/org/mozilla/gecko/permissions/TestPermissions.java
@@ -8,22 +8,21 @@ package org.mozilla.gecko.permissions;
 import android.Manifest;
 import android.app.Activity;
 import android.content.Context;
 import android.content.pm.PackageManager;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Matchers;
-
-import org.mozilla.gecko.background.testhelpers.TestRunner;
+import org.mockito.runners.MockitoJUnitRunner;
 
 import static org.mockito.Mockito.*;
 
-@RunWith(TestRunner.class)
+@RunWith(MockitoJUnitRunner.class)
 public class TestPermissions {
     @Test
     public void testSuccessRunnableIsExecutedIfPermissionsAreGranted() {
         Permissions.setPermissionHelper(mockGrantingHelper());
 
         Runnable onPermissionsGranted = mock(Runnable.class);
         Runnable onPermissionsDenied = mock(Runnable.class);
 
rename from mobile/android/app/src/test/java/org/mozilla/gecko/util/NetworkUtilsTest.java
rename to mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/NetworkUtilsTest.java
--- a/mobile/android/app/src/test/java/org/mozilla/gecko/util/NetworkUtilsTest.java
+++ b/mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/NetworkUtilsTest.java
@@ -6,30 +6,30 @@ package org.mozilla.gecko.util;
 import android.content.Context;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
 import android.telephony.TelephonyManager;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mozilla.gecko.background.testhelpers.TestRunner;
 import org.mozilla.gecko.util.NetworkUtils.ConnectionSubType;
 import org.mozilla.gecko.util.NetworkUtils.ConnectionType;
 import org.mozilla.gecko.util.NetworkUtils.NetworkStatus;
+import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadow.api.Shadow;
 import org.robolectric.shadows.ShadowConnectivityManager;
 import org.robolectric.shadows.ShadowNetworkInfo;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-@RunWith(TestRunner.class)
+@RunWith(RobolectricTestRunner.class)
 public class NetworkUtilsTest {
     private ConnectivityManager connectivityManager;
     private ShadowConnectivityManager shadowConnectivityManager;
 
     @Before
     public void setUp() {
         connectivityManager = (ConnectivityManager) RuntimeEnvironment.application.getSystemService(Context.CONNECTIVITY_SERVICE);
 
rename from mobile/android/app/src/test/java/org/mozilla/gecko/util/TestContextUtils.java
rename to mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestContextUtils.java
--- a/mobile/android/app/src/test/java/org/mozilla/gecko/util/TestContextUtils.java
+++ b/mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestContextUtils.java
@@ -5,25 +5,25 @@
  */
 
 package org.mozilla.gecko.util;
 
 import android.content.Context;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mozilla.gecko.background.testhelpers.TestRunner;
+import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 
 import static org.junit.Assert.*;
 
 /**
  * Unit test methods of the ContextUtils class.
  */
-@RunWith(TestRunner.class)
+@RunWith(RobolectricTestRunner.class)
 public class TestContextUtils {
 
     private Context context;
 
     @Before
     public void setUp() {
         context = RuntimeEnvironment.application;
     }
rename from mobile/android/app/src/test/java/org/mozilla/gecko/util/TestDateUtil.java
rename to mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestDateUtil.java
--- a/mobile/android/app/src/test/java/org/mozilla/gecko/util/TestDateUtil.java
+++ b/mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestDateUtil.java
@@ -2,30 +2,27 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, you can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 package org.mozilla.gecko.util;
 
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mozilla.gecko.background.testhelpers.TestRunner;
 
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 import java.util.Locale;
 import java.util.TimeZone;
 
 import static org.junit.Assert.assertEquals;
 
 /**
  * Unit tests for date utilities.
  */
-@RunWith(TestRunner.class)
 public class TestDateUtil {
     @Test
     public void testGetDateInHTTPFormatGMT() {
         final TimeZone gmt = TimeZone.getTimeZone("GMT");
         final GregorianCalendar calendar = new GregorianCalendar(gmt, Locale.US);
         calendar.set(2011, Calendar.FEBRUARY, 1, 14, 0, 0);
         final String expectedDate = "Tue, 01 Feb 2011 14:00:00 GMT";
 
rename from mobile/android/app/src/test/java/org/mozilla/gecko/util/TestFileUtils.java
rename to mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestFileUtils.java
--- a/mobile/android/app/src/test/java/org/mozilla/gecko/util/TestFileUtils.java
+++ b/mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestFileUtils.java
@@ -10,20 +10,20 @@ import org.json.JSONException;
 import org.json.JSONObject;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.junit.runner.RunWith;
 import org.mockito.Matchers;
-import org.mozilla.gecko.background.testhelpers.TestRunner;
 import org.mozilla.gecko.util.FileUtils.FileLastModifiedComparator;
 import org.mozilla.gecko.util.FileUtils.FilenameRegexFilter;
 import org.mozilla.gecko.util.FileUtils.FilenameWhitelistFilter;
+import org.robolectric.RobolectricTestRunner;
 
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
@@ -39,17 +39,17 @@ import static org.hamcrest.Matchers.not;
 import static org.hamcrest.Matchers.nullValue;
 import static org.junit.Assert.assertThat;
 import static org.mockito.Matchers.notNull;
 import static org.mockito.Mockito.*;
 
 /**
  * Tests the utilities in {@link FileUtils}.
  */
-@RunWith(TestRunner.class)
+@RunWith(RobolectricTestRunner.class)
 public class TestFileUtils {
 
     private static final Charset CHARSET = Charset.forName("UTF-8");
 
     @Rule
     public TemporaryFolder tempDir = new TemporaryFolder();
     public File testFile;
     public File nonExistentFile;
rename from mobile/android/app/src/test/java/org/mozilla/gecko/util/TestFloatUtils.java
rename to mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestFloatUtils.java
--- a/mobile/android/app/src/test/java/org/mozilla/gecko/util/TestFloatUtils.java
+++ b/mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestFloatUtils.java
@@ -2,29 +2,26 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, you can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 package org.mozilla.gecko.util;
 
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mozilla.gecko.background.testhelpers.TestRunner;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
 
 
 /**
  * Unit tests for float utilities.
  */
-@RunWith(TestRunner.class)
 public class TestFloatUtils {
 
     @Test
     public void testEqualIfComparingZeros() {
         assertTrue(FloatUtils.fuzzyEquals(0, 0));
     }
 
     @Test
rename from mobile/android/app/src/test/java/org/mozilla/gecko/util/TestIntentUtils.java
rename to mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestIntentUtils.java
--- a/mobile/android/app/src/test/java/org/mozilla/gecko/util/TestIntentUtils.java
+++ b/mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestIntentUtils.java
@@ -2,32 +2,33 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, you can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 package org.mozilla.gecko.util;
 
 import android.content.Intent;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mozilla.gecko.background.testhelpers.TestRunner;
 import org.mozilla.gecko.mozglue.SafeIntent;
+import org.robolectric.RobolectricTestRunner;
 
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
 import static org.junit.Assert.*;
 
 /**
  * Tests for the Intent utilities.
  */
-@RunWith(TestRunner.class)
+@RunWith(RobolectricTestRunner.class)
 public class TestIntentUtils {
 
     private static final Map<String, String> TEST_ENV_VAR_MAP;
     static {
         final HashMap<String, String> tempMap = new HashMap<>();
         tempMap.put("ZERO", "0");
         tempMap.put("ONE", "1");
         tempMap.put("STRING", "TEXT");
@@ -65,9 +66,9 @@ public class TestIntentUtils {
             assertTrue("Actual key exists in test data: " + actualEnvVarName,
                     TEST_ENV_VAR_MAP.containsKey(actualEnvVarName));
 
             final String expectedValue = TEST_ENV_VAR_MAP.get(actualEnvVarName);
             final String actualValue = actual.get(actualEnvVarName);
             assertEquals("Actual env var value matches test data", expectedValue, actualValue);
         }
     }
-}
\ No newline at end of file
+}
rename from mobile/android/app/src/test/java/org/mozilla/gecko/util/TestStringUtils.java
rename to mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestStringUtils.java
--- a/mobile/android/app/src/test/java/org/mozilla/gecko/util/TestStringUtils.java
+++ b/mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestStringUtils.java
@@ -2,26 +2,26 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.util;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mozilla.gecko.background.testhelpers.TestRunner;
+import org.robolectric.RobolectricTestRunner;
 
 import java.util.Arrays;
 import java.util.Collections;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-@RunWith(TestRunner.class)
+@RunWith(RobolectricTestRunner.class)
 public class TestStringUtils {
     @Test
     public void testIsHttpOrHttps() {
         // No value
         assertFalse(StringUtils.isHttpOrHttps(null));
         assertFalse(StringUtils.isHttpOrHttps(""));
 
         // Garbage
rename from mobile/android/app/src/test/java/org/mozilla/gecko/util/TestUUIDUtil.java
rename to mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestUUIDUtil.java
--- a/mobile/android/app/src/test/java/org/mozilla/gecko/util/TestUUIDUtil.java
+++ b/mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/TestUUIDUtil.java
@@ -2,25 +2,22 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, you can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 package org.mozilla.gecko.util;
 
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mozilla.gecko.background.testhelpers.TestRunner;
 
 import static org.junit.Assert.*;
 
 /**
  * Tests for uuid utils.
  */
-@RunWith(TestRunner.class)
 public class TestUUIDUtil {
     private static final String[] validUUIDs = {
         "904cd9f8-af63-4525-8ce0-b9127e5364fa",
         "8d584bd2-00ea-4043-a617-ed4ce7018ed0",
         "3abad327-2669-4f68-b9ef-7ace8c5314d6",
     };
 
     private static final String[] invalidUUIDs = {