Merge remote-tracking branch 'origin/master' into notification-service
[platform/upstream/iotivity.git] / service / easy-setup / mediator / richsdk / unittests / ESEnrolleeSimulator.h
1 //******************************************************************
2 //
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
21 #ifndef _ES_MEDIATOR_SIMULATOR_H_
22 #define _ES_MEDIATOR_SIMULATOR_H_
23
24 #include <iostream>
25
26 #include "OCPlatform.h"
27 #include "OCApi.h"
28 #include "oic_malloc.h"
29
30 #include "escommon.h"
31 #include "ESEnrolleeCommon.h"
32 #include "easysetup.h"
33
34 #define PROV_RESOURCE_TYPE "ocf.wk.prov"
35
36 class ESEnrolleeSimulator
37 {
38 public:
39     ESEnrolleeSimulator()
40     {
41     };
42     ~ESEnrolleeSimulator() = default;
43
44     ESEnrolleeSimulator(const ESEnrolleeSimulator &) = delete;
45     ESEnrolleeSimulator & operator = (const ESEnrolleeSimulator &) = delete;
46
47     ESEnrolleeSimulator(ESEnrolleeSimulator &&) = delete;
48     ESEnrolleeSimulator & operator = (ESEnrolleeSimulator &&) = delete;
49
50     ESResult initEnrollee()
51     {
52         ESResourceMask resourcemMask = (ESResourceMask)(ES_WIFI_RESOURCE |
53                                                     ES_CLOUD_RESOURCE |
54                                                     ES_DEVCONF_RESOURCE);
55         ESProvisioningCallbacks callbacks;
56
57         callbacks.WiFiProvCb = &onWiFiProvisioning;
58         callbacks.DevConfProvCb = &onDevConfProvisioning;
59         callbacks.CloudDataProvCb = &onCloudProvisioning;
60
61         return ESInitEnrollee(false, resourcemMask, callbacks);
62     }
63
64     ESResult setDeviceProperty()
65     {
66         ESDeviceProperty deviceProperty = {
67             {{WIFI_11G, WiFi_EOF}, WIFI_5G}, {"Test Device", "Test Model Number"}
68         };
69
70         return ESSetDeviceProperty(&deviceProperty);
71     }
72
73     ESResult setESState()
74     {
75         return ESSetState(ES_STATE_CONNECTED_TO_ENROLLER);
76     }
77
78     ESResult setESErrorCode()
79     {
80         return ESSetErrorCode(ES_ERRCODE_NO_INTERNETCONNECTION);
81     }
82
83 private:
84     static void onWiFiProvisioning(ESWiFiProvData* /*data*/)
85     {
86     }
87
88     static void onDevConfProvisioning(ESDevConfProvData* /*data*/)
89     {
90     }
91
92     static void onCloudProvisioning(ESCloudProvData* /*data*/)
93     {
94     }
95 };
96
97 #endif //_NS_CONSUMER_SIMULATOR_H_