Commit 50ade67c by xiaojing.zhang

GoogleTest

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