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