[pitivi] dogtail tests: Allow the search_by_text helper function to do fuzzy searches
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] dogtail tests: Allow the search_by_text helper function to do fuzzy searches
- Date: Sat, 20 Oct 2012 20:25:50 +0000 (UTC)
commit 789cbb21bccf8271e9f505c0f47e22817e09573c
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date: Sat Oct 20 11:31:39 2012 -0400
dogtail tests: Allow the search_by_text helper function to do fuzzy searches
Also fix test_timeline to look for "AgingTV" in table cells, not an icon view
tests/dogtail_scripts/helper_functions.py | 20 ++++++++++++++++----
tests/dogtail_scripts/test_timeline.py | 4 ++--
2 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/tests/dogtail_scripts/helper_functions.py b/tests/dogtail_scripts/helper_functions.py
index 39a9c65..cb10c68 100644
--- a/tests/dogtail_scripts/helper_functions.py
+++ b/tests/dogtail_scripts/helper_functions.py
@@ -44,14 +44,26 @@ class HelpFunc(BaseDogTail):
# If it fails, dogtail will fail with a SearchError, which is fine
self.pitivi.child(name="Close without saving", roleName="push button").click()
- def search_by_text(self, text, parent, name=None, roleName=None):
+ def search_by_text(self, text, parent, name=None, roleName=None, exactMatchOnly=True):
"""
- Search a parent widget for childs containing the given text
+ Search a parent widget for the first child whose text matches exactly.
+ If you want to search for a widget "containing" the text, set the
+ "exactMatchOnly" parameter to False (it will also be case-insensitive).
"""
children = parent.findChildren(GenericPredicate(roleName=roleName, name=name))
for child in children:
- if child.text == text:
- return child
+ if hasattr(child, "text"):
+ # This is cute and all, but we're not just searching inside
+ # text entry widgets or labels... we can also be in a table cell
+ # and that means we can't assume that it's a text cell. Many
+ # listviews/treeviews/etc have cells for icons (text is None)
+ if child.text is not None:
+ print "Searching for", text, "in", child.text
+ if exactMatchOnly:
+ if text == child.text:
+ return child
+ elif text.lower() in child.text.lower():
+ return child
def search_by_regex(self, regex, parent, name=None, roleName=None, regex_flags=0):
"""
diff --git a/tests/dogtail_scripts/test_timeline.py b/tests/dogtail_scripts/test_timeline.py
index 9db4d41..c05eb2c 100644
--- a/tests/dogtail_scripts/test_timeline.py
+++ b/tests/dogtail_scripts/test_timeline.py
@@ -167,8 +167,8 @@ class TimelineTest(HelpFunc):
self.clipproperties.click()
center = lambda obj: (obj.position[0] + obj.size[0] / 2, obj.position[1] + obj.size[1] / 2)
table = self.clipproperties.child(roleName="table")
- icon = self.search_by_text("Agingtv ", self.effectslibrary, roleName="icon")
- self.improved_drag(center(icon), center(table))
+ effect_from_library = self.search_by_text("Agingtv", self.effectslibrary, roleName="table cell", exactMatchOnly=False)
+ self.improved_drag(center(effect_from_library), center(table))
self.goToEnd_button.click()
seekbefore = seektime.text
#Try riple and roll
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]