@@ -35,6 +35,8 @@ static std::string last_path; // NOLINT(runtime/string)
35
35
static void (*handshake_delegate)(enum inspector_handshake_event state,
36
36
const std::string& path,
37
37
bool * should_continue);
38
+ static const char SERVER_CLOSE_FRAME[] = {' \x88 ' , ' \x00 ' };
39
+
38
40
39
41
struct read_expects {
40
42
const char * expected;
@@ -879,7 +881,6 @@ TEST_F(InspectorSocketTest, Send1Mb) {
879
881
// 3. Close
880
882
const char CLIENT_CLOSE_FRAME[] = {' \x88 ' , ' \x80 ' , ' \x2D ' ,
881
883
' \x0E ' , ' \x1E ' , ' \xFA ' };
882
- const char SERVER_CLOSE_FRAME[] = {' \x88 ' , ' \x00 ' };
883
884
do_write (CLIENT_CLOSE_FRAME, sizeof (CLIENT_CLOSE_FRAME));
884
885
expect_on_client (SERVER_CLOSE_FRAME, sizeof (SERVER_CLOSE_FRAME));
885
886
GTEST_ASSERT_EQ (0 , uv_is_active (
@@ -906,4 +907,33 @@ TEST_F(InspectorSocketTest, ErrorCleansUpTheSocket) {
906
907
EXPECT_EQ (UV_EPROTO, err);
907
908
}
908
909
910
+ static void ServerClosedByClient_cb (InspectorSocket* socket, int code) {
911
+ *static_cast <bool *>(socket->data ) = true ;
912
+ }
913
+
914
+ TEST_F (InspectorSocketTest, NoCloseResponseFromClinet) {
915
+ ASSERT_TRUE (connected);
916
+ ASSERT_FALSE (inspector_ready);
917
+ do_write (const_cast <char *>(HANDSHAKE_REQ), sizeof (HANDSHAKE_REQ) - 1 );
918
+ SPIN_WHILE (!inspector_ready);
919
+ expect_handshake ();
920
+
921
+ // 2. Brief exchange
922
+ const char SERVER_MESSAGE[] = " abcd" ;
923
+ const char CLIENT_FRAME[] = {' \x81 ' , ' \x04 ' , ' a' , ' b' , ' c' , ' d' };
924
+ inspector_write (&inspector, SERVER_MESSAGE, sizeof (SERVER_MESSAGE) - 1 );
925
+ expect_on_client (CLIENT_FRAME, sizeof (CLIENT_FRAME));
926
+
927
+ bool closed = false ;
928
+
929
+ inspector.data = &closed;
930
+ inspector_close (&inspector, ServerClosedByClient_cb);
931
+ expect_on_client (SERVER_CLOSE_FRAME, sizeof (SERVER_CLOSE_FRAME));
932
+ uv_close (reinterpret_cast <uv_handle_t *>(&client_socket), nullptr );
933
+ SPIN_WHILE (!closed);
934
+ inspector.data = nullptr ;
935
+ GTEST_ASSERT_EQ (0 , uv_is_active (
936
+ reinterpret_cast <uv_handle_t *>(&client_socket)));
937
+ }
938
+
909
939
} // anonymous namespace
0 commit comments