Revert D36052198: Partially remove dependency on folly async

Differential Revision:
D36052198 (ade685c621)

Original commit changeset: 170d64a324a1

Original Phabricator Diff: D36052198 (ade685c621)

fbshipit-source-id: 69d2b18e70a6267667432d6ed9dc1c5bc545b417
This commit is contained in:
Billy Ng
2022-05-12 18:47:41 -07:00
committed by Facebook GitHub Bot
parent ade685c621
commit 3804ccf898
18 changed files with 116 additions and 132 deletions

View File

@@ -6,11 +6,10 @@
*/
#include <Flipper/FlipperConnectionManagerImpl.h>
#include <Flipper/FlipperFollyScheduler.h>
#include <FlipperTestLib/ConnectionContextStoreMock.h>
#include <folly/Singleton.h>
#include <gtest/gtest.h>
#include <memory>
namespace facebook {
namespace flipper {
@@ -22,16 +21,12 @@ class FlipperConnectionManagerImplTerminationTest : public ::testing::Test {
protected:
std::shared_ptr<FlipperState> state;
std::shared_ptr<ConnectionContextStore> contextStore;
std::unique_ptr<Scheduler> sonarScheduler;
std::unique_ptr<Scheduler> connectionScheduler;
void SetUp() override {
// Folly singletons must be registered before they are used.
// Without this, test fails in phabricator.
folly::SingletonVault::singleton()->registrationComplete();
state = std::make_shared<FlipperState>();
contextStore = std::make_shared<ConnectionContextStoreMock>();
sonarScheduler = std::make_unique<FollyScheduler>(new EventBase());
connectionScheduler = std::make_unique<FollyScheduler>(new EventBase());
}
};
@@ -40,7 +35,7 @@ TEST_F(
testNullEventBaseGetsRejected) {
try {
auto instance = std::make_shared<FlipperConnectionManagerImpl>(
FlipperInitConfig{DeviceData{}, nullptr, connectionScheduler.get()},
FlipperInitConfig{DeviceData{}, nullptr, new EventBase()},
state,
contextStore);
FAIL();
@@ -49,7 +44,7 @@ TEST_F(
}
try {
auto instance = std::make_shared<FlipperConnectionManagerImpl>(
FlipperInitConfig{DeviceData{}, sonarScheduler.get(), nullptr},
FlipperInitConfig{DeviceData{}, new EventBase(), nullptr},
state,
contextStore);
FAIL();
@@ -61,8 +56,8 @@ TEST_F(
TEST_F(
FlipperConnectionManagerImplTerminationTest,
testNonStartedEventBaseDoesntHang) {
auto config = FlipperInitConfig{
DeviceData{}, sonarScheduler.get(), connectionScheduler.get()};
auto config =
FlipperInitConfig{DeviceData{}, new EventBase(), new EventBase()};
auto instance = std::make_shared<FlipperConnectionManagerImpl>(
config, state, contextStore);
instance->start();
@@ -77,11 +72,8 @@ TEST_F(
std::thread([flipperEventBase]() { flipperEventBase->loopForever(); });
auto connectionThread = std::thread(
[connectionEventBase]() { connectionEventBase->loopForever(); });
auto localSonarScheduler = std::make_unique<FollyScheduler>(flipperEventBase);
auto localConnectionScheduler =
std::make_unique<FollyScheduler>(connectionEventBase);
auto config = FlipperInitConfig{
DeviceData{}, localSonarScheduler.get(), localConnectionScheduler.get()};
auto config =
FlipperInitConfig{DeviceData{}, flipperEventBase, connectionEventBase};
auto instance = std::make_shared<FlipperConnectionManagerImpl>(
config, state, contextStore);