public void testDoesNotSetContentIfFileIsToBeDeleted() throws Exception {
    VirtualFile f = root.createChildData(null, "f.txt");
    f.setBinaryContent(new byte[] {1});

    LoggingVirtualFileAdapter a = new LoggingVirtualFileAdapter();
    addFileListenerDuring(
        a,
        new RunnableAdapter() {
          @Override
          public void doRun() throws IOException {
            revertChange(root, 1);
          }
        });

    assertEquals("fileDeleted ", a.getLog());
  }
  public void testApplyingOnlyLastContent() throws Exception {
    VirtualFile f = root.createChildData(null, "f.txt");
    f.setBinaryContent(new byte[] {1}, -1, 1000);
    f.setBinaryContent(new byte[] {2}, -1, 2000);
    f.setBinaryContent(new byte[] {3}, -1, 3000);
    f.setBinaryContent(new byte[] {4}, -1, 4000);

    LoggingVirtualFileAdapter a = new LoggingVirtualFileAdapter();
    addFileListenerDuring(
        a,
        new RunnableAdapter() {
          @Override
          public void doRun() throws IOException {
            revertChange(root, 2);
          }
        });

    assertEquals("contentChanged ", a.getLog());
    assertEquals(1, f.contentsToByteArray()[0]);
    assertEquals(1000, f.getTimeStamp());
  }
  public void testApplyingRightContentEvenIfFileWasMoved() throws Exception {
    VirtualFile dir = root.createChildDirectory(null, "dir");
    VirtualFile f = root.createChildData(null, "f.txt");

    f.setBinaryContent(new byte[] {1});
    f.setBinaryContent(new byte[] {2});
    f.move(null, dir);
    f.setBinaryContent(new byte[] {3});

    LoggingVirtualFileAdapter a = new LoggingVirtualFileAdapter();
    addFileListenerDuring(
        a,
        new RunnableAdapter() {
          @Override
          public void doRun() throws IOException {
            revertChange(root, 2);
          }
        });

    assertEquals("fileMoved contentChanged ", a.getLog());
    assertEquals(1, f.contentsToByteArray()[0]);
  }