Add unit test for RequestBroker
[platform/core/appfw/tizen-theme-manager.git] / test / unit_tests / test_theme_info.cc
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <stdlib.h>
18 #include <gtest/gtest.h>
19
20 #include <iostream>
21 #include <memory>
22
23 #include "theme/loader/theme_info.h"
24
25 using ttm::loader::ThemeInfo;
26
27 class ThemeInfoTest : public testing::Test {
28  public:
29   virtual ~ThemeInfoTest() {}
30
31   virtual void SetUp() {
32     b_.Add("id", "testid");
33     b_.Add("pkgid", "testpkgid");
34     b_.Add("uid", "5001");
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");
41   }
42
43   virtual void TearDown() {
44   }
45
46   tizen_base::Bundle b_;
47 };
48
49 TEST_F(ThemeInfoTest, ThemeInfo_GetId) {
50   ThemeInfo info(b_);
51
52   EXPECT_EQ(info.GetId(), "testid");
53 }
54
55 TEST_F(ThemeInfoTest, ThemeInfo_GetPkgid) {
56   ThemeInfo info(b_);
57
58   EXPECT_EQ(info.GetPkgid(), "testpkgid");
59 }
60
61 TEST_F(ThemeInfoTest, ThemeInfo_GetUid) {
62   ThemeInfo info(b_);
63
64   EXPECT_EQ(info.GetUid(), 5001);
65 }
66
67 TEST_F(ThemeInfoTest, ThemeInfo_GetVersion) {
68   ThemeInfo info(b_);
69
70   EXPECT_EQ(info.GetVersion(), "1.0");
71 }
72
73 TEST_F(ThemeInfoTest, ThemeInfo_GetToolVersion) {
74   ThemeInfo info(b_);
75
76   EXPECT_EQ(info.GetToolVersion(), "1.1");
77 }
78
79 TEST_F(ThemeInfoTest, ThemeInfo_GetTitle) {
80   ThemeInfo info(b_);
81
82   EXPECT_EQ(info.GetTitle(), "Test");
83 }
84
85 TEST_F(ThemeInfoTest, ThemeInfo_GetResolution) {
86   ThemeInfo info(b_);
87
88   EXPECT_EQ(info.GetResolution(), "360X360");
89 }
90
91 TEST_F(ThemeInfoTest, ThemeInfo_GetPreview) {
92   ThemeInfo info(b_);
93
94   EXPECT_EQ(info.GetPreview(), "shared/res/preview.png");
95 }
96
97 TEST_F(ThemeInfoTest, ThemeInfo_GetDescription) {
98   ThemeInfo info(b_);
99
100   EXPECT_EQ(info.GetDescription(), "test");
101 }
102
103 TEST_F(ThemeInfoTest, ThemeInfo_Serialize) {
104   ThemeInfo info(b_);
105
106   tizen_base::Bundle b = info.Serialize();
107   EXPECT_EQ(b.GetString("id"), "testid");
108   EXPECT_EQ(b.GetString("pkgid"), "testpkgid");
109   EXPECT_EQ(b.GetString("uid"), "5001");
110   EXPECT_EQ(b.GetString("version"), "1.0");
111   EXPECT_EQ(b.GetString("tool_version"), "1.1");
112   EXPECT_EQ(b.GetString("title"), "Test");
113   EXPECT_EQ(b.GetString("resolution"), "360X360");
114   EXPECT_EQ(b.GetString("preview"), "shared/res/preview.png");
115   EXPECT_EQ(b.GetString("description"), "test");
116 }