#include "gtest/gtest.h"
#include "cainterface.h"
+#include "cautilinterface.h"
#include "cacommon.h"
#define CA_TRANSPORT_ADAPTER_SCOPE 1000
void request_handler(CAEndpoint_t* object, CARequestInfo_t* requestInfo);
void response_handler(CAEndpoint_t* object, CAResponseInfo_t* responseInfo);
void error_handler(const CAEndpoint_t *object, const CAErrorInfo_t* errorInfo);
+void adapter_handler(CATransportAdapter_t adapter, bool enabled);
+void connection_handler(CATransportAdapter_t adapter, const char *remote_address, bool connected);
CAResult_t checkGetNetworkInfo();
CAResult_t checkSelectNetwork();
return;
}
+void adapter_handler(CATransportAdapter_t adapter,
+ bool enabled)
+{
+
+}
+
+void connection_handler(CATransportAdapter_t adapter,
+ const char *remote_address,
+ bool connected)
+{
+
+}
+
static char* addr = NULL;
static CAEndpoint_t* tempRep = NULL;
static CARequestInfo_t requestInfo;
EXPECT_EQ(CA_STATUS_OK, CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, addr,
PORT, &tempRep));
- if (tempRep != NULL)
- {
- CADestroyEndpoint(tempRep);
- tempRep = NULL;
- }
+ CADestroyEndpoint(tempRep);
+ tempRep = NULL;
}
// check remoteEndpoint and values of remoteEndpoint
EXPECT_TRUE(tempRep != NULL);
- if (tempRep != NULL)
- {
- CADestroyEndpoint(tempRep);
- tempRep = NULL;
- }
+ CADestroyEndpoint(tempRep);
+ tempRep = NULL;
}
// CAGerateToken TC
EXPECT_EQ(CA_STATUS_OK, CASendRequest(tempRep, &requestInfo));
CADestroyToken(tempToken);
-
- free(requestData.payload);
-
CADestroyEndpoint(tempRep);
+ free(requestData.payload);
tempRep = NULL;
-
}
// check return value when a NULL is passed instead of a valid CARequestInfo_t address
EXPECT_EQ(CA_STATUS_INVALID_PARAM, CASendRequest(tempRep, NULL));
- if (tempRep != NULL)
- {
- CADestroyEndpoint(tempRep);
- tempRep = NULL;
- }
+ CADestroyEndpoint(tempRep);
+ tempRep = NULL;
}
// CASendResponse TC
EXPECT_EQ(CA_STATUS_OK, CASendResponse(tempRep, &responseInfo));
CADestroyToken(tempToken);
- if (tempRep != NULL)
- {
- CADestroyEndpoint(tempRep);
- tempRep = NULL;
- }
+ CADestroyEndpoint(tempRep);
free (responseData.payload);
+ tempRep = NULL;
}
// check return value NULL is passed instead of a valid CAResponseInfo_t address
EXPECT_EQ(CA_STATUS_INVALID_PARAM, CASendResponse(tempRep, NULL));
- if (tempRep != NULL)
- {
- CADestroyEndpoint(tempRep);
- tempRep = NULL;
- }
+ CADestroyEndpoint(tempRep);
+ tempRep = NULL;
}
// CASelectNewwork TC
// check return value
TEST_F(CATests, SelectNetworkTestGood)
{
- CAResult_t res = checkSelectNetwork();
- EXPECT_EQ(CA_STATUS_OK, res);
+ EXPECT_EQ(CA_STATUS_OK, checkSelectNetwork());
}
CAResult_t checkSelectNetwork()
#endif
}
+// CARegisterNetworkMonitorHandler TC
+// check return value
+TEST_F(CATests, RegisterNetworkMonitorHandler)
+{
+#ifdef LE_ADAPTER
+ EXPECT_EQ(CA_STATUS_OK, CARegisterNetworkMonitorHandler(adapter_handler,
+ connection_handler));
+#else
+ EXPECT_EQ(CA_NOT_SUPPORTED, CARegisterNetworkMonitorHandler(adapter_handler,
+ connection_handler));
+#endif
+}
+
+// CASetAutoConnectionDeviceInfo TC
+// check return value
+TEST_F(CATests, SetAutoConnectionDeviceInfo)
+{
+ addr = (char *) ADDRESS;
+
+#if defined(__ANDROID__) && defined(LE_ADAPTER)
+ EXPECT_EQ(CA_STATUS_OK, CASetAutoConnectionDeviceInfo(addr));
+#else
+ EXPECT_EQ(CA_NOT_SUPPORTED, CASetAutoConnectionDeviceInfo(addr));
+#endif
+}
+
+// CAUnsetAutoConnectionDeviceInfo TC
+// check return value
+TEST_F(CATests, UnsetAutoConnectionDeviceInfo)
+{
+ addr = (char *) ADDRESS;
+
+#if defined(__ANDROID__) && defined(LE_ADAPTER)
+ EXPECT_EQ(CA_STATUS_OK, CAUnsetAutoConnectionDeviceInfo(addr));
+#else
+ EXPECT_EQ(CA_NOT_SUPPORTED, CAUnsetAutoConnectionDeviceInfo(addr));
+#endif
+}
+
CAResult_t checkGetNetworkInfo()
{
CAEndpoint_t *tempInfo = NULL;