2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file AttributeSetter.h
18 * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
20 * @brief Stub for attribute_facade.h
22 #ifndef _TEST_ACE_TESTS_ATTRIBUTE_SETTER_
23 #define _TEST_ACE_TESTS_ATTRIBUTE_SETTER_
29 #include <dpl/singleton.h>
30 #include <dpl/foreach.h>
31 #include <dpl/log/log.h>
33 #include <ace/Request.h>
34 #include <ace/WRT_INTERFACE.h>
36 class AttributeSetter {
38 typedef std::list<std::string> ValueList;
39 typedef std::map<std::string, ValueList> AttributeMap;
40 typedef std::map<int, AttributeMap> CollectionHandlerMap;
42 typedef std::list<ATTRIBUTE> Evil;
44 void get(const Request &request,
47 int handle = request.getWidgetHandle();
49 CollectionHandlerMap::iterator widgetContextIt =
50 m_collectionMap.find(handle);
52 if (widgetContextIt == m_collectionMap.end()) {
53 LogError("WidgetContext is empty");
59 std::string attrName = *(it->first);
61 if (attrName == "device-cap") {
62 Request::DeviceCapabilitySet devCapSet =
63 request.getDeviceCapabilitySet();
64 std::copy(devCapSet.begin(),
66 std::back_inserter(*(it->second)));
70 AttributeMap::iterator attrIt =
71 widgetContextIt->second.find(attrName);
73 if (attrIt == widgetContextIt->second.end()) {
74 LogError("No attribute: " << attrName <<
75 " in context nr: " << handle);
76 const ATTRIBUTE &a = *it;
77 const_cast<ATTRIBUTE&>(a).second = NULL;
81 ValueList valueList = attrIt->second;
83 std::copy(valueList.begin(),
85 std::back_inserter(*(it->second)));
89 void addValue(int handler,
90 const std::string &attributeName,
91 const std::string &attributeValue)
93 m_collectionMap[handler][attributeName].push_back(attributeValue);
96 std::string getValue(int handler, const std::string &attributeName)
98 std::list<std::string> lst = m_collectionMap[handler][attributeName];
100 return "fake-device-name-that-should-not-match-with-anything";
104 void addValue(int handler,
105 const char *attributeName,
106 const char *attributeValue)
108 std::string aN = attributeName;
109 std::string aV = attributeValue;
110 addValue(handler, aN, aV);
114 m_collectionMap.clear();
120 CollectionHandlerMap m_collectionMap;
123 typedef DPL::Singleton<AttributeSetter> AttributeSetterSingleton;
125 #endif // _TEST_ACE_TESTS_ATTRIBUTE_SETTER_