Commit 50ade67c by xiaojing.zhang

GoogleTest

parent 528bc798
...@@ -17,6 +17,8 @@ FMPDataBase::FMPDataBase(QString dbname, QString connectname, QObject *parent) : ...@@ -17,6 +17,8 @@ FMPDataBase::FMPDataBase(QString dbname, QString connectname, QObject *parent) :
} }
_db.setDatabaseName(dbname); _db.setDatabaseName(dbname);
_isopen = _db.open(); _isopen = _db.open();
if(!_isopen)
qDebug() << _db.lastError().databaseText();
} }
FMPDataBase::~FMPDataBase() FMPDataBase::~FMPDataBase()
......
...@@ -37,6 +37,7 @@ int FMNetwork::send(const QString &url, const QByteArray &reqData, QByteArray &r ...@@ -37,6 +37,7 @@ int FMNetwork::send(const QString &url, const QByteArray &reqData, QByteArray &r
_req->setHeader(QNetworkRequest::ContentLengthHeader, reqData.length()); _req->setHeader(QNetworkRequest::ContentLengthHeader, reqData.length());
auto reply = _nam->post(*_req, reqData); auto reply = _nam->post(*_req, reqData);
//auto reply = _nam->get(*_req);
// 使用定时器处理超时 // 使用定时器处理超时
QEventLoop loop; QEventLoop loop;
......
...@@ -20,10 +20,6 @@ FMPVipSettings *FMPVipSettings::instance() ...@@ -20,10 +20,6 @@ FMPVipSettings *FMPVipSettings::instance()
return &vipSettings; return &vipSettings;
} }
void FMPVipSettings::init(FMPSettingsInterface *settings)
{
this->_settings = settings;
}
#ifdef UNIT_TEST #ifdef UNIT_TEST
QString FMPVipSettings::getServerUrl() QString FMPVipSettings::getServerUrl()
...@@ -42,6 +38,11 @@ QString FMPVipSettings::getServerUrl() ...@@ -42,6 +38,11 @@ QString FMPVipSettings::getServerUrl()
} }
#endif #endif
void FMPVipSettings::init(FMPSettingsInterface *settings)
{
this->_settings = settings;
}
bool FMPVipSettings::getIsNeedSocketHeader() bool FMPVipSettings::getIsNeedSocketHeader()
......
...@@ -14,16 +14,15 @@ class FMPVipSettings : public QObject ...@@ -14,16 +14,15 @@ class FMPVipSettings : public QObject
Q_OBJECT Q_OBJECT
public: public:
static FMPVipSettings *instance(); static FMPVipSettings *instance();
void init(FMPSettingsInterface *settings);
QString getServerUrl(); QString getServerUrl();
bool getIsNeedSocketHeader();
int GetPayPartnerId();
private: private:
explicit FMPVipSettings(QObject *parent = 0); explicit FMPVipSettings(QObject *parent = 0);
public:
void init(FMPSettingsInterface *settings);
bool getIsNeedSocketHeader();
int GetPayPartnerId();
QVariant _GetValue(const QString &key, QVariant defaultValue = 0); QVariant _GetValue(const QString &key, QVariant defaultValue = 0);
bool _SetValue(const QString &key, QVariant value); bool _SetValue(const QString &key, QVariant value);
...@@ -31,4 +30,7 @@ private: ...@@ -31,4 +30,7 @@ private:
FMPSettingsInterface *_settings; FMPSettingsInterface *_settings;
}; };
#endif // FMP_VIP_SETTINGS_H #endif // FMP_VIP_SETTINGS_H
...@@ -21,12 +21,10 @@ ...@@ -21,12 +21,10 @@
//#define KEY_CODE "059e15e7-19a6-480f-8b5f-3a082a5b553e" //#define KEY_CODE "059e15e7-19a6-480f-8b5f-3a082a5b553e"
//#define PARTNER_ID "c3e82ff2-6285-4823-8e3f-7ec880ae7119" //#define PARTNER_ID "c3e82ff2-6285-4823-8e3f-7ec880ae7119"
#ifdef UNIT_TEST
//! 测试 //! 测试
#define APP_ID "T015" #define APP_ID "T015"
#define KEY_CODE "85870ccc8da9affa5eafe7488533f273" #define KEY_CODE "85870ccc8da9affa5eafe7488533f273"
#define PARTNER_ID "7f657d18-9f3f-41fd-b97f-1a71f7d1ffa0" #define PARTNER_ID "7f657d18-9f3f-41fd-b97f-1a71f7d1ffa0"
#endif
// 请求类型的枚举值 // 请求类型的枚举值
enum FM_TYPE { enum FM_TYPE {
......
...@@ -95,17 +95,17 @@ void FMTask::showWindow() ...@@ -95,17 +95,17 @@ void FMTask::showWindow()
if(_window != nullptr) { if(_window != nullptr) {
_window->initWnd(this->session()); _window->initWnd(this->session());
int ret; int ret;
/*
#ifdef UNIT_TEST #ifdef UNIT_TEST
if(_FM_Type == FM_Login || _FM_Type == FM_Pay|| _FM_Type == FM_Refund ) if(_FM_Type == FM_Login || _FM_Type == FM_Pay )
ret = 1; ret = 1;
else else
ret = _window->exec(); ret = _window->exec();
#else #else
ret = _window->exec(); ret = _window->exec();
#endif #endif
*/
// ret = _window->exec(); ret = _window->exec();
if(ret != 1) { if(ret != 1) {
setError(FM_API_WINDOWCLOSE); setError(FM_API_WINDOWCLOSE);
...@@ -133,8 +133,11 @@ bool FMTask::sendToServer(bool isShowMsg) ...@@ -133,8 +133,11 @@ bool FMTask::sendToServer(bool isShowMsg)
QByteArray rspData; QByteArray rspData;
FMNetwork net; FMNetwork net;
qDebug()<<"send url is" << url;
qDebug() <<"send to url data is"<< data.data();
net.send(url, data, rspData); net.send(url, data, rspData);
FMP_INFO() << "Server rsponse: " << rspData.data(); FMP_INFO() << "Server rsponse: " << rspData.data();
// 网络错误 // 网络错误
......
...@@ -29,6 +29,7 @@ void TaskLogin::setWindow() ...@@ -29,6 +29,7 @@ void TaskLogin::setWindow()
void TaskLogin::packageServerReq() void TaskLogin::packageServerReq()
{ {
QJsonObject code; QJsonObject code;
qDebug()<< "code" <<session()->data(PosProps.Member_sign).toString();
code[ServerProps(PosProps.Member_sign)] = session()->data(PosProps.Member_sign).toString(); code[ServerProps(PosProps.Member_sign)] = session()->data(PosProps.Member_sign).toString();
serverReqJsonObj["data"] = code; serverReqJsonObj["data"] = code;
} }
...@@ -79,11 +80,13 @@ void TaskLogin::onLogin() ...@@ -79,11 +80,13 @@ void TaskLogin::onLogin()
name = "--"; name = "--";
} }
bool canPay = (getServerJsonValue(PosProps.CanPay).toInt() == 1);
bool canPay = (getServerJsonValue(PosProps.CanPay).toInt() == 1);
/*
#ifdef UNIT_TEST #ifdef UNIT_TEST
canPay = true; canPay = true;
#endif #endif
*/
if(!canPay) { if(!canPay) {
if(getPosJsonValue(PosProps.Fm_cmd).toInt() != FM_Pay) { if(getPosJsonValue(PosProps.Fm_cmd).toInt() != FM_Pay) {
FMMsgWnd::LoginSuccess(account, name, birthday, _window); FMMsgWnd::LoginSuccess(account, name, birthday, _window);
......
...@@ -85,6 +85,7 @@ void TaskRefund::packagePOSRsp() ...@@ -85,6 +85,7 @@ void TaskRefund::packagePOSRsp()
void TaskRefund::onRefundPay(int DBID) void TaskRefund::onRefundPay(int DBID)
{ {
qDebug()<< "PosProps.TransId "<<session()->data(PosProps.TransId).toString();
posReqJsonObj[PosProps.TransId] = session()->data(PosProps.TransId).toString(); posReqJsonObj[PosProps.TransId] = session()->data(PosProps.TransId).toString();
QSharedPointer<FMItem::Pay> payPointer = DBOP::GetPayByDBId(DBID); QSharedPointer<FMItem::Pay> payPointer = DBOP::GetPayByDBId(DBID);
......
...@@ -73,13 +73,11 @@ int FMMsgWnd::_exec(InfoType type, const QString &info) ...@@ -73,13 +73,11 @@ int FMMsgWnd::_exec(InfoType type, const QString &info)
void FMMsgWnd::FailureWnd(const QString &info, QDialog *parent) void FMMsgWnd::FailureWnd(const QString &info, QDialog *parent)
{ {
#ifndef UNIT_TEST
FMMsgWnd window(parent); FMMsgWnd window(parent);
if(parent != nullptr) { if(parent != nullptr) {
window.setGeometry(parent->geometry()); window.setGeometry(parent->geometry());
} }
window._exec(FMMsgWnd::T_Failure, info); window._exec(FMMsgWnd::T_Failure, info);
#endif
} }
void FMMsgWnd::WarningWnd(const QString &info, QDialog *parent) void FMMsgWnd::WarningWnd(const QString &info, QDialog *parent)
{ {
...@@ -91,25 +89,21 @@ void FMMsgWnd::WarningWnd(const QString &info, QDialog *parent) ...@@ -91,25 +89,21 @@ void FMMsgWnd::WarningWnd(const QString &info, QDialog *parent)
} }
void FMMsgWnd::SuccessWnd(const QString &info, QDialog *parent) void FMMsgWnd::SuccessWnd(const QString &info, QDialog *parent)
{ {
#ifndef UNIT_TEST
FMMsgWnd window(parent); FMMsgWnd window(parent);
if(parent != nullptr) { if(parent != nullptr) {
window.setGeometry(parent->geometry()); window.setGeometry(parent->geometry());
} }
window._exec(FMMsgWnd::T_Success, info); window._exec(FMMsgWnd::T_Success, info);
#endif
} }
void FMMsgWnd::LoginSuccess(const QString &account, const QString &name, const QString &birthday, QDialog *parent) void FMMsgWnd::LoginSuccess(const QString &account, const QString &name, const QString &birthday, QDialog *parent)
{ {
#ifndef UNIT_TEST
FMMsgWnd window(parent); FMMsgWnd window(parent);
if(parent != nullptr) { if(parent != nullptr) {
window.setGeometry(parent->geometry()); window.setGeometry(parent->geometry());
} }
QString info = QString::fromLocal8Bit("账号:%1\n姓名:%2\n生日:%3").arg(account).arg(name).arg(birthday); QString info = QString::fromLocal8Bit("账号:%1\n姓名:%2\n生日:%3").arg(account).arg(name).arg(birthday);
window._exec(FMMsgWnd::T_LoginSuccess, info); window._exec(FMMsgWnd::T_LoginSuccess, info);
#endif
} }
int FMMsgWnd::Question(const QString &info, QDialog *parent) int FMMsgWnd::Question(const QString &info, QDialog *parent)
......
...@@ -50,20 +50,21 @@ bool FMVipLogin::initWnd(Session *session) ...@@ -50,20 +50,21 @@ bool FMVipLogin::initWnd(Session *session)
#ifdef UNIT_TEST #ifdef UNIT_TEST
QString paycode = GetPayCode(); QString paycode = GetPayCode();
QTest::keyClicks(ui->login_edit, paycode); QTest::keyClicks(ui->login_edit, paycode);
QTest::mouseClick(ui->login_btn,Qt::LeftButton); //QTest::mouseClick(ui->login_btn,Qt::LeftButton);
#endif #endif
} else { } else {
placeText = QString::fromLocal8Bit("输入手机号/会员码/支付码"); placeText = QString::fromLocal8Bit("输入手机号/会员码/支付码");
} }
ui->store_label->setText(session->data(PosProps.StoreId).toString()); ui->store_label->setText(session->data(PosProps.StoreId).toString());
ui->pos_label->setText(session->data(PosProps.PosId).toString()); ui->pos_label->setText(session->data(PosProps.PosId).toString());
ui->operator_label->setText(session->data(PosProps.OperatorId).toString()); ui->operator_label->setText(session->data(PosProps.OperatorId).toString());
ui->bd_label->setText(session->data(PosProps.BussinessDate).toString()); ui->bd_label->setText(session->data(PosProps.BussinessDate).toString());
ui->login_edit->setPlaceholderText(placeText); ui->login_edit->setPlaceholderText(placeText);
return true; return true;
} }
QString FMVipLogin::getVersionInfo() QString FMVipLogin::getVersionInfo()
{ {
QByteArray versionInfo; QByteArray versionInfo;
...@@ -113,7 +114,7 @@ QString FMVipLogin::GetPayCode() ...@@ -113,7 +114,7 @@ QString FMVipLogin::GetPayCode()
QNetworkAccessManager networkAcessManager; QNetworkAccessManager networkAcessManager;
QNetworkRequest _req; QNetworkRequest _req;
QString codeFormat; QString codeFormat;
QString url = "http://membertest1.sandload.cn:8748/wechat/card/getPayCode?partnerId=7f657d18-9f3f-41fd-b97f-1a71f7d1ffa0&openId=o4_93jjwHWPke-U1IT2IkUO5hbII&mobile=15821343897&URL=http%3A%2F%2Fjtest.sandload.cn"; QString url = "http://jtest.sandload.cn:8748/wechat/card/getPayCode?partnerId=7f657d18-9f3f-41fd-b97f-1a71f7d1ffa0&openId=o4_93jjwHWPke-U1IT2IkUO5hbII&mobile=15821343897&URL=http%3A%2F%2Fjtest.sandload.cn";
_req.setUrl(url); _req.setUrl(url);
auto reply = networkAcessManager.get(_req); auto reply = networkAcessManager.get(_req);
QEventLoop loop; QEventLoop loop;
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
#include "fmnumpad.h" #include "fmnumpad.h"
#include <QScrollBar> #include <QScrollBar>
#include <QItemSelectionModel> #include <QItemSelectionModel>
/*
#ifdef UNIT_TEST #ifdef UNIT_TEST
#include <QTest> #include <QTest>
#endif #endif
*/
FMVipOrder::FMVipOrder(QDialog *parent) : FMVipOrder::FMVipOrder(QDialog *parent) :
FMVipWnd(parent), FMVipWnd(parent),
...@@ -88,11 +88,11 @@ bool FMVipOrder::initWnd(Session *session) ...@@ -88,11 +88,11 @@ bool FMVipOrder::initWnd(Session *session)
ui->pay_edit->setValidator(new QRegExpValidator(regexp)); ui->pay_edit->setValidator(new QRegExpValidator(regexp));
ui->score_edit->setValidator(new QRegExpValidator(regexp)); ui->score_edit->setValidator(new QRegExpValidator(regexp));
setWillPayText(); setWillPayText();
/*
#ifdef UNIT_TEST #ifdef UNIT_TEST
QTest::mouseClick(ui->pay_btn,Qt::LeftButton); QTest::mouseClick(ui->pay_btn,Qt::LeftButton);
#endif #endif
*/
return true; return true;
} }
......
...@@ -108,10 +108,6 @@ bool FMVipRefund::initWnd(Session *session) ...@@ -108,10 +108,6 @@ bool FMVipRefund::initWnd(Session *session)
col = 0; col = 0;
} }
} }
#ifdef UNIT_TEST
UiAutoTest();
#endif
return true; return true;
} }
...@@ -153,7 +149,7 @@ void FMVipRefund::setIsRefundSuccess(bool isRefundSuccess) ...@@ -153,7 +149,7 @@ void FMVipRefund::setIsRefundSuccess(bool isRefundSuccess)
_isRefundSuccess = isRefundSuccess; _isRefundSuccess = isRefundSuccess;
} }
/*
//测试程序自动退款时退最近的一笔 //测试程序自动退款时退最近的一笔
#ifdef UNIT_TEST #ifdef UNIT_TEST
void FMVipRefund::UiAutoTest() void FMVipRefund::UiAutoTest()
...@@ -166,4 +162,4 @@ void FMVipRefund::UiAutoTest() ...@@ -166,4 +162,4 @@ void FMVipRefund::UiAutoTest()
QTest::mouseClick(ui->close_btn,Qt::LeftButton); QTest::mouseClick(ui->close_btn,Qt::LeftButton);
} }
#endif #endif
*/
...@@ -27,11 +27,11 @@ public: ...@@ -27,11 +27,11 @@ public:
bool isRefundSuccess() const; bool isRefundSuccess() const;
void setIsRefundSuccess(bool isRefundSuccess); void setIsRefundSuccess(bool isRefundSuccess);
/*
#ifdef UNIT_TEST #ifdef UNIT_TEST
void UiAutoTest(); void UiAutoTest();
#endif #endif
*/
signals: signals:
void refundPay(int); void refundPay(int);
......
...@@ -29,5 +29,3 @@ HEADERS += \ ...@@ -29,5 +29,3 @@ HEADERS += \
readjsoncommand.h \ readjsoncommand.h \
test_newvip.h \ test_newvip.h \
../../../include/application/fm_singleton.h ../../../include/application/fm_singleton.h
loadrelyplugin.h
#ifndef LOADRELYPLUGIN_H
#define LOADRELYPLUGIN_H
#include "../application/fm_singleton.h"
#include <qtservice.h>
#include <QSettings>
class LoadRelyPlugin:public QtService<FMSingleApplication>
{
public:
LoadRelyPlugin(int argc, char**argv, const QString &svcname);
bool isRunning();
void start();
QString getPluginPath(const QString &plugin_name);
protected:
virtual void createApplication(int &argc, char **argv);
private:
int _starttype;
QSettings *_setting;
QString _name;
QString _description;
QString _plugin_path;
QString _entry_plugin;
QString _plugin_suffix;
};
#endif // LOADRELYPLUGIN_H
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
ReadJsonCommand::ReadJsonCommand() ReadJsonCommand::ReadJsonCommand()
{ {
qDebug()<<"Test"; qDebug()<<"Test......";
} }
QString ReadJsonCommand::Readjson(QString fileName) QString ReadJsonCommand::Readjson(QString fileName)
......
...@@ -82,7 +82,7 @@ QByteArray VipInfo() ...@@ -82,7 +82,7 @@ QByteArray VipInfo()
ret = foo_env->readjson.Readjson("set_vipConfirm.json"); ret = foo_env->readjson.Readjson("set_vipConfirm.json");
reqData = ret.toLocal8Bit(); reqData = ret.toLocal8Bit();
foo_env->fmvip.doTask(reqData,rspData); foo_env->fmvip.doTask(reqData,rspData);
QString mount =foo_env->readjson.ParseSecondLevel(rspData,"data","amount"); QString mount =foo_env->readjson.ParseSecondLevel(rspData,"data","amount");
QString score = foo_env->readjson.ParseSecondLevel(rspData,"data","score"); QString score = foo_env->readjson.ParseSecondLevel(rspData,"data","score");
foo_env->VIPMount =mount.toInt(&ok, 10); foo_env->VIPMount =mount.toInt(&ok, 10);
foo_env->VIPScore =score.toInt(&ok, 10); foo_env->VIPScore =score.toInt(&ok, 10);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment