-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make more Selector
properties work on iOS
#2030
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
75efe19
start
bartekpacia 30b4ef4
small progress
bartekpacia 909d7f6
add extension `toNSPredicate()` on `Selector`
bartekpacia 35ba9fa
more progress
bartekpacia 62cd0e0
implement toNSPredicate and test it
fylyppo d87314c
Merge branch 'master' of github.com:leancodepl/patrol into feature/io…
piotruela d891347
Format swift code
piotruela 7ab42bb
Merge branch 'master' of github.com:leancodepl/patrol into feature/io…
piotruela 4526fd0
Update patrol dependency
piotruela 7f765ce
Update pods version
piotruela 01999dc
Make textStartsWith and textContains work in more methods on iOS
piotruela 88e1246
Format code
piotruela b805128
Update enterText to work with textStartsWith and textContains
piotruela ac5e907
Update macos protocol implementation
piotruela 2c3f457
Add tests for native Selector methods on iOS
piotruela 6ef3a0a
Remove incorrect TODO
piotruela fa164fa
Add comment explaining weird behavior of ios_selector_test.dart
piotruela 9701ebb
Merge branch 'master' of github.com:leancodepl/patrol into feature/io…
piotruela 1bb4985
Format swift code
piotruela cfdfe20
Remove flaky ios selector tests
3688294
Hide extension behind PATROL_ENABLED
zltnDC b0605d3
Make darwin contracts public
zltnDC f4314ab
Fix tests
zltnDC 8aeb56c
Merge branch 'master' into feature/ios_text_startswith_endswith
zltnDC 5d87802
Fix swift format
zltnDC 8c93fd8
Unhide Selector extension
zltnDC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,114 @@ | ||
import XCTest | ||
import patrol | ||
|
||
typealias Selector = patrol.Selector | ||
|
||
final class RunnerTests: XCTestCase { | ||
func testSample() { | ||
// This test is here to serve as a sample for more tests in the future | ||
XCTAssertEqual(2 + 2, 4) | ||
} | ||
|
||
func testSelectorToNSPredicate_text() { | ||
var selector = createEmptySelector() | ||
selector.text = "Log in" | ||
|
||
let predicate = selector.toNSPredicate() | ||
|
||
NSLog(predicate.predicateFormat) | ||
XCTAssertEqual( | ||
predicate.predicateFormat, | ||
""" | ||
label == "Log in" OR \ | ||
title == "Log in" | ||
""") | ||
} | ||
|
||
func testSelectorToNSPredicate_textStartsWith() { | ||
var selector = createEmptySelector() | ||
selector.textStartsWith = "Log in" | ||
|
||
let predicate = selector.toNSPredicate() | ||
|
||
NSLog(predicate.predicateFormat) | ||
XCTAssertEqual( | ||
predicate.predicateFormat, | ||
""" | ||
label BEGINSWITH "Log in" OR \ | ||
title BEGINSWITH "Log in" | ||
""") | ||
} | ||
|
||
func testSelectorToNSPredicate_textContains() { | ||
var selector = createEmptySelector() | ||
selector.textContains = "Log in" | ||
|
||
let predicate = selector.toNSPredicate() | ||
|
||
NSLog(predicate.predicateFormat) | ||
XCTAssertEqual( | ||
predicate.predicateFormat, | ||
""" | ||
label CONTAINS "Log in" OR \ | ||
title CONTAINS "Log in" | ||
""") | ||
} | ||
|
||
func testSelectorToNSPredicate_resourceId() { | ||
var selector = createEmptySelector() | ||
selector.resourceId = "log_in" | ||
|
||
let predicate = selector.toNSPredicate() | ||
|
||
NSLog(predicate.predicateFormat) | ||
XCTAssertEqual( | ||
predicate.predicateFormat, | ||
""" | ||
identifier == "log_in" | ||
""") | ||
} | ||
|
||
func testSelectorToNSPredicate_complex_1() { | ||
var selector = createEmptySelector() | ||
selector.textContains = "text_contains" | ||
selector.resourceId = "resource_id" | ||
|
||
let predicate = selector.toNSPredicate() | ||
|
||
NSLog(predicate.predicateFormat) | ||
XCTAssertEqual( | ||
predicate.predicateFormat, | ||
""" | ||
(label CONTAINS "text_contains" OR \ | ||
title CONTAINS "text_contains") AND \ | ||
identifier == "resource_id" | ||
""") | ||
} | ||
|
||
func testSelectorToNSPredicate_complex_2() { | ||
var selector = createEmptySelector() | ||
selector.textContains = "text_contains" | ||
selector.resourceId = "resource_id" | ||
|
||
let predicate = selector.toNSPredicate() | ||
|
||
NSLog(predicate.predicateFormat) | ||
XCTAssertEqual( | ||
predicate.predicateFormat, | ||
""" | ||
(label CONTAINS "text_contains" OR \ | ||
title CONTAINS "text_contains") AND \ | ||
identifier == "resource_id" | ||
""") | ||
} | ||
} | ||
|
||
private func createEmptySelector(text: String? = nil) -> patrol.Selector { | ||
// Temporary fix. We will remove the Selector class later | ||
let jsonString = "{}" | ||
|
||
let jsonData = jsonString.data(using: .utf8)! | ||
let decoder = JSONDecoder() | ||
|
||
return try! decoder.decode(patrol.Selector.self, from: jsonData) | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This extension should be rather below #if PATROL_ENABLED.