1""" 2Test that we are able to find out how many children NSWindow has 3""" 4 5import os, time 6import unittest2 7import lldb 8from lldbtest import * 9import lldbutil 10 11@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 12class Rdar12408181TestCase(TestBase): 13 14 mydir = os.path.join("lang", "objc", "rdar-12408181") 15 16 @dsym_test 17 def test_nswindow_count_with_dsym(self): 18 """Test that we are able to find out how many children NSWindow has.""" 19 d = {'EXE': self.exe_name} 20 self.buildDsym(dictionary=d) 21 self.setTearDownCleanup(dictionary=d) 22 self.nswindow_count(self.exe_name) 23 24 @dwarf_test 25 def test_nswindow_count_with_dwarf(self): 26 """Test that we are able to find out how many children NSWindow has.""" 27 d = {'EXE': self.exe_name} 28 self.buildDwarf(dictionary=d) 29 self.setTearDownCleanup(dictionary=d) 30 self.nswindow_count(self.exe_name) 31 32 def setUp(self): 33 # Call super's setUp(). 34 TestBase.setUp(self) 35 # We'll use the test method name as the exe_name. 36 self.exe_name = self.testMethodName 37 # Find the line number to break inside main(). 38 self.main_source = "main.m" 39 self.line = line_number(self.main_source, '// Set breakpoint here.') 40 41 def nswindow_count(self, exe_name): 42 """Test that we are able to find out how many children NSWindow has.""" 43 exe = os.path.join(os.getcwd(), exe_name) 44 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 45 46 lldbutil.run_break_set_by_file_and_line (self, self.main_source, self.line, num_expected_locations=1, loc_exact=True) 47 48 self.runCmd("run", RUN_SUCCEEDED) 49 window = self.frame().FindVariable("window") 50 window_dynamic = window.GetDynamicValue(lldb.eDynamicCanRunTarget) 51 self.assertTrue(window.GetNumChildren() > 1, "NSWindow (static) only has 1 child!") 52 self.assertTrue(window_dynamic.GetNumChildren() > 1, "NSWindow (dynamic) only has 1 child!") 53 self.assertTrue(window.GetChildAtIndex(0).IsValid(), "NSWindow (static) has an invalid child") 54 self.assertTrue(window_dynamic.GetChildAtIndex(0).IsValid(), "NSWindow (dynamic) has an invalid child") 55 56if __name__ == '__main__': 57 import atexit 58 lldb.SBDebugger.Initialize() 59 atexit.register(lambda: lldb.SBDebugger.Terminate()) 60 unittest2.main() 61