Package com.google.speedtracer.client.WindowChannel

Examples of com.google.speedtracer.client.WindowChannel.Client


    final WindowExt window = WindowExt.getHostWindow();
    final TestServerListener serverListener = new TestServerListener();
    Server server = Server.listen(window, channelName, serverListener);

    final TestListener clientListener = new TestListener();
    final Client client = WindowChannel.Client.connect(window, channelName,
        clientListener);

    ServerClientAndListener serverPair = serverListener.getListenerAndChannelAt(0);
    assertTrue("Channel is null.", serverPair.channel != null);
    assertTrue("Listener is null.", serverPair.listener != null);

    assertTrue("server failed to connect.", serverPair.listener.isConnected());
    assertTrue("client failed to connect.", clientListener.isConnected());

    serverPair.channel.close();
    assertFalse("server failed to close.", serverPair.listener.isConnected());
    assertFalse("client failed to close.", clientListener.isConnected());

    // Ensures there is no error calling close on a channel that was previously
    // closed.
    client.close();
    server.close();
    assertTrue("Server Connector did not null out after close.",
        window.getObjectProperty(PROPERTY_NAME + channelName) == null);
  }
View Full Code Here


    final WindowExt window = WindowExt.getHostWindow();
    final TestServerListener serverListener = new TestServerListener();
    Server server = Server.listen(window, channelName, serverListener);

    final TestListener clientListenerA = new TestListener();
    final Client clientA = Client.connect(window, channelName, clientListenerA);

    ServerClientAndListener serverPairA = serverListener.getListenerAndChannelAt(0);
    assertTrue("Channel is null.", serverPairA.channel != null);
    assertTrue("Listener is null.", serverPairA.listener != null);

    assertTrue("server failed to connect.", serverPairA.listener.isConnected());
    assertTrue("client failed to connect.", clientListenerA.isConnected());

    final TestListener clientListenerB = new TestListener();
    final Client clientB = Client.connect(window, channelName, clientListenerB);

    ServerClientAndListener serverPairB = serverListener.getListenerAndChannelAt(1);
    assertTrue("Channel is null.", serverPairB.channel != null);
    assertTrue("Listener is null.", serverPairB.listener != null);

    assertTrue("server failed to connect.", serverPairB.listener.isConnected());
    assertTrue("client failed to connect.", clientListenerB.isConnected());

    serverPairA.channel.close();
    assertFalse("server failed to close.", serverPairA.listener.isConnected());
    assertFalse("client failed to close.", clientListenerA.isConnected());

    serverPairB.channel.close();
    assertFalse("server failed to close.", serverPairB.listener.isConnected());
    assertFalse("client failed to close.", clientListenerB.isConnected());

    // Ensures there is no error calling close on a channel that was previously
    // closed.
    clientA.close();
    clientB.close();
    server.close();
    assertTrue("Server Connector did not null out after close.",
        window.getObjectProperty(PROPERTY_NAME + channelName) == null);
  }
View Full Code Here

    final WindowExt window = WindowExt.getHostWindow();
    final TestServerListener serverListener = new TestServerListener();
    Server server = Server.listen(window, channelName, serverListener);

    final TestListener clientListener = new TestListener();
    final Client client = Client.connect(window, channelName, clientListener);

    ServerClientAndListener serverPair = serverListener.getListenerAndChannelAt(0);
    assertTrue("Channel is null.", serverPair.channel != null);
    assertTrue("Listener is null.", serverPair.listener != null);

    assertTrue("server failed to connect.", serverPair.listener.isConnected());
    assertTrue("client failed to connect.", clientListener.isConnected());

    for (int i = 0; i < numberOfMessagesToSend; ++i) {
      serverPair.channel.sendMessage(i, TestMessage.create(i));
      client.sendMessage(i, TestMessage.create(i));
    }

    assertEquals("server received wrong # of messages.",
        numberOfMessagesToSend, serverPair.listener.getMessageCount());
    assertEquals("client received wrong # of messages.",
View Full Code Here

    final WindowExt window = WindowExt.getHostWindow();

    final TestServerListener serverListener = new SendInConnectServerListener();
    Server server = Server.listen(window, channelName, serverListener);
    final SendInConnectListener clientListener = new SendInConnectListener();
    final Client client = Client.connect(window, channelName, clientListener);

    ServerClientAndListener serverPair = serverListener.getListenerAndChannelAt(0);
    assertTrue("Channel is null.", serverPair.channel != null);
    assertTrue("Listener is null.", serverPair.listener != null);

    assertTrue("server failed to connect.", serverPair.listener.isConnected());
    assertTrue("client failed to connect.", clientListener.connected);

    assertTrue("client did not receive message",
        clientListener.didReceiveMessage());
    assertTrue("server did not receive message",
        ((SendInConnectListener) serverPair.listener).didReceiveMessage());

    client.close();
    server.close();
    assertTrue("Server Connector did not null out after close.",
        window.getObjectProperty(PROPERTY_NAME + channelName) == null);
  }
View Full Code Here

TOP

Related Classes of com.google.speedtracer.client.WindowChannel.Client

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.