use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.
the class FileStoreFileBufferFunctions method test5.
/*
* Tests getModificationStamp.
*/
@Test
public void test5() throws Exception {
fManager.connectFileStore(fFileStore, null);
try {
ITextFileBuffer fileBuffer = fManager.getFileStoreTextFileBuffer(fFileStore);
long modificationStamp = fileBuffer.getModificationStamp();
IFileInfo fileInfo = fFileStore.fetchInfo();
assertEquals(modificationStamp != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP, fileInfo.exists());
fileInfo.setLastModified(1000);
if (fileInfo.exists())
fFileStore.putInfo(fileInfo, EFS.SET_LAST_MODIFIED, null);
long lastModified = fFileStore.fetchInfo().getLastModified();
assertTrue(lastModified == EFS.NONE || modificationStamp != fileBuffer.getModificationStamp());
} finally {
fManager.disconnectFileStore(fFileStore, null);
}
}
use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.
the class FileStoreFileBufferFunctions method test15.
/*
* Test IFileBufferListener#underlyingFileMoved
*/
@Test
public void test15() throws Exception {
class Listener extends FileBufferListener {
public IFileBuffer buffer;
public int count;
public IPath newLocation;
@Override
public void underlyingFileMoved(IFileBuffer buf, IPath location) {
++count;
this.buffer = buf;
this.newLocation = location;
}
}
Listener listener = new Listener();
fManager.addFileBufferListener(listener);
try {
ITextFileBuffer fileBuffer = fManager.getFileStoreTextFileBuffer(fFileStore);
assertTrue(listener.count == 0 && listener.buffer == null);
fManager.connectFileStore(fFileStore, null);
try {
fileBuffer = fManager.getFileStoreTextFileBuffer(fFileStore);
IPath newLocation = moveUnderlyingFile();
if (newLocation != null) {
assertTrue(listener.count == 1);
assertTrue(listener.buffer == fileBuffer);
assertEquals(listener.newLocation, newLocation);
}
} finally {
fManager.disconnectFileStore(fFileStore, null);
}
} finally {
fManager.removeFileBufferListener(listener);
}
}
use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.
the class FileStoreFileBufferFunctions method test11_1.
/*
* Test IFileBufferListener#dirtyStateChanged
*/
@Test
public void test11_1() throws Exception {
class Listener extends FileBufferListener {
public IFileBuffer buffer;
public int count;
public boolean isDirty;
@Override
public void dirtyStateChanged(IFileBuffer buf, boolean state) {
++count;
this.buffer = buf;
this.isDirty = state;
}
}
Listener listener = new Listener();
fManager.addFileBufferListener(listener);
try {
ITextFileBuffer fileBuffer = fManager.getFileStoreTextFileBuffer(fFileStore);
assertTrue(listener.count == 0 && listener.buffer == null);
fManager.connectFileStore(fFileStore, null);
try {
fileBuffer = fManager.getFileStoreTextFileBuffer(fFileStore);
IDocument document = fileBuffer.getDocument();
document.replace(0, 0, "prefix");
assertTrue(listener.count == 1);
assertTrue(listener.buffer == fileBuffer);
assertTrue(listener.isDirty);
fileBuffer.commit(null, true);
assertTrue(listener.count == 2);
assertTrue(listener.buffer == fileBuffer);
assertFalse(listener.isDirty);
} finally {
fManager.disconnectFileStore(fFileStore, null);
}
} finally {
fManager.removeFileBufferListener(listener);
}
}
use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.
the class FileStoreFileBufferFunctions method test9_2.
/*
* Test resetStateValidation.
*/
@Test
public void test9_2() throws Exception {
fManager.connectFileStore(fFileStore, null);
try {
setReadOnly(true);
ITextFileBuffer fileBuffer = fManager.getFileStoreTextFileBuffer(fFileStore);
fileBuffer.validateState(null, null);
fileBuffer.resetStateValidation();
if (isStateValidationSupported())
assertFalse(fileBuffer.isStateValidated());
} finally {
setReadOnly(false);
fManager.disconnectFileStore(fFileStore, null);
}
}
use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.
the class FileBufferCreation method test3_2_new.
/*
* Tests the creation of a file buffer for a file in a linked folder.
*/
@Test
public void test3_2_new() throws Exception {
IPath path = createLinkedFolder("linkedFolder", "testResources/linkedFolderTarget");
assertNotNull(path);
path = path.append("FileInLinkedFolder");
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
manager.connect(path, LocationKind.IFILE, null);
ITextFileBuffer buffer = manager.getTextFileBuffer(path, LocationKind.IFILE);
Assert.assertNotNull(buffer);
IDocument document = buffer.getDocument();
Assert.assertNotNull(document);
Assert.assertTrue(CONTENT4.equals(document.get()));
assertSame(buffer, manager.getTextFileBuffer(document));
manager.disconnect(path, LocationKind.IFILE, null);
assertNull(manager.getTextFileBuffer(path, LocationKind.IFILE));
}
Aggregations