1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "usb_camera_test.h"
16
SetUpTestCase(void)17 void UtestUSBCameraTest::SetUpTestCase(void)
18 {}
TearDownTestCase(void)19 void UtestUSBCameraTest::TearDownTestCase(void)
20 {}
SetUp(void)21 void UtestUSBCameraTest::SetUp(void)
22 {
23 if (display_ == nullptr)
24 display_ = std::make_shared<TestDisplay>();
25 display_->FBInit();
26 display_->UsbInit();
27 }
TearDown(void)28 void UtestUSBCameraTest::TearDown(void)
29 {
30 display_->Close();
31 }
32
33 /**
34 * @tc.name: USB Camera
35 * @tc.desc: USB Camera, getCameraID success.
36 * @tc.level: Level0
37 * @tc.size: MediumTest
38 * @tc.type: Function
39 */
TEST_F(UtestUSBCameraTest,camera_usb_0001)40 TEST_F(UtestUSBCameraTest, camera_usb_0001)
41 {
42 std::cout << "==========[test log] USB Camera, getCameraID success."<< std::endl;
43 std::vector<std::string> cameraIds;
44 std::cout << "==========[test log] 1. get current system cameraID."<< std::endl;
45 display_->cameraHost->GetCameraIds(cameraIds);
46 std::cout << "==========[test log] First cameraId.size = " << cameraIds.size() << std::endl;
47 std::cout << "==========[test log] OnCameraStatus interface has been mobilized" << std::endl;
48 for (auto &cameraId : cameraIds) {
49 std::cout << "==========[test log] cameraId = " << cameraId << std::endl;
50 }
51 std::cout << "==========[test log] 2. please add or delete the usb camera, wait for 10s..."<< std::endl;
52 sleep(10);
53 std::cout << "==========[test log] r u ready? wait for 10s..."<< std::endl;
54 sleep(10);
55 std::cout << "==========[test log] 3. check zhe cameraID again... wait for 10s..."<< std::endl;
56 sleep(10);
57 std::cout << "==========[test log] Second cameraId.size = " << cameraIds.size() << std::endl;
58 if (cameraIds.size() == 1) {
59 cameraIds.clear();
60 }
61 display_->cameraHost->GetCameraIds(cameraIds);
62 for (auto &cameraId : cameraIds) {
63 std::cout << "cameraId = " << cameraId << std::endl;
64 }
65 }