Add tests for WeakRef change.

This commit is contained in:
Eloy Durán
2014-04-08 15:02:56 +02:00
parent 53e519eb05
commit e3fa07fe1c
3 changed files with 53 additions and 4 deletions

View File

@@ -7,7 +7,7 @@ ENV['output'] ||= 'pretty_spec_dox'
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'test'
app.frameworks += ['AddressBook', 'AddressBookUI', 'CoreData', 'CoreMIDI', 'GameKit', 'AudioToolbox']
app.frameworks += ['AddressBook', 'AddressBookUI', 'AudioToolbox', 'AVFoundation', 'CoreData', 'CoreMIDI', 'GameKit']
app.vendor_project('vendor/code', :static)
app.spec_files.insert(1, *FileList['../helpers/*.rb'])

View File

@@ -108,9 +108,58 @@ describe "WeakRef" do
WeakRef.new(false).should == false
end
# TODO what's the good way to determine if we're running on 10.7?
unless defined?(NSView) && ENV['deployment_target'] == '10.7'
it "allows weak references to AVFoundation classes" do
lambda { WeakRef.new(AVPlayer.new) }.should.not.raise
end
end
it "raises with classes that do not support weak references" do
obj = NSMutableParagraphStyle.new
lambda { WeakRef.new(obj) }.should.raise(WeakRef::RefError)
# iOS and OS X classes, regardless of SDK version
classes = [
NSParagraphStyle,
NSMutableParagraphStyle,
]
# OSX only classes
if defined?(NSView)
# Some of these are deprecated, so define a stub if necessary.
unless defined?(NSSimpleHorizontalTypesetter)
class NSSimpleHorizontalTypesetter; end
end
unless defined?(NSMenuView)
class NSMenuView; end
end
classes.concat([
NSSimpleHorizontalTypesetter,
NSATSTypesetter,
NSColorSpace,
NSFont,
NSMenuView,
NSTextView,
])
# In addition, the following classes don't allow weak references on 10.7
if ENV['deployment_target'] == '10.7'
puts 'TESTING OSX 10.7 CLASSES!'
if AVPlayer.new.allowsWeakReference
puts 'ERROR: Expected AVPlayer to not allow weak references!!'
end
classes.concat([
AVPlayer,
NSFontManager,
NSFontPanel,
NSImage,
NSTableCellView,
NSViewController,
NSWindow,
NSWindowController,
])
end
end
classes.each do |klass|
puts "Testing whether allows weak references: #{klass.name}"
lambda { WeakRef.new(klass.new) }.should.raise(WeakRef::RefError)
end
end
end

2
vm

Submodule vm updated: 37c6ff62c4...6bbe580c62