@@ -33,3 +33,35 @@ def test_without_external_bit_set(self):
33
33
expected_string = "Test progress first increment"
34
34
progress .Increment (1 , expected_string )
35
35
self .assertFalse (listener .PeekAtNextEvent (event ))
36
+
37
+ def test_with_external_bit_set (self ):
38
+ """Test SBProgress can handle null events."""
39
+
40
+ progress = lldb .SBProgress ("Test SBProgress" , "Test progress" , 3 , self .dbg )
41
+ listener = lldb .SBListener ("Test listener" )
42
+ broadcaster = self .dbg .GetBroadcaster ()
43
+ broadcaster .AddListener (listener , lldb .eBroadcastBitExternalProgress )
44
+ event = lldb .SBEvent ()
45
+ # Sample JSON we're expecting:
46
+ # { id = 2, title = "Test SBProgress", details = "Test progress", type = update, progress = 1 of 3}
47
+ # details remains the same as specified in the constructor of the progress
48
+ # until we update it in the increment function, so we check for the Null and empty string case
49
+ # that details hasn't changed, but progress x of 3 has.
50
+ progress .Increment (1 , None )
51
+ self .assertTrue (listener .GetNextEvent (event ))
52
+ stream = lldb .SBStream ()
53
+ event .GetDescription (stream )
54
+ self .assertIn ("Test progress" , stream .GetData ())
55
+ self .assertIn ("1 of 3" , stream .GetData ())
56
+
57
+ progress .Increment (1 , "" )
58
+ self .assertTrue (listener .GetNextEvent (event ))
59
+ event .GetDescription (stream )
60
+ self .assertIn ("Test progress" , stream .GetData ())
61
+ self .assertIn ("2 of 3" , stream .GetData ())
62
+
63
+ progress .Increment (1 , "Step 3" )
64
+ self .assertTrue (listener .GetNextEvent (event ))
65
+ stream = lldb .SBStream ()
66
+ event .GetDescription (stream )
67
+ self .assertIn ("Step 3" , stream .GetData ())
0 commit comments