Revision: 9583
Author: gwt.mirror...@gmail.com
Date: Thu Jan 20 17:38:25 2011
Log: Public(t.bro...@gmail.com):
Adds a unit-test to explicitly check that redundant calls to
showActivityWidget are okay. The test is needed because
AcceptsOneWidget passed to the Activity by ActivityManager is not
directly the one you passed to its setDisplay() method, so
ActivityManager could (theoretically) evolve in the future and break
this use case, which isn't documented as being a "valid use case".
Also "fixes" what looks like an oversight in AsyncActivity#start.
Review by rj...@google.com
http://gwt-code-reviews.appspot.com/999802
Review by: robertvaw...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=9583
Modified:
/trunk/user/test/com/google/gwt/activity/shared/ActivityManagerTest.java
=======================================
---
/trunk/user/test/com/google/gwt/activity/shared/ActivityManagerTest.java
Wed Dec 8 14:50:20 2010
+++
/trunk/user/test/com/google/gwt/activity/shared/ActivityManagerTest.java
Thu Jan 20 17:38:25 2011
@@ -41,6 +41,7 @@
@Override
public void start(AcceptsOneWidget display, EventBus eventBus) {
this.display = display;
+ this.bus = eventBus;
}
void finish() {
@@ -455,4 +456,51 @@
assertTrue(activity1.stopped);
assertFalse(activity1.canceled);
}
-}
+
+ /**
+ * Non-regression test: make sure an activity can call {@link
AcceptsOneWidget#setWidget(IsWidget)} several times to switch views.
+ */
+ public void testSetWidgetSeveralTimesPerActivity() {
+ class TwoViewActivity extends SyncActivity {
+ MyView view2;
+
+ public TwoViewActivity(MyView view1, MyView view2) {
+ super(view1);
+ this.view2 = view2;
+ }
+
+ void secondView() {
+ display.setWidget(view2);
+ }
+
+ void firstView() {
+ display.setWidget(view);
+ }
+ }
+ final TwoViewActivity activity = new TwoViewActivity(new MyView(), new
MyView());
+
+ ActivityMapper map = new ActivityMapper() {
+ public Activity getActivity(Place place) {
+ return activity;
+ }
+ };
+
+ manager = new ActivityManager(map, eventBus);
+ manager.setDisplay(realDisplay);
+
+ // Start an activity
+ manager.onPlaceChange(new PlaceChangeEvent(place1));
+
+ assertEquals(activity.view, realDisplay.widget);
+
+ // Call setWidget on the display several times, just to make sure it's
possible
+ activity.secondView();
+ assertEquals(activity.view2, realDisplay.widget);
+
+ activity.firstView();
+ assertEquals(activity.view, realDisplay.widget);
+
+ activity.secondView();
+ assertEquals(activity.view2, realDisplay.widget);
+ }
+}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors