Fix flakiness in pyauto test on ChromeOS: ntp.NTPTest.testThumbnailPersistence.

The test previously failed to wait for the 'pkill chrome' command to finish
killing the relevant chrome processes.

BUG=chromium-os:16297
TEST=None

Review URL: http://codereview.chromium.org/7108023

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88411 0039d316-1c4b-4281-b951-d872f2087c98
parent f4107ff9
...@@ -171,11 +171,41 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): ...@@ -171,11 +171,41 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
def tearDown(self): def tearDown(self):
self.TearDown() # Destroy browser self.TearDown() # Destroy browser
@staticmethod def CloseChromeOnChromeOS(self):
def CloseChromeOnChromeOS():
"""Gracefully exit chrome on ChromeOS.""" """Gracefully exit chrome on ChromeOS."""
def _GetListOfChromePids():
"""Retrieves the list of currently-running Chrome process IDs.
Returns:
A list of strings, where each string represents a currently-running
'chrome' process ID.
"""
proc = subprocess.Popen(['pgrep', 'chrome'], stdout=subprocess.PIPE)
proc.wait()
return [x.strip() for x in proc.stdout.readlines()]
orig_pids = _GetListOfChromePids()
subprocess.call(['pkill', 'chrome']) subprocess.call(['pkill', 'chrome'])
def _AreOrigPidsDead(orig_pids):
"""Determines whether all originally-running 'chrome' processes are dead.
Args:
orig_pids: A list of strings, where each string represents the PID for
an originally-running 'chrome' process.
Returns:
True, if all originally-running 'chrome' processes have been killed, or
False otherwise.
"""
for new_pid in _GetListOfChromePids():
if new_pid in orig_pids:
return False
return True
self.WaitUntil(lambda: _AreOrigPidsDead(orig_pids))
def EnableChromeTestingOnChromeOS(self): def EnableChromeTestingOnChromeOS(self):
"""Enables the named automation interface on chromeos. """Enables the named automation interface on chromeos.
......
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