Skip to content

Commit

Permalink
CHE-1523: update related virtual file when resource was changed
Browse files Browse the repository at this point in the history
Signed-off-by: Valeriy Svydenko <vsvydenko@codenvy.com>
  • Loading branch information
Valeriy Svydenko committed Jul 18, 2016
1 parent 3eb38cd commit b8c9684
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Expand Up @@ -151,8 +151,8 @@ public void update(@NotNull PartPresenter part) {
title.setText(part.getTitle());

if (part instanceof EditorPartPresenter) {
VirtualFile changedFile = ((EditorPartPresenter)part).getEditorInput().getFile();
FileType fileType = fileTypeRegistry.getFileTypeByFile(changedFile);
file = ((EditorPartPresenter)part).getEditorInput().getFile();
FileType fileType = fileTypeRegistry.getFileTypeByFile(file);
icon = fileType.getImage();
iconPanel.setWidget(getIcon());
}
Expand Down
Expand Up @@ -35,6 +35,8 @@
import org.vectomatic.dom.svg.ui.SVGResource;

import static org.eclipse.che.ide.api.parts.PartStackView.TabPosition.BELOW;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -161,4 +163,22 @@ public void tabIconShouldBeUpdatedWhenMediaTypeChanged() {
verify(fileTypeRegistry).getFileTypeByFile(file);
verify(tab.iconPanel).setWidget(Matchers.<SVGImage>anyObject());
}

@Test
public void virtualFileShouldBeUpdated() throws Exception {
EditorInput editorInput = mock(EditorInput.class);
FileType fileType = mock(FileType.class);
VirtualFile newFile = mock(VirtualFile.class);

when(editorPartPresenter.getEditorInput()).thenReturn(editorInput);
when(fileTypeRegistry.getFileTypeByFile(newFile)).thenReturn(fileType);
when(fileType.getImage()).thenReturn(icon);
when(editorInput.getFile()).thenReturn(newFile);

assertNotEquals(tab.getFile(), newFile);

tab.update(editorPartPresenter);

assertEquals(tab.getFile(), newFile);
}
}

0 comments on commit b8c9684

Please sign in to comment.