Revision: 10033
Author:   rj...@google.com
Date:     Tue Apr 19 15:43:31 2011
Log:      Finishes the job of making EventBus backward compatible,
half done in r10023

Review at http://gwt-code-reviews.appspot.com/1425804

Review by: robertvaw...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=10033

Added:
 /trunk/user/test/com/google/gwt/event/shared/EventBusTest.java
Modified:
 /trunk/user/src/com/google/gwt/event/shared/EventBus.java
 /trunk/user/src/com/google/gwt/event/shared/ResettableEventBus.java
 /trunk/user/src/com/google/gwt/event/shared/SimpleEventBus.java
 /trunk/user/src/com/google/gwt/event/shared/testing/CountingEventBus.java
 /trunk/user/test/com/google/gwt/event/EventSuite.java

=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/event/shared/EventBusTest.java Tue Apr 19 15:43:31 2011
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.event.shared;
+
+import com.google.gwt.event.shared.GwtEvent.Type;
+
+import junit.framework.TestCase;
+
+/**
+ * Test that EventBus is api compatible after its retrofit to extend
+ * {@link com.google.web.bindery.event.shared.EventBus}.
+ */
+public class EventBusTest extends TestCase {
+  EventBus bus = new EventBus() {
+
+    @Override
+ public <H extends EventHandler> HandlerRegistration addHandler(Type<H> type, H handler) {
+      throw new UnsupportedOperationException();
+    }
+
+    @Override
+ public <H extends EventHandler> HandlerRegistration addHandlerToSource(Type<H> type,
+        Object source, H handler) {
+      throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void fireEvent(GwtEvent<?> event) {
+      throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void fireEventFromSource(GwtEvent<?> event, Object source) {
+      throw new UnsupportedOperationException();
+    }
+  };
+
+  public void testOne() {
+    // Nothing to test, really, just make sure it still compiles.
+    assertNotNull(bus);
+  }
+}
=======================================
--- /trunk/user/src/com/google/gwt/event/shared/EventBus.java Tue Apr 19 06:56:46 2011 +++ /trunk/user/src/com/google/gwt/event/shared/EventBus.java Tue Apr 19 15:43:31 2011
@@ -24,15 +24,27 @@
public abstract class EventBus extends com.google.web.bindery.event.shared.EventBus implements
     HasHandlers {

- public <H extends EventHandler> HandlerRegistration addHandler(GwtEvent.Type<H> type, H handler) {
-    return wrap(addHandler((Event.Type<H>) type, handler));
-  }
-
- public <H extends EventHandler> HandlerRegistration addHandlerToSource(GwtEvent.Type<H> type,
+  @Override
+ public <H> com.google.web.bindery.event.shared.HandlerRegistration addHandler(Event.Type<H> type, H handler) {
+    throw new UnsupportedOperationException("Subclass responsibility. "
+ + "This class is a legacy wrapper for com.google.web.bindery.event.shared.EventBus. " + + "Use that directly, or try com.google.gwt.event.shared.SimpleEventBus");
+  }
+
+ public abstract <H extends EventHandler> HandlerRegistration addHandler(GwtEvent.Type<H> type, H handler);
+
+  @Override
+ public <H> com.google.web.bindery.event.shared.HandlerRegistration addHandlerToSource(Event.Type<H> type,
       Object source, H handler) {
-    return wrap(addHandlerToSource((Event.Type<H>) type, source, handler));
+    throw new UnsupportedOperationException("Subclass responsibility. "
+ + "This class is a legacy wrapper for com.google.web.bindery.event.shared.EventBus. " + + "Use that directly, or try com.google.gwt.event.shared.SimpleEventBus");
   }

+ public abstract <H extends EventHandler> HandlerRegistration addHandlerToSource(GwtEvent.Type<H> type,
+      Object source, H handler);
+
+  @Override
   public void fireEvent(Event<?> event) {
     throw new UnsupportedOperationException("Subclass responsibility. "
+ "This class is a legacy wrapper for com.google.web.bindery.event.shared.EventBus. "
@@ -41,6 +53,8 @@

   public abstract void fireEvent(GwtEvent<?> event);

+
+  @Override
   public void fireEventFromSource(Event<?> event, Object source) {
     throw new UnsupportedOperationException("Subclass responsibility. "
+ "This class is a legacy wrapper for com.google.web.bindery.event.shared.EventBus. "
=======================================
--- /trunk/user/src/com/google/gwt/event/shared/ResettableEventBus.java Tue Apr 19 06:56:46 2011 +++ /trunk/user/src/com/google/gwt/event/shared/ResettableEventBus.java Tue Apr 19 15:43:31 2011
@@ -37,17 +37,27 @@
       return super.getRegistrationSize();
     }
   }
-
+
   private final TestableResettableEventBus real;

   public ResettableEventBus(EventBus wrappedBus) {
     real = new TestableResettableEventBus(wrappedBus);
   }
+
+ public <H extends EventHandler> com.google.gwt.event.shared.HandlerRegistration addHandler(
+      GwtEvent.Type<H> type, H handler) {
+    return wrap(addHandler((Event.Type<H>) type, handler));
+  }

   @Override
   public <H> HandlerRegistration addHandler(Type<H> type, H handler) {
     return real.addHandler(type, handler);
   }
+
+ public <H extends EventHandler> com.google.gwt.event.shared.HandlerRegistration addHandlerToSource(
+      GwtEvent.Type<H> type, Object source, H handler) {
+    return wrap(addHandlerToSource((Event.Type<H>) type, source, handler));
+  }

   @Override
public <H> HandlerRegistration addHandlerToSource(Type<H> type, Object source, H handler) {
=======================================
--- /trunk/user/src/com/google/gwt/event/shared/SimpleEventBus.java Tue Apr 19 06:56:46 2011 +++ /trunk/user/src/com/google/gwt/event/shared/SimpleEventBus.java Tue Apr 19 15:43:31 2011
@@ -26,11 +26,21 @@
 public class SimpleEventBus extends EventBus {
   private final com.google.web.bindery.event.shared.SimpleEventBus real =
       new com.google.web.bindery.event.shared.SimpleEventBus();
+
+ public <H extends EventHandler> com.google.gwt.event.shared.HandlerRegistration addHandler(
+      GwtEvent.Type<H> type, H handler) {
+    return wrap(addHandler((Event.Type<H>) type, handler));
+  }

   @Override
   public <H> HandlerRegistration addHandler(Type<H> type, H handler) {
     return real.addHandler(type, handler);
   }
+
+ public <H extends EventHandler> com.google.gwt.event.shared.HandlerRegistration addHandlerToSource(
+      GwtEvent.Type<H> type, Object source, H handler) {
+    return wrap(addHandlerToSource((Event.Type<H>) type, source, handler));
+  }

   @Override
public <H> HandlerRegistration addHandlerToSource(Type<H> type, Object source, H handler) {
=======================================
--- /trunk/user/src/com/google/gwt/event/shared/testing/CountingEventBus.java Tue Apr 19 06:56:46 2011 +++ /trunk/user/src/com/google/gwt/event/shared/testing/CountingEventBus.java Tue Apr 19 15:43:31 2011
@@ -15,6 +15,7 @@
  */
 package com.google.gwt.event.shared.testing;

+import com.google.gwt.event.shared.EventHandler;
 import com.google.gwt.event.shared.GwtEvent;
 import com.google.web.bindery.event.shared.Event;
 import com.google.web.bindery.event.shared.Event.Type;
@@ -34,12 +35,22 @@
   public CountingEventBus(com.google.gwt.event.shared.EventBus wrapped) {
real = new com.google.web.bindery.event.shared.testing.CountingEventBus(wrapped);
   }
+
+ public <H extends EventHandler> com.google.gwt.event.shared.HandlerRegistration addHandler(
+      GwtEvent.Type<H> type, H handler) {
+    return wrap(addHandler((Event.Type<H>) type, handler));
+  }

   @Override
   public <H> HandlerRegistration addHandler(Type<H> type, H handler) {
     return real.addHandler(type, handler);
   }

+ public <H extends EventHandler> com.google.gwt.event.shared.HandlerRegistration addHandlerToSource(
+      GwtEvent.Type<H> type, Object source, H handler) {
+    return wrap(addHandlerToSource((Event.Type<H>) type, source, handler));
+  }
+
   @Override
public <H> HandlerRegistration addHandlerToSource(Type<H> type, Object source, H handler) {
     return real.addHandlerToSource(type, source, handler);
=======================================
--- /trunk/user/test/com/google/gwt/event/EventSuite.java Fri Sep 10 17:56:09 2010 +++ /trunk/user/test/com/google/gwt/event/EventSuite.java Tue Apr 19 15:43:31 2011
@@ -17,9 +17,10 @@

 import com.google.gwt.event.dom.client.DomEventTest;
 import com.google.gwt.event.logical.shared.LogicalEventsTest;
+import com.google.gwt.event.shared.EventBusTest;
 import com.google.gwt.event.shared.HandlerManagerTest;
-import com.google.gwt.event.shared.SimpleEventBusTest;
 import com.google.gwt.event.shared.ResettableEventBusTest;
+import com.google.gwt.event.shared.SimpleEventBusTest;
 import com.google.gwt.junit.tools.GWTTestSuite;

 import junit.framework.Test;
@@ -32,11 +33,12 @@
     GWTTestSuite suite = new GWTTestSuite(
         "Test for suite for the com.google.gwt.event module.");

-    suite.addTestSuite(LogicalEventsTest.class);
     suite.addTestSuite(DomEventTest.class);
+    suite.addTestSuite(EventBusTest.class);
     suite.addTestSuite(HandlerManagerTest.class);
-    suite.addTestSuite(SimpleEventBusTest.class);
+    suite.addTestSuite(LogicalEventsTest.class);
     suite.addTestSuite(ResettableEventBusTest.class);
+    suite.addTestSuite(SimpleEventBusTest.class);

     return suite;
   }

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to