Skip to content

Commit

Permalink
Convert RebarTestCases to new MFC sample. Add RebarTest test apps for…
Browse files Browse the repository at this point in the history
… x86/x64
  • Loading branch information
airelil committed May 30, 2015
1 parent ea2ffda commit 0211050
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
Binary file added apps/MFC_samples/RebarTest.exe
Binary file not shown.
Binary file added apps/MFC_samples/x64/RebarTest.exe
Binary file not shown.
7 changes: 4 additions & 3 deletions pywinauto/controls/common_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2220,8 +2220,9 @@ def GetBand(self, band_index):
win32defines.RBBIM_TEXT

# set the pointer for the text
band_info.pszText = ctypes.c_long(remote_mem.Address() + ctypes.sizeof(band_info))
band_info.cchText = 2000
band_info.lpText = win32structures.LPWSTR(
remote_mem.Address() + ctypes.sizeof(band_info))
band_info.cch = 2000

# write the structure
remote_mem.Write(band_info)
Expand All @@ -2236,7 +2237,7 @@ def GetBand(self, band_index):
remote_mem.Read(band_info)

# read the text
band_info.text = ctypes.create_unicode_buffer(1999)
band_info.text = ctypes.create_unicode_buffer(2000)
remote_mem.Read(band_info.text, remote_mem.Address() + ctypes.sizeof(band_info))

band_info.text = band_info.text.value
Expand Down
20 changes: 14 additions & 6 deletions pywinauto/unittests/test_common_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,16 +866,23 @@ class RebarTestCases(unittest.TestCase):

def setUp(self):
"""Start the application set some data and ensure the application
is in the state we want it."""
is in the state we want it.
The app title can be tricky. If no document is opened the title is just: "RebarTest"
However if an document is created/opened in the child frame
the title is appended with a document name: "RebarTest - RebarTest1"
A findbestmatch proc does well here with guessing the title
even though the app is started with a short title "RebarTest".
"""

# start the application
from pywinauto.application import Application
app = Application()
app.start_(os.path.join(controlspy_folder, "rebar.exe"))
app.start_(os.path.join(mfc_samples_folder, "RebarTest.exe"))

self.app = app
self.dlg = app.MicrosoftControlSpy
self.ctrl = app.MicrosoftControlSpy.Rebar.WrapperObject()
self.dlg = app.RebarTest_RebarTest
self.ctrl = app.RebarTest_RebarTest.Rebar.WrapperObject()

#self.dlg.MenuSelect("Styles")

Expand Down Expand Up @@ -910,9 +917,10 @@ def testGetBand(self):
band = self.ctrl.GetBand(0)


self.assertEquals(band.hwndChild, self.dlg.ToolBar.handle)
self.assertEquals(band.hwndChild, self.dlg.MenuBar.handle)

#self.assertEquals(band.text, "blah")
self.assertEquals(self.ctrl.GetBand(1).text, u"Tools band:")
self.assertEquals(self.ctrl.GetBand(0).text, u"Menus band:")

def testGetToolTipsControl(self):
self.assertEquals(self.ctrl.GetToolTipsControl(), None)
Expand Down
10 changes: 6 additions & 4 deletions pywinauto/win32structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,14 +797,16 @@ class REBARBANDINFOW(Structure):
('cxIdeal', UINT),
('lParam', LPARAM),
('cxHeader', UINT),
#('rcChevronLocation', RECT), # the rect is in client co-ord wrt hwndChild
#('uChevronState', UINT)
# The fields below added for _WIN32_WINNT >= 0x0600 (Vista, Win7, ...)
# It means that sizeof(REBARBANDINFOW) is wrong for WinXP
('rcChevronLocation', RECT), # the rect is in client co-ord wrt hwndChild
('uChevronState', UINT)
]
if sysinfo.is_x64_Python():
assert sizeof(REBARBANDINFOW) == 112, sizeof(REBARBANDINFOW) #128
assert sizeof(REBARBANDINFOW) == 128, sizeof(REBARBANDINFOW) #128
assert alignment(REBARBANDINFOW) == 8, alignment(REBARBANDINFOW)
else:
assert sizeof(REBARBANDINFOW) == 80, sizeof(REBARBANDINFOW) #100
assert sizeof(REBARBANDINFOW) == 100, sizeof(REBARBANDINFOW) #100
assert alignment(REBARBANDINFOW) == 4, alignment(REBARBANDINFOW)


Expand Down

0 comments on commit 0211050

Please sign in to comment.