TESTFAIRY-1906: Added ability to hide views

This commit is contained in:
Vijay Sharma 2016-01-12 15:12:56 -05:00
parent 55eb08f43d
commit 506270a5ab
6 changed files with 277 additions and 10 deletions

View File

@ -10,18 +10,23 @@ var {
StyleSheet,
Text,
View,
findNodeHandle
} = React;
const TestFairyBridge = require('react-native-testfairy');
var TestFairy = React.createClass({
componentDidMount: function() {
TestFairyBridge.hideView(findNodeHandle(this.refs.instructions));
},
render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
<Text style={styles.instructions} ref="instructions">
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>

View File

@ -34,6 +34,10 @@ class TestFairy {
static sendUserFeedback(feedback) {
TestFairyBridge.sendUserFeedback(feedback);
}
static hideView(viewTag) {
TestFairyBridge.hideView(viewTag);
}
}
module.exports = TestFairy;

View File

@ -1,15 +1,14 @@
#import "RCTTestFairyBridge.h"
#import "RCTLog.h"
#import "RCTConvert.h"
#import "RCTUIManager.h"
#import "TestFairy.h"
@implementation RCTTestFairyBridge
RCT_EXPORT_MODULE();
@synthesize bridge = _bridge;
RCT_EXPORT_METHOD(begin:(NSString *)appKey) {
[TestFairy begin:appKey];
}
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(begin:(NSString *)appKey withOptions:(NSDictionary *)options) {
[TestFairy begin:appKey withOptions:options];
@ -19,10 +18,6 @@ RCT_EXPORT_METHOD(setCorrelationId:(NSString *)correlationId) {
[TestFairy setCorrelationId:correlationId];
}
RCT_EXPORT_METHOD(identify:(NSString *)correlationId) {
[TestFairy identify:correlationId];
}
RCT_EXPORT_METHOD(identify:(NSString *)correlationId traits:(NSDictionary *)traits) {
[TestFairy identify:correlationId traits:traits];
}
@ -47,4 +42,23 @@ RCT_EXPORT_METHOD(sendUserFeedback:(NSString *)feedback) {
[TestFairy sendUserFeedback:feedback];
}
@end
RCT_EXPORT_METHOD(sessionUrl:(RCTResponseSenderBlock)callback) {
callback(@[[NSNull null], [TestFairy sessionUrl]]);
}
RCT_EXPORT_METHOD(version:(RCTResponseSenderBlock)callback) {
callback(@[[NSNull null], [TestFairy version]]);
}
RCT_EXPORT_METHOD(hideView:(nonnull NSNumber *)reactTag) {
dispatch_async(_bridge.uiManager.methodQueue, ^{
[_bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
UIView *view = viewRegistry[reactTag];
if (view != nil) {
[TestFairy hideView:view];
}
}];
});
}
@end

159
ios/TestFairy.h Normal file
View File

@ -0,0 +1,159 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface TestFairy: NSObject
/**
* Initialize a TestFairy session.
*
* @param appToken Your key as given to you in your TestFairy account
*/
+ (void)begin:(NSString *)appToken;
/**
* Initialize a TestFairy session with options.
*
* @param appToken Your key as given to you in your TestFairy account
* @param options A dictionary of options controlling the current session
*/
+ (void)begin:(NSString *)appToken withOptions:(NSDictionary *)options;
/**
* Returns SDK version (x.x.x) string
*
* @return version
*/
+ (NSString *)version;
/**
* Hides a specific view from appearing in the video generated.
*
* @param view The specific view you wish to hide from screenshots
*
*/
+ (void)hideView:(UIView *)view;
/**
* Pushes the feedback view controller. Hook a button
* to this method to allow users to provide feedback about the current
* session. All feedback will appear in your build report page, and in
* the recorded session page.
*
*/
+ (void)pushFeedbackController;
/**
* Send a feedback on behalf of the user. Call when using a in-house
* feedback view controller with a custom design and feel. Feedback will
* be associated with the current session.
*
* @param feedbackString Feedback text
*/
+ (void)sendUserFeedback:(NSString *)feedbackString;
/**
* Proxy didUpdateLocation delegate values and these
* locations will appear in the recorded sessions. Useful for debugging
* actual long/lat values against what the user sees on screen.
*
* @param locations Array of CLLocation. The first object of the array will determine the user location
*/
+ (void)updateLocation:(NSArray *)locations;
/**
* Marks a checkpoint in session. Use this text to tag a session
* with a checkpoint name. Later you can filter sessions where your
* user passed through this checkpoint, for bettering understanding
* user experience and behavior.
*
* @param name The checkpoint name
*/
+ (void)checkpoint:(NSString *)name;
/**
* Sets a correlation identifier for this session. This value can
* be looked up via web dashboard. For example, setting correlation
* to the value of the user-id after they logged in. Can be called
* only once per session (subsequent calls will be ignored.)
*
* @param correlationId Id for the current session
*/
+ (void)setCorrelationId:(NSString *)correlationId;
/**
* Sets a correlation identifier for this session. This value can
* be looked up via web dashboard. For example, setting correlation
* to the value of the user-id after they logged in. Can be called
* only once per session (subsequent calls will be ignored.)
*
* @param correlationId Id for the current session
*/
+ (void)identify:(NSString *)correlationId;
/**
* Sets a correlation identifier for this session. This value can
* be looked up via web dashboard. For example, setting correlation
* to the value of the user-id after they logged in. Can be called
* only once per session (subsequent calls will be ignored.)
*
* @param correlationId Id for the current session
* @param traits Attributes and custom attributes to be associated with this session
*/
+ (void)identify:(NSString *)correlationId traits:(NSDictionary *)traits;
/**
* Pauses the current session. This method stops recoding of
* the current session until resume has been called.
*
* @see resume
*/
+ (void)pause;
/**
* Resumes the recording of the current session. This method
* resumes a session after it was paused.
*
* @see pause
*/
+ (void)resume;
/**
* Returns the address of the recorded session on testfairy's
* developer portal. Will return nil if recording not yet started.
*
* @return session URL
*/
+ (NSString *)sessionUrl;
/**
* Takes a screenshot.
*
*/
+ (void)takeScreenshot;
/**
* Remote logging, use TFLog as you would use printf. These logs will be sent to the server,
* but will not appear in the console.
*/
#if __cplusplus
extern "C" {
#endif
void TFLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
void TFLogv(NSString *format, va_list arg_list);
#if __cplusplus
}
#endif
@end
extern NSString *const TFSDKIdentityTraitNameKey;
extern NSString *const TFSDKIdentityTraitEmailAddressKey;
extern NSString *const TFSDKIdentityTraitBirthdayKey;
extern NSString *const TFSDKIdentityTraitGenderKey;
extern NSString *const TFSDKIdentityTraitPhoneNumberKey;
extern NSString *const TFSDKIdentityTraitWebsiteAddressKey;
extern NSString *const TFSDKIdentityTraitAgeKey;
extern NSString *const TFSDKIdentityTraitSignupDateKey;

BIN
ios/libTestFairy.a Normal file

Binary file not shown.

85
ios/upload-dsym.sh Normal file
View File

@ -0,0 +1,85 @@
#!/bin/sh
TESTFAIRY_ENDPOINT="http://app.testfairy.com/upload/dsym/"
ZIP=zip
CURL=curl
STAT=stat
DATE=date
log() {
NOW=$($DATE +"%Y-%m-%d %H:%M:%S")
echo "${NOW} ${1}"
}
help() {
echo "Usage: ${0} [-f] TESTFAIRY_API_KEY [-p DSYM_PATH]"
exit 1
}
DAEMON=1
if [ "${1}" == "-f" ]; then
DAEMON=0
shift
elif [ "${1}" == "-d" ]; then
# backward compatible when -f was the default
shift
fi
API_KEY="${1}"
if [ ! "${API_KEY}" ]; then
help
fi
DSYM_PATH=${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}
if [ "${#}" -gt 1 ]; then
shift
if [ "${1}" != "-p" ]; then
help
fi
shift
DSYM_PATH="${1}"
fi
if [ "${DSYM_PATH}" == "" ] || [ "${DSYM_PATH}" == "/" ] || [ ! -d "${DSYM_PATH}" ]; then
echo "Fatal: Can't find .dSYM folder!"
help
fi
NOW=$($DATE +%s)
TMP_FILENAME="/tmp/${NOW}-${DWARF_DSYM_FILE_NAME}.zip"
# Compress the .dSYM folder into a zip file
log "Compressing .dSYM folder ${DSYM_PATH}"
$ZIP -qrp9 "${TMP_FILENAME}" "${DSYM_PATH}"
FILE_SIZE=$($STAT -f "%z" "${TMP_FILENAME}")
foreground_upload() {
# Upload zipped .dSYM file to TestFairy's servers
STARTED=$($DATE +"%s")
$CURL -s -F api_key="${API_KEY}" -F dsym=@"${1}" -o /dev/null "${TESTFAIRY_ENDPOINT}"
ENDED=$($DATE +"%s")
DIFF=$(expr ${ENDED} - ${STARTED})
log "Symbols uploaded in ${DIFF} seconds"
# Clean up behind
rm -f ${TMP_FILENAME}
}
background_upload() {
sh -c "$CURL -F api_key=\"${API_KEY}\" -F dsym=@\"${1}\" -s -o /dev/null \"${TESTFAIRY_ENDPOINT}\"; rm -f ${TMP_FILENAME};" /dev/null 2>&1 &
}
if [ "$DAEMON" == "0" ]; then
log "Uploading ${FILE_SIZE} bytes to dsym server in foreground"
foreground_upload "${TMP_FILENAME}"
else
log "Uploading ${FILE_SIZE} bytes to dsym server in background"
background_upload "${TMP_FILENAME}"
fi
log "TestFairy .dSYM upload script ends"