[Autotest] Fixing policy_DownloadDirectory.default

Test was failing due to the Gdrive not being fully "ready" when the file
was to be deleted prior to the test. Added a poll to wait until the
gdrive dir is ready for operations, thus helping ensure the test file is
rm'd.

BUG=None
TEST=All variations of this test, multiple times.

Change-Id: I927cc840784b3fef09b9008a40ce91809b3f7604
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/1954262
Tested-by: Derek Beckett <dbeckett@chromium.org>
Reviewed-by: Ruben Zakarian <rzakarian@chromium.org>
Commit-Queue: Derek Beckett <dbeckett@chromium.org>
diff --git a/client/site_tests/policy_DownloadDirectory/policy_DownloadDirectory.py b/client/site_tests/policy_DownloadDirectory/policy_DownloadDirectory.py
index 54c177d..df37bfe 100644
--- a/client/site_tests/policy_DownloadDirectory/policy_DownloadDirectory.py
+++ b/client/site_tests/policy_DownloadDirectory/policy_DownloadDirectory.py
@@ -41,13 +41,15 @@
                         real_gaia=True)
 
         self.GDRIVE_DIR = self._get_Gdrive_path()
+        self._wait_for_mount_ready()
         self._clear_test_locations()
         self._the_test(case)
         self._clear_test_locations()
 
     def _get_Gdrive_path(self):
         """Returns the path for the Google Drive Mountpoint."""
-        return '{}/root/download'.format(self._get_mount(False))
+        self.GDRIVE_BASE = self._get_mount(False)
+        return '{}/root/download'.format(self.GDRIVE_BASE)
 
     def _download_test_file(self):
         """Loads to the test URL which automatically downloads the test file."""
@@ -57,6 +59,7 @@
         except exceptions.TimeoutException:
             pass
 
+
     def _the_test(self, case):
         """
         Download the test file, and verify it is in the proper directory,
@@ -88,6 +91,22 @@
             except error.CmdError:
                 pass
 
+    def _wait_for_mount_ready(self):
+        """Wait for the mount to be ready."""
+        def _mount_ready():
+            try:
+                utils.system_output('ls {}/root/'.format(self.GDRIVE_BASE))
+                return True
+            except error.CmdError:
+                return False
+
+        utils.poll_for_condition(
+            lambda: (_mount_ready()),
+            exception=error.TestFail('derek mounts not ready ever'),
+            timeout=15,
+            sleep_interval=1,
+            desc='Polling for mounts to be ready.')
+
     def _get_mount(self, case):
         """Get the Google Drive mount path."""
         e_msg = 'Should have found mountpoint but did not!'