chrome.py: Add callback for cheets on browser closing.
BUG=b:27405466
TEST=Made sure the callback runs on cheets.
CQ-DEPEND=CL:*255362
Change-Id: Id9a441ea8b592b3b48cff6ea79c80c58d4e6450e
Reviewed-on: https://chromium-review.googlesource.com/338943
Commit-Ready: Hidehiko Abe <hidehiko@chromium.org>
Tested-by: Hidehiko Abe <hidehiko@chromium.org>
Reviewed-by: Shuhei Takahashi <nya@chromium.org>
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
diff --git a/client/common_lib/cros/chrome.py b/client/common_lib/cros/chrome.py
index 478d262..488aba5 100644
--- a/client/common_lib/cros/chrome.py
+++ b/client/common_lib/cros/chrome.py
@@ -63,8 +63,9 @@
finder_options = browser_options.BrowserFinderOptions()
# Append cheets specific browser args
- is_cheets_platform = utils.get_current_board().endswith(self.CHEETS)
- if is_cheets_platform:
+ self._is_cheets_platform = (
+ utils.get_current_board().endswith(self.CHEETS))
+ if self._is_cheets_platform:
from autotest_lib.client.common_lib.cros import cheets
extra_browser_args = cheets.append_extra_args(extra_browser_args)
logged_in = True
@@ -134,7 +135,7 @@
try:
browser_to_create = browser_finder.FindBrowser(finder_options)
self._browser = browser_to_create.Create(finder_options)
- if is_cheets_platform:
+ if self._is_cheets_platform:
cheets.post_processing_after_browser()
break
except (exceptions.LoginException) as e:
@@ -241,4 +242,9 @@
def close(self):
"""Closes the browser."""
- self._browser.Close()
+ try:
+ if self._is_cheets_platform:
+ from autotest_lib.client.common_lib.cros import cheets
+ cheets.pre_processing_before_close()
+ finally:
+ self._browser.Close()