This repository has been archived by the owner on Dec 26, 2019. It is now read-only.
Use NSProxy as base class for FBApplicationProcessProxy #979
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
WebDriverAgentTests/UnitTests/FBApplicationProcessProxyTests.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#import <XCTest/XCTest.h> | ||
#import "FBApplicationProcessProxy.h" | ||
#import "XCUIApplicationProcess.h" | ||
|
||
@interface FBApplicationProcessProxy (NonProxiedMethod) | ||
- (void)objectsMethod; | ||
@end | ||
|
||
@implementation FBApplicationProcessProxy (NonProxiedMethod) | ||
|
||
- (void)objectsMethod | ||
{ | ||
// intentionally empty | ||
} | ||
|
||
@end | ||
|
||
@interface FBApplicationProcessProxy (ProxiedMethod) | ||
- (int)proxiedMethod; | ||
@end | ||
|
||
@interface XCUIApplicationProcess (TestableMethods) | ||
- (void)objectsMethod; | ||
- (int)proxiedMethod; | ||
@end | ||
|
||
@implementation XCUIApplicationProcess (TestableMethods) | ||
|
||
- (int)proxiedMethod; | ||
{ | ||
return 1; | ||
} | ||
|
||
- (void)objectsMethod | ||
{ | ||
NSString *errorMessage = [NSString stringWithFormat:@"Method %@ must NOT be proxied", NSStringFromSelector(_cmd)]; | ||
NSException * exception = [[NSException alloc] initWithName:@"Test failed" reason:errorMessage userInfo:nil]; | ||
[exception raise]; | ||
} | ||
|
||
@end | ||
|
||
@interface FBApplicationProcessProxyTest : XCTestCase | ||
|
||
@end | ||
|
||
@implementation FBApplicationProcessProxyTest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
|
||
- (void)testMethodCallIsProxied { | ||
XCUIApplicationProcess *applicationProcess = [[XCUIApplicationProcess alloc] init]; | ||
FBApplicationProcessProxy *proxy = [FBApplicationProcessProxy proxyWithApplicationProcess:applicationProcess]; | ||
XCTAssertEqual([proxy proxiedMethod], 1); | ||
} | ||
|
||
- (void)testMethodCallIsNotProxied { | ||
XCUIApplicationProcess *applicationProcess = [[XCUIApplicationProcess alloc] init]; | ||
FBApplicationProcessProxy *proxy = [FBApplicationProcessProxy proxyWithApplicationProcess:applicationProcess]; | ||
XCTAssertNoThrow([proxy objectsMethod]); | ||
} | ||
|
||
- (void)testProxyIsProxy { | ||
XCUIApplicationProcess *applicationProcess = [[XCUIApplicationProcess alloc] init]; | ||
FBApplicationProcessProxy *proxy = [FBApplicationProcessProxy proxyWithApplicationProcess:applicationProcess]; | ||
XCTAssertTrue([proxy isProxy]); | ||
} | ||
|
||
- (void)testAssertProxyObjectParameter { | ||
XCUIApplicationProcess *applicationProcess = [[XCUIApplicationProcess alloc] init]; | ||
id proxy = (id)[FBApplicationProcessProxy proxyWithApplicationProcess:applicationProcess]; | ||
XCTAssertThrows([FBApplicationProcessProxy proxyWithApplicationProcess:proxy]); | ||
} | ||
|
||
@end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
Sorry, something went wrong.