• 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 #include <memory>
16 
17 #include "gtest/gtest.h"
18 #define private public
19 #define protected public
20 #include "deeplink_reserve_config.h"
21 #undef private
22 #undef protected
23 
24 
25 namespace OHOS {
26 namespace AAFwk {
27 using namespace testing::ext;
28 class DeepLinkReserveConfigTest : public testing::Test {
29 public:
30     DeepLinkReserveConfigTest() = default;
31     virtual ~DeepLinkReserveConfigTest() = default;
32 
33     static void SetUpTestCase(void);
34     static void TearDownTestCase(void);
35     void SetUp();
36     void TearDown();
37 };
SetUpTestCase(void)38 void DeepLinkReserveConfigTest::SetUpTestCase(void)
39 {}
TearDownTestCase(void)40 void DeepLinkReserveConfigTest::TearDownTestCase(void)
41 {}
SetUp()42 void DeepLinkReserveConfigTest::SetUp()
43 {}
TearDown()44 void DeepLinkReserveConfigTest::TearDown()
45 {}
46 
47 /*
48  * Feature: deepLinkReserveConfig
49  * Function: IsLinkReserved
50  * SubFunction: NA
51  * FunctionPoints: deepLinkReserveConfig IsLinkReserved
52  * EnvConditions: NA
53  * CaseDescription: Verify that the deepLinkReserveConfig IsLinkReserved is normal.
54  */
55 HWTEST_F(DeepLinkReserveConfigTest, AaFwk_DeepLinkReserveConfigTest_0200, TestSize.Level1)
56 {
57     GTEST_LOG_(INFO) << "AaFwk_DeepLinkReserveConfigTest_0200 start";
58     DeepLinkReserveConfig deepLinkReserveConfig;
59     const nlohmann::json DEFAULT_CONFIG = R"(
60         {
61             "deepLinkReservedUri": [
62                 {
63                     "bundleName": "bundleName",
64                     "uris": [
65                         {
66                             "scheme": "http",
67                             "host": "www.xxx.com",
68                             "port": "80",
69                             "path": "path",
70                             "pathStartWith": "pathStartWith",
71                             "pathRegex": "pathRegex",
72                             "type": "type",
73                             "utd": "utd"
74                         }
75                     ]
76                 }
77             ]
78         }
79     )"_json;
80     deepLinkReserveConfig.LoadReservedUriList(DEFAULT_CONFIG);
81     std::string linkString = "http://www.xxx.com:80/pathRegex";
82     std::string bundleName = "just a test";
83     auto ans = deepLinkReserveConfig.IsLinkReserved(linkString, bundleName);
84     EXPECT_EQ(ans, true);
85     GTEST_LOG_(INFO) << "AaFwk_DeepLinkReserveConfigTest_0200 end";
86 }
87 
88 }  // namespace AAFwk
89 }  // namespace OHOS
90