Java Code Examples for com.intellij.openapi.extensions.Extensions#registerAreaClass()

The following examples show how to use com.intellij.openapi.extensions.Extensions#registerAreaClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuckClientTest.java    From buck with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 2
Source File: BuckClientTest.java    From buck with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 3
Source File: BuckModuleTest.java    From buck with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: GradleDependencyFetcherTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeClass
public static void setUp() {
  Disposable disposable = Disposer.newDisposable();
  ApplicationManager.setApplication(new MockApplication(disposable), disposable);
  Extensions.registerAreaClass("IDEA_PROJECT", null);
  ourProject = new MockProject(ApplicationManager.getApplication().getPicoContainer(), disposable);
}
 
Example 5
Source File: TestUtils.java    From intellij with Apache License 2.0 5 votes vote down vote up
@NotNull
public static MockProject mockProject(
    @Nullable PicoContainer container, Disposable parentDisposable) {
  Extensions.registerAreaClass("IDEA_PROJECT", null);
  container = container != null ? container : new DefaultPicoContainer();
  return new MockProject(container, parentDisposable);
}
 
Example 6
Source File: BuckClientTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example 7
Source File: TestUtils.java    From intellij with Apache License 2.0 4 votes vote down vote up
static MockProject mockProject(@Nullable PicoContainer container, Disposable parentDisposable) {
  Extensions.registerAreaClass("IDEA_PROJECT", null);
  container = container != null ? container : new DefaultPicoContainer();
  return new MockProject(container, parentDisposable);
}
 
Example 8
Source File: BuckEventsConsumerTest.java    From buck with Apache License 2.0 4 votes vote down vote up
public MockProject initProject() {
  Extensions.registerAreaClass("IDEA_PROJECT", null);
  MockProject mockProject = new MockProjectEx(new MockDisposable());
  return mockProject;
}