1 /*
2  * Copyright (c) 2023-2023 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 <memory>
17 #include <string>
18 #include "gtest/gtest.h"
19 #include "plugin/plugins/source/file_source/file_source_plugin.h"
20 
21 namespace OHOS {
22 namespace Media {
23 namespace Test {
24 using namespace OHOS::Media::Plugin;
25 using namespace testing::ext;
26 
27 class TestFileSourcePlugin : public ::testing::Test {
28 public:
29     std::shared_ptr<FileSource::FileSourcePlugin> fileSourcePlugin;
SetUp()30     void SetUp() override
31     {
32         fileSourcePlugin = std::make_shared<FileSource::FileSourcePlugin>("test");
33     }
34 
TearDown()35     void TearDown() override
36     {
37     }
38 };
39 
40 HWTEST_F(TestFileSourcePlugin, test_init, TestSize.Level1)
41 {
42     auto status = fileSourcePlugin->Init();
43     EXPECT_EQ(Status::OK, status);
44 }
45 
46 HWTEST_F(TestFileSourcePlugin, test_prepare, TestSize.Level1)
47 {
48     auto status = fileSourcePlugin->Prepare();
49     EXPECT_EQ(Status::OK, status);
50 }
51 
52 HWTEST_F(TestFileSourcePlugin, test_reset, TestSize.Level1)
53 {
54     auto status = fileSourcePlugin->Reset();
55     EXPECT_EQ(Status::OK, status);
56 }
57 
58 HWTEST_F(TestFileSourcePlugin, test_set_callback, TestSize.Level1)
59 {
60     Callback* cb  = nullptr;
61     auto status = fileSourcePlugin->SetCallback(cb);
62     EXPECT_EQ(Status::ERROR_UNIMPLEMENTED, status);
63     delete cb;
64 }
65 
66 HWTEST_F(TestFileSourcePlugin, test_get_size, TestSize.Level1)
67 {
68     uint64_t size = 10;
69     auto status = fileSourcePlugin->GetSize(size);
70     EXPECT_EQ(Status::ERROR_WRONG_STATE, status);
71 }
72 
73 HWTEST_F(TestFileSourcePlugin, test_seek_to, TestSize.Level1)
74 {
75     auto status = fileSourcePlugin->SeekTo(10);
76     EXPECT_EQ(Status::ERROR_WRONG_STATE, status);
77 }
78 
79 HWTEST_F(TestFileSourcePlugin, test_set_get_parameter, TestSize.Level1)
80 {
81     Tag tag = Tag::SECTION_VIDEO_UNIVERSAL_START;
82     ValueType value = 2;
83     auto status = fileSourcePlugin->GetParameter(tag, value);
84     EXPECT_EQ(Status::ERROR_UNIMPLEMENTED, status);
85     status = fileSourcePlugin->SetParameter(tag, value);
86     EXPECT_EQ(Status::ERROR_UNIMPLEMENTED, status);
87 }
88 
89 HWTEST_F(TestFileSourcePlugin, test_deinit_status, TestSize.Level1)
90 {
91     auto status = fileSourcePlugin->Deinit();
92     EXPECT_EQ(Status::OK, status);
93 }
94 } // namespace Test
95 } // namespace Media
96 } // namespace OHOS
97