More work on tests.
This commit is contained in:
+3
-3
@@ -59,9 +59,9 @@ enum PlayerInfoRights {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum NetAvatarType {
|
enum NetAvatarType {
|
||||||
avatarImagePng = 0;
|
avatarImagePng = 1;
|
||||||
avatarImageJpg = 1;
|
avatarImageJpg = 2;
|
||||||
avatarImageGif = 2;
|
avatarImageGif = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Message part containing game information.
|
// Message part containing game information.
|
||||||
|
|||||||
+7
-7
@@ -2598,8 +2598,8 @@ void protobuf_AddDesc_pokerth_2eproto() {
|
|||||||
"*X\n\020PlayerInfoRights\022\025\n\021playerRightsGues"
|
"*X\n\020PlayerInfoRights\022\025\n\021playerRightsGues"
|
||||||
"t\020\001\022\026\n\022playerRightsNormal\020\002\022\025\n\021playerRig"
|
"t\020\001\022\026\n\022playerRightsNormal\020\002\022\025\n\021playerRig"
|
||||||
"htsAdmin\020\003*K\n\rNetAvatarType\022\022\n\016avatarIma"
|
"htsAdmin\020\003*K\n\rNetAvatarType\022\022\n\016avatarIma"
|
||||||
"gePng\020\000\022\022\n\016avatarImageJpg\020\001\022\022\n\016avatarIma"
|
"gePng\020\001\022\022\n\016avatarImageJpg\020\002\022\022\n\016avatarIma"
|
||||||
"geGif\020\002", 17727);
|
"geGif\020\003B\037\n\023de.pokerth.protocolB\010ProtoBuf", 17760);
|
||||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||||
"pokerth.proto", &protobuf_RegisterTypes);
|
"pokerth.proto", &protobuf_RegisterTypes);
|
||||||
NetGameInfo::default_instance_ = new NetGameInfo();
|
NetGameInfo::default_instance_ = new NetGameInfo();
|
||||||
@@ -2866,9 +2866,9 @@ const ::google::protobuf::EnumDescriptor* NetAvatarType_descriptor() {
|
|||||||
}
|
}
|
||||||
bool NetAvatarType_IsValid(int value) {
|
bool NetAvatarType_IsValid(int value) {
|
||||||
switch(value) {
|
switch(value) {
|
||||||
case 0:
|
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
|
case 3:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@@ -6727,7 +6727,7 @@ AvatarHeaderMessage::AvatarHeaderMessage(const AvatarHeaderMessage& from)
|
|||||||
void AvatarHeaderMessage::SharedCtor() {
|
void AvatarHeaderMessage::SharedCtor() {
|
||||||
_cached_size_ = 0;
|
_cached_size_ = 0;
|
||||||
requestid_ = 0u;
|
requestid_ = 0u;
|
||||||
avatartype_ = 0;
|
avatartype_ = 1;
|
||||||
avatarsize_ = 0u;
|
avatarsize_ = 0u;
|
||||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||||
}
|
}
|
||||||
@@ -6764,7 +6764,7 @@ AvatarHeaderMessage* AvatarHeaderMessage::New() const {
|
|||||||
void AvatarHeaderMessage::Clear() {
|
void AvatarHeaderMessage::Clear() {
|
||||||
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||||
requestid_ = 0u;
|
requestid_ = 0u;
|
||||||
avatartype_ = 0;
|
avatartype_ = 1;
|
||||||
avatarsize_ = 0u;
|
avatarsize_ = 0u;
|
||||||
}
|
}
|
||||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||||
@@ -9616,7 +9616,7 @@ PlayerInfoReplyMessage_PlayerInfoData_AvatarData::PlayerInfoReplyMessage_PlayerI
|
|||||||
|
|
||||||
void PlayerInfoReplyMessage_PlayerInfoData_AvatarData::SharedCtor() {
|
void PlayerInfoReplyMessage_PlayerInfoData_AvatarData::SharedCtor() {
|
||||||
_cached_size_ = 0;
|
_cached_size_ = 0;
|
||||||
avatartype_ = 0;
|
avatartype_ = 1;
|
||||||
avatarhash_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
|
avatarhash_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
|
||||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||||
}
|
}
|
||||||
@@ -9655,7 +9655,7 @@ PlayerInfoReplyMessage_PlayerInfoData_AvatarData* PlayerInfoReplyMessage_PlayerI
|
|||||||
|
|
||||||
void PlayerInfoReplyMessage_PlayerInfoData_AvatarData::Clear() {
|
void PlayerInfoReplyMessage_PlayerInfoData_AvatarData::Clear() {
|
||||||
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||||
avatartype_ = 0;
|
avatartype_ = 1;
|
||||||
if (has_avatarhash()) {
|
if (has_avatarhash()) {
|
||||||
if (avatarhash_ != &::google::protobuf::internal::kEmptyString) {
|
if (avatarhash_ != &::google::protobuf::internal::kEmptyString) {
|
||||||
avatarhash_->clear();
|
avatarhash_->clear();
|
||||||
|
|||||||
+5
-5
@@ -774,9 +774,9 @@ inline bool PlayerInfoRights_Parse(
|
|||||||
PlayerInfoRights_descriptor(), name, value);
|
PlayerInfoRights_descriptor(), name, value);
|
||||||
}
|
}
|
||||||
enum NetAvatarType {
|
enum NetAvatarType {
|
||||||
avatarImagePng = 0,
|
avatarImagePng = 1,
|
||||||
avatarImageJpg = 1,
|
avatarImageJpg = 2,
|
||||||
avatarImageGif = 2
|
avatarImageGif = 3
|
||||||
};
|
};
|
||||||
bool NetAvatarType_IsValid(int value);
|
bool NetAvatarType_IsValid(int value);
|
||||||
const NetAvatarType NetAvatarType_MIN = avatarImagePng;
|
const NetAvatarType NetAvatarType_MIN = avatarImagePng;
|
||||||
@@ -12232,7 +12232,7 @@ inline void AvatarHeaderMessage::clear_has_avatartype() {
|
|||||||
_has_bits_[0] &= ~0x00000002u;
|
_has_bits_[0] &= ~0x00000002u;
|
||||||
}
|
}
|
||||||
inline void AvatarHeaderMessage::clear_avatartype() {
|
inline void AvatarHeaderMessage::clear_avatartype() {
|
||||||
avatartype_ = 0;
|
avatartype_ = 1;
|
||||||
clear_has_avatartype();
|
clear_has_avatartype();
|
||||||
}
|
}
|
||||||
inline NetAvatarType AvatarHeaderMessage::avatartype() const {
|
inline NetAvatarType AvatarHeaderMessage::avatartype() const {
|
||||||
@@ -12832,7 +12832,7 @@ inline void PlayerInfoReplyMessage_PlayerInfoData_AvatarData::clear_has_avatarty
|
|||||||
_has_bits_[0] &= ~0x00000001u;
|
_has_bits_[0] &= ~0x00000001u;
|
||||||
}
|
}
|
||||||
inline void PlayerInfoReplyMessage_PlayerInfoData_AvatarData::clear_avatartype() {
|
inline void PlayerInfoReplyMessage_PlayerInfoData_AvatarData::clear_avatartype() {
|
||||||
avatartype_ = 0;
|
avatartype_ = 1;
|
||||||
clear_has_avatartype();
|
clear_has_avatartype();
|
||||||
}
|
}
|
||||||
inline NetAvatarType PlayerInfoReplyMessage_PlayerInfoData_AvatarData::avatartype() const {
|
inline NetAvatarType PlayerInfoReplyMessage_PlayerInfoData_AvatarData::avatartype() const {
|
||||||
|
|||||||
@@ -391,23 +391,23 @@ public final class ProtoBuf {
|
|||||||
|
|
||||||
public enum NetAvatarType
|
public enum NetAvatarType
|
||||||
implements com.google.protobuf.ProtocolMessageEnum {
|
implements com.google.protobuf.ProtocolMessageEnum {
|
||||||
avatarImagePng(0, 0),
|
avatarImagePng(0, 1),
|
||||||
avatarImageJpg(1, 1),
|
avatarImageJpg(1, 2),
|
||||||
avatarImageGif(2, 2),
|
avatarImageGif(2, 3),
|
||||||
;
|
;
|
||||||
|
|
||||||
public static final int avatarImagePng_VALUE = 0;
|
public static final int avatarImagePng_VALUE = 1;
|
||||||
public static final int avatarImageJpg_VALUE = 1;
|
public static final int avatarImageJpg_VALUE = 2;
|
||||||
public static final int avatarImageGif_VALUE = 2;
|
public static final int avatarImageGif_VALUE = 3;
|
||||||
|
|
||||||
|
|
||||||
public final int getNumber() { return value; }
|
public final int getNumber() { return value; }
|
||||||
|
|
||||||
public static NetAvatarType valueOf(int value) {
|
public static NetAvatarType valueOf(int value) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 0: return avatarImagePng;
|
case 1: return avatarImagePng;
|
||||||
case 1: return avatarImageJpg;
|
case 2: return avatarImageJpg;
|
||||||
case 2: return avatarImageGif;
|
case 3: return avatarImageGif;
|
||||||
default: return null;
|
default: return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55550,8 +55550,8 @@ public final class ProtoBuf {
|
|||||||
"*X\n\020PlayerInfoRights\022\025\n\021playerRightsGues",
|
"*X\n\020PlayerInfoRights\022\025\n\021playerRightsGues",
|
||||||
"t\020\001\022\026\n\022playerRightsNormal\020\002\022\025\n\021playerRig" +
|
"t\020\001\022\026\n\022playerRightsNormal\020\002\022\025\n\021playerRig" +
|
||||||
"htsAdmin\020\003*K\n\rNetAvatarType\022\022\n\016avatarIma" +
|
"htsAdmin\020\003*K\n\rNetAvatarType\022\022\n\016avatarIma" +
|
||||||
"gePng\020\000\022\022\n\016avatarImageJpg\020\001\022\022\n\016avatarIma" +
|
"gePng\020\001\022\022\n\016avatarImageJpg\020\002\022\022\n\016avatarIma" +
|
||||||
"geGif\020\002B\037\n\023de.pokerth.protocolB\010ProtoBuf"
|
"geGif\020\003B\037\n\023de.pokerth.protocolB\010ProtoBuf"
|
||||||
};
|
};
|
||||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||||
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
|
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
|
||||||
|
|||||||
@@ -26,6 +26,14 @@ import java.util.Collection;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.pokerth.protocol.ProtoBuf.NetGameInfo;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.NetGameInfo.EndRaiseMode;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.NetGameInfo.NetGameType;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.PokerTHMessage.PokerTHMessageType;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.MyActionRequestMessage;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.NetPlayerAction;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.PokerTHMessage;
|
||||||
|
|
||||||
|
|
||||||
public class LoadTest extends TestBase {
|
public class LoadTest extends TestBase {
|
||||||
|
|
||||||
@@ -39,8 +47,8 @@ public class LoadTest extends TestBase {
|
|||||||
|
|
||||||
// We need a lot of sockets and player ids.
|
// We need a lot of sockets and player ids.
|
||||||
Socket s[] = new Socket[NumGames * 10];
|
Socket s[] = new Socket[NumGames * 10];
|
||||||
long playerId[] = new long[NumGames * 10];
|
int playerId[] = new int[NumGames * 10];
|
||||||
long gameId[] = new long[NumGames];
|
int gameId[] = new int[NumGames];
|
||||||
|
|
||||||
PokerTHMessage msg;
|
PokerTHMessage msg;
|
||||||
// First players are game admins.
|
// First players are game admins.
|
||||||
@@ -53,20 +61,17 @@ public class LoadTest extends TestBase {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
msg = receiveMessage(s[i * 10]);
|
msg = receiveMessage(s[i * 10]);
|
||||||
} while (msg.isGameListMessageSelected() || msg.isGamePlayerMessageSelected());
|
} while (msg.hasGameListNewMessage() || msg.hasGameListPlayerJoinedMessage() || msg.hasGamePlayerJoinedMessage());
|
||||||
if (!msg.isPlayerListMessageSelected()) {
|
if (!msg.hasPlayerListMessage()) {
|
||||||
failOnErrorMessage(msg);
|
failOnErrorMessage(msg);
|
||||||
fail("Invalid message.");
|
fail("Invalid message.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<InitialNonZeroAmountOfMoney> l = new ArrayList<InitialNonZeroAmountOfMoney>();
|
Collection<Integer> l = new ArrayList<Integer>();
|
||||||
String gameName = AuthUser + " load game " + i;
|
String gameName = AuthUser + " load game " + i;
|
||||||
NetGameInfo gameInfo = createGameInfo(5, EndRaiseModeEnumType.EnumType.doubleBlinds, 0, 200, gameName, l, 10, 0, 1, 10000);
|
NetGameInfo gameInfo = createGameInfo(NetGameType.normalGame, 5, 7, 5, EndRaiseMode.doubleBlinds, 0, 200, gameName, l, 10, 0, 1, 10000);
|
||||||
sendMessage(createGameRequestMsg(
|
sendMessage(createGameRequestMsg(
|
||||||
gameInfo,
|
gameInfo,
|
||||||
NetGameTypeEnumType.EnumType.normalGame,
|
|
||||||
5,
|
|
||||||
7,
|
|
||||||
"",
|
"",
|
||||||
false),
|
false),
|
||||||
s[i * 10]);
|
s[i * 10]);
|
||||||
@@ -75,19 +80,14 @@ public class LoadTest extends TestBase {
|
|||||||
do {
|
do {
|
||||||
msg = receiveMessage(s[i * 10]);
|
msg = receiveMessage(s[i * 10]);
|
||||||
failOnErrorMessage(msg);
|
failOnErrorMessage(msg);
|
||||||
} while (msg.isGameListMessageSelected() || msg.isPlayerListMessageSelected());
|
} while (msg.hasGameListNewMessage() || msg.hasGameListPlayerJoinedMessage() || msg.hasPlayerListMessage());
|
||||||
|
|
||||||
// Join game ack.
|
// Join game ack.
|
||||||
if (msg.isJoinGameReplyMessageSelected()) {
|
if (!msg.hasJoinGameAckMessage()) {
|
||||||
if (!msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameAckSelected()) {
|
failOnErrorMessage(msg);
|
||||||
fail("Could not create game!");
|
fail("Could not create game!");
|
||||||
}
|
}
|
||||||
}
|
gameId[i] = msg.getJoinGameAckMessage().getGameId();
|
||||||
else {
|
|
||||||
failOnErrorMessage(msg);
|
|
||||||
fail("Invalid message.");
|
|
||||||
}
|
|
||||||
gameId[i] = msg.getJoinGameReplyMessage().getValue().getGameId().getValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -103,8 +103,8 @@ public class LoadTest extends TestBase {
|
|||||||
// Waiting for player list update.
|
// Waiting for player list update.
|
||||||
do {
|
do {
|
||||||
msg = receiveMessage(s[i]);
|
msg = receiveMessage(s[i]);
|
||||||
} while (msg.isGameListMessageSelected() || msg.isGamePlayerMessageSelected());
|
} while (msg.hasGameListPlayerJoinedMessage() || msg.hasGamePlayerJoinedMessage());
|
||||||
if (!msg.isPlayerListMessageSelected()) {
|
if (!msg.hasPlayerListMessage()) {
|
||||||
failOnErrorMessage(msg);
|
failOnErrorMessage(msg);
|
||||||
fail("Invalid message.");
|
fail("Invalid message.");
|
||||||
}
|
}
|
||||||
@@ -112,40 +112,39 @@ public class LoadTest extends TestBase {
|
|||||||
do {
|
do {
|
||||||
msg = receiveMessage(s[i]);
|
msg = receiveMessage(s[i]);
|
||||||
failOnErrorMessage(msg);
|
failOnErrorMessage(msg);
|
||||||
} while (!msg.isJoinGameReplyMessageSelected());
|
} while (!msg.hasJoinGameAckMessage() && !msg.hasJoinGameFailedMessage());
|
||||||
if (!msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameAckSelected()) {
|
if (!msg.hasJoinGameAckMessage()) {
|
||||||
fail("User " + username + " could not join ranking game.");
|
fail("User " + username + " could not join normal game.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean abort = false;
|
boolean abort = false;
|
||||||
long handNum = 0;
|
int handNum[] = new int[NumGames];
|
||||||
do {
|
do {
|
||||||
for (int i = 0; i < NumGames * 10; i++) {
|
for (int i = 0; i < NumGames * 10; i++) {
|
||||||
while (s[i].getInputStream().available() > 0) {
|
while (s[i].getInputStream().available() > 0) {
|
||||||
msg = receiveMessage(s[i]);
|
msg = receiveMessage(s[i]);
|
||||||
failOnErrorMessage(msg);
|
failOnErrorMessage(msg);
|
||||||
if (msg.isHandStartMessageSelected()) {
|
if (msg.hasHandStartMessage()) {
|
||||||
handNum++;
|
handNum[i / 10]++;
|
||||||
}
|
}
|
||||||
else if (msg.isPlayersTurnMessageSelected()) {
|
else if (msg.hasPlayersTurnMessage()) {
|
||||||
if (msg.getPlayersTurnMessage().getValue().getPlayerId().getValue() == playerId[i / 10]) {
|
if (msg.getPlayersTurnMessage().getPlayerId() == playerId[i / 10]) {
|
||||||
NetPlayerAction action = new NetPlayerAction();
|
MyActionRequestMessage myRequest = MyActionRequestMessage.newBuilder()
|
||||||
action.setValue(NetPlayerAction.EnumType.actionAllIn);
|
.setGameId(gameId[i / 10])
|
||||||
MyActionRequestMessageSequenceType myRequest = new MyActionRequestMessageSequenceType();
|
.setGameState(msg.getPlayersTurnMessage().getGameState())
|
||||||
myRequest.setGameId(new NonZeroId(gameId[i / 10]));
|
.setHandNum(handNum[i / 10])
|
||||||
myRequest.setGameState(msg.getPlayersTurnMessage().getValue().getGameState());
|
.setMyAction(NetPlayerAction.actionAllIn)
|
||||||
myRequest.setHandNum(new NonZeroId(handNum));
|
.setMyRelativeBet(0)
|
||||||
myRequest.setMyAction(action);
|
.build();
|
||||||
myRequest.setMyRelativeBet(new AmountOfMoney(0));
|
PokerTHMessage outMsg = PokerTHMessage.newBuilder()
|
||||||
MyActionRequestMessage myAction = new MyActionRequestMessage();
|
.setMessageType(PokerTHMessageType.Type_MyActionRequestMessage)
|
||||||
myAction.setValue(myRequest);
|
.setMyActionRequestMessage(myRequest)
|
||||||
PokerTHMessage outMsg = new PokerTHMessage();
|
.build();
|
||||||
outMsg.selectMyActionRequestMessage(myAction);
|
|
||||||
sendMessage(outMsg, s[i]);
|
sendMessage(outMsg, s[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (msg.isEndOfGameMessageSelected()) {
|
else if (msg.hasEndOfGameMessage()) {
|
||||||
abort = true;
|
abort = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,14 @@ import java.util.Collection;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.pokerth.protocol.ProtoBuf.NetGameInfo;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.NetGameInfo.EndRaiseMode;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.PokerTHMessage;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.SubscriptionRequestMessage;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.NetGameInfo.NetGameType;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.PokerTHMessage.PokerTHMessageType;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.SubscriptionRequestMessage.SubscriptionAction;
|
||||||
|
|
||||||
|
|
||||||
public class LobbySubscriptionTest extends TestBase {
|
public class LobbySubscriptionTest extends TestBase {
|
||||||
|
|
||||||
@@ -35,38 +43,33 @@ public class LobbySubscriptionTest extends TestBase {
|
|||||||
|
|
||||||
PokerTHMessage msg;
|
PokerTHMessage msg;
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
if (!msg.isPlayerListMessageSelected()) {
|
if (!msg.hasPlayerListMessage()) {
|
||||||
failOnErrorMessage(msg);
|
failOnErrorMessage(msg);
|
||||||
fail("Invalid message.");
|
fail("Invalid message.");
|
||||||
}
|
}
|
||||||
|
|
||||||
SubscriptionRequestMessageSequenceType subscriptionType = new SubscriptionRequestMessageSequenceType();
|
SubscriptionRequestMessage subscriptionRequest = SubscriptionRequestMessage.newBuilder()
|
||||||
SubscriptionActionEnumType action = new SubscriptionActionEnumType();
|
.setSubscriptionAction(SubscriptionAction.unsubscribeGameList)
|
||||||
action.setValue(SubscriptionActionEnumType.EnumType.unsubscribeGameList);
|
.build();
|
||||||
subscriptionType.setSubscriptionAction(action);
|
msg = PokerTHMessage.newBuilder()
|
||||||
SubscriptionRequestMessage subscriptionRequest = new SubscriptionRequestMessage();
|
.setMessageType(PokerTHMessageType.Type_SubscriptionRequestMessage)
|
||||||
subscriptionRequest.setValue(subscriptionType);
|
.setSubscriptionRequestMessage(subscriptionRequest)
|
||||||
msg = new PokerTHMessage();
|
.build();
|
||||||
msg.selectSubscriptionRequestMessage(subscriptionRequest);
|
|
||||||
sendMessage(msg);
|
sendMessage(msg);
|
||||||
|
|
||||||
// Create a new game.
|
// Create a new game.
|
||||||
Collection<InitialNonZeroAmountOfMoney> l = new ArrayList<InitialNonZeroAmountOfMoney>();
|
Collection<Integer> l = new ArrayList<Integer>();
|
||||||
NetGameInfo gameInfo = createGameInfo(5, EndRaiseModeEnumType.EnumType.doubleBlinds, 0, 100, GuestUser + " game list normal game", l, 10, 0, 2, 2000);
|
NetGameInfo gameInfo = createGameInfo(NetGameType.normalGame, 10, 5, 5, EndRaiseMode.doubleBlinds, 0, 100, GuestUser + " game list normal game", l, 10, 0, 2, 2000);
|
||||||
sendMessage(createGameRequestMsg(
|
sendMessage(createGameRequestMsg(
|
||||||
gameInfo,
|
gameInfo,
|
||||||
NetGameTypeEnumType.EnumType.normalGame,
|
|
||||||
10,
|
|
||||||
5,
|
|
||||||
"",
|
"",
|
||||||
false));
|
false));
|
||||||
|
|
||||||
// No game list message should be sent by the server.
|
// No game list message should be sent by the server.
|
||||||
// Next message is join game ack.
|
// Next message is join game ack.
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
assertTrue(msg.isJoinGameReplyMessageSelected());
|
assertTrue(msg.hasJoinGameAckMessage());
|
||||||
assertTrue(msg.getJoinGameReplyMessage().getValue().getJoinGameResult().isJoinGameAckSelected());
|
int gameId = msg.getJoinGameAckMessage().getGameId();
|
||||||
long gameId = msg.getJoinGameReplyMessage().getValue().getGameId().getValue().longValue();
|
|
||||||
|
|
||||||
Socket s[] = new Socket[9];
|
Socket s[] = new Socket[9];
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
@@ -80,30 +83,29 @@ public class LobbySubscriptionTest extends TestBase {
|
|||||||
// No game list message should be received.
|
// No game list message should be received.
|
||||||
do {
|
do {
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
if (msg.isGameListMessageSelected() || msg.isPlayerListMessageSelected()) {
|
if (msg.hasGameListNewMessage() || msg.hasPlayerListMessage()) {
|
||||||
fail("Game/player list messages are switched off!");
|
fail("Game/player list messages are switched off!");
|
||||||
}
|
}
|
||||||
} while (!msg.isStartEventMessageSelected());
|
} while (!msg.hasStartEventMessage());
|
||||||
|
|
||||||
// Resubscribe game list
|
// Resubscribe game list
|
||||||
subscriptionType = new SubscriptionRequestMessageSequenceType();
|
subscriptionRequest = SubscriptionRequestMessage.newBuilder()
|
||||||
action = new SubscriptionActionEnumType();
|
.setSubscriptionAction(SubscriptionAction.resubscribeGameList)
|
||||||
action.setValue(SubscriptionActionEnumType.EnumType.resubscribeGameList);
|
.build();
|
||||||
subscriptionType.setSubscriptionAction(action);
|
msg = PokerTHMessage.newBuilder()
|
||||||
subscriptionRequest = new SubscriptionRequestMessage();
|
.setMessageType(PokerTHMessageType.Type_SubscriptionRequestMessage)
|
||||||
subscriptionRequest.setValue(subscriptionType);
|
.setSubscriptionRequestMessage(subscriptionRequest)
|
||||||
msg = new PokerTHMessage();
|
.build();
|
||||||
msg.selectSubscriptionRequestMessage(subscriptionRequest);
|
|
||||||
sendMessage(msg);
|
sendMessage(msg);
|
||||||
|
|
||||||
// Next messages should player list messages for all 10 players.
|
// Next messages should player list messages for all 10 players.
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
assertTrue(msg.isPlayerListMessageSelected());
|
assertTrue(msg.hasPlayerListMessage());
|
||||||
}
|
}
|
||||||
// Now there should be one game list message.
|
// Now there should be one game list message.
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
assertTrue(msg.isGameListMessageSelected());
|
assertTrue(msg.hasGameListNewMessage());
|
||||||
|
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
s[i].close();
|
s[i].close();
|
||||||
|
|||||||
@@ -25,22 +25,31 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.pokerth.protocol.ProtoBuf.NetAvatarType;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.PlayerInfoReplyMessage;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.PlayerInfoReplyMessage.PlayerInfoData;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.PlayerInfoRequestMessage;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.PlayerInfoRights;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.PokerTHMessage;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.PokerTHMessage.PokerTHMessageType;
|
||||||
|
|
||||||
public class PlayerInfoTest extends TestBase {
|
public class PlayerInfoTest extends TestBase {
|
||||||
|
|
||||||
protected void sendPlayerInfoRequest(Socket s, long playerId) throws Exception {
|
protected void sendPlayerInfoRequest(Socket s, int playerId) throws Exception {
|
||||||
PlayerInfoRequestMessageSequenceType type = new PlayerInfoRequestMessageSequenceType();
|
PlayerInfoRequestMessage request = PlayerInfoRequestMessage.newBuilder()
|
||||||
type.setPlayerId(new NonZeroId(playerId));
|
.setPlayerId(playerId)
|
||||||
PlayerInfoRequestMessage request = new PlayerInfoRequestMessage();
|
.build();
|
||||||
request.setValue(type);
|
PokerTHMessage msg = PokerTHMessage.newBuilder()
|
||||||
PokerTHMessage msg = new PokerTHMessage();
|
.setMessageType(PokerTHMessageType.Type_PlayerInfoRequestMessage)
|
||||||
msg.selectPlayerInfoRequestMessage(request);
|
.setPlayerInfoRequestMessage(request)
|
||||||
|
.build();
|
||||||
sendMessage(msg, s);
|
sendMessage(msg, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPlayerInfoRequest() throws Exception {
|
public void testPlayerInfoRequest() throws Exception {
|
||||||
|
|
||||||
long firstPlayerId = guestInit();
|
int firstPlayerId = guestInit();
|
||||||
byte[] avatarHash =
|
byte[] avatarHash =
|
||||||
{
|
{
|
||||||
// one of the builtin avatars.
|
// one of the builtin avatars.
|
||||||
@@ -52,8 +61,8 @@ public class PlayerInfoTest extends TestBase {
|
|||||||
|
|
||||||
// Let 9 additional clients join.
|
// Let 9 additional clients join.
|
||||||
Socket s[] = new Socket[9];
|
Socket s[] = new Socket[9];
|
||||||
long playerId[] = new long[9];
|
int playerId[] = new int[9];
|
||||||
long maxPlayerId = 0;
|
int maxPlayerId = 0;
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
s[i] = new Socket("localhost", 7234);
|
s[i] = new Socket("localhost", 7234);
|
||||||
String username = "test" + (i+1);
|
String username = "test" + (i+1);
|
||||||
@@ -75,48 +84,49 @@ public class PlayerInfoTest extends TestBase {
|
|||||||
sendPlayerInfoRequest(s[i], firstPlayerId);
|
sendPlayerInfoRequest(s[i], firstPlayerId);
|
||||||
do {
|
do {
|
||||||
msg = receiveMessage(s[i]);
|
msg = receiveMessage(s[i]);
|
||||||
} while (msg.isPlayerListMessageSelected());
|
} while (msg.hasPlayerListMessage());
|
||||||
assertTrue(msg.isPlayerInfoReplyMessageSelected());
|
assertTrue(msg.hasPlayerInfoReplyMessage() && msg.getMessageType() == PokerTHMessageType.Type_PlayerInfoReplyMessage);
|
||||||
PlayerInfoReplyMessage reply = msg.getPlayerInfoReplyMessage();
|
PlayerInfoReplyMessage reply = msg.getPlayerInfoReplyMessage();
|
||||||
assertTrue(reply.getValue().getPlayerId().getValue() == firstPlayerId);
|
assertTrue(reply.getPlayerId() == firstPlayerId);
|
||||||
assertTrue(reply.getValue().getPlayerInfoResult().isPlayerInfoDataSelected());
|
assertTrue(reply.hasPlayerInfoData());
|
||||||
PlayerInfoData info = reply.getValue().getPlayerInfoResult().getPlayerInfoData();
|
PlayerInfoData info = reply.getPlayerInfoData();
|
||||||
assertEquals(GuestUser, info.getPlayerName());
|
assertEquals(GuestUser, info.getPlayerName());
|
||||||
assertEquals(null, info.getCountryCode());
|
assertFalse(info.hasCountryCode());
|
||||||
assertTrue(info.getIsHuman());
|
assertTrue(info.getIsHuman());
|
||||||
assertEquals(PlayerInfoRights.EnumType.playerRightsGuest, info.getPlayerRights().getValue());
|
assertEquals(PlayerInfoRights.playerRightsGuest, info.getPlayerRights());
|
||||||
assertEquals(null, info.getAvatarData());
|
assertFalse(info.hasAvatarData());
|
||||||
}
|
}
|
||||||
// Request other players' info.
|
// Request other players' info.
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
sendPlayerInfoRequest(sock, playerId[i]);
|
sendPlayerInfoRequest(sock, playerId[i]);
|
||||||
do {
|
do {
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
} while (msg.isPlayerListMessageSelected());
|
} while (msg.hasPlayerListMessage());
|
||||||
assertTrue(msg.isPlayerInfoReplyMessageSelected());
|
assertTrue(msg.hasPlayerInfoReplyMessage() && msg.getMessageType() == PokerTHMessageType.Type_PlayerInfoReplyMessage);
|
||||||
PlayerInfoReplyMessage reply = msg.getPlayerInfoReplyMessage();
|
PlayerInfoReplyMessage reply = msg.getPlayerInfoReplyMessage();
|
||||||
assertTrue(reply.getValue().getPlayerId().getValue() == playerId[i]);
|
assertTrue(reply.getPlayerId() == playerId[i]);
|
||||||
assertTrue(reply.getValue().getPlayerInfoResult().isPlayerInfoDataSelected());
|
assertTrue(reply.hasPlayerInfoData());
|
||||||
PlayerInfoData info = reply.getValue().getPlayerInfoResult().getPlayerInfoData();
|
PlayerInfoData info = reply.getPlayerInfoData();
|
||||||
assertEquals("test" + (i+1), info.getPlayerName());
|
assertEquals("test" + (i+1), info.getPlayerName());
|
||||||
assertEquals(null, info.getCountryCode());
|
assertFalse(info.hasCountryCode());
|
||||||
assertTrue(info.getIsHuman());
|
assertTrue(info.getIsHuman());
|
||||||
assertEquals(PlayerInfoRights.EnumType.playerRightsNormal, info.getPlayerRights().getValue());
|
assertEquals(PlayerInfoRights.playerRightsNormal, info.getPlayerRights());
|
||||||
// Every second player has an avatar, see above.
|
// Every second player has an avatar, see above.
|
||||||
if (i % 2 == 0) {
|
if (i % 2 == 0) {
|
||||||
assertEquals(null, info.getAvatarData());
|
assertFalse(info.hasAvatarData());
|
||||||
} else {
|
} else {
|
||||||
assertTrue(Arrays.equals(info.getAvatarData().getAvatar().getValue(), avatarHash));
|
assertTrue(info.hasAvatarData());
|
||||||
assertEquals(NetAvatarType.EnumType.avatarImagePng, info.getAvatarData().getAvatarType().getValue());
|
assertTrue(Arrays.equals(info.getAvatarData().getAvatarHash().toByteArray(), avatarHash));
|
||||||
|
assertEquals(NetAvatarType.avatarImagePng, info.getAvatarData().getAvatarType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Request invalid player info.
|
// Request invalid player info.
|
||||||
sendPlayerInfoRequest(sock, maxPlayerId + 1);
|
sendPlayerInfoRequest(sock, maxPlayerId + 1);
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
assertTrue(msg.isPlayerInfoReplyMessageSelected());
|
assertTrue(msg.hasPlayerInfoReplyMessage() && msg.getMessageType() == PokerTHMessageType.Type_PlayerInfoReplyMessage);
|
||||||
PlayerInfoReplyMessage reply = msg.getPlayerInfoReplyMessage();
|
PlayerInfoReplyMessage reply = msg.getPlayerInfoReplyMessage();
|
||||||
assertTrue(reply.getValue().getPlayerId().getValue() == maxPlayerId + 1);
|
assertTrue(reply.getPlayerId() == maxPlayerId + 1);
|
||||||
assertTrue(reply.getValue().getPlayerInfoResult().isUnknownPlayerInfoSelected());
|
assertFalse(reply.hasPlayerInfoData());
|
||||||
|
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
s[i].close();
|
s[i].close();
|
||||||
|
|||||||
@@ -24,23 +24,27 @@ import java.net.Socket;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.pokerth.protocol.ProtoBuf.PlayerListMessage;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.PlayerListMessage.PlayerListNotification;
|
||||||
|
import de.pokerth.protocol.ProtoBuf.PokerTHMessage;
|
||||||
|
|
||||||
|
|
||||||
public class PlayerListTest extends TestBase {
|
public class PlayerListTest extends TestBase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPlayerList() throws Exception {
|
public void testPlayerList() throws Exception {
|
||||||
|
|
||||||
long myId = guestInit();
|
int myId = guestInit();
|
||||||
|
|
||||||
// Waiting for player list update.
|
// Waiting for player list update.
|
||||||
PokerTHMessage msg;
|
PokerTHMessage msg;
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
assertTrue(msg.isPlayerListMessageSelected());
|
assertTrue(msg.hasPlayerListMessage());
|
||||||
|
|
||||||
// This should be a "player list new" notification with correct player id.
|
// This should be a "player list new" notification with correct player id.
|
||||||
PlayerListMessage listMsg = msg.getPlayerListMessage();
|
PlayerListMessage listMsg = msg.getPlayerListMessage();
|
||||||
assertEquals(myId, listMsg.getValue().getPlayerId().getValue().longValue());
|
assertEquals(myId, listMsg.getPlayerId());
|
||||||
assertEquals(PlayerListNotificationEnumType.EnumType.playerListNew, listMsg.getValue().getPlayerListNotification().getValue());
|
assertEquals(PlayerListNotification.playerListNew, listMsg.getPlayerListNotification());
|
||||||
|
|
||||||
Socket s[] = new Socket[9];
|
Socket s[] = new Socket[9];
|
||||||
long playerId[] = new long[9];
|
long playerId[] = new long[9];
|
||||||
@@ -51,22 +55,22 @@ public class PlayerListTest extends TestBase {
|
|||||||
playerId[i] = userInit(s[i], username, password);
|
playerId[i] = userInit(s[i], username, password);
|
||||||
|
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
assertTrue(msg.isPlayerListMessageSelected());
|
assertTrue(msg.hasPlayerListMessage());
|
||||||
listMsg = msg.getPlayerListMessage();
|
listMsg = msg.getPlayerListMessage();
|
||||||
// Id should be different from first id.
|
// Id should be different from first id.
|
||||||
assertTrue(myId != playerId[i]);
|
assertTrue(myId != playerId[i]);
|
||||||
// This should be a "player list new" notification with correct player id.
|
// This should be a "player list new" notification with correct player id.
|
||||||
assertEquals(playerId[i], listMsg.getValue().getPlayerId().getValue().longValue());
|
assertEquals(playerId[i], listMsg.getPlayerId());
|
||||||
assertEquals(PlayerListNotificationEnumType.EnumType.playerListNew, listMsg.getValue().getPlayerListNotification().getValue());
|
assertEquals(PlayerListNotification.playerListNew, listMsg.getPlayerListNotification());
|
||||||
|
|
||||||
s[i].close();
|
s[i].close();
|
||||||
|
|
||||||
// After the connection is closed, a "player list left" notification should be received.
|
// After the connection is closed, a "player list left" notification should be received.
|
||||||
msg = receiveMessage();
|
msg = receiveMessage();
|
||||||
assertTrue(msg.isPlayerListMessageSelected());
|
assertTrue(msg.hasPlayerListMessage());
|
||||||
listMsg = msg.getPlayerListMessage();
|
listMsg = msg.getPlayerListMessage();
|
||||||
assertEquals(playerId[i], listMsg.getValue().getPlayerId().getValue().longValue());
|
assertEquals(playerId[i], listMsg.getPlayerId());
|
||||||
assertEquals(PlayerListNotificationEnumType.EnumType.playerListLeft, listMsg.getValue().getPlayerListNotification().getValue());
|
assertEquals(PlayerListNotification.playerListLeft, listMsg.getPlayerListNotification());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user