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 "dlp_permission_proxy_test.h"
17 #include <cerrno>
18 #include <gtest/gtest.h>
19 #include <securec.h>
20 #include "dlp_permission.h"
21 #include "dlp_permission_log.h"
22 #include "iremote_stub.h"
23 
24 using namespace testing::ext;
25 using namespace OHOS;
26 using namespace OHOS::Security::DlpPermission;
27 using namespace std;
28 
29 namespace {
30 static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {
31     LOG_CORE, SECURITY_DOMAIN_DLP_PERMISSION, "DlpPermissionProxyTest"};
32 }
33 
SetUpTestCase()34 void DlpPermissionProxyTest::SetUpTestCase() {}
35 
TearDownTestCase()36 void DlpPermissionProxyTest::TearDownTestCase() {}
37 
SetUp()38 void DlpPermissionProxyTest::SetUp() {}
39 
TearDown()40 void DlpPermissionProxyTest::TearDown() {}
41 
42 class DlpTestRemoteObj : public IRemoteBroker {
43 public:
44     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.dlp.test");
45 
46     DlpTestRemoteObj() = default;
47     virtual ~DlpTestRemoteObj() noexcept = default;
48 };
49 
50 /**
51  * @tc.name: SetReadFlag001
52  * @tc.desc: SetReadFlag test
53  * @tc.type: FUNC
54  * @tc.require:
55  */
56 HWTEST_F(DlpPermissionProxyTest, SetReadFlag001, TestSize.Level1)
57 {
58     DLP_LOG_INFO(LABEL, "SetReadFlag001");
59 
60     sptr<DlpTestRemoteObj> callback = new (std::nothrow)IRemoteStub<DlpTestRemoteObj>();
61     EXPECT_TRUE(callback != nullptr);
62 
63     auto proxy = std::make_shared<DlpPermissionProxy>(callback->AsObject());
64     uint32_t uid = 0;
65     int32_t ret = proxy->SetReadFlag(uid);
66     ASSERT_NE(DLP_SERVICE_ERROR_PARCEL_OPERATE_FAIL, ret);
67 }
68