[kune-commits] r1306 - in trunk/src: main/java/cc/kune/client main/java/cc/kune/core/client/init main/java/cc/kune/core/client/notify/spiner main/java/cc/kune/core/client/state main/java/cc/kune/wave/server test/java/cc/kune/core/client/state
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Wed Apr 6 12:51:50 CEST 2011
Author: vjrj_
Date: 2011-04-06 12:51:50 +0200 (Wed, 06 Apr 2011)
New Revision: 1306
Modified:
trunk/src/main/java/cc/kune/client/KuneEntryPoint.java
trunk/src/main/java/cc/kune/core/client/init/AppStarterDefault.java
trunk/src/main/java/cc/kune/core/client/notify/spiner/SpinerPresenter.java
trunk/src/main/java/cc/kune/core/client/state/ContentCacheDefault.java
trunk/src/main/java/cc/kune/core/client/state/Session.java
trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java
trunk/src/main/java/cc/kune/wave/server/KuneWaveManagerDefault.java
trunk/src/test/java/cc/kune/core/client/state/StateManagerDefaultTest.java
Log:
Some minor fixes in startup
Modified: trunk/src/main/java/cc/kune/client/KuneEntryPoint.java
===================================================================
--- trunk/src/main/java/cc/kune/client/KuneEntryPoint.java 2011-04-06 01:22:52 UTC (rev 1305)
+++ trunk/src/main/java/cc/kune/client/KuneEntryPoint.java 2011-04-06 10:51:50 UTC (rev 1306)
@@ -64,6 +64,7 @@
*/
public void onModuleLoadCont() {
DelayedBindRegistry.bind(ginjector);
+ ginjector.getSpinerPresenter();
ginjector.getGlobalShortcutRegister().enable();
AsyncCallbackSimple.init(ginjector.getErrorHandler());
ginjector.getEventLogger();
Modified: trunk/src/main/java/cc/kune/core/client/init/AppStarterDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/init/AppStarterDefault.java 2011-04-06 01:22:52 UTC (rev 1305)
+++ trunk/src/main/java/cc/kune/core/client/init/AppStarterDefault.java 2011-04-06 10:51:50 UTC (rev 1306)
@@ -61,20 +61,6 @@
private void getInitData() {
siteService.getInitData(session.getUserHash(), new AsyncCallback<InitDataDTO>() {
private void hideInitialPanels() {
- // final RootPanel curtain =
- // RootPanel.get("kuneinitialcurtain");
- // Fade anim = new Fade(curtain.getElement());
- // anim.setDuration(3);
- // anim.addEffectCompletedHandler(new EffectCompletedHandler() {
- // @Override
- // public void onEffectCompleted(EffectCompletedEvent event) {
- // curtain.setVisible(false);
- // RootPanel.get("kuneloading").setVisible(false);
- // }
- // });
- // anim.play();
- // eventBus.fireEvent(new UserNotifyEvent(NotifyLevel.info,
- // "Starting"));
}
@Override
@@ -95,9 +81,6 @@
@Override
public void execute() {
hideInitialPanels();
- // eventBus.fireEvent(new
- // UserNotifyEvent(NotifyLevel.info, "Success",
- // "App Started.", true));
}
});
}
Modified: trunk/src/main/java/cc/kune/core/client/notify/spiner/SpinerPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/notify/spiner/SpinerPresenter.java 2011-04-06 01:22:52 UTC (rev 1305)
+++ trunk/src/main/java/cc/kune/core/client/notify/spiner/SpinerPresenter.java 2011-04-06 10:51:50 UTC (rev 1306)
@@ -33,8 +33,6 @@
public class SpinerPresenter extends Presenter<SpinerPresenter.SpinerView, SpinerPresenter.SpinerProxy> {
- private final I18nTranslationService i18n;
-
@ProxyCodeSplit
public interface SpinerProxy extends Proxy<SpinerPresenter> {
}
@@ -45,26 +43,29 @@
void show(String message);
}
+ private final I18nTranslationService i18n;
+
@Inject
public SpinerPresenter(final EventBus eventBus, final SpinerView view, final SpinerProxy proxy,
- I18nTranslationService i18n) {
+ final I18nTranslationService i18n) {
super(eventBus, view, proxy);
this.i18n = i18n;
+ getView().show("");
}
@ProxyEvent
- public void onProgressShow(ProgressShowEvent event) {
- getView().show(event.getMessage());
+ public void onI18nReady(final I18nReadyEvent event) {
+ getView().show(i18n.t("Loading"));
}
@ProxyEvent
- public void onI18nReady(I18nReadyEvent event) {
- getView().show(i18n.t("Loading"));
+ public void onProgressHide(final ProgressHideEvent event) {
+ getView().fade();
}
@ProxyEvent
- public void onProgressHide(ProgressHideEvent event) {
- getView().fade();
+ public void onProgressShow(final ProgressShowEvent event) {
+ getView().show(event.getMessage());
}
@Override
Modified: trunk/src/main/java/cc/kune/core/client/state/ContentCacheDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/ContentCacheDefault.java 2011-04-06 01:22:52 UTC (rev 1305)
+++ trunk/src/main/java/cc/kune/core/client/state/ContentCacheDefault.java 2011-04-06 10:51:50 UTC (rev 1306)
@@ -47,18 +47,20 @@
@Override
public void cache(final StateToken encodeState, final StateAbstractDTO content) {
+ assert encodeState != null;
if (useCache) {
cacheMap.put(encodeState, content);
}
}
private StateAbstractDTO getCached(final StateToken newState) {
+ assert newState != null;
return useCache ? cacheMap.get(newState) : null;
- // return useCache ? cache.remove(newState) : null;
}
@Override
public void getContent(final String user, final StateToken newState, final AsyncCallback<StateAbstractDTO> callback) {
+ assert newState != null;
eventBus.fireEvent(new ProgressShowEvent(""));
final StateAbstractDTO catched = getCached(newState);
if (catched != null) {
Modified: trunk/src/main/java/cc/kune/core/client/state/Session.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/Session.java 2011-04-06 01:22:52 UTC (rev 1305)
+++ trunk/src/main/java/cc/kune/core/client/state/Session.java 2011-04-06 10:51:50 UTC (rev 1306)
@@ -65,6 +65,7 @@
* Duration remembering login: 2 weeks
*/
int SESSION_DURATION = 1000 * 60 * 60 * 24 * 14;
+ // int SESSION_DURATION = 1000;
String USERHASH = "k007userHash";
Modified: trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java 2011-04-06 01:22:52 UTC (rev 1305)
+++ trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java 2011-04-06 10:51:50 UTC (rev 1306)
@@ -78,7 +78,6 @@
this.siteTokens = siteTokens;
beforeStateChangeCollection = new BeforeActionCollection();
session.onAppStart(true, new AppStartHandler() {
-
@Override
public void onAppStart(final AppStartEvent event) {
session.onUserSignIn(false, new UserSignInEvent.UserSignInHandler() {
@@ -93,7 +92,7 @@
refreshCurrentGroupState();
}
});
- processHistoryToken(history.getToken());
+ processCurrentHistoryToken();
}
});
}
@@ -224,6 +223,10 @@
processHistoryToken(event.getValue());
}
+ private void processCurrentHistoryToken() {
+ processHistoryToken(history.getToken());
+ }
+
void processHistoryToken(final String newHistoryToken) {
// http://code.google.com/p/google-web-toolkit-doc-1-5/wiki/DevGuideHistory
if (beforeStateChangeCollection.checkBeforeAction()) {
@@ -288,7 +291,7 @@
// Starting with some token like "signin": load defContent
// also
processHistoryToken("");
- SpaceSelectEvent.fire(eventBus, Space.groupSpace);
+ // SpaceSelectEvent.fire(eventBus, Space.groupSpace);
}
// Fire the listener of this #hash token
tokenListener.onHistoryToken();
@@ -324,8 +327,12 @@
@Override
public void refreshCurrentGroupState() {
final StateToken currentStateToken = session.getCurrentStateToken();
- contentProvider.removeContent(currentStateToken);
- onHistoryChanged(currentStateToken);
+ if (currentStateToken == null) {
+ processCurrentHistoryToken();
+ } else {
+ contentProvider.removeContent(currentStateToken);
+ onHistoryChanged(currentStateToken);
+ }
}
/**
Modified: trunk/src/main/java/cc/kune/wave/server/KuneWaveManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/KuneWaveManagerDefault.java 2011-04-06 01:22:52 UTC (rev 1305)
+++ trunk/src/main/java/cc/kune/wave/server/KuneWaveManagerDefault.java 2011-04-06 10:51:50 UTC (rev 1306)
@@ -17,7 +17,6 @@
import com.google.inject.Inject;
import com.google.inject.name.Named;
-import com.google.wave.api.Markup;
import com.google.wave.api.OperationQueue;
import com.google.wave.api.OperationRequest;
import com.google.wave.api.ProtocolVersion;
@@ -55,10 +54,16 @@
final Set<String> users = new HashSet<String>();
users.add(user.toString());
final Wavelet newWavelet = opQueue.createWavelet(domain, users, message);
- final Markup markup = Markup.of(message);
- opQueue.createChildOfBlip(newWavelet.getRootBlip());
- opQueue.appendBlipToWavelet(newWavelet, message);
- opQueue.appendBlipToWavelet(newWavelet, message);
+ // opQueue.appendBlipToWavelet(newWavelet, "kk2");
+ // final Markup markup = Markup.of(message);
+ // opQueue.modifyTagOfWavelet(newWavelet, "tag", "add");
+
+ // newWavelet.getRootBlip().appendMarkup(markup.getMarkup());
+ // opQueue.createChildOfBlip(newWavelet.getRootBlip());
+ // opQueue.appendBlipToWavelet(newWavelet, message);
+ // opQueue.appendBlipToWavelet(newWavelet, message);
+ // opQueue.appendMarkupToDocument(null, message)
+ // opQueue.modifyDocument(null)
assert newWavelet.getRootBlip() != null;
final OperationContextImpl context = new OperationContextImpl(waveletProvider,
converterManager.getEventDataConverter(ProtocolVersion.DEFAULT), conversationUtil);
Modified: trunk/src/test/java/cc/kune/core/client/state/StateManagerDefaultTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/client/state/StateManagerDefaultTest.java 2011-04-06 01:22:52 UTC (rev 1305)
+++ trunk/src/test/java/cc/kune/core/client/state/StateManagerDefaultTest.java 2011-04-06 10:51:50 UTC (rev 1306)
@@ -19,15 +19,24 @@
*/
package cc.kune.core.client.state;
+import static org.mockito.Matchers.anyBoolean;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
import cc.kune.common.client.actions.BeforeActionListener;
+import cc.kune.core.client.init.AppStartEvent;
+import cc.kune.core.client.init.AppStartEvent.AppStartHandler;
import cc.kune.core.client.state.GroupChangedEvent.GroupChangedHandler;
import cc.kune.core.client.state.StateChangedEvent.StateChangedHandler;
import cc.kune.core.client.state.ToolChangedEvent.ToolChangedHandler;
+import cc.kune.core.client.state.UserSignInEvent.UserSignInHandler;
+import cc.kune.core.client.state.UserSignOutEvent.UserSignOutHandler;
import cc.kune.core.shared.domain.utils.StateToken;
+import cc.kune.core.shared.dto.InitDataDTO;
import cc.kune.core.shared.dto.StateAbstractDTO;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -57,9 +66,30 @@
tokenMatcher = Mockito.mock(TokenMatcher.class);
siteTokens = Mockito.mock(SiteTokenListeners.class);
eventBus = new EventBusTester();
- stateManager = new StateManagerDefault(contentProvider, session, history, tokenMatcher, eventBus, siteTokens);
Mockito.when(session.getUserHash()).thenReturn(HASH);
+ Mockito.doAnswer(new Answer<Object>() {
+ @Override
+ public Object answer(final InvocationOnMock invocation) throws Throwable {
+ eventBus.addHandler(UserSignInEvent.getType(), (UserSignInHandler) invocation.getArguments()[1]);
+ return null;
+ }
+ }).when(session).onUserSignIn(anyBoolean(), (UserSignInHandler) Mockito.anyObject());
+ Mockito.doAnswer(new Answer<Object>() {
+ @Override
+ public Object answer(final InvocationOnMock invocation) throws Throwable {
+ eventBus.addHandler(UserSignOutEvent.getType(), (UserSignOutHandler) invocation.getArguments()[1]);
+ return null;
+ }
+ }).when(session).onUserSignOut(anyBoolean(), (UserSignOutHandler) Mockito.anyObject());
+ Mockito.doAnswer(new Answer<Object>() {
+ @Override
+ public Object answer(final InvocationOnMock invocation) throws Throwable {
+ eventBus.addHandler(AppStartEvent.getType(), (AppStartHandler) invocation.getArguments()[1]);
+ return null;
+ }
+ }).when(session).onAppStart(anyBoolean(), (AppStartHandler) Mockito.anyObject());
state = Mockito.mock(StateAbstractDTO.class);
+ stateManager = new StateManagerDefault(contentProvider, session, history, tokenMatcher, eventBus, siteTokens);
stateChangeHandler = Mockito.mock(StateChangedHandler.class);
groupChangeHandler = Mockito.mock(GroupChangedHandler.class);
toolChangeHandler = Mockito.mock(ToolChangedHandler.class);
@@ -159,8 +189,7 @@
@Test
public void getDefGroup() {
stateManager.processHistoryToken("site.docs");
- Mockito.verify(contentProvider, Mockito.times(1)).getContent(Mockito.anyString(),
- (StateToken) Mockito.anyObject(), (AsyncCallback<StateAbstractDTO>) Mockito.anyObject());
+ verifyGetServerContent();
}
public void getWaveToken() {
@@ -174,8 +203,7 @@
// (and the user was logged)
Mockito.when(history.getToken()).thenReturn("");
stateManager.reload();
- Mockito.verify(contentProvider, Mockito.times(1)).getContent(Mockito.anyString(),
- (StateToken) Mockito.anyObject(), (AsyncCallback<StateAbstractDTO>) Mockito.anyObject());
+ verifyGetServerContent();
}
@SuppressWarnings("unchecked")
@@ -185,8 +213,7 @@
stateManager.processHistoryToken(newToken);
removeBeforeStateChangeListener();
stateManager.processHistoryToken(newToken);
- Mockito.verify(contentProvider, Mockito.times(1)).getContent(Mockito.anyString(),
- (StateToken) Mockito.anyObject(), (AsyncCallback<StateAbstractDTO>) Mockito.anyObject());
+ verifyGetServerContent();
}
@Test
@@ -219,8 +246,7 @@
@Test
public void oneBeforeStateChangeListenerReturnTrue() {
stateManager.processHistoryToken(confBeforeStateChangeListeners(true, true));
- Mockito.verify(contentProvider, Mockito.times(1)).getContent(Mockito.anyString(),
- (StateToken) Mockito.anyObject(), (AsyncCallback<StateAbstractDTO>) Mockito.anyObject());
+ verifyGetServerContent();
}
private void removeBeforeStateChangeListener() {
@@ -237,8 +263,7 @@
Mockito.when(siteTokens.get(SiteTokens.SIGNIN)).thenReturn(listener);
stateManager.processHistoryToken(token);
Mockito.verify(listener, Mockito.times(1)).onHistoryToken();
- Mockito.verify(contentProvider, Mockito.times(1)).getContent(Mockito.anyString(),
- (StateToken) Mockito.anyObject(), (AsyncCallback<StateAbstractDTO>) Mockito.anyObject());
+ verifyGetServerContent();
}
@Test
@@ -249,4 +274,17 @@
stateManager.processHistoryToken("signIn");
Mockito.verify(listener, Mockito.times(1)).onHistoryToken();
}
+
+ @Test
+ public void startMustLoadContent() {
+ final InitDataDTO initData = Mockito.mock(InitDataDTO.class);
+ Mockito.when(history.getToken()).thenReturn("");
+ eventBus.fireEvent(new AppStartEvent(initData));
+ verifyGetServerContent();
+ }
+
+ private void verifyGetServerContent() {
+ Mockito.verify(contentProvider, Mockito.times(1)).getContent(Mockito.anyString(),
+ (StateToken) Mockito.anyObject(), (AsyncCallback<StateAbstractDTO>) Mockito.anyObject());
+ }
}
More information about the kune-commits
mailing list