import javax.swing.JDialog; //导入方法依赖的package包/类
public void testDiffView () throws Throwable {
// create a file and initial commit
File file = new File(wc, "file.txt");
file.createNewFile();
// chain of change & commit
StringBuilder content = new StringBuilder();
for (int i = 1; i < 10; ++i) {
for (int j = 1; j < 20; ++j) {
content.append("File change number ").append(i).append("_").append(j).append("\n");
}
TestKit.write(file, content.toString());
System.out.println("Commit nbr. " + i);
TestKit.commit(wc);
}
// local changes
// changes every few lines
int pos = content.indexOf("\n");
while (pos != -1) {
int nextPos = content.indexOf("\n", pos + 30);
if (nextPos == -1) {
pos = -1;
} else {
String replaceString = "Local change \nLocal change \nLocal change \n";
content.replace(pos + 1, nextPos, replaceString);
pos = nextPos + nextPos - pos + replaceString.length();
// every 5 next lines
for (int i = 0; i < 5 && pos != -1; ++i) {
pos = content.indexOf("\n", pos + 1);
}
}
}
TestKit.write(file, content.toString());
boolean showing = SvnSearchHistorySupport.getInstance(file).searchHistory(100);
assertTrue(showing);
JDialog d = new JDialog((JFrame)null, "Close dialog");
d.setModal(false);
d.setVisible(true);
while (d.isVisible()) {
Thread.sleep(1000);
}
}