Bug 943703 - Moved helper initialization to a separate static function.
authorIsura Edirisinghe <isurae@gmail.com>
Mon, 06 Jan 2014 14:50:38 -0800
changeset 179262 96088a8ba7386a84273189e5cd471f16eef1d533
parent 179261 a58fd917dead962ff03314d72ab7bd2fdc380261
child 179263 1720e3409e728588a66de93ae820a938b739233d
push id462
push userraliiev@mozilla.com
push dateTue, 22 Apr 2014 00:22:30 +0000
treeherdermozilla-release@ac5db8c74ac0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs943703
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 943703 - Moved helper initialization to a separate static function.
mobile/android/base/tests/UITest.java
mobile/android/base/tests/helpers/AssertionHelper.java
mobile/android/base/tests/helpers/DeviceHelper.java
mobile/android/base/tests/helpers/GeckoHelper.java
mobile/android/base/tests/helpers/HelperInitializer.java
mobile/android/base/tests/helpers/NavigationHelper.java
mobile/android/base/tests/helpers/WaitHelper.java
--- a/mobile/android/base/tests/UITest.java
+++ b/mobile/android/base/tests/UITest.java
@@ -8,17 +8,17 @@ import org.mozilla.gecko.Actions;
 import org.mozilla.gecko.Assert;
 import org.mozilla.gecko.Driver;
 import org.mozilla.gecko.FennecInstrumentationTestRunner;
 import org.mozilla.gecko.FennecMochitestAssert;
 import org.mozilla.gecko.FennecNativeActions;
 import org.mozilla.gecko.FennecNativeDriver;
 import org.mozilla.gecko.FennecTalosAssert;
 import org.mozilla.gecko.tests.components.*;
-import org.mozilla.gecko.tests.helpers.*;
+import org.mozilla.gecko.tests.helpers.HelperInitializer;
 
 import com.jayway.android.robotium.solo.Solo;
 
 import android.app.Activity;
 import android.content.Intent;
 import android.test.ActivityInstrumentationTestCase2;
 import android.text.TextUtils;
 
@@ -116,23 +116,17 @@ abstract class UITest extends ActivityIn
     }
 
     private void initComponents() {
         mAboutHome = new AboutHomeComponent(this);
         mToolbar = new ToolbarComponent(this);
     }
 
     private void initHelpers() {
-        // Other helpers make assertions so init AssertionHelper first.
-        AssertionHelper.init(this);
-
-        DeviceHelper.init(this);
-        GeckoHelper.init(this);
-        NavigationHelper.init(this);
-        WaitHelper.init(this);
+        HelperInitializer.init(this);
     }
 
     @Override
     public Solo getSolo() {
         return mSolo;
     }
 
     @Override
--- a/mobile/android/base/tests/helpers/AssertionHelper.java
+++ b/mobile/android/base/tests/helpers/AssertionHelper.java
@@ -13,17 +13,17 @@ import org.mozilla.gecko.tests.UITestCon
 public final class AssertionHelper {
     // Assert.ok has a "diag" ("diagnostic") parameter that has no useful purpose.
     private static final String DIAG_STRING = "";
 
     private static Assert sAsserter;
 
     private AssertionHelper() { /* To disallow instantation. */ }
 
-    public static void init(final UITestContext context) {
+    protected static void init(final UITestContext context) {
         sAsserter = context.getAsserter();
     }
 
     public static void assertEquals(final String message, final Object expected, final Object actual) {
         sAsserter.is(actual, expected, message);
     }
 
     public static void assertEquals(final String message, final int expected, final int actual) {
--- a/mobile/android/base/tests/helpers/DeviceHelper.java
+++ b/mobile/android/base/tests/helpers/DeviceHelper.java
@@ -42,17 +42,17 @@ public final class DeviceHelper {
     private static int sScreenWidth;
 
     private DeviceHelper() { /* To disallow instantiation. */ }
 
     public static void assertIsTablet() {
         assertTrue("The device is a tablet", isTablet());
     }
 
-    public static void init(final UITestContext context) {
+    protected static void init(final UITestContext context) {
         sActivity = context.getActivity();
         sSolo = context.getSolo();
 
         setAndroidVersion();
         setScreenDimensions();
         setDeviceType();
     }
 
--- a/mobile/android/base/tests/helpers/GeckoHelper.java
+++ b/mobile/android/base/tests/helpers/GeckoHelper.java
@@ -16,17 +16,17 @@ import android.app.Activity;
  * Provides helper functions for accessing the underlying Gecko engine.
  */
 public final class GeckoHelper {
     private static Activity sActivity;
     private static Actions sActions;
 
     private GeckoHelper() { /* To disallow instantiation. */ }
 
-    public static void init(final UITestContext context) {
+    protected static void init(final UITestContext context) {
         sActivity = context.getActivity();
         sActions = context.getActions();
     }
 
     public static void blockForReady() {
         final EventExpecter geckoReady = sActions.expectGeckoEvent("Gecko:Ready");
 
         final boolean isReady = GeckoThread.checkLaunchState(LaunchState.GeckoRunning);
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/tests/helpers/HelperInitializer.java
@@ -0,0 +1,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.tests.helpers;
+
+import org.mozilla.gecko.tests.UITestContext;
+
+/**
+ * AssertionHelper is statically imported in many places. Thus we want to hide
+ * its init method outside of this package. We initialize the remaining helper
+ * classes from here so that all the init methods are package protected.
+ */
+public final class HelperInitializer {
+
+    private HelperInitializer() { /* To disallow instantiation. */ }
+
+    public static void init(final UITestContext context) {
+        // Other helpers make assertions so init AssertionHelper first.
+        AssertionHelper.init(context);
+
+        DeviceHelper.init(context);
+        GeckoHelper.init(context);
+        NavigationHelper.init(context);
+        WaitHelper.init(context);
+    }
+}
--- a/mobile/android/base/tests/helpers/NavigationHelper.java
+++ b/mobile/android/base/tests/helpers/NavigationHelper.java
@@ -19,17 +19,17 @@ import android.text.TextUtils;
  * combine actions taken on multiple components to perform larger interactions.
  */
 final public class NavigationHelper {
     private static UITestContext sContext;
     private static Solo sSolo;
 
     private static ToolbarComponent sToolbar;
 
-    public static void init(final UITestContext context) {
+    protected static void init(final UITestContext context) {
         sContext = context;
         sSolo = context.getSolo();
 
         sToolbar = (ToolbarComponent) context.getComponent(ComponentType.TOOLBAR);
     }
 
     public static void enterAndLoadUrl(String url) {
         assertNotNull("url is not null", url);
--- a/mobile/android/base/tests/helpers/WaitHelper.java
+++ b/mobile/android/base/tests/helpers/WaitHelper.java
@@ -35,17 +35,17 @@ public final class WaitHelper {
     private static UITestContext sContext;
     private static Solo sSolo;
     private static Actions sActions;
 
     private static ToolbarComponent sToolbar;
 
     private WaitHelper() { /* To disallow instantiation. */ }
 
-    public static void init(final UITestContext context) {
+    protected static void init(final UITestContext context) {
         sContext = context;
         sSolo = context.getSolo();
         sActions = context.getActions();
 
         sToolbar = (ToolbarComponent) context.getComponent(ComponentType.TOOLBAR);
     }
 
     /**