void gpsdataTimerCallBack(void);
void ClearAll(void);
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
private:
UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener);
UILabel *InitLabel(LabelConfig &labelConfig);
void ClearAll(void);
void set_LCD_color(int);
void LCDHideNextButton(void);
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
private:
bool testLCDScrollViewcrollViewinit(uint8_t);
UIScrollView *testLCDScrollView{nullptr};
UIScrollView *SEChipInitIView(uint8_t);
void ClearAll(void);
UILabel *InitLabel(LabelConfig &labelConfig);
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
private:
UIScrollView *testTPInitIView(uint8_t);
void ClearAll(void);
void TPHideNextButton(void);
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
private:
UIButton *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnTouchListener *clickListener);
bool testTPScrollViewcrollViewinit(uint8_t);
UIScrollView *GetSystemScrollView(int ViewId);\r
\r
bool AddResultButtons(UIScrollView *scrollView, int16_t viewId,UILabelButton*&oktestBtn,UILabelButton*&failtestBtn);\r
+ \r
+ // 更新测试结果按钮状态和颜色\r
+ void UpdateResultButtonStatus(int16_t viewId, UILabelButton* oktestBtn, UILabelButton* failtestBtn);\r
+ \r
+ // 获取测试按钮的推荐位置\r
+ void GetTestButtonPosition(const char* testModuleName, int& okX, int& okY, int& failX, int& failY, bool& isScrollable);\r
+ \r
+ // 根据viewId实时更新对应界面的按钮颜色\r
+ void UpdateButtonColorByViewId(const char* viewId);\r
private:\r
void InitIView(void);\r
void initView_ext(int x, int y, int w, int h, int interval, const char *imagsrc);\r
UIScrollView *testBTInitIView(uint8_t);
void ClearAll(void);
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
void set_BR_connect(char *);
bool br_scan_set_text(unsigned char *name ,unsigned char *addr,int16_t rssi,int i);
UILabelButtonExt* button{NULL};
void ClearAll(void);
void setcat1msg(cat1_msg);
void setcat1vermsg(cat1_Ver);
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
private:
UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener);
UILabel *InitLabel(LabelConfig &labelConfig);
UIScrollView *testCHANINGInitIView(uint8_t);
void ClearAll(void);
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
private:
UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener);
bool testCHANINGScrollViewcrollViewinit(uint8_t);
UIScrollView *testGSENSONInitIView(uint8_t);
void ClearAll(void);
void set_data();
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
private:
bool testGsonsonScrollViewcrollViewinit(uint8_t);
UILabel *InitLabel(LabelConfig &labelConfig);
void ClearAll(void);
void setgrayvalue(int,int,int);
void setlightvalue(void);
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
private:
UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener);
UILabel *InitLabel(LabelConfig &labelConfig);
}
UIScrollView *testLUMInitIView(uint8_t);
void ClearAll(void);
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
private:
bool testLUMScrollViewcrollViewinit(uint8_t);
UIScrollView *testLUMScrollView{nullptr};
UIScrollView *testmagicInitIView(uint8_t);
void ClearAll(void);
void set_data();
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
private:
bool testmagicScrollViewcrollViewinit(uint8_t);
UILabel *InitLabel(LabelConfig &labelConfig);
void addvolumebuttoncallback();
UIScrollView *testmicrophoneInitIView(uint8_t);
void ClearAll(void);
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
private:
UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener);
bool testphoneScrollViewcrollViewinit(uint8_t);
UIScrollView *testMOTORInitIView(uint8_t);
void ClearAll(void);
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
private:
UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener);
bool testMOTORScrollViewcrollViewinit(uint8_t);
UIScrollView *testSPEAKInitIView(uint8_t);
void ClearAll(void);
+
+ // 获取测试结果按钮的函数
+ UILabelButton* GetOKTestBtn() { return oktestBtn; }
+ UILabelButton* GetFailTestBtn() { return failtestBtn; }
private:
UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener);
bool tesSPEAKScrollViewcrollViewinit(uint8_t);
#include "producttest/include/testView.h"
#include "producttest/include/testGPS.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
// #include "gnss_sample.h"
#include "graphic_service.h"
namespace OHOS
testGPSScrollView->SetTouchable(true);
testGPSScrollView->SetDraggable(true);
- // 添加成功失败按钮
- testView::GetInstance()->AddResultButtons(testGPSScrollView, GPS_TEST, oktestBtn, failtestBtn);
-
- // 重新设置viewId,使用对应的测试项ID
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(GPS_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取GPS测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("GPS", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKGPS", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return false;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOGPS", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return false;
+ }
+
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ testGPSScrollView->Add(oktestBtn);
+ testGPSScrollView->Add(failtestBtn);
+
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(GPS_TEST, oktestBtn, failtestBtn);
uint32_t tick;
osStatus_t retTimer;
#include "producttest/include/testLCD.h"
#include "producttest/include/testView.h"
#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
#include "cmsis_os2.h"
#include "custom_runtime.h"
#ifdef __cplusplus
- testView::GetInstance()->AddResultButtons(testLCDScrollView,LCD_TEST,oktestBtn,failtestBtn);
- // 获取测试项描述
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(LCD_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
-
- //打印viewDesc
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "viewDesc: %s", viewDesc.c_str());
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "okIdStr: %s", okIdStr.c_str());
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "failIdStr: %s", failIdStr.c_str());
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取LCD测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("LCD", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKLCD", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return false;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOLCD", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return false;
+ }
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ testLCDScrollView->Add(oktestBtn);
+ testLCDScrollView->Add(failtestBtn);
- //打印oktestBtn和failtestBtn的viewId
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "oktestBtn->GetViewId(): %s", oktestBtn->GetViewId());
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "failtestBtn->GetViewId(): %s", failtestBtn->GetViewId());
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(LCD_TEST, oktestBtn, failtestBtn);
return true;
}
return true;\r
}\r
\r
- // 处理各测试界面的 成功/失败 按钮\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"view.GetViewId() %s ",view.GetViewId());\r
- if (strncmp(view.GetViewId(), "TestOK", 6) == 0 || strncmp(view.GetViewId(), "TestNO", 6) == 0)\r
- {\r
- printf("=== 成功失败按钮处理调试 ===\n");\r
- printf("检测到成功/失败按钮点击\n");\r
- printf("按钮viewId = %s\n", view.GetViewId());\r
- printf("按钮viewId地址 = %p\n", view.GetViewId());\r
- printf("按钮viewId长度 = %zu\n", strlen(view.GetViewId()));\r
- \r
- std::string vid = view.GetViewId();\r
- printf("转换为std::string后 = %s\n", vid.c_str());\r
- printf("std::string长度 = %zu\n", vid.length());\r
-\r
- if(testModel::GetInstance()->SetResult(vid))\r
- {\r
- printf("SetResult成功\n");\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"222");\r
- return true;\r
- }\r
- printf("SetResult失败\n");\r
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"111");\r
- return false;\r
- }\r
-\r
-\r
- for(int i=0;i<len;i++)\r
+ for(int i=0;i<len;i++)\r
{\r
if(strcmp(view.GetViewId(),Test_ViewMapper_t[i].viewid_str) == 0)\r
{\r
}\r
\r
}\r
+ \r
+ // 处理各测试界面的 成功/失败 按钮\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"view.GetViewId() %s ",view.GetViewId());\r
+ if (strncmp(view.GetViewId(), "TestOK", 6) == 0 || strncmp(view.GetViewId(), "TestNO", 6) == 0)\r
+ {\r
+\r
+ std::string vid = view.GetViewId();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"view.GetViewId() %s ",vid.c_str());\r
+\r
+ if(testModel::GetInstance()->SetResult(vid))\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"SetResult成功");\r
+ \r
+ // 实时更新按钮颜色\r
+ testView::GetInstance()->UpdateButtonColorByViewId(view.GetViewId());\r
+ \r
+ return true;\r
+ }\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"SetResult失败");\r
+ return false;\r
+ }\r
+\r
+\r
\r
if(strcmp(view.GetViewId(),"speak_play") == 0)\r
{ \r
#include "producttest/include/testSEChipTest.h"
#include "ConfigModel.h"
#include "producttest/include/testView.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
#ifdef __cplusplus
#if __cplusplus
extern "C"
Title= testAboutView::GetInstance()->init_title(142,40,"SEChip_TEST");
testSEChipScrollView->Add(Title);
- // 添加成功失败按钮
- testView::GetInstance()->AddResultButtons(testSEChipScrollView, APPI_TEST, oktestBtn, failtestBtn);
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取SE Chip测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("SE_Chip", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKSE_Chip", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return nullptr;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOSE_Chip", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return nullptr;
+ }
+
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ testSEChipScrollView->Add(oktestBtn);
+ testSEChipScrollView->Add(failtestBtn);
- // 重新设置viewId,使用对应的测试项ID
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(APPI_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(APPI_TEST, oktestBtn, failtestBtn);
// uint8_t cnt = pm_veto_get_id_cnt(PM_ID_P_TEST);
// if (cnt == 0) {
#include "producttest/include/testPresenter.h"
#include "producttest/include/testTP.h"
#include "producttest/include/testView.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
#include "cmsis_os2.h"
#ifdef __cplusplus
#if __cplusplus
- testView::GetInstance()->AddResultButtons(testTPScrollView,TP_TEST,oktestBtn,failtestBtn);
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取TP测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("Touch_Panel", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKTouch_Panel", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return false;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOTouch_Panel", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return false;
+ }
+
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ testTPScrollView->Add(oktestBtn);
+ testTPScrollView->Add(failtestBtn);
- // 重新设置viewId,使用对应的测试项ID
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(TP_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(TP_TEST, oktestBtn, failtestBtn);
return true;
}
AddViewToRootContainer(group);
}
+ // 更新测试结果按钮状态和颜色
+ void testView::UpdateResultButtonStatus(int16_t viewId, UILabelButton* oktestBtn, UILabelButton* failtestBtn)
+ {
+ if (oktestBtn == nullptr || failtestBtn == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateResultButtonStatus: buttons are nullptr");
+ return;
+ }
+
+ test_status_enum currentStatus = testModel::GetInstance()->GetResult(viewId);
+
+ switch (currentStatus)
+ {
+ case TEST_STATUS_NONE:
+ oktestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); // 深灰色
+ failtestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ break;
+ case TEST_STATUS_SUCCESS:
+ oktestBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failtestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ break;
+ case TEST_STATUS_ERROR:
+ oktestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failtestBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ break;
+ }
+
+ // oktestBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0x80); //设置为半透明
+ // failtestBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0x80);
+
+ oktestBtn->Invalidate();
+ failtestBtn->Invalidate();
+ }
+
+ // 获取测试按钮的推荐位置
+ void testView::GetTestButtonPosition(const char* testModuleName, int& okX, int& okY, int& failX, int& failY, bool& isScrollable)
+{
+ if (strcmp(testModuleName, "TP") == 0 || strcmp(testModuleName, "Touch_Panel") == 0)
+ {
+ // TP测试界面不能滚动,按钮放在上面,避免遮挡触摸测试区域
+ okX = 40;
+ okY = 80;
+ failX = 220;
+ failY = 80;
+ isScrollable = false;
+ }
+ else if (strcmp(testModuleName, "LCD") == 0)
+ {
+ // LCD测试界面可以滚动,按钮放在下面,避免遮挡显示测试内容
+ okX = 40;
+ okY = 320; // 稍微上移一点,避免完全贴底
+ failX = 220;
+ failY = 320;
+ isScrollable = true;
+ }
+ else if (strcmp(testModuleName, "Magnetic") == 0)
+ {
+ // 磁力计测试界面可以滚动,按钮放在下面,避免遮挡传感器数据显示
+ okX = 40;
+ okY = 330; // 为磁力计数据显示留出更多空间
+ failX = 220;
+ failY = 330;
+ isScrollable = true;
+ }
+ else if (strcmp(testModuleName, "Luminance") == 0)
+ {
+ // 亮度测试界面可以滚动,按钮放在下面,避免遮挡亮度调节滑块
+ okX = 40;
+ okY = 340; // 为亮度滑块留出更多空间
+ failX = 220;
+ failY = 340;
+ isScrollable = true;
+ }
+ else if (strcmp(testModuleName, "BatteryCharger") == 0)
+ {
+ // 电池充电测试界面可以滚动,按钮放在下面,避免遮挡充电状态显示
+ okX = 40;
+ okY = 335; // 为充电状态显示留出更多空间
+ failX = 220;
+ failY = 335;
+ isScrollable = true;
+ }
+ else if (strcmp(testModuleName, "Speaker") == 0)
+ {
+ // 扬声器测试界面可以滚动,按钮放在下面,避免遮挡音频控制按钮
+ okX = 40;
+ okY = 325; // 为音频控制按钮留出更多空间
+ failX = 220;
+ failY = 325;
+ isScrollable = true;
+ }
+ else if (strcmp(testModuleName, "Microphone") == 0)
+ {
+ // 麦克风测试界面可以滚动,按钮放在下面,避免遮挡录音控制按钮
+ okX = 40;
+ okY = 325; // 为录音控制按钮留出更多空间
+ failX = 220;
+ failY = 325;
+ isScrollable = true;
+ }
+ else if (strcmp(testModuleName, "Motor") == 0)
+ {
+ // 马达测试界面可以滚动,按钮放在下面,避免遮挡马达控制按钮
+ okX = 40;
+ okY = 325; // 为马达控制按钮留出更多空间
+ failX = 220;
+ failY = 325;
+ isScrollable = true;
+ }
+ else if (strcmp(testModuleName, "Heart_Rate") == 0)
+ {
+ // 心率传感器测试界面可以滚动,按钮放在下面,避免遮挡心率数据显示
+ okX = 40;
+ okY = 335; // 为心率数据显示留出更多空间
+ failX = 220;
+ failY = 335;
+ isScrollable = true;
+ }
+ else if (strcmp(testModuleName, "G_Sensor") == 0)
+ {
+ // G传感器测试界面可以滚动,按钮放在下面,避免遮挡传感器数据
+ okX = 40;
+ okY = 330; // 为G传感器数据留出更多空间
+ failX = 220;
+ failY = 330;
+ isScrollable = true;
+ }
+ else if (strcmp(testModuleName, "CAT1") == 0)
+ {
+ // CAT1测试界面可以滚动,按钮放在下面,避免遮挡网络状态信息
+ okX = 40;
+ okY = 330; // 为网络状态信息留出更多空间
+ failX = 220;
+ failY = 330;
+ isScrollable = true;
+ }
+ else if (strcmp(testModuleName, "Key") == 0)
+ {
+ // 按键测试界面可以滚动,按钮放在下面,避免遮挡按键测试区域
+ okX = 40;
+ okY = 345; // 为按键测试区域留出更多空间
+ failX = 220;
+ failY = 345;
+ isScrollable = true;
+ }
+ else if (strcmp(testModuleName, "GPS") == 0)
+ {
+ // GPS测试界面可以滚动,按钮放在下面,避免遮挡GPS状态信息
+ okX = 40;
+ okY = 330; // 为GPS状态信息留出更多空间
+ failX = 220;
+ failY = 330;
+ isScrollable = true;
+ }
+ else
+ {
+ // 默认位置:其他界面可以滚动,按钮放在下面
+ okX = 40;
+ okY = 340; // 为其他内容留出更多空间
+ failX = 220;
+ failY = 340;
+ isScrollable = true;
+ }
+}
+
+ // 根据viewId实时更新对应界面的按钮颜色
+ void testView::UpdateButtonColorByViewId(const char* viewId)
+ {
+ if (viewId == nullptr) return;
+
+ // 解析viewId,确定是成功还是失败,以及对应的测试项
+ bool isSuccess = (strncmp(viewId, "TestOK", 6) == 0);
+ std::string testItem;
+
+ if (isSuccess)
+ {
+ testItem = std::string(viewId + 6); // 跳过 "TestOK"
+ }
+ else if (strncmp(viewId, "TestNO", 6) == 0)
+ {
+ testItem = std::string(viewId + 6); // 跳过 "TestNO"
+ }
+ else
+ {
+ return; // 不是测试按钮
+ }
+
+ // 根据测试项找到对应的界面并更新按钮
+ if (testItem == "LCD")
+ {
+ if (test_LCD_view != nullptr)
+ {
+ UILabelButton* okBtn = test_LCD_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_LCD_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ else if (testItem == "Touch_Panel")
+ {
+ if (test_TP_view != nullptr)
+ {
+ UILabelButton* okBtn = test_TP_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_TP_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ else if (testItem == "Bluetooth")
+ {
+ if (test_BT_view != nullptr)
+ {
+ UILabelButton* okBtn = test_BT_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_BT_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ else if (testItem == "CAT1")
+ {
+ if (test_cat1_view != nullptr)
+ {
+ UILabelButton* okBtn = test_cat1_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_cat1_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ else if (testItem == "GPS")
+ {
+ if (test_GPS_view != nullptr)
+ {
+ UILabelButton* okBtn = test_GPS_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_GPS_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ else if (testItem == "SE_Chip")
+ {
+ if (test_SEChip_view != nullptr)
+ {
+ UILabelButton* okBtn = test_SEChip_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_SEChip_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ else if (testItem == "Microphone")
+ {
+ if (test_MP_view != nullptr)
+ {
+ UILabelButton* okBtn = test_MP_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_MP_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ else if (testItem == "Magnetic")
+ {
+ if (test_MG_view != nullptr)
+ {
+ UILabelButton* okBtn = test_MG_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_MG_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ else if (testItem == "Heart_Rate")
+ {
+ if (test_hr_view != nullptr)
+ {
+ UILabelButton* okBtn = test_hr_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_hr_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ else if (testItem == "G_Sensor")
+ {
+ if (test_G_view != nullptr)
+ {
+ UILabelButton* okBtn = test_G_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_G_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ else if (testItem == "Motor")
+ {
+ if (test_motor_view != nullptr)
+ {
+ UILabelButton* okBtn = test_motor_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_motor_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ else if (testItem == "Speaker")
+ {
+ if (test_speak_view != nullptr)
+ {
+ UILabelButton* okBtn = test_speak_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_speak_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ else if (testItem == "BatteryCharger")
+ {
+ if (test_charging_view != nullptr)
+ {
+ UILabelButton* okBtn = test_charging_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_charging_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ else if (testItem == "Luminance")
+ {
+ if (test_lum_view != nullptr)
+ {
+ UILabelButton* okBtn = test_lum_view->GetOKTestBtn();
+ UILabelButton* failBtn = test_lum_view->GetFailTestBtn();
+ if (okBtn && failBtn)
+ {
+ if (isSuccess)
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 绿色
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ }
+ else
+ {
+ okBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
+ failBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe74c3c); // 红色
+ }
+ okBtn->Invalidate();
+ failBtn->Invalidate();
+ }
+ }
+ }
+ // 可以继续添加其他测试项...
+ }
+
} // namespace OHOS
\ No newline at end of file
#include "bluetooth/include/BluetoothModel.h"
#include "producttest/include/testView.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
#ifdef __cplusplus
#if __cplusplus
extern "C"
discovery_falg=false;
- // 添加成功失败按钮
- testView::GetInstance()->AddResultButtons(testBTScrollView, BT_TEST, oktestBtn, failtestBtn);
-
- // 重新设置viewId,使用对应的测试项ID
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(BT_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取BT测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("Bluetooth", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKBluetooth", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return false;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOBluetooth", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return false;
+ }
+
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ testBTScrollView->Add(oktestBtn);
+ testBTScrollView->Add(failtestBtn);
+
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(BT_TEST, oktestBtn, failtestBtn);
// uint8_t cnt = pm_veto_get_id_cnt(PM_ID_P_TEST);
// if (cnt == 0) {
#include "alarm/include/AlarmClockModel.h"
#include "cmsis_os2.h"
#include "producttest/include/testView.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
#ifdef __cplusplus
#if __cplusplus
extern "C"
#include "cat1_server_hal.h"
#include "custom_runtime.h"
#include "producttest/include/testView.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
namespace OHOS
{
testcat1ScrollView->SetTouchable(true);
testcat1ScrollView->SetDraggable(true);
- // 添加成功失败按钮
- testView::GetInstance()->AddResultButtons(testcat1ScrollView, CAT1_TEST, oktestBtn, failtestBtn);
-
- // 重新设置viewId,使用对应的测试项ID
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(CAT1_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取CAT1测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("CAT1", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKCAT1", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return false;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOCAT1", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return false;
+ }
+
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ testcat1ScrollView->Add(oktestBtn);
+ testcat1ScrollView->Add(failtestBtn);
+
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(CAT1_TEST, oktestBtn, failtestBtn);
uint32_t tick;
osStatus_t retTimer;
#endif
#include "producttest/include/testView.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
#include "cmsis_os2.h"
#ifdef __cplusplus
#if __cplusplus
charnge_label= testAboutView::GetInstance()->init_title(100,250,battery_buf);
testCHANINGScrollView->Add(charnge_label);
- // 添加成功失败按钮
- testView::GetInstance()->AddResultButtons(testCHANINGScrollView, BAT_TEST, oktestBtn, failtestBtn);
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取充电测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("BatteryCharger", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKBatteryCharger", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return false;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOBatteryCharger", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return false;
+ }
+
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ testCHANINGScrollView->Add(oktestBtn);
+ testCHANINGScrollView->Add(failtestBtn);
- // 重新设置viewId,使用对应的测试项ID
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(BAT_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(BAT_TEST, oktestBtn, failtestBtn);
// uint8_t cnt = pm_veto_get_id_cnt(PM_ID_P_TEST);
// if (cnt == 0) {
#include "cmsis_os2.h"
#include "producttest/include/testView.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
#include "math.h"
#ifdef __cplusplus
#if __cplusplus
testGsonsonScrollView->SetTouchable(true);
testGsonsonScrollView->SetDraggable(true);
- // 添加成功失败按钮
- testView::GetInstance()->AddResultButtons(testGsonsonScrollView, GSENSOR_TEST, oktestBtn, failtestBtn);
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取G-Sensor测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("G_Sensor", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKG_Sensor", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return false;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOG_Sensor", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return false;
+ }
+
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ testGsonsonScrollView->Add(oktestBtn);
+ testGsonsonScrollView->Add(failtestBtn);
- // 重新设置viewId,使用对应的测试项ID
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(GSENSOR_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(GSENSOR_TEST, oktestBtn, failtestBtn);
return true;
}
#include "alarm/include/AlarmClockModel.h"
#include "cmsis_os2.h"
#include "producttest/include/testView.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
#ifdef __cplusplus
#if __cplusplus
extern "C"
testhrsensonScrollView->SetTouchable(true);
testhrsensonScrollView->SetDraggable(true);
- // 添加成功失败按钮
- testView::GetInstance()->AddResultButtons(testhrsensonScrollView, HR_TEST, oktestBtn, failtestBtn);
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取心率传感器测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("Heart_Rate", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKHeart_Rate", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return false;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOHeart_Rate", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return false;
+ }
+
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ testhrsensonScrollView->Add(oktestBtn);
+ testhrsensonScrollView->Add(failtestBtn);
- // 重新设置viewId,使用对应的测试项ID
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(HR_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(HR_TEST, oktestBtn, failtestBtn);
#ifdef SUPPORT_PPG_SERVICE
int8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST;
#include "ConfigModel.h"
#include "cmsis_os2.h"
#include "producttest/include/testView.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
#ifdef __cplusplus
#if __cplusplus
extern "C"
Title= testAboutView::GetInstance()->init_title(99,54,"BRIGHTNESS_TEST");
testLUMScrollView->Add(Title);
- // 添加成功失败按钮
- testView::GetInstance()->AddResultButtons(testLUMScrollView, LUMINANCE_TEST, oktestBtn, failtestBtn);
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取亮度测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("Luminance", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKLuminance", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return false;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOLuminance", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return false;
+ }
- // 重新设置viewId,使用对应的测试项ID
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(LUMINANCE_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ testLUMScrollView->Add(oktestBtn);
+ testLUMScrollView->Add(failtestBtn);
+
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(LUMINANCE_TEST, oktestBtn, failtestBtn);
// uint8_t cnt = pm_veto_get_id_cnt(PM_ID_P_TEST);
// if (cnt == 0) {
#include "producttest/include/testmagnetic.h"
#include "cmsis_os2.h"
#include "producttest/include/testView.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
// #define TEST_BATTERY
#ifdef TEST_BATTERY
#include "battery_service.h"
testmagicScrollView->SetTouchable(true);
testmagicScrollView->SetDraggable(true);
- // 添加成功失败按钮
- testView::GetInstance()->AddResultButtons(testmagicScrollView, MAGETIC_TEST, oktestBtn, failtestBtn);
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取磁力计测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("Magnetic", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKMagnetic", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return false;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOMagnetic", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return false;
+ }
+
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ testmagicScrollView->Add(oktestBtn);
+ testmagicScrollView->Add(failtestBtn);
- // 重新设置viewId,使用对应的测试项ID
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(MAGETIC_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(MAGETIC_TEST, oktestBtn, failtestBtn);
// uint8_t cnt = pm_veto_get_id_cnt(PM_ID_P_TEST);
// if (cnt == 0) {
#include "cmsis_os2.h"
#include "audio_capture_wrapper.h"
#include "producttest/include/testView.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
#ifdef FD230
#include "findwatch_notification.h"
#endif
testmakephoneScrollView->SetTouchable(true);
testmakephoneScrollView->SetDraggable(true);
- // 添加成功失败按钮
- testView::GetInstance()->AddResultButtons(testmakephoneScrollView, MIC_TEST, oktestBtn, failtestBtn);
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取麦克风测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("Microphone", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKMicrophone", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return false;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOMicrophone", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return false;
+ }
+
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ testmakephoneScrollView->Add(oktestBtn);
+ testmakephoneScrollView->Add(failtestBtn);
- // 重新设置viewId,使用对应的测试项ID
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(MIC_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(MIC_TEST, oktestBtn, failtestBtn);
// uint8_t cnt = pm_veto_get_id_cnt(PM_ID_P_TEST);
// if (cnt == 0) {
#include "dock/vibrator_manager.h"
#include "vibrator_service.h"
#include "producttest/include/testView.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
#ifdef __cplusplus
#if __cplusplus
Title= testAboutView::GetInstance()->init_title(136,45,"MOTOR_TEST");
tesMOTORScrollView->Add(Title);
- // 添加成功失败按钮
- testView::GetInstance()->AddResultButtons(tesMOTORScrollView, MOTOR_TEST, oktestBtn, failtestBtn);
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取马达测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("Motor", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKMotor", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return false;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOMotor", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return false;
+ }
+
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ tesMOTORScrollView->Add(oktestBtn);
+ tesMOTORScrollView->Add(failtestBtn);
- // 重新设置viewId,使用对应的测试项ID
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(MOTOR_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(MOTOR_TEST, oktestBtn, failtestBtn);
// uint8_t cnt = pm_veto_get_id_cnt(PM_ID_P_TEST);
// if (cnt == 0) {
#include "alarm/include/AlarmClockModel.h"
#include "cmsis_os2.h"
#include "producttest/include/testView.h"
+#include "producttest/include/testModel.h"
+#include "uicomponents/UIComponents.h"
#ifdef __cplusplus
#if __cplusplus
extern "C"
testSPEAKScrollView->SetTouchable(true);
testSPEAKScrollView->SetDraggable(true);
- // 添加成功失败按钮
- testView::GetInstance()->AddResultButtons(testSPEAKScrollView, SPK_TEST, oktestBtn, failtestBtn);
+ // 使用通用的InitLabelButton函数初始化按钮,避免viewId地址过期问题
+ // 获取扬声器测试界面的按钮推荐位置
+ int okX, okY, failX, failY;
+ bool isScrollable;
+ testView::GetInstance()->GetTestButtonPosition("Speaker", okX, okY, failX, failY, isScrollable);
+
+ if (!InitLabelButton(oktestBtn, okX, okY, 135, 88, "TestOKSpeaker", "成功", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for OK button failed");
+ return false;
+ }
+
+ if (!InitLabelButton(failtestBtn, failX, failY, 135, 88, "TestNOSpeaker", "失败", 30))
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton for Fail button failed");
+ return false;
+ }
+
+ // 设置按钮样式和监听器
+ oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+ failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER);
+
+ // 设置点击监听器
+ oktestBtn->SetOnClickListener(testPresenter::GetInstance());
+ failtestBtn->SetOnClickListener(testPresenter::GetInstance());
+
+ // 添加到滚动视图
+ testSPEAKScrollView->Add(oktestBtn);
+ testSPEAKScrollView->Add(failtestBtn);
- // 重新设置viewId,使用对应的测试项ID
- std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(SPK_TEST);
- std::string okIdStr = "TestOK" + viewDesc;
- std::string failIdStr = "TestNO" + viewDesc;
- oktestBtn->SetViewId(okIdStr.c_str());
- failtestBtn->SetViewId(failIdStr.c_str());
+ // 根据当前测试状态更新按钮颜色和状态
+ testView::GetInstance()->UpdateResultButtonStatus(SPK_TEST, oktestBtn, failtestBtn);
// uint8_t cnt = pm_veto_get_id_cnt(PM_ID_P_TEST);
// if (cnt == 0) {