1# encoding: utf-8
2"""
3Test lldb data formatter subsystem.
4"""
5
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12
13class ObjCDataFormatterTestCase(TestBase):
14
15   mydir = TestBase.compute_mydir(__file__)
16
17   def appkit_tester_impl(self, commands):
18      self.build()
19      self.appkit_common_data_formatters_command()
20      commands()
21
22   def appkit_common_data_formatters_command(self):
23      """Test formatters for AppKit classes."""
24      self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
25          self, '// Set break point at this line.',
26          lldb.SBFileSpec('main.m', False))
27
28      # The stop reason of the thread should be breakpoint.
29      self.expect(
30          "thread list",
31          STOPPED_DUE_TO_BREAKPOINT,
32          substrs=['stopped', 'stop reason = breakpoint'])
33
34      # This is the function to remove the custom formats in order to have a
35      # clean slate for the next test case.
36      def cleanup():
37         self.runCmd('type format clear', check=False)
38         self.runCmd('type summary clear', check=False)
39         self.runCmd('type synth clear', check=False)
40
41      # Execute the cleanup function during test case tear down.
42      self.addTearDownHook(cleanup)
43