use of com.intellij.mock.MockApplication 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.intellij.mock.MockApplication 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.intellij.mock.MockApplication 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.intellij.mock.MockApplication in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugHistoricalSnapshotsTest method setUp.
@Before
public void setUp() {
MockApplication application = new MyMockApplicationEx(parent);
ActionManagerEx manager = Mockito.mock(ActionManagerEx.class);
ActionToolbar actionToolbar = Mockito.mock(ActionToolbar.class);
Mockito.when(actionToolbar.getComponent()).thenReturn(new JComponent() {
});
Mockito.when(manager.createActionToolbar(Mockito.anyString(), Mockito.any(ActionGroup.class), Mockito.anyBoolean())).thenReturn(actionToolbar);
Mockito.when(manager.createActionToolbar(Mockito.anyString(), Mockito.any(ActionGroup.class), Mockito.anyBoolean(), Mockito.anyBoolean())).thenReturn(actionToolbar);
application.addComponent(ActionManager.class, manager);
application.registerService(UISettings.class);
ApplicationManager.setApplication(application, parent);
XDebugSession session = Mockito.mock(XDebugSession.class);
Mockito.when(handler.getProcess()).thenReturn(mockProcess);
Mockito.when(mockProcess.getXDebugSession()).thenReturn(session);
}
use of com.intellij.mock.MockApplication 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;
}
Aggregations