• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "js_module_reader.h"
19 #include "extractor.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 using JsModuleReader = OHOS::AbilityRuntime::JsModuleReader;
24 using Extractor = OHOS::AbilityBase::Extractor;
25 
26 namespace OHOS {
27 namespace AAFwk {
28 class JsModuleReaderTest : public testing::Test {
29 public:
30     static void SetUpTestCase();
31     static void TearDownTestCase();
32     void SetUp() override;
33     void TearDown() override;
34 };
35 
SetUpTestCase()36 void JsModuleReaderTest::SetUpTestCase()
37 {}
38 
TearDownTestCase()39 void JsModuleReaderTest::TearDownTestCase()
40 {}
41 
SetUp()42 void JsModuleReaderTest::SetUp()
43 {}
44 
TearDown()45 void JsModuleReaderTest::TearDown()
46 {}
47 
48 /**
49  * @tc.name: JsModuleReaderTest_0100
50  * @tc.desc: JsModuleReaderTest Test
51  * @tc.type: FUNC
52  * @tc.require: issueI581SE
53  */
54 HWTEST_F(JsModuleReaderTest, JsModuleReaderTest_0100, TestSize.Level0)
55 {
56     JsModuleReader jsModuleReader("JsModuleReader", "");
57     uint8_t *buff = nullptr;
58     size_t buffSize = 0;
59     auto result = jsModuleReader("", &buff, &buffSize);
60     EXPECT_EQ(result, false);
61 }
62 
63 /**
64  * @tc.name: JsModuleReaderTest_0200
65  * @tc.desc: JsModuleReaderTest Test
66  * @tc.type: FUNC
67  * @tc.require: issueI581RO
68  */
69 HWTEST_F(JsModuleReaderTest, JsModuleReaderTest_0200, TestSize.Level0)
70 {
71     JsModuleReader jsModuleReader("JsModuleReader", "");
72     uint8_t *buff = nullptr;
73     size_t buffSize = 0;
74     auto result = jsModuleReader("bundleName/moduleName", &buff, &buffSize);
75     EXPECT_EQ(result, false);
76 }
77 
78 /**
79  * @tc.name: GetPresetAppHapPathTest_0100
80  * @tc.desc: GetPresetAppHapPath Test
81  * @tc.type: FUNC
82  */
83 HWTEST_F(JsModuleReaderTest, GetPresetAppHapPathTest_0100, TestSize.Level0)
84 {
85 JsModuleReader jsModuleReader("JsModuleReader", "");
86 std::string hapPath = jsModuleReader.GetPresetAppHapPath("");
87 EXPECT_TRUE(hapPath.empty());
88 }
89 
90 /**
91  * @tc.name: GetPresetAppHapPathTest_0200
92  * @tc.desc: GetPresetAppHapPath Test
93  * @tc.type: FUNC
94  */
95 HWTEST_F(JsModuleReaderTest, GetPresetAppHapPathTest_0200, TestSize.Level0)
96 {
97 JsModuleReader jsModuleReader("JsModuleReader", "/data/storage/el1/test.hsp");
98 std::string hapPath = jsModuleReader.GetPresetAppHapPath("");
99 EXPECT_TRUE(hapPath.empty());
100 }
101 }  // namespace AAFwk
102 }  // namespace OHOS
103