class Qt::Test
Public Class Methods
current_binding()
click to toggle source
# File ext/ruby/qttest/qttest.rb, line 69 def self.current_binding @@current_binding end
current_binding=(b)
click to toggle source
# File ext/ruby/qttest/qttest.rb, line 73 def self.current_binding=(b) @@current_binding = b end
qExec(*args)
click to toggle source
Calls superclass method
# File ext/ruby/qttest/qttest.rb, line 77 def self.qExec(*args) test_functions = [] meta = args[0].metaObject className = meta.className for i in 0...meta.methodCount sl = meta.method(i) if Test.validSlot?(sl) test_functions << sl.signature.sub("()", "").to_sym end end # Trap calls to the test functions and save their binding, so that # the various test methods, like QVERIFY(), can evaluate the code strings # passed to them in the context of the test function trace_func = set_trace_func proc { |event, file, line, id, binding, klass| if event == 'call' && klass.name == className && test_functions.include?(id) Test.current_binding = binding end } if args.length == 2 && args[1].kind_of?(Array) super(args[0], args[1].length + 1, [$0] + args[1]) else super(*args) end set_trace_func(trace_func) end
validSlot?(sl)
click to toggle source
This is the isValidSlot() function in testlib/qtestcase.cpp translated to Ruby. Probably could be a bit shorter in Ruby..
# File ext/ruby/qttest/qttest.rb, line 40 def self.validSlot?(sl) if sl.access != Qt::MetaMethod::Private || !sl.parameterTypes.empty? || sl.typeName != "" || sl.methodType != Qt::MetaMethod::Slot return false end sig = sl.signature len = sig.length if len < 2 return false end if sig[len - 2, 1] != '(' || sig[len - 1, 1] != ')' return false end if len > 7 && sig[len - 7, len] == "_data()" return false end if sig == "initTestCase()" || sig == "cleanupTestCase()" || sig == "cleanup()" || sig == "init()" return false end return true end