• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""
2Test that we are able to find out how many children NSWindow has
3"""
4
5
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12
13# TODO: The Jenkins testers on OS X fail running this test because they don't
14# have access to WindowServer so NSWindow doesn't work.  We should disable this
15# test if WindowServer isn't available.
16# Note: Simply applying the @skipIf decorator here confuses the test harness
17# and gives a spurious failure.
18class Rdar12408181TestCase(TestBase):
19
20    mydir = TestBase.compute_mydir(__file__)
21
22    def setUp(self):
23        # Call super's setUp().
24        TestBase.setUp(self)
25        # We'll use the test method name as the exe_name.
26        self.exe_name = self.testMethodName
27        # Find the line number to break inside main().
28        self.main_source = "main.m"
29        self.line = line_number(self.main_source, '// Set breakpoint here.')
30
31    def test_nswindow_count(self):
32        """Test that we are able to find out how many children NSWindow has."""
33
34        self.skipTest("Skipping this test due to timeout flakiness")
35
36        d = {'EXE': self.exe_name}
37        self.build(dictionary=d)
38        self.setTearDownCleanup(dictionary=d)
39
40        exe = self.getBuildArtifact(self.exe_name)
41        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
42
43        lldbutil.run_break_set_by_file_and_line(
44            self,
45            self.main_source,
46            self.line,
47            num_expected_locations=1,
48            loc_exact=True)
49
50        self.runCmd("run", RUN_SUCCEEDED)
51        if self.frame().EvaluateExpression(
52                '(void*)_CGSDefaultConnection()').GetValueAsUnsigned() != 0:
53            window = self.frame().FindVariable("window")
54            window_dynamic = window.GetDynamicValue(lldb.eDynamicCanRunTarget)
55            self.assertTrue(
56                window.GetNumChildren() > 1,
57                "NSWindow (static) only has 1 child!")
58            self.assertTrue(
59                window_dynamic.GetNumChildren() > 1,
60                "NSWindow (dynamic) only has 1 child!")
61            self.assertTrue(
62                window.GetChildAtIndex(0).IsValid(),
63                "NSWindow (static) has an invalid child")
64            self.assertTrue(
65                window_dynamic.GetChildAtIndex(0).IsValid(),
66                "NSWindow (dynamic) has an invalid child")
67        else:
68            self.skipTest('no WindowServer connection')
69