History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEA-9239
Type: New Feature New Feature
Status: Open Open
Assignee: Eugene Zhuravlev
Reporter: Keith Lea
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
IDEA: Feedback

TestEditorManagerImpl should support editor listeners

Created: 07 Sep 06 21:04   Updated: 06 Mar 07 21:48
Component/s: Plugin Support. API

Build: 6,148
Severity: Low


 Description  « Hide
Currently any added listeners are never called.

 All   Comments   Work Log   Change History      Sort Order:
Keith Lea - 03 Mar 07 02:42
Here's a test case you can copy and paste into your codebase! When it passes, this bug is fixed.
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.ex.dummy.DummyFileSystem;
import com.intellij.testFramework.IdeaTestCase;

public class FileEditorTest extends IdeaTestCase {
  public void testDummyFileEditorManagerFiresEvents() throws Exception {
    VirtualFile root = DummyFileSystem.getInstance().createRoot("root");
    VirtualFile textFile = root.createChildData(null, "ok.txt");
    FileEditorManager editorMgr = FileEditorManager.getInstance(getProject());
    final VirtualFile[] opened = {null};
    editorMgr.addFileEditorManagerListener(new FileEditorManagerAdapter() {
      public void fileOpened(FileEditorManager source, VirtualFile file) {
        if (opened[0] != null) {
          fail();
        }
        opened[0] = file;
      }
    });
    editorMgr.openFile(textFile, false);
    assertEquals(textFile, opened[0]);
  }
}