camera_V4L2: only test FirstFrameAfterStreamOn when config file exists

Since this is new requirement, we only test the case when device has the
config file.

BUG=chromium:734891
TEST=pass camera_V4L2 on stout

Change-Id: I988f2a675d3beeb87a0f752cee61f0cb3b0d3b74
Reviewed-on: https://chromium-review.googlesource.com/541001
Commit-Ready: Heng-ruey Hsu <henryhsu@google.com>
Tested-by: Heng-ruey Hsu <henryhsu@google.com>
Reviewed-by: Heng-ruey Hsu <henryhsu@google.com>
diff --git a/client/site_tests/camera_V4L2/src/camera_characteristics.cc b/client/site_tests/camera_V4L2/src/camera_characteristics.cc
index 64df19e..1755667 100644
--- a/client/site_tests/camera_V4L2/src/camera_characteristics.cc
+++ b/client/site_tests/camera_V4L2/src/camera_characteristics.cc
@@ -85,27 +85,8 @@
   FILE* file = base::OpenFile(path, "r");
   if (!file) {
     LOG(INFO) << __func__ << ": Can't open file "
-              << kCameraCharacteristicsConfigFile
-              << ". Use default characteristics instead";
-    DeviceInfos device_infos;
-    for (const auto& device : devices) {
-      device_infos.push_back(kDefaultCharacteristics);
-      size_t pos = device.first.find(":");
-      if (pos != std::string::npos) {
-        // If configuration file doesn't exist, the two attributes should be
-        // true.
-        device_infos.back().resolution_1280x960_unsupported = true;
-        device_infos.back().resolution_1600x1200_unsupported = true;
-        device_infos.back().constant_framerate_unsupported = true;
-
-        device_infos.back().device_path = device.second;
-        device_infos.back().usb_vid = device.first.substr(0, pos - 1);
-        device_infos.back().usb_pid = device.first.substr(pos + 1);
-      } else {
-        LOG(ERROR) << __func__ << ": Invalid device: " << device.first;
-      }
-    }
-    return device_infos;
+              << kCameraCharacteristicsConfigFile;
+    return DeviceInfos();
   }
 
   DeviceInfos tmp_device_infos;
diff --git a/client/site_tests/camera_V4L2/src/media_v4l2_test.cc b/client/site_tests/camera_V4L2/src/media_v4l2_test.cc
index 216d595..5137c95 100644
--- a/client/site_tests/camera_V4L2/src/media_v4l2_test.cc
+++ b/client/site_tests/camera_V4L2/src/media_v4l2_test.cc
@@ -22,7 +22,7 @@
          "Options:\n"
          "--help               Print usage\n"
          "--device=DEVICE_NAME Video device name [/dev/video]\n"
-         "--usb-info=VID:PID   Device vendor id and product id\n",
+         "--usb-info=VID:PID   Device vendor id and product id\n"
          "--constant-framerate Only test constant framerate\n",
          argv[0]);
 }
@@ -477,6 +477,7 @@
   bool check_1280x960 = false;
   bool check_1600x1200 = false;
   bool support_constant_framerate = false;
+  bool check_first_jpeg_frame_valid = false;
   uint32_t skip_frames = 0;
   if (device_infos.size() > 1) {
     printf("[Error] One device should not have multiple configs.\n");
@@ -488,6 +489,7 @@
     support_constant_framerate =
         !device_infos[0].constant_framerate_unsupported;
     skip_frames = device_infos[0].frames_to_skip_after_streamon;
+    check_first_jpeg_frame_valid = true;
   }
   printf("[Info] check 1280x960: %d\n", check_1280x960);
   printf("[Info] check 1600x1200: %d\n", check_1600x1200);
@@ -502,7 +504,8 @@
     if (!TestResolutions(dev_name, check_1280x960, check_1600x1200, false)) {
       return EXIT_FAILURE;
     }
-    if (!TestFirstFrameAfterStreamOn(dev_name, skip_frames)) {
+    if (check_first_jpeg_frame_valid &&
+        !TestFirstFrameAfterStreamOn(dev_name, skip_frames)) {
       return EXIT_FAILURE;
     }
   } else if (support_constant_framerate) {