class IWidgetFeature
{
public:
- typedef std::pair<std::string, std::string> Param;
- typedef std::list<Param> Params;
- typedef Params::const_iterator ParamsIterator;
-
- public:
virtual ~IWidgetFeature()
{}
virtual std::string getName() const = 0;
- virtual bool isRequired() const = 0;
-
- virtual Params getParams() const = 0;
-
- virtual void addParam(const std::string& paramName,
- const std::string& paramValue) = 0;
-
virtual bool isRequestedByWidget() const = 0;
};
{
Api::IWidgetFeaturePtr feature(
new WidgetFeature(DPL::ToUTF8String((*it).name),
- (*it).required,
true)); // requested (WidgetFeature param)
- // iterating multimap
- FOREACH(iterator, (*it).params)
- {
- // adding features with key(first) and value(second)
- feature->addParam(DPL::ToUTF8String(iterator->first),
- DPL::ToUTF8String(iterator->second));
- }
-
outFeatures.push_back(feature);
}
// 'required' property false
Api::IWidgetFeaturePtr newFeature(new WidgetFeature(
dao.GetName(),
- false,
false));
// TODO what about feature params? aren't they needed
namespace WrtDeviceApis {
namespace WidgetDB {
WidgetFeature::WidgetFeature(const std::string& name,
- bool required,
bool requested) :
m_name(name),
- m_required(required),
m_requested(requested)
{
//LogDebug("entered");
return m_name;
}
-bool WidgetFeature::isRequired() const
-{
- //LogDebug("entered");
- return m_required;
-}
-
-Api::IWidgetFeature::Params WidgetFeature::getParams() const
-{
- //LogDebug("entered");
- return m_params;
-}
-
-void WidgetFeature::addParam(const std::string& paramName,
- const std::string& paramValue)
-{
- //LogDebug("entered");
- m_params.push_back(std::make_pair(paramName, paramValue));
-}
-
WidgetFeature::~WidgetFeature()
{
//LogDebug("entered");
{
public:
WidgetFeature(const std::string& name,
- bool required,
bool requested);
std::string getName() const;
- bool isRequired() const;
-
- Api::IWidgetFeature::Params getParams() const;
-
virtual ~WidgetFeature();
- virtual void addParam(const std::string& paramName,
- const std::string& paramValue);
-
virtual bool isRequestedByWidget() const;
private:
std::string m_name;
- bool m_required;
bool m_requested;
- Params m_params;
};
} // WidgetDB
} // WrtDeviceApis
}
}
-/*
- * Name: widgetDB_test_widget_feature
- * Description: check accessiblity of widget features and their values by
- * WidgetDB
- * Expected: feature names and values should match this, which was inserted into
- * widget database
- */
-RUNNER_TEST(widgetDB_test_widget_feature)
-{
- try {
- IWidgetDBPtr widget = getWidgetDB(2000);
- Features features = widget->getWidgetFeatures();
-
- RUNNER_ASSERT(features.size() == 5);
-
- FOREACH(it, features)
- {
- std::string name = (*it)->getName();
- if ("first_2000" == name) {
- RUNNER_ASSERT((*it)->getParams().size() == 4);
-
- RUNNER_ASSERT((*it)->isRequired());
- } else if ("second_2000" == name) {
- RUNNER_ASSERT((*it)->getParams().size() == 1);
- } else if ("third_2000" == name) {
- IWidgetFeature::Params params = (*it)->getParams();
-
- RUNNER_ASSERT(params.size() == 1);
- RUNNER_ASSERT_WHAT_EQUALS("third_2000", params.begin()->first);
- RUNNER_ASSERT_WHAT_EQUALS("thirdValue1", params.begin()->second);
- RUNNER_ASSERT(!(*it)->isRequired());
- } else if ("fourth_2000" == name) {
- RUNNER_ASSERT((*it)->getParams().size() == 0);
- } else if ("fifth_2000" == name) {
- RUNNER_ASSERT((*it)->getParams().size() == 0);
- } else {
- RUNNER_ASSERT(false);
- }
- }
- } catch (const WrtDeviceApis::Commons::SecurityException &e) {
- LogError("Exception thrown." << e.DumpToString());
- RUNNER_ASSERT(false);
- }
-}
-
-/*
- * Name: widgetDB_test_widget_feature2
- * Description: check if requesting features from WidgetDB throw excpetion if
- * widget does not exists
- * Expected: exception should be raise if widget does not exists
- */
-RUNNER_TEST(widgetDB_test_widget_feature2)
-{
- try {
- IWidgetDBPtr widget = getWidgetDB(2011); //no such widget
- Features features = widget->getWidgetFeatures();
-
- RUNNER_ASSERT(false);
- } catch (const WrtDeviceApis::Commons::SecurityException &e) {
- LogDebug("OK. Exception thrown." << e.DumpToString());
- }
-}
-
#undef RUNNER_ASSERT_WHAT_EQUALS