RDK Documentation (Open Sourced RDK Components)
testConfigVOP.cpp
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 // TODO: Include your class to test here.
21 
22 
23 /**
24 * @defgroup devicesettings
25 * @{
26 * @defgroup test
27 * @{
28 **/
29 
30 
31 #define BOOST_TEST_MODULE rpVOP
32 #define BOOST_TEST_MAIN
33 #include "boost/test/included/unit_test.hpp"
34 #include <iostream>
35 
36 #include "videoOutputPort.hpp"
37 #include "videoOutputPortConfig.hpp"
38 #include "audioOutputPortConfig.hpp"
39 
40 #include "videoResolution.hpp"
41 #include "frameRate.hpp"
42 #include "dsUtl.h"
43 #include "dsError.h"
44 #include "dsVideoPort.h"
45 #include "illegalArgumentException.hpp"
46 #include "list.hpp"
47 #include "exception.hpp"
48 
49 
50 #undef _DS_VIDEOOUTPUTPORTSETTINGS_H
51 #include "dsVideoPortSettings.h"
52 #undef _DS_VIDEORESOLUTIONSETTINGS_H
53 #include "dsVideoResolutionSettings.h"
54 
55 BOOST_AUTO_TEST_CASE(test_VideoOutputPortConfig_load)
56 {
57  BOOST_CHECK(rpVOP_init() == dsERR_NONE);
58  {
59  try {
60  device::AudioOutputPortConfig::getInstance().load();
61 
62  device::VideoOutputPortConfig & vConfig = device::VideoOutputPortConfig::getInstance();
63  device::List<device::VideoOutputPortType> vTypes = vConfig.getSupportedTypes();
64  BOOST_CHECK(vTypes.size() == 0);
65 
66  vConfig.load();
67  vTypes = vConfig.getSupportedTypes();
68  BOOST_CHECK(vTypes.size() == dsUTL_DIM(kSupportedPortTypes));
69  /* Verify Constants */
70  for (size_t i = 0; i < rpVOP_PIXELRES_MAX; i++) {
71  BOOST_CHECK(device::VideoOutputPortConfig::getInstance().getPixelResolution(i).getId() == i);
72  BOOST_CHECK(!device::VideoOutputPortConfig::getInstance().getPixelResolution(i).getName().empty());
73  BOOST_CHECK(device::VideoOutputPortConfig::getInstance().getPixelResolution(i).getId() == device::PixelResolution::getInstance(i).getId());
74  }
75  for (size_t i = 0; i < rpVOP_ASPECT_MAX; i++) {
76  BOOST_CHECK(device::VideoOutputPortConfig::getInstance().getAspectRatio(i).getId() == i);
77  BOOST_CHECK(!device::VideoOutputPortConfig::getInstance().getAspectRatio(i).getName().empty());
78  BOOST_CHECK(device::VideoOutputPortConfig::getInstance().getAspectRatio(i).getId() == device::AspectRatio::getInstance(i).getId());
79 
80  }
81  for (size_t i = 0; i < rpVOP_SSMODE_MAX; i++) {
82  BOOST_CHECK(device::VideoOutputPortConfig::getInstance().getSSMode(i).getId() == i);
83  BOOST_CHECK(!device::VideoOutputPortConfig::getInstance().getPortType(i).getName().empty());
84  BOOST_CHECK(device::VideoOutputPortConfig::getInstance().getSSMode(i).getId() == device::StereoScopicMode::getInstance(i).getId());
85 
86  }
87  for (size_t i = 0; i < rpVOP_FRAMERATE_MAX; i++) {
88  BOOST_CHECK(device::VideoOutputPortConfig::getInstance().getFrameRate(i).getId() == i);
89  BOOST_CHECK(!device::VideoOutputPortConfig::getInstance().getFrameRate(i).getName().empty());
90  BOOST_CHECK(device::VideoOutputPortConfig::getInstance().getFrameRate(i).getId() == device::FrameRate::getInstance(i).getId());
91 
92  }
93  BOOST_CHECK(device::VideoOutputPortConfig::getInstance().getPorts().size() == dsUTL_DIM(kPorts));
94 
95  for (size_t i = 0; i < dsUTL_DIM(kPorts); i++) {
96  BOOST_CHECK(device::VideoOutputPortConfig::getInstance().getPort(i).getId() == i);
97  }
98 
99  /* verify Capability */
100  vTypes = vConfig.getSupportedTypes();
101 
102  BOOST_CHECK(vTypes.size() == dsUTL_DIM(kSupportedPortTypes));
103 
104  for (size_t i = 0; i < vTypes.size(); i++) {
105  /* find this type in the kConfigs */
106  {
107  bool found = false;
108  for (size_t j = 0; j < dsUTL_DIM(kConfigs); j++) {
109  if (vTypes.at(i).getId() == kConfigs[i].typeId) {
110  BOOST_CHECK(std::string(vTypes.at(i).getName()).compare(kConfigs[i].name) == 0);
111  BOOST_CHECK(vTypes.at(i).isHDCPSupported() == kConfigs[i].hdcpSupported);
112  BOOST_CHECK(vTypes.at(i).getRestrictedResolution() == kConfigs[i].restrictedResollution);
113  BOOST_CHECK(vTypes.at(i).isDTCPSupported() == kConfigs[i].dtcpSupported);
114  found = true;
115  break;
116  }
117  }
118  }
119 
120  BOOST_CHECK(vTypes.at(i).getSupportedResolutions().size() == dsUTL_DIM(kResolutions));
121 
122  for (size_t j = 0; j < vTypes.at(i).getSupportedResolutions().size(); j++) {
123  BOOST_CHECK(std::string(vTypes.at(i).getSupportedResolutions().at(j).getName()).compare(std::string(kResolutions[j].name)) == 0);
124 
125  BOOST_CHECK(vTypes.at(i).getSupportedResolutions().at(j).getPixelResolution() == kResolutions[j].pixelResolution);
126 
127  BOOST_CHECK(vTypes.at(i).getSupportedResolutions().at(j).getAspectRatio() == kResolutions[j].aspectRatio);
128 
129  BOOST_CHECK(vTypes.at(i).getSupportedResolutions().at(j).getStereoscopicMode() == kResolutions[j].stereoScopicMode);
130 
131  BOOST_CHECK(vTypes.at(i).getSupportedResolutions().at(j).getFrameRate().getId() == kResolutions[j].frameRate);
132 
133  BOOST_CHECK(vTypes.at(i).getSupportedResolutions().at(j).isInterlaced() == kResolutions[j].interlaced);
134  BOOST_CHECK(vTypes.at(i).getSupportedResolutions().at(j).isEnabled());
135  }
136 
137  {
138  /* Check Ports */
139  BOOST_CHECK(vConfig.getPorts().size() == dsUTL_DIM(kPorts));
140  device::List<device::VideoOutputPortType> vPortTypes = vConfig.getSupportedTypes();
141  size_t k = 0;
142  for (size_t i = 0; i < vPortTypes.size(); i++) {
143 
144  for (size_t j = 0; j < vPortTypes.at(i).getPorts().size(); j++) {
145 
146  { /* find this port in kPorts */
147  bool found = false;
148  for (size_t k = 0; k < dsUTL_DIM(kPorts); k++) {
149  if (vPortTypes.at(i).getId() == kPorts[k].id.type && vPortTypes.at(i).getPorts().at(j).getIndex() == kPorts[k].id.index) {
150  BOOST_CHECK(vPortTypes.at(i).getPorts().at(j).getType().getId() == kPorts[k].id.type);
151  BOOST_CHECK(std::string(vPortTypes.at(i).getPorts().at(j).getResolution().getName()).compare(std::string(kPorts[k].defaultResolution)) == 0);
152  found = true;
153  break;
154  } else {
155  }
156  }
157  BOOST_CHECK(found);
158  }
159  }
160  }
161  }
162  }
163  }
164  catch (const device::IllegalArgumentException &e)
165  {
166  BOOST_CHECK(0);
167 
168  }
169  catch (const int &e)
170  {
171  BOOST_CHECK(0);
172 
173  }
174  catch (const dsError_t &e)
175  {
176  BOOST_CHECK(0);
177 
178  }
179  catch (const device::Exception &e) {
180  //e.dump();
181  BOOST_CHECK(0);
182  }
183  }
184 
185 }
186 
187 BOOST_AUTO_TEST_CASE(testDummy)
188 {
189  BOOST_CHECK(1 == 1);
190 }
191 
192 
193 /** @} */
194 /** @} */
device::List
This class is implemented using templates and it is used to maintain a container with the list of sup...
Definition: list.hpp:51
device::VideoOutputPortConfig
Definition: videoOutputPortConfig.hpp:45
device::VideoOutputPortType::isDTCPSupported
bool isDTCPSupported() const
This API is used to query if DTCP is supported by the port type.
Definition: videoOutputPortType.cpp:258
dsVideoPort.h
device::PixelResolution::getInstance
static const PixelResolution & getInstance(int id)
This function gets the instance of PixelResolution against the specified id, only if the id passed is...
Definition: pixelResolution.cpp:85
device::VideoOutputPortType::isHDCPSupported
bool isHDCPSupported() const
This API is used to query if HDCP is supported by the port type.
Definition: videoOutputPortType.cpp:272
dsError.h
Device Settings HAL error codes.
device::List::size
size_t size()
This function gets the size of the container.
Definition: list.hpp:118
device::StereoScopicMode::getInstance
static const StereoScopicMode & getInstance(int id)
This function gets an instance of the StereoScopicMode against the specified id, only if the id passe...
Definition: stereoScopicMode.cpp:78
dsUtl.h
Device Settings HAL utilities.
dsERR_NONE
@ dsERR_NONE
Definition: dsError.h:85
device::VideoOutputPortType::getPorts
const List< VideoOutputPort > getPorts() const
This function is used to get the list of videooutputporttype.
Definition: videoOutputPortType.cpp:184
videoResolution.hpp
It contains class and structure refrenced by the videoResolution.cpp file.
frameRate.hpp
This file defines FrameRate class to manage the video frame rate types.
device::AspectRatio::getInstance
static const AspectRatio & getInstance(int id)
This function gets the instance of the AspectRatio against the id specified, only if the id passed is...
Definition: aspectRatio.cpp:74
device::VideoOutputPortType::getSupportedResolutions
const List< VideoResolution > getSupportedResolutions() const
This API is used to get a list of supported Video Resolutions by the port type.
Definition: videoOutputPortType.cpp:311
device::DSConstant::getName
virtual const std::string & getName() const
This function is used to the get the data member name.
Definition: dsConstant.hpp:141
videoOutputPort.hpp
It contains class and structure refrenced by the videooutputport.cpp file.
device::Exception
This class handles exceptions occurring in DS module.
Definition: exception.hpp:52
device::VideoOutputPortType::getRestrictedResolution
int getRestrictedResolution() const
This function is used to get the resolution type which has been restricted from usage.
Definition: videoOutputPortType.cpp:298
device::IllegalArgumentException
This class extends Exception class to manage the expections caused due to illegal arguments.
Definition: illegalArgumentException.hpp:51
dsUTL_DIM
#define dsUTL_DIM(arr)
Device Settings general Array dimension calculation inline definition.
Definition: dsUtl.h:85
dsError_t
dsError_t
Device Settings API Error return codes.
Definition: dsError.h:84
device::DSConstant::getId
virtual int getId() const
This function is used to get the id.
Definition: dsConstant.hpp:130