2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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.
18 #include <gtest/gtest.h>
23 #include "api/theme.h"
24 #include "api/theme_error.h"
25 #include "theme/loader/theme_info.h"
27 using ttm::loader::ThemeInfo;
29 class ThemeTest : public testing::Test {
31 virtual ~ThemeTest() {}
33 virtual void SetUp() {
34 b_.Add("id", "testid");
35 b_.Add("version", "1.0");
36 b_.Add("tool_version", "1.1");
37 b_.Add("title", "Test");
38 b_.Add("resolution", "360X360");
39 b_.Add("preview", "shared/res/preview.png");
40 b_.Add("description", "test");
43 virtual void TearDown() {
46 tizen_base::Bundle b_;
49 TEST_F(ThemeTest, Theme_GetId) {
50 std::shared_ptr<ThemeInfo> info(
52 theme_h handle = static_cast<void*>(&info);
54 int ret = theme_get_id(handle, &id);
56 EXPECT_EQ(ret, THEME_MANAGER_ERROR_NONE);
57 EXPECT_EQ(std::string(id), "testid");
62 TEST_F(ThemeTest, Theme_GetId_N) {
64 int ret = theme_get_id(nullptr, &id);
66 EXPECT_EQ(ret, THEME_MANAGER_ERROR_INVALID_PARAMETER);
69 TEST_F(ThemeTest, Theme_GetVersion) {
70 std::shared_ptr<ThemeInfo> info(
72 theme_h handle = static_cast<void*>(&info);
74 int ret = theme_get_version(handle, &version);
76 EXPECT_EQ(ret, THEME_MANAGER_ERROR_NONE);
77 EXPECT_EQ(std::string(version), "1.0");
82 TEST_F(ThemeTest, Theme_GetVersion_N) {
84 int ret = theme_get_version(nullptr, &version);
86 EXPECT_EQ(ret, THEME_MANAGER_ERROR_INVALID_PARAMETER);
89 TEST_F(ThemeTest, Theme_GetToolVersion) {
90 std::shared_ptr<ThemeInfo> info(
93 theme_h handle = static_cast<void*>(&info);
95 int ret = theme_get_tool_version(handle, &version);
97 EXPECT_EQ(ret, THEME_MANAGER_ERROR_NONE);
98 EXPECT_EQ(std::string(version), "1.1");
103 TEST_F(ThemeTest, Theme_GetToolVersion_N) {
105 int ret = theme_get_tool_version(nullptr, &version);
107 EXPECT_EQ(ret, THEME_MANAGER_ERROR_INVALID_PARAMETER);
110 TEST_F(ThemeTest, Theme_GetTitle) {
111 std::shared_ptr<ThemeInfo> info(
114 theme_h handle = static_cast<void*>(&info);
116 int ret = theme_get_title(handle, &title);
118 EXPECT_EQ(ret, THEME_MANAGER_ERROR_NONE);
119 EXPECT_EQ(std::string(title), "Test");
125 TEST_F(ThemeTest, Theme_GetTitle_N) {
127 int ret = theme_get_title(nullptr, &title);
129 EXPECT_EQ(ret, THEME_MANAGER_ERROR_INVALID_PARAMETER);
132 TEST_F(ThemeTest, Theme_GetResolution) {
133 std::shared_ptr<ThemeInfo> info(
136 theme_h handle = static_cast<void*>(&info);
138 int ret = theme_get_resolution(handle, &resolution);
140 EXPECT_EQ(ret, THEME_MANAGER_ERROR_NONE);
141 EXPECT_EQ(std::string(resolution), "360X360");
144 TEST_F(ThemeTest, Theme_GetResolution_N) {
146 int ret = theme_get_title(nullptr, &resolution);
148 EXPECT_EQ(ret, THEME_MANAGER_ERROR_INVALID_PARAMETER);
151 TEST_F(ThemeTest, Theme_GetPreview) {
152 std::shared_ptr<ThemeInfo> info(
155 theme_h handle = static_cast<void*>(&info);
157 int ret = theme_get_preview(handle, &preview);
159 EXPECT_EQ(ret, THEME_MANAGER_ERROR_NONE);
160 EXPECT_EQ(std::string(preview), "shared/res/preview.png");
165 TEST_F(ThemeTest, Theme_GetPreview_N) {
167 int ret = theme_get_preview(nullptr, &preview);
169 EXPECT_EQ(ret, THEME_MANAGER_ERROR_INVALID_PARAMETER);
172 TEST_F(ThemeTest, Theme_GetDescription) {
173 std::shared_ptr<ThemeInfo> info(
176 theme_h handle = static_cast<void*>(&info);
178 int ret = theme_get_description(handle, &description);
180 EXPECT_EQ(ret, THEME_MANAGER_ERROR_NONE);
181 EXPECT_EQ(std::string(description), "test");
186 TEST_F(ThemeTest, Theme_GetDescription_N) {
188 int ret = theme_get_description(nullptr, &description);
190 EXPECT_EQ(ret, THEME_MANAGER_ERROR_INVALID_PARAMETER);