Sha256: 0a00b4340e9f1919efa014fb4052a124cf57d5893cabc005784616a841d001ef

Contents?: true

Size: 1.79 KB

Versions: 3

Compression:

Stored size: 1.79 KB

Contents

$: << File.expand_path( File.dirname(__FILE__) )
require File.dirname(__FILE__) + "/../ogre"
require "test/unit"

class Test::Unit::TestCase
	include Ogre

	# Run through Ogre setup routines so we have access to the system.
	#
	# Any test classes that override #setup will need to call super
	#
	# I use class variables to make sure only one window pops up instead
	# of one per test case, which would make things really, really slow.
	# In the else clause here, do any cleanup you need.
	def setup
		@@root ||= nil
		unless @@root
			@@log_manager = LogManager.new
			@@log_manager.create_log("Test.log",true,false,false)

			dir = File.expand_path( File.dirname(__FILE__) )
			@@root = Root.new "#{dir}/plugins.cfg", "#{dir}/ogre.cfg", "Test.log"
			@@scene_manager = @@root.create_scene_manager(ST_GENERIC, "test")

			# If needed later
			#media_path = File.expand_path(File.dirname(__FILE__)+"/media")
			#ResourceGroupManager.instance.add_resource_location(media_path, "FileSystem", "General")

			# Find a renderer to use
			renderers = @@root.get_available_renderers
			@@root.set_render_system(renderers[0])

			@@root.initialise(false)

			# I really, really don't want this! 
			# but I don't seem to have a choice right now.
			@@window = @@root.create_render_window("Testing Ogre", 320, 240, false)

			ResourceGroupManager.instance.initialise_all_resource_groups
		end
	end

	def teardown
		@@scene_manager.clear_scene
	end

	def scene_manager
		@@scene_manager
	end

	def window
		@@window
	end


	# An interesting BDD function
	def self.should(behave,&block)
		mname = "test_should_#{behave}"
		if block
			define_method mname, &block
		else
			define_method mname do 
				flunk "#{self.class.name.sub(/Test$/,'')} should #{behave}"
			end
		end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ogre.rb-0.2-i686-linux test/test_helper.rb
ogre.rb-0.2-i386-mswin32 test/test_helper.rb
ogre.rb-0.2-x86_64-linux test/test_helper.rb