Index: ppapi/tests/test_websocket.cc |
diff --git a/ppapi/tests/test_websocket.cc b/ppapi/tests/test_websocket.cc |
index e61185df9cee55d5d9f879256970dcc2a8ee381d..61a8e199947111947aac12a0b446a4f61f0728b0 100644 |
--- a/ppapi/tests/test_websocket.cc |
+++ b/ppapi/tests/test_websocket.cc |
@@ -350,18 +350,18 @@ std::string TestWebSocket::TestUninitializedPropertiesAccess() { |
ASSERT_EQ(0U, close_code); |
PP_Var close_reason = websocket_interface_->GetCloseReason(ws); |
- ASSERT_TRUE(AreEqualWithString(close_reason, "")); |
+ ASSERT_TRUE(AreEqualWithString(close_reason, std::string())); |
ReleaseVar(close_reason); |
PP_Bool close_was_clean = websocket_interface_->GetCloseWasClean(ws); |
ASSERT_EQ(PP_FALSE, close_was_clean); |
PP_Var extensions = websocket_interface_->GetExtensions(ws); |
- ASSERT_TRUE(AreEqualWithString(extensions, "")); |
+ ASSERT_TRUE(AreEqualWithString(extensions, std::string())); |
ReleaseVar(extensions); |
PP_Var protocol = websocket_interface_->GetProtocol(ws); |
- ASSERT_TRUE(AreEqualWithString(protocol, "")); |
+ ASSERT_TRUE(AreEqualWithString(protocol, std::string())); |
ReleaseVar(protocol); |
PP_WebSocketReadyState ready_state = |
@@ -369,7 +369,7 @@ std::string TestWebSocket::TestUninitializedPropertiesAccess() { |
ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID, ready_state); |
PP_Var url = websocket_interface_->GetURL(ws); |
- ASSERT_TRUE(AreEqualWithString(url, "")); |
+ ASSERT_TRUE(AreEqualWithString(url, std::string())); |
ReleaseVar(url); |
core_interface_->ReleaseResource(ws); |
@@ -398,7 +398,7 @@ std::string TestWebSocket::TestInvalidConnect() { |
for (int i = 0; kInvalidURLs[i]; ++i) { |
int32_t result; |
- ws = Connect(kInvalidURLs[i], &result, ""); |
+ ws = Connect(kInvalidURLs[i], &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_ERROR_BADARGUMENT, result); |
@@ -448,7 +448,7 @@ std::string TestWebSocket::TestProtocols() { |
std::string TestWebSocket::TestGetURL() { |
for (int i = 0; kInvalidURLs[i]; ++i) { |
int32_t result; |
- PP_Resource ws = Connect(kInvalidURLs[i], &result, ""); |
+ PP_Resource ws = Connect(kInvalidURLs[i], &result, std::string()); |
ASSERT_TRUE(ws); |
PP_Var url = websocket_interface_->GetURL(ws); |
ASSERT_TRUE(AreEqualWithString(url, kInvalidURLs[i])); |
@@ -463,11 +463,11 @@ std::string TestWebSocket::TestGetURL() { |
std::string TestWebSocket::TestValidConnect() { |
int32_t result; |
- PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &result, ""); |
+ PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
PP_Var extensions = websocket_interface_->GetExtensions(ws); |
- ASSERT_TRUE(AreEqualWithString(extensions, "")); |
+ ASSERT_TRUE(AreEqualWithString(extensions, std::string())); |
core_interface_->ReleaseResource(ws); |
ReleaseVar(extensions); |
@@ -489,7 +489,7 @@ std::string TestWebSocket::TestInvalidClose() { |
// Close with bad arguments. |
int32_t result; |
- ws = Connect(GetFullURL(kEchoServerURL), &result, ""); |
+ ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
callback.WaitForResult(websocket_interface_->Close( |
@@ -498,7 +498,7 @@ std::string TestWebSocket::TestInvalidClose() { |
core_interface_->ReleaseResource(ws); |
// Close with PP_VARTYPE_NULL. |
- ws = Connect(GetFullURL(kEchoServerURL), &result, ""); |
+ ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
callback.WaitForResult(websocket_interface_->Close( |
@@ -508,7 +508,7 @@ std::string TestWebSocket::TestInvalidClose() { |
core_interface_->ReleaseResource(ws); |
// Close with PP_VARTYPE_NULL and ongoing receive message. |
- ws = Connect(GetFullURL(kEchoServerURL), &result, ""); |
+ ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
PP_Var receive_message_var; |
@@ -532,7 +532,7 @@ std::string TestWebSocket::TestInvalidClose() { |
core_interface_->ReleaseResource(ws); |
// Close twice. |
- ws = Connect(GetFullURL(kEchoServerURL), &result, ""); |
+ ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
result = websocket_interface_->Close( |
@@ -569,7 +569,7 @@ std::string TestWebSocket::TestValidClose() { |
// Close. |
int32_t result; |
- PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &result, ""); |
+ PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
callback.WaitForResult(websocket_interface_->Close( |
@@ -580,7 +580,7 @@ std::string TestWebSocket::TestValidClose() { |
core_interface_->ReleaseResource(ws); |
// Close without code and reason. |
- ws = Connect(GetFullURL(kEchoServerURL), &result, ""); |
+ ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
callback.WaitForResult(websocket_interface_->Close( |
@@ -590,7 +590,7 @@ std::string TestWebSocket::TestValidClose() { |
core_interface_->ReleaseResource(ws); |
// Close with PP_VARTYPE_UNDEFINED. |
- ws = Connect(GetFullURL(kEchoServerURL), &result, ""); |
+ ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
callback.WaitForResult(websocket_interface_->Close( |
@@ -620,7 +620,7 @@ std::string TestWebSocket::TestValidClose() { |
// Close in closing. |
// The first close will be done successfully, then the second one failed with |
// with PP_ERROR_INPROGRESS immediately. |
- ws = Connect(GetFullURL(kEchoServerURL), &result, ""); |
+ ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
result = websocket_interface_->Close( |
@@ -636,7 +636,7 @@ std::string TestWebSocket::TestValidClose() { |
core_interface_->ReleaseResource(ws); |
// Close with ongoing receive message. |
- ws = Connect(GetFullURL(kEchoServerURL), &result, ""); |
+ ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
PP_Var receive_message_var; |
@@ -655,7 +655,7 @@ std::string TestWebSocket::TestValidClose() { |
core_interface_->ReleaseResource(ws); |
// Close with PP_VARTYPE_UNDEFINED and ongoing receive message. |
- ws = Connect(GetFullURL(kEchoServerURL), &result, ""); |
+ ws = Connect(GetFullURL(kEchoServerURL), &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
result = websocket_interface_->ReceiveMessage( |
@@ -673,7 +673,8 @@ std::string TestWebSocket::TestValidClose() { |
core_interface_->ReleaseResource(ws); |
// Server initiated closing handshake. |
- ws = Connect(GetFullURL(kCloseWithCodeAndReasonServerURL), &result, ""); |
+ ws = Connect( |
+ GetFullURL(kCloseWithCodeAndReasonServerURL), &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
// Text messsage "1000 bye" requests the server to initiate closing handshake |
@@ -720,7 +721,8 @@ std::string TestWebSocket::TestGetProtocol() { |
std::string TestWebSocket::TestTextSendReceive() { |
// Connect to test echo server. |
int32_t connect_result; |
- PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &connect_result, ""); |
+ PP_Resource ws = |
+ Connect(GetFullURL(kEchoServerURL), &connect_result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, connect_result); |
@@ -747,7 +749,8 @@ std::string TestWebSocket::TestTextSendReceive() { |
std::string TestWebSocket::TestBinarySendReceive() { |
// Connect to test echo server. |
int32_t connect_result; |
- PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &connect_result, ""); |
+ PP_Resource ws = |
+ Connect(GetFullURL(kEchoServerURL), &connect_result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, connect_result); |
@@ -776,7 +779,8 @@ std::string TestWebSocket::TestBinarySendReceive() { |
std::string TestWebSocket::TestStressedSendReceive() { |
// Connect to test echo server. |
int32_t connect_result; |
- PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &connect_result, ""); |
+ PP_Resource ws = |
+ Connect(GetFullURL(kEchoServerURL), &connect_result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, connect_result); |
@@ -836,7 +840,8 @@ std::string TestWebSocket::TestStressedSendReceive() { |
std::string TestWebSocket::TestBufferedAmount() { |
// Connect to test echo server. |
int32_t connect_result; |
- PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &connect_result, ""); |
+ PP_Resource ws = |
+ Connect(GetFullURL(kEchoServerURL), &connect_result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, connect_result); |
@@ -876,7 +881,7 @@ std::string TestWebSocket::TestBufferedAmount() { |
// After connection closure, all sending requests fail and just increase |
// the bufferedAmount property. |
- PP_Var empty_string = CreateVarString(""); |
+ PP_Var empty_string = CreateVarString(std::string()); |
result = websocket_interface_->SendMessage(ws, empty_string); |
ASSERT_EQ(PP_ERROR_FAILED, result); |
buffered_amount = websocket_interface_->GetBufferedAmount(ws); |
@@ -919,7 +924,7 @@ std::string TestWebSocket::TestAbortCallsWithCallback() { |
ASSERT_EQ(PP_ERROR_ABORTED, connect_callback.result()); |
// Test the behavior for Close(). |
- ws = Connect(url, &result, ""); |
+ ws = Connect(url, &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
PP_Var reason_var = CreateVarString("abort"); |
@@ -936,7 +941,7 @@ std::string TestWebSocket::TestAbortCallsWithCallback() { |
// Test the behavior for ReceiveMessage(). |
// Make sure the simplest case to wait for data which never arrives, here. |
- ws = Connect(url, &result, ""); |
+ ws = Connect(url, &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
PP_Var receive_var; |
@@ -952,7 +957,7 @@ std::string TestWebSocket::TestAbortCallsWithCallback() { |
// Release the resource in the aborting receive completion callback which is |
// introduced by calling Close(). |
- ws = Connect(url, &result, ""); |
+ ws = Connect(url, &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
result = websocket_interface_->ReceiveMessage( |
@@ -986,7 +991,7 @@ std::string TestWebSocket::TestAbortSendMessageCall() { |
int32_t result; |
std::string url = GetFullURL(kEchoServerURL); |
- PP_Resource ws = Connect(url, &result, ""); |
+ PP_Resource ws = Connect(url, &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
result = websocket_interface_->SendMessage(ws, large_var); |
@@ -1001,7 +1006,7 @@ std::string TestWebSocket::TestAbortCloseCall() { |
// Release the resource in the close completion callback. |
int32_t result; |
std::string url = GetFullURL(kEchoServerURL); |
- PP_Resource ws = Connect(url, &result, ""); |
+ PP_Resource ws = Connect(url, &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
TestCompletionCallback close_callback( |
@@ -1034,7 +1039,7 @@ std::string TestWebSocket::TestAbortReceiveMessageCall() { |
// released while the next message is going to be received. |
const int trial_count = 8; |
for (int trial = 1; trial <= trial_count; trial++) { |
- ws = Connect(url, &result, ""); |
+ ws = Connect(url, &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
for (int i = 0; i <= trial_count; ++i) { |
@@ -1060,7 +1065,7 @@ std::string TestWebSocket::TestAbortReceiveMessageCall() { |
} |
// Same test, but the last receiving message is large message over 64KiB. |
for (int trial = 1; trial <= trial_count; trial++) { |
- ws = Connect(url, &result, ""); |
+ ws = Connect(url, &result, std::string()); |
ASSERT_TRUE(ws); |
ASSERT_EQ(PP_OK, result); |
for (int i = 0; i <= trial_count; ++i) { |
@@ -1102,12 +1107,12 @@ std::string TestWebSocket::TestCcInterfaces() { |
// Check uninitialized properties access. |
ASSERT_EQ(0, ws.GetBufferedAmount()); |
ASSERT_EQ(0, ws.GetCloseCode()); |
- ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), "")); |
+ ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), std::string())); |
ASSERT_EQ(false, ws.GetCloseWasClean()); |
- ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); |
- ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); |
+ ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), std::string())); |
+ ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), std::string())); |
ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID, ws.GetReadyState()); |
- ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), "")); |
+ ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), std::string())); |
// Check communication interfaces (connect, send, receive, and close). |
TestCompletionCallback connect_callback( |
@@ -1163,7 +1168,7 @@ std::string TestWebSocket::TestCcInterfaces() { |
ASSERT_TRUE( |
AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str())); |
ASSERT_EQ(true, ws.GetCloseWasClean()); |
- ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); |
+ ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), std::string())); |
ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED, ws.GetReadyState()); |
ASSERT_TRUE(AreEqualWithString( |
ws.GetURL().pp_var(), GetFullURL(kCloseServerURL).c_str())); |
@@ -1268,7 +1273,8 @@ std::string TestWebSocket::TestUtilityValidConnect() { |
const std::vector<WebSocketEvent>& events = websocket.GetSeenEvents(); |
ASSERT_EQ(1U, events.size()); |
ASSERT_EQ(WebSocketEvent::EVENT_OPEN, events[0].event_type); |
- ASSERT_TRUE(AreEqualWithString(websocket.GetExtensions().pp_var(), "")); |
+ ASSERT_TRUE( |
+ AreEqualWithString(websocket.GetExtensions().pp_var(), std::string())); |
PASS(); |
} |
@@ -1496,7 +1502,7 @@ std::string TestWebSocket::TestUtilityBufferedAmount() { |
// After connection closure, all sending requests fail and just increase |
// the bufferedAmount property. |
- result = websocket.Send(pp::Var(std::string(""))); |
+ result = websocket.Send(pp::Var(std::string())); |
ASSERT_EQ(PP_ERROR_FAILED, result); |
buffered_amount = websocket.GetBufferedAmount(); |
ASSERT_EQ(base_buffered_amount + kMessageFrameOverhead, buffered_amount); |