1fa7767c5Sopenharmony_ci/*
2fa7767c5Sopenharmony_ci * Copyright (c) 2023-2023 Huawei Device Co., Ltd.
3fa7767c5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4fa7767c5Sopenharmony_ci * you may not use this file except in compliance with the License.
5fa7767c5Sopenharmony_ci * You may obtain a copy of the License at
6fa7767c5Sopenharmony_ci *
7fa7767c5Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8fa7767c5Sopenharmony_ci *
9fa7767c5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10fa7767c5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11fa7767c5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fa7767c5Sopenharmony_ci * See the License for the specific language governing permissions and
13fa7767c5Sopenharmony_ci * limitations under the License.
14fa7767c5Sopenharmony_ci */
15fa7767c5Sopenharmony_ci
16fa7767c5Sopenharmony_ci#include <memory>
17fa7767c5Sopenharmony_ci#include <string>
18fa7767c5Sopenharmony_ci#include "gtest/gtest.h"
19fa7767c5Sopenharmony_ci#include "plugin/plugins/source/file_source/file_source_plugin.h"
20fa7767c5Sopenharmony_ci
21fa7767c5Sopenharmony_cinamespace OHOS {
22fa7767c5Sopenharmony_cinamespace Media {
23fa7767c5Sopenharmony_cinamespace Test {
24fa7767c5Sopenharmony_ciusing namespace OHOS::Media::Plugin;
25fa7767c5Sopenharmony_ciusing namespace testing::ext;
26fa7767c5Sopenharmony_ci
27fa7767c5Sopenharmony_ciclass TestFileSourcePlugin : public ::testing::Test {
28fa7767c5Sopenharmony_cipublic:
29fa7767c5Sopenharmony_ci    std::shared_ptr<FileSource::FileSourcePlugin> fileSourcePlugin;
30fa7767c5Sopenharmony_ci    void SetUp() override
31fa7767c5Sopenharmony_ci    {
32fa7767c5Sopenharmony_ci        fileSourcePlugin = std::make_shared<FileSource::FileSourcePlugin>("test");
33fa7767c5Sopenharmony_ci    }
34fa7767c5Sopenharmony_ci
35fa7767c5Sopenharmony_ci    void TearDown() override
36fa7767c5Sopenharmony_ci    {
37fa7767c5Sopenharmony_ci    }
38fa7767c5Sopenharmony_ci};
39fa7767c5Sopenharmony_ci
40fa7767c5Sopenharmony_ciHWTEST_F(TestFileSourcePlugin, test_init, TestSize.Level1)
41fa7767c5Sopenharmony_ci{
42fa7767c5Sopenharmony_ci    auto status = fileSourcePlugin->Init();
43fa7767c5Sopenharmony_ci    EXPECT_EQ(Status::OK, status);
44fa7767c5Sopenharmony_ci}
45fa7767c5Sopenharmony_ci
46fa7767c5Sopenharmony_ciHWTEST_F(TestFileSourcePlugin, test_prepare, TestSize.Level1)
47fa7767c5Sopenharmony_ci{
48fa7767c5Sopenharmony_ci    auto status = fileSourcePlugin->Prepare();
49fa7767c5Sopenharmony_ci    EXPECT_EQ(Status::OK, status);
50fa7767c5Sopenharmony_ci}
51fa7767c5Sopenharmony_ci
52fa7767c5Sopenharmony_ciHWTEST_F(TestFileSourcePlugin, test_reset, TestSize.Level1)
53fa7767c5Sopenharmony_ci{
54fa7767c5Sopenharmony_ci    auto status = fileSourcePlugin->Reset();
55fa7767c5Sopenharmony_ci    EXPECT_EQ(Status::OK, status);
56fa7767c5Sopenharmony_ci}
57fa7767c5Sopenharmony_ci
58fa7767c5Sopenharmony_ciHWTEST_F(TestFileSourcePlugin, test_set_callback, TestSize.Level1)
59fa7767c5Sopenharmony_ci{
60fa7767c5Sopenharmony_ci    Callback* cb  = nullptr;
61fa7767c5Sopenharmony_ci    auto status = fileSourcePlugin->SetCallback(cb);
62fa7767c5Sopenharmony_ci    EXPECT_EQ(Status::ERROR_UNIMPLEMENTED, status);
63fa7767c5Sopenharmony_ci    delete cb;
64fa7767c5Sopenharmony_ci}
65fa7767c5Sopenharmony_ci
66fa7767c5Sopenharmony_ciHWTEST_F(TestFileSourcePlugin, test_get_size, TestSize.Level1)
67fa7767c5Sopenharmony_ci{
68fa7767c5Sopenharmony_ci    uint64_t size = 10;
69fa7767c5Sopenharmony_ci    auto status = fileSourcePlugin->GetSize(size);
70fa7767c5Sopenharmony_ci    EXPECT_EQ(Status::ERROR_WRONG_STATE, status);
71fa7767c5Sopenharmony_ci}
72fa7767c5Sopenharmony_ci
73fa7767c5Sopenharmony_ciHWTEST_F(TestFileSourcePlugin, test_seek_to, TestSize.Level1)
74fa7767c5Sopenharmony_ci{
75fa7767c5Sopenharmony_ci    auto status = fileSourcePlugin->SeekToPos(10);
76fa7767c5Sopenharmony_ci    EXPECT_EQ(Status::ERROR_WRONG_STATE, status);
77fa7767c5Sopenharmony_ci}
78fa7767c5Sopenharmony_ci
79fa7767c5Sopenharmony_ciHWTEST_F(TestFileSourcePlugin, test_set_get_parameter, TestSize.Level1)
80fa7767c5Sopenharmony_ci{
81fa7767c5Sopenharmony_ci    Tag tag = Tag::SECTION_VIDEO_UNIVERSAL_START;
82fa7767c5Sopenharmony_ci    ValueType value = 2;
83fa7767c5Sopenharmony_ci    auto status = fileSourcePlugin->GetParameter(tag, value);
84fa7767c5Sopenharmony_ci    EXPECT_EQ(Status::ERROR_UNIMPLEMENTED, status);
85fa7767c5Sopenharmony_ci    status = fileSourcePlugin->SetParameter(tag, value);
86fa7767c5Sopenharmony_ci    EXPECT_EQ(Status::ERROR_UNIMPLEMENTED, status);
87fa7767c5Sopenharmony_ci}
88fa7767c5Sopenharmony_ci
89fa7767c5Sopenharmony_ciHWTEST_F(TestFileSourcePlugin, test_deinit_status, TestSize.Level1)
90fa7767c5Sopenharmony_ci{
91fa7767c5Sopenharmony_ci    auto status = fileSourcePlugin->Deinit();
92fa7767c5Sopenharmony_ci    EXPECT_EQ(Status::OK, status);
93fa7767c5Sopenharmony_ci}
94fa7767c5Sopenharmony_ci} // namespace Test
95fa7767c5Sopenharmony_ci} // namespace Media
96fa7767c5Sopenharmony_ci} // namespace OHOS
97