Revision: 6319
Author: [email protected]
Date: Wed Oct  7 16:56:57 2009
Log: Add protocol v3 support to BrowserChannelClient, sort tests, fix  
problem
with -notHeadless from JUnitShell.

http://code.google.com/p/google-web-toolkit/source/detail?r=6319

Modified:
  /changes/jat/abstractui/dev/core/src/com/google/gwt/dev/HostedModeBase.java
   
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/BrowserChannelClient.java
   
/changes/jat/abstractui/dev/oophm/test/com/google/gwt/dev/shell/BrowserChannelTest.java
  /changes/jat/abstractui/user/src/com/google/gwt/junit/JUnitShell.java

=======================================
---  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/HostedModeBase.java     
 
Mon Oct  5 15:54:05 2009
+++  
/changes/jat/abstractui/dev/core/src/com/google/gwt/dev/HostedModeBase.java     
 
Wed Oct  7 16:56:57 2009
@@ -81,13 +81,13 @@
      public interface Callback {

        /**
-       * UI-initiated callback for some event
+       * UI-initiated callback for some event.
         *
         * @param event event name (TODO: make this a type-safe event in some
         *     way, need to consider alternate UI implementations though)
         * @param callbackData arbitrary data, defined for the event type
         */
-      public void callback(String event, Object callbackData);
+      void callback(String event, Object callbackData);
      }

      /**
=======================================
---  
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/BrowserChannelClient.java
         
Tue Oct  6 09:29:34 2009
+++  
/changes/jat/abstractui/dev/oophm/src/com/google/gwt/dev/shell/BrowserChannelClient.java
         
Wed Oct  7 16:56:57 2009
@@ -64,6 +64,7 @@
    private final String versionString;
    private boolean connected = false;
    private boolean shouldDisconnect = false;
+  private int protocolVersion;

    public BrowserChannelClient(String addressParts[], String url,
        String sessionKey, String moduleName, String versionString,
@@ -94,6 +95,14 @@
      connected = false;
      return true;
    }
+
+  /**
+   * @return the negotiated protocol version -- only valid after {...@link  
#init}
+   * has returned.
+   */
+  public int getProtocolVersion() {
+    return protocolVersion;
+  }

    public boolean isConnected() {
      return connected;
@@ -138,7 +147,7 @@
    void setShouldDisconnect() {
      shouldDisconnect = true;
    }
-
+
    /*
     * Perform the initial interaction. Return true if interaction succeeds,  
false
     * if it fails. Do a check protocol versions, expected with 2.0+ oophm
@@ -147,15 +156,15 @@
    private boolean init() throws IOException, BrowserChannelException {
      logger.log(TreeLogger.DEBUG, "sending " + MessageType.CHECK_VERSIONS
          + " message");
-    new CheckVersionsMessage(this, PROTOCOL_VERSION_CURRENT,
+    new CheckVersionsMessage(this, PROTOCOL_VERSION_OLDEST,
          PROTOCOL_VERSION_CURRENT, versionString).send();
      MessageType type = Message.readMessageType(getStreamFromOtherSide());
      switch (type) {
        case PROTOCOL_VERSION:
          ProtocolVersionMessage protocolMessage =  
ProtocolVersionMessage.receive(this);
+        protocolVersion = protocolMessage.getProtocolVersion();
          logger.log(TreeLogger.DEBUG, MessageType.PROTOCOL_VERSION
-            + ": protocol version = " +  
protocolMessage.getProtocolVersion());
-        // TODO(jat) : save selected protocol version when a range is  
supported.
+            + ": protocol version = " + protocolVersion);
          break;
        case FATAL_ERROR:
          FatalErrorMessage errorMessage = FatalErrorMessage.receive(this);
@@ -212,6 +221,11 @@
              htmlUnitSessionHandler.loadJsni(this, jsniString);
              // no response
              break;
+          case REQUEST_ICON:
+            RequestIconMessage.receive(this);
+            // no need for icon here
+            UserAgentIconMessage.send(this, null);
+            break;
            case RETURN:
              if (!expectReturn) {
                logger.log(TreeLogger.ERROR, "Received unexpected "
=======================================
---  
/changes/jat/abstractui/dev/oophm/test/com/google/gwt/dev/shell/BrowserChannelTest.java
  
Tue Oct  6 15:59:35 2009
+++  
/changes/jat/abstractui/dev/oophm/test/com/google/gwt/dev/shell/BrowserChannelTest.java
  
Wed Oct  7 16:56:57 2009
@@ -49,7 +49,8 @@
   * Test for {...@link BrowserChannel}.
   */
  public class BrowserChannelTest extends TestCase {
-
+  // TODO(jat): add more tests for Value types
+
    private TemporaryBufferStream bufferStream = new TemporaryBufferStream();

    private DataInputStream iStr = new DataInputStream(
@@ -57,12 +58,6 @@
    private DataOutputStream oStr = new DataOutputStream(
        bufferStream.getOutputStream());
    private TestBrowserChannel channel;
-
-  @Override
-  protected void setUp() throws Exception {
-    channel = new TestBrowserChannel(bufferStream.getInputStream(),
-        bufferStream.getOutputStream());
-  }

    public void testBooleanValue() throws IOException {
      Value val = new Value();
@@ -77,13 +72,11 @@
      assertEquals(ValueType.BOOLEAN, val.getType());
      assertEquals(false, val.getBoolean());
    }
-
-  // TODO(jat): add more tests for Value types
-
+
    public void testCheckVersions() throws IOException,  
BrowserChannelException {
-    int minVersion = 1;
-    int maxVersion = 2;
-    String hostedHtmlVersion = "2.0";
+    int minVersion = BrowserChannel.PROTOCOL_VERSION_OLDEST;
+    int maxVersion = BrowserChannel.PROTOCOL_VERSION_CURRENT;
+    String hostedHtmlVersion =  
HostedHtmlVersion.EXPECTED_GWT_ONLOAD_VERSION;
      new CheckVersionsMessage(channel, minVersion, maxVersion,
          hostedHtmlVersion).send();
      MessageType type = channel.readMessageType();
@@ -93,7 +86,7 @@
      assertEquals(maxVersion, message.getMaxVersion());
      assertEquals(hostedHtmlVersion, message.getHostedHtmlVersion());
    }
-
+
    public void testChooseTransport() throws IOException,
        BrowserChannelException {
      String[] transports = new String[] { "shm" };
@@ -104,7 +97,7 @@
      String[] transportsRecv = message.getTransports();
      assertTrue(Arrays.equals(transports, transportsRecv));
    }
-
+
    public void testFatalErrorMessage() throws IOException,
        BrowserChannelException {
      String error = "Fatal error";
@@ -114,7 +107,7 @@
      FatalErrorMessage message = FatalErrorMessage.receive(channel);
      assertEquals(error, message.getError());
    }
-
+
    public void testFreeMessage() throws IOException,  
BrowserChannelException {
      int[] ids = new int[] { 42, 1024 };
      new FreeMessage(channel, ids).send();
@@ -124,7 +117,7 @@
      int[] idsRecv = message.getIds();
      assertTrue(Arrays.equals(ids, idsRecv));
    }
-
+
    public void testInvokeOnClientMessage() throws IOException,
        BrowserChannelException {
      String methodName = "fooMethod";
@@ -150,7 +143,7 @@
        assertEquals(i, argsRecv[i].getInt());
      }
    }
-
+
    public void testInvokeOnServerMessage() throws IOException,
        BrowserChannelException {
      int methodId = -1;
@@ -176,7 +169,7 @@
        assertEquals(i, argsRecv[i].getInt());
      }
    }
-
+
    public void testInvokeSpecialMessage() throws IOException,
        BrowserChannelException {
      Value[] args = new Value[] {
@@ -196,7 +189,7 @@
        assertEquals(i, argsRecv[i].getInt());
      }
    }
-
+
    public void testLoadJsniMessage() throws IOException,
        BrowserChannelException {
      String jsni = "function foo() { }";
@@ -206,7 +199,7 @@
      LoadJsniMessage message = LoadJsniMessage.receive(channel);
      assertEquals(jsni, message.getJsni());
    }
-
+
    public void testLoadModuleMessage() throws IOException,
        BrowserChannelException {
      String url = "http://www.google.com";;
@@ -254,7 +247,7 @@
      } catch (Exception expected) {
        // will be AssertionError if assertions are turned on, otherwise NPE
      }
-
+
      try {
        new LoadModuleMessage(trashableChannel, url, null, sessionKey,  
moduleName,
            userAgent).send();
@@ -262,7 +255,7 @@
      } catch (Exception expected) {
        // will be AssertionError if assertions are turned on, otherwise NPE
      }
-
+
      try {
        new LoadModuleMessage(trashableChannel, url, tabKey, null,  
moduleName,
            userAgent).send();
@@ -270,7 +263,7 @@
      } catch (Exception expected) {
        // will be AssertionError if assertions are turned on, otherwise NPE
      }
-
+
      try {
        new LoadModuleMessage(trashableChannel, url, tabKey, sessionKey,  
null,
            userAgent).send();
@@ -278,7 +271,7 @@
      } catch (Exception expected) {
        // will be AssertionError if assertions are turned on, otherwise NPE
      }
-
+
      try {
        new LoadModuleMessage(trashableChannel, url, tabKey, sessionKey,  
moduleName,
            null).send();
@@ -287,7 +280,7 @@
        // will be AssertionError if assertions are turned on, otherwise NPE
      }
    }
-
+
    public void testOldLoadModuleMessage() throws IOException,
        BrowserChannelException {
      int protoVersion = 42;
@@ -302,7 +295,7 @@
      assertEquals(moduleName, message.getModuleName());
      assertEquals(userAgent, message.getUserAgent());
    }
-
+
    public void testProtocolVersionMessage() throws IOException,
        BrowserChannelException {
      int protoVersion = 42;
@@ -312,7 +305,7 @@
      ProtocolVersionMessage message =  
ProtocolVersionMessage.receive(channel);
      assertEquals(protoVersion, message.getProtocolVersion());
    }
-
+
    public void testQuitMessage() throws IOException,
        BrowserChannelException {
      new QuitMessage(channel).send();
@@ -320,7 +313,16 @@
      assertEquals(MessageType.QUIT, type);
      QuitMessage.receive(channel);
    }
-
+
+  public void testRequestIconMessage() throws IOException,
+      BrowserChannelException {
+    RequestIconMessage.send(channel);
+    MessageType type = channel.readMessageType();
+    assertEquals(MessageType.REQUEST_ICON, type);
+    RequestIconMessage message = RequestIconMessage.receive(channel);
+    assertFalse(message.isAsynchronous());
+  }
+
    public void testReturnMessage() throws IOException,
        BrowserChannelException {
      Value val = new Value();
@@ -334,16 +336,7 @@
      assertEquals(ValueType.INT, valRecv.getType());
      assertEquals(42, valRecv.getInt());
    }
-
-  public void testRequestIconMessage() throws IOException,
-      BrowserChannelException {
-    RequestIconMessage.send(channel);
-    MessageType type = channel.readMessageType();
-    assertEquals(MessageType.REQUEST_ICON, type);
-    RequestIconMessage message = RequestIconMessage.receive(channel);
-    assertFalse(message.isAsynchronous());
-  }
-
+
    public void testSwitchTransportMessage() throws IOException,
        BrowserChannelException {
      String transport = "shm";
@@ -385,4 +378,10 @@
        assertEquals(bytes[i], receivedBytes[i]);
      }
    }
-}
+
+  @Override
+  protected void setUp() throws Exception {
+    channel = new TestBrowserChannel(bufferStream.getInputStream(),
+        bufferStream.getOutputStream());
+  }
+}
=======================================
--- /changes/jat/abstractui/user/src/com/google/gwt/junit/JUnitShell.java       
 
Fri Oct  2 16:13:44 2009
+++ /changes/jat/abstractui/user/src/com/google/gwt/junit/JUnitShell.java       
 
Wed Oct  7 16:56:57 2009
@@ -278,7 +278,7 @@

          @Override
          public boolean setFlag() {
-          setHeadless(false);
+          setHeadlessAccessor(false);
            return true;
          }
        });
@@ -799,6 +799,16 @@
        compileForWebMode(moduleName, userAgents);
      }
    }
+
+  /**
+   * Accessor method to HostedModeBase.setHeadless -- without this, we get
+   * IllegalAccessError from the -notHeadless arg handler.  Compiler bug?
+   *
+   * @param headlessMode
+   */
+  void setHeadlessAccessor(boolean headlessMode) {
+    setHeadless(headlessMode);
+  }

    /**
     * Set the expected number of clients.

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

Reply via email to