• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 
16 #include <gtest/gtest.h>
17 
18 #include "dcamera_post_authorization_event.h"
19 #include "dcamera_capture_info_cmd.h"
20 #include "distributed_hardware_log.h"
21 
22 using namespace testing::ext;
23 
24 namespace OHOS {
25 namespace DistributedHardware {
26 class DCameraPostAuthorizationEventTest : public testing::Test {
27 public:
28     static void SetUpTestCase(void);
29     static void TearDownTestCase(void);
30     void SetUp();
31     void TearDown();
32 
33     std::shared_ptr<DCameraCaptureInfo> videoInfo;
34     std::vector<std::shared_ptr<DCameraCaptureInfo>> captureInfos;
35     std::shared_ptr<EventSender> testsender_;
36     std::shared_ptr<DCameraPostAuthorizationEvent> testDCameraPostAuthorizationEvent_;
37 };
38 
39 namespace {
40     constexpr int32_t TEST_WIDTH = 640;
41     constexpr int32_t TEST_HEIGHT = 480;
42     constexpr int32_t TEST_FORMAT_VIDEO = OHOS_CAMERA_FORMAT_RGBA_8888;
43 }
44 
SetUpTestCase(void)45 void DCameraPostAuthorizationEventTest::SetUpTestCase(void)
46 {
47         DHLOGI("DCameraPostAuthorizationEventTest SetUpTestCase");
48 }
49 
TearDownTestCase(void)50 void DCameraPostAuthorizationEventTest::TearDownTestCase(void)
51 {
52         DHLOGI("DCameraPostAuthorizationEventTest TearDownTestCase");
53 }
54 
SetUp(void)55 void DCameraPostAuthorizationEventTest::SetUp(void)
56 {
57     DHLOGI("DCameraPostAuthorizationEventTest SetUp");
58     videoInfo = std::make_shared<DCameraCaptureInfo>();
59     videoInfo->width_ = TEST_WIDTH;
60     videoInfo->height_ = TEST_HEIGHT;
61     videoInfo->format_ = TEST_FORMAT_VIDEO;
62     videoInfo->isCapture_ = true;
63     videoInfo->streamType_ = CONTINUOUS_FRAME;
64     captureInfos.push_back(videoInfo);
65     testsender_ = std::make_shared<EventSender>();
66     testDCameraPostAuthorizationEvent_ = std::make_shared<DCameraPostAuthorizationEvent>(*testsender_, captureInfos);
67 }
68 
TearDown(void)69 void DCameraPostAuthorizationEventTest::TearDown(void)
70 {
71     DHLOGI("DCameraPostAuthorizationEventTest SetUp");
72     testsender_ = nullptr;
73     testDCameraPostAuthorizationEvent_ = nullptr;
74 }
75 
76 /**
77  * @tc.name: dcamera_post_authorization_event_test_001
78  * @tc.desc: Verify DCameraPostAuthorizationEvent init param correct
79  * @tc.type: FUNC
80  * @tc.require: Issue Number
81  */
82 HWTEST_F(DCameraPostAuthorizationEventTest, dcamera_post_authorization_event_test_001, TestSize.Level1)
83 {
84     std::vector<std::shared_ptr<DCameraCaptureInfo>> info = testDCameraPostAuthorizationEvent_->GetParam();
85     EXPECT_EQ(info.size(), captureInfos.size());
86 }
87 } // namespace DistributedHardware
88 } // namespace OHOS
89