Skip to content

Commit

Permalink
Add is_editable method for editwrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
drinkertea committed Apr 28, 2019
1 parent 9d808de commit c0a2e71
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
Binary file modified apps/WinForms_samples/DataGridView_TestApp.exe
Binary file not shown.
Binary file modified apps/WinForms_samples/x64/DataGridView_TestApp.exe
Binary file not shown.
5 changes: 5 additions & 0 deletions pywinauto/controls/uia_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ def get_value(self):
"""Return the current value of the element"""
return self.iface_value.CurrentValue

# -----------------------------------------------------------
def is_editable(self):
"""Return the edit possibility of the element"""
return not self.iface_value.CurrentIsReadOnly

# -----------------------------------------------------------
def texts(self):
"""Get the text of the edit control"""
Expand Down
27 changes: 26 additions & 1 deletion pywinauto/unittests/test_uiawrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ def tearDown(self):

class MenuBarTestsWinForms(unittest.TestCase):

"""Unit tests for the ListViewWrapper class"""
"""Unit tests for the MenuBar class"""

def setUp(self):
"""Set some data and ensure the application is in the state we want"""
Expand Down Expand Up @@ -1293,6 +1293,31 @@ def tearDown(self):
self.app.kill()


class EditTestsWinForms(unittest.TestCase):

"""Unit tests for the WinFormEdit class"""

def setUp(self):
"""Set some data and ensure the application is in the state we want"""
_set_timings()
self.app = Application(backend='uia').start(winfoms_app_grid)
self.dlg = self.app.Dialog

def test_edit_editable(self):
"""Test editable method for editable edit"""
self.assertEqual(self.dlg.Edit2.get_value(), "Editable")
self.assertTrue(self.dlg.Edit2.is_editable())

def test_edit_readonly(self):
"""Test editable method for read only edit"""
self.assertEqual(self.dlg.Edit1.get_value(), "ReadOnly")
self.assertFalse(self.dlg.Edit1.is_editable())

def tearDown(self):
"""Close the application after tests"""
self.app.kill()


class ComboBoxTestsWinForms(unittest.TestCase):

"""Unit tests for the ComboBoxWrapper class with WinForms app"""
Expand Down

0 comments on commit c0a2e71

Please sign in to comment.