/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include "InspectorMocks.h" #include "ReactNativeMocks.h" #include "UniquePtrFactory.h" #include "utils/InspectorFlagOverridesGuard.h" #include #include #include #include #include #include namespace facebook::react::jsinspector_modern { using namespace ::testing; struct FeatureFlags { const bool fuseboxEnabledDebug = true; }; class ReactInstanceIntegrationTest : public Test { protected: ReactInstanceIntegrationTest(); void SetUp() override; void TearDown() override; jsi::Value run(const std::string& script); bool verbose(bool isVerbose); void send( const std::string& method, const folly::dynamic& params = folly::dynamic::object()); void sendJSONString(const std::string& message); jsi::Runtime* runtime; std::unique_ptr instance; std::shared_ptr messageQueueThread; std::shared_ptr errorHandler; MockRemoteConnection& getRemoteConnection() { EXPECT_EQ(mockRemoteConnections_.objectsVended(), 1); auto rawPtr = mockRemoteConnections_[0]; assert(rawPtr); return *rawPtr; } private: void initializeRuntime(std::string_view script); size_t id_ = 1; bool verbose_ = false; std::optional pageId_; UniquePtrFactory mockRemoteConnections_; std::unique_ptr clientToVM_; folly::QueuedImmediateExecutor immediateExecutor_; }; class ReactInstanceIntegrationTestWithFlags : public ReactInstanceIntegrationTest, public ::testing::WithParamInterface { protected: ReactInstanceIntegrationTestWithFlags() : inspectorFlagsGuard_(GetParam()) {} private: InspectorFlagOverridesGuard inspectorFlagsGuard_; }; } // namespace facebook::react::jsinspector_modern