@@ -30,6 +30,7 @@ def setUp(self):
3030 def tearDown (self ):
3131 for file in self .files_to_delete :
3232 os .remove (file )
33+ notepad .showDocSwitcher (False )
3334
3435# helper functions
3536
@@ -114,6 +115,7 @@ def __test_invalid_parameter_passed(self, notepad_method):
114115 self ._invalid_parameter_passed (notepad_method , - 1 ,- 1 ,- 1 )
115116
116117
118+ doc_switcher_found = False
117119 @staticmethod
118120 def foreach_window (hwnd , lParam ):
119121 if ctypes .windll .user32 .IsWindowVisible (hwnd ):
@@ -122,14 +124,17 @@ def foreach_window(hwnd, lParam):
122124 buffer = ctypes .create_unicode_buffer (length )
123125 ctypes .windll .user32 .GetWindowTextW (hwnd , buffer , length )
124126 if buffer .value == ctypes .wstring_at (lParam ):
127+ NotepadTestCase .doc_switcher_found = True
125128 return False
126129 return True
127130
128131
129132 def find_child_window (self , caption ):
130- return not ctypes .windll .user32 .EnumChildWindows (NPP_HANDLE ,
133+ NotepadTestCase .doc_switcher_found = False
134+ ctypes .windll .user32 .EnumChildWindows (NPP_HANDLE ,
131135 EnumWindowsProc (self .foreach_window ),
132136 ctypes .create_unicode_buffer (caption ))
137+ return NotepadTestCase .doc_switcher_found
133138
134139# old tests
135140
@@ -611,6 +616,8 @@ def reset_auto_updater(hwnd, lParam):
611616 self .assertEqual (self ._get_disable_update_xml (), 'no' )
612617 prepare_auto_updater ()
613618
619+
620+ doc_switcher_control_value_found = False
614621 def test_docSwitcherDisableColumn (self ):
615622 ''' '''
616623 def search_for_doc_switcher (hwnd , lParam ):
@@ -629,7 +636,9 @@ def search_for_doc_switcher_controls(hwnd, lParam):
629636 ctypes .windll .user32 .GetClassNameW (hwnd , curr_class , 256 )
630637
631638 if curr_class .value == 'SysHeader32' :
632- if ctypes .windll .user32 .SendMessageW (hwnd , 0x1200 , 0 , 0 ) == lParam :
639+ HDM_GETITEMCOUNT = 0x1200
640+ if ctypes .windll .user32 .SendMessageW (hwnd , HDM_GETITEMCOUNT , 0 , 0 ) == lParam :
641+ self .doc_switcher_control_value_found = True
633642 return False
634643 return True
635644
@@ -651,21 +660,23 @@ def search_for_doc_switcher_controls(hwnd, lParam):
651660 EnumWindowsProc (search_for_doc_switcher ),
652661 ctypes .create_unicode_buffer (u'Doc Switcher' ))
653662
654- return_code = ctypes .windll .user32 .EnumChildWindows (control_dict .get (u'Doc Switcher' ),
663+ self .doc_switcher_control_value_found = False
664+ ctypes .windll .user32 .EnumChildWindows (control_dict .get (u'Doc Switcher' ),
655665 EnumWindowsProc (search_for_doc_switcher_controls ),
656666 2 )
657- self .assertEqual ( return_code , 0 )
667+ self .assertTrue ( self . doc_switcher_control_value_found )
658668
659669 self .assertIsNone (notepad .docSwitcherDisableColumn (True ))
660670
661671 ctypes .windll .user32 .EnumChildWindows (NPP_HANDLE ,
662672 EnumWindowsProc (search_for_doc_switcher ),
663673 ctypes .create_unicode_buffer (u'Doc Switcher' ))
664674
665- return_code = ctypes .windll .user32 .EnumChildWindows (control_dict .get (u'Doc Switcher' ),
675+ self .doc_switcher_control_value_found = False
676+ ctypes .windll .user32 .EnumChildWindows (control_dict .get (u'Doc Switcher' ),
666677 EnumWindowsProc (search_for_doc_switcher_controls ),
667678 1 )
668- self .assertEqual ( return_code , 0 )
679+ self .assertTrue ( self . doc_switcher_control_value_found )
669680 notepad .showDocSwitcher (False )
670681
671682
0 commit comments