use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.
the class FileStoreFileBufferFunctions method test13_3.
/*
* Test IFileBufferListener#stateValidationChanged
*/
@Test
public void test13_3() throws Exception {
class Listener extends FileBufferListener {
public IFileBuffer buffer;
public int count;
public boolean isStateValidated;
@Override
public void stateValidationChanged(IFileBuffer buf, boolean state) {
++count;
this.buffer = buf;
this.isStateValidated = 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);
fileBuffer.validateState(null, null);
fileBuffer.resetStateValidation();
if (isStateValidationSupported()) {
assertTrue(listener.count == 2);
assertTrue(listener.buffer == fileBuffer);
assertFalse(listener.isStateValidated);
}
} 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 test16_1.
/*
* Test IFileBufferListener#stateChanging for external changes
*/
@Test
public void test16_1() throws Exception {
class Listener extends FileBufferListener {
public IFileBuffer buffer;
public int count;
@Override
public void stateChanging(IFileBuffer buf) {
++count;
this.buffer = buf;
}
}
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);
if (modifyUnderlyingFile()) {
assertSame(listener.buffer, fileBuffer);
assertEquals(1, listener.count);
}
} 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 test17_1.
/*
* Test IFileBufferListener#stateChanging for internal changes
*/
@Test
public void test17_1() throws Exception {
class Listener extends FileBufferListener {
public IFileBuffer buffer;
public int count;
@Override
public void stateChanging(IFileBuffer buf) {
++count;
this.buffer = buf;
}
}
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);
fileBuffer.validateState(null, null);
if (isStateValidationSupported()) {
assertTrue(listener.count == 1);
assertTrue(listener.buffer == fileBuffer);
}
} 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 tearDown.
@After
public void tearDown() {
ITextFileBuffer buffer = fManager.getFileStoreTextFileBuffer(fFileStore);
assertTrue(buffer == null);
ResourceHelper.deleteProject("project");
}
use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.
the class FileStoreFileBufferFunctions method test8_1.
/*
* Test validateState.
*/
@Test
public void test8_1() throws Exception {
fManager.connectFileStore(fFileStore, null);
try {
ITextFileBuffer fileBuffer = fManager.getFileStoreTextFileBuffer(fFileStore);
fileBuffer.validateState(null, null);
assertTrue(fileBuffer.isStateValidated());
} finally {
fManager.disconnectFileStore(fFileStore, null);
}
}
Aggregations