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 #define LOG_TAG "TextTest"
16
17 #include <unistd.h>
18 #include <gtest/gtest.h>
19 #include <string>
20
21 #include "logger.h"
22 #include "udmf_capi_common.h"
23 #include "html.h"
24
25 using namespace testing::ext;
26 using namespace OHOS::UDMF;
27 using namespace OHOS;
28 namespace OHOS::Test {
29 using namespace std;
30
31 class TextTest : public testing::Test {
32 public:
33 static void SetUpTestCase();
34 static void TearDownTestCase();
35 void SetUp() override;
36 void TearDown() override;
37 };
38
SetUpTestCase()39 void TextTest::SetUpTestCase()
40 {
41 }
42
TearDownTestCase()43 void TextTest::TearDownTestCase()
44 {
45 }
46
SetUp()47 void TextTest::SetUp()
48 {
49 }
50
TearDown()51 void TextTest::TearDown()
52 {
53 }
54
55 /**
56 * @tc.name: Text001
57 * @tc.desc: Normal testcase of Text
58 * @tc.type: FUNC
59 */
60 HWTEST_F(TextTest, Text001, TestSize.Level1)
61 {
62 LOG_INFO(UDMF_TEST, "Text001 begin.");
63 UDDetails variantMap;
64 variantMap.insert({ "details", "details"});
65 Text text(variantMap);
66 EXPECT_EQ(text.details_, variantMap);
67 LOG_INFO(UDMF_TEST, "Text001 end.");
68 }
69
70 /**
71 * @tc.name: InitObject001
72 * @tc.desc: Normal testcase of InitObject
73 * @tc.type: FUNC
74 */
75 HWTEST_F(TextTest, InitObject001, TestSize.Level1)
76 {
77 LOG_INFO(UDMF_TEST, "InitObject001 begin.");
78 Text text;
79 text.details_.insert({ "first", "second" });
80 text.InitObject();
81 auto object = std::get<std::shared_ptr<Object>>(text.value_);
82 auto details = std::get<std::shared_ptr<Object>>(object->value_[Text::DETAILS]);
83 EXPECT_NE(details->value_.size(), 0);
84 LOG_INFO(UDMF_TEST, "InitObject001 end.");
85 }
86 } // OHOS::Test