Release version 0.26.2
[platform/core/appfw/pkgmgr-info.git] / test / unit_tests / test_request_type.cc
1 /*
2  * Copyright (c) 2021 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 <gtest/gtest.h>
18
19 #include <request_type.hh>
20
21 #include <cstdio>
22 #include <iostream>
23 #include <tuple>
24
25 namespace pc = pkgmgr_common;
26
27 class RequestTypeTest : public ::testing::Test {
28  public:
29   virtual void SetUp() {}
30
31   virtual void TearDown() {}
32 };
33
34 TEST_F(RequestTypeTest, GetAppInfoTypeTest) {
35   pc::ReqType type = pc::ReqType::GET_APP_INFO;
36   EXPECT_EQ(strcmp(ReqTypeToString(type), "GET_APP_INFO"), 0);
37 }
38
39 TEST_F(RequestTypeTest, GetPkgInfoTypeTest) {
40   pc::ReqType type = pc::ReqType::GET_PKG_INFO;
41   EXPECT_EQ(strcmp(ReqTypeToString(type), "GET_PKG_INFO"), 0);
42 }
43
44 TEST_F(RequestTypeTest, SetPkgInfoTypeTest) {
45   pc::ReqType type = pc::ReqType::SET_PKG_INFO;
46   EXPECT_EQ(strcmp(ReqTypeToString(type), "SET_PKG_INFO"), 0);
47 }
48
49 TEST_F(RequestTypeTest, SetCertInfoTypeTest) {
50   pc::ReqType type = pc::ReqType::SET_CERT_INFO;
51   EXPECT_EQ(strcmp(ReqTypeToString(type), "SET_CERT_INFO"), 0);
52 }
53
54 TEST_F(RequestTypeTest, GetCertInfoTypeTest) {
55   pc::ReqType type = pc::ReqType::GET_CERT_INFO;
56   EXPECT_EQ(strcmp(ReqTypeToString(type), "GET_CERT_INFO"), 0);
57 }
58
59 TEST_F(RequestTypeTest, GetPkgDepInfoTypeTest) {
60   pc::ReqType type = pc::ReqType::GET_PKG_DEP_INFO;
61   EXPECT_EQ(strcmp(ReqTypeToString(type), "GET_PKG_DEP_INFO"), 0);
62 }
63
64 TEST_F(RequestTypeTest, GetQueryTypeTest) {
65   pc::ReqType type = pc::ReqType::READ_QUERY;
66   EXPECT_EQ(strcmp(ReqTypeToString(type), "READ_QUERY"), 0);
67 }
68
69 TEST_F(RequestTypeTest, SetQueryTypeTest) {
70   pc::ReqType type = pc::ReqType::WRITE_QUERY;
71   EXPECT_EQ(strcmp(ReqTypeToString(type), "WRITE_QUERY"), 0);
72 }
73
74 TEST_F(RequestTypeTest, CommandTypeTest) {
75   pc::ReqType type = pc::ReqType::COMMAND;
76   EXPECT_EQ(strcmp(ReqTypeToString(type), "COMMAND"), 0);
77 }
78
79 TEST_F(RequestTypeTest, NoneTypeTest) {
80   pc::ReqType type = pc::ReqType::REQ_TYPE_NONE;
81   EXPECT_EQ(strcmp(ReqTypeToString(type), "ERROR_REQ_TYPE"), 0);
82 }
83
84 TEST_F(RequestTypeTest, MaxTypeTest) {
85   pc::ReqType type = pc::ReqType::MAX;
86   EXPECT_EQ(strcmp(ReqTypeToString(type), "ERROR_REQ_TYPE"), 0);
87 }