mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Merge branch '832-fix-bridge-test' into 'master'
Fix Tor bridge integration test See merge request briar/briar!875
This commit is contained in:
@@ -3,14 +3,15 @@ package org.briarproject.bramble.plugin.tor;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import org.briarproject.bramble.DaggerIntegrationTestComponent;
|
|
||||||
import org.briarproject.bramble.IntegrationTestComponent;
|
|
||||||
import org.briarproject.bramble.api.event.EventBus;
|
import org.briarproject.bramble.api.event.EventBus;
|
||||||
|
import org.briarproject.bramble.api.network.NetworkManager;
|
||||||
import org.briarproject.bramble.api.plugin.BackoffFactory;
|
import org.briarproject.bramble.api.plugin.BackoffFactory;
|
||||||
import org.briarproject.bramble.api.plugin.duplex.DuplexPlugin;
|
import org.briarproject.bramble.api.plugin.duplex.DuplexPlugin;
|
||||||
import org.briarproject.bramble.api.system.Clock;
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
import org.briarproject.bramble.api.system.LocationUtils;
|
import org.briarproject.bramble.api.system.LocationUtils;
|
||||||
|
import org.briarproject.bramble.test.BrambleAndroidIntegrationTestComponent;
|
||||||
import org.briarproject.bramble.test.BrambleTestCase;
|
import org.briarproject.bramble.test.BrambleTestCase;
|
||||||
|
import org.briarproject.bramble.test.DaggerBrambleAndroidIntegrationTestComponent;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -41,6 +42,8 @@ public class BridgeTest extends BrambleTestCase {
|
|||||||
private final static Logger LOG =
|
private final static Logger LOG =
|
||||||
Logger.getLogger(BridgeTest.class.getSimpleName());
|
Logger.getLogger(BridgeTest.class.getSimpleName());
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
NetworkManager networkManager;
|
||||||
@Inject
|
@Inject
|
||||||
EventBus eventBus;
|
EventBus eventBus;
|
||||||
@Inject
|
@Inject
|
||||||
@@ -77,8 +80,8 @@ public class BridgeTest extends BrambleTestCase {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
IntegrationTestComponent component =
|
BrambleAndroidIntegrationTestComponent component =
|
||||||
DaggerIntegrationTestComponent.builder().build();
|
DaggerBrambleAndroidIntegrationTestComponent.builder().build();
|
||||||
component.inject(this);
|
component.inject(this);
|
||||||
|
|
||||||
Executor ioExecutor = Executors.newCachedThreadPool();
|
Executor ioExecutor = Executors.newCachedThreadPool();
|
||||||
@@ -87,7 +90,7 @@ public class BridgeTest extends BrambleTestCase {
|
|||||||
SocketFactory torSocketFactory = SocketFactory.getDefault();
|
SocketFactory torSocketFactory = SocketFactory.getDefault();
|
||||||
|
|
||||||
factory = new TorPluginFactory(ioExecutor, scheduler, appContext,
|
factory = new TorPluginFactory(ioExecutor, scheduler, appContext,
|
||||||
locationUtils, eventBus, torSocketFactory,
|
networkManager, locationUtils, eventBus, torSocketFactory,
|
||||||
backoffFactory, circumventionProvider, clock);
|
backoffFactory, circumventionProvider, clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package org.briarproject.bramble.test;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import android.support.test.InstrumentationRegistry;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import dagger.Module;
|
||||||
|
import dagger.Provides;
|
||||||
|
|
||||||
|
@Module
|
||||||
|
class ApplicationModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
Application provideApplication() {
|
||||||
|
return (Application) InstrumentationRegistry.getTargetContext()
|
||||||
|
.getApplicationContext();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.briarproject.bramble;
|
package org.briarproject.bramble.test;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.BrambleAndroidModule;
|
||||||
import org.briarproject.bramble.event.EventModule;
|
import org.briarproject.bramble.event.EventModule;
|
||||||
import org.briarproject.bramble.plugin.PluginModule;
|
import org.briarproject.bramble.plugin.PluginModule;
|
||||||
import org.briarproject.bramble.plugin.tor.BridgeTest;
|
import org.briarproject.bramble.plugin.tor.BridgeTest;
|
||||||
@@ -12,11 +13,13 @@ import dagger.Component;
|
|||||||
@Singleton
|
@Singleton
|
||||||
@Component(modules = {
|
@Component(modules = {
|
||||||
BrambleAndroidModule.class,
|
BrambleAndroidModule.class,
|
||||||
|
TestLifecycleModule.class,
|
||||||
|
ApplicationModule.class,
|
||||||
PluginModule.class, // needed for BackoffFactory
|
PluginModule.class, // needed for BackoffFactory
|
||||||
EventModule.class,
|
EventModule.class,
|
||||||
SystemModule.class,
|
SystemModule.class,
|
||||||
})
|
})
|
||||||
public interface IntegrationTestComponent {
|
public interface BrambleAndroidIntegrationTestComponent {
|
||||||
|
|
||||||
void inject(BridgeTest init);
|
void inject(BridgeTest init);
|
||||||
|
|
||||||
Reference in New Issue
Block a user