Permalink
Browse files

- Add test project back in. Not working with the build right now, TODO.

  • Loading branch information...
1 parent becf9ec commit 960d93c4fb9c1263268f9645490da2a5b0b6306f @justinberry justinberry committed Mar 26, 2013
Showing with 1,134 additions and 14 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 resilience-app/src/main/java/au/com/dius/resilience/ResilienceApplication.java
  3. +0 −9 resilience-app/src/test/java/au/com/dius/resilience/test/unit/ui/activity/CreateIncidentTest.java
  4. +2 −4 resilience-app/src/test/java/au/com/dius/resilience/test/unit/utils/TestHelper.java
  5. +24 −0 resilience-test/AndroidManifest.xml
  6. +18 −0 resilience-test/ant.properties
  7. +92 −0 resilience-test/build.xml
  8. BIN resilience-test/libs/robotium-solo-3.5.1.jar
  9. +20 −0 resilience-test/proguard-project.txt
  10. +14 −0 resilience-test/project.properties
  11. +62 −0 resilience-test/src/test/java/au/com/dius/resilience/test/AbstractResilienceActivityTestCase.java
  12. +29 −0 resilience-test/src/test/java/au/com/dius/resilience/test/AbstractResilienceTestCase.java
  13. +48 −0 resilience-test/src/test/java/au/com/dius/resilience/test/ResilienceTestActions.java
  14. +172 −0 ...ience-test/src/test/java/au/com/dius/resilience/test/persistence/ParseIncidentRepositoryTest.java
  15. +122 −0 resilience-test/src/test/java/au/com/dius/resilience/test/persistence/ParsePhotoRepositoryTest.java
  16. +112 −0 resilience-test/src/test/java/au/com/dius/resilience/test/persistence/ParseRepositoryTest.java
  17. +47 −0 resilience-test/src/test/java/au/com/dius/resilience/test/ui/activity/CreateActivityTest.java
  18. +44 −0 resilience-test/src/test/java/au/com/dius/resilience/test/ui/activity/EditIncidentActivityTest.java
  19. +85 −0 resilience-test/src/test/java/au/com/dius/resilience/test/ui/activity/PreferenceActivityTest.java
  20. +67 −0 resilience-test/src/test/java/au/com/dius/resilience/test/ui/activity/ResilienceActivityTest.java
  21. +18 −0 resilience-test/src/test/java/au/com/dius/resilience/test/util/MutableBoolean.java
  22. +70 −0 resilience-test/src/test/java/au/com/dius/resilience/test/util/ParseTestUtils.java
  23. +86 −0 resilience-test/src/test/java/au/com/dius/resilience/test/util/TestHelper.java
View
1 .gitignore
@@ -11,3 +11,4 @@ tmp/
local.properties
target/
resilience-local.properties
+*.iml
View
2 resilience-app/src/main/java/au/com/dius/resilience/ResilienceApplication.java
@@ -26,7 +26,7 @@ private void initialiseParse() {
Log.d(LOG_TAG, "Connecting to parse using " + appKey + " application key and " + clientKey + " client key");
- Parse.initialize(this, appKey, clientKey);
+// Parse.initialize(this, appKey, clientKey);
}
private void setDefaultPreferences() {
View
9 ...ce-app/src/test/java/au/com/dius/resilience/test/unit/ui/activity/CreateIncidentTest.java
@@ -1,9 +0,0 @@
-package au.com.dius.resilience.test.unit.ui.activity;
-
-import au.com.dius.resilience.test.unit.utils.ResilienceTestRunner;
-import org.junit.runner.RunWith;
-
-@RunWith(ResilienceTestRunner.class)
-public class CreateIncidentTest {
-
-}
View
6 resilience-app/src/test/java/au/com/dius/resilience/test/unit/utils/TestHelper.java
@@ -2,7 +2,6 @@
import android.content.Context;
import android.content.Intent;
-import au.com.dius.resilience.bootstrap.ResilienceModule;
import au.com.dius.resilience.model.Incident;
import au.com.dius.resilience.model.Photo;
import au.com.dius.resilience.persistence.repository.RepositoryCommandResult;
@@ -12,14 +11,13 @@
import com.google.inject.Provider;
import com.google.inject.util.Modules;
import com.xtremelabs.robolectric.Robolectric;
+import junit.framework.Assert;
import roboguice.RoboGuice;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
-import static com.sun.tools.internal.ws.wsdl.parser.Util.fail;
-
public class TestHelper {
public static RepositoryCommand<String> createRepositoryCommand() {
return new RepositoryCommand<String>() {
@@ -83,7 +81,7 @@ public static void assertContainsIntents(List<Intent> intents, String intentActi
return;
}
}
- fail("Did not find intent in list " + intentAction);
+ Assert.fail("Did not find intent in list " + intentAction);
}
public static void overrideRoboguiceModule(Module module) {
View
24 resilience-test/AndroidManifest.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="au.com.dius.resilience.tests"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="17"/>
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner"/>
+ </application>
+ <!--
+ This declares that this application uses the instrumentation test runner targeting
+ the package of au.com.dius.resilience. To run the tests use the command:
+ "adb shell am instrument -w au.com.dius.resilience.tests/android.test.InstrumentationTestRunner"
+ -->
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="au.com.dius.resilience"
+ android:label="Tests for au.com.dius.resilience"/>
+</manifest>
View
18 resilience-test/ant.properties
@@ -0,0 +1,18 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked into Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
+tested.project.dir=../resilience-android/resilience-app
View
92 resilience-test/build.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="resilience_test" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <property file="local.properties"/>
+
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
+ Here are some properties you may want to change/update:
+
+ source.dir
+ The name of the source directory. Default is 'src'.
+ out.dir
+ The name of the output directory. Default is 'bin'.
+
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
+
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems.
+
+ -->
+ <property file="ant.properties"/>
+
+ <!-- if sdk.dir was not set from one of the property file, then
+ get it from the ANDROID_HOME env var.
+ This must be done before we load project.properties since
+ the proguard config can use sdk.dir -->
+ <property environment="env"/>
+ <condition property="sdk.dir" value="${env.ANDROID_HOME}">
+ <isset property="env.ANDROID_HOME"/>
+ </condition>
+
+ <!-- The project.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <loadproperties srcFile="project.properties"/>
+
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
+ unless="sdk.dir"
+ />
+
+ <!--
+ Import per project custom build rules if present at the root of the project.
+ This is the place to put custom intermediary targets such as:
+ -pre-build
+ -pre-compile
+ -post-compile (This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir})
+ -post-package
+ -post-build
+ -pre-clean
+ -->
+ <import file="custom_rules.xml" optional="true"/>
+
+ <!-- Import the actual build file.
+
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <import> task.
+ - customize it to your needs.
+ - Customize the whole content of build.xml
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, replacing the <import> task.
+ - customize to your needs.
+
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
+ -->
+ <!-- version-tag: 1 -->
+ <import file="${sdk.dir}/tools/ant/build.xml"/>
+
+</project>
View
BIN resilience-test/libs/robotium-solo-3.5.1.jar
Binary file not shown.
View
20 resilience-test/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
View
14 resilience-test/project.properties
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-16
View
62 ...ce-test/src/test/java/au/com/dius/resilience/test/AbstractResilienceActivityTestCase.java
@@ -0,0 +1,62 @@
+package au.com.dius.resilience.test;
+
+import android.test.ActivityInstrumentationTestCase2;
+import android.widget.SeekBar;
+import com.jayway.android.robotium.solo.Solo;
+
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * @author georgepapas
+ */
+public abstract class AbstractResilienceActivityTestCase<T extends android.app.Activity> extends ActivityInstrumentationTestCase2<T> {
+
+ public static final String LOG_TAG = AbstractResilienceActivityTestCase.class.getName();
+
+ protected Solo solo;
+
+ private ResilienceTestActions testActions;
+
+ protected void beforeTest() {
+ }
+
+ protected void afterTest() {
+ }
+
+ public AbstractResilienceActivityTestCase(Class<T> activityClass) {
+ super(activityClass);
+ testActions = new ResilienceTestActions(this);
+ }
+
+ protected String getString(int id) {
+ return testActions.getString(id);
+ }
+
+ protected void setProgressBar(final SeekBar seekbar, final int progress) {
+ final CountDownLatch latch = new CountDownLatch(1);
+ getActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ seekbar.setProgress(progress);
+ latch.countDown();
+ }
+ });
+
+ try {
+ latch.await();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ protected void setUp() {
+ testActions.setUp();
+ solo = new Solo(getInstrumentation(), getActivity());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ solo.finishOpenedActivities();
+ }
+}
View
29 resilience-test/src/test/java/au/com/dius/resilience/test/AbstractResilienceTestCase.java
@@ -0,0 +1,29 @@
+package au.com.dius.resilience.test;
+
+import android.content.Context;
+import android.test.InstrumentationTestCase;
+
+/**
+ * For running instrumentation tests which do not have an activity bound to them.
+ */
+public class AbstractResilienceTestCase extends InstrumentationTestCase {
+
+ private ResilienceTestActions testActions;
+
+ public AbstractResilienceTestCase() {
+ testActions = new ResilienceTestActions(this);
+ }
+
+ @Override
+ public void setUp() {
+ testActions.setUp();
+ }
+
+ public Context getContext() {
+ return getInstrumentation().getContext();
+ }
+
+ protected String getString(int id) {
+ return testActions.getString(id);
+ }
+}
View
48 resilience-test/src/test/java/au/com/dius/resilience/test/ResilienceTestActions.java
@@ -0,0 +1,48 @@
+package au.com.dius.resilience.test;
+
+import android.content.Context;
+import android.preference.PreferenceManager;
+import android.test.InstrumentationTestCase;
+import android.util.Log;
+import au.com.dius.resilience.persistence.repository.impl.PreferenceAdapter;
+import au.com.dius.resilience.test.util.ParseTestUtils;
+
+import static android.content.Context.MODE_PRIVATE;
+
+/**
+ * For sharing test helper functionality across AbstractResilience*TestCases.
+ */
+public class ResilienceTestActions {
+
+ private InstrumentationTestCase test;
+ private static final String LOG_TAG = ResilienceTestActions.class.getName();
+
+ public ResilienceTestActions(InstrumentationTestCase instrumentation) {
+ this.test = instrumentation;
+ }
+
+ public void setUp() {
+ Log.d(LOG_TAG, "Preparing for test " + Thread.currentThread().getName());
+ test.getInstrumentation().waitForIdleSync();
+ reinitialiseSharedPreferences();
+
+// ParseTestUtils.setUp(test.getInstrumentation().getTargetContext());
+// ParseTestUtils.dropAll(test.getInstrumentation());
+ }
+
+ private void reinitialiseSharedPreferences() {
+ Context application = test.getInstrumentation().getTargetContext();
+ application.getSharedPreferences(PreferenceAdapter.PREFERENCES_FILE_COMMON, MODE_PRIVATE)
+ .edit().clear().commit();
+ application.getSharedPreferences(PreferenceAdapter.PREFERENCES_FILE_DEFAULT, MODE_PRIVATE)
+ .edit().clear().commit();
+ PreferenceManager.setDefaultValues(application, PreferenceAdapter.PREFERENCES_FILE_COMMON,
+ MODE_PRIVATE, au.com.dius.resilience.R.xml.common_preferences, true);
+ PreferenceManager.setDefaultValues(application, PreferenceAdapter.PREFERENCES_FILE_DEFAULT, MODE_PRIVATE,
+ au.com.dius.resilience.R.xml.user_preferences, true);
+ }
+
+ public String getString(int id) {
+ return test.getInstrumentation().getContext().getString(id);
+ }
+}
View
172 ...st/src/test/java/au/com/dius/resilience/test/persistence/ParseIncidentRepositoryTest.java
@@ -0,0 +1,172 @@
+package au.com.dius.resilience.test.persistence;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import roboguice.RoboGuice;
+import android.app.Application;
+import android.content.Context;
+import android.test.InstrumentationTestCase;
+import au.com.dius.resilience.model.Impact;
+import au.com.dius.resilience.model.Incident;
+import au.com.dius.resilience.persistence.repository.IncidentRepository;
+import au.com.dius.resilience.persistence.repository.RepositoryCommandResult;
+import au.com.dius.resilience.persistence.repository.RepositoryCommandResultListener;
+import au.com.dius.resilience.test.util.ParseTestUtils;
+
+import com.google.inject.Injector;
+
+public class ParseIncidentRepositoryTest extends InstrumentationTestCase {
+
+ private IncidentRepository repository;
+
+ final private CountDownLatch latch = new CountDownLatch(1);
+
+ private RepositoryCommandResultListener<Incident> saveListener;
+ private CountDownLatch saveLatch;
+
+ // A place to store variables across threads.
+ final Map<String, String> testValues = new HashMap<String, String>();
+
+ @Override
+ public void setUp() throws Exception {
+ getInstrumentation().waitForIdleSync();
+
+ Context targetContext = getInstrumentation().getTargetContext();
+ Injector applicationInjector = RoboGuice.getBaseApplicationInjector((Application) targetContext.getApplicationContext());
+ repository = applicationInjector.getInstance(IncidentRepository.class);
+
+ ParseTestUtils.setUp(targetContext);
+ ParseTestUtils.dropAll(getInstrumentation());
+
+ testValues.clear();
+ saveLatch = new CountDownLatch(1);
+ saveListener = new RepositoryCommandResultListener<Incident>() {
+ @Override
+ public void commandComplete(RepositoryCommandResult<Incident> result) {
+ assertTrue(result.isSuccess());
+ assertEquals(1, result.getResults().size());
+ Incident savedIncident = result.getResults().get(0);
+ testValues.put("INCIDENT_ID", savedIncident.getId());
+ saveLatch.countDown();
+ }
+ };
+ }
+
+ public void testSave() throws Exception {
+ final Incident incident = new Incident("SomeName", null, "SomeNote", "Explosion", "Subby", Impact.MEDIUM);
+
+ getInstrumentation().runOnMainSync(new Runnable() {
+ @Override
+ public void run() {
+ repository.save(saveListener, incident);
+ }
+ });
+
+ saveLatch.await(30, TimeUnit.SECONDS);
+
+ final RepositoryCommandResultListener<Incident> foundIncidentListener = new RepositoryCommandResultListener<Incident>() {
+ @Override
+ public void commandComplete(RepositoryCommandResult<Incident> result) {
+ assertTrue(result.isSuccess());
+ assertEquals(1, result.getResults().size());
+
+ Incident foundIncident = result.getResults().get(0);
+ assertNotNull(foundIncident);
+ assertEquals(testValues.get("INCIDENT_ID"), foundIncident.getId());
+ assertEquals("SomeName", foundIncident.getName());
+ assertNotNull(foundIncident.getDateCreated());
+ assertEquals("SomeNote", foundIncident.getNote());
+ assertEquals("Explosion", foundIncident.getCategory());
+ assertEquals("Subby", foundIncident.getSubCategory());
+ assertEquals(Impact.MEDIUM, foundIncident.getImpact());
+
+ latch.countDown();
+ }
+ };
+
+ getInstrumentation().runOnMainSync(new Runnable() {
+ @Override
+ public void run() {
+ repository.findById(foundIncidentListener, testValues.get("INCIDENT_ID"));
+ }
+ });
+
+ latch.await(30, TimeUnit.SECONDS);
+ }
+
+ public void testUpdate() throws Exception {
+ Incident incident = new Incident("OrigName", null, "OrigNote", "OrigCat", "OrigSubCat", Impact.MEDIUM);
+ repository.save(saveListener, incident);
+ saveLatch.await();
+
+ final String id = incident.getId();
+
+ saveLatch = new CountDownLatch(1);
+
+ incident.setName("NewName");
+ incident.setNote("NewNote");
+ incident.setCategory("NewCat");
+ incident.setSubCategory("NewSubCat");
+ incident.setScale(Impact.LOW);
+ repository.save(saveListener, incident);
+
+ saveLatch.await();
+ final CountDownLatch findLatch = new CountDownLatch(1);
+
+ RepositoryCommandResultListener<Incident> foundIncidentListener = new RepositoryCommandResultListener<Incident>() {
+ @Override
+ public void commandComplete(RepositoryCommandResult<Incident> result) {
+ assertTrue(result.isSuccess());
+ Incident foundIncident = result.getResults().get(0);
+ assertNotNull(foundIncident);
+ assertEquals(id, foundIncident.getId());
+ assertEquals("NewName", foundIncident.getName());
+ assertNotNull(foundIncident.getDateCreated());
+ assertEquals("NewNote", foundIncident.getNote());
+ assertEquals("NewCat", foundIncident.getCategory());
+ assertEquals("NewSubCat", foundIncident.getSubCategory());
+ assertEquals(Impact.LOW, foundIncident.getImpact());
+
+ findLatch.countDown();
+ }
+ };
+
+ repository.findById(foundIncidentListener, id);
+ findLatch.await();
+ }
+
+ public void testFindAll() throws Exception {
+ saveLatch = new CountDownLatch(3);
+ Incident incident1 = new Incident("Fooaaa", new Date().getTime(), "FooNote", "Wind", "SubC1", Impact.MEDIUM);
+ Incident incident2 = new Incident("Bareee", new Date().getTime(), "BarNote", "Water", "SubC2", Impact.LOW);
+ Incident incident3 = new Incident("Wharrr", new Date().getTime(), "WhaNote", "Fire", "SubC3", Impact.HIGH);
+ repository.save(saveListener, incident1);
+ repository.save(saveListener, incident2);
+ repository.save(saveListener, incident3);
+
+ saveLatch.await();
+
+ final CountDownLatch findLatch = new CountDownLatch(1);
+ final RepositoryCommandResultListener<Incident> findIncidentsListener = new RepositoryCommandResultListener<Incident>() {
+ @Override
+ public void commandComplete(RepositoryCommandResult<Incident> result) {
+ assertTrue(result.isSuccess());
+ assertEquals(3, result.getResults().size());
+
+ for (Incident incident : result.getResults()) {
+ assertNotNull(incident.getId());
+ }
+
+ findLatch.countDown();
+ }
+ };
+
+ repository.findAll(findIncidentsListener);
+
+ findLatch.await();
+ }
+}
View
122 ...-test/src/test/java/au/com/dius/resilience/test/persistence/ParsePhotoRepositoryTest.java
@@ -0,0 +1,122 @@
+package au.com.dius.resilience.test.persistence;
+
+import android.app.Application;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.CompressFormat;
+import android.graphics.BitmapFactory;
+import android.os.Environment;
+import android.test.InstrumentationTestCase;
+import au.com.dius.resilience.R;
+import au.com.dius.resilience.model.Impact;
+import au.com.dius.resilience.model.Incident;
+import au.com.dius.resilience.model.Photo;
+import au.com.dius.resilience.persistence.repository.IncidentRepository;
+import au.com.dius.resilience.persistence.repository.PhotoRepository;
+import au.com.dius.resilience.persistence.repository.RepositoryCommandResultListener;
+import au.com.dius.resilience.persistence.repository.impl.ParsePhotoRepository;
+import au.com.dius.resilience.test.util.MutableBoolean;
+import au.com.dius.resilience.test.util.ParseTestUtils;
+import au.com.dius.resilience.test.util.TestHelper;
+import com.google.inject.Injector;
+import roboguice.RoboGuice;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
+
+public class ParsePhotoRepositoryTest extends InstrumentationTestCase {
+
+ private IncidentRepository incidentRepository;
+ private ParsePhotoRepository parsePhotoRepository;
+ private Incident incident;
+
+ public void setUp() throws Exception {
+ getInstrumentation().waitForIdleSync();
+ incident = new Incident("name", new Date().getTime(), "note", "cat", "subCat", Impact.MEDIUM);
+
+ Context targetContext = getInstrumentation().getTargetContext();
+ Injector applicationInjector = RoboGuice.getBaseApplicationInjector((Application) targetContext.getApplicationContext());
+
+ parsePhotoRepository = (ParsePhotoRepository) applicationInjector.getInstance(PhotoRepository.class);
+ incidentRepository = applicationInjector.getInstance(IncidentRepository.class);
+
+ ParseTestUtils.setUp(targetContext);
+ ParseTestUtils.dropAll(getInstrumentation());
+ }
+
+ public void testSave() throws Exception {
+
+ // Need an incident to save against
+ final List<Incident> resultList1 = new ArrayList<Incident>();
+ MutableBoolean mutableBoolean1 = new MutableBoolean(false);
+ final CountDownLatch incidentSaveLatch = new CountDownLatch(1);
+ RepositoryCommandResultListener<Incident> saveListener = TestHelper.createIncidentListener(mutableBoolean1, resultList1, incidentSaveLatch);
+
+ incidentRepository.save(saveListener, incident);
+
+ incidentSaveLatch.await();
+
+ assertTrue(mutableBoolean1.isTrue());
+ assertEquals(1, resultList1.size());
+
+ // Generate test image and upload
+ File photoFile = new File(Environment.getExternalStorageDirectory().getPath() + "/test_image.jpg");
+
+ Bitmap bitmap = BitmapFactory.decodeResource(getInstrumentation().getTargetContext().getResources(), R.drawable.electricity);
+ OutputStream out = new FileOutputStream(photoFile);
+ bitmap.compress(CompressFormat.JPEG, 100, out);
+ out.close();
+ Photo photo = new Photo(photoFile);
+
+ final List<Incident> resultList2 = new ArrayList<Incident>();
+ MutableBoolean mutableBoolean2 = new MutableBoolean(false);
+ final CountDownLatch photoSaveLatch = new CountDownLatch(1);
+ parsePhotoRepository.save(TestHelper.createIncidentListener(mutableBoolean2, resultList2, photoSaveLatch), photo, incident);
+ photoSaveLatch.await();
+
+ assertTrue(mutableBoolean2.isTrue());
+ assertEquals(1, resultList2.size());
+
+ // Retrieve photo
+ MutableBoolean mutableBoolean3 = new MutableBoolean(false);
+ final List<Photo> resultList3 = new ArrayList<Photo>();
+ final CountDownLatch latch3 = new CountDownLatch(1);
+ parsePhotoRepository.findByIncident(TestHelper.createPhotoListener(mutableBoolean3, resultList3, latch3), incident);
+
+ latch3.await();
+
+ assertTrue(mutableBoolean3.isTrue());
+ assertEquals(1, resultList3.size());
+ assertNotNull(resultList3.get(0).getUri());
+ }
+
+ public void testRetrieveByIncidentLacksPhoto() throws Exception {
+ final List<Incident> resultList1 = new ArrayList<Incident>();
+ MutableBoolean mutableBoolean1 = new MutableBoolean(false);
+ final CountDownLatch latch1 = new CountDownLatch(1);
+ RepositoryCommandResultListener<Incident> saveListener = TestHelper.createIncidentListener(mutableBoolean1, resultList1, latch1);
+
+ incidentRepository.save(saveListener, incident);
+
+ latch1.await();
+
+ assertTrue(mutableBoolean1.isTrue());
+ assertEquals(1, resultList1.size());
+
+ MutableBoolean mutableBoolean2 = new MutableBoolean(false);
+ final List<Photo> resultList2 = new ArrayList<Photo>();
+ final CountDownLatch latch2 = new CountDownLatch(1);
+ parsePhotoRepository.findByIncident(TestHelper.createPhotoListener(mutableBoolean2, resultList2, latch2), incident);
+
+ latch2.await();
+
+ assertFalse(mutableBoolean2.isTrue());
+ assertEquals(0, resultList2.size());
+ }
+}
View
112 ...ience-test/src/test/java/au/com/dius/resilience/test/persistence/ParseRepositoryTest.java
@@ -0,0 +1,112 @@
+package au.com.dius.resilience.test.persistence;
+
+import au.com.dius.resilience.model.Feedback;
+import au.com.dius.resilience.model.Impact;
+import au.com.dius.resilience.model.Incident;
+import au.com.dius.resilience.model.Point;
+import au.com.dius.resilience.persistence.Columns;
+import au.com.dius.resilience.persistence.repository.impl.ParseIncidentAdapter;
+import au.com.dius.resilience.persistence.repository.impl.ParseRepository;
+import au.com.dius.resilience.test.AbstractResilienceTestCase;
+import au.com.dius.resilience.test.util.ParseTestUtils;
+import com.parse.ParseException;
+import com.parse.ParseGeoPoint;
+import com.parse.ParseObject;
+
+import java.util.List;
+
+import static au.com.dius.resilience.Constants.*;
+
+public class ParseRepositoryTest extends AbstractResilienceTestCase {
+
+ public static final Point SOURCE_POINT = new Point(-37.82097184843051, 144.95498657226562);
+ public static final Point POINT_WITHIN_1KM = new Point(-37.818141132093125, 144.96485710144043); // Approx 900m away
+ public static final Point POINT_WITHIN_15KM = new Point(-37.705281862026936, 144.8894762992859); // Approx 14km away
+
+ public static final String INCIDENT_1 = "Incident1";
+ public static final String INCIDENT_2 = "Incident2";
+ public static final String INCIDENT_3 = "Incident3";
+
+ private ParseRepository repository;
+
+ @Override
+ public void setUp() {
+ super.setUp();
+
+ repository = new ParseRepository(new ParseIncidentAdapter());
+
+ ParseGeoPoint sourcePoint = new ParseGeoPoint(SOURCE_POINT.getLatitude(), SOURCE_POINT.getLongitude());
+ ParseGeoPoint within1KM = new ParseGeoPoint(POINT_WITHIN_1KM.getLatitude(), POINT_WITHIN_1KM.getLongitude());
+ ParseGeoPoint within15KM = new ParseGeoPoint(POINT_WITHIN_15KM.getLatitude(), POINT_WITHIN_15KM.getLongitude());
+
+ double distance1 = sourcePoint.distanceInKilometersTo(within1KM);
+ assertTrue(distance1 > 0.9 && distance1 < 1.0);
+ double distance2 = sourcePoint.distanceInKilometersTo(within15KM);
+ assertTrue(distance2 > 14.0 && distance2 < 15.0);
+
+ final ParseObject incident = new ParseObject(Columns.Incident.TABLE_NAME);
+ incident.put(Columns.Incident.NAME, INCIDENT_1);
+ incident.put(Columns.Incident.LOCATION, sourcePoint);
+ incident.put(Columns.Incident.IMPACT, Impact.LOW.name());
+
+ final ParseObject incident2 = new ParseObject(Columns.Incident.TABLE_NAME);
+ incident2.put(Columns.Incident.NAME, INCIDENT_2);
+ incident2.put(Columns.Incident.LOCATION, within1KM);
+ incident2.put(Columns.Incident.IMPACT, Impact.MEDIUM.name());
+
+ final ParseObject incident3 = new ParseObject(Columns.Incident.TABLE_NAME);
+ incident3.put(Columns.Incident.NAME, INCIDENT_3);
+ incident3.put(Columns.Incident.LOCATION, within15KM);
+ incident3.put(Columns.Incident.IMPACT, Impact.HIGH.name());
+
+ ParseTestUtils.saveAll(incident, incident2, incident3);
+ }
+
+ public void testFindAllIncidents() {
+ List<Incident> incidents = repository.findIncidents();
+ assertEquals(3, incidents.size());
+ }
+
+ public void testFindWithinDistanceOfPoint() throws ParseException {
+
+ List<Incident> incidentsWithin1KM = repository.findIncidentsWithinDistanceKM(SOURCE_POINT, 1);
+
+ assertEquals(2, incidentsWithin1KM.size());
+
+ assertEquals(SOURCE_POINT.getLatitude(), incidentsWithin1KM.get(0).getPoint().getLatitude());
+ assertEquals(SOURCE_POINT.getLongitude(), incidentsWithin1KM.get(0).getPoint().getLongitude());
+
+ assertEquals(POINT_WITHIN_1KM.getLatitude(), incidentsWithin1KM.get(1).getPoint().getLatitude());
+ assertEquals(POINT_WITHIN_1KM.getLongitude(), incidentsWithin1KM.get(1).getPoint().getLongitude());
+
+ // Point outside of 1km radius is excluded.
+ }
+
+ public void testFindWithinBoundingBox() {
+
+ // Contains the Melbourne CBD
+ Point bbSouthWest = new Point(-37.82497195707115, 144.94528770446777);
+ Point bbNorthEast = new Point(-37.80435890857138, 144.97687339782715);
+
+ List<Incident> incidentsWithinBoundingBox = repository.findIncidentsWithinBoundingBox(bbSouthWest, bbNorthEast);
+
+ assertEquals(2, incidentsWithinBoundingBox.size());
+
+ for (Incident i : incidentsWithinBoundingBox) {
+ if (INCIDENT_1.equals(i.getName())) {
+ assertEquals(SOURCE_POINT.getLatitude(), i.getPoint().getLatitude());
+ assertEquals(SOURCE_POINT.getLongitude(), i.getPoint().getLongitude());
+ } else if (INCIDENT_2.equals(i.getName())) {
+ assertEquals(POINT_WITHIN_1KM.getLatitude(), i.getPoint().getLatitude());
+ assertEquals(POINT_WITHIN_1KM.getLongitude(), i.getPoint().getLongitude());
+ } else {
+ fail("Unexpected incident " + i.getName() + " returned.");
+ }
+ }
+ }
+
+ public void testSendFeedback() {
+ // TODO
+// repository.sendFeedback(new Feedback("test feedback", "dev-id123"));
+ }
+}
View
47 ...lience-test/src/test/java/au/com/dius/resilience/test/ui/activity/CreateActivityTest.java
@@ -0,0 +1,47 @@
+package au.com.dius.resilience.test.ui.activity;
+
+import android.view.View;
+import android.widget.Button;
+import android.widget.ListView;
+import au.com.dius.resilience.R;
+import au.com.dius.resilience.test.AbstractResilienceActivityTestCase;
+import au.com.dius.resilience.ui.activity.EditIncidentActivity;
+import au.com.dius.resilience.ui.activity.ResilienceActivity;
+
+import java.util.ArrayList;
+
+/**
+ * @author georgepapas
+ */
+public class CreateActivityTest extends AbstractResilienceActivityTestCase<ResilienceActivity> {
+
+ public CreateActivityTest() {
+ super(ResilienceActivity.class);
+ }
+
+ public void testCreateIncident() {
+
+ final int incidentsBefore = getNoOfIncidentsInList();
+
+ View raiseIncidentButton = solo.getView(R.id.create_incident);
+ solo.clickOnView(raiseIncidentButton);
+ solo.assertCurrentActivity("expected edit activity", EditIncidentActivity.class);
+
+ solo.pressSpinnerItem(0, 1);
+ solo.typeText(0, "Run for the hills");
+
+ final View createButton = solo.getView(R.id.submit_incident);
+ solo.clickOnView(createButton);
+
+ solo.waitForFragmentById(R.id.fragment_incident_list_view);
+
+ int incidentsAfter = getNoOfIncidentsInList();
+ assertEquals(incidentsBefore + 1, incidentsAfter);
+ }
+
+ private int getNoOfIncidentsInList() {
+ final ArrayList<ListView> listViews = solo.getCurrentListViews();
+ return listViews.get(0) != null ? listViews.get(0).getCount() : 0;
+ }
+
+}
View
44 ...-test/src/test/java/au/com/dius/resilience/test/ui/activity/EditIncidentActivityTest.java
@@ -0,0 +1,44 @@
+package au.com.dius.resilience.test.ui.activity;
+
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.SeekBar;
+import android.widget.TextView;
+import au.com.dius.resilience.R;
+import au.com.dius.resilience.model.Impact;
+import au.com.dius.resilience.test.AbstractResilienceActivityTestCase;
+import au.com.dius.resilience.ui.activity.EditIncidentActivity;
+
+public class EditIncidentActivityTest extends AbstractResilienceActivityTestCase<EditIncidentActivity> {
+
+ public EditIncidentActivityTest() {
+ super(EditIncidentActivity.class);
+ }
+
+ public void testCreateAndSaveIncident() {
+
+ solo.pressSpinnerItem(0, 2);
+ solo.pressSpinnerItem(1, 3);
+
+ EditText notes = (EditText) solo.getView(R.id.notes);
+ Button createButton = (Button) solo.getView(R.id.submit_incident);
+
+ solo.typeText(notes, "fire");
+ solo.clickOnView(createButton);
+ }
+
+ public void testImpactLabelChange() {
+ // Test that the initial displayed impact is LOW
+ TextView impactRatingLbl = (TextView) solo.getView(R.id.impact_scale_desc);
+ assertEquals(Impact.LOW.name(), impactRatingLbl.getText().toString());
+
+ final SeekBar impactRating = (SeekBar) solo.getView(R.id.impact_scale);
+ setProgressBar(impactRating, 50);
+ assertEquals(Impact.MEDIUM.name(), impactRatingLbl.getText().toString());
+
+ setProgressBar(impactRating, 100);
+ solo.sleep(500);
+ assertEquals(Impact.HIGH.name(), impactRatingLbl.getText().toString());
+ }
+
+}
View
85 ...ce-test/src/test/java/au/com/dius/resilience/test/ui/activity/PreferenceActivityTest.java
@@ -0,0 +1,85 @@
+package au.com.dius.resilience.test.ui.activity;
+
+import android.app.Application;
+import android.content.SharedPreferences;
+import android.widget.EditText;
+import au.com.dius.resilience.R;
+import au.com.dius.resilience.persistence.repository.impl.PreferenceAdapter;
+import au.com.dius.resilience.test.AbstractResilienceActivityTestCase;
+import au.com.dius.resilience.ui.activity.ManageProfileActivity;
+import au.com.dius.resilience.ui.activity.PreferenceActivity;
+import au.com.dius.resilience.ui.activity.ResilienceActivity;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import static android.content.Context.MODE_PRIVATE;
+
+public class PreferenceActivityTest extends AbstractResilienceActivityTestCase<PreferenceActivity> {
+ public PreferenceActivityTest() {
+ super(PreferenceActivity.class);
+ }
+
+ private void createTestUsers() {
+ Application application = getActivity().getApplication();
+ SharedPreferences.Editor editor = application.getSharedPreferences(PreferenceAdapter.PREFERENCES_FILE_COMMON, MODE_PRIVATE).edit();
+ Set<String> profiles = new LinkedHashSet<String>();
+ profiles.add("Default User");
+ profiles.add("John Doe");
+ profiles.add("Jayne Doe");
+ editor.putStringSet(getString(R.string.profile_entries), profiles);
+ editor.commit();
+ }
+
+ public void testSwitchingProfileUpdatesUserSettings() {
+ createTestUsers();
+
+ solo.clickOnText(getString(R.string.response_radius));
+
+ solo.clearEditText(0);
+ solo.typeText(0, "999");
+ solo.clickOnText(getString(android.R.string.ok));
+
+ solo.clickOnText(getString(R.string.current_profile));
+ solo.clickOnText("John Doe");
+ solo.clickOnText(getString(R.string.response_radius));
+
+ EditText editText = solo.getEditText(0);
+
+ assertEquals("10", editText.getText().toString());
+ }
+
+ public void testCreateProfile() {
+ solo.clickOnText(getString(R.string.current_profile));
+ solo.clickOnText(getString(R.string.create_plus));
+
+ solo.assertCurrentActivity("Switching to profile manager failed.", ManageProfileActivity.class);
+
+ solo.clickOnEditText(0);
+ solo.typeText(0, "Brand spankin' new profile");
+ solo.clickOnButton(getString(R.string.save));
+
+ solo.assertCurrentActivity("Switching back to preferences failed.", PreferenceActivity.class);
+
+ solo.clickOnText(getString(R.string.current_profile));
+ assertTrue(solo.searchText("Brand spankin' new profile"));
+ }
+
+ public void testRestartOnThemeChange() {
+ solo.clickOnText(getString(R.string.use_light_theme));
+ solo.clickOnButton(getString(R.string.restart));
+ solo.assertCurrentActivity("App restart failed.", ResilienceActivity.class);
+ }
+
+ public void testCheckboxRevertsOnThemeChangeCancel() {
+
+ boolean startValue = solo.isCheckBoxChecked(getString(R.string.use_light_theme));
+ solo.clickOnText(getString(R.string.use_light_theme));
+ solo.searchText(getString(R.string.theme_change_warning));
+ solo.clickOnButton(getString(android.R.string.cancel));
+
+ boolean endValue = solo.isCheckBoxChecked(getString(R.string.use_light_theme));
+
+ assertEquals(startValue, endValue);
+ }
+}
View
67 ...ce-test/src/test/java/au/com/dius/resilience/test/ui/activity/ResilienceActivityTest.java
@@ -0,0 +1,67 @@
+package au.com.dius.resilience.test.ui.activity;
+
+import au.com.dius.resilience.test.AbstractResilienceActivityTestCase;
+import au.com.dius.resilience.ui.activity.ResilienceActivity;
+
+/**
+ * This is a simple framework for a test of an Application. See
+ * {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
+ * how to write and extend Application tests.
+ * <p/>
+ * To run this test, you can type:
+ * adb shell am instrument -w \
+ * -e class au.com.dius.resilience.ResilienceActivityTest \
+ * au.com.dius.resilience.tests/android.test.InstrumentationTestRunner
+ */
+public class ResilienceActivityTest extends AbstractResilienceActivityTestCase<ResilienceActivity> {
+
+ public ResilienceActivityTest() {
+ super(ResilienceActivity.class);
+ }
+
+ @Override
+ protected void beforeTest() {
+ }
+
+ @Override
+ protected void afterTest() {
+ solo.finishOpenedActivities();
+ }
+
+// public void test_MainActivityShouldHaveTabs() {
+//
+// assertNotNull(solo.getView(R.id.tab_list_view));
+// assertNotNull(solo.getView(R.id.tab_map_view));
+//
+// }
+//
+// public void test_ListTabShouldBeSelectedByDefault() {
+// assertEquals("expected list view tab to be selected", R.id.tab_list_view, getCurrentlySelectedTabId());
+// }
+//
+// public void test_ShouldBeAbleToSelectMapTab() {
+// solo.clickOnView(solo.getView(R.id.tab_map_view));
+// assertEquals("expected map view tab to be selected", R.id.tab_map_view, getCurrentlySelectedTabId());
+// }
+//
+// public void test_ShouldBeAbleToSelectListTab() {
+// solo.clickOnView(solo.getView(R.id.tab_list_view));
+// assertEquals("expected map view tab to be selected", R.id.tab_list_view, getCurrentlySelectedTabId());
+// }
+//
+// private int getCurrentlySelectedTabId() {
+// System.out.println("Current views" + solo.getCurrentViews());
+// System.out.println("Current buttons" + solo.getCurrentButtons());
+// System.out.println("Current image buttons" + solo.getCurrentImageButtons());
+//
+// for (View view : solo.getCurrentViews()) {
+// System.out.println("view class is : " + view.getClass().getName() + "id is " + view.getId());
+// if (view instanceof TabHost) {
+// return ((TabHost)view).getCurrentTabView().getId();
+// }
+// }
+// return -1;
+// }
+}
+
+
View
18 resilience-test/src/test/java/au/com/dius/resilience/test/util/MutableBoolean.java
@@ -0,0 +1,18 @@
+package au.com.dius.resilience.test.util;
+
+public class MutableBoolean {
+
+ private boolean bool;
+
+ public MutableBoolean(boolean bool) {
+ this.bool = bool;
+ }
+
+ public void setBool(boolean bool) {
+ this.bool = bool;
+ }
+
+ public boolean isTrue() {
+ return bool;
+ }
+}
View
70 resilience-test/src/test/java/au/com/dius/resilience/test/util/ParseTestUtils.java
@@ -0,0 +1,70 @@
+package au.com.dius.resilience.test.util;
+
+import android.app.Instrumentation;
+import android.content.Context;
+import android.os.StrictMode;
+import android.util.Log;
+import au.com.dius.resilience.Constants;
+import au.com.dius.resilience.R;
+import au.com.dius.resilience.model.Incident;
+import au.com.dius.resilience.persistence.Columns;
+import com.parse.Parse;
+import com.parse.ParseObject;
+import com.parse.ParseQuery;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class ParseTestUtils {
+
+ public static final String LOG_TAG = ParseTestUtils.class.getName();
+
+ public static void setUp(Context context) {
+ Parse.initialize(
+ context,
+ context.getString(R.string.key_parse_application),
+ context.getString(R.string.key_parse_client));
+
+ Parse.setLogLevel(Parse.LOG_LEVEL_INFO);
+ }
+
+ public static void dropAll(Instrumentation instrumentation) {
+ instrumentation.runOnMainSync(new DropTables());
+ instrumentation.waitForIdleSync();
+ }
+
+ public static void saveAll(ParseObject... incidents) {
+ try {
+ ParseObject.saveAll(Arrays.asList(incidents));
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to save incidents! ", e);
+ }
+ }
+
+ private static class DropTables implements Runnable {
+
+ public void run() {
+
+ StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build());
+ try {
+ ParseQuery query = new ParseQuery(Columns.Incident.TABLE_NAME);
+ List<ParseObject> incidents = query.find();
+
+ if (incidents == null || incidents.size() == 0) {
+ return;
+ }
+
+ Log.d(LOG_TAG, "Deleting " + incidents.size() + " incidents.");
+
+ for (ParseObject pObject : incidents) {
+ Log.d(LOG_TAG, "Deleting object " + pObject.getObjectId() + " succeeded.");
+ pObject.delete();
+ }
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to delete objects: ", e);
+ } finally {
+ StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
+ }
+ }
+ }
+}
View
86 resilience-test/src/test/java/au/com/dius/resilience/test/util/TestHelper.java
@@ -0,0 +1,86 @@
+package au.com.dius.resilience.test.util;
+
+import android.content.Context;
+import android.content.Intent;
+import au.com.dius.resilience.model.Incident;
+import au.com.dius.resilience.model.Photo;
+import au.com.dius.resilience.persistence.repository.RepositoryCommandResult;
+import au.com.dius.resilience.persistence.repository.RepositoryCommandResultListener;
+import au.com.dius.resilience.persistence.repository.impl.RepositoryCommand;
+import au.com.dius.resilience.test.util.MutableBoolean;
+import com.google.inject.Module;
+import com.google.inject.Provider;
+import com.google.inject.util.Modules;
+import junit.framework.Assert;
+import roboguice.RoboGuice;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
+public class TestHelper {
+ public static RepositoryCommand<String> createRepositoryCommand() {
+ return new RepositoryCommand<String>() {
+ public RepositoryCommandResult<String> perform() {
+ return new RepositoryCommandResult<String>(true, new ArrayList<String>());
+ }
+ };
+ }
+
+ public static RepositoryCommandResultListener<String> createCommandListener(final MutableBoolean callbackFlag) {
+ return new RepositoryCommandResultListener<String>() {
+ public void commandComplete(RepositoryCommandResult<String> result) {
+ callbackFlag.setBool(true);
+ }
+ };
+ }
+
+ public static RepositoryCommandResultListener<Incident> createIncidentListener(
+ final MutableBoolean callbackFlag,
+ final List<Incident> resultList, final CountDownLatch... latch) {
+ return new RepositoryCommandResultListener<Incident>() {
+
+ public void commandComplete(RepositoryCommandResult<Incident> result) {
+ callbackFlag.setBool(result.isSuccess());
+ resultList.addAll(result.getResults());
+
+ if (latch != null) {
+ latch[0].countDown();
+ }
+ }
+ };
+ }
+
+ public static RepositoryCommandResultListener<Photo> createPhotoListener(
+ final MutableBoolean callbackFlag,
+ final List<Photo> resultList, final CountDownLatch... latch) {
+ return new RepositoryCommandResultListener<Photo>() {
+
+ public void commandComplete(RepositoryCommandResult<Photo> result) {
+ callbackFlag.setBool(result.isSuccess());
+ resultList.addAll(result.getResults());
+
+ if (latch != null) {
+ latch[0].countDown();
+ }
+ }
+ };
+ }
+
+ public static Provider<Context> createContextProvider(final Context context) {
+ return new Provider<Context>() {
+ public Context get() {
+ return context;
+ }
+ };
+ }
+
+ public static void assertContainsIntents(List<Intent> intents, String intentAction) {
+ for (Intent intent : intents) {
+ if (intentAction.equals(intent.getAction())) {
+ return;
+ }
+ }
+ Assert.fail("Did not find intent in list " + intentAction);
+ }
+}

0 comments on commit 960d93c

Please sign in to comment.