use of com.intellij.mock.MockVirtualFile in project intellij-community by JetBrains.
the class FileDocumentManagerImplTest method testConvertSeparators.
public void testConvertSeparators() throws Exception {
final VirtualFile file = new MockVirtualFile("test.txt", "test\rtest");
Document document = myDocumentManager.getDocument(file);
assertNotNull(file.toString(), document);
assertEquals("test\ntest", document.getText());
}
use of com.intellij.mock.MockVirtualFile in project intellij-community by JetBrains.
the class FileDocumentManagerImplTest method testContentChanged_doNotReloadChangedDocumentOnSave.
public void testContentChanged_doNotReloadChangedDocumentOnSave() throws Exception {
final MockVirtualFile file = new MockVirtualFile("test.txt", "test") {
@Override
public void refresh(boolean asynchronous, boolean recursive, Runnable postRunnable) {
long oldStamp = getModificationStamp();
setModificationStamp(LocalTimeCounter.currentTime());
myDocumentManager.contentsChanged(new VirtualFileEvent(null, this, null, oldStamp, getModificationStamp()));
}
};
myReloadFromDisk = Boolean.FALSE;
final Document document = myDocumentManager.getDocument(file);
assertNotNull(file.toString(), document);
WriteCommandAction.runWriteCommandAction(myProject, () -> document.insertString(0, "old "));
long documentStamp = document.getModificationStamp();
file.setContent(null, "xxx", false);
myDocumentManager.saveAllDocuments();
assertEquals("old test", document.getText());
assertEquals(file.getModificationStamp(), document.getModificationStamp());
assertEquals("old test", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
assertEquals(documentStamp, document.getModificationStamp());
}
use of com.intellij.mock.MockVirtualFile in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineFlexibleFrameworkDetectorTest method createSuitableFilePattern_withInvalidFilename_doesNotMatch.
@Test
public void createSuitableFilePattern_withInvalidFilename_doesNotMatch() {
// unaccepted file name pattern, although correct content.
MockVirtualFile invalidNameFile = new MockVirtualFile("myApp.yaml");
FileContent wrongFile = new FileContentImpl(invalidNameFile, VALID_APP_ENGINE_FLEX_YAML_CONTENT, System.currentTimeMillis());
assertThat(pattern.accepts(wrongFile)).isFalse();
}
use of com.intellij.mock.MockVirtualFile in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineFlexibleFrameworkDetectorTest method createSuitableFilePattern_appYaml_withValidContent_matches.
@Test
public void createSuitableFilePattern_appYaml_withValidContent_matches() {
MockVirtualFile validAppEngineFlexFile = new MockVirtualFile("app.yaml");
FileContent validAppEngineFlexFileContent = new FileContentImpl(validAppEngineFlexFile, VALID_APP_ENGINE_FLEX_YAML_CONTENT, System.currentTimeMillis());
assertThat(pattern.accepts(validAppEngineFlexFileContent)).isTrue();
}
use of com.intellij.mock.MockVirtualFile in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineFlexibleFrameworkDetectorTest method createSuitableFilePattern_appYml_withValidContent_matches.
@Test
public void createSuitableFilePattern_appYml_withValidContent_matches() {
MockVirtualFile validAppEngineFlexFile = new MockVirtualFile("app.yml");
FileContent validAppEngineFlexFileContent = new FileContentImpl(validAppEngineFlexFile, VALID_APP_ENGINE_FLEX_YAML_CONTENT, System.currentTimeMillis());
assertThat(pattern.accepts(validAppEngineFlexFileContent)).isTrue();
}
Aggregations