• 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 "runtime_extractor.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 using JsModuleReader = OHOS::AbilityRuntime::JsModuleReader;
24 using RuntimeExtractor = OHOS::AbilityRuntime::RuntimeExtractor;
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", "", nullptr);
57     std::vector<uint8_t> result = jsModuleReader("", "");
58     EXPECT_EQ(result.size(), 0);
59 }
60 
61 /**
62  * @tc.name: JsModuleReaderTest_0200
63  * @tc.desc: JsModuleReaderTest Test
64  * @tc.type: FUNC
65  * @tc.require: issueI581RO
66  */
67 HWTEST_F(JsModuleReaderTest, JsModuleReaderTest_0200, TestSize.Level0)
68 {
69     auto extractor = std::make_shared<RuntimeExtractor>("");
70     if (extractor == nullptr) {
71         EXPECT_TRUE(extractor == nullptr);
72         return;
73     }
74     JsModuleReader jsModuleReader("JsModuleReader", "", extractor);
75     std::vector<uint8_t> result = jsModuleReader("", "");
76     EXPECT_EQ(result.size(), 0);
77 }
78 
79 /**
80  * @tc.name: JsModuleReaderTest_0300
81  * @tc.desc: JsModuleReaderTest test
82  * @tc.type: FUNC
83  * @tc.require: issueI581RO
84  */
85 HWTEST_F(JsModuleReaderTest, JsModuleReaderTest_0300, TestSize.Level0)
86 {
87     auto extractor = std::make_shared<RuntimeExtractor>("");
88     if (extractor == nullptr) {
89         EXPECT_TRUE(extractor == nullptr);
90         return;
91     }
92     JsModuleReader jsModuleReader("JsModuleReader", "", extractor);
93     std::vector<uint8_t> result = jsModuleReader("/test", "/test2");
94     EXPECT_EQ(result.size(), 0);
95 }
96 }  // namespace AAFwk
97 }  // namespace OHOS
98