use of com.intellij.mock.MockApplicationEx in project buck by facebook.
the class BuckClientTest method testConnectDisconnect.
@Test
public void testConnectDisconnect() {
Extensions.registerAreaClass("IDEA_PROJECT", null);
MockDisposable mockDisposable = new MockDisposable();
MockApplication application = new MockApplicationEx(mockDisposable);
ApplicationManager.setApplication(application, mockDisposable);
Project project = new MockProjectEx(new MockDisposable());
TestBuckEventHandler handler = new TestBuckEventHandler();
BuckSocket buckSocket = new BuckSocket(handler);
BuckClientManager.getOrCreateClient(project, handler).setBuckSocket(buckSocket);
BuckClientManager.getOrCreateClient(project, handler).connect();
buckSocket.onConnect(new MockSession());
BuckClientManager.getOrCreateClient(project, handler).disconnectWithoutRetry();
buckSocket.onClose(0, "FOO");
assertFalse(BuckClientManager.getOrCreateClient(project, handler).isConnected());
}
use of com.intellij.mock.MockApplicationEx in project android by JetBrains.
the class SdkComponentSourceTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
//noinspection Convert2Lambda Since otherwise it desn't create new instances.
myDisposable = new Disposable() {
@Override
public void dispose() {
}
};
MockApplicationEx instance = new MockApplicationEx(myDisposable);
instance.registerService(ExternalComponentManager.class, ExternalComponentManagerImpl.class);
instance.registerService(UpdateSettings.class, UpdateSettings.class);
ApplicationManager.setApplication(instance, myDisposable);
myFileOp = new MockFileOp();
myFileOp.recordExistingFile("/sdk/noRemote/package.xml", getLocalRepoXml("noRemote", new Revision(1)));
myFileOp.recordExistingFile("/sdk/newerRemote/package.xml", getLocalRepoXml("newerRemote", new Revision(1)));
myFileOp.recordExistingFile("/sdk/sameRemote/package.xml", getLocalRepoXml("sameRemote", new Revision(1)));
myFileOp.recordExistingFile("/sdk/olderRemote/package.xml", getLocalRepoXml("olderRemote", new Revision(1, 2)));
myFileOp.recordExistingFile("/sdk/hasPreview/package.xml", getLocalRepoXml("hasPreview", new Revision(1)));
myFileOp.recordExistingFile("/sdk/newerPreview/package.xml", getLocalRepoXml("newerPreview", new Revision(1, 0, 0, 1)));
myFileOp.recordExistingFile("/sdk/samePreview/package.xml", getLocalRepoXml("samePreview", new Revision(1, 0, 0, 1)));
myFileOp.recordExistingFile("/sdk/olderPreview/package.xml", getLocalRepoXml("olderPreview", new Revision(2)));
myFileOp.recordExistingFile("/sdk/zNewerInBeta/package.xml", getLocalRepoXml("zNewerInBeta", new Revision(1)));
final FakeDownloader downloader = new FakeDownloader(myFileOp);
List<String> remotePaths = Lists.newArrayList();
List<Revision> remoteRevisions = Lists.newArrayList();
List<Integer> remoteChannels = Lists.newArrayList();
remotePaths.add("newerRemote");
remoteRevisions.add(new Revision(1, 1));
remoteChannels.add(0);
remotePaths.add("sameRemote");
remoteRevisions.add(new Revision(1));
remoteChannels.add(0);
remotePaths.add("olderRemote");
remoteRevisions.add(new Revision(1, 1));
remoteChannels.add(0);
remotePaths.add("hasPreview");
remoteRevisions.add(new Revision(1, 0, 0, 1));
remoteChannels.add(0);
remotePaths.add("newerPreview");
remoteRevisions.add(new Revision(1, 0, 0, 2));
remoteChannels.add(0);
remotePaths.add("samePreview");
remoteRevisions.add(new Revision(1, 0, 0, 1));
remoteChannels.add(0);
remotePaths.add("olderPreview");
remoteRevisions.add(new Revision(1, 0, 0, 1));
remoteChannels.add(0);
remotePaths.add("onlyRemote");
remoteRevisions.add(new Revision(1));
remoteChannels.add(0);
remotePaths.add("zNewerInBeta");
remoteRevisions.add(new Revision(2));
remoteChannels.add(1);
String url = "http://example.com/repo";
downloader.registerUrl(new URL(url), getRepoXml(remotePaths, remoteRevisions, remoteChannels, true).getBytes());
final RepoManager mgr = new RepoManagerImpl(myFileOp);
mgr.setLocalPath(new File("/sdk"));
mgr.registerSchemaModule(AndroidSdkHandler.getRepositoryModule());
mgr.registerSchemaModule(AndroidSdkHandler.getCommonModule());
mgr.registerSourceProvider(new FakeRepositorySourceProvider(ImmutableList.<RepositorySource>of(new SimpleRepositorySource(url, "dummy", true, mgr.getSchemaModules(), null))));
myChannelId = 0;
myTestComponentSource = new SdkComponentSource() {
@Nullable
@Override
public List<String> getAllChannels() {
return null;
}
@Override
@NotNull
RepoManager getRepoManager() {
return mgr;
}
@NotNull
@Override
SettingsController getSettingsController() {
return new FakeSettingsController(false) {
@Override
public Channel getChannel() {
return Channel.create(myChannelId);
}
};
}
@NotNull
@Override
Downloader getDownloader(@Nullable ProgressIndicator indicator) {
return downloader;
}
};
}
use of com.intellij.mock.MockApplicationEx in project android by JetBrains.
the class FormFactorApiComboBoxTest method setUp.
@Before
public void setUp() throws Exception {
//noinspection Convert2Lambda Since otherwise it doesn't create new instances.
myDisposable = new Disposable() {
@Override
public void dispose() {
}
};
MockApplicationEx instance = new MockApplicationEx(myDisposable);
instance.registerService(PropertiesComponent.class, ProjectPropertiesComponentImpl.class);
ApplicationManager.setApplication(instance, myDisposable);
}
use of com.intellij.mock.MockApplicationEx in project kotlin by JetBrains.
the class KtPlatformLiteFixture method initApplication.
public void initApplication() {
MockApplicationEx instance = new MockApplicationEx(getTestRootDisposable());
ApplicationManager.setApplication(instance, new Getter<FileTypeRegistry>() {
@Override
public FileTypeRegistry get() {
return FileTypeManager.getInstance();
}
}, getTestRootDisposable());
getApplication().registerService(EncodingManager.class, CoreEncodingProjectManager.class);
}
Aggregations