Skip to content

Commit

Permalink
fix some tests by using Application context, rather than activity (RG2)
Browse files Browse the repository at this point in the history
A lot of the test-fixes hinge on switching from injecting 'Context'
(which is taken to mean Activity or Service) to injecting Application -
which is a context that is always available, and doesn't require your
classes to be ContextScoped.
  • Loading branch information
rtyley committed May 21, 2012
1 parent b1da0b9 commit ef408e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Expand Up @@ -21,16 +21,15 @@

import static org.eclipse.jgit.lib.Constants.DOT_GIT;
import android.content.Context;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;

import com.madgag.agit.matchers.GitTestHelper;
import com.madgag.agit.operation.lifecycle.RepoNotifications;

import java.io.File;

import roboguice.test.RoboUnitTestCase;

public class RepoNotificationsTest extends RoboUnitTestCase<AgitTestApplication> {
public class RepoNotificationsTest extends InstrumentationTestCase {

private static final String TAG = "RNT";
private final GitTestHelper helper = AndroidTestEnvironment.helper(getInstrumentation());
Expand Down
Expand Up @@ -21,7 +21,7 @@

import static android.R.drawable.stat_notify_error;
import static java.lang.System.currentTimeMillis;
import android.content.Context;
import android.app.Application;
import android.os.Handler;
import android.util.Log;

Expand Down Expand Up @@ -63,11 +63,11 @@ public void run() {

@Inject
public GitAsyncTask(
Context context,
Application application,
@Named("uiThread") Handler handler,
@Assisted GitOperation operation,
@Assisted OperationLifecycleSupport lifecycleSupport) {
super(context);
super(application);
handler(handler);
this.operation = operation;
this.lifecycleSupport = lifecycleSupport;
Expand Down
Expand Up @@ -2,7 +2,7 @@


import static com.madgag.agit.GitIntents.broadcastIntentForRepoStateChange;
import android.content.Context;
import android.app.Application;

import com.google.inject.Inject;
import com.google.inject.name.Named;
Expand All @@ -12,7 +12,7 @@
public class RepoUpdateBroadcaster {

@Inject
Context context;
Application context;
@Inject
@Named("gitdir")
File gitdir;
Expand Down

0 comments on commit ef408e9

Please sign in to comment.