RDK Documentation (Open Sourced RDK Components)
testConfigAOP.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 rpAOP
32 #define BOOST_TEST_MAIN
33 #include "boost/test/included/unit_test.hpp"
34 #include <iostream>
35 
36 #include "audioOutputPortConfig.hpp"
37 
38 #include "dsUtl.h"
39 #include "dsError.h"
40 #include "rpAudioOutputPort.h"
41 #include "audioEncoding.hpp"
42 #include "audioCompression.hpp"
43 #include "audioStereoMode.hpp"
44 #include "list.hpp"
45 #include "exception.hpp"
46 
47 
48 #undef _DS_AUDIOOUTPUTPORTSETTINGS_H
49 #include "rpAudioOutputPortSettings.h"
50 
51 BOOST_AUTO_TEST_CASE(test_AudioOutputPortConfig_load)
52 {
53  BOOST_CHECK(rpAOP_init() == dsERR_NONE);
54  {
55  try {
56  device::AudioOutputPortConfig & aConfig = device::AudioOutputPortConfig::getInstance();
57  device::List<device::AudioOutputPortType> aTypes = aConfig.getSupportedTypes();
58  BOOST_CHECK(aTypes.size() == 0);
59  aConfig.load();
60  aTypes = aConfig.getSupportedTypes();
61  BOOST_CHECK(aTypes.size() == dsUTL_DIM(kSupportedPortTypes));
62 
63  /* Verify Constants */
64  for (size_t i = 0; i < rpAOP_ENC_MAX; i++) {
65  BOOST_CHECK(device::AudioOutputPortConfig::getInstance().getEncoding(i).getId() == i);
66  BOOST_CHECK(!device::AudioOutputPortConfig::getInstance().getEncoding(i).getName().empty());
67  BOOST_CHECK(device::AudioOutputPortConfig::getInstance().getEncoding(i).getId() == device::AudioEncoding::getInstance(i).getId());
68  }
69  for (size_t i = 0; i < rpAOP_CMP_MAX; i++) {
70  BOOST_CHECK(device::AudioOutputPortConfig::getInstance().getCompression(i).getId() == i);
71  BOOST_CHECK(!device::AudioOutputPortConfig::getInstance().getCompression(i).getName().empty());
72  BOOST_CHECK(device::AudioOutputPortConfig::getInstance().getCompression(i).getId() == device::AudioEncoding::getInstance(i).getId());
73  }
74  for (size_t i = 0; i < rpAOP_STMODE_MAX; i++) {
75  BOOST_CHECK(device::AudioOutputPortConfig::getInstance().getStereoMode(i).getId() == i);
76  BOOST_CHECK(!device::AudioOutputPortConfig::getInstance().getStereoMode(i).getName().empty());
77  BOOST_CHECK(device::AudioOutputPortConfig::getInstance().getStereoMode(i).getId() == device::AudioEncoding::getInstance(i).getId());
78  }
79  for (size_t i = 0; i < rpAOP_TYPE_MAX; i++) {
80  BOOST_CHECK(device::AudioOutputPortConfig::getInstance().getPortType(i).getId() == i);
81  BOOST_CHECK(!device::AudioOutputPortConfig::getInstance().getPortType(i).getName().empty());
82  BOOST_CHECK(device::AudioOutputPortConfig::getInstance().getPortType(i).getId() == device::AudioEncoding::getInstance(i).getId());
83  }
84 
85  BOOST_CHECK(device::AudioOutputPortConfig::getInstance().getPorts().size() == dsUTL_DIM(kPorts));
86  for (size_t i = 0; i < dsUTL_DIM(kPorts); i++) {
87  BOOST_CHECK(device::AudioOutputPortConfig::getInstance().getPort(i).getId() == i);
88  }
89 
90  /* verify Capability */
91  aTypes = aConfig.getSupportedTypes();
92 
93  BOOST_CHECK(aTypes.size() == dsUTL_DIM(kSupportedPortTypes));
94 
95  for (size_t i = 0; i < aTypes.size(); i++) {
96 
97  BOOST_CHECK(std::string(aTypes.at(i).getName()).compare(kConfigs[i].name) == 0);
98  BOOST_CHECK(aTypes.at(i).getSupportedEncodings().size() == kConfigs[i].numSupportedEncodings);
99  {
100  for (size_t j = 0; j < aTypes.at(i).getSupportedEncodings().size(); j++) {
101  BOOST_CHECK(aTypes.at(i).getSupportedEncodings().at(j).getId() == int(kConfigs[i].encodings[j]));
102  BOOST_CHECK(std::string(aTypes.at(i).getSupportedEncodings().at(j).toString()).empty() == false);
103  //std::cout << aTypes.at(i).getSupportedEncodings().at(j).toString() << std::endl;
104  }
105  }
106  BOOST_CHECK(aTypes.at(i).getSupportedCompressions().size() == kConfigs[i].numSupportedCompressions);
107  {
108  for (size_t j = 0; j < aTypes.at(i).getSupportedCompressions().size(); j++) {
109  BOOST_CHECK(aTypes.at(i).getSupportedCompressions().at(j).getId() == int(kConfigs[i].compressions[j]));
110  BOOST_CHECK(std::string(aTypes.at(i).getSupportedCompressions().at(j).toString()).empty() == false);
111  //std::cout << aTypes.at(i).getSupportedCompressions().at(j).toString() << std::endl;
112  }
113  }
114  BOOST_CHECK(aTypes.at(i).getSupportedStereoModes().size() == kConfigs[i].numSupportedStereoModes);
115  {
116  for (size_t j = 0; j < aTypes.at(i).getSupportedStereoModes().size(); j++) {
117  BOOST_CHECK(aTypes.at(i).getSupportedStereoModes().at(j).getId() == int(kConfigs[i].stereoModes[j]));
118  BOOST_CHECK(std::string(aTypes.at(i).getSupportedStereoModes().at(j).toString()).empty() == false);
119  //std::cout << aTypes.at(i).getSupportedStereoModes().at(j).toString() << std::endl;
120  }
121  }
122  }
123 
124  {
125  /* Check Ports */
126  BOOST_CHECK(aConfig.getPorts().size() == dsUTL_DIM(kPorts));
127  device::List<device::AudioOutputPortType> vPortTypes = aConfig.getSupportedTypes();
128  size_t k = 0;
129  for (size_t i = 0; i < vPortTypes.size(); i++) {
130  for (size_t j = 0; j < vPortTypes.at(i).getPorts().size(); j++) {
131  BOOST_CHECK(vPortTypes.at(i).getPorts().at(j).getType() == kPorts[k].id.type);
132  BOOST_CHECK(vPortTypes.at(i).getPorts().at(j).getId() == k);
133  k++;
134  }
135  }
136  }
137 
138  }
139  catch (device::Exception &e)
140  {
141  e.dump();
142  BOOST_CHECK(0);
143  }
144  }
145 
146 }
147 
148 BOOST_AUTO_TEST_CASE(testDummy)
149 {
150  BOOST_CHECK(1 == 1);
151 }
152 
153 
154 /** @} */
155 /** @} */
device::AudioOutputPortType::getPorts
const List< AudioOutputPort > getPorts() const
This function is used to get the list of platform supported audio output ports.
Definition: audioOutputPortType.cpp:176
device::AudioEncoding::getInstance
static const AudioEncoding & getInstance(int id)
This function gets an AudioEncoding instance against the id parameter, only if the id passed is valid...
Definition: audioEncoding.cpp:82
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
dsError.h
Device Settings HAL error codes.
device::AudioOutputPortType::getSupportedStereoModes
const List< AudioStereoMode > getSupportedStereoModes() const
This API is used to get the list of audio stereo modes supported by the audio port.
Definition: audioOutputPortType.cpp:164
device::List::size
size_t size()
This function gets the size of the container.
Definition: list.hpp:118
dsUtl.h
Device Settings HAL utilities.
audioStereoMode.hpp
This file defines AudioStereoMode class for managing audio mode types.
dsERR_NONE
@ dsERR_NONE
Definition: dsError.h:85
device::AudioOutputPortType::getSupportedEncodings
const List< AudioEncoding > getSupportedEncodings() const
This API is used to get the list of audio encodings supported by the audio port .
Definition: audioOutputPortType.cpp:150
device::DSConstant::getName
virtual const std::string & getName() const
This function is used to the get the data member name.
Definition: dsConstant.hpp:141
device::Exception
This class handles exceptions occurring in DS module.
Definition: exception.hpp:52
device::AudioOutputPortConfig
Definition: audioOutputPortConfig.hpp:43
dsUTL_DIM
#define dsUTL_DIM(arr)
Device Settings general Array dimension calculation inline definition.
Definition: dsUtl.h:85
device::AudioOutputPortType::getSupportedCompressions
const List< AudioCompression > getSupportedCompressions() const
This API is used to get the list of audio compressions supported by the audio port.
Definition: audioOutputPortType.cpp:138
audioCompression.hpp
This file defines AudioCompression class for managing audio compression levels.
audioEncoding.hpp
This file defines AudioEncoding class for managing audio encoding types.