Permalink
Browse files

Server interleave during test

  • Loading branch information...
1 parent 4c3d8b1 commit 8f50ba28cf1bed2853e36438309f78fc86d3f805 @bear101 bear101 committed Feb 14, 2017
@@ -836,54 +836,38 @@ protected static void connect(TeamTalkSrv server, TeamTalkBase ttclient)
connect(server, ttclient, SYSTEMID);
}
- protected static void connect(TeamTalkSrv server, TeamTalkBase ttclient, String systemID)
+ protected static void connect(final TeamTalkSrv server, TeamTalkBase ttclient, String systemID)
{
- assertTrue("connect call", ttclient.connectSysID(IPADDR, TCPPORT, UDPPORT, 0, 0, ENCRYPTED, systemID));
-
- while(server.runEventLoop(0));
-
- assertTrue("wait connect", waitForEvent(ttclient, ClientEvent.CLIENTEVENT_CON_SUCCESS, 1000));
+ connect(ttclient, SYSTEMID, new ServerInterleave() {
+ public void interleave() {
+ while(server.runEventLoop(0));
+ }
+ });
}
protected static void login(TeamTalkSrv server, TeamTalkBase ttclient,
String nick, String username, String passwd) {
login(server, ttclient, nick, username, passwd, "");
}
- protected static void login(TeamTalkSrv server, TeamTalkBase ttclient,
+ protected static void login(final TeamTalkSrv server, TeamTalkBase ttclient,
String nick, String username, String passwd,
String clientname)
{
- int cmdid = ttclient.doLoginEx(nick, username, passwd, clientname);
- assertTrue("do login", cmdid > 0);
-
- while(server.runEventLoop(100));
-
- TTMessage msg = new TTMessage();
- assertTrue("wait login", waitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_MYSELF_LOGGEDIN, DEF_WAIT, msg));
-
- UserAccount account = msg.useraccount;
- assertEquals("username set", username, account.szUsername);
- //Assert.AreEqual(passwd, account.szPassword, "password set");
- assertTrue("Wait login complete", waitCmdComplete(ttclient, cmdid, 1000));
- assertTrue("Authorized", hasFlag(ttclient.getFlags(), ClientFlag.CLIENT_AUTHORIZED));
+ login(ttclient, nick, username, passwd, clientname, new ServerInterleave() {
+ public void interleave() {
+ while(server.runEventLoop(100));
+ }
+ });
}
- protected static void joinRoot(TeamTalkSrv server, TeamTalkBase ttclient)
+ protected static void joinRoot(final TeamTalkSrv server, TeamTalkBase ttclient)
{
- assertTrue("Auth ok", hasFlag(ttclient.getFlags(), ClientFlag.CLIENT_AUTHORIZED));
-
- assertTrue("root exists", ttclient.getRootChannelID() > 0);
-
- int cmdid = ttclient.doJoinChannelByID(ttclient.getRootChannelID(), "");
-
- assertTrue("do join root", cmdid > 0);
-
- while(server.runEventLoop(100));
-
- assertTrue("Wait join complete", waitCmdComplete(ttclient, cmdid, 1000));
-
- assertEquals("In root channel", ttclient.getMyChannelID(), ttclient.getRootChannelID());
+ joinRoot(ttclient, new ServerInterleave() {
+ public void interleave() {
+ while(server.runEventLoop(0));
+ }
+ });
}
}
@@ -89,27 +89,49 @@ protected void initSound(TeamTalkBase ttclient, boolean duplex) {
assertEquals("agc9", spxdsp.nEchoSuppressActive, spxdsp2.nEchoSuppressActive);
}
+ public interface ServerInterleave {
+ public void interleave();
+ }
+
+ static ServerInterleave nop = new ServerInterleave() {
+ public void interleave() {
+ }
+ };
+
protected static void connect(TeamTalkBase ttclient)
{
connect(ttclient, SYSTEMID);
}
- protected static void connect(TeamTalkBase ttclient, String systemID)
+ protected static void connect(TeamTalkBase ttclient, String systemID) {
+ connect(ttclient, systemID, nop);
+ }
+
+ protected static void connect(TeamTalkBase ttclient, String systemID, ServerInterleave server)
{
assertTrue("connect call", ttclient.connectSysID(IPADDR, TCPPORT, UDPPORT, 0, 0, ENCRYPTED, systemID));
+ server.interleave();
+
assertTrue("wait connect", waitForEvent(ttclient, ClientEvent.CLIENTEVENT_CON_SUCCESS, 1000));
}
protected static void login(TeamTalkBase ttclient, String nick, String username, String passwd) {
login(ttclient, nick, username, passwd, "");
}
- protected static void login(TeamTalkBase ttclient, String nick, String username, String passwd, String clientname)
+ protected static void login(TeamTalkBase ttclient, String nick, String username, String passwd, String clientname) {
+ login(ttclient, nick, username, passwd, clientname, nop);
+ }
+
+ protected static void login(TeamTalkBase ttclient, String nick, String username,
+ String passwd, String clientname, ServerInterleave server)
{
int cmdid = ttclient.doLoginEx(nick, username, passwd, clientname);
assertTrue("do login", cmdid > 0);
+ server.interleave();
+
TTMessage msg = new TTMessage();
assertTrue("wait login", waitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_MYSELF_LOGGEDIN, DEF_WAIT, msg));
@@ -134,7 +156,11 @@ protected void makeUserAccount(String nickname, String username, String password
assertTrue("Disconnect", ttclient.disconnect());
}
- protected static void joinRoot(TeamTalkBase ttclient)
+ protected static void joinRoot(TeamTalkBase ttclient) {
+ joinRoot(ttclient, nop);
+ }
+
+ protected static void joinRoot(TeamTalkBase ttclient, ServerInterleave server)
{
assertTrue("Auth ok", hasFlag(ttclient.getFlags(), ClientFlag.CLIENT_AUTHORIZED));
@@ -143,6 +169,8 @@ protected static void joinRoot(TeamTalkBase ttclient)
int cmdid = ttclient.doJoinChannelByID(ttclient.getRootChannelID(), "");
assertTrue("do join root", cmdid > 0);
+
+ server.interleave();
assertTrue("Wait join complete", waitCmdComplete(ttclient, cmdid, 1000));

0 comments on commit 8f50ba2

Please sign in to comment.