Commit 519b74ad by xiaojing.zhang

GoogleTest隐藏弹出框

parent 50ade67c
...@@ -22,9 +22,11 @@ ...@@ -22,9 +22,11 @@
//#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,18 +95,15 @@ void FMTask::showWindow() ...@@ -95,18 +95,15 @@ 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 ) if(_FM_Type == FM_Login || _FM_Type == FM_Pay ||_FM_Type == FM_Refund )
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();
if(ret != 1) { if(ret != 1) {
setError(FM_API_WINDOWCLOSE); setError(FM_API_WINDOWCLOSE);
} }
......
...@@ -82,11 +82,10 @@ void TaskLogin::onLogin() ...@@ -82,11 +82,10 @@ void TaskLogin::onLogin()
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);
......
...@@ -73,37 +73,45 @@ int FMMsgWnd::_exec(InfoType type, const QString &info) ...@@ -73,37 +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)
......
...@@ -47,12 +47,6 @@ bool FMVipLogin::initWnd(Session *session) ...@@ -47,12 +47,6 @@ bool FMVipLogin::initWnd(Session *session)
QString placeText; QString placeText;
if(session->data(PosProps.FM_Type).toInt() == FM_Pay) { if(session->data(PosProps.FM_Type).toInt() == FM_Pay) {
placeText = QString::fromLocal8Bit("输入支付码"); placeText = QString::fromLocal8Bit("输入支付码");
#ifdef UNIT_TEST
QString paycode = GetPayCode();
QTest::keyClicks(ui->login_edit, paycode);
//QTest::mouseClick(ui->login_btn,Qt::LeftButton);
#endif
} else { } else {
placeText = QString::fromLocal8Bit("输入手机号/会员码/支付码"); placeText = QString::fromLocal8Bit("输入手机号/会员码/支付码");
} }
...@@ -62,7 +56,12 @@ bool FMVipLogin::initWnd(Session *session) ...@@ -62,7 +56,12 @@ 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()
...@@ -114,7 +113,7 @@ QString FMVipLogin::GetPayCode() ...@@ -114,7 +113,7 @@ QString FMVipLogin::GetPayCode()
QNetworkAccessManager networkAcessManager; QNetworkAccessManager networkAcessManager;
QNetworkRequest _req; QNetworkRequest _req;
QString codeFormat; QString codeFormat;
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"; 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); _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,6 +108,9 @@ bool FMVipRefund::initWnd(Session *session) ...@@ -108,6 +108,9 @@ bool FMVipRefund::initWnd(Session *session)
col = 0; col = 0;
} }
} }
#ifdef UNIT_TEST
UiAutoTest();
#endif
return true; return true;
} }
...@@ -149,7 +152,7 @@ void FMVipRefund::setIsRefundSuccess(bool isRefundSuccess) ...@@ -149,7 +152,7 @@ void FMVipRefund::setIsRefundSuccess(bool isRefundSuccess)
_isRefundSuccess = isRefundSuccess; _isRefundSuccess = isRefundSuccess;
} }
/*
//测试程序自动退款时退最近的一笔 //测试程序自动退款时退最近的一笔
#ifdef UNIT_TEST #ifdef UNIT_TEST
void FMVipRefund::UiAutoTest() void FMVipRefund::UiAutoTest()
...@@ -162,4 +165,4 @@ void FMVipRefund::UiAutoTest() ...@@ -162,4 +165,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);
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "fmtask.h" #include "fmtask.h"
#include "fmnumpad.h" #include "fmnumpad.h"
#include "readjsoncommand.h" #include "readjsoncommand.h"
#include "loadrelyplugin.h"
#include <QByteArray> #include <QByteArray>
#include <gtest/gtest.h> #include <gtest/gtest.h>
...@@ -126,7 +125,7 @@ QByteArray VipRefund() ...@@ -126,7 +125,7 @@ QByteArray VipRefund()
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/*
TEST(TestNewVip, Vip_InfoFailed) TEST(TestNewVip, Vip_InfoFailed)
{ {
DeleteLocalDB(); DeleteLocalDB();
...@@ -134,6 +133,7 @@ TEST(TestNewVip, Vip_InfoFailed) ...@@ -134,6 +133,7 @@ TEST(TestNewVip, Vip_InfoFailed)
rspData = VipInfo(); rspData = VipInfo();
ASSERT_FALSE(respDataDetect(rspData)); ASSERT_FALSE(respDataDetect(rspData));
} }
*/
//设置门店信息 //设置门店信息
TEST(TestNewVip, store_Info) TEST(TestNewVip, store_Info)
{ {
......
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