Commit 8debc885 by xiaojing.zhang

去掉测试宏

parent 6c090f86
......@@ -2,14 +2,6 @@
#include <fmp_settings_i.h>
#include <QDebug>
#ifdef UNIT_TEST
#include <Qsettings>
#include <QApplication>
#endif
FMPVipSettings::FMPVipSettings(QObject *parent) : QObject(parent)
{
}
......@@ -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()
{
return _GetValue(FMP_INIKEY_VIPSERVER).toString();
}
#endif
void FMPVipSettings::init(FMPSettingsInterface *settings)
{
......
......@@ -95,15 +95,8 @@ 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 )
ret = 1;
else
ret = _window->exec();
#else
ret = _window->exec();
#endif
if(ret != 1) {
setError(FM_API_WINDOWCLOSE);
}
......
......@@ -83,9 +83,6 @@ void TaskLogin::onLogin()
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);
......
......@@ -73,45 +73,45 @@ 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)
{
#ifndef UNIT_TEST
FMMsgWnd window(parent);
if(parent != nullptr) {
window.setGeometry(parent->geometry());
}
window._exec(FMMsgWnd::T_Warning, info);
#endif
}
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)
......
......@@ -7,17 +7,7 @@
#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) :
FMVipWnd(parent),
......@@ -56,12 +46,6 @@ bool FMVipLogin::initWnd(Session *session)
ui->operator_label->setText(session->data(PosProps.OperatorId).toString());
ui->bd_label->setText(session->data(PosProps.BussinessDate).toString());
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;
}
QString FMVipLogin::getVersionInfo()
......@@ -106,39 +90,4 @@ void FMVipLogin::on_login_key_clicked()
_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:
Ui::FMVipLogin *ui;
FMNumPad *_numpad;
#ifdef UNIT_TEST
QString GetPayCode(); //测试的时候用于获取付款码
#endif
};
#endif // FMVIPLOGIN_H
......@@ -7,10 +7,6 @@
#include <QScrollBar>
#include <QItemSelectionModel>
#ifdef UNIT_TEST
#include <QTest>
#endif
FMVipOrder::FMVipOrder(QDialog *parent) :
FMVipWnd(parent),
......@@ -89,9 +85,6 @@ bool FMVipOrder::initWnd(Session *session)
ui->score_edit->setValidator(new QRegExpValidator(regexp));
setWillPayText();
#ifdef UNIT_TEST
QTest::mouseClick(ui->pay_btn,Qt::LeftButton);
#endif
return true;
}
......
......@@ -9,9 +9,7 @@
#include "items/order.h"
#include "items/pay.h"
#include "items/storeinfo.h"
#ifdef UNIT_TEST
#include <QTest>
#endif
FMVipRefund::FMVipRefund(QDialog *parent) :
FMVipWnd(parent),
......@@ -108,9 +106,7 @@ bool FMVipRefund::initWnd(Session *session)
col = 0;
}
}
#ifdef UNIT_TEST
UiAutoTest();
#endif
return true;
}
......@@ -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:
bool isRefundSuccess() const;
void setIsRefundSuccess(bool isRefundSuccess);
#ifdef UNIT_TEST
void UiAutoTest();
#endif
signals:
void refundPay(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