439 lines
29 KiB
C++
439 lines
29 KiB
C++
#include "AtCommandMock.h"
|
|
#include "Log.h"
|
|
extern const char *AT_COMMAND_ATE;
|
|
extern const char *AT_GSN;
|
|
extern const char *AT_ATI;
|
|
extern const char *AT_QGMR;
|
|
extern const char *AT_QSIMSTAT;
|
|
extern const char *AT_QURCCFG;
|
|
extern const char *AT_QCFG;
|
|
extern const char *AT_QCFG_2;
|
|
extern const char *AT_QLWCFG;
|
|
extern const char *AT_QLWCFG_2;
|
|
extern const char *AT_CPIN;
|
|
extern const char *AT_QCCID;
|
|
extern const char *AT_CIMI;
|
|
extern const char *AT_CGREG;
|
|
extern const char *AT_QCFG_PDP;
|
|
extern const char *AT_QCFG_TCP_1;
|
|
extern const char *AT_QCFG_TCP_2;
|
|
extern const char *AT_QNWINFO;
|
|
extern const char *AT_COPS;
|
|
extern const char *AT_QCSQ;
|
|
extern const char *AT_W;
|
|
const char *AT_COMMAND_ATE_RESPONSE_OK = "ATE1\r\nOK\r";
|
|
const char *AT_COMMAND_GSN_RESPONSE_OK = "AT+GSN\r\n864004046816259\r\nOK\r";
|
|
const char *AT_COMMAND_ATI_RESPONSE_OK = "ATI\r\nQuectel\r\nEG95\r\nRevision: EG95EXGAR08A04M1G\r\nOK\r";
|
|
const char *AT_COMMAND_QGMR_RESPONSE_OK = "AT+QGMR\r\nEG95EXGAR08A04M1G_20.002.20.002\r\nOK\r";
|
|
const char *AT_COMMAND_QSIMSTAT_RESPONSE_OK = "AT+QSIMSTAT?\r\n+QSIMSTAT: 0,1\r\nOK\r";
|
|
const char *AT_COMMAND_QURCCFG_RESPONSE_OK = "AT+QURCCFG=\"urcport\",\"usbat\"\r\nOK\r";
|
|
const char *AT_COMMAND_QCFG_RESPONSE_OK = "AT+QCFG=\"risignaltype\",\"physical\"\r\nOK\r";
|
|
const char *AT_COMMAND_QCFG_2_RESPONSE_OK = "AT+QCFG=\"urc/ri/other\",\"off\"\r\nOK\r";
|
|
const char *AT_COMMAND_QLWCFG_RESPONSE_OK = "AT+QLWCFG=\"urc\",0\r\nOK\r";
|
|
const char *AT_COMMAND_QLWCFG_2_RESPONSE_OK = "AT+QLWCFG=\"startup\",0\r\nOK\r";
|
|
const char *AT_COMMAND_CPIN_RESPONSE_OK = "AT+CPIN?\r\n+CPIN: READY\r\nOK\r";
|
|
const char *AT_COMMAND_QCCID_RESPONSE_OK = "AT+QCCID\r\n+QCCID: 898607B0101980001318\r\nOK\r";
|
|
const char *AT_COMMAND_CIMI_RESPONSE_OK = "AT+CIMI\r\n460041057611818\r\nOK\r";
|
|
|
|
const char *AT_CGREG_RESPONSE_OK = "AT+CGREG?\r\n+CGREG: 0,1\r\nOK\r";
|
|
const char *AT_QCFG_PDP_RESPONSE_OK = "AT+QCFG=\"pdp/duplicatechk\",0\r\nOK\r";
|
|
const char *AT_QCFG_TCP_1_RESPONSE_OK = "AT+QCFG=\"tcp/windowsize\",0,100\r\nOK\r";
|
|
const char *AT_QCFG_TCP_2_RESPONSE_OK = "AT+QCFG=\"tcp/windowsize\",1,100\r\nOK\r";
|
|
const char *AT_QNWINFO_RESPONSE_OK = "AT+QNWINFO\r\n+QNWINFO: \"FDD LTE\",\"46000\",\"LTE BAND 3\",1300\r\nOK\r";
|
|
const char *AT_COPS_RESPONSE_OK = "AT+COPS?\r\n+COPS: 0,0,\"CHINA MOBILE\",7\r\nOK\r";
|
|
const char *AT_QCSQ_RESPONSE_OK = "AT+QCSQ\r\n+QCSQ: \"LTE\",50,-82,109,-13\r\nOK\r";
|
|
const char *AT_W_RESPONSE_OK = "AT&W\r\nOK\r";
|
|
const char *AT_QICSGP_RESPONSE_OK = "XXXXXXXXXX\r\nOK\r";
|
|
|
|
void AtCommandMock::AtCommandInit(const int &usbFd, std::shared_ptr<LinuxApiTest> &mock)
|
|
{
|
|
auto selectOk = [=, &mock](int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
|
|
{
|
|
FD_ZERO(readfds);
|
|
FD_SET(usbFd, readfds);
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
|
|
auto APN_CONFIG_RESPONSE_MONITOR = [=, &mock](const void *writeBuf, const unsigned int &length)
|
|
{
|
|
if (strstr((const char *)writeBuf, "AT+QICSGP="))
|
|
{
|
|
auto ATE_QICSGP = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("ATE_QICSGP mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_QICSGP_RESPONSE_OK, strlen(AT_QICSGP_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_QICSGP_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, writeBuf, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(ATE_QICSGP)), ::testing::Return(length)));
|
|
}
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<1, 2>(::testing::Invoke(APN_CONFIG_RESPONSE_MONITOR)), ::testing::Return(MOCK_WRITE_FAILED)));
|
|
|
|
auto ATE_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("ATE_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COMMAND_ATE_RESPONSE_OK, strlen(AT_COMMAND_ATE_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COMMAND_ATE_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_COMMAND_ATE, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(ATE_RESPONSE)), ::testing::Return(strlen(AT_COMMAND_ATE))));
|
|
|
|
auto AT_GSN_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_GSN_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COMMAND_GSN_RESPONSE_OK, strlen(AT_COMMAND_GSN_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COMMAND_GSN_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_GSN, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_GSN_RESPONSE)), ::testing::Return(strlen(AT_GSN))));
|
|
|
|
auto AT_ATI_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_ATI_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COMMAND_ATI_RESPONSE_OK, strlen(AT_COMMAND_ATI_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COMMAND_ATI_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_ATI, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_ATI_RESPONSE)), ::testing::Return(strlen(AT_ATI))));
|
|
|
|
auto AT_QGMR_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_QGMR_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COMMAND_QGMR_RESPONSE_OK, strlen(AT_COMMAND_QGMR_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COMMAND_QGMR_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_QGMR, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_QGMR_RESPONSE)), ::testing::Return(strlen(AT_QGMR))));
|
|
|
|
auto AT_QSIMSTAT_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_QSIMSTAT_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COMMAND_QSIMSTAT_RESPONSE_OK, strlen(AT_COMMAND_QSIMSTAT_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COMMAND_QSIMSTAT_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_QSIMSTAT, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_QSIMSTAT_RESPONSE)), ::testing::Return(strlen(AT_QSIMSTAT))));
|
|
|
|
auto AT_QURCCFG_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_QURCCFG_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COMMAND_QURCCFG_RESPONSE_OK, strlen(AT_COMMAND_QURCCFG_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COMMAND_QURCCFG_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_QURCCFG, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_QURCCFG_RESPONSE)), ::testing::Return(strlen(AT_QURCCFG))));
|
|
|
|
auto AT_QCFG_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_QCFG_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COMMAND_QCFG_RESPONSE_OK, strlen(AT_COMMAND_QCFG_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COMMAND_QCFG_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_QCFG, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_QCFG_RESPONSE)), ::testing::Return(strlen(AT_QCFG))));
|
|
|
|
auto AT_QCFG_2_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_QCFG_2_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COMMAND_QCFG_2_RESPONSE_OK, strlen(AT_COMMAND_QCFG_2_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COMMAND_QCFG_2_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_QCFG_2, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_QCFG_2_RESPONSE)), ::testing::Return(strlen(AT_QCFG_2))));
|
|
|
|
auto AT_QLWCFG_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_QLWCFG_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COMMAND_QLWCFG_RESPONSE_OK, strlen(AT_COMMAND_QLWCFG_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COMMAND_QLWCFG_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_QLWCFG, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_QLWCFG_RESPONSE)), ::testing::Return(strlen(AT_QLWCFG))));
|
|
|
|
auto AT_QLWCFG_2_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_QLWCFG_2_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COMMAND_QLWCFG_2_RESPONSE_OK, strlen(AT_COMMAND_QLWCFG_2_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COMMAND_QLWCFG_2_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_QLWCFG_2, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_QLWCFG_2_RESPONSE)), ::testing::Return(strlen(AT_QLWCFG_2))));
|
|
|
|
auto AT_CPIN_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_CPIN_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COMMAND_CPIN_RESPONSE_OK, strlen(AT_COMMAND_CPIN_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COMMAND_CPIN_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_CPIN, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_CPIN_RESPONSE)), ::testing::Return(strlen(AT_CPIN))));
|
|
|
|
auto AT_QCCID_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_QCCID_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COMMAND_QCCID_RESPONSE_OK, strlen(AT_COMMAND_QCCID_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COMMAND_QCCID_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_QCCID, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_QCCID_RESPONSE)), ::testing::Return(strlen(AT_QCCID))));
|
|
|
|
auto AT_CIMI_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_CIMI_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COMMAND_CIMI_RESPONSE_OK, strlen(AT_COMMAND_CIMI_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COMMAND_CIMI_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_CIMI, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_CIMI_RESPONSE)), ::testing::Return(strlen(AT_CIMI))));
|
|
|
|
auto AT_CGREG_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_CGREG_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_CGREG_RESPONSE_OK, strlen(AT_CGREG_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_CGREG_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_CGREG, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_CGREG_RESPONSE)), ::testing::Return(strlen(AT_CGREG))));
|
|
|
|
auto AT_QCFG_PDP_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_QCFG_PDP_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_QCFG_PDP_RESPONSE_OK, strlen(AT_QCFG_PDP_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_QCFG_PDP_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_QCFG_PDP, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_QCFG_PDP_RESPONSE)), ::testing::Return(strlen(AT_QCFG_PDP))));
|
|
|
|
auto AT_QCFG_TCP_1_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_QCFG_TCP_1_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_QCFG_TCP_1_RESPONSE_OK, strlen(AT_QCFG_TCP_1_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_QCFG_TCP_1_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_QCFG_TCP_1, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_QCFG_TCP_1_RESPONSE)), ::testing::Return(strlen(AT_QCFG_TCP_1))));
|
|
|
|
auto AT_QCFG_TCP_2_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_QCFG_TCP_2_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_QCFG_TCP_2_RESPONSE_OK, strlen(AT_QCFG_TCP_2_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_QCFG_TCP_2_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_QCFG_TCP_2, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_QCFG_TCP_2_RESPONSE)), ::testing::Return(strlen(AT_QCFG_TCP_2))));
|
|
|
|
auto AT_QNWINFO_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_QNWINFO_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_QNWINFO_RESPONSE_OK, strlen(AT_QNWINFO_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_QNWINFO_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_QNWINFO, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_QNWINFO_RESPONSE)), ::testing::Return(strlen(AT_QNWINFO))));
|
|
|
|
auto AT_COPS_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_COPS_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_COPS_RESPONSE_OK, strlen(AT_COPS_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_COPS_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_COPS, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_COPS_RESPONSE)), ::testing::Return(strlen(AT_COPS))));
|
|
|
|
auto AT_QCSQ_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_QCSQ_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_QCSQ_RESPONSE_OK, strlen(AT_QCSQ_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_QCSQ_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_QCSQ, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_QCSQ_RESPONSE)), ::testing::Return(strlen(AT_QCSQ))));
|
|
|
|
auto AT_W_RESPONSE = [=, &mock](const int &usbFd)
|
|
{
|
|
LogInfo("AT_W_RESPONSE mock\n");
|
|
auto readBuf = [=, &mock](int fd, void *buf, size_t count)
|
|
{
|
|
memcpy(buf, AT_W_RESPONSE_OK, strlen(AT_W_RESPONSE_OK));
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::Return(MOCK_SELECT_FAILED)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), read(usbFd, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2>(::testing::Invoke(readBuf)), ::testing::Return(strlen(AT_W_RESPONSE_OK))));
|
|
EXPECT_CALL(*mock.get(), select(usbFd + 1, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0, 1, 2, 3, 4>(::testing::Invoke(selectOk)), ::testing::Return(MOCK_SELECT_READABLE)));
|
|
};
|
|
EXPECT_CALL(*mock.get(), write(usbFd, AT_W, ::testing::_))
|
|
.WillRepeatedly(::testing::DoAll(::testing::WithArgs<0>(::testing::Invoke(AT_W_RESPONSE)), ::testing::Return(strlen(AT_W))));
|
|
} |