From 96dda9f7a3cc7365feba594a7d749de007f04ac0 Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Fri, 10 Mar 2017 17:12:26 +0300 Subject: [PATCH] [vcs]: cleanUp and fix tests --- .../ui/DirectoryHistoryDialogPatchCreationTest.java | 4 +++- .../testSrc/hg4idea/test/history/HgHistoryTest.java | 13 +++++++------ .../hg4idea/test/merge/HgMergeProviderTest.java | 8 +++++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/history/integration/ui/DirectoryHistoryDialogPatchCreationTest.java b/platform/platform-tests/testSrc/com/intellij/history/integration/ui/DirectoryHistoryDialogPatchCreationTest.java index d739ac5bf2b9..bb31fd193cd3 100644 --- a/platform/platform-tests/testSrc/com/intellij/history/integration/ui/DirectoryHistoryDialogPatchCreationTest.java +++ b/platform/platform-tests/testSrc/com/intellij/history/integration/ui/DirectoryHistoryDialogPatchCreationTest.java @@ -23,11 +23,13 @@ import java.nio.charset.Charset; public class DirectoryHistoryDialogPatchCreationTest extends PatchingTestCase { public void testPatchCreation() throws Exception { + + DirectoryHistoryDialogModel m = new DirectoryHistoryDialogModel(myProject, myGateway, getVcs(), myRoot); + m.clearRevisions(); createChildDataWithContent(myRoot, "f1.txt"); createChildDataWithContent(myRoot, "f2.txt"); createChildDataWithContent(myRoot, "f3.txt"); - DirectoryHistoryDialogModel m = new DirectoryHistoryDialogModel(myProject, myGateway, getVcs(), myRoot); assertSize(6, m.getRevisions()); m.selectRevisions(0, 5); diff --git a/plugins/hg4idea/testSrc/hg4idea/test/history/HgHistoryTest.java b/plugins/hg4idea/testSrc/hg4idea/test/history/HgHistoryTest.java index 14727970c97e..754577337366 100644 --- a/plugins/hg4idea/testSrc/hg4idea/test/history/HgHistoryTest.java +++ b/plugins/hg4idea/testSrc/hg4idea/test/history/HgHistoryTest.java @@ -16,6 +16,7 @@ package hg4idea.test.history; import com.intellij.openapi.vcs.FilePath; +import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.vcsUtil.VcsUtil; @@ -63,7 +64,7 @@ public class HgHistoryTest extends HgPlatformTest { int namesSize = names.length; VirtualFile subDir = myRepository.findFileByRelativePath(subDirName); assert subDir != null; - VirtualFile vFile = subDir.findFileByRelativePath(names[namesSize - 1]); + VirtualFile vFile = VfsUtil.findFileByIoFile(new File(subDir.getPath(),names[namesSize - 1]), true); assert vFile != null; HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(vFile)); HgLogCommand logCommand = new HgLogCommand(myProject); @@ -86,7 +87,7 @@ public class HgHistoryTest extends HgPlatformTest { //find file with parent revision name VirtualFile subDir = myRepository.findFileByRelativePath(subDirName); assert subDir != null; - VirtualFile vFile = subDir.findFileByRelativePath(names[namesSize - 1]); + VirtualFile vFile = VfsUtil.findFileByIoFile(new File(subDir.getPath(),names[namesSize - 1]), true); assert vFile != null; HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(vFile)); HgLogCommand logCommand = new HgLogCommand(myProject); @@ -105,9 +106,9 @@ public class HgHistoryTest extends HgPlatformTest { int namesSize = names.length; VirtualFile subDir = myRepository.findFileByRelativePath(subDirName); assert subDir != null; - VirtualFile currentVirtualFile = subDir.findFileByRelativePath(names[namesSize - 1]); - assert currentVirtualFile != null; - HgFile localFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(currentVirtualFile)); + VirtualFile vFile = VfsUtil.findFileByIoFile(new File(subDir.getPath(), names[namesSize - 1]), true); + assert vFile != null; + HgFile localFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(vFile)); HgLogCommand logCommand = new HgLogCommand(myProject); logCommand.setFollowCopies(true); List revisions = logCommand.execute(localFile, -1, true); @@ -126,7 +127,7 @@ public class HgHistoryTest extends HgPlatformTest { cd(subDir); int namesSize = names.length; String beforeName = names[namesSize - 1]; - VirtualFile before = subDir.findFileByRelativePath(beforeName); + VirtualFile before = VfsUtil.findFileByIoFile(new File(subDir.getPath(), beforeName), true); assert before != null; FilePath filePath = VcsUtil.getFilePath(VfsUtilCore.virtualToIoFile(before)); final String renamed = "renamed"; diff --git a/plugins/hg4idea/testSrc/hg4idea/test/merge/HgMergeProviderTest.java b/plugins/hg4idea/testSrc/hg4idea/test/merge/HgMergeProviderTest.java index ed7896a12211..d3d58d9a9be0 100644 --- a/plugins/hg4idea/testSrc/hg4idea/test/merge/HgMergeProviderTest.java +++ b/plugins/hg4idea/testSrc/hg4idea/test/merge/HgMergeProviderTest.java @@ -19,6 +19,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.merge.MergeData; import com.intellij.openapi.vcs.merge.MergeProvider; +import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.EdtTestUtil; import hg4idea.test.HgPlatformTest; @@ -94,7 +95,7 @@ public class HgMergeProviderTest extends HgPlatformTest { hg("commit -m " + COMMIT_MESSAGE); updateProject(); //committing conflicting change - verifyMergeData(myChildRepo.findChild(childFile.getName()), "basic", "local", "server"); + verifyMergeData(childFile, "basic", "local", "server"); } public void testMergeWithUncommittedLocalChange() throws Exception { @@ -112,7 +113,7 @@ public class HgMergeProviderTest extends HgPlatformTest { HgTestUtil.printToFile(childFile, "local"); updateProject(); //uncommitted conflicting change - verifyMergeData(myChildRepo.findChild(childFile.getName()), "basic", "local", "server"); + verifyMergeData(childFile, "basic", "local", "server"); } public void testFileAddedAndCommitted() throws Exception { @@ -129,6 +130,7 @@ public class HgMergeProviderTest extends HgPlatformTest { //Add a file with the same name, but different content in child repository, commit. cd(myChildRepo); touch(bFile, "local"); + myChildRepo.refresh(false, true); hg("add " + bFile); hg("commit -m " + COMMIT_MESSAGE); @@ -193,6 +195,6 @@ public class HgMergeProviderTest extends HgPlatformTest { } private static void assertEquals(String s, byte[] bytes) { - Assert.assertEquals(s, new String(bytes)); + Assert.assertEquals(s, new String(bytes, CharsetToolkit.UTF8_CHARSET)); } }