Bug 1261713 - (Part 4) Add test for getActiveExperiments. r=sebastian draft
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Sun, 03 Apr 2016 18:27:00 -0400
changeset 347229 110bfc30d2cb38e1e3ad329fcf55b47d25a76832
parent 347228 e41b11103c6792071480e5118fa08a8d4c18f703
child 517572 29427d3247ea40fd558dd44bc16c4341bf1095d1
push id14518
push usermleibovic@mozilla.com
push dateSun, 03 Apr 2016 22:28:38 +0000
reviewerssebastian
bugs1261713
milestone48.0a1
Bug 1261713 - (Part 4) Add test for getActiveExperiments. r=sebastian MozReview-Commit-ID: 4VwUR1GXFcg
mobile/android/tests/background/junit4/src/com/keepsafe/switchboard/TestSwitchboard.java
--- a/mobile/android/tests/background/junit4/src/com/keepsafe/switchboard/TestSwitchboard.java
+++ b/mobile/android/tests/background/junit4/src/com/keepsafe/switchboard/TestSwitchboard.java
@@ -6,16 +6,17 @@ import org.json.JSONException;
 import org.json.JSONObject;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mozilla.gecko.background.testhelpers.TestRunner;
 import org.robolectric.RuntimeEnvironment;
 
 import java.io.IOException;
+import java.util.List;
 import java.util.UUID;
 
 import static org.junit.Assert.*;
 
 @RunWith(TestRunner.class)
 public class TestSwitchboard {
 
     private static final String TEST_JSON = "{\"active-experiment\":{\"isActive\":true,\"values\":{\"foo\": true}},\"inactive-experiment\":{\"isActive\":false,\"values\":null}}";
@@ -54,9 +55,19 @@ public class TestSwitchboard {
         assertNotNull("active-experiment values are not null", values);
         try {
             assertTrue("\"foo\" extra value is true", values.getBoolean("foo"));
         } catch (JSONException e) {
             fail();
         }
     }
 
+    @Test
+    public void testGetActiveExperiments() {
+        final Context c = RuntimeEnvironment.application;
+        final List<String> experiments = SwitchBoard.getActiveExperiments(c);
+        assertNotNull("List of active experiments is not null", experiments);
+
+        assertTrue("List of active experiments contains active-experiemnt", experiments.contains("active-experiment"));
+        assertFalse("List of active experiments does not contain inactive-experiemnt", experiments.contains("inactive-experiment"));
+    }
+
 }