• 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     ASSERT_NE(samgr, nullptr);
71     sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID);
72     sptr<DCameraSinkCallbackProxy> callbackProxy(new DCameraSinkCallbackProxy(remoteObject));
73     EXPECT_EQ(false, callbackProxy == nullptr);
74 }
75 
76 /**
77  * @tc.name: dcamera_sink_callback_proxy_test_002
78  * @tc.desc: Verify the OnNotifyResourceInfo function.
79  * @tc.type: FUNC
80  * @tc.require: issue
81  */
82 HWTEST_F(DcameraSinkCallbackProxyTest, dcamera_sink_callback_proxy_test_002, TestSize.Level1)
83 {
84     DHLOGI("DcameraSinkCallbackProxyTest::dcamera_sink_callback_proxy_test_002");
85     sptr<IRemoteObject> remoteObject = sptr<IRemoteObject>(new DCameraSinkCallback());
86     sptr<DCameraSinkCallbackProxy> callbackProxy(new DCameraSinkCallbackProxy(remoteObject));
87     EXPECT_EQ(false, callbackProxy == nullptr);
88 
89     int32_t ret = DCAMERA_BAD_VALUE;
90     ResourceEventType type = ResourceEventType::EVENT_TYPE_QUERY_RESOURCE;
91     std::string subtype("");
92     std::string newworkId("");
93     bool isSensitive = false;
94     bool isSameAccout = false;
95     ret = callbackProxy->OnNotifyResourceInfo(type, subtype, newworkId, isSensitive, isSameAccout);
96     EXPECT_EQ(DCAMERA_OK, ret);
97 }
98 } // namespace DistributedHardware
99 } // namespace OHOS