1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include <OCPlatform.h>
24 //Uncomment the below line for testing with Mocks
25 //TODO enable these tests (unconditionally) after CA code clean up
29 #include "hippomocks.h"
30 #include "Framework.h"
32 #define GTEST_DONT_DEFINE_TEST 1
34 #include <gtest/gtest.h>
36 namespace ConstructResourceTest
39 std::vector<std::string> ifaces = {DEFAULT_INTERFACE};
40 //using mocks framework
41 GTEST_TEST(ConstructResourceObjectTest, ConstructResourceObjectValidReturnValue)
44 OCResource::Ptr rightdoor = std::shared_ptr<OCResource>();
45 OCConnectivityType connectivityType = OC_WIFI;
46 mocks.ExpectCallFunc(OCPlatform::constructResourceObject).Return(rightdoor);
47 std::vector<std::string> types = {"core.leftdoor"};
48 OCResource::Ptr leftdoor = OCPlatform::constructResourceObject("192.168.1.2:5000",
49 "a/leftdoor", connectivityType, false, types, ifaces);
50 EXPECT_EQ(leftdoor, rightdoor);
54 GTEST_TEST(ConstructResourceObjectTest, ConstructResourceObjectInValidReturnValue)
57 OCResource::Ptr rightdoor = std::shared_ptr<OCResource>();
58 OCConnectivityType connectivityType = OC_WIFI;
59 mocks.ExpectCallFunc(OCPlatform::constructResourceObject).Return(NULL);
60 std::vector<std::string> types = {"core.rightdoor"};
61 OCResource::Ptr leftdoor = OCPlatform::constructResourceObject("192.168.1.2:5000",
62 "a/rightdoor", connectivityType, false, types, ifaces);
63 bool value = (leftdoor == NULL);
64 EXPECT_EQ(true, value);