cros_test_unittest: Add Deploy Chrome Unittest.

 * testDeployChrome tests the deploy chrome run command.
 * testDeployChromeWithArgs tests the deploy chrome run command with
 additional arguments.

BUG=chromium:965129
TEST=This is the test.

Change-Id: I61e019769293a62388ef7b0f0413a7e94dbbafb6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1680456
Reviewed-by: Achuith Bhandarkar <achuith@chromium.org>
Reviewed-by: Ben Pastene <bpastene@chromium.org>
Tested-by: Eashan Bhatt <eashanbhatt@google.com>
Commit-Queue: Eashan Bhatt <eashanbhatt@google.com>
diff --git a/lib/cros_test_unittest.py b/lib/cros_test_unittest.py
index 2c7faf8..18445ef 100644
--- a/lib/cros_test_unittest.py
+++ b/lib/cros_test_unittest.py
@@ -53,6 +53,26 @@
         '/usr/local/autotest/bin/vm_sanity.py'
     ])
 
+  def testDeployChrome(self):
+    """Tests basic deploy chrome command."""
+    self._tester.deploy = True
+    self._tester.build_dir = self.TempFilePath('out_amd64-generic/Release')
+    self._tester.Run()
+    self.assertCommandContains(['deploy_chrome', '--force', '--build-dir',
+                                self._tester.build_dir, '--process-timeout',
+                                '180', '--to', self._tester._device.device,
+                                '--port', '9222', '--board', 'amd64-generic',
+                                '--cache-dir', self._tester.cache_dir])
+
+  def testDeployChromeWithArgs(self):
+    """Tests deploy chrome command with additional arguments."""
+    self._tester.deploy = True
+    self._tester.build_dir = self.TempFilePath('out_amd64-generic/Release')
+    self._tester.nostrip = True
+    self._tester.mount = True
+    self._tester.Run()
+    self.assertCommandContains(['--nostrip', '--mount'])
+
   def testCatapult(self):
     """Verify catapult test command."""
     self._tester.catapult_tests = ['testAddResults']
@@ -86,6 +106,64 @@
         '-F /dev/null -i /dev/null',
         'localhost:9222', 'accessiblity_Sanity'])
 
+  def testAutotestWithArgs(self):
+    """Tests an autotest call with attributes."""
+    self._tester.autotest = ['accessibility_Sanity']
+    self._tester.results_dir = 'test_results'
+    self._tester._device.private_key = '.ssh/testing_rsa'
+    self._tester._device.log_level = 'debug'
+    self._tester._device.ssh_port = None
+    self._tester._device.device = '100.90.29.199'
+    self._tester.test_that_args = ['--test_that-args',
+                                   '--whitelist-chrome-crashes']
+
+    cwd = os.path.join('/mnt/host/source',
+                       os.path.relpath(os.getcwd(), constants.SOURCE_ROOT))
+    test_results_dir = os.path.join(cwd, 'test_results')
+    testing_rsa_dir = os.path.join(cwd, '.ssh/testing_rsa')
+
+    self._tester._RunAutotest()
+
+    self.assertCommandCalled(
+        ['test_that', '--board', 'amd64-generic', '--results_dir',
+         test_results_dir, '--ssh_private_key', testing_rsa_dir, '--debug',
+         '--whitelist-chrome-crashes', '--no-quickmerge', '--ssh_options',
+         '-F /dev/null -i /dev/null', '100.90.29.199', 'accessibility_Sanity'],
+        enter_chroot=not cros_build_lib.IsInsideChroot())
+
+  @mock.patch('chromite.lib.cros_build_lib.IsInsideChroot', return_value=True)
+  def testInsideChrootAutotest(self, check_inside_chroot_mock):
+    """Tests running an autotest from within the chroot."""
+    # Checks that mock version has been called.
+    check_inside_chroot_mock.assert_called()
+
+    self._tester.autotest = ['accessiblity_Sanity']
+    self._tester.results_dir = '/mnt/host/source/test_results'
+    self._tester._device.private_key = '/mnt/host/source/.ssh/testing_rsa'
+
+    self._tester._RunAutotest()
+
+    self.assertCommandContains([
+        '--results_dir', '/mnt/host/source/test_results',
+        '--ssh_private_key', '/mnt/host/source/.ssh/testing_rsa'])
+
+  @mock.patch('chromite.lib.cros_build_lib.IsInsideChroot', return_value=False)
+  def testOutsideChrootAutotest(self, check_inside_chroot_mock):
+    """Tests running an autotest from outside the chroot."""
+    # Checks that mock version has been called.
+    check_inside_chroot_mock.assert_called()
+
+    self._tester.autotest = ['accessibility_Sanity']
+    # Capture the run command. This is necessary beacuse the mock doesn't
+    # capture the cros_sdk wrapper.
+    with cros_build_lib.OutputCapturer() as output:
+      self._tester._RunAutotest()
+    # Check that we enter the chroot before running test_that.
+    self.assertIn(
+        'cros_sdk -- test_that --board amd64-generic --no-quickmerge'
+        ' --ssh_options \'-F /dev/null -i /dev/null\' localhost:9222'
+        ' accessibility_Sanity', output.GetStderr())
+
   def testSingleBaseTastTest(self):
     """Verify running a single tast test."""
     self._tester.tast = ['ui.ChromeLogin']
@@ -145,61 +223,3 @@
         '-ephemeraldevserver=false', '-keyfile', '/tmp/.ssh/testing_rsa',
         '-extrauseflags=tast_vm', 'localhost:9222', 'ui.ChromeLogin'
     ])
-
-  def testAutotestWithArgs(self):
-    """Tests an autotest call with attributes."""
-    self._tester.autotest = ['accessibility_Sanity']
-    self._tester.results_dir = 'test_results'
-    self._tester._device.private_key = '.ssh/testing_rsa'
-    self._tester._device.log_level = 'debug'
-    self._tester._device.ssh_port = None
-    self._tester._device.device = '100.90.29.199'
-    self._tester.test_that_args = ['--test_that-args',
-                                   '--whitelist-chrome-crashes']
-
-    cwd = os.path.join('/mnt/host/source',
-                       os.path.relpath(os.getcwd(), constants.SOURCE_ROOT))
-    test_results_dir = os.path.join(cwd, 'test_results')
-    testing_rsa_dir = os.path.join(cwd, '.ssh/testing_rsa')
-
-    self._tester._RunAutotest()
-
-    self.assertCommandCalled(
-        ['test_that', '--board', 'amd64-generic', '--results_dir',
-         test_results_dir, '--ssh_private_key', testing_rsa_dir, '--debug',
-         '--whitelist-chrome-crashes', '--no-quickmerge', '--ssh_options',
-         '-F /dev/null -i /dev/null', '100.90.29.199', 'accessibility_Sanity'],
-        enter_chroot=not cros_build_lib.IsInsideChroot())
-
-  @mock.patch('chromite.lib.cros_build_lib.IsInsideChroot', return_value=True)
-  def testInsideChrootAutotest(self, check_inside_chroot_mock):
-    """Tests running an autotest from within the chroot."""
-    # Checks that mock version has been called.
-    check_inside_chroot_mock.assert_called()
-
-    self._tester.autotest = ['accessiblity_Sanity']
-    self._tester.results_dir = '/mnt/host/source/test_results'
-    self._tester._device.private_key = '/mnt/host/source/.ssh/testing_rsa'
-
-    self._tester._RunAutotest()
-
-    self.assertCommandContains([
-        '--results_dir', '/mnt/host/source/test_results',
-        '--ssh_private_key', '/mnt/host/source/.ssh/testing_rsa'])
-
-  @mock.patch('chromite.lib.cros_build_lib.IsInsideChroot', return_value=False)
-  def testOutsideChrootAutotest(self, check_inside_chroot_mock):
-    """Tests running an autotest from outside the chroot."""
-    # Checks that mock version has been called.
-    check_inside_chroot_mock.assert_called()
-
-    self._tester.autotest = ['accessibility_Sanity']
-    # Capture the run command. This is necessary beacuse the mock doesn't
-    # capture the cros_sdk wrapper.
-    with cros_build_lib.OutputCapturer() as output:
-      self._tester._RunAutotest()
-    # Check that we enter the chroot before running test_that.
-    self.assertIn(
-        'cros_sdk -- test_that --board amd64-generic --no-quickmerge'
-        ' --ssh_options \'-F /dev/null -i /dev/null\' localhost:9222'
-        ' accessibility_Sanity', output.GetStderr())