Method: Qt::Test.qExec

Defined in:
lib/qttest/qttest.rb,
ext/ruby/qttest/qttest.rb

.qExec(*args) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/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