earlgrey 1.13.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/earlgrey/cli.rb +1 -1
- data/lib/earlgrey/configure_earlgrey.rb +4 -4
- data/lib/earlgrey/extensions/earlgrey_yaml.rb +1 -1
- data/lib/earlgrey/files/Swift-3.0/EarlGrey.swift +22 -48
- data/lib/earlgrey/files/Swift-4.0/EarlGrey.swift +188 -0
- data/lib/earlgrey/version.rb +1 -1
- metadata +4 -4
- data/lib/earlgrey/files/Swift-2.3/EarlGrey.swift +0 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b0fd78736a6bd318523f914889b82f8d73bcc0ef05ab43df222bb5606de0693e
|
4
|
+
data.tar.gz: 626a0e999f96bcd70e1083bd50866b271219d5862f6826275e9efaf123398f63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4980ec74cb857edf363a0a034dbd750adeb6a2e4f2bf2e854299e9b939a5fa19d8634e9ab379dab7b5079e07ea375f102b903f9450e1620abf4fafcb66591869
|
7
|
+
data.tar.gz: d4fe8be26881f0860e95f70e2a668e9bdb46a2a9abc52c9b7a5ef7de3fad80385ae3675c03545d2a87703cc7f83ffff6b91084475e94c9b29f4ce131198cd33e
|
data/lib/earlgrey/cli.rb
CHANGED
@@ -23,7 +23,7 @@ module EarlGrey
|
|
23
23
|
method_option :project, aliases: '-p', type: :string, required: false, desc: 'Project'
|
24
24
|
method_option :scheme, aliases: '-s', type: :string, required: false, desc: 'EarlGreyTestTarget.xcscheme'
|
25
25
|
method_option :swift, type: :boolean, default: true
|
26
|
-
method_option :swift_version, type: :string, default: '
|
26
|
+
method_option :swift_version, type: :string, default: '4.0', enum: %w[3.0 4.0]
|
27
27
|
method_option :target, aliases: '-t', type: :string, required: true, desc: 'EarlGreyTestTarget'
|
28
28
|
|
29
29
|
PROJECT = 'project'.freeze
|
@@ -105,7 +105,7 @@ module EarlGrey
|
|
105
105
|
def set_defaults(project_name, test_target_name, scheme_file, opts = {})
|
106
106
|
@swift = opts.fetch(:swift, false)
|
107
107
|
@carthage = opts.fetch(:carthage, false)
|
108
|
-
@swift_version = opts.fetch(:swift_version, '
|
108
|
+
@swift_version = opts.fetch(:swift_version, '4.0')
|
109
109
|
|
110
110
|
puts_magenta "Checking and Updating #{project_name} for EarlGrey."
|
111
111
|
project_file = path_for project_name, '.xcodeproj'
|
@@ -368,7 +368,7 @@ module EarlGrey
|
|
368
368
|
|
369
369
|
raise "Test target group not found! #{test_target_group}" unless test_target_group
|
370
370
|
|
371
|
-
swift_version ||= '
|
371
|
+
swift_version ||= '4.0'
|
372
372
|
src_root = File.join(__dir__, 'files')
|
373
373
|
dst_root = test_target_group.real_path
|
374
374
|
raise "Missing target folder #{dst_root}" unless File.exist? dst_root
|
@@ -378,8 +378,8 @@ module EarlGrey
|
|
378
378
|
|
379
379
|
unless File.exist? src_swift
|
380
380
|
puts_magenta "EarlGrey.swift for version #{swift_version} not found. " \
|
381
|
-
'Falling back to version
|
382
|
-
swift_fallback = 'Swift-
|
381
|
+
'Falling back to version 4.0.'
|
382
|
+
swift_fallback = 'Swift-4.0'
|
383
383
|
src_swift = File.join(src_root, swift_fallback, src_swift_name)
|
384
384
|
raise "Unable to locate #{swift_fallback} file at path #{src_swift}." unless File.exist?(src_swift)
|
385
385
|
end
|
@@ -5,7 +5,7 @@ class EarlGreyYaml
|
|
5
5
|
|
6
6
|
def initialize(analyzer, podfile)
|
7
7
|
@analyzer = analyzer
|
8
|
-
earlgrey_yml_path = File.join(File.dirname(podfile.defined_in_file), 'earlgrey_gem.yml')
|
8
|
+
earlgrey_yml_path = File.join(File.dirname(podfile.defined_in_file.to_s), 'earlgrey_gem.yml')
|
9
9
|
|
10
10
|
@earlgrey_yml = {}
|
11
11
|
@earlgrey_yml = YAML.safe_load(File.read(earlgrey_yml_path)) if File.exist?(earlgrey_yml_path)
|
@@ -48,15 +48,17 @@ public func GREYAssertNotEqual(_ left: @autoclosure () -> AnyObject?,
|
|
48
48
|
}
|
49
49
|
|
50
50
|
public func GREYAssertEqualObjects<T: Equatable>( _ left: @autoclosure () -> T?,
|
51
|
-
_ right: @autoclosure () -> T?,
|
52
|
-
|
53
|
-
|
51
|
+
_ right: @autoclosure () -> T?,
|
52
|
+
reason: String) {
|
53
|
+
GREYAssert(left() == right(), reason, details: "Expected object of the left term to be equal " +
|
54
|
+
"to the object of the right term")
|
54
55
|
}
|
55
56
|
|
56
57
|
public func GREYAssertNotEqualObjects<T: Equatable>( _ left: @autoclosure () -> T?,
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
_ right: @autoclosure () -> T?,
|
59
|
+
reason: String) {
|
60
|
+
GREYAssert(left() != right(), reason, details: "Expected object of the left term to not " +
|
61
|
+
"equal the object of the right term")
|
60
62
|
}
|
61
63
|
|
62
64
|
public func GREYFail(_ reason: String) {
|
@@ -97,34 +99,26 @@ private func GREYWaitUntilIdle() {
|
|
97
99
|
}
|
98
100
|
|
99
101
|
open class EarlGrey: NSObject {
|
100
|
-
public static func selectElement(with matcher: GREYMatcher,
|
101
|
-
file: StaticString = #file,
|
102
|
-
line: UInt = #line) -> GREYInteraction {
|
103
|
-
return EarlGreyImpl.invoked(fromFile: file.description, lineNumber: line)
|
104
|
-
.selectElement(with: matcher)
|
105
|
-
}
|
106
|
-
|
107
|
-
@available(*, deprecated, renamed: "selectElement(with:)")
|
108
102
|
open class func select(elementWithMatcher matcher:GREYMatcher,
|
109
103
|
file: StaticString = #file,
|
110
104
|
line: UInt = #line) -> GREYElementInteraction {
|
111
105
|
return EarlGreyImpl.invoked(fromFile: file.description, lineNumber: line)
|
112
|
-
|
106
|
+
.selectElement(with: matcher)
|
113
107
|
}
|
114
108
|
|
115
109
|
open class func setFailureHandler(handler: GREYFailureHandler,
|
116
|
-
|
117
|
-
|
110
|
+
file: StaticString = #file,
|
111
|
+
line: UInt = #line) {
|
118
112
|
return EarlGreyImpl.invoked(fromFile: file.description, lineNumber: line)
|
119
|
-
|
113
|
+
.setFailureHandler(handler)
|
120
114
|
}
|
121
115
|
|
122
116
|
open class func handle(exception: GREYFrameworkException,
|
123
|
-
|
124
|
-
|
125
|
-
|
117
|
+
details: String,
|
118
|
+
file: StaticString = #file,
|
119
|
+
line: UInt = #line) {
|
126
120
|
return EarlGreyImpl.invoked(fromFile: file.description, lineNumber: line)
|
127
|
-
|
121
|
+
.handle(exception, details: details)
|
128
122
|
}
|
129
123
|
|
130
124
|
@discardableResult open class func rotateDeviceTo(orientation: UIDeviceOrientation,
|
@@ -132,40 +126,20 @@ open class EarlGrey: NSObject {
|
|
132
126
|
file: StaticString = #file,
|
133
127
|
line: UInt = #line)
|
134
128
|
-> Bool {
|
135
|
-
|
136
|
-
|
137
|
-
|
129
|
+
return EarlGreyImpl.invoked(fromFile: file.description, lineNumber: line)
|
130
|
+
.rotateDevice(to: orientation,
|
131
|
+
errorOrNil: errorOrNil)
|
138
132
|
}
|
139
133
|
}
|
140
134
|
|
141
135
|
extension GREYInteraction {
|
142
136
|
@discardableResult public func assert(_ matcher: @autoclosure () -> GREYMatcher) -> Self {
|
143
|
-
return self.
|
137
|
+
return self.assert(with:matcher())
|
144
138
|
}
|
145
139
|
|
146
140
|
@discardableResult public func assert(_ matcher: @autoclosure () -> GREYMatcher,
|
147
141
|
error:UnsafeMutablePointer<NSError?>!) -> Self {
|
148
|
-
return self.
|
149
|
-
}
|
150
|
-
|
151
|
-
@available(*, deprecated, renamed: "assert(_:)")
|
152
|
-
@discardableResult public func assert(with matcher: GREYMatcher!) -> Self {
|
153
|
-
return self.__assert(with: matcher)
|
154
|
-
}
|
155
|
-
|
156
|
-
@available(*, deprecated, renamed: "assert(_:error:)")
|
157
|
-
@discardableResult public func assert(with matcher: GREYMatcher!,
|
158
|
-
error:UnsafeMutablePointer<NSError?>!) -> Self {
|
159
|
-
return self.__assert(with: matcher, error: error)
|
160
|
-
}
|
161
|
-
|
162
|
-
@discardableResult public func perform(_ action: GREYAction!) -> Self {
|
163
|
-
return self.__perform(action)
|
164
|
-
}
|
165
|
-
|
166
|
-
@discardableResult public func perform(_ action: GREYAction!,
|
167
|
-
error:UnsafeMutablePointer<NSError?>!) -> Self {
|
168
|
-
return self.__perform(action, error: error)
|
142
|
+
return self.assert(with: matcher(), error: error)
|
169
143
|
}
|
170
144
|
|
171
145
|
@discardableResult public func using(searchAction: GREYAction,
|
@@ -181,6 +155,6 @@ extension GREYCondition {
|
|
181
155
|
|
182
156
|
open func waitWithTimeout(seconds: CFTimeInterval, pollInterval: CFTimeInterval)
|
183
157
|
-> Bool {
|
184
|
-
|
158
|
+
return self.wait(withTimeout: seconds, pollInterval: pollInterval)
|
185
159
|
}
|
186
160
|
}
|
@@ -0,0 +1,188 @@
|
|
1
|
+
//
|
2
|
+
// Copyright 2018 Google Inc.
|
3
|
+
//
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
// you may not use this file except in compliance with the License.
|
6
|
+
// You may obtain a copy of the License at
|
7
|
+
//
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
//
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
// See the License for the specific language governing permissions and
|
14
|
+
// limitations under the License.
|
15
|
+
//
|
16
|
+
|
17
|
+
import EarlGrey
|
18
|
+
import Foundation
|
19
|
+
|
20
|
+
public func GREYAssert(_ expression: @autoclosure () -> Bool, reason: String) {
|
21
|
+
GREYAssert(expression, reason, details: "Expected expression to be true")
|
22
|
+
}
|
23
|
+
|
24
|
+
public func GREYAssertTrue(_ expression: @autoclosure () -> Bool, reason: String) {
|
25
|
+
GREYAssert(expression(), reason, details: "Expected the boolean expression to be true")
|
26
|
+
}
|
27
|
+
|
28
|
+
public func GREYAssertFalse(_ expression: @autoclosure () -> Bool, reason: String) {
|
29
|
+
GREYAssert(!expression(), reason, details: "Expected the boolean expression to be false")
|
30
|
+
}
|
31
|
+
|
32
|
+
public func GREYAssertNotNil(_ expression: @autoclosure ()-> Any?, reason: String) {
|
33
|
+
GREYAssert(expression() != nil, reason, details: "Expected expression to be not nil")
|
34
|
+
}
|
35
|
+
|
36
|
+
public func GREYAssertNil(_ expression: @autoclosure () -> Any?, reason: String) {
|
37
|
+
GREYAssert(expression() == nil, reason, details: "Expected expression to be nil")
|
38
|
+
}
|
39
|
+
|
40
|
+
public func GREYAssertEqual(_ left: @autoclosure () -> AnyObject?,
|
41
|
+
_ right: @autoclosure () -> AnyObject?, reason: String) {
|
42
|
+
GREYAssert(left() === right(), reason, details: "Expected left term to be equal to right term")
|
43
|
+
}
|
44
|
+
|
45
|
+
public func GREYAssertNotEqual(_ left: @autoclosure () -> AnyObject?,
|
46
|
+
_ right: @autoclosure () -> AnyObject?, reason: String) {
|
47
|
+
GREYAssert(left() !== right(), reason, details: "Expected left term to not equal the right term")
|
48
|
+
}
|
49
|
+
|
50
|
+
public func GREYAssertEqualObjects<T: Equatable>( _ left: @autoclosure () -> T?,
|
51
|
+
_ right: @autoclosure () -> T?,
|
52
|
+
reason: String) {
|
53
|
+
GREYAssert(left() == right(), reason, details: "Expected object of the left term to be equal " +
|
54
|
+
"to the object of the right term")
|
55
|
+
}
|
56
|
+
|
57
|
+
public func GREYAssertNotEqualObjects<T: Equatable>( _ left: @autoclosure () -> T?,
|
58
|
+
_ right: @autoclosure () -> T?,
|
59
|
+
reason: String) {
|
60
|
+
GREYAssert(left() != right(), reason, details: "Expected object of the left term to not " +
|
61
|
+
"equal the object of the right term")
|
62
|
+
}
|
63
|
+
|
64
|
+
public func GREYFail(_ reason: String) {
|
65
|
+
EarlGrey.handle(exception: GREYFrameworkException(name: kGREYAssertionFailedException,
|
66
|
+
reason: reason),
|
67
|
+
details: "")
|
68
|
+
}
|
69
|
+
|
70
|
+
public func GREYFailWithDetails(_ reason: String, details: String) {
|
71
|
+
EarlGrey.handle(exception: GREYFrameworkException(name: kGREYAssertionFailedException,
|
72
|
+
reason: reason),
|
73
|
+
details: details)
|
74
|
+
}
|
75
|
+
|
76
|
+
private func GREYAssert(_ expression: @autoclosure () -> Bool,
|
77
|
+
_ reason: String, details: String) {
|
78
|
+
GREYSetCurrentAsFailable()
|
79
|
+
GREYWaitUntilIdle()
|
80
|
+
if !expression() {
|
81
|
+
EarlGrey.handle(exception: GREYFrameworkException(name: kGREYAssertionFailedException,
|
82
|
+
reason: reason),
|
83
|
+
details: details)
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
private func GREYSetCurrentAsFailable() {
|
88
|
+
let greyFailureHandlerSelector =
|
89
|
+
#selector(GREYFailureHandler.setInvocationFile(_:andInvocationLine:))
|
90
|
+
let greyFailureHandler =
|
91
|
+
Thread.current.threadDictionary.value(forKey: kGREYFailureHandlerKey) as! GREYFailureHandler
|
92
|
+
if greyFailureHandler.responds(to: greyFailureHandlerSelector) {
|
93
|
+
greyFailureHandler.setInvocationFile!(#file, andInvocationLine:#line)
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
private func GREYWaitUntilIdle() {
|
98
|
+
GREYUIThreadExecutor.sharedInstance().drainUntilIdle()
|
99
|
+
}
|
100
|
+
|
101
|
+
open class EarlGrey: NSObject {
|
102
|
+
public static func selectElement(with matcher: GREYMatcher,
|
103
|
+
file: StaticString = #file,
|
104
|
+
line: UInt = #line) -> GREYInteraction {
|
105
|
+
return EarlGreyImpl.invoked(fromFile: file.description, lineNumber: line)
|
106
|
+
.selectElement(with: matcher)
|
107
|
+
}
|
108
|
+
|
109
|
+
@available(*, deprecated, renamed: "selectElement(with:)")
|
110
|
+
open class func select(elementWithMatcher matcher:GREYMatcher,
|
111
|
+
file: StaticString = #file,
|
112
|
+
line: UInt = #line) -> GREYElementInteraction {
|
113
|
+
return EarlGreyImpl.invoked(fromFile: file.description, lineNumber: line)
|
114
|
+
.selectElement(with: matcher)
|
115
|
+
}
|
116
|
+
|
117
|
+
open class func setFailureHandler(handler: GREYFailureHandler,
|
118
|
+
file: StaticString = #file,
|
119
|
+
line: UInt = #line) {
|
120
|
+
return EarlGreyImpl.invoked(fromFile: file.description, lineNumber: line)
|
121
|
+
.setFailureHandler(handler)
|
122
|
+
}
|
123
|
+
|
124
|
+
open class func handle(exception: GREYFrameworkException,
|
125
|
+
details: String,
|
126
|
+
file: StaticString = #file,
|
127
|
+
line: UInt = #line) {
|
128
|
+
return EarlGreyImpl.invoked(fromFile: file.description, lineNumber: line)
|
129
|
+
.handle(exception, details: details)
|
130
|
+
}
|
131
|
+
|
132
|
+
@discardableResult open class func rotateDeviceTo(orientation: UIDeviceOrientation,
|
133
|
+
errorOrNil: UnsafeMutablePointer<NSError?>!,
|
134
|
+
file: StaticString = #file,
|
135
|
+
line: UInt = #line)
|
136
|
+
-> Bool {
|
137
|
+
return EarlGreyImpl.invoked(fromFile: file.description, lineNumber: line)
|
138
|
+
.rotateDevice(to: orientation,
|
139
|
+
errorOrNil: errorOrNil)
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
extension GREYInteraction {
|
144
|
+
@discardableResult public func assert(_ matcher: @autoclosure () -> GREYMatcher) -> Self {
|
145
|
+
return self.__assert(with: matcher())
|
146
|
+
}
|
147
|
+
|
148
|
+
@discardableResult public func assert(_ matcher: @autoclosure () -> GREYMatcher,
|
149
|
+
error:UnsafeMutablePointer<NSError?>!) -> Self {
|
150
|
+
return self.__assert(with: matcher(), error: error)
|
151
|
+
}
|
152
|
+
|
153
|
+
@available(*, deprecated, renamed: "assert(_:)")
|
154
|
+
@discardableResult public func assert(with matcher: GREYMatcher!) -> Self {
|
155
|
+
return self.__assert(with: matcher)
|
156
|
+
}
|
157
|
+
|
158
|
+
@available(*, deprecated, renamed: "assert(_:error:)")
|
159
|
+
@discardableResult public func assert(with matcher: GREYMatcher!,
|
160
|
+
error:UnsafeMutablePointer<NSError?>!) -> Self {
|
161
|
+
return self.__assert(with: matcher, error: error)
|
162
|
+
}
|
163
|
+
|
164
|
+
@discardableResult public func perform(_ action: GREYAction!) -> Self {
|
165
|
+
return self.__perform(action)
|
166
|
+
}
|
167
|
+
|
168
|
+
@discardableResult public func perform(_ action: GREYAction!,
|
169
|
+
error:UnsafeMutablePointer<NSError?>!) -> Self {
|
170
|
+
return self.__perform(action, error: error)
|
171
|
+
}
|
172
|
+
|
173
|
+
@discardableResult public func using(searchAction: GREYAction,
|
174
|
+
onElementWithMatcher matcher: GREYMatcher) -> Self {
|
175
|
+
return self.usingSearch(searchAction, onElementWith: matcher)
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
extension GREYCondition {
|
180
|
+
open func waitWithTimeout(seconds: CFTimeInterval) -> Bool {
|
181
|
+
return self.wait(withTimeout: seconds)
|
182
|
+
}
|
183
|
+
|
184
|
+
open func waitWithTimeout(seconds: CFTimeInterval, pollInterval: CFTimeInterval)
|
185
|
+
-> Bool {
|
186
|
+
return self.wait(withTimeout: seconds, pollInterval: pollInterval)
|
187
|
+
}
|
188
|
+
}
|
data/lib/earlgrey/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: earlgrey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khandpur
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-
|
14
|
+
date: 2018-05-31 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: colored
|
@@ -127,8 +127,8 @@ files:
|
|
127
127
|
- lib/earlgrey/extensions/aggregate_target_extensions.rb
|
128
128
|
- lib/earlgrey/extensions/analyzer_extensions.rb
|
129
129
|
- lib/earlgrey/extensions/earlgrey_yaml.rb
|
130
|
-
- lib/earlgrey/files/Swift-2.3/EarlGrey.swift
|
131
130
|
- lib/earlgrey/files/Swift-3.0/EarlGrey.swift
|
131
|
+
- lib/earlgrey/files/Swift-4.0/EarlGrey.swift
|
132
132
|
- lib/earlgrey/version.rb
|
133
133
|
homepage: https://github.com/google/EarlGrey
|
134
134
|
licenses:
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
152
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.
|
153
|
+
rubygems_version: 2.7.6
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: EarlGrey installer gem
|
@@ -1,115 +0,0 @@
|
|
1
|
-
//
|
2
|
-
// Copyright 2016 Google Inc.
|
3
|
-
//
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
// you may not use this file except in compliance with the License.
|
6
|
-
// You may obtain a copy of the License at
|
7
|
-
//
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
//
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
// See the License for the specific language governing permissions and
|
14
|
-
// limitations under the License.
|
15
|
-
//
|
16
|
-
|
17
|
-
import EarlGrey
|
18
|
-
import Foundation
|
19
|
-
|
20
|
-
let greyFailureHandler =
|
21
|
-
NSThread.currentThread().threadDictionary
|
22
|
-
.valueForKey(kGREYFailureHandlerKey) as! GREYFailureHandler
|
23
|
-
|
24
|
-
public func EarlGrey(file: String = #file, line: UInt = #line) -> EarlGreyImpl! {
|
25
|
-
return EarlGreyImpl.invokedFromFile(file, lineNumber: line)
|
26
|
-
}
|
27
|
-
|
28
|
-
public func GREYAssert(@autoclosure expression: () -> BooleanType, reason: String) {
|
29
|
-
GREYAssert(expression, reason, details: "Expected expression to be true")
|
30
|
-
}
|
31
|
-
|
32
|
-
public func GREYAssertTrue(@autoclosure expression: () -> BooleanType, reason: String) {
|
33
|
-
GREYAssert(expression().boolValue,
|
34
|
-
reason,
|
35
|
-
details: "Expected the boolean expression to be true")
|
36
|
-
}
|
37
|
-
|
38
|
-
public func GREYAssertFalse(@autoclosure expression: () -> BooleanType, reason: String) {
|
39
|
-
GREYAssert(!expression().boolValue,
|
40
|
-
reason,
|
41
|
-
details: "Expected the boolean expression to be false")
|
42
|
-
}
|
43
|
-
|
44
|
-
public func GREYAssertNotNil(@autoclosure expression: () -> Any?, reason: String) {
|
45
|
-
GREYAssert(expression() != nil, reason, details: "Expected expression to be not nil")
|
46
|
-
}
|
47
|
-
|
48
|
-
public func GREYAssertNil(@autoclosure expression: () -> Any?, reason: String) {
|
49
|
-
GREYAssert(expression() == nil, reason, details: "Expected expression to be nil")
|
50
|
-
}
|
51
|
-
|
52
|
-
public func GREYAssertEqual(@autoclosure left: () -> AnyObject?,
|
53
|
-
@autoclosure _ right: () -> AnyObject?, reason: String) {
|
54
|
-
GREYAssert(left() === right(), reason, details: "Expected left term to be equal to right term")
|
55
|
-
}
|
56
|
-
|
57
|
-
public func GREYAssertNotEqual(@autoclosure left: () -> AnyObject?,
|
58
|
-
@autoclosure _ right: () -> AnyObject?, reason: String) {
|
59
|
-
GREYAssert(left() !== right(), reason, details: "Expected left term to not be equal to right" +
|
60
|
-
" term")
|
61
|
-
}
|
62
|
-
|
63
|
-
public func GREYAssertEqualObjects<T : Equatable>(@autoclosure left: () -> T?,
|
64
|
-
@autoclosure _ right: () -> T?, reason: String) {
|
65
|
-
GREYAssert(left() == right(), reason, details: "Expected object of the left term to be equal" +
|
66
|
-
" to the object of the right term")
|
67
|
-
}
|
68
|
-
|
69
|
-
public func GREYAssertNotEqualObjects<T : Equatable>(@autoclosure left: () -> T?,
|
70
|
-
@autoclosure _ right: () -> T?, reason: String) {
|
71
|
-
GREYAssert(left() != right(), reason, details: "Expected object of the left term to not be" +
|
72
|
-
" equal to the object of the right term")
|
73
|
-
}
|
74
|
-
|
75
|
-
public func GREYFail(reason: String) {
|
76
|
-
greyFailureHandler.handleException(GREYFrameworkException(name: kGREYAssertionFailedException,
|
77
|
-
reason: reason),
|
78
|
-
details: "")
|
79
|
-
}
|
80
|
-
|
81
|
-
@available(*, deprecated=1.2.0, message="Please use GREYFAIL::withDetails instead.")
|
82
|
-
public func GREYFail(reason: String, details: String) {
|
83
|
-
greyFailureHandler.handleException(GREYFrameworkException(name: kGREYAssertionFailedException,
|
84
|
-
reason: reason),
|
85
|
-
details: details)
|
86
|
-
}
|
87
|
-
|
88
|
-
public func GREYFailWithDetails(reason: String, details: String) {
|
89
|
-
greyFailureHandler.handleException(GREYFrameworkException(name: kGREYAssertionFailedException,
|
90
|
-
reason: reason),
|
91
|
-
details: details)
|
92
|
-
}
|
93
|
-
|
94
|
-
private func GREYAssert(@autoclosure expression: () -> BooleanType,
|
95
|
-
_ reason: String, details: String) {
|
96
|
-
GREYSetCurrentAsFailable()
|
97
|
-
GREYWaitUntilIdle()
|
98
|
-
if !expression().boolValue {
|
99
|
-
greyFailureHandler.handleException(GREYFrameworkException(name: kGREYAssertionFailedException,
|
100
|
-
reason: reason),
|
101
|
-
details: details)
|
102
|
-
}
|
103
|
-
}
|
104
|
-
|
105
|
-
private func GREYWaitUntilIdle() {
|
106
|
-
GREYUIThreadExecutor.sharedInstance().drainUntilIdle()
|
107
|
-
}
|
108
|
-
|
109
|
-
private func GREYSetCurrentAsFailable(file: String = #file, line: UInt = #line) {
|
110
|
-
let greyFailureHandlerSelector =
|
111
|
-
#selector(GREYFailureHandler.setInvocationFile(_:andInvocationLine:))
|
112
|
-
if greyFailureHandler.respondsToSelector(greyFailureHandlerSelector) {
|
113
|
-
greyFailureHandler.setInvocationFile!(file, andInvocationLine: line)
|
114
|
-
}
|
115
|
-
}
|