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 <gmock/gmock.h>
18 #include <gtest/gtest.h>
21 #include "mm_player_priv.h"
22 #include "gtest_mm_player.h"
23 #include "gtest_mm_player_priv.h"
25 using ::testing::InitGoogleTest;
26 using ::testing::Test;
27 using ::testing::TestCase;
29 TEST(MMPlayerPreTest, Create_p)
31 int ret = MM_ERROR_NONE;
34 ret = player.Create();
35 EXPECT_EQ(ret, MM_ERROR_NONE);
38 TEST(MMPlayerPreTest, Destroy_p)
40 int ret = MM_ERROR_NONE;
43 ret = player.Create();
44 EXPECT_EQ(ret, MM_ERROR_NONE);
46 ret = player.Destroy();
47 EXPECT_EQ(ret, MM_ERROR_NONE);
50 TEST(MMPlayerPrePrivTest, Create_p)
52 int ret = MM_ERROR_NONE;
55 ret = player.Create();
56 EXPECT_EQ(ret, MM_ERROR_NONE);
59 TEST(MMPlayerPrePrivTest, Destroy_p)
61 int ret = MM_ERROR_NONE;
64 ret = player.Create();
65 EXPECT_EQ(ret, MM_ERROR_NONE);
67 ret = player.Destroy();
68 EXPECT_EQ(ret, MM_ERROR_NONE);
71 class MMPlayerPrivTest : public ::testing::Test {
74 virtual void TearDown();
77 MMPlayerPriv priv_player;
80 void MMPlayerPrivTest::SetUp()
82 int ret = MM_ERROR_NONE;
83 ret = priv_player.Create();
84 EXPECT_EQ(ret, MM_ERROR_NONE);
87 void MMPlayerPrivTest::TearDown()
89 int ret = MM_ERROR_NONE;
90 MMPlayerStateType state = MM_PLAYER_STATE_NULL;
92 ret = priv_player.GetCurrentState(&state);
93 if (ret != MM_ERROR_NONE)
94 LOGE("failed to get current state");
96 if (state > MM_PLAYER_STATE_NULL) {
97 ret = priv_player.Unrealize();
98 if (ret != MM_ERROR_NONE)
99 LOGE("failed to unrealize");
102 ret = priv_player.Destroy();
103 if (ret != MM_ERROR_NONE)
104 LOGE("failed to destroy");
107 TEST_F(MMPlayerPrivTest, Realize_P)
109 int ret = MM_ERROR_NONE;
110 const gchar *uri = "http://test-url.mp4";
112 ret = priv_player.SetUri(uri);
113 EXPECT_EQ(ret, MM_ERROR_NONE);
115 ret = priv_player.Realize();
116 EXPECT_EQ(ret, MM_ERROR_NONE);
119 TEST_F(MMPlayerPrivTest, Realize_N)
121 int ret = MM_ERROR_NONE;
122 ret = priv_player.Realize();
123 EXPECT_EQ(ret, MM_ERROR_PLAYER_INVALID_URI);
126 TEST_F(MMPlayerPrivTest, ParseProfile_p)
128 int ret = MM_ERROR_NONE;
129 const gchar *uri = "http://test-url";
130 int uri_type = MM_PLAYER_URI_TYPE_NONE;
132 ret = priv_player.ParseProfile(uri, &uri_type);
134 EXPECT_EQ(ret, MM_ERROR_NONE);
135 EXPECT_EQ(uri_type, MM_PLAYER_URI_TYPE_URL_HTTP);
138 TEST_F(MMPlayerPrivTest, ParseProfile_n)
140 int ret = MM_ERROR_NONE;
141 const gchar *uri = "file://non-existing-file.mp4";
143 ret = priv_player.ParseProfile(uri, NULL);
145 EXPECT_EQ(ret, MM_ERROR_PLAYER_FILE_NOT_FOUND);
148 gint main(gint argc, gchar **argv)
150 InitGoogleTest(&argc, argv);
152 return RUN_ALL_TESTS();