Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions Jenkinsfiles/mac
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pipeline {
cd osxscraper
xcodebuild -list -project OSXScraper.xcodeproj
xcodebuild -scheme OSXScraper build

echo "Build OSXProxy..."
cd ../osxproxy
xcodebuild -list -project OSXProxy.xcodeproj
Expand All @@ -33,7 +33,45 @@ pipeline {
steps {
timeout(time: 1, unit: 'HOURS'){
sh '''
echo "Test(s) go here"
echo "[OSXScraper] Start testing"
mkdir -p testoutput
cd osxscraper
/Applications/Calculator.app/Contents/MacOS/Calculator &

echo "[OSXScraper] build-for-testing"
xcodebuild build-for-testing -project OSXScraper.xcodeproj -scheme OSXScraper

echo "clean the TCC.db"
sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'select * from access'
sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" "SELECT name FROM PRAGMA_TABLE_INFO('access')"
sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" "delete from access where client='edu.unc.OSXScraper' and service='kTCCServiceAccessibility'"
sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'select * from access'

echo "[OSXScraper] test-without-building, run 1 case to enable Accessibility access magically"
xcodebuild test-without-building -project OSXScraper.xcodeproj -scheme OSXScraper -only-testing:OSXScraperTests/OSXScrapperTests/test001_LS_Self

echo "enable the allow access in TCC.db"
sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'select * from access'
sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" "SELECT name FROM PRAGMA_TABLE_INFO('access')"
sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'UPDATE access SET allowed = "1";'
sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'select * from access'

echo "[OSXScraper] test-without-building, run the testcases"
xcodebuild test-without-building -project OSXScraper.xcodeproj -scheme OSXScraper
cd -
ls -lht testoutput/
echo "[OSXScraper] Testing Done"

echo "[OSXProxy] Start testing"
cd osxproxy

echo "[OSXProxy] build-for-testing"
xcodebuild build-for-testing -project OSXProxy.xcodeproj -scheme OSXProxy

echo "[OSXProxy] test-without-building, run the testcases"
xcodebuild test-without-building -project OSXProxy.xcodeproj -scheme OSXProxy -skip-testing:OSXProxyUITests

echo "[OSXProxy] Testing Done"
'''
}
}
Expand Down
31 changes: 31 additions & 0 deletions common/AppleConnection/AppleConnection/ClientHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ - (id) init {
- (void) initForClientSocket {
_isServerSocket = NO;

if ( [[NSProcessInfo processInfo] environment][@"isUITest"] )
{
isConnected = true;
[[NSNotificationCenter defaultCenter] postNotificationName:@"connectedInd" object:self];
return;
}

CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)ipAddress, _port, &readStream, &writeStream);
Expand Down Expand Up @@ -174,6 +181,30 @@ - (id) initForServerSocketWithtInputStream:(NSInputStream *) inStream outputStre
- (void) sendMessage: (NSString *) message {
static NSData *last_data;

if ( [[NSProcessInfo processInfo] environment][@"isUITest"] )
{
return;
}

#ifdef DEBUG
NSDictionary * instanceSetting = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"plist"]];
NSString * logfolder = [instanceSetting objectForKey:@"xml_logfolder"];
NSString * filename = nil;
if ((logfolder != Nil ) && ([logfolder length] != 0)) {
if (_isServerSocket == YES) {
filename = [NSString stringWithFormat:@"%@/scraper_%@.xml", logfolder, [NSDate date]];
}
else {
filename = [NSString stringWithFormat:@"%@/proxy_%@.xml", logfolder, [NSDate date]];
}
NSError * error = NULL;
if([message writeToFile:filename atomically:NO encoding:NSUTF8StringEncoding error:&error])
{
NSLog( @"xml saving to %@", filename);
}
}
#endif

NSData *data = [[NSData alloc] initWithData:[message dataUsingEncoding:NSUTF8StringEncoding]];
if ([last_data isEqualToData:data]) {
NSLog(@"Same data being sent repeatedly.Skipping send...\n");
Expand Down
Loading