[tests] adds a couple of regression tests for IDEA-12099

This commit is contained in:
Roman Shevchenko
2017-03-09 10:38:41 +01:00
parent 528d72e793
commit 4e4f40b003
2 changed files with 34 additions and 5 deletions
@@ -454,14 +454,11 @@ class FileWatcherTest : BareTestFixtureTestCase() {
assertEvents({ file.renameTo(newFile) }, mapOf(newFile to 'P'))
}
// tests the same scenario with an active file watcher (prevents explicit marking of refreshed paths)
// tests the same scenarios with an active file watcher (prevents explicit marking of refreshed paths)
@Test fun testPartialRefresh() = LocalFileSystemTest.doTestPartialRefresh(tempDir.newFolder("top"))
// tests the same scenario with an active file watcher (prevents explicit marking of refreshed paths)
@Test fun testInterruptedRefresh() = LocalFileSystemTest.doTestInterruptedRefresh(tempDir.newFolder("top"))
// tests the same scenario with an active file watcher (prevents explicit marking of refreshed paths)
@Test fun testRefreshAndFindFile() = LocalFileSystemTest.doTestRefreshAndFindFile(tempDir.newFolder("top"))
@Test fun testRefreshEquality() = LocalFileSystemTest.doTestRefreshEquality(tempDir.newFolder("top"))
@Test fun testUnicodePaths() {
val root = tempDir.newFolder(UNICODE_NAME_1)
@@ -177,6 +177,38 @@ public class LocalFileSystemTest extends PlatformTestCase {
assertNotNull(lfs.refreshAndFindFileByPath(file3.getPath()));
}
public void testRefreshEquality() throws IOException {
doTestRefreshEquality(createTempDirectory());
}
public static void doTestRefreshEquality(@NotNull File tempDir) throws IOException {
LocalFileSystem lfs = LocalFileSystem.getInstance();
VirtualFile tempVDir = lfs.refreshAndFindFileByPath(tempDir.getPath());
assertNotNull(tempVDir);
assertEquals(0, tempVDir.getChildren().length);
FileUtil.writeToFile(new File(tempDir, "file1.txt"), "hello");
tempVDir.refresh(false, false);
assertEquals(1, tempVDir.getChildren().length);
FileUtil.writeToFile(new File(tempDir, "file2.txt"), "hello");
tempVDir.refresh(false, true);
assertEquals(2, tempVDir.getChildren().length);
File tempDir1 = IoTestUtil.createTestDir(tempDir, "sub1");
VirtualFile tempVDir1 = lfs.refreshAndFindFileByIoFile(tempDir1);
assertNotNull(tempVDir1);
FileUtil.writeToFile(new File(tempDir1, "file.txt"), "hello");
tempVDir1.refresh(false, false);
assertEquals(1, tempVDir1.getChildren().length);
File tempDir2 = IoTestUtil.createTestDir(tempDir, "sub2");
VirtualFile tempVDir2 = lfs.refreshAndFindFileByIoFile(tempDir2);
assertNotNull(tempVDir2);
FileUtil.writeToFile(new File(tempDir2, "file.txt"), "hello");
tempVDir2.refresh(false, true);
assertEquals(1, tempVDir2.getChildren().length);
}
public void testCopyFile() throws Exception {
File fromDir = createTempDirectory();
File toDir = createTempDirectory();