Implementation of Sysroot.CreateSimpleChromeSysroot in the BuildAPI.

This included regenerationg api/gen/chromite/api/sysroot_pb2.py
with api/compile_build_api_proto to pick up most recent proto
and updating sysroot__create_simple_chrome_example_input.json.

BUG=chromium:999670
TEST=manual, run_tests

Change-Id: Ibcd749b3d0cb0423688931c5aebaf3ce29d74edf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1829972
Reviewed-by: Alex Klein <saklein@chromium.org>
Commit-Queue: Michael Mortensen <mmortensen@google.com>
Tested-by: Michael Mortensen <mmortensen@google.com>
diff --git a/api/controller/sysroot_unittest.py b/api/controller/sysroot_unittest.py
index 75790e9..ec6fba9 100644
--- a/api/controller/sysroot_unittest.py
+++ b/api/controller/sysroot_unittest.py
@@ -140,6 +140,52 @@
     self.assertEqual(sysroot_path, out_proto.sysroot.path)
 
 
+class CreateSimpleChromeSysrootTest(cros_test_lib.MockTempDirTestCase,
+                                    api_config.ApiConfigMixin):
+  """CreateSimpleChromeSysroot function tests."""
+
+  def _InputProto(self, build_target=None, use_flags=None):
+    """Helper to build and input proto instance."""
+    proto = sysroot_pb2.CreateSimpleChromeSysrootRequest()
+    if build_target:
+      proto.build_target.name = build_target
+    if use_flags:
+      proto.use_flags = use_flags
+    return proto
+
+  def _OutputProto(self):
+    """Helper to build output proto instance."""
+    return sysroot_pb2.CreateSimpleChromeSysrootResponse()
+
+  def testValidateOnly(self):
+    """Sanity check that a validate only call does not execute any logic."""
+    patch = self.PatchObject(sysroot_service, 'CreateSimpleChromeSysroot')
+
+    board = 'board'
+    in_proto = self._InputProto(build_target=board, use_flags=[])
+    sysroot_controller.CreateSimpleChromeSysroot(in_proto, self._OutputProto(),
+                                                 self.validate_only_config)
+    patch.assert_not_called()
+
+  def testArgumentValidation(self):
+    """Test the input argument validation."""
+    # Error when no build target provided.
+    in_proto = self._InputProto()
+    out_proto = self._OutputProto()
+    with self.assertRaises(cros_build_lib.DieSystemExit):
+      sysroot_controller.CreateSimpleChromeSysroot(in_proto, out_proto,
+                                                   self.api_config)
+
+    # Valid when board is specified.
+    patch = self.PatchObject(sysroot_service, 'CreateSimpleChromeSysroot',
+                             return_value='/path/to/sysroot/tar.bz')
+    in_proto = self._InputProto(build_target='board')
+    out_proto = self._OutputProto()
+    sysroot_controller.CreateSimpleChromeSysroot(in_proto, out_proto,
+                                                 self.api_config)
+    patch.assert_called_once()
+
+
 class InstallToolchainTest(cros_test_lib.MockTempDirTestCase,
                            api_config.ApiConfigMixin):
   """Install toolchain function tests."""