Rename SonarClient to FlipperClient
Summary: Part of the Sonar -> Flipper rename Reviewed By: passy Differential Revision: D9871902 fbshipit-source-id: 4b64953cb1a64235d47caaf0fabfb560bb85f7a2
This commit is contained in:
committed by
Facebook Github Bot
parent
df8763e697
commit
3c656de7fa
@@ -18,7 +18,7 @@
|
|||||||
#include <folly/io/async/EventBase.h>
|
#include <folly/io/async/EventBase.h>
|
||||||
#include <folly/io/async/EventBaseManager.h>
|
#include <folly/io/async/EventBaseManager.h>
|
||||||
|
|
||||||
#include <Flipper/SonarClient.h>
|
#include <Flipper/FlipperClient.h>
|
||||||
#include <Flipper/SonarWebSocket.h>
|
#include <Flipper/SonarWebSocket.h>
|
||||||
#include <Flipper/SonarConnection.h>
|
#include <Flipper/SonarConnection.h>
|
||||||
#include <Flipper/FlipperResponder.h>
|
#include <Flipper/FlipperResponder.h>
|
||||||
@@ -291,42 +291,42 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void start() {
|
void start() {
|
||||||
SonarClient::instance()->start();
|
FlipperClient::instance()->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop() {
|
void stop() {
|
||||||
SonarClient::instance()->stop();
|
FlipperClient::instance()->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPlugin(jni::alias_ref<JFlipperPlugin> plugin) {
|
void addPlugin(jni::alias_ref<JFlipperPlugin> plugin) {
|
||||||
auto wrapper = std::make_shared<JFlipperPluginWrapper>(make_global(plugin));
|
auto wrapper = std::make_shared<JFlipperPluginWrapper>(make_global(plugin));
|
||||||
SonarClient::instance()->addPlugin(wrapper);
|
FlipperClient::instance()->addPlugin(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removePlugin(jni::alias_ref<JFlipperPlugin> plugin) {
|
void removePlugin(jni::alias_ref<JFlipperPlugin> plugin) {
|
||||||
auto client = SonarClient::instance();
|
auto client = FlipperClient::instance();
|
||||||
client->removePlugin(client->getPlugin(plugin->identifier()));
|
client->removePlugin(client->getPlugin(plugin->identifier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void subscribeForUpdates(jni::alias_ref<JFlipperStateUpdateListener> stateListener) {
|
void subscribeForUpdates(jni::alias_ref<JFlipperStateUpdateListener> stateListener) {
|
||||||
auto client = SonarClient::instance();
|
auto client = FlipperClient::instance();
|
||||||
mStateListener = std::make_shared<AndroidFlipperStateUpdateListener>(stateListener);
|
mStateListener = std::make_shared<AndroidFlipperStateUpdateListener>(stateListener);
|
||||||
client->setStateListener(mStateListener);
|
client->setStateListener(mStateListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unsubscribe() {
|
void unsubscribe() {
|
||||||
auto client = SonarClient::instance();
|
auto client = FlipperClient::instance();
|
||||||
mStateListener = nullptr;
|
mStateListener = nullptr;
|
||||||
client->setStateListener(nullptr);
|
client->setStateListener(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getState() {
|
std::string getState() {
|
||||||
return SonarClient::instance()->getState();
|
return FlipperClient::instance()->getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
jni::global_ref<JStateSummary::javaobject> getStateSummary() {
|
jni::global_ref<JStateSummary::javaobject> getStateSummary() {
|
||||||
auto summary = jni::make_global(JStateSummary::create());
|
auto summary = jni::make_global(JStateSummary::create());
|
||||||
auto elements = SonarClient::instance()->getStateElements();
|
auto elements = FlipperClient::instance()->getStateElements();
|
||||||
for (auto&& element : elements) {
|
for (auto&& element : elements) {
|
||||||
std::string status;
|
std::string status;
|
||||||
switch (element.state_) {
|
switch (element.state_) {
|
||||||
@@ -340,7 +340,7 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jni::alias_ref<JFlipperPlugin> getPlugin(const std::string& identifier) {
|
jni::alias_ref<JFlipperPlugin> getPlugin(const std::string& identifier) {
|
||||||
auto plugin = SonarClient::instance()->getPlugin(identifier);
|
auto plugin = FlipperClient::instance()->getPlugin(identifier);
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
auto wrapper = std::static_pointer_cast<JFlipperPluginWrapper>(plugin);
|
auto wrapper = std::static_pointer_cast<JFlipperPluginWrapper>(plugin);
|
||||||
return wrapper->jplugin;
|
return wrapper->jplugin;
|
||||||
@@ -361,7 +361,7 @@ class JFlipperClient : public jni::HybridClass<JFlipperClient> {
|
|||||||
const std::string appId,
|
const std::string appId,
|
||||||
const std::string privateAppDirectory) {
|
const std::string privateAppDirectory) {
|
||||||
|
|
||||||
SonarClient::init({
|
FlipperClient::init({
|
||||||
{
|
{
|
||||||
std::move(host),
|
std::move(host),
|
||||||
std::move(os),
|
std::move(os),
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#import "FlipperClient.h"
|
#import "FlipperClient.h"
|
||||||
#import "SonarCppWrapperPlugin.h"
|
#import "SonarCppWrapperPlugin.h"
|
||||||
#import <Flipper/SonarClient.h>
|
#import <Flipper/FlipperClient.h>
|
||||||
#include <folly/io/async/EventBase.h>
|
#include <folly/io/async/EventBase.h>
|
||||||
#include <folly/io/async/ScopedEventBaseThread.h>
|
#include <folly/io/async/ScopedEventBaseThread.h>
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
using WrapperPlugin = facebook::flipper::SonarCppWrapperPlugin;
|
using WrapperPlugin = facebook::flipper::SonarCppWrapperPlugin;
|
||||||
|
|
||||||
@implementation FlipperClient {
|
@implementation FlipperClient {
|
||||||
facebook::flipper::SonarClient *_cppClient;
|
facebook::flipper::FlipperClient *_cppClient;
|
||||||
folly::ScopedEventBaseThread sonarThread;
|
folly::ScopedEventBaseThread sonarThread;
|
||||||
folly::ScopedEventBaseThread connectionThread;
|
folly::ScopedEventBaseThread connectionThread;
|
||||||
#if !TARGET_OS_SIMULATOR
|
#if !TARGET_OS_SIMULATOR
|
||||||
@@ -61,7 +61,7 @@ using WrapperPlugin = facebook::flipper::SonarCppWrapperPlugin;
|
|||||||
deviceName = [NSString stringWithFormat:@"%@ %@", [[UIDevice currentDevice] model], @"Simulator"];
|
deviceName = [NSString stringWithFormat:@"%@ %@", [[UIDevice currentDevice] model], @"Simulator"];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
facebook::flipper::SonarClient::init({
|
facebook::flipper::FlipperClient::init({
|
||||||
{
|
{
|
||||||
"localhost",
|
"localhost",
|
||||||
"iOS",
|
"iOS",
|
||||||
@@ -74,7 +74,7 @@ using WrapperPlugin = facebook::flipper::SonarCppWrapperPlugin;
|
|||||||
sonarThread.getEventBase(),
|
sonarThread.getEventBase(),
|
||||||
connectionThread.getEventBase()
|
connectionThread.getEventBase()
|
||||||
});
|
});
|
||||||
_cppClient = facebook::flipper::SonarClient::instance();
|
_cppClient = facebook::flipper::FlipperClient::instance();
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,11 @@
|
|||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
#import <Flipper/SonarClient.h>
|
#import <Flipper/FlipperClient.h>
|
||||||
#import <FlipperKit/FlipperClient.h>
|
#import <FlipperKit/FlipperClient.h>
|
||||||
|
|
||||||
@interface FlipperClient (Testing)
|
@interface FlipperClient (Testing)
|
||||||
|
|
||||||
- (instancetype)initWithCppClient:(facebook::flipper::SonarClient *)cppClient;
|
- (instancetype)initWithCppClient:(facebook::flipper::FlipperClient *)cppClient;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SonarClient.h"
|
#include "FlipperClient.h"
|
||||||
#include "SonarConnectionImpl.h"
|
#include "SonarConnectionImpl.h"
|
||||||
#include "SonarResponderImpl.h"
|
#include "SonarResponderImpl.h"
|
||||||
#include "SonarState.h"
|
#include "SonarState.h"
|
||||||
@@ -24,29 +24,29 @@
|
|||||||
namespace facebook {
|
namespace facebook {
|
||||||
namespace flipper {
|
namespace flipper {
|
||||||
|
|
||||||
static SonarClient* kInstance;
|
static FlipperClient* kInstance;
|
||||||
|
|
||||||
using folly::dynamic;
|
using folly::dynamic;
|
||||||
|
|
||||||
void SonarClient::init(SonarInitConfig config) {
|
void FlipperClient::init(SonarInitConfig config) {
|
||||||
auto state = std::make_shared<SonarState>();
|
auto state = std::make_shared<SonarState>();
|
||||||
auto context = std::make_shared<ConnectionContextStore>(config.deviceData);
|
auto context = std::make_shared<ConnectionContextStore>(config.deviceData);
|
||||||
kInstance =
|
kInstance =
|
||||||
new SonarClient(std::make_unique<SonarWebSocketImpl>(std::move(config), state, context), state);
|
new FlipperClient(std::make_unique<SonarWebSocketImpl>(std::move(config), state, context), state);
|
||||||
}
|
}
|
||||||
|
|
||||||
SonarClient* SonarClient::instance() {
|
FlipperClient* FlipperClient::instance() {
|
||||||
return kInstance;
|
return kInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SonarClient::setStateListener(
|
void FlipperClient::setStateListener(
|
||||||
std::shared_ptr<SonarStateUpdateListener> stateListener) {
|
std::shared_ptr<SonarStateUpdateListener> stateListener) {
|
||||||
log("Setting state listener");
|
log("Setting state listener");
|
||||||
sonarState_->setUpdateListener(stateListener);
|
sonarState_->setUpdateListener(stateListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SonarClient::addPlugin(std::shared_ptr<SonarPlugin> plugin) {
|
void FlipperClient::addPlugin(std::shared_ptr<SonarPlugin> plugin) {
|
||||||
log("SonarClient::addPlugin " + plugin->identifier());
|
log("FlipperClient::addPlugin " + plugin->identifier());
|
||||||
auto step = sonarState_->start("Add plugin " + plugin->identifier());
|
auto step = sonarState_->start("Add plugin " + plugin->identifier());
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
@@ -63,8 +63,8 @@ void SonarClient::addPlugin(std::shared_ptr<SonarPlugin> plugin) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SonarClient::removePlugin(std::shared_ptr<SonarPlugin> plugin) {
|
void FlipperClient::removePlugin(std::shared_ptr<SonarPlugin> plugin) {
|
||||||
log("SonarClient::removePlugin " + plugin->identifier());
|
log("FlipperClient::removePlugin " + plugin->identifier());
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
performAndReportError([this, plugin]() {
|
performAndReportError([this, plugin]() {
|
||||||
@@ -79,7 +79,7 @@ void SonarClient::removePlugin(std::shared_ptr<SonarPlugin> plugin) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<SonarPlugin> SonarClient::getPlugin(
|
std::shared_ptr<SonarPlugin> FlipperClient::getPlugin(
|
||||||
const std::string& identifier) {
|
const std::string& identifier) {
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
if (plugins_.find(identifier) == plugins_.end()) {
|
if (plugins_.find(identifier) == plugins_.end()) {
|
||||||
@@ -88,12 +88,12 @@ std::shared_ptr<SonarPlugin> SonarClient::getPlugin(
|
|||||||
return plugins_.at(identifier);
|
return plugins_.at(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SonarClient::hasPlugin(const std::string& identifier) {
|
bool FlipperClient::hasPlugin(const std::string& identifier) {
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
return plugins_.find(identifier) != plugins_.end();
|
return plugins_.find(identifier) != plugins_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SonarClient::disconnect(std::shared_ptr<SonarPlugin> plugin) {
|
void FlipperClient::disconnect(std::shared_ptr<SonarPlugin> plugin) {
|
||||||
const auto& conn = connections_.find(plugin->identifier());
|
const auto& conn = connections_.find(plugin->identifier());
|
||||||
if (conn != connections_.end()) {
|
if (conn != connections_.end()) {
|
||||||
connections_.erase(plugin->identifier());
|
connections_.erase(plugin->identifier());
|
||||||
@@ -101,22 +101,22 @@ void SonarClient::disconnect(std::shared_ptr<SonarPlugin> plugin) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SonarClient::refreshPlugins() {
|
void FlipperClient::refreshPlugins() {
|
||||||
performAndReportError([this]() {
|
performAndReportError([this]() {
|
||||||
dynamic message = dynamic::object("method", "refreshPlugins");
|
dynamic message = dynamic::object("method", "refreshPlugins");
|
||||||
socket_->sendMessage(message);
|
socket_->sendMessage(message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SonarClient::onConnected() {
|
void FlipperClient::onConnected() {
|
||||||
log("SonarClient::onConnected");
|
log("FlipperClient::onConnected");
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
connected_ = true;
|
connected_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SonarClient::onDisconnected() {
|
void FlipperClient::onDisconnected() {
|
||||||
log("SonarClient::onDisconnected");
|
log("FlipperClient::onDisconnected");
|
||||||
auto step = sonarState_->start("Trigger onDisconnected callbacks");
|
auto step = sonarState_->start("Trigger onDisconnected callbacks");
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
connected_ = false;
|
connected_ = false;
|
||||||
@@ -128,7 +128,7 @@ void SonarClient::onDisconnected() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SonarClient::onMessageReceived(const dynamic& message) {
|
void FlipperClient::onMessageReceived(const dynamic& message) {
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
performAndReportError([this, &message]() {
|
performAndReportError([this, &message]() {
|
||||||
const auto& method = message["method"];
|
const auto& method = message["method"];
|
||||||
@@ -198,7 +198,7 @@ void SonarClient::onMessageReceived(const dynamic& message) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SonarClient::performAndReportError(const std::function<void()>& func) {
|
void FlipperClient::performAndReportError(const std::function<void()>& func) {
|
||||||
try {
|
try {
|
||||||
func();
|
func();
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
@@ -213,11 +213,11 @@ void SonarClient::performAndReportError(const std::function<void()>& func) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SonarClient::getState() {
|
std::string FlipperClient::getState() {
|
||||||
return sonarState_->getState();
|
return sonarState_->getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<StateElement> SonarClient::getStateElements() {
|
std::vector<StateElement> FlipperClient::getStateElements() {
|
||||||
return sonarState_->getStateElements();
|
return sonarState_->getStateElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,26 +21,26 @@
|
|||||||
namespace facebook {
|
namespace facebook {
|
||||||
namespace flipper {
|
namespace flipper {
|
||||||
|
|
||||||
class SonarClient : public SonarWebSocket::Callbacks {
|
class FlipperClient : public SonarWebSocket::Callbacks {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
Call before accessing instance with SonarClient::instance(). This will set up
|
Call before accessing instance with FlipperClient::instance(). This will set up
|
||||||
all the state needed to establish a Sonar connection.
|
all the state needed to establish a Sonar connection.
|
||||||
*/
|
*/
|
||||||
static void init(SonarInitConfig config);
|
static void init(SonarInitConfig config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Standard accessor for the shared SonarClient instance. This returns a
|
Standard accessor for the shared FlipperClient instance. This returns a
|
||||||
singleton instance to a shared SonarClient. First call to this function will
|
singleton instance to a shared FlipperClient. First call to this function will
|
||||||
create the shared SonarClient. Must call SonarClient::initDeviceData() before
|
create the shared FlipperClient. Must call FlipperClient::initDeviceData() before
|
||||||
first call to SonarClient::instance().
|
first call to FlipperClient::instance().
|
||||||
*/
|
*/
|
||||||
static SonarClient* instance();
|
static FlipperClient* instance();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Only public for testing
|
Only public for testing
|
||||||
*/
|
*/
|
||||||
SonarClient(std::unique_ptr<SonarWebSocket> socket, std::shared_ptr<SonarState> state)
|
FlipperClient(std::unique_ptr<SonarWebSocket> socket, std::shared_ptr<SonarState> state)
|
||||||
: socket_(std::move(socket)), sonarState_(state) {
|
: socket_(std::move(socket)), sonarState_(state) {
|
||||||
auto step = sonarState_->start("Create client");
|
auto step = sonarState_->start("Create client");
|
||||||
socket_->setCallbacks(this);
|
socket_->setCallbacks(this);
|
||||||
@@ -88,7 +88,7 @@ class SonarClient : public SonarWebSocket::Callbacks {
|
|||||||
bool hasPlugin(const std::string& identifier);
|
bool hasPlugin(const std::string& identifier);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static SonarClient* instance_;
|
static FlipperClient* instance_;
|
||||||
bool connected_ = false;
|
bool connected_ = false;
|
||||||
std::unique_ptr<SonarWebSocket> socket_;
|
std::unique_ptr<SonarWebSocket> socket_;
|
||||||
std::map<std::string, std::shared_ptr<SonarPlugin>> plugins_;
|
std::map<std::string, std::shared_ptr<SonarPlugin>> plugins_;
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Flipper/SonarClient.h>
|
#include <Flipper/FlipperClient.h>
|
||||||
#include <FlipperTestLib/SonarPluginMock.h>
|
#include <FlipperTestLib/SonarPluginMock.h>
|
||||||
#include <FlipperTestLib/SonarWebSocketMock.h>
|
#include <FlipperTestLib/SonarWebSocketMock.h>
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ TEST(SonarClientTests, testSaneMocks) {
|
|||||||
|
|
||||||
TEST(SonarClientTests, testGetPlugins) {
|
TEST(SonarClientTests, testGetPlugins) {
|
||||||
auto socket = new SonarWebSocketMock;
|
auto socket = new SonarWebSocketMock;
|
||||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
FlipperClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||||
client.start();
|
client.start();
|
||||||
|
|
||||||
client.addPlugin(std::make_shared<SonarPluginMock>("Cat"));
|
client.addPlugin(std::make_shared<SonarPluginMock>("Cat"));
|
||||||
@@ -50,7 +50,7 @@ TEST(SonarClientTests, testGetPlugins) {
|
|||||||
|
|
||||||
TEST(SonarClientTests, testGetPlugin) {
|
TEST(SonarClientTests, testGetPlugin) {
|
||||||
auto socket = new SonarWebSocketMock;
|
auto socket = new SonarWebSocketMock;
|
||||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
FlipperClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||||
|
|
||||||
const auto catPlugin = std::make_shared<SonarPluginMock>("Cat");
|
const auto catPlugin = std::make_shared<SonarPluginMock>("Cat");
|
||||||
client.addPlugin(catPlugin);
|
client.addPlugin(catPlugin);
|
||||||
@@ -63,7 +63,7 @@ TEST(SonarClientTests, testGetPlugin) {
|
|||||||
|
|
||||||
TEST(SonarClientTests, testGetPluginWithDowncast) {
|
TEST(SonarClientTests, testGetPluginWithDowncast) {
|
||||||
auto socket = new SonarWebSocketMock;
|
auto socket = new SonarWebSocketMock;
|
||||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
FlipperClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||||
|
|
||||||
const auto catPlugin = std::make_shared<SonarPluginMock>("Cat");
|
const auto catPlugin = std::make_shared<SonarPluginMock>("Cat");
|
||||||
client.addPlugin(catPlugin);
|
client.addPlugin(catPlugin);
|
||||||
@@ -72,7 +72,7 @@ TEST(SonarClientTests, testGetPluginWithDowncast) {
|
|||||||
|
|
||||||
TEST(SonarClientTests, testRemovePlugin) {
|
TEST(SonarClientTests, testRemovePlugin) {
|
||||||
auto socket = new SonarWebSocketMock;
|
auto socket = new SonarWebSocketMock;
|
||||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
FlipperClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||||
client.start();
|
client.start();
|
||||||
|
|
||||||
auto plugin = std::make_shared<SonarPluginMock>("Test");
|
auto plugin = std::make_shared<SonarPluginMock>("Test");
|
||||||
@@ -89,7 +89,7 @@ TEST(SonarClientTests, testRemovePlugin) {
|
|||||||
|
|
||||||
TEST(SonarClientTests, testStartStop) {
|
TEST(SonarClientTests, testStartStop) {
|
||||||
auto socket = new SonarWebSocketMock;
|
auto socket = new SonarWebSocketMock;
|
||||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
FlipperClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||||
|
|
||||||
client.start();
|
client.start();
|
||||||
EXPECT_TRUE(socket->isOpen());
|
EXPECT_TRUE(socket->isOpen());
|
||||||
@@ -100,7 +100,7 @@ TEST(SonarClientTests, testStartStop) {
|
|||||||
|
|
||||||
TEST(SonarClientTests, testConnectDisconnect) {
|
TEST(SonarClientTests, testConnectDisconnect) {
|
||||||
auto socket = new SonarWebSocketMock;
|
auto socket = new SonarWebSocketMock;
|
||||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
FlipperClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||||
|
|
||||||
bool pluginConnected = false;
|
bool pluginConnected = false;
|
||||||
const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) {
|
const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) {
|
||||||
@@ -123,7 +123,7 @@ TEST(SonarClientTests, testConnectDisconnect) {
|
|||||||
|
|
||||||
TEST(SonarClientTests, testInitDeinit) {
|
TEST(SonarClientTests, testInitDeinit) {
|
||||||
auto socket = new SonarWebSocketMock;
|
auto socket = new SonarWebSocketMock;
|
||||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
FlipperClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||||
|
|
||||||
bool pluginConnected = false;
|
bool pluginConnected = false;
|
||||||
const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) {
|
const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) {
|
||||||
@@ -161,7 +161,7 @@ TEST(SonarClientTests, testInitDeinit) {
|
|||||||
|
|
||||||
TEST(SonarClientTests, testRemovePluginWhenConnected) {
|
TEST(SonarClientTests, testRemovePluginWhenConnected) {
|
||||||
auto socket = new SonarWebSocketMock;
|
auto socket = new SonarWebSocketMock;
|
||||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
FlipperClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||||
|
|
||||||
bool pluginConnected = false;
|
bool pluginConnected = false;
|
||||||
const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) {
|
const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) {
|
||||||
@@ -182,7 +182,7 @@ TEST(SonarClientTests, testRemovePluginWhenConnected) {
|
|||||||
|
|
||||||
TEST(SonarClientTests, testUnhandleableMethod) {
|
TEST(SonarClientTests, testUnhandleableMethod) {
|
||||||
auto socket = new SonarWebSocketMock;
|
auto socket = new SonarWebSocketMock;
|
||||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
FlipperClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||||
|
|
||||||
auto plugin = std::make_shared<SonarPluginMock>("Test");
|
auto plugin = std::make_shared<SonarPluginMock>("Test");
|
||||||
client.addPlugin(plugin);
|
client.addPlugin(plugin);
|
||||||
@@ -202,7 +202,7 @@ TEST(SonarClientTests, testUnhandleableMethod) {
|
|||||||
|
|
||||||
TEST(SonarClientTests, testExecute) {
|
TEST(SonarClientTests, testExecute) {
|
||||||
auto socket = new SonarWebSocketMock;
|
auto socket = new SonarWebSocketMock;
|
||||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
FlipperClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||||
client.start();
|
client.start();
|
||||||
|
|
||||||
const auto connectionCallback = [](std::shared_ptr<SonarConnection> conn) {
|
const auto connectionCallback = [](std::shared_ptr<SonarConnection> conn) {
|
||||||
@@ -232,7 +232,7 @@ TEST(SonarClientTests, testExecute) {
|
|||||||
|
|
||||||
TEST(SonarClientTests, testExecuteWithParams) {
|
TEST(SonarClientTests, testExecuteWithParams) {
|
||||||
auto socket = new SonarWebSocketMock;
|
auto socket = new SonarWebSocketMock;
|
||||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
FlipperClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||||
|
|
||||||
const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) {
|
const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) {
|
||||||
const auto receiver = [](const dynamic ¶ms,
|
const auto receiver = [](const dynamic ¶ms,
|
||||||
@@ -265,7 +265,7 @@ TEST(SonarClientTests, testExecuteWithParams) {
|
|||||||
|
|
||||||
TEST(SonarClientTests, testExceptionUnknownPlugin) {
|
TEST(SonarClientTests, testExceptionUnknownPlugin) {
|
||||||
auto socket = new SonarWebSocketMock;
|
auto socket = new SonarWebSocketMock;
|
||||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
FlipperClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||||
client.start();
|
client.start();
|
||||||
|
|
||||||
dynamic messageInit = dynamic::object("method", "init")(
|
dynamic messageInit = dynamic::object("method", "init")(
|
||||||
@@ -278,7 +278,7 @@ TEST(SonarClientTests, testExceptionUnknownPlugin) {
|
|||||||
|
|
||||||
TEST(SonarClientTests, testExceptionUnknownApi) {
|
TEST(SonarClientTests, testExceptionUnknownApi) {
|
||||||
auto socket = new SonarWebSocketMock;
|
auto socket = new SonarWebSocketMock;
|
||||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
FlipperClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||||
client.start();
|
client.start();
|
||||||
|
|
||||||
dynamic messageInit = dynamic::object("method", "execute")(
|
dynamic messageInit = dynamic::object("method", "execute")(
|
||||||
|
|||||||
Reference in New Issue
Block a user