Commit d0779450 authored by Doug Turner's avatar Doug Turner Committed by Commit Bot

_WaitForSpeech should not wait for speech output that happened in the past.

Currently, nvda_chrome_tests.py _WaitForSpeech will block for a period of
time until NVDA speaks some given text. The implementation reads output from
a log file that NVDA writes to.  This read just starts at the start of the
file and builds a list of what was said. This means that each call to
_WaitForSpeech() must contain the prior expected text.

This CL simply remembers the last offsite and when reading the file again
we ignore old stuff.  I don't think that re-reading the file is a big deal
since we're barely testing with this approach.  At some point, if it becomes
a problem, we might think of something more clever.

Bug: 742592
Change-Id: I47b417f7aa7b7cf8f6f6361d4581ab0ea562a042
Reviewed-on: https://chromium-review.googlesource.com/599373Reviewed-by: default avatarAlice Boxhall <aboxhall@chromium.org>
Commit-Queue: Doug Turner <dougt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491869}
parent f7abacec
......@@ -115,6 +115,7 @@ class NvdaChromeTest(unittest.TestCase):
app = pywinauto.application.Application()
app.connect_(process = self._chrome_proc.pid)
self._pywinauto_window = app.top_window_()
self.last_nvda_log_line = 0;
try:
self._WaitForSpeech(['Address and search bar edit', 'about:blank'])
......@@ -151,7 +152,7 @@ class NvdaChromeTest(unittest.TestCase):
"""
if not os.access(NVDA_LOGPATH, os.F_OK):
return []
lines = open(NVDA_LOGPATH).readlines()
lines = open(NVDA_LOGPATH).readlines()[self.last_nvda_log_line:]
regex = re.compile(r"u'((?:[^\'\\]|\\.)*)\'")
result = []
for line in lines:
......@@ -159,6 +160,7 @@ class NvdaChromeTest(unittest.TestCase):
speech_with_whitespace = m.group(1)
speech_stripped = re.sub(r'\s+', ' ', speech_with_whitespace).strip()
result.append(speech_stripped)
self.last_nvda_log_line = len(lines) - 1
return result
def _WaitForSpeech(self, expected):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment