use of com.google.gwt.storage.client.Storage in project gwt-test-utils by gwt-test-utils.
the class StorageTest method keyLocalStorage.
@Test
public void keyLocalStorage() {
// Given
Storage local = Storage.getLocalStorageIfSupported();
local.setItem("test0", "my test 0");
local.setItem("test1", "my test 1");
local.setItem("test2", "my test 2");
// When
String key0 = local.key(0);
String key1 = local.key(1);
String key2 = local.key(2);
// Then
assertThat(key0).isEqualTo("test0");
assertThat(key1).isEqualTo("test1");
assertThat(key2).isEqualTo("test2");
}
use of com.google.gwt.storage.client.Storage in project che by eclipse.
the class BreakpointManagerImpl method preserveBreakpoints.
private void preserveBreakpoints() {
Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage != null) {
List<StorableBreakpointDto> allDtoBreakpoints = new LinkedList<StorableBreakpointDto>();
List<Breakpoint> allBreakpoints = getBreakpointList();
if (currentBreakpoint != null) {
allBreakpoints.add(currentBreakpoint);
}
for (Breakpoint breakpoint : allBreakpoints) {
StorableBreakpointDto dto = dtoFactory.createDto(StorableBreakpointDto.class);
dto.setType(breakpoint.getType());
dto.setPath(breakpoint.getPath());
dto.setLineNumber(breakpoint.getLineNumber());
if (breakpoint.getFile() instanceof Resource) {
final Optional<Project> project = ((Resource) breakpoint.getFile()).getRelatedProject();
if (project.isPresent()) {
final ProjectConfigDto projectDto = dtoFactory.createDto(ProjectConfigDto.class).withName(project.get().getName()).withPath(project.get().getPath()).withType(project.get().getType()).withDescription(project.get().getDescription()).withAttributes(project.get().getAttributes()).withMixins(project.get().getMixins());
//TODO need to think to change argument type from dto to model interface
dto.setFileProjectConfig(projectDto);
}
}
dto.setActive(breakpoint.isActive());
allDtoBreakpoints.add(dto);
}
String data = dtoFactory.toJson(allDtoBreakpoints);
localStorage.setItem(LOCAL_STORAGE_BREAKPOINTS_KEY, data);
}
}
use of com.google.gwt.storage.client.Storage in project gwt-test-utils by gwt-test-utils.
the class StorageTest method getLenghtLocalStorage.
@Test
public void getLenghtLocalStorage() {
// Given
Storage local = Storage.getLocalStorageIfSupported();
local.setItem("test", "my test");
local.setItem("test", "my test bis");
local.setItem("test2", "my test 2");
// When
int length = local.getLength();
// Then
assertThat(length).isEqualTo(2);
}
use of com.google.gwt.storage.client.Storage in project gwt-test-utils by gwt-test-utils.
the class StorageTest method clearSessionStorage.
@Test
public void clearSessionStorage() {
// Given
Storage session = Storage.getSessionStorageIfSupported();
session.setItem("test", "my test");
session.setItem("test2", "my test 2");
// Preconditions
assertThat(session.getLength()).isEqualTo(2);
// When
session.clear();
// Then
assertThat(session.getLength()).isEqualTo(0);
}
use of com.google.gwt.storage.client.Storage in project gwt-test-utils by gwt-test-utils.
the class StorageTest method clearLocalStorage.
@Test
public void clearLocalStorage() {
// Given
Storage local = Storage.getLocalStorageIfSupported();
local.setItem("test", "my test");
local.setItem("test2", "my test 2");
// Preconditions
assertThat(local.getLength()).isEqualTo(2);
// When
local.clear();
// Then
assertThat(local.getLength()).isEqualTo(0);
}
Aggregations