Skip to content

Commit 046f664

Browse files
motiz88facebook-github-bot
authored andcommitted
Port Hermes integration tests to TYPED_TEST
Summary: Changelog: [Internal] Ports RN's Hermes CDP integration tests to `TYPED_TEST` so we can easily run them against a different Hermes engine adapter in another diff. bypass-github-export-checks Reviewed By: huntie Differential Revision: D53810359 fbshipit-source-id: fb9717bbdc1346ed26b9c8796c13bac641bc5a60
1 parent 1863805 commit 046f664

1 file changed

Lines changed: 38 additions & 35 deletions

File tree

packages/react-native/ReactCommon/jsinspector-modern/tests/JsiIntegrationTest.cpp

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,8 @@ class JsiIntegrationPortableTest : public Test, private PageTargetDelegate {
158158
////////////////////////////////////////////////////////////////////////////////
159159

160160
// Some tests are specific to Hermes's CDP capabilities and some are not.
161-
// We'll use JsiIntegrationHermesTest as a fixture for Hermes-specific tests
162-
// and typed tests for the engine-agnostic ones.
163-
164-
using JsiIntegrationHermesTest =
165-
JsiIntegrationPortableTest<JsiIntegrationTestHermesEngineAdapter>;
161+
// We'll use JsiIntegrationHermesTest as an alias for Hermes-specific tests
162+
// and JsiIntegrationPortableTest for the engine-agnostic ones.
166163

167164
/**
168165
* The list of engine adapters for which engine-agnostic tests should pass.
@@ -171,8 +168,14 @@ using AllEngines = Types<
171168
JsiIntegrationTestHermesEngineAdapter,
172169
JsiIntegrationTestGenericEngineAdapter>;
173170

171+
using AllHermesVariants = Types<JsiIntegrationTestHermesEngineAdapter>;
172+
174173
TYPED_TEST_SUITE(JsiIntegrationPortableTest, AllEngines);
175174

175+
template <typename EngineAdapter>
176+
using JsiIntegrationHermesTest = JsiIntegrationPortableTest<EngineAdapter>;
177+
TYPED_TEST_SUITE(JsiIntegrationHermesTest, AllHermesVariants);
178+
176179
////////////////////////////////////////////////////////////////////////////////
177180

178181
TYPED_TEST(JsiIntegrationPortableTest, ConnectWithoutCrashing) {
@@ -453,27 +456,27 @@ TYPED_TEST(JsiIntegrationPortableTest, ExceptionDuringAddBindingIsIgnored) {
453456

454457
////////////////////////////////////////////////////////////////////////////////
455458

456-
TEST_F(JsiIntegrationHermesTest, EvaluateExpression) {
457-
connect();
458-
459-
expectMessageFromPage(JsonEq(R"({
460-
"id": 1,
461-
"result": {
462-
"result": {
463-
"type": "number",
464-
"value": 42
465-
}
466-
}
467-
})"));
468-
toPage_->sendMessage(R"({
469-
"id": 1,
470-
"method": "Runtime.evaluate",
471-
"params": {"expression": "42"}
472-
})");
459+
TYPED_TEST(JsiIntegrationHermesTest, EvaluateExpression) {
460+
this->connect();
461+
462+
this->expectMessageFromPage(JsonEq(R"({
463+
"id": 1,
464+
"result": {
465+
"result": {
466+
"type": "number",
467+
"value": 42
468+
}
469+
}
470+
})"));
471+
this->toPage_->sendMessage(R"({
472+
"id": 1,
473+
"method": "Runtime.evaluate",
474+
"params": {"expression": "42"}
475+
})");
473476
}
474477

475-
TEST_F(JsiIntegrationHermesTest, EvaluateExpressionInExecutionContext) {
476-
connect();
478+
TYPED_TEST(JsiIntegrationHermesTest, EvaluateExpressionInExecutionContext) {
479+
this->connect();
477480

478481
InSequence s;
479482

@@ -490,16 +493,16 @@ TEST_F(JsiIntegrationHermesTest, EvaluateExpressionInExecutionContext) {
490493
auto executionContextId =
491494
executionContextInfo->value()["params"]["context"]["id"].getInt();
492495

493-
expectMessageFromPage(JsonEq(R"({
494-
"id": 1,
495-
"result": {
496-
"result": {
497-
"type": "number",
498-
"value": 42
499-
}
500-
}
501-
})"));
502-
toPage_->sendMessage(sformat(
496+
this->expectMessageFromPage(JsonEq(R"({
497+
"id": 1,
498+
"result": {
499+
"result": {
500+
"type": "number",
501+
"value": 42
502+
}
503+
}
504+
})"));
505+
this->toPage_->sendMessage(sformat(
503506
R"({{
504507
"id": 1,
505508
"method": "Runtime.evaluate",
@@ -521,7 +524,7 @@ TEST_F(JsiIntegrationHermesTest, EvaluateExpressionInExecutionContext) {
521524
// Now the old execution context is stale.
522525
this->expectMessageFromPage(
523526
JsonParsed(AllOf(AtJsonPtr("/id", 3), AtJsonPtr("/error/code", -32000))));
524-
toPage_->sendMessage(sformat(
527+
this->toPage_->sendMessage(sformat(
525528
R"({{
526529
"id": 3,
527530
"method": "Runtime.evaluate",

0 commit comments

Comments
 (0)