video_VideoDecodeAccelerator: Add test cases to run VDA unittest with IMPORT mode

VDA unittest can run with either ALLOCATE or IMPORT mode. The existing test
cases all run with ALLOCATE mode. This adds the test case to run IMPORT mode.
We enable VideoFrameValidator with IMPORT mode, which checks soundness of video
decoded frames in VDA unittest.
It is infeasible to let VDA unittest run with IMPORT mode on some devices,
https://crbug.com/881729. They are the devices where ARC++ is disabled. So I set
DEPENDENCIES to "arc" in order to not run on them.

BUG=chromium:856562
TEST=video_VideoDecodeAccelerator.h264.import

Change-Id: I1cc1b8a7acd1d671d517b3f2c3071287a7d49860
Reviewed-on: https://chromium-review.googlesource.com/1331194
Commit-Ready: Hirokazu Honda <hiroh@chromium.org>
Tested-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
diff --git a/client/site_tests/video_VideoDecodeAccelerator/control.h264.import b/client/site_tests/video_VideoDecodeAccelerator/control.h264.import
new file mode 100644
index 0000000..1a51b18
--- /dev/null
+++ b/client/site_tests/video_VideoDecodeAccelerator/control.h264.import
@@ -0,0 +1,39 @@
+# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+AUTHOR = "Chrome OS Team, chromeos-video@google.com"
+NAME = "video_VideoDecodeAccelerator.h264.import"
+PURPOSE = """
+Verify Chromium hardware Video Decode Acceleration works with IMPORT mode.
+"""
+CRITERIA = """
+This test will fail if any of the tests in video_decode_accelerator_unittest
+with IMPORT mode fails. Running video_decode_accelerator_unittest is skipped on
+machines that are known not to support video decode.
+"""
+ATTRIBUTES = "suite:bvt-perbuild"
+DEPENDENCIES= "arc"
+TIME = "SHORT"
+TEST_CATEGORY = "Functional"
+TEST_CLASS = "video"
+TEST_TYPE = "client"
+JOB_RETRIES = 2
+# Reboot in the lab after the test ends.
+DEPENDENCIES = "cleanup-reboot"
+BUG_TEMPLATE = {
+    'labels': ['OS-Chrome', 'VideoTestFailure'],
+    'cc': ['chromeos-video-test-failures@google.com'],
+}
+
+DOC = """
+This is a wrapper test for Chrome video_decode_accelerator_unittest with IMPORT
+mode.
+"""
+
+# The FPS expectations here are lower than observed in most runs to keep
+# the bots green.
+videos = ['test-25fps.h264:320:240:250:258:35:150:1']
+
+job.run_test('video_VideoDecodeAccelerator', videos=videos,
+             capability='hw_dec_h264_1080_30', import_mode=True)
diff --git a/client/site_tests/video_VideoDecodeAccelerator/control.vp8.import b/client/site_tests/video_VideoDecodeAccelerator/control.vp8.import
new file mode 100644
index 0000000..13e772a
--- /dev/null
+++ b/client/site_tests/video_VideoDecodeAccelerator/control.vp8.import
@@ -0,0 +1,39 @@
+# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+AUTHOR = "Chrome OS Team, chromeos-video@google.com"
+NAME = "video_VideoDecodeAccelerator.vp8.import"
+PURPOSE = """
+Verify Chromium hardware Video Decode Acceleration works with IMPORT mode
+"""
+CRITERIA = """
+This test will fail if any of the tests in video_decode_accelerator_unittest
+with IMPORT mode fails. Running video_decode_accelerator_unittest is skipped on
+machines that are known not to support video decode.
+"""
+ATTRIBUTES = "suite:bvt-perbuild"
+DEPENDENCIES= "arc"
+TIME = "SHORT"
+TEST_CATEGORY = "Functional"
+TEST_CLASS = "video"
+TEST_TYPE = "client"
+JOB_RETRIES = 2
+# Reboot in the lab after the test ends.
+DEPENDENCIES = "cleanup-reboot"
+BUG_TEMPLATE = {
+    'labels': ['OS-Chrome', 'VideoTestFailure'],
+    'cc': ['chromeos-video-test-failures@google.com'],
+}
+
+DOC = """
+This is a wrapper test for Chrome video_decode_accelerator_unittest with IMPORT
+mode.
+"""
+
+# The FPS expectations here are lower than observed in most runs to keep
+# the bots green.
+videos = ['test-25fps.vp8:320:240:250:250:35:150:11']
+
+job.run_test('video_VideoDecodeAccelerator', videos=videos,
+             capability='hw_dec_vp8_1080_30', import_mode=True)
diff --git a/client/site_tests/video_VideoDecodeAccelerator/control.vp9.import b/client/site_tests/video_VideoDecodeAccelerator/control.vp9.import
new file mode 100644
index 0000000..588f10c
--- /dev/null
+++ b/client/site_tests/video_VideoDecodeAccelerator/control.vp9.import
@@ -0,0 +1,39 @@
+# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+AUTHOR = "Chrome OS Team, chromeos-video@google.com"
+NAME = "video_VideoDecodeAccelerator.vp9.import"
+PURPOSE = """
+Verify Chromium Video Decode Acceleration for VP9 works with IMPORT mode.
+"""
+CRITERIA = """
+This test will fail if any of the tests in video_decode_accelerator_unittest
+with IMPORT mode fails. Running video_decode_accelerator_unittest is skipped on
+machines that are known not to support video decode.
+"""
+ATTRIBUTES = "suite:bvt-perbuild"
+DEPENDENCIES= "arc"
+TIME = "SHORT"
+TEST_CATEGORY = "Functional"
+TEST_CLASS = "video"
+TEST_TYPE = "client"
+JOB_RETRIES = 2
+# Reboot in the lab after the test ends.
+DEPENDENCIES = "cleanup-reboot"
+BUG_TEMPLATE = {
+    'labels': ['OS-Chrome', 'VideoTestFailure'],
+    'cc': ['chromeos-video-test-failures@google.com'],
+}
+
+DOC = """
+This is a wrapper test for Chrome video_decode_accelerator_unittest with IMPORT
+mode.
+"""
+
+# The FPS expectations here are lower than observed in most runs to keep
+# the bots green.
+videos = ['test-25fps.vp9:320:240:250:250:35:150:12']
+
+job.run_test('video_VideoDecodeAccelerator', videos=videos,
+             capability='hw_dec_vp9_1080_30', import_mode=True)
diff --git a/client/site_tests/video_VideoDecodeAccelerator/control.vp9_2.import b/client/site_tests/video_VideoDecodeAccelerator/control.vp9_2.import
new file mode 100644
index 0000000..8233d77
--- /dev/null
+++ b/client/site_tests/video_VideoDecodeAccelerator/control.vp9_2.import
@@ -0,0 +1,40 @@
+# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+AUTHOR = "Chrome OS Team, chromeos-video@google.com"
+NAME = "video_VideoDecodeAccelerator.vp9_2.import"
+PURPOSE = """
+Verify Chromium Video Decode Acceleration for VP9 Profile 2 works with IMPORT
+mode.
+"""
+CRITERIA = """
+This test will fail if any of the tests in video_decode_accelerator_unittest
+with IMPORT mode fails. Running video_decode_accelerator_unittest is skipped on
+machines that are known not to support video decode.
+"""
+ATTRIBUTES = "suite:bvt-perbuild"
+DEPENDENCIES= "arc"
+TIME = "SHORT"
+TEST_CATEGORY = "Functional"
+TEST_CLASS = "video"
+TEST_TYPE = "client"
+JOB_RETRIES = 2
+# Reboot in the lab after the test ends.
+DEPENDENCIES = "cleanup-reboot"
+BUG_TEMPLATE = {
+    'labels': ['OS-Chrome', 'VideoTestFailure'],
+    'cc': ['chromeos-video-test-failures@google.com'],
+}
+
+DOC = """
+This is a wrapper test for Chrome video_decode_accelerator_unittest with IMPORT
+mode.
+"""
+
+# The FPS expectations here are lower than observed in most runs to keep
+# the bots green.
+videos = ['test-25fps.vp9_2:320:240:250:250:35:150:14']
+
+job.run_test('video_VideoDecodeAccelerator', videos=videos,
+             capability='hw_dec_vp9-2_1080_30', import_mode=True)
diff --git a/client/site_tests/video_VideoDecodeAccelerator/video_VideoDecodeAccelerator.py b/client/site_tests/video_VideoDecodeAccelerator/video_VideoDecodeAccelerator.py
index 3689fe1..369ba39 100644
--- a/client/site_tests/video_VideoDecodeAccelerator/video_VideoDecodeAccelerator.py
+++ b/client/site_tests/video_VideoDecodeAccelerator/video_VideoDecodeAccelerator.py
@@ -21,7 +21,8 @@
 
     @helper_logger.video_log_wrapper
     @chrome_binary_test.nuke_chrome
-    def run_once(self, videos, capability, use_cr_source_dir=True):
+    def run_once(self, videos, capability, import_mode=False,
+                 use_cr_source_dir=True):
         """
         Runs video_decode_accelerator_unittest on the videos.
 
@@ -51,6 +52,10 @@
             cmd_line_list.append(helper_logger.chrome_vmodule_flag())
             cmd_line_list.append('--ozone-platform=gbm')
 
+            if import_mode:
+                cmd_line_list.append('--test_import')
+                cmd_line_list.append('--frame_validator=check')
+
             cmd_line = ' '.join(cmd_line_list)
             try:
                 self.run_chrome_test_binary(self.binary, cmd_line)