mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-01-12 22:51:55 +08:00
fix a bug where #tap and #rotate_device cause a crash with "rake spec" on x86_64
http://hipbyte.myjetbrains.com/youtrack/issue/RM-654 The spec helper uses the following methods of UIAutomation. sendTaps and setOrientation has same method signature in i386 and x86_64. 318: _event_generator.setOrientation(orientation) 325: _event_generator.sendAccelerometerX(options[:x], Y:options[:y], Z:options[:z], duration:duration) 330: _event_generator.shake 341: _event_generator.sendTaps(taps, 356: _event_generator.sendFlickWithStartPoint(from, endPoint:to, duration:duration) 371: _event_generator.sendPinchOpenWithStartPoint(from, endPoint:to, duration:duration) 385: _event_generator.sendPinchCloseWithStartPoint(from, endPoint:to, duration:duration) 406: _event_generator.touchDown(points.first) 409: _event_generator._moveLastTouchPoint(point) 412: _event_generator.liftUp(points.last) 428: _event_generator.sendRotate(center, withRadius:radius, rotation:angle, duration:duration, touchCount:touches)
This commit is contained in:
@@ -465,17 +465,24 @@ namespace :UIAutomation do
|
||||
|
||||
content.gsub!(/(duration):\(double\)/i) { "#{$1}:(NSTimeInterval)" }
|
||||
|
||||
content.gsub!(/\(((float|int|unsigned int)(\s*\*)?)\)/) do
|
||||
type = case $2
|
||||
when 'float'
|
||||
'CGFloat'
|
||||
when 'int'
|
||||
'NSInteger'
|
||||
when 'unsigned int'
|
||||
'NSUInteger'
|
||||
end
|
||||
"(#{type}#{$3})"
|
||||
end
|
||||
content = content.each_line.inject([]) do |replaced, line|
|
||||
if line.include?("sendTaps") or line.include?("setOrientation")
|
||||
# The signature of these methods are same in i386 and x86_64. Should not change.
|
||||
next (replaced << line)
|
||||
end
|
||||
|
||||
replaced << line.gsub(/\(((float|int|unsigned int)(\s*\*)?)\)/) do
|
||||
type = case $2
|
||||
when 'float'
|
||||
'CGFloat'
|
||||
when 'int'
|
||||
'NSInteger'
|
||||
when 'unsigned int'
|
||||
'NSUInteger'
|
||||
end
|
||||
"(#{type}#{$3})"
|
||||
end
|
||||
end.join
|
||||
end
|
||||
File.open(header, 'w') { |f| f << content }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user