Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "media/capture/video/linux/camera_facing_chromeos.h" | 7 #include "media/capture/video/linux/camera_config_chromeos.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 #include <base/files/file_util.h> | 10 #include <base/files/file_util.h> |
| 11 #include <base/files/file.h> | 11 #include <base/files/file.h> |
| 12 | 12 |
| 13 namespace media { | 13 namespace media { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 const char kConfigFileContent[] = | 17 const char kConfigFileContent[] = |
| 18 "camera0.lens_facing=1\ncamera0.sensor_orientation=0\ncamera0.module0.usb_" | 18 "camera0.lens_facing=1\ncamera0.sensor_orientation=90\ncamera0.module0.usb_" |
| 19 "vid_pid=04f2:b53a\n"; | 19 "vid_pid=04f2:b53a\n"; |
| 20 } | 20 } |
| 21 | 21 |
| 22 TEST(CameraFacingChromeOSTest, ParseSuccessfully) { | 22 TEST(CameraConfigChromeOSTest, ParseSuccessfully) { |
| 23 const char file_name[] = "fake_camera_characteristics.conf"; | 23 const char file_name[] = "fake_camera_characteristics.conf"; |
| 24 base::WriteFile(base::FilePath(file_name), kConfigFileContent, | 24 base::WriteFile(base::FilePath(file_name), kConfigFileContent, |
| 25 sizeof(kConfigFileContent)); | 25 sizeof(kConfigFileContent)); |
| 26 | 26 |
| 27 std::string file_name_str(file_name); | 27 std::string file_name_str(file_name); |
| 28 CameraFacingChromeOS camera_facing(file_name_str); | 28 CameraConfigChromeOS camera_config(file_name_str); |
| 29 EXPECT_EQ(VideoFacingMode::MEDIA_VIDEO_FACING_ENVIRONMENT, | 29 EXPECT_EQ(VideoFacingMode::MEDIA_VIDEO_FACING_ENVIRONMENT, |
| 30 camera_facing.GetCameraFacing(std::string("/dev/video2"), | 30 camera_config.GetCameraFacing(std::string("/dev/video2"), |
| 31 std::string("04f2:b53a"))); | |
| 32 EXPECT_EQ(90, camera_config.GetOrientation(std::string("/dev/video2"), | |
| 33 std::string("04f2:b53a"))); | |
| 34 } | |
| 35 | |
| 36 TEST(CameraConfigChromeOSTest, ConfigFileNotExist) { | |
| 37 CameraConfigChromeOS camera_config(std::string("file_not_exist")); | |
| 38 EXPECT_EQ(VideoFacingMode::MEDIA_VIDEO_FACING_NONE, | |
| 39 camera_config.GetCameraFacing(std::string("/dev/video2"), | |
| 31 std::string("04f2:b53a"))); | 40 std::string("04f2:b53a"))); |
| 32 } | 41 } |
|
wuchengli
2017/01/24 04:18:22
Also check orientation here.
shenghao
2017/01/24 14:29:52
Done.
| |
| 33 | 42 |
| 34 TEST(CameraFacingChromeOSTest, ConfigFileNotExist) { | |
| 35 CameraFacingChromeOS camera_facing(std::string("file_not_exist")); | |
| 36 EXPECT_EQ(VideoFacingMode::MEDIA_VIDEO_FACING_NONE, | |
| 37 camera_facing.GetCameraFacing(std::string("/dev/video2"), | |
| 38 std::string("04f2:b53a"))); | |
| 39 } | |
| 40 | |
| 41 } // namespace media | 43 } // namespace media |
| OLD | NEW |