Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5118)

Unified Diff: chrome/test/pyautolib/pyauto.py

Issue 7108023: Fix flakiness in pyauto test on ChromeOS: ntp.NTPTest.testThumbnailPersistence. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed first round of review comments. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/pyautolib/pyauto.py
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 1ba07cb79e5e8cca8804c49017d6d7dbe54e0bdc..036a7443eaa384d5454fefb3292e031a114a5e70 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -171,11 +171,41 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
def tearDown(self):
self.TearDown() # Destroy browser
- @staticmethod
- def CloseChromeOnChromeOS():
+ def CloseChromeOnChromeOS(self):
"""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'])
+ 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):
"""Enables the named automation interface on chromeos.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698