Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Sep 25, 2012
1 parent e416b2d commit e65dd0d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
Expand Up @@ -253,7 +253,7 @@ protected void expendSideMenu(boolean isExpend)
eventBus.fireEvent(new ShowSideMenuEvent(isExpended));
if (!isExpended)
{
display.setSelectedTab(SideMenuDisplay.EMPTY_VIEW);
display.setSelectedTab(SideMenuDisplay.NOTIFICATION_VIEW);
}
}

Expand Down
@@ -1,18 +1,15 @@
package org.zanata.webtrans.client.view;

import org.zanata.webtrans.client.events.NotificationEvent;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.HasVisibility;

import net.customware.gwt.presenter.client.widget.WidgetDisplay;

import org.zanata.webtrans.client.events.NotificationEvent;

/**
* @author Patrick Huang <a href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
*/
public interface SideMenuDisplay extends WidgetDisplay
{
//Order of the tab
static final int EMPTY_VIEW = -1;
static final int NOTIFICATION_VIEW = 0;
static final int WORKSPACEUSER_VIEW = 1;
static final int EDITOR_OPTION_VIEW = 2;
Expand Down
Expand Up @@ -167,7 +167,7 @@ public void canSwitchToEditorView()
verify(sideMenuPresenter).showEditorMenu(true);
verify(display).setResizeVisible(true);
verify(display).showInMainView(MainView.Editor);
verify(display).setStats(statsCaptor.capture());
verify(display).setStats(statsCaptor.capture(), eq(true));

assertThat(statsCaptor.getValue(), Matchers.sameInstance(selectedDocumentStats));
}
Expand All @@ -190,7 +190,7 @@ public void canSwitchToSearchView()
verify(sideMenuPresenter).showEditorMenu(false);
verify(display).setResizeVisible(false);
verify(display).showInMainView(MainView.Search);
verify(display).setStats(statsCaptor.capture());
verify(display).setStats(statsCaptor.capture(), eq(true));

assertThat(statsCaptor.getValue(), Matchers.sameInstance(projectStats));
}
Expand All @@ -213,7 +213,7 @@ public void canSwitchToDocumentView()
verify(sideMenuPresenter).showEditorMenu(false);
verify(display).setResizeVisible(false);
verify(display).showInMainView(MainView.Documents);
verify(display).setStats(statsCaptor.capture());
verify(display).setStats(statsCaptor.capture(), eq(true));

assertThat(statsCaptor.getValue(), Matchers.sameInstance(projectStats));
}
Expand All @@ -230,15 +230,15 @@ public void canSelectDocumentInEditorView()
when(documentListPresenter.getDocumentInfo(docId)).thenReturn(documentInfo);
// current view is editor
presenter.showView(MainView.Editor);
verify(display).setStats(statsCaptor.capture());
verify(display).setStats(statsCaptor.capture(), eq(true));
assertThat(statsCaptor.getValue(), Matchers.sameInstance(selectedDocumentStats));

// When:
presenter.selectDocument(docId);

// Then:
display.setDocumentLabel("pot/", "a.po");
verify(display, atLeastOnce()).setStats(newSelectedStats);
verify(display, atLeastOnce()).setStats(newSelectedStats, true);
assertThat(presenter.getSelectedDocIdOrNull(), Matchers.is(docId));
}

Expand Down Expand Up @@ -298,7 +298,7 @@ public void onDocumentStatsUpdateWillSetStatsIfSameDocument()
DocumentInfo documentInfo = new DocumentInfo(docId, "a.po", "pot/", new LocaleId("en-US"), selectedDocumentStats);
when(documentListPresenter.getDocumentInfo(docId)).thenReturn(documentInfo);
presenter.selectDocument(docId);
verify(display, atLeastOnce()).setStats(selectedDocumentStats);
verify(display, atLeastOnce()).setStats(selectedDocumentStats, true);

// When:
TranslationStats newStats = new TranslationStats(new TransUnitCount(9, 9, 9), new TransUnitWords(8, 8, 8));
Expand All @@ -307,7 +307,7 @@ public void onDocumentStatsUpdateWillSetStatsIfSameDocument()
// Then:
assertThat(selectedDocumentStats.getUnitCount(), Matchers.equalTo(newStats.getUnitCount()));
assertThat(selectedDocumentStats.getWordCount(), Matchers.equalTo(newStats.getWordCount()));
verify(display, atLeastOnce()).setStats(newStats);
verify(display, atLeastOnce()).setStats(newStats, true);
}

@Test
Expand All @@ -320,7 +320,7 @@ public void onProjectStatsUpdate()

assertThat(projectStats.getUnitCount(), Matchers.equalTo(newProjectStats.getUnitCount()));
assertThat(projectStats.getWordCount(), Matchers.equalTo(newProjectStats.getWordCount()));
verify(display).setStats(eq(newProjectStats));
verify(display).setStats(eq(newProjectStats), eq(true));
}

@Test
Expand Down
@@ -1,5 +1,15 @@
package org.zanata.webtrans.client.presenter;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import net.customware.gwt.presenter.client.EventBus;

import org.hamcrest.Matchers;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
Expand All @@ -9,12 +19,9 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.zanata.webtrans.client.events.EnterWorkspaceEvent;
import org.zanata.webtrans.client.events.EnterWorkspaceEventHandler;
import org.zanata.webtrans.client.events.ExitWorkspaceEvent;
import org.zanata.webtrans.client.events.ExitWorkspaceEventHandler;
import org.zanata.webtrans.client.events.NotificationEvent;
import org.zanata.webtrans.client.events.PublishWorkspaceChatEvent;
import org.zanata.webtrans.client.events.PublishWorkspaceChatEventHandler;
import org.zanata.webtrans.client.events.ShowSideMenuEvent;
import org.zanata.webtrans.client.events.WorkspaceContextUpdateEvent;
import org.zanata.webtrans.client.events.WorkspaceContextUpdateEventHandler;
Expand All @@ -31,16 +38,6 @@

import com.google.gwt.user.client.rpc.AsyncCallback;

import net.customware.gwt.presenter.client.EventBus;
import static org.hamcrest.MatcherAssert.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;

/**
* @author Patrick Huang <a href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
*/
Expand Down Expand Up @@ -221,7 +218,7 @@ public void testHideEditorMenu()

verify(display).setEditorOptionsTabVisible(false);
verify(display).setValidationOptionsTabVisible(false);
verify(display).setSelectedTab(SideMenuDisplay.EMPTY_VIEW);
verify(display).setSelectedTab(SideMenuDisplay.NOTIFICATION_VIEW);
}

@Test
Expand Down Expand Up @@ -272,7 +269,7 @@ public void testOnEditorOptionsClickExpandedAndCurrentTabIsEditorOptionTab() thr
verify(display).getCurrentTab();
verify(eventBus, times(2)).fireEvent(eventCaptor.capture());
assertThat(eventCaptor.getValue().isShowing(), Matchers.equalTo(false));
verify(display).setSelectedTab(SideMenuDisplay.EMPTY_VIEW);
verify(display).setSelectedTab(SideMenuDisplay.NOTIFICATION_VIEW);
verifyNoMoreInteractions(display);
}

Expand Down

0 comments on commit e65dd0d

Please sign in to comment.