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 #define private public
19 #include "nweb_adapter_helper.h"
20 #include "nweb_cookie_manager.h"
21 #include "nweb_helper.h"
22 #include "nweb.h"
23 
24 using namespace testing;
25 using namespace testing::ext;
26 using namespace OHOS;
27 
28 namespace OHOS::NWeb {
29 namespace {
30 const std::string MOCK_NWEB_INSTALLATION_DIR = "/data/app/el1/bundle/public/com.ohos.arkwebcore";
31 } // namespace
32 
33 class NapiWebCookieManagerTest : public testing::Test {
34 public:
35     static void SetUpTestCase(void);
36     static void TearDownTestCase(void);
37     void SetUp();
38     void TearDown();
39 };
40 
SetUpTestCase(void)41 void NapiWebCookieManagerTest::SetUpTestCase(void)
42 {}
43 
TearDownTestCase(void)44 void NapiWebCookieManagerTest::TearDownTestCase(void)
45 {}
46 
SetUp(void)47 void NapiWebCookieManagerTest::SetUp(void)
48 {}
49 
TearDown(void)50 void NapiWebCookieManagerTest::TearDown(void)
51 {}
52 
53 /**
54  * @tc.name: NapiWebCookieManagerTest_001
55  * @tc.desc: GetCookieManager.
56  * @tc.type: FUNC
57  * @tc.require: I5P91V
58  */
59 HWTEST_F(NapiWebCookieManagerTest, NapiWebCookieManagerTest_001, TestSize.Level1)
60 {
61     std::string hapPath = "";
62     if (access(MOCK_NWEB_INSTALLATION_DIR.c_str(), F_OK) == 0) {
63         hapPath = MOCK_NWEB_INSTALLATION_DIR;
64     }
65     NWebHelper::Instance().SetBundlePath(hapPath);
66     NWebAdapterHelper::Instance().Init(false);
67     std::shared_ptr<NWebCookieManager> cookieManager = NWebHelper::Instance().GetCookieManager();
68     EXPECT_EQ(cookieManager, nullptr);
69 }
70 } // namespace OHOS::NWeb
71