Commit 8debc885 by xiaojing.zhang

去掉测试宏

parent 6c090f86
...@@ -2,14 +2,6 @@ ...@@ -2,14 +2,6 @@
#include <fmp_settings_i.h> #include <fmp_settings_i.h>
#include <QDebug> #include <QDebug>
#ifdef UNIT_TEST
#include <Qsettings>
#include <QApplication>
#endif
FMPVipSettings::FMPVipSettings(QObject *parent) : QObject(parent) FMPVipSettings::FMPVipSettings(QObject *parent) : QObject(parent)
{ {
} }
...@@ -21,22 +13,11 @@ FMPVipSettings *FMPVipSettings::instance() ...@@ -21,22 +13,11 @@ FMPVipSettings *FMPVipSettings::instance()
} }
#ifdef UNIT_TEST
QString FMPVipSettings::getServerUrl()
{
QSettings * _setting = new QSettings(qApp->applicationDirPath() + "/" + "FreemudPOS.ini", QSettings::IniFormat);
QString serverUrl = _setting->value(FMP_INIKEY_VIPSERVER, "Server").toString();
return serverUrl;
}
#else
QString FMPVipSettings::getServerUrl() QString FMPVipSettings::getServerUrl()
{ {
return _GetValue(FMP_INIKEY_VIPSERVER).toString(); return _GetValue(FMP_INIKEY_VIPSERVER).toString();
} }
#endif
void FMPVipSettings::init(FMPSettingsInterface *settings) void FMPVipSettings::init(FMPSettingsInterface *settings)
{ {
......
...@@ -95,15 +95,8 @@ void FMTask::showWindow() ...@@ -95,15 +95,8 @@ void FMTask::showWindow()
if(_window != nullptr) { if(_window != nullptr) {
_window->initWnd(this->session()); _window->initWnd(this->session());
int ret; int ret;
#ifdef UNIT_TEST
if(_FM_Type == FM_Login || _FM_Type == FM_Pay ||_FM_Type == FM_Refund )
ret = 1;
else
ret = _window->exec();
#else
ret = _window->exec(); ret = _window->exec();
#endif
if(ret != 1) { if(ret != 1) {
setError(FM_API_WINDOWCLOSE); setError(FM_API_WINDOWCLOSE);
} }
......
...@@ -83,9 +83,6 @@ void TaskLogin::onLogin() ...@@ -83,9 +83,6 @@ void TaskLogin::onLogin()
bool canPay = (getServerJsonValue(PosProps.CanPay).toInt() == 1); bool canPay = (getServerJsonValue(PosProps.CanPay).toInt() == 1);
#ifdef UNIT_TEST
canPay = true;
#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);
......
...@@ -73,45 +73,45 @@ int FMMsgWnd::_exec(InfoType type, const QString &info) ...@@ -73,45 +73,45 @@ 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)
{ {
#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_Warning, info); window._exec(FMMsgWnd::T_Warning, info);
#endif
} }
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)
......
...@@ -7,17 +7,7 @@ ...@@ -7,17 +7,7 @@
#include "fmnumpad.h" #include "fmnumpad.h"
#ifdef UNIT_TEST
#include <QTest>
#include <QEventLoop>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QJsonObject>
#include <QNetworkAccessManager>
#include <QUrl>
#include <QNetworkReply>
#include <QNetworkRequest>
#endif
FMVipLogin::FMVipLogin(QDialog *parent) : FMVipLogin::FMVipLogin(QDialog *parent) :
FMVipWnd(parent), FMVipWnd(parent),
...@@ -56,12 +46,6 @@ bool FMVipLogin::initWnd(Session *session) ...@@ -56,12 +46,6 @@ bool FMVipLogin::initWnd(Session *session)
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);
#ifdef UNIT_TEST
QString paycode = GetPayCode();
QTest::keyClicks(ui->login_edit, paycode);
QTest::mouseClick(ui->login_btn,Qt::LeftButton);
#endif
return true; return true;
} }
QString FMVipLogin::getVersionInfo() QString FMVipLogin::getVersionInfo()
...@@ -106,39 +90,4 @@ void FMVipLogin::on_login_key_clicked() ...@@ -106,39 +90,4 @@ void FMVipLogin::on_login_key_clicked()
_numpad->exec(); _numpad->exec();
} }
} }
#ifdef UNIT_TEST
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";
_req.setUrl(url);
auto reply = networkAcessManager.get(_req);
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
QByteArray rspData= reply->readAll();
qDebug()<<"reply get "<<rspData;
QJsonParseError jsonErr;
QJsonDocument rspJson = QJsonDocument::fromJson(rspData, &jsonErr);
//QJsonObject serverRspJsonObj;
if(jsonErr.error == QJsonParseError::NoError) {
//serverRspJsonObj = rspJson.object();
if(rspJson.isObject())
{
QVariantMap result = rspJson.toVariant().toMap();
QVariantMap nestedMap = result["data"].toMap();
codeFormat = nestedMap["codeFormat"].toString();
codeFormat.remove(QRegExp("\\s"));
qDebug() << "length:" << codeFormat;
}
}
return codeFormat;
}
#endif
...@@ -34,8 +34,5 @@ private: ...@@ -34,8 +34,5 @@ private:
Ui::FMVipLogin *ui; Ui::FMVipLogin *ui;
FMNumPad *_numpad; FMNumPad *_numpad;
#ifdef UNIT_TEST
QString GetPayCode(); //测试的时候用于获取付款码
#endif
}; };
#endif // FMVIPLOGIN_H #endif // FMVIPLOGIN_H
...@@ -7,10 +7,6 @@ ...@@ -7,10 +7,6 @@
#include <QScrollBar> #include <QScrollBar>
#include <QItemSelectionModel> #include <QItemSelectionModel>
#ifdef UNIT_TEST
#include <QTest>
#endif
FMVipOrder::FMVipOrder(QDialog *parent) : FMVipOrder::FMVipOrder(QDialog *parent) :
FMVipWnd(parent), FMVipWnd(parent),
...@@ -89,9 +85,6 @@ bool FMVipOrder::initWnd(Session *session) ...@@ -89,9 +85,6 @@ bool FMVipOrder::initWnd(Session *session)
ui->score_edit->setValidator(new QRegExpValidator(regexp)); ui->score_edit->setValidator(new QRegExpValidator(regexp));
setWillPayText(); setWillPayText();
#ifdef UNIT_TEST
QTest::mouseClick(ui->pay_btn,Qt::LeftButton);
#endif
return true; return true;
} }
......
...@@ -9,9 +9,7 @@ ...@@ -9,9 +9,7 @@
#include "items/order.h" #include "items/order.h"
#include "items/pay.h" #include "items/pay.h"
#include "items/storeinfo.h" #include "items/storeinfo.h"
#ifdef UNIT_TEST
#include <QTest>
#endif
FMVipRefund::FMVipRefund(QDialog *parent) : FMVipRefund::FMVipRefund(QDialog *parent) :
FMVipWnd(parent), FMVipWnd(parent),
...@@ -108,9 +106,7 @@ bool FMVipRefund::initWnd(Session *session) ...@@ -108,9 +106,7 @@ bool FMVipRefund::initWnd(Session *session)
col = 0; col = 0;
} }
} }
#ifdef UNIT_TEST
UiAutoTest();
#endif
return true; return true;
} }
...@@ -153,16 +149,3 @@ void FMVipRefund::setIsRefundSuccess(bool isRefundSuccess) ...@@ -153,16 +149,3 @@ void FMVipRefund::setIsRefundSuccess(bool isRefundSuccess)
} }
//测试程序自动退款时退最近的一笔
#ifdef UNIT_TEST
void FMVipRefund::UiAutoTest()
{
int rows = ui->tableWidget_pays->rowCount();
ui->tableWidget_pays->setCurrentCell(rows-1, QItemSelectionModel::Select);
QWidget* cell= ui->tableWidget_pays->cellWidget(rows-1,3);
QPushButton* button = dynamic_cast<QPushButton*>(cell);
QTest::mouseClick(button,Qt::LeftButton);
QTest::mouseClick(ui->close_btn,Qt::LeftButton);
}
#endif
...@@ -28,11 +28,6 @@ public: ...@@ -28,11 +28,6 @@ public:
bool isRefundSuccess() const; bool isRefundSuccess() const;
void setIsRefundSuccess(bool isRefundSuccess); void setIsRefundSuccess(bool isRefundSuccess);
#ifdef UNIT_TEST
void UiAutoTest();
#endif
signals: signals:
void refundPay(int); void refundPay(int);
void refundOrder(int); void refundOrder(int);
......
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