@Test public void onWorkspaceContextUpdateEventFromReadOnlyToWritable() { // Given: event sets workspace to writable and we first have workspace as read only userWorkspaceContext.setProjectActive(false); WorkspaceContextUpdateEvent event = mock(WorkspaceContextUpdateEvent.class); when(event.isProjectActive()).thenReturn(true); // When: presenter.onWorkspaceContextUpdated(event); // Then: verify(display, times(3)).setToMode(ToggleEditor.ViewMode.EDIT); verify(display, atLeast(3)).showButtons(true); verify(editorKeyShortcuts).enableEditContext(); }
@Test public void onWorkspaceContextUpdateEventBecomeReadOnly() { // Given: event sets workspace to read only WorkspaceContextUpdateEvent event = mock(WorkspaceContextUpdateEvent.class); when(event.isProjectActive()).thenReturn(false); userWorkspaceContext.setHasEditTranslationAccess(false); // When: presenter.onWorkspaceContextUpdated(event); // Then: verify(display, times(3)).setToMode(ToggleEditor.ViewMode.VIEW); verify(display, times(3)).showButtons(false); verify(editorKeyShortcuts).enableNavigationContext(); }