Search in sources :

Example 6 with MockApplication

use of com.intellij.mock.MockApplication 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());
}
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 7 with MockApplication

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

the class UsefulTestCase method checkForSettingsDamage.

protected void checkForSettingsDamage() {
    Application app = ApplicationManager.getApplication();
    if (isStressTest() || app == null || app instanceof MockApplication) {
        return;
    }
    CodeStyleSettings oldCodeStyleSettings = myOldCodeStyleSettings;
    if (oldCodeStyleSettings == null) {
        return;
    }
    myOldCodeStyleSettings = null;
    doCheckForSettingsDamage(oldCodeStyleSettings, getCurrentCodeStyleSettings());
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) MockApplication(com.intellij.mock.MockApplication) Application(com.intellij.openapi.application.Application) MockApplication(com.intellij.mock.MockApplication)

Aggregations

MockApplication (com.intellij.mock.MockApplication)7 MockDisposable (com.facebook.buck.intellij.ideabuck.test.util.MockDisposable)6 MockProjectEx (com.intellij.mock.MockProjectEx)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 ProjectPropertiesComponentImpl (com.intellij.ide.util.ProjectPropertiesComponentImpl)1 Mock (com.intellij.mock.Mock)1 MockFileDocumentManagerImpl (com.intellij.mock.MockFileDocumentManagerImpl)1 MockProject (com.intellij.mock.MockProject)1 Application (com.intellij.openapi.application.Application)1 FileTypeManager (com.intellij.openapi.fileTypes.FileTypeManager)1 VirtualFileManager (com.intellij.openapi.vfs.VirtualFileManager)1 PsiDocumentManager (com.intellij.psi.PsiDocumentManager)1 CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)1 Field (java.lang.reflect.Field)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1 EasyMock (org.easymock.EasyMock)1