Stop the UI instead of stopping the session in some tests.

Some tests need to unmount and remove a cryptohome at the end of the test.
Stopping the user's session and then unmounting the user's cryptohome
can cause a race with ui.conf's session cleanup code (which ALSO wants to
own unmounting the user's cryptohome). Find the tests that were manually
unmounting during cleanup and make them stop or restart the UI instead.
BUG=chromium:381034
TEST=run these three tests.

Change-Id: I2fae64fdfea8da569e5ab61691fddbe3d1157708
Reviewed-on: https://chromium-review.googlesource.com/203320
Reviewed-by: Darren Krahn <dkrahn@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
Commit-Queue: Chris Masone <cmasone@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205990
diff --git a/client/site_tests/login_OwnershipApi/login_OwnershipApi.py b/client/site_tests/login_OwnershipApi/login_OwnershipApi.py
index 817ec79..0f67d73 100644
--- a/client/site_tests/login_OwnershipApi/login_OwnershipApi.py
+++ b/client/site_tests/login_OwnershipApi/login_OwnershipApi.py
@@ -103,7 +103,9 @@
 
 
     def cleanup(self):
-        self._cryptohome_proxy.unmount(ownership.TESTUSER)
         if self._tempdir: self._tempdir.clean()
-        cros_ui.start(allow_fail=True)
+        # Best effort to bounce the UI, which may be up or down.
+        cros_ui.stop(allow_fail=True)
+        self._cryptohome_proxy.remove(ownership.TESTUSER)
+        cros_ui.start(allow_fail=True, wait_for_login_prompt=False)
         super(login_OwnershipApi, self).cleanup()
diff --git a/client/site_tests/login_OwnershipRetaken/login_OwnershipRetaken.py b/client/site_tests/login_OwnershipRetaken/login_OwnershipRetaken.py
index 955a130..6f28243 100644
--- a/client/site_tests/login_OwnershipRetaken/login_OwnershipRetaken.py
+++ b/client/site_tests/login_OwnershipRetaken/login_OwnershipRetaken.py
@@ -89,7 +89,7 @@
 
 
     def cleanup(self):
-        self._cryptohome_proxy.unmount(ownership.TESTUSER)
         if self._tempdir: self._tempdir.clean()
-        cros_ui.start(allow_fail=True)
+        cros_ui.restart()
+        self._cryptohome_proxy.remove(ownership.TESTUSER)
         super(login_OwnershipRetaken, self).cleanup()
diff --git a/client/site_tests/login_RemoteOwnership/login_RemoteOwnership.py b/client/site_tests/login_RemoteOwnership/login_RemoteOwnership.py
index d7c1057..1b7ef02 100644
--- a/client/site_tests/login_RemoteOwnership/login_RemoteOwnership.py
+++ b/client/site_tests/login_RemoteOwnership/login_RemoteOwnership.py
@@ -8,7 +8,7 @@
 from autotest_lib.client.bin import test, utils
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.common_lib.cros import policy, session_manager
-from autotest_lib.client.cros import cryptohome, ownership
+from autotest_lib.client.cros import cros_ui, cryptohome, ownership
 
 
 class login_RemoteOwnership(test.test):
@@ -74,5 +74,8 @@
 
 
     def cleanup(self):
-        self._cryptohome_proxy.unmount(self.username)
+        # Best effort to bounce the UI, which may be up or down.
+        cros_ui.stop(allow_fail=True)
+        self._cryptohome_proxy.remove(self.username)
+        cros_ui.start(allow_fail=True, wait_for_login_prompt=False)
         super(login_RemoteOwnership, self).cleanup()