use of com.facebook.buck.intellij.ideabuck.test.util.MockDisposable in project buck by facebook.
the class BuckClientTest method hasBuckDisconnectedThenWeReconnectIfSoSpecified.
@Test
public void hasBuckDisconnectedThenWeReconnectIfSoSpecified() {
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).disconnectWithRetry();
buckSocket.onClose(0, "FOO");
buckSocket.onConnect(new MockSession());
assertTrue(BuckClientManager.getOrCreateClient(project, handler).isConnected());
}
use of com.facebook.buck.intellij.ideabuck.test.util.MockDisposable in project buck by facebook.
the class BuckEventsConsumerTest method initialiseEventsConsumer.
public BuckEventsConsumer initialiseEventsConsumer() {
Extensions.registerAreaClass("IDEA_PROJECT", null);
MockDisposable mockDisposable = new MockDisposable();
MockProject project = new MockProjectEx(new MockDisposable());
MockApplication application = new MyMockApplication(mockDisposable);
ApplicationManager.setApplication(application, mockDisposable);
final BuckEventsConsumer buckEventsConsumer = new BuckEventsConsumer(project);
project.registerService(BuckUIManager.class, new BuckUIManager());
project.registerService(ToolWindowManager.class, new Mock.MyToolWindowManager());
application.registerService(FileDocumentManager.class, new MockFileDocumentManagerImpl(null, null));
application.registerService(VirtualFileManager.class, EasyMock.createMock(VirtualFileManager.class));
return buckEventsConsumer;
}
use of com.facebook.buck.intellij.ideabuck.test.util.MockDisposable in project buck by facebook.
the class BuckClientTest method testMessages.
@Test
public void testMessages() {
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();
BuckClient client = BuckClientManager.getOrCreateClient(project, handler);
// Set the socket we control
BuckSocket socket = new BuckSocket(handler);
client.setBuckSocket(socket);
client.connect();
assertEquals("", handler.getLastMessage());
socket.onMessage("some text");
assertEquals("some text", handler.getLastMessage());
socket.onMessage("some text 1");
socket.onMessage("some text 2");
socket.onMessage("some text 3");
socket.onMessage("some text 4");
assertEquals("some text 4", handler.getLastMessage());
}
use of com.facebook.buck.intellij.ideabuck.test.util.MockDisposable in project buck by facebook.
the class BuckModuleTest method initBuckModule.
public Project initBuckModule() {
Extensions.registerAreaClass("IDEA_PROJECT", null);
MockDisposable mockDisposable = new MockDisposable();
MockProjectEx project = new MockProjectEx(mockDisposable);
MockApplication application = new MockApplicationEx(mockDisposable);
ApplicationManager.setApplication(application, mockDisposable);
application.registerService(UISettings.class, UISettings.getShadowInstance());
application.registerService(PropertiesComponent.class, new ProjectPropertiesComponentImpl());
FileTypeManager fileTypeManager = EasyMock.createMock(FileTypeManager.class);
EasyMock.expect(fileTypeManager.getFileTypeByFileName(BuckFileType.INSTANCE.getDefaultExtension())).andReturn(BuckFileType.INSTANCE).times(3);
EasyMock.replay(fileTypeManager);
application.registerService(FileTypeManager.class, fileTypeManager);
project.addComponent(PsiDocumentManager.class, EasyMock.createMock(PsiDocumentManager.class));
return project;
}
use of com.facebook.buck.intellij.ideabuck.test.util.MockDisposable in project buck by facebook.
the class BuckEventsConsumerTest method hasBuckModuleAttachReceivedNullTargetThenWeShowNone.
@Test
public void hasBuckModuleAttachReceivedNullTargetThenWeShowNone() throws NoSuchFieldException, IllegalAccessException {
Extensions.registerAreaClass("IDEA_PROJECT", null);
MockDisposable mockDisposable = new MockDisposable();
MockApplication application = new MockApplicationEx(mockDisposable);
ApplicationManager.setApplication(application, mockDisposable);
BuckEventsConsumer buckEventsConsumer = new BuckEventsConsumer(new MockProjectEx(new MockDisposable()));
buckEventsConsumer.attach(null, new DefaultTreeModel(null));
Field privateStringField = BuckEventsConsumer.class.getDeclaredField("mTarget");
privateStringField.setAccessible(true);
String fieldValue = (String) privateStringField.get(buckEventsConsumer);
assertEquals(fieldValue, "NONE");
}
Aggregations