Chromium Code Reviews| Index: chrome/test/pyautolib/pyauto.py |
| diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py |
| index 1ba07cb79e5e8cca8804c49017d6d7dbe54e0bdc..685d4f99fcdeec6412cf79ac5a41b2f622da1767 100644 |
| --- a/chrome/test/pyautolib/pyauto.py |
| +++ b/chrome/test/pyautolib/pyauto.py |
| @@ -171,11 +171,43 @@ 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(['ps', '-C', 'chrome'], stdout=subprocess.PIPE) |
|
Nirnimesh
2011/06/08 18:32:22
'prep chrome' will be easier to parse
dennis_jeffrey
2011/06/08 21:50:31
Awesome! Thanks!
|
| + output, _ = proc.communicate() |
|
Nirnimesh
2011/06/08 18:32:22
output = proc.communicate()[0]
dennis_jeffrey
2011/06/08 21:50:31
This line has since been removed.
|
| + pids = [] |
| + for line in output.split('\n'): |
| + line = line.strip() |
| + if line.find('chrome') >= 0: |
| + pids.append(line[:line.find(' ')]) |
| + return pids |
| + |
| + orig_pids = _GetListOfChromePids() |
| subprocess.call(['pkill', 'chrome']) |
| + def _DoesOldChromeProcessStillExist(): |
|
Nirnimesh
2011/06/08 18:32:22
take orig_pids as arg
dennis_jeffrey
2011/06/08 21:50:31
Done.
|
| + """Determines whether an originally-running 'chrome' process exists. |
| + |
| + Returns: |
| + True, if an originally-running 'chrome' process still exists, or |
| + False otherwise. |
| + """ |
| + new_pids = _GetListOfChromePids() |
| + for new_pid in new_pids: |
|
Nirnimesh
2011/06/08 18:32:22
merge with previous line
dennis_jeffrey
2011/06/08 21:50:31
Done.
|
| + if new_pid in orig_pids: |
| + return True |
| + return False |
| + |
| + self.WaitUntil(lambda: not _DoesOldChromeProcessStillExist()) |
|
Nirnimesh
2011/06/08 18:32:22
pass orig_pids as arg
Nirnimesh
2011/06/08 18:32:22
Why the negation? Just invert the function --
lamb
dennis_jeffrey
2011/06/08 21:50:31
Done.
dennis_jeffrey
2011/06/08 21:50:31
Done.
|
| + |
| def EnableChromeTestingOnChromeOS(self): |
| """Enables the named automation interface on chromeos. |