Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encapsulate calling FindItemByProperty #1328

Open
wants to merge 3 commits into
base: atspi
Choose a base branch
from

Conversation

junkmd
Copy link
Contributor

@junkmd junkmd commented Aug 31, 2023

IUIAutomationItemContainerPattern.FindItemByProperty is useful for finding matching elements in containers, but is inconvenient to use because it requires a null pointer and complicated arguments.

In the uiawrapper and uia_controls modules, direct referencing of such complex COM object methods to retrieve IUIAutomationElement and then passing it to the constructor of UIAElementInfo is overly responsible.
It is more appropriate that those be in the uia_element_info module.
So I defined the wrapper of UI item container in uia_element_info.

And I changed arguments passed to IUIAutomationItemContainerPattern.FindItemByProperty to be an instance of a more proper type.
As mentioned in #733 (comment) (317a7c9), if we try to create a null com pointer by passing 0 or None to uia_defs.IUIA().iuia.ElementFromHandle, an error will be raised.
I realized there is a simpler way to create a null com pointer. It is just doing POINTER(SubclassOfIUnknown)().

@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

Merging #1328 (caeb3ec) into atspi (bf7f789) will decrease coverage by 6.32%.
The diff coverage is 97.14%.

Additional details and impacted files
@@            Coverage Diff             @@
##            atspi    #1328      +/-   ##
==========================================
- Coverage   94.15%   87.84%   -6.32%     
==========================================
  Files          60       60              
  Lines       23036    23053      +17     
==========================================
- Hits        21689    20250    -1439     
- Misses       1347     2803    +1456     

@junkmd junkmd marked this pull request as draft September 1, 2023 21:48
@junkmd junkmd changed the title update uia_controls.ListViewWrapper.get_item encapsulate calling FindItemByProperty Sep 2, 2023
@junkmd junkmd marked this pull request as ready for review September 2, 2023 06:12
add `_ItemContainer` class and `UIAElementInfo.item_container` property
@junkmd junkmd force-pushed the listview_get_item_refactoring branch from 0668aef to caeb3ec Compare September 12, 2023 08:57
except (uia_defs.NoPatternInterfaceError):
for elem in self.element_info.item_container:
texts.append(UIAWrapper(elem).texts())
except uia_defs.NoPatternInterfaceError:

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant