Apply clang-format
Differential Revision: D19843069 fbshipit-source-id: af3f3998e2259ca5070b43ffb19933cf9304319d
This commit is contained in:
committed by
Facebook Github Bot
parent
71928fdf08
commit
c315691b2d
@@ -8,10 +8,10 @@
|
||||
#include "CertificateUtils.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <folly/portability/Fcntl.h>
|
||||
#include <folly/portability/SysStat.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <folly/portability/SysStat.h>
|
||||
#include <folly/portability/Fcntl.h>
|
||||
#include <cstring>
|
||||
|
||||
void free(
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <folly/io/async/SSLContext.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <folly/io/async/SSLContext.h>
|
||||
#include <string>
|
||||
#include "FlipperInitConfig.h"
|
||||
|
||||
using namespace folly;
|
||||
@@ -18,8 +18,7 @@ namespace facebook {
|
||||
namespace flipper {
|
||||
|
||||
class ConnectionContextStore {
|
||||
|
||||
public:
|
||||
public:
|
||||
ConnectionContextStore(DeviceData deviceData);
|
||||
bool hasRequiredFiles();
|
||||
std::string getCertificateSigningRequest();
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FlipperResponder.h"
|
||||
#include <folly/json.h>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include "FlipperResponder.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace flipper {
|
||||
|
||||
@@ -18,7 +18,9 @@ namespace flipper {
|
||||
|
||||
class FlipperConnectionImpl : public FlipperConnection {
|
||||
public:
|
||||
FlipperConnectionImpl(FlipperConnectionManager* socket, const std::string& name)
|
||||
FlipperConnectionImpl(
|
||||
FlipperConnectionManager* socket,
|
||||
const std::string& name)
|
||||
: socket_(socket), name_(name) {}
|
||||
|
||||
void call(
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FlipperConnection.h"
|
||||
#include <string>
|
||||
#include "FlipperConnection.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace flipper {
|
||||
@@ -38,7 +38,8 @@ class FlipperPlugin {
|
||||
virtual void didDisconnect() = 0;
|
||||
|
||||
/**
|
||||
Returns true if the plugin is meant to be run in background too, otherwise it returns false.
|
||||
Returns true if the plugin is meant to be run in background too, otherwise it
|
||||
returns false.
|
||||
*/
|
||||
virtual bool runInBackground() {
|
||||
return false;
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
namespace facebook {
|
||||
namespace flipper {
|
||||
|
||||
void log(const std::string& message) {
|
||||
#ifdef __ANDROID__
|
||||
__android_log_print(ANDROID_LOG_INFO, "flipper", "flipper: %s", message.c_str());
|
||||
#else
|
||||
printf("flipper: %s\n", message.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
void log(const std::string& message) {
|
||||
#ifdef __ANDROID__
|
||||
__android_log_print(
|
||||
ANDROID_LOG_INFO, "flipper", "flipper: %s", message.c_str());
|
||||
#else
|
||||
printf("flipper: %s\n", message.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace flipper
|
||||
} // namespace facebook
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace facebook {
|
||||
namespace flipper {
|
||||
|
||||
void log(const std::string& message);
|
||||
void log(const std::string& message);
|
||||
|
||||
} // namespace flipper
|
||||
} // namespace facebook
|
||||
|
||||
@@ -11,25 +11,26 @@ namespace facebook {
|
||||
namespace flipper {
|
||||
namespace test {
|
||||
|
||||
class ConnectionContextStoreMock : public ConnectionContextStore {
|
||||
public:
|
||||
ConnectionContextStoreMock() : ConnectionContextStore(DeviceData()) {
|
||||
}
|
||||
bool hasRequiredFiles() {
|
||||
return true;
|
||||
}
|
||||
std::string createCertificateSigningRequest() {
|
||||
return "thisIsACsr";
|
||||
}
|
||||
std::shared_ptr<SSLContext> getSSLContext() {
|
||||
return nullptr;
|
||||
}
|
||||
dynamic getConnectionConfig() {
|
||||
return nullptr;
|
||||
}
|
||||
std::string getCertificateDirectoryPath() {
|
||||
return "/something/sonar/";
|
||||
}
|
||||
};
|
||||
class ConnectionContextStoreMock : public ConnectionContextStore {
|
||||
public:
|
||||
ConnectionContextStoreMock() : ConnectionContextStore(DeviceData()) {}
|
||||
bool hasRequiredFiles() {
|
||||
return true;
|
||||
}
|
||||
std::string createCertificateSigningRequest() {
|
||||
return "thisIsACsr";
|
||||
}
|
||||
std::shared_ptr<SSLContext> getSSLContext() {
|
||||
return nullptr;
|
||||
}
|
||||
dynamic getConnectionConfig() {
|
||||
return nullptr;
|
||||
}
|
||||
std::string getCertificateDirectoryPath() {
|
||||
return "/something/sonar/";
|
||||
}
|
||||
};
|
||||
|
||||
}}}
|
||||
} // namespace test
|
||||
} // namespace flipper
|
||||
} // namespace facebook
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace test {
|
||||
using folly::EventBase;
|
||||
|
||||
class FlipperConnectionManagerImplTerminationTest : public ::testing::Test {
|
||||
protected:
|
||||
protected:
|
||||
std::shared_ptr<FlipperState> state;
|
||||
std::shared_ptr<ConnectionContextStore> contextStore;
|
||||
void SetUp() override {
|
||||
@@ -30,60 +30,52 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(FlipperConnectionManagerImplTerminationTest, testNullEventBaseGetsRejected) {
|
||||
TEST_F(
|
||||
FlipperConnectionManagerImplTerminationTest,
|
||||
testNullEventBaseGetsRejected) {
|
||||
try {
|
||||
auto instance = std::make_shared<FlipperConnectionManagerImpl>(FlipperInitConfig {
|
||||
DeviceData {},
|
||||
nullptr,
|
||||
new EventBase()
|
||||
},
|
||||
state,
|
||||
contextStore
|
||||
);
|
||||
auto instance = std::make_shared<FlipperConnectionManagerImpl>(
|
||||
FlipperInitConfig{DeviceData{}, nullptr, new EventBase()},
|
||||
state,
|
||||
contextStore);
|
||||
FAIL();
|
||||
} catch (std::invalid_argument& e) {
|
||||
// Pass test
|
||||
}
|
||||
try {
|
||||
auto instance = std::make_shared<FlipperConnectionManagerImpl>(FlipperInitConfig {
|
||||
DeviceData {},
|
||||
new EventBase(),
|
||||
nullptr
|
||||
},
|
||||
state,
|
||||
contextStore
|
||||
);
|
||||
auto instance = std::make_shared<FlipperConnectionManagerImpl>(
|
||||
FlipperInitConfig{DeviceData{}, new EventBase(), nullptr},
|
||||
state,
|
||||
contextStore);
|
||||
FAIL();
|
||||
} catch (std::invalid_argument& e) {
|
||||
// Pass test
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(FlipperConnectionManagerImplTerminationTest, testNonStartedEventBaseDoesntHang) {
|
||||
auto config = FlipperInitConfig {
|
||||
DeviceData {},
|
||||
new EventBase(),
|
||||
new EventBase()
|
||||
};
|
||||
auto instance = std::make_shared<FlipperConnectionManagerImpl>(config, state, contextStore);
|
||||
TEST_F(
|
||||
FlipperConnectionManagerImplTerminationTest,
|
||||
testNonStartedEventBaseDoesntHang) {
|
||||
auto config =
|
||||
FlipperInitConfig{DeviceData{}, new EventBase(), new EventBase()};
|
||||
auto instance = std::make_shared<FlipperConnectionManagerImpl>(
|
||||
config, state, contextStore);
|
||||
instance->start();
|
||||
}
|
||||
|
||||
TEST_F(FlipperConnectionManagerImplTerminationTest, testStartedEventBaseDoesntHang) {
|
||||
TEST_F(
|
||||
FlipperConnectionManagerImplTerminationTest,
|
||||
testStartedEventBaseDoesntHang) {
|
||||
auto flipperEventBase = new EventBase();
|
||||
auto connectionEventBase = new EventBase();
|
||||
auto flipperThread = std::thread([flipperEventBase](){
|
||||
flipperEventBase->loopForever();
|
||||
});
|
||||
auto connectionThread = std::thread([connectionEventBase](){
|
||||
connectionEventBase->loopForever();
|
||||
});
|
||||
auto config = FlipperInitConfig {
|
||||
DeviceData {},
|
||||
flipperEventBase,
|
||||
connectionEventBase
|
||||
};
|
||||
auto instance = std::make_shared<FlipperConnectionManagerImpl>(config, state, contextStore);
|
||||
auto flipperThread =
|
||||
std::thread([flipperEventBase]() { flipperEventBase->loopForever(); });
|
||||
auto connectionThread = std::thread(
|
||||
[connectionEventBase]() { connectionEventBase->loopForever(); });
|
||||
auto config =
|
||||
FlipperInitConfig{DeviceData{}, flipperEventBase, connectionEventBase};
|
||||
auto instance = std::make_shared<FlipperConnectionManagerImpl>(
|
||||
config, state, contextStore);
|
||||
|
||||
instance->start();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user