From 8780b985450dd6592fcda0d7291ad03cc45b3bcd Mon Sep 17 00:00:00 2001 From: lotodore Date: Sun, 13 Feb 2011 00:22:03 +0000 Subject: [PATCH] New test cases for player info requests - also tests basic avatar handling. --- tests/src/pokerth_test/AllTests.java | 1 + .../src/pokerth_test/RunRankingGameTest.java | 3 +++ tests/src/pokerth_test/TestBase.java | 21 ++++++++++++++----- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/src/pokerth_test/AllTests.java b/tests/src/pokerth_test/AllTests.java index 2a9ec7ef..c2e3d734 100644 --- a/tests/src/pokerth_test/AllTests.java +++ b/tests/src/pokerth_test/AllTests.java @@ -26,6 +26,7 @@ import org.junit.runners.Suite; @Suite.SuiteClasses( { GuestLoginTest.class, AuthLoginTest.class, + PlayerInfoTest.class, CreateGameTest.class, CreateRankingGameTest.class, StartNormalGameTest.class, diff --git a/tests/src/pokerth_test/RunRankingGameTest.java b/tests/src/pokerth_test/RunRankingGameTest.java index 03ecb4aa..53a37958 100644 --- a/tests/src/pokerth_test/RunRankingGameTest.java +++ b/tests/src/pokerth_test/RunRankingGameTest.java @@ -248,6 +248,9 @@ public class RunRankingGameTest extends TestBase { } } while (!msg.isEndOfGameMessageSelected()); + for (int i = 0; i < 9; i++) { + s[i].close(); + } Thread.sleep(2000); // Check database entry for the game. diff --git a/tests/src/pokerth_test/TestBase.java b/tests/src/pokerth_test/TestBase.java index ce54c119..5e6479f4 100644 --- a/tests/src/pokerth_test/TestBase.java +++ b/tests/src/pokerth_test/TestBase.java @@ -80,11 +80,12 @@ public abstract class TestBase { return decoder.decode(s.getInputStream(), PokerTHMessage.class); } - public void guestInit() throws Exception { - guestInit(sock); + public long guestInit() throws Exception { + return guestInit(sock); } - public void guestInit(Socket s) throws Exception { + public long guestInit(Socket s) throws Exception { + long playerId = 0; PokerTHMessage msg = receiveMessage(s); AnnounceMessage announce = msg.getAnnounceMessage(); assertTrue(announce.getValue().getServerType().getValue() == ServerTypeEnumType.EnumType.serverTypeInternetAuth); @@ -107,11 +108,11 @@ public abstract class TestBase { sendMessage(msg, s); msg = receiveMessage(s); - if (msg.isInitAckMessageSelected()) - { + if (msg.isInitAckMessageSelected()) { InitAckMessage initAck = msg.getInitAckMessage(); assertTrue(initAck.getValue().getYourPlayerId().getValue() != 0L); assertTrue(!initAck.getValue().isYourAvatarPresent()); + playerId = initAck.getValue().getYourPlayerId().getValue(); } else { failOnErrorMessage(msg); @@ -123,6 +124,7 @@ public abstract class TestBase { failOnErrorMessage(msg); fail("Invalid message."); } + return playerId; } public long userInit() throws Exception { @@ -130,6 +132,10 @@ public abstract class TestBase { } public long userInit(Socket s, String user, String password) throws Exception { + return userInit(s, user, password, null); + } + + public long userInit(Socket s, String user, String password, byte[] avatarData) throws Exception { long playerId = 0; PokerTHMessage msg = receiveMessage(s); AnnounceMessage announce = msg.getAnnounceMessage(); @@ -142,6 +148,11 @@ public abstract class TestBase { requestedVersion.setMajor(PROTOCOL_VERSION_MAJOR); requestedVersion.setMinor(PROTOCOL_VERSION_MINOR); AuthenticatedLogin authLogin = new AuthenticatedLogin(); + AvatarHash avatar = null; + if (avatarData != null) { + avatar = new AvatarHash(avatarData); + } + authLogin.setAvatar(avatar); authLogin.setClientUserData(scramAuth.executeStep1(user).getBytes()); LoginChoiceType loginType = new LoginChoiceType(); loginType.selectAuthenticatedLogin(authLogin);