1 /*
2  * Copyright (c) 2022 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 "authorization_result.h"
19 
20 namespace OHOS {
21 namespace AppExecFwk {
22 using namespace testing::ext;
23 using namespace OHOS::AbilityRuntime;
24 class AuthorizationResultTest : public testing::Test {
25 public:
26     static void SetUpTestCase(void);
27     static void TearDownTestCase(void);
28     void SetUp();
29     void TearDown();
30 };
31 
SetUpTestCase(void)32 void AuthorizationResultTest::SetUpTestCase(void)
33 {}
34 
TearDownTestCase(void)35 void AuthorizationResultTest::TearDownTestCase(void)
36 {}
37 
SetUp(void)38 void AuthorizationResultTest::SetUp(void)
39 {}
40 
TearDown(void)41 void AuthorizationResultTest::TearDown(void)
42 {}
43 
44 /**
45  * @tc.number: GrantResultsCallback_0100
46  * @tc.name: GrantResultsCallback
47  * @tc.desc: Grant Results Callback sucess
48  */
49 HWTEST_F(AuthorizationResultTest, GrantResultsCallback_0100, Function | MediumTest | Level1)
50 {
51     PermissionRequestTask task = [](const std::vector<std::string>& vecString, const std::vector<int>& vecInt)
__anon71a83f3e0102(const std::vector<std::string>& vecString, const std::vector<int>& vecInt) 52     { GTEST_LOG_(INFO) << "GrantResultsCallback_0100 task called"; };
53     auto authorizationResult = new AbilityRuntime::AuthorizationResult(std::move(task));
54     EXPECT_NE(authorizationResult, nullptr);
55     std::vector<std::string> permissions;
56     std::vector<int> grantResults;
57     authorizationResult->GrantResultsCallback(permissions, grantResults);
58 }
59 
60 /**
61  * @tc.number: GrantResultsCallback_0200
62  * @tc.name: GrantResultsCallback
63  * @tc.desc: Grant Results Callback failed
64  */
65 HWTEST_F(AuthorizationResultTest, GrantResultsCallback_0200, Function | MediumTest | Level1)
66 {
67     PermissionRequestTask task;
68     auto authorizationResult = new AbilityRuntime::AuthorizationResult(std::move(task));
69     EXPECT_NE(authorizationResult, nullptr);
70     std::vector<std::string> permissions;
71     std::vector<int> grantResults;
72     authorizationResult->GrantResultsCallback(permissions, grantResults);
73 }
74 } // namespace AppExecFwk
75 } // namespace OHOS