Add extra check in IXWebSocketCloseTest.cpp
This commit is contained in:
parent
eea42bff66
commit
01bc6654cb
@ -33,6 +33,8 @@ namespace
|
|||||||
uint16_t getCloseCode();
|
uint16_t getCloseCode();
|
||||||
const std::string& getCloseReason();
|
const std::string& getCloseReason();
|
||||||
bool getCloseRemote();
|
bool getCloseRemote();
|
||||||
|
|
||||||
|
bool hasConnectionError() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ix::WebSocket _webSocket;
|
ix::WebSocket _webSocket;
|
||||||
@ -42,6 +44,7 @@ namespace
|
|||||||
uint16_t _closeCode;
|
uint16_t _closeCode;
|
||||||
std::string _closeReason;
|
std::string _closeReason;
|
||||||
bool _closeRemote;
|
bool _closeRemote;
|
||||||
|
std::atomic<bool> _connectionError;
|
||||||
};
|
};
|
||||||
|
|
||||||
WebSocketClient::WebSocketClient(int port)
|
WebSocketClient::WebSocketClient(int port)
|
||||||
@ -49,9 +52,15 @@ namespace
|
|||||||
, _closeCode(0)
|
, _closeCode(0)
|
||||||
, _closeReason(std::string(""))
|
, _closeReason(std::string(""))
|
||||||
, _closeRemote(false)
|
, _closeRemote(false)
|
||||||
|
, _connectionError(false)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WebSocketClient::hasConnectionError() const
|
||||||
|
{
|
||||||
|
return _connectionError;
|
||||||
|
}
|
||||||
|
|
||||||
bool WebSocketClient::isReady() const
|
bool WebSocketClient::isReady() const
|
||||||
{
|
{
|
||||||
@ -133,6 +142,7 @@ namespace
|
|||||||
}
|
}
|
||||||
else if (msg->type == ix::WebSocketMessageType::Error)
|
else if (msg->type == ix::WebSocketMessageType::Error)
|
||||||
{
|
{
|
||||||
|
_connectionError = true;
|
||||||
ss << "Error ! " << msg->errorInfo.reason;
|
ss << "Error ! " << msg->errorInfo.reason;
|
||||||
log(ss.str());
|
log(ss.str());
|
||||||
}
|
}
|
||||||
@ -248,6 +258,7 @@ TEST_CASE("Websocket_client_close_default", "[close]")
|
|||||||
// Wait for all chat instance to be ready
|
// Wait for all chat instance to be ready
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
REQUIRE(!webSocketClient.hasConnectionError());
|
||||||
if (webSocketClient.isReady()) break;
|
if (webSocketClient.isReady()) break;
|
||||||
ix::msleep(10);
|
ix::msleep(10);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user