• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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_sink_callback_proxy.h"
19 #include "dcamera_sink_callback.h"
20 #include "distributed_camera_errno.h"
21 #include "distributed_camera_constants.h"
22 #include "distributed_camera_sink_proxy.h"
23 #include "distributed_hardware_log.h"
24 #include "if_system_ability_manager.h"
25 #include "iservice_registry.h"
26 
27 using namespace testing::ext;
28 
29 namespace OHOS {
30 namespace DistributedHardware {
31 class DcameraSinkCallbackProxyTest : public testing::Test {
32 public:
33     static void SetUpTestCase(void);
34     static void TearDownTestCase(void);
35     void SetUp();
36     void TearDown();
37 };
38 
SetUpTestCase(void)39 void DcameraSinkCallbackProxyTest::SetUpTestCase(void)
40 {
41     DHLOGI("DcameraSinkCallbackProxyTest::SetUpTestCase");
42 }
43 
TearDownTestCase(void)44 void DcameraSinkCallbackProxyTest::TearDownTestCase(void)
45 {
46     DHLOGI("DcameraSinkCallbackProxyTest::TearDownTestCase");
47 }
48 
SetUp(void)49 void DcameraSinkCallbackProxyTest::SetUp(void)
50 {
51     DHLOGI("DcameraSinkCallbackProxyTest::SetUp");
52 }
53 
TearDown(void)54 void DcameraSinkCallbackProxyTest::TearDown(void)
55 {
56     DHLOGI("DcameraSinkCallbackProxyTest::TearDown");
57 }
58 
59 /**
60  * @tc.name: dcamera_sink_callback_proxy_test_001
61  * @tc.desc: Verify the OnNotifyResourceInfo function.
62  * @tc.type: FUNC
63  * @tc.require: issue
64  */
65 HWTEST_F(DcameraSinkCallbackProxyTest, dcamera_sink_callback_proxy_test_001, TestSize.Level1)
66 {
67     DHLOGI("DcameraSinkCallbackProxyTest::dcamera_sink_callback_proxy_test_001");
68     sptr<ISystemAbilityManager> samgr =
69         SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
70     sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID);
71     sptr<DCameraSinkCallbackProxy> callbackProxy(new DCameraSinkCallbackProxy(remoteObject));
72     EXPECT_EQ(false, callbackProxy == nullptr);
73 }
74 
75 /**
76  * @tc.name: dcamera_sink_callback_proxy_test_002
77  * @tc.desc: Verify the OnNotifyResourceInfo function.
78  * @tc.type: FUNC
79  * @tc.require: issue
80  */
81 HWTEST_F(DcameraSinkCallbackProxyTest, dcamera_sink_callback_proxy_test_002, TestSize.Level1)
82 {
83     DHLOGI("DcameraSinkCallbackProxyTest::dcamera_sink_callback_proxy_test_002");
84     sptr<IRemoteObject> remoteObject = sptr<IRemoteObject>(new DCameraSinkCallback());
85     sptr<DCameraSinkCallbackProxy> callbackProxy(new DCameraSinkCallbackProxy(remoteObject));
86     EXPECT_EQ(false, callbackProxy == nullptr);
87 
88     int32_t ret = DCAMERA_BAD_VALUE;
89     ResourceEventType type = ResourceEventType::EVENT_TYPE_QUERY_RESOURCE;
90     std::string subtype("");
91     std::string newworkId("");
92     bool isSensitive = false;
93     bool isSameAccout = false;
94     ret = callbackProxy->OnNotifyResourceInfo(type, subtype, newworkId, isSensitive, isSameAccout);
95     EXPECT_EQ(DCAMERA_OK, ret);
96 }
97 } // namespace DistributedHardware
98 } // namespace OHOS