Rename SonarKit tests and testutils folder

Summary: Renames SonarKit tests and testutils folder

Reviewed By: passy

Differential Revision: D10017892

fbshipit-source-id: 0725e061ee2c6baa77a3d80af36375e08d9f415e
This commit is contained in:
Pritesh Nandgaonkar
2018-09-25 12:47:04 -07:00
committed by Facebook Github Bot
parent 632628e630
commit ef6ee6281f
9 changed files with 4 additions and 4 deletions

View File

@@ -0,0 +1,21 @@
/*
* Copyright (c) 2018-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*
*/
#import <Foundation/Foundation.h>
#import <FlipperKit/FlipperPlugin.h>
@protocol FlipperConnection;
typedef void (^ConnectBlock)(id<FlipperConnection>);
typedef void (^DisconnectBlock)();
@interface BlockBasedSonarPlugin : NSObject<FlipperPlugin>
- (instancetype)initIdentifier:(NSString *)identifier connect:(ConnectBlock)connect disconnect:(DisconnectBlock)disconnect;
@end

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2018-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*
*/
#import "BlockBasedSonarPlugin.h"
@implementation BlockBasedSonarPlugin
{
NSString *_identifier;
ConnectBlock _connect;
DisconnectBlock _disconnect;
}
- (instancetype)initIdentifier:(NSString *)identifier connect:(ConnectBlock)connect disconnect:(DisconnectBlock)disconnect
{
if (self = [super init]) {
_identifier = identifier;
_connect = connect;
_disconnect = disconnect;
}
return self;
}
- (NSString *)identifier
{
return _identifier;
}
- (void)didConnect:(id<FlipperConnection>)connection
{
if (_connect) {
_connect(connection);
}
}
- (void)didDisconnect
{
if (_connect) {
_disconnect();
}
}
@end

View File

@@ -0,0 +1,21 @@
/*
* Copyright (c) 2018-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*
*/
#ifndef __cplusplus
#error This header can only be included in .mm (ObjC++) files
#endif
#import <Foundation/Foundation.h>
#import <Flipper/FlipperClient.h>
#import <FlipperKit/FlipperClient.h>
@interface FlipperClient (Testing)
- (instancetype)initWithCppClient:(facebook::flipper::FlipperClient *)cppClient;
@end

View File

@@ -0,0 +1,18 @@
/*
* Copyright (c) 2018-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*
*/
#import <Foundation/Foundation.h>
#import <FlipperKit/FlipperConnection.h>
@interface SonarConnectionMock : NSObject<FlipperConnection>
@property (nonatomic, assign, getter=isConnected) BOOL connected;
@property (nonatomic, readonly) NSDictionary<NSString *, SonarReceiver> *receivers;
@property (nonatomic, readonly) NSDictionary<NSString *, NSArray<NSDictionary *> *> *sent;
@end

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2018-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*
*/
#import "SonarConnectionMock.h"
@implementation SonarConnectionMock
- (instancetype)init
{
if (self = [super init]) {
_connected = YES;
_receivers = @{};
_sent = @{};
}
return self;
}
- (void)send:(NSString *)method withParams:(NSDictionary *)params
{
if (_connected) {
NSMutableDictionary *newSent = [NSMutableDictionary new];
[newSent addEntriesFromDictionary:_sent];
if (newSent[method]) {
newSent[method] = [_sent[method] arrayByAddingObject:params];
} else {
newSent[method] = @[params];
}
_sent = newSent;
}
}
- (void)receive:(NSString *)method withBlock:(SonarReceiver)receiver
{
if (_connected) {
NSMutableDictionary *newReceivers = [NSMutableDictionary new];
[newReceivers addEntriesFromDictionary:_receivers];
newReceivers[method] = receiver;
_receivers = newReceivers;
}
}
@end

View File

@@ -0,0 +1,17 @@
/*
* Copyright (c) 2018-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*
*/
#import <Foundation/Foundation.h>
#import <FlipperKit/FlipperResponder.h>
@interface SonarResponderMock : NSObject<FlipperResponder>
@property (nonatomic, readonly) NSArray<NSDictionary *> *successes;
@property (nonatomic, readonly) NSArray<NSDictionary *> *errors;
@end

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2018-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*
*/
#import "SonarResponderMock.h"
@implementation SonarResponderMock
- (instancetype)init
{
if (self = [super init]) {
_successes = @[];
_errors = @[];
}
return self;
}
- (void)success:(NSDictionary *)response
{
_successes = [_successes arrayByAddingObject:response];
}
- (void)error:(NSDictionary *)response
{
_errors = [_errors arrayByAddingObject:response];
}
@end