diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.kt b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.kt index 57f92ef47f85..b49d38c781db 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.kt @@ -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) diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java index c0c90fdff9f8..92059ffc43ea 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java @@ -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();