2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "libmm_fileinfo_unittest.h"
20 #define GTEST_VIDEO_FILE_PATH "/usr/bin/libmm-fileinfo-unittest.mp4"
21 #define GTEST_SOUND_FILE_PATH "/usr/bin/libmm-fileinfo-unittest.mp3"
23 using ::testing::InitGoogleTest;
24 using ::testing::Test;
25 using ::testing::TestCase;
27 class libmm_fileinfo_Test : public ::testing::Test {
30 std::cout << "SetUp()" << std::endl;
34 std::cout << "TearDown()" << std::endl;
38 TEST(libmm_fileinfo_Test, mm_file_create_content_attrs_p)
40 int ret = FILEINFO_ERROR_NONE;
41 MMHandleType content_attrs;
43 ret = mm_file_create_content_attrs(&content_attrs, GTEST_VIDEO_FILE_PATH);
44 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
46 ret = mm_file_destroy_content_attrs(content_attrs);
47 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
50 TEST(libmm_fileinfo_Test, mm_file_get_content_attrs_p)
52 int ret = FILEINFO_ERROR_NONE;
53 MMHandleType content_attrs;
54 char *err_attr_name = NULL;
57 ret = mm_file_create_content_attrs(&content_attrs, GTEST_VIDEO_FILE_PATH);
58 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
60 ret = mm_file_get_attrs(content_attrs, &err_attr_name, MM_FILE_CONTENT_DURATION, &p, NULL);
61 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
64 ret = mm_file_get_attrs(content_attrs, &err_attr_name, MM_FILE_CONTENT_VIDEO_BITRATE, &p, NULL);
65 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
68 ret = mm_file_get_attrs(content_attrs, &err_attr_name, MM_FILE_CONTENT_VIDEO_FPS, &p, NULL);
69 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
72 ret = mm_file_get_attrs(content_attrs, &err_attr_name, MM_FILE_CONTENT_VIDEO_WIDTH, &p, NULL);
73 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
76 ret = mm_file_get_attrs(content_attrs, &err_attr_name, MM_FILE_CONTENT_VIDEO_HEIGHT, &p, NULL);
77 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
80 ret = mm_file_destroy_content_attrs(content_attrs);
81 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
84 TEST(libmm_fileinfo_Test, mm_file_create_tag_attrs_p)
86 int ret = FILEINFO_ERROR_NONE;
87 MMHandleType tag_attrs;
89 ret = mm_file_create_tag_attrs(&tag_attrs, GTEST_VIDEO_FILE_PATH);
90 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
92 ret = mm_file_destroy_tag_attrs(tag_attrs);
93 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
96 TEST(libmm_fileinfo_Test, mm_file_get_tag_attrs_p)
98 int ret = FILEINFO_ERROR_NONE;
99 MMHandleType tag_attrs;
100 char *err_attr_name = NULL;
102 unsigned int size = 0;
104 ret = mm_file_create_tag_attrs(&tag_attrs, GTEST_VIDEO_FILE_PATH);
105 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
107 ret = mm_file_get_attrs(tag_attrs, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
108 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
109 EXPECT_STREQ(p, "Test");
111 ret = mm_file_get_attrs(tag_attrs, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL);
112 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
113 EXPECT_STREQ(p, "Test");
115 ret = mm_file_get_attrs(tag_attrs, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
116 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
117 EXPECT_STREQ(p, "Test");
119 ret = mm_file_get_attrs(tag_attrs, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
120 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
121 EXPECT_STREQ(p, "Test");
123 ret = mm_file_destroy_tag_attrs(tag_attrs);
124 EXPECT_EQ(ret, FILEINFO_ERROR_NONE);
127 int main(int argc, char **argv)
129 InitGoogleTest(&argc, argv);
131 return RUN_ALL_TESTS();