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 "FileTest"
16
17#include <unistd.h>
18#include <gtest/gtest.h>
19#include <string>
20#include <cstring>
21
22#include "logger.h"
23#include "file.h"
24#include "unified_meta.h"
25
26using namespace testing::ext;
27using namespace OHOS::UDMF;
28using namespace OHOS;
29namespace OHOS::Test {
30using namespace std;
31
32class FileTest : public testing::Test {
33public:
34    static void SetUpTestCase();
35    static void TearDownTestCase();
36    void SetUp() override;
37    void TearDown() override;
38};
39
40void FileTest::SetUpTestCase()
41{
42}
43
44void FileTest::TearDownTestCase()
45{
46}
47
48void FileTest::SetUp()
49{
50}
51
52void FileTest::TearDown()
53{
54}
55
56/**
57* @tc.name: File001
58* @tc.desc: Normal testcase of File
59* @tc.type: FUNC
60*/
61HWTEST_F(FileTest, File001, TestSize.Level1)
62{
63    LOG_INFO(UDMF_TEST, "File001 begin.");
64    UDType type = UDType::ENTITY;
65    ValueType value = "string";
66    OHOS::UDMF::File file(type, value);
67    EXPECT_EQ(file.dataType_, UDType::FILE);
68    EXPECT_EQ(file.oriUri_.length(), std::get<std::string>(value).length());
69    LOG_INFO(UDMF_TEST, "File001 end.");
70}
71
72/**
73* @tc.name: File002
74* @tc.desc: Normal testcase of File
75* @tc.type: FUNC
76*/
77HWTEST_F(FileTest, File002, TestSize.Level1)
78{
79    LOG_INFO(UDMF_TEST, "File002 begin.");
80    UDType type = UDType::ENTITY;
81    ValueType value = 0;
82    OHOS::UDMF::File file(type, value);
83    EXPECT_EQ(file.dataType_, UDType::FILE);
84    EXPECT_EQ(file.oriUri_.length(), 0);
85    LOG_INFO(UDMF_TEST, "File002 end.");
86}
87} // OHOS::Test