فهرست منبع

Removed bonjour from testing to simplify it

Mike Lewis 13 سال پیش
والد
کامیت
7bc583a612

+ 2 - 21
SRWebSocketTests/SRTAutobahnTests.m

@@ -17,7 +17,6 @@
 #import <SenTestingKit/SenTestingKit.h>
 #import "SRWebSocket.h"
 #import "SRTWebSocketOperation.h"
-#import "SRTBonjourLocatorOperation.h"
 #import "SenTestCase+SRTAdditions.h"
 
 #define SRLogDebug(format, ...) 
@@ -54,27 +53,9 @@
 - (void)testFuzzer;
 {
     _sockets = [[NSMutableArray alloc] init];
-
-    NSString *const testHarnessKey = [[NSProcessInfo processInfo].environment objectForKey:@"SR_TESTHARNESS_KEY"];
-
-    STAssertNotNil(testHarnessKey, @"Should have SR_TESTHARNESS_KEY key set in env");
-
-    SRTBonjourLocatorOperation *locatorOperation = [[SRTBonjourLocatorOperation alloc] initWithKey:testHarnessKey];
-    [locatorOperation start];
-
-    [self runCurrentRunLoopUntilTestPasses:^BOOL{
-        return locatorOperation.isFinished;
-    } timeout:20.0];
-
-    STAssertNotNil(locatorOperation.foundService, @"Should have found a test harness service");
     
-    NSURL *prefixURL = [[[NSURL alloc] 
-                         initWithScheme:locatorOperation.foundScheme 
-                         host:[NSString stringWithFormat:@"%@:%d", 
-                               @"localhost",
-                               locatorOperation.foundService.port] 
-                         path:@"/.."] 
-                        standardizedURL];
+    NSString *testURLString = [[NSProcessInfo processInfo].environment objectForKey:@"SR_TEST_URL"];
+    NSURL *prefixURL = [NSURL URLWithString:testURLString];    
     
     CaseGetterOperation *caseGetter = [[CaseGetterOperation alloc] initWithBaseURL:prefixURL];
     [caseGetter start];

+ 0 - 18
SRWebSocketTests/SRTBonjourLocatorOperation.h

@@ -1,18 +0,0 @@
-//
-//  SRTBonjourLocatorOperation.h
-//  SocketRocket
-//
-//  Created by Mike Lewis on 1/28/12.
-//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-
-@interface SRTBonjourLocatorOperation : NSOperation
-
-- (id)initWithKey:(NSString *)key;
-
-@property (nonatomic, readonly, retain) NSNetService *foundService;
-@property (nonatomic, readonly, retain) NSString *foundScheme;
-
-@end

+ 0 - 111
SRWebSocketTests/SRTBonjourLocatorOperation.m

@@ -1,111 +0,0 @@
-//
-//  SRTBonjourLocatorOperation.m
-//  SocketRocket
-//
-//  Created by Mike Lewis on 1/28/12.
-//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
-//
-
-#import "SRTBonjourLocatorOperation.h"
-
-@interface SRTBonjourLocatorOperation () <NSNetServiceBrowserDelegate, NSNetServiceDelegate>
-
-@property (nonatomic, readonly) BOOL isCancelled;
-@property (nonatomic, readonly) BOOL isExecuting;
-@property (nonatomic, readonly) BOOL isFinished;
-
-@end
-
-@implementation SRTBonjourLocatorOperation {
-    NSMutableArray *_foundServices;
-    NSNetServiceBrowser *_serviceBrowser;
-    NSString *_key;
-}
-
-@synthesize isCancelled = _isCancelled;
-@synthesize isExecuting = _isExecuting;
-@synthesize isFinished = _isFinished;
-
-@synthesize foundService = _foundService;
-@synthesize foundScheme = _foundScheme;
-
-- (id)initWithKey:(NSString *)key {
-    self = [super init];
-    if (self) {
-        _foundServices = [[NSMutableArray alloc] init];
-        _serviceBrowser = [[NSNetServiceBrowser alloc] init];
-        _serviceBrowser.delegate = self;
-        _key = key;
-    }
-    return self;
-}
-
-- (void)dealloc
-{
-    for (NSNetService *service in _foundServices) {
-        service.delegate = nil;
-    }
-    
-    _serviceBrowser.delegate = nil;
-}
-
-- (void)start;
-{
-    [super start];
-    _isExecuting = YES;
-    [_serviceBrowser searchForServicesOfType:@"_autbahn_ws._tcp" inDomain:@""];
-}
-
-- (BOOL)isConcurrent
-{
-    return YES;
-}
-
-#pragma mark NSNetServiceBrowserDelegate
-
-- (void)netServiceBrowserDidStopSearch:(NSNetServiceBrowser *)aNetServiceBrowser;
-{
-    _isExecuting = NO;
-    _isFinished = YES;
-    NSLog(@"netServiceBrowserDidStopSearch stopped");
-}
-
-- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didNotSearch:(NSDictionary *)errorDict;
-{
-    _isExecuting = NO;
-    _isFinished = YES;
-    NSLog(@"NetServiceBrowser stopped");
-}
-
-- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didFindService:(NSNetService *)aNetService moreComing:(BOOL)moreComing;
-{
-    [_foundServices addObject:aNetService];
-    aNetService.delegate = self;
-    const float SRTResolveTimeout = 2.0f;
-    [aNetService resolveWithTimeout:SRTResolveTimeout];
-}
-
-#pragma mark NSNetServiceDelegate
-- (void)netService:(NSNetService *)sender didNotResolve:(NSDictionary *)errorDict;
-{
-    _isFinished = YES;
-    _isExecuting = NO;
-}
-
-- (void)netServiceDidResolveAddress:(NSNetService *)sender;
-{
-    if (!_isFinished) {
-        NSDictionary *txtRecordData = [NSNetService dictionaryFromTXTRecordData:sender.TXTRecordData];
-        NSString *scheme = [[NSString alloc] initWithData:[txtRecordData valueForKey:@"scheme"] encoding:NSUTF8StringEncoding];
-        NSString *key = [[NSString alloc] initWithData:[txtRecordData valueForKey:@"key"] encoding:NSUTF8StringEncoding];
-        
-        if ([key isEqualToString:_key]) {
-            _foundService = sender;
-            _foundScheme = scheme;
-
-            _isFinished = YES;
-            _isExecuting = NO;
-        }
-    }
-}
-@end

+ 0 - 8
SocketRocket.xcodeproj/project.pbxproj

@@ -13,8 +13,6 @@
 		F6016C8914620ECC0037BB3D /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6A12CD3145122FC00C1D980 /* Security.framework */; };
 		F6016C8A1462143C0037BB3D /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6A12CD51451231B00C1D980 /* CFNetwork.framework */; };
 		F60CC2A114D4EA0500A005E4 /* SRTWebSocketOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F60CC2A014D4EA0500A005E4 /* SRTWebSocketOperation.m */; };
-		F611322A14D4C4F2008A42D5 /* SRTBonjourLocatorOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = F611322814D4C4F2008A42D5 /* SRTBonjourLocatorOperation.h */; };
-		F62417D414D5073D003CE997 /* SRTBonjourLocatorOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F611322914D4C4F2008A42D5 /* SRTBonjourLocatorOperation.m */; };
 		F62417E614D52F3C003CE997 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F62417E514D52F3C003CE997 /* UIKit.framework */; };
 		F62417E714D52F3C003CE997 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6B208301450F597009315AF /* Foundation.framework */; };
 		F62417E914D52F3C003CE997 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F62417E814D52F3C003CE997 /* CoreGraphics.framework */; };
@@ -58,8 +56,6 @@
 		F6016C7E146124ED0037BB3D /* base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = base64.h; sourceTree = "<group>"; };
 		F60CC29F14D4EA0500A005E4 /* SRTWebSocketOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRTWebSocketOperation.h; sourceTree = "<group>"; };
 		F60CC2A014D4EA0500A005E4 /* SRTWebSocketOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRTWebSocketOperation.m; sourceTree = "<group>"; };
-		F611322814D4C4F2008A42D5 /* SRTBonjourLocatorOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRTBonjourLocatorOperation.h; sourceTree = "<group>"; };
-		F611322914D4C4F2008A42D5 /* SRTBonjourLocatorOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRTBonjourLocatorOperation.m; sourceTree = "<group>"; };
 		F62417E314D52F3C003CE997 /* TestChat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestChat.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		F62417E514D52F3C003CE997 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
 		F62417E814D52F3C003CE997 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
@@ -227,8 +223,6 @@
 				F6BDA810145900D200FE3253 /* SRWebSocketTests-Prefix.pch */,
 				F6AE4526145907D30022AF3C /* SenTestCase+SRTAdditions.h */,
 				F6AE4527145907D30022AF3C /* SenTestCase+SRTAdditions.m */,
-				F611322814D4C4F2008A42D5 /* SRTBonjourLocatorOperation.h */,
-				F611322914D4C4F2008A42D5 /* SRTBonjourLocatorOperation.m */,
 				F60CC29F14D4EA0500A005E4 /* SRTWebSocketOperation.h */,
 				F60CC2A014D4EA0500A005E4 /* SRTWebSocketOperation.m */,
 			);
@@ -253,7 +247,6 @@
 			files = (
 				F6A12CD1145119B700C1D980 /* SRWebSocket.h in Headers */,
 				F6016C7F146124ED0037BB3D /* base64.h in Headers */,
-				F611322A14D4C4F2008A42D5 /* SRTBonjourLocatorOperation.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -405,7 +398,6 @@
 				F6BDA8161459016900FE3253 /* SRTAutobahnTests.m in Sources */,
 				F6AE4528145907D30022AF3C /* SenTestCase+SRTAdditions.m in Sources */,
 				F60CC2A114D4EA0500A005E4 /* SRTWebSocketOperation.m in Sources */,
-				F62417D414D5073D003CE997 /* SRTBonjourLocatorOperation.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

+ 2 - 2
SocketRocket.xcodeproj/xcshareddata/xcschemes/SocketRocket.xcscheme

@@ -87,8 +87,8 @@
       </MacroExpansion>
       <EnvironmentVariables>
          <EnvironmentVariable
-            key = "SR_TESTHARNESS_KEY"
-            value = "hello_test_harness"
+            key = "SR_TEST_URL"
+            value = "ws://localhost:9001"
             isEnabled = "YES">
          </EnvironmentVariable>
       </EnvironmentVariables>