Search in sources :

Example 1 with MockProjectEx

use of com.intellij.mock.MockProjectEx 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());
}
Also used : Project(com.intellij.openapi.project.Project) MockApplicationEx(com.intellij.mock.MockApplicationEx) MockSession(com.facebook.buck.intellij.ideabuck.test.util.MockSession) MockApplication(com.intellij.mock.MockApplication) MockDisposable(com.facebook.buck.intellij.ideabuck.test.util.MockDisposable) MockProjectEx(com.intellij.mock.MockProjectEx) Test(org.junit.Test)

Example 2 with MockProjectEx

use of com.intellij.mock.MockProjectEx 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;
}
Also used : MockProject(com.intellij.mock.MockProject) MockFileDocumentManagerImpl(com.intellij.mock.MockFileDocumentManagerImpl) MockApplication(com.intellij.mock.MockApplication) MyMockApplication(com.facebook.buck.intellij.ideabuck.test.util.MyMockApplication) VirtualFileManager(com.intellij.openapi.vfs.VirtualFileManager) MockDisposable(com.facebook.buck.intellij.ideabuck.test.util.MockDisposable) MyMockApplication(com.facebook.buck.intellij.ideabuck.test.util.MyMockApplication) MockProjectEx(com.intellij.mock.MockProjectEx) EasyMock(org.easymock.EasyMock) Mock(com.intellij.mock.Mock)

Example 3 with MockProjectEx

use of com.intellij.mock.MockProjectEx 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());
}
Also used : Project(com.intellij.openapi.project.Project) MockApplicationEx(com.intellij.mock.MockApplicationEx) MockApplication(com.intellij.mock.MockApplication) MockDisposable(com.facebook.buck.intellij.ideabuck.test.util.MockDisposable) MockProjectEx(com.intellij.mock.MockProjectEx) Test(org.junit.Test)

Example 4 with MockProjectEx

use of com.intellij.mock.MockProjectEx in project intellij-community by JetBrains.

the class ActivityMonitorTest method testReady.

public void testReady() {
    assertReady(null);
    MockProject project1 = new MockProjectEx(getTestRootDisposable());
    assertReady(project1);
    MockProject project2 = new MockProjectEx(getTestRootDisposable());
    assertReady(project2);
    myMonitor.initBusyObjectFor(project1);
    assertTrue(myMonitor.hasObjectFor(project1));
    myMonitor.initBusyObjectFor(project2);
    assertTrue(myMonitor.hasObjectFor(project2));
    myMonitor.addActivity(new UiActivity("global"), ModalityState.any());
    assertBusy(null);
    assertBusy(project1);
    assertBusy(project2);
    myMonitor.addActivity(new UiActivity("global"), ModalityState.any());
    assertBusy(null);
    assertBusy(project1);
    assertBusy(project2);
    myMonitor.removeActivity(new UiActivity("global"));
    assertReady(null);
    assertReady(project1);
    assertReady(project2);
    myMonitor.addActivity(project1, new UiActivity("p1"), ModalityState.any());
    assertReady(null);
    assertBusy(project1);
    assertReady(project2);
    myMonitor.addActivity(new UiActivity("global"), ModalityState.any());
    assertBusy(null);
    assertBusy(project1);
    assertBusy(project2);
    myMonitor.removeActivity(new UiActivity("global"));
    assertReady(null);
    assertBusy(project1);
    assertReady(project2);
    myMonitor.removeActivity(project1, new UiActivity("p1"));
    assertReady(null);
    assertReady(project1);
    assertReady(project2);
}
Also used : MockProject(com.intellij.mock.MockProject) MockProjectEx(com.intellij.mock.MockProjectEx)

Example 5 with MockProjectEx

use of com.intellij.mock.MockProjectEx in project ServiceStack.Java by ServiceStack.

the class AddRefTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    initApplication();
    Extensions.registerAreaClass("IDEA_PROJECT", null);
    myProject = new MockProjectEx(getTestRootDisposable());
    windowManager = new TestWindowManager();
    getApplication().registerService(WindowManager.class, windowManager);
}
Also used : TestWindowManager(com.intellij.openapi.wm.impl.TestWindowManager) MockProjectEx(com.intellij.mock.MockProjectEx)

Aggregations

MockProjectEx (com.intellij.mock.MockProjectEx)10 MockDisposable (com.facebook.buck.intellij.ideabuck.test.util.MockDisposable)6 MockApplication (com.intellij.mock.MockApplication)6 MockApplicationEx (com.intellij.mock.MockApplicationEx)5 Test (org.junit.Test)4 Project (com.intellij.openapi.project.Project)3 MockSession (com.facebook.buck.intellij.ideabuck.test.util.MockSession)2 MyMockApplication (com.facebook.buck.intellij.ideabuck.test.util.MyMockApplication)2 MockProject (com.intellij.mock.MockProject)2 PsiManager (com.intellij.psi.PsiManager)2 Breakpoint (com.google.api.services.clouddebugger.v2.model.Breakpoint)1 SetBreakpointHandler (com.google.cloud.tools.intellij.debugger.CloudDebugProcessStateController.SetBreakpointHandler)1 CloudLineBreakpoint (com.google.cloud.tools.intellij.debugger.CloudLineBreakpointType.CloudLineBreakpoint)1 CredentialedUser (com.google.cloud.tools.intellij.login.CredentialedUser)1 IntegratedGoogleLoginService (com.google.cloud.tools.intellij.login.IntegratedGoogleLoginService)1 GoogleLoginState (com.google.gdt.eclipse.login.common.GoogleLoginState)1 ProjectPropertiesComponentImpl (com.intellij.ide.util.ProjectPropertiesComponentImpl)1 Mock (com.intellij.mock.Mock)1 MockFileDocumentManagerImpl (com.intellij.mock.MockFileDocumentManagerImpl)1 FileTypeManager (com.intellij.openapi.fileTypes.FileTypeManager)1