Bug 1261713 - (Part 4) Add test for getActiveExperiments. r=sebastian
MozReview-Commit-ID: 4VwUR1GXFcg
--- 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"));
+ }
+
}