package com.intellij.localvcsperf;

import com.intellij.localvcs.core.revisions.Revision;
import com.intellij.localvcs.integration.ui.models.SelectionCalculator;
import org.junit.Before;
import org.junit.Test;

import java.util.List;


public class SelectionCalculatorTest extends LocalVcsPerformanceTestCase {
  private List<Revision> rr;
  private SelectionCalculator c;

  @Before
  public void setUp() {
    buildVcsTree();
    for (int i = 0; i < 100; i++) {
      vcs.changeFileContent("root/file1", cf("content" + i), -1);
    }
    rr = vcs.getRevisionsFor("root/file1");
    c = new SelectionCalculator(rr, 0, 0);
  }

  @Test
  public void testCalculationFromTheScratch() {
    assertExecutionTime(1, new Task() {
      public void execute() throws Exception {
        c.getSelectionFor(rr.get(100));
      }
    });
  }

  @Test
  public void testUsingCache() {
    c.getSelectionFor(rr.get(100));

    assertExecutionTime(1, new Task() {
      public void execute() throws Exception {
        c.getSelectionFor(rr.get(1));
        c.getSelectionFor(rr.get(50));
        c.getSelectionFor(rr.get(100));
      }
    });
  }
}

@@ -29,16 +29,49 @@
 sperf;%0A%0A
+import com.intellij.idea.Bombed;%0A
 import c
@@ -258,15 +258,100 @@
 til.
-List;%0A%0A
+Calendar;%0Aimport java.util.List;%0A%0A@Bombed(month = Calendar.AUGUST, day = 31, user = %22anton%22)
 %0Apub

test fixes