1616#include < jsinspector-modern/InspectorInterfaces.h>
1717#include < jsinspector-modern/InspectorPackagerConnection.h>
1818
19+ #include < format>
1920#include < memory>
2021
2122#include " FollyDynamicMatchers.h"
2526using namespace ::testing;
2627using namespace std ::literals::chrono_literals;
2728using namespace std ::literals::string_literals;
28- using folly::dynamic, folly::toJson, folly::sformat ;
29+ using folly::dynamic, folly::toJson;
2930
3031namespace facebook ::react::jsinspector_modern {
3132
@@ -281,7 +282,7 @@ TEST_F(InspectorPackagerConnectionTest, TestSendReceiveEvents) {
281282 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
282283
283284 // Connect to the page.
284- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
285+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
285286 R"( {{
286287 "event": "connect",
287288 "payload": {{
@@ -321,7 +322,7 @@ TEST_F(InspectorPackagerConnectionTest, TestSendReceiveEvents) {
321322 AtJsonPtr (" /params" , ElementsAre (" arg1" , " arg2" ))))))
322323 .RetiresOnSaturation ();
323324
324- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
325+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
325326 R"( {{
326327 "event": "wrappedEvent",
327328 "payload": {{
@@ -373,7 +374,7 @@ TEST_F(InspectorPackagerConnectionTest, TestSendReceiveEventsToMultiplePages) {
373374
374375 for (int i = 0 ; i < kNumPages ; ++i) {
375376 // Connect to the i-th page.
376- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
377+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
377378 R"( {{
378379 "event": "connect",
379380 "payload": {{
@@ -415,7 +416,7 @@ TEST_F(InspectorPackagerConnectionTest, TestSendReceiveEventsToMultiplePages) {
415416 *localConnections_[i],
416417 sendMessage (JsonParsed (AtJsonPtr (" /method" , Eq (method)))))
417418 .RetiresOnSaturation ();
418- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
419+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
419420 R"( {{
420421 "event": "wrappedEvent",
421422 "payload": {{
@@ -445,7 +446,7 @@ TEST_F(InspectorPackagerConnectionTest, TestSendEventToAllConnections) {
445446 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
446447
447448 // Connect to the page.
448- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
449+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
449450 R"( {{
450451 "event": "connect",
451452 "payload": {{
@@ -486,7 +487,7 @@ TEST_F(InspectorPackagerConnectionTest, TestConnectThenDisconnect) {
486487 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
487488
488489 // Connect to the page.
489- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
490+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
490491 R"( {{
491492 "event": "connect",
492493 "payload": {{
@@ -498,7 +499,7 @@ TEST_F(InspectorPackagerConnectionTest, TestConnectThenDisconnect) {
498499
499500 // Disconnect from the page.
500501 EXPECT_CALL (*localConnections_[0 ], disconnect ()).RetiresOnSaturation ();
501- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
502+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
502503 R"( {{
503504 "event": "disconnect",
504505 "payload": {{
@@ -521,7 +522,7 @@ TEST_F(InspectorPackagerConnectionTest, TestConnectThenCloseSocket) {
521522 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
522523
523524 // Connect to the page.
524- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
525+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
525526 R"( {{
526527 "event": "connect",
527528 "payload": {{
@@ -549,7 +550,7 @@ TEST_F(InspectorPackagerConnectionTest, TestConnectThenSocketFailure) {
549550 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
550551
551552 // Connect to the page.
552- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
553+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
553554 R"( {{
554555 "event": "connect",
555556 "payload": {{
@@ -579,7 +580,7 @@ TEST_F(
579580 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
580581
581582 // Connect to the page.
582- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
583+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
583584 R"( {{
584585 "event": "connect",
585586 "payload": {{
@@ -625,7 +626,7 @@ TEST_F(
625626 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
626627
627628 // Connect to the page.
628- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
629+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
629630 R"( {{
630631 "event": "connect",
631632 "payload": {{
@@ -637,7 +638,7 @@ TEST_F(
637638
638639 // Try connecting to the same page again. This results in a disconnection.
639640 EXPECT_CALL (*localConnections_[0 ], disconnect ()).RetiresOnSaturation ();
640- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
641+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
641642 R"( {{
642643 "event": "connect",
643644 "payload": {{
@@ -660,7 +661,7 @@ TEST_F(InspectorPackagerConnectionTest, TestMultipleDisconnect) {
660661 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
661662
662663 // Connect to the page.
663- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
664+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
664665 R"( {{
665666 "event": "connect",
666667 "payload": {{
@@ -672,7 +673,7 @@ TEST_F(InspectorPackagerConnectionTest, TestMultipleDisconnect) {
672673
673674 // Disconnect from the page.
674675 EXPECT_CALL (*localConnections_[0 ], disconnect ()).RetiresOnSaturation ();
675- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
676+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
676677 R"( {{
677678 "event": "disconnect",
678679 "payload": {{
@@ -683,7 +684,7 @@ TEST_F(InspectorPackagerConnectionTest, TestMultipleDisconnect) {
683684 EXPECT_FALSE (localConnections_[0 ]);
684685
685686 // Disconnect again. This is a noop.
686- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
687+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
687688 R"( {{
688689 "event": "disconnect",
689690 "payload": {{
@@ -706,7 +707,7 @@ TEST_F(InspectorPackagerConnectionTest, TestDisconnectThenSendEvent) {
706707 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
707708
708709 // Connect to the page.
709- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
710+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
710711 R"( {{
711712 "event": "connect",
712713 "payload": {{
@@ -718,7 +719,7 @@ TEST_F(InspectorPackagerConnectionTest, TestDisconnectThenSendEvent) {
718719
719720 // Disconnect from the page.
720721 EXPECT_CALL (*localConnections_[0 ], disconnect ()).RetiresOnSaturation ();
721- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
722+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
722723 R"( {{
723724 "event": "disconnect",
724725 "payload": {{
@@ -730,7 +731,7 @@ TEST_F(InspectorPackagerConnectionTest, TestDisconnectThenSendEvent) {
730731
731732 // Send an event from the frontend (remote) to the backend (local). This
732733 // is a noop.
733- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
734+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
734735 R"( {{
735736 "event": "wrappedEvent",
736737 "payload": {{
@@ -754,7 +755,7 @@ TEST_F(InspectorPackagerConnectionTest, TestSendEventToUnknownPage) {
754755
755756 // Send an event from the frontend (remote) to the backend (local). This
756757 // is a noop (except for logging).
757- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
758+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
758759 R"( {{
759760 "event": "wrappedEvent",
760761 "payload": {{
@@ -921,7 +922,7 @@ TEST_F(
921922 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
922923
923924 // Connect to the page.
924- retainedWebSocketDelegate->didReceiveMessage (sformat (
925+ retainedWebSocketDelegate->didReceiveMessage (std::format (
925926 R"( {{
926927 "event": "connect",
927928 "payload": {{
@@ -941,7 +942,7 @@ TEST_F(
941942 AtJsonPtr (" /params" , ElementsAre (" arg1" , " arg2" ))))))
942943 .RetiresOnSaturation ();
943944
944- retainedWebSocketDelegate->didReceiveMessage (sformat (
945+ retainedWebSocketDelegate->didReceiveMessage (std::format (
945946 R"( {{
946947 "event": "wrappedEvent",
947948 "payload": {{
@@ -975,7 +976,7 @@ TEST_F(InspectorPackagerConnectionTest, TestDestroyConnectionOnPageRemoved) {
975976 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
976977
977978 // Connect to the page.
978- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
979+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
979980 R"( {{
980981 "event": "connect",
981982 "payload": {{
@@ -1005,7 +1006,7 @@ TEST_F(
10051006 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
10061007
10071008 // Connect to the page.
1008- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
1009+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
10091010 R"( {{
10101011 "event": "connect",
10111012 "payload": {{
@@ -1045,7 +1046,7 @@ TEST_F(
10451046 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
10461047
10471048 // Connect to the page.
1048- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
1049+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
10491050 R"( {{
10501051 "event": "connect",
10511052 "payload": {{
@@ -1064,7 +1065,7 @@ TEST_F(
10641065
10651066 // Disconnect from the page.
10661067 EXPECT_CALL (*localConnections_[0 ], disconnect ()).RetiresOnSaturation ();
1067- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
1068+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
10681069 R"( {{
10691070 "event": "disconnect",
10701071 "payload": {{
@@ -1075,7 +1076,7 @@ TEST_F(
10751076 EXPECT_FALSE (localConnections_[0 ]);
10761077
10771078 // Connect to the same page again.
1078- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
1079+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
10791080 R"( {{
10801081 "event": "connect",
10811082 "payload": {{
@@ -1127,7 +1128,7 @@ TEST_F(
11271128 .lazily_make_unique <std::unique_ptr<IRemoteConnection>>());
11281129
11291130 // Connect to the page.
1130- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
1131+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
11311132 R"( {{
11321133 "event": "connect",
11331134 "payload": {{
@@ -1151,7 +1152,7 @@ TEST_F(
11511152
11521153 // Disconnect from the page.
11531154 EXPECT_CALL (*localConnections_[0 ], disconnect ()).RetiresOnSaturation ();
1154- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
1155+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
11551156 R"( {{
11561157 "event": "disconnect",
11571158 "payload": {{
@@ -1162,7 +1163,7 @@ TEST_F(
11621163 EXPECT_FALSE (localConnections_[0 ]);
11631164
11641165 // Connect to the same page again.
1165- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
1166+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
11661167 R"( {{
11671168 "event": "connect",
11681169 "payload": {{
@@ -1256,7 +1257,7 @@ TEST_F(InspectorPackagerConnectionTest, TestRejectedPageConnection) {
12561257 AtJsonPtr (" /payload/pageId" , Eq (std::to_string (pageId)))))))
12571258 .RetiresOnSaturation ();
12581259
1259- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
1260+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
12601261 R"( {{
12611262 "event": "connect",
12621263 "payload": {{
@@ -1265,7 +1266,7 @@ TEST_F(InspectorPackagerConnectionTest, TestRejectedPageConnection) {
12651266 }})" ,
12661267 toJson (std::to_string (pageId))));
12671268
1268- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
1269+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
12691270 R"( {{
12701271 "event": "wrappedEvent",
12711272 "payload": {{
@@ -1291,7 +1292,7 @@ TEST_F(InspectorPackagerConnectionTest, TestRejectedPageConnection) {
12911292 AtJsonPtr (" /payload/pageId" , Eq (std::to_string (pageId)))))))
12921293 .RetiresOnSaturation ();
12931294
1294- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
1295+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
12951296 R"( {{
12961297 "event": "connect",
12971298 "payload": {{
@@ -1300,7 +1301,7 @@ TEST_F(InspectorPackagerConnectionTest, TestRejectedPageConnection) {
13001301 }})" ,
13011302 toJson (std::to_string (pageId))));
13021303
1303- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
1304+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
13041305 R"( {{
13051306 "event": "wrappedEvent",
13061307 "payload": {{
@@ -1319,7 +1320,7 @@ TEST_F(InspectorPackagerConnectionTest, TestRejectedPageConnection) {
13191320 // page.
13201321 mockNextConnectionBehavior = Accept;
13211322
1322- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
1323+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
13231324 R"( {{
13241325 "event": "connect",
13251326 "payload": {{
@@ -1336,7 +1337,7 @@ TEST_F(InspectorPackagerConnectionTest, TestRejectedPageConnection) {
13361337 AtJsonPtr (" /params" , ElementsAre (" arg1" , " arg2" ))))))
13371338 .RetiresOnSaturation ();
13381339
1339- webSockets_[0 ]->getDelegate ().didReceiveMessage (sformat (
1340+ webSockets_[0 ]->getDelegate ().didReceiveMessage (std::format (
13401341 R"( {{
13411342 "event": "wrappedEvent",
13421343 "payload": {{
0 commit comments