diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/objc/rdar-12408181')
3 files changed, 83 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/Makefile b/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/Makefile new file mode 100644 index 0000000000000..385b557c9af0a --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/Makefile @@ -0,0 +1,11 @@ +LEVEL = ../../../make + +OBJC_SOURCES := main.m + +include $(LEVEL)/Makefile.rules + +ifneq (,$(findstring arm,$(ARCH))) + LD_EXTRAS = -framework Foundation -framework UIKit +else + LD_EXTRAS = -framework Foundation -framework Cocoa +endif diff --git a/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py b/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py new file mode 100644 index 0000000000000..b95d95106032a --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py @@ -0,0 +1,48 @@ +""" +Test that we are able to find out how many children NSWindow has +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + +@skipUnlessDarwin +class Rdar12408181TestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # We'll use the test method name as the exe_name. + self.exe_name = self.testMethodName + # Find the line number to break inside main(). + self.main_source = "main.m" + self.line = line_number(self.main_source, '// Set breakpoint here.') + + def test_nswindow_count(self): + """Test that we are able to find out how many children NSWindow has.""" + d = {'EXE': self.exe_name} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + + exe = os.path.join(os.getcwd(), self.exe_name) + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_file_and_line (self, self.main_source, self.line, num_expected_locations=1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + if self.frame().EvaluateExpression('(void*)_CGSDefaultConnection()').GetValueAsUnsigned() != 0: + window = self.frame().FindVariable("window") + window_dynamic = window.GetDynamicValue(lldb.eDynamicCanRunTarget) + self.assertTrue(window.GetNumChildren() > 1, "NSWindow (static) only has 1 child!") + self.assertTrue(window_dynamic.GetNumChildren() > 1, "NSWindow (dynamic) only has 1 child!") + self.assertTrue(window.GetChildAtIndex(0).IsValid(), "NSWindow (static) has an invalid child") + self.assertTrue(window_dynamic.GetChildAtIndex(0).IsValid(), "NSWindow (dynamic) has an invalid child") + else: + self.skipTest('no WindowServer connection') diff --git a/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/main.m b/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/main.m new file mode 100644 index 0000000000000..858ba2a4a22ff --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/main.m @@ -0,0 +1,24 @@ +#import <Foundation/Foundation.h> +#if defined (__i386__) || defined (__x86_64__) +#import <Cocoa/Cocoa.h> +#else +#import <UIKit/UIKit.h> +#endif + +int main (int argc, char const *argv[]) +{ + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; +#if defined (__i386__) || defined (__x86_64__) + + [NSApplication sharedApplication]; + NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,100,100) styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained defer:NO]; + [window setCanHide:YES]; +#else + [UIApplication sharedApplication]; + CGRect rect = { 0, 0, 100, 100}; + UIWindow* window = [[UIWindow alloc] initWithFrame:rect]; +#endif + [pool release]; // Set breakpoint here. + return 0; +} + |