|
| 1 | +#include <string> |
| 2 | +#include <list> |
| 3 | +#include <thread> |
| 4 | +#include <chrono> |
| 5 | +#include "CameraFixture.h" |
| 6 | +#include "ClientCommunicator.h" |
| 7 | + |
| 8 | +using namespace std; |
| 9 | +using namespace android; |
| 10 | +using namespace std::chrono_literals; |
| 11 | + |
| 12 | + |
| 13 | +void CameraFixture::runStreamer(){ |
| 14 | + cc.IsRunning = true; |
| 15 | + cc.startDummyStreamer(); |
| 16 | +} |
| 17 | + |
| 18 | +CameraFixture::CameraFixture() |
| 19 | +{ |
| 20 | + SetCallback(); |
| 21 | + t1 = new thread(&CameraFixture::runStreamer, this); |
| 22 | + this_thread::sleep_for(1500ms); |
| 23 | + std::vector<std::shared_ptr<ClientCommunicator>> mClientThread = gVirtualCameraFactory.getClientThread(); |
| 24 | + client_thread = mClientThread[clientId]; |
| 25 | +} |
| 26 | + |
| 27 | +void CameraFixture::SetUp() |
| 28 | +{ |
| 29 | +} |
| 30 | + |
| 31 | +void CameraFixture::TearDown() |
| 32 | +{ |
| 33 | +} |
| 34 | + |
| 35 | +CameraFixture::~CameraFixture() |
| 36 | +{ |
| 37 | + cc.IsRunning = false; |
| 38 | + t1->join(); |
| 39 | +} |
| 40 | + |
| 41 | +TEST_F(CameraFixture, ClientWithOneCamera) |
| 42 | +{ |
| 43 | + ASSERT_EQ(NoCameraPresent, gVirtualCameraFactory.get_number_of_cameras()); |
| 44 | + cc.RequestCameraCapability(); |
| 45 | + cc.sendOneCameraConfig(); |
| 46 | + this_thread::sleep_for(500ms); |
| 47 | + ASSERT_EQ(OneCameraClient, gVirtualCameraFactory.get_number_of_cameras()); |
| 48 | + gVirtualCameraFactory.clearCameraInfo(clientId); |
| 49 | +} |
| 50 | + |
| 51 | +TEST_F(CameraFixture, ClientWithTwoCamera) |
| 52 | +{ |
| 53 | + cc.RequestCameraCapability(); |
| 54 | + cc.sendTwoCameraConfig(); |
| 55 | + this_thread::sleep_for(500ms); |
| 56 | + ASSERT_EQ(TwoCameraClient, gVirtualCameraFactory.get_number_of_cameras()); |
| 57 | + gVirtualCameraFactory.clearCameraInfo(clientId); |
| 58 | +} |
| 59 | + |
| 60 | +TEST_F(CameraFixture, ClientWithMultiCamera) |
| 61 | +{ |
| 62 | + cc.RequestCameraCapability(); |
| 63 | + cc.sendMultipleCameraConfig(); |
| 64 | + this_thread::sleep_for(500ms); |
| 65 | + ASSERT_EQ(MultiCameraClient, gVirtualCameraFactory.get_number_of_cameras()); |
| 66 | + gVirtualCameraFactory.clearCameraInfo(clientId); |
| 67 | +} |
| 68 | + |
| 69 | +TEST_F(CameraFixture, CheckForCodecType) |
| 70 | +{ |
| 71 | + ASSERT_EQ(ValidType, client_thread->IsCodecTypeValid((uint32_t)kH264)); |
| 72 | + ASSERT_EQ(ValidType, client_thread->IsCodecTypeValid((uint32_t)kH265)); |
| 73 | + ASSERT_EQ(InvalidType, client_thread->IsCodecTypeValid((uint32_t)WAV)); |
| 74 | +} |
| 75 | + |
| 76 | +TEST_F(CameraFixture, CheckForFacing) |
| 77 | +{ |
| 78 | + ASSERT_EQ(ValidType, client_thread->IsCameraFacingValid((uint32_t)BACK_FACING)); |
| 79 | + ASSERT_EQ(ValidType, client_thread->IsCameraFacingValid((uint32_t)FRONT_FACING)); |
| 80 | + ASSERT_EQ(InvalidType, client_thread->IsCameraFacingValid((uint32_t)FRONTCORNER_FACING)); |
| 81 | +} |
| 82 | + |
| 83 | +TEST_F(CameraFixture, CheckForOrientation) |
| 84 | +{ |
| 85 | + ASSERT_EQ(ValidType, client_thread->IsSensorOrientationValid((uint32_t)ORIENTATION_90)); |
| 86 | + ASSERT_EQ(ValidType, client_thread->IsSensorOrientationValid((uint32_t)ORIENTATION_270)); |
| 87 | + ASSERT_EQ(InvalidType, client_thread->IsSensorOrientationValid((uint32_t)ORIENTATION_360)); |
| 88 | +} |
| 89 | + |
| 90 | +TEST_F(CameraFixture, CheckForResolution) |
| 91 | +{ |
| 92 | + ASSERT_EQ(ValidType, client_thread->IsResolutionValid((uint32_t)k720p)); |
| 93 | + ASSERT_EQ(ValidType, client_thread->IsResolutionValid((uint32_t)k1080p)); |
| 94 | + ASSERT_EQ(InvalidType, client_thread->IsResolutionValid((uint32_t)k2160p)); |
| 95 | +} |
| 96 | + |
| 97 | +TEST_F(CameraFixture, MultipleCameraCapReq) |
| 98 | +{ |
| 99 | + cc.RequestCameraCapability(); |
| 100 | + cc.RequestCameraCapability(); |
| 101 | + cc.RequestCameraCapability(); |
| 102 | + cc.sendMultipleCameraConfig(); |
| 103 | + this_thread::sleep_for(500ms); |
| 104 | + ASSERT_EQ(TwoCameraClient, gVirtualCameraFactory.get_number_of_cameras()); |
| 105 | + gVirtualCameraFactory.clearCameraInfo(clientId); |
| 106 | +} |
| 107 | + |
0 commit comments