Search in sources :

Example 6 with Storage

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");
}
Also used : Storage(com.google.gwt.storage.client.Storage) Test(org.junit.Test)

Example 7 with Storage

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);
    }
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) Project(org.eclipse.che.ide.api.resources.Project) Storage(com.google.gwt.storage.client.Storage) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) Resource(org.eclipse.che.ide.api.resources.Resource) StorableBreakpointDto(org.eclipse.che.ide.api.debug.dto.StorableBreakpointDto) LinkedList(java.util.LinkedList)

Example 8 with Storage

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);
}
Also used : Storage(com.google.gwt.storage.client.Storage) Test(org.junit.Test)

Example 9 with Storage

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);
}
Also used : Storage(com.google.gwt.storage.client.Storage) Test(org.junit.Test)

Example 10 with Storage

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);
}
Also used : Storage(com.google.gwt.storage.client.Storage) Test(org.junit.Test)

Aggregations

Storage (com.google.gwt.storage.client.Storage)14 Test (org.junit.Test)8 Breakpoint (org.eclipse.che.ide.api.debug.Breakpoint)2 StorableBreakpointDto (org.eclipse.che.ide.api.debug.dto.StorableBreakpointDto)2 Optional (com.google.common.base.Optional)1 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 UrlBuilder (com.google.gwt.http.client.UrlBuilder)1 GetGuiConfiguration (cz.metacentrum.perun.webgui.json.GetGuiConfiguration)1 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)1 GetPerunPrincipal (cz.metacentrum.perun.webgui.json.authzResolver.GetPerunPrincipal)1 KeepAlive (cz.metacentrum.perun.webgui.json.authzResolver.KeepAlive)1 BasicOverlayType (cz.metacentrum.perun.webgui.model.BasicOverlayType)1 PerunError (cz.metacentrum.perun.webgui.model.PerunError)1 PerunPrincipal (cz.metacentrum.perun.webgui.model.PerunPrincipal)1 TabManager (cz.metacentrum.perun.webgui.tabs.TabManager)1 UrlMapper (cz.metacentrum.perun.webgui.tabs.UrlMapper)1 CantLogAsServiceUserWidget (cz.metacentrum.perun.webgui.widgets.CantLogAsServiceUserWidget)1 Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)1