From: Caisking Date: Sat, 23 Aug 2025 08:57:33 +0000 (+0800) Subject: 1、以后产测成功失败按键的交互连接; X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~167 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=85b593591fd7e55420def9062857b1432dd114a0;p=mirrors%2FFD230.git 1、以后产测成功失败按键的交互连接; --- diff --git a/code/sdk/zhihui/UI/producttest/include/testGPS.h b/code/sdk/zhihui/UI/producttest/include/testGPS.h index 20da60e2e..3d2b82280 100644 --- a/code/sdk/zhihui/UI/producttest/include/testGPS.h +++ b/code/sdk/zhihui/UI/producttest/include/testGPS.h @@ -64,6 +64,10 @@ namespace OHOS 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); diff --git a/code/sdk/zhihui/UI/producttest/include/testLCD.h b/code/sdk/zhihui/UI/producttest/include/testLCD.h index 324594cd1..ae03784b9 100644 --- a/code/sdk/zhihui/UI/producttest/include/testLCD.h +++ b/code/sdk/zhihui/UI/producttest/include/testLCD.h @@ -25,6 +25,10 @@ namespace OHOS 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}; diff --git a/code/sdk/zhihui/UI/producttest/include/testSEChipTest.h b/code/sdk/zhihui/UI/producttest/include/testSEChipTest.h index 1d7041991..e7f9ed29d 100644 --- a/code/sdk/zhihui/UI/producttest/include/testSEChipTest.h +++ b/code/sdk/zhihui/UI/producttest/include/testSEChipTest.h @@ -33,6 +33,10 @@ namespace OHOS UIScrollView *SEChipInitIView(uint8_t); void ClearAll(void); UILabel *InitLabel(LabelConfig &labelConfig); + + // 获取测试结果按钮的函数 + UILabelButton* GetOKTestBtn() { return oktestBtn; } + UILabelButton* GetFailTestBtn() { return failtestBtn; } private: diff --git a/code/sdk/zhihui/UI/producttest/include/testTP.h b/code/sdk/zhihui/UI/producttest/include/testTP.h index b5f35bdf6..1227717af 100644 --- a/code/sdk/zhihui/UI/producttest/include/testTP.h +++ b/code/sdk/zhihui/UI/producttest/include/testTP.h @@ -36,6 +36,10 @@ namespace OHOS 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); diff --git a/code/sdk/zhihui/UI/producttest/include/testView.h b/code/sdk/zhihui/UI/producttest/include/testView.h index 79f994d56..80a3fc4bf 100644 --- a/code/sdk/zhihui/UI/producttest/include/testView.h +++ b/code/sdk/zhihui/UI/producttest/include/testView.h @@ -112,6 +112,15 @@ namespace OHOS UIScrollView *GetSystemScrollView(int ViewId); bool AddResultButtons(UIScrollView *scrollView, int16_t viewId,UILabelButton*&oktestBtn,UILabelButton*&failtestBtn); + + // 更新测试结果按钮状态和颜色 + void UpdateResultButtonStatus(int16_t viewId, UILabelButton* oktestBtn, UILabelButton* failtestBtn); + + // 获取测试按钮的推荐位置 + void GetTestButtonPosition(const char* testModuleName, int& okX, int& okY, int& failX, int& failY, bool& isScrollable); + + // 根据viewId实时更新对应界面的按钮颜色 + void UpdateButtonColorByViewId(const char* viewId); private: void InitIView(void); void initView_ext(int x, int y, int w, int h, int interval, const char *imagsrc); diff --git a/code/sdk/zhihui/UI/producttest/include/testbt.h b/code/sdk/zhihui/UI/producttest/include/testbt.h index 739e1f3d3..293f6295c 100644 --- a/code/sdk/zhihui/UI/producttest/include/testbt.h +++ b/code/sdk/zhihui/UI/producttest/include/testbt.h @@ -58,6 +58,10 @@ namespace OHOS 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}; diff --git a/code/sdk/zhihui/UI/producttest/include/testcat1.h b/code/sdk/zhihui/UI/producttest/include/testcat1.h index 4ec0c6dd1..13ea76a69 100644 --- a/code/sdk/zhihui/UI/producttest/include/testcat1.h +++ b/code/sdk/zhihui/UI/producttest/include/testcat1.h @@ -79,6 +79,10 @@ namespace OHOS 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); diff --git a/code/sdk/zhihui/UI/producttest/include/testchanging.h b/code/sdk/zhihui/UI/producttest/include/testchanging.h index 3c677a831..f7a9f2978 100644 --- a/code/sdk/zhihui/UI/producttest/include/testchanging.h +++ b/code/sdk/zhihui/UI/producttest/include/testchanging.h @@ -41,6 +41,10 @@ namespace OHOS 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); diff --git a/code/sdk/zhihui/UI/producttest/include/testgsenson.h b/code/sdk/zhihui/UI/producttest/include/testgsenson.h index 9e85b70dd..1ff5f6960 100644 --- a/code/sdk/zhihui/UI/producttest/include/testgsenson.h +++ b/code/sdk/zhihui/UI/producttest/include/testgsenson.h @@ -39,6 +39,10 @@ namespace OHOS 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); diff --git a/code/sdk/zhihui/UI/producttest/include/testhrsenson.h b/code/sdk/zhihui/UI/producttest/include/testhrsenson.h index 627b3cb7c..f9d1ed11f 100644 --- a/code/sdk/zhihui/UI/producttest/include/testhrsenson.h +++ b/code/sdk/zhihui/UI/producttest/include/testhrsenson.h @@ -86,6 +86,10 @@ namespace OHOS 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); diff --git a/code/sdk/zhihui/UI/producttest/include/testluminance.h b/code/sdk/zhihui/UI/producttest/include/testluminance.h index a87320f43..383e1483d 100644 --- a/code/sdk/zhihui/UI/producttest/include/testluminance.h +++ b/code/sdk/zhihui/UI/producttest/include/testluminance.h @@ -30,6 +30,10 @@ namespace OHOS } UIScrollView *testLUMInitIView(uint8_t); void ClearAll(void); + + // 获取测试结果按钮的函数 + UILabelButton* GetOKTestBtn() { return oktestBtn; } + UILabelButton* GetFailTestBtn() { return failtestBtn; } private: bool testLUMScrollViewcrollViewinit(uint8_t); UIScrollView *testLUMScrollView{nullptr}; diff --git a/code/sdk/zhihui/UI/producttest/include/testmagnetic.h b/code/sdk/zhihui/UI/producttest/include/testmagnetic.h index b613db1a3..a7c4c4d47 100644 --- a/code/sdk/zhihui/UI/producttest/include/testmagnetic.h +++ b/code/sdk/zhihui/UI/producttest/include/testmagnetic.h @@ -41,6 +41,10 @@ namespace OHOS 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); diff --git a/code/sdk/zhihui/UI/producttest/include/testmicrophone.h b/code/sdk/zhihui/UI/producttest/include/testmicrophone.h index a8fce1f3e..a366aabd5 100644 --- a/code/sdk/zhihui/UI/producttest/include/testmicrophone.h +++ b/code/sdk/zhihui/UI/producttest/include/testmicrophone.h @@ -58,6 +58,10 @@ namespace OHOS 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); diff --git a/code/sdk/zhihui/UI/producttest/include/testmotor.h b/code/sdk/zhihui/UI/producttest/include/testmotor.h index cdec49d95..aff0905a3 100644 --- a/code/sdk/zhihui/UI/producttest/include/testmotor.h +++ b/code/sdk/zhihui/UI/producttest/include/testmotor.h @@ -44,6 +44,10 @@ namespace OHOS 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); diff --git a/code/sdk/zhihui/UI/producttest/include/testspeak.h b/code/sdk/zhihui/UI/producttest/include/testspeak.h index 94f12afdb..35a2a3a61 100644 --- a/code/sdk/zhihui/UI/producttest/include/testspeak.h +++ b/code/sdk/zhihui/UI/producttest/include/testspeak.h @@ -43,6 +43,10 @@ namespace OHOS 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); diff --git a/code/sdk/zhihui/UI/producttest/src/testGPS.cpp b/code/sdk/zhihui/UI/producttest/src/testGPS.cpp index 07cdb6c52..8f6c1aa1d 100644 --- a/code/sdk/zhihui/UI/producttest/src/testGPS.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testGPS.cpp @@ -13,6 +13,8 @@ #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 @@ -282,15 +284,38 @@ 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; diff --git a/code/sdk/zhihui/UI/producttest/src/testLCD.cpp b/code/sdk/zhihui/UI/producttest/src/testLCD.cpp index 7def78e5e..4c4b79228 100644 --- a/code/sdk/zhihui/UI/producttest/src/testLCD.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testLCD.cpp @@ -4,6 +4,7 @@ #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 @@ -196,23 +197,38 @@ namespace OHOS - 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; } diff --git a/code/sdk/zhihui/UI/producttest/src/testPresenter.cpp b/code/sdk/zhihui/UI/producttest/src/testPresenter.cpp index b68ad064f..efea0a5f4 100644 --- a/code/sdk/zhihui/UI/producttest/src/testPresenter.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testPresenter.cpp @@ -239,33 +239,7 @@ namespace OHOS return true; } - // 处理各测试界面的 成功/失败 按钮 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"view.GetViewId() %s ",view.GetViewId()); - if (strncmp(view.GetViewId(), "TestOK", 6) == 0 || strncmp(view.GetViewId(), "TestNO", 6) == 0) - { - printf("=== 成功失败按钮处理调试 ===\n"); - printf("检测到成功/失败按钮点击\n"); - printf("按钮viewId = %s\n", view.GetViewId()); - printf("按钮viewId地址 = %p\n", view.GetViewId()); - printf("按钮viewId长度 = %zu\n", strlen(view.GetViewId())); - - std::string vid = view.GetViewId(); - printf("转换为std::string后 = %s\n", vid.c_str()); - printf("std::string长度 = %zu\n", vid.length()); - - if(testModel::GetInstance()->SetResult(vid)) - { - printf("SetResult成功\n"); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"222"); - return true; - } - printf("SetResult失败\n"); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"111"); - return false; - } - - - for(int i=0;iSetResult(vid)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"SetResult成功"); + + // 实时更新按钮颜色 + testView::GetInstance()->UpdateButtonColorByViewId(view.GetViewId()); + + return true; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"SetResult失败"); + return false; + } + + if(strcmp(view.GetViewId(),"speak_play") == 0) { diff --git a/code/sdk/zhihui/UI/producttest/src/testSEChipTest.cpp b/code/sdk/zhihui/UI/producttest/src/testSEChipTest.cpp index 608dc1c75..3c58c16cd 100644 --- a/code/sdk/zhihui/UI/producttest/src/testSEChipTest.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testSEChipTest.cpp @@ -4,6 +4,8 @@ #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" @@ -245,15 +247,38 @@ namespace OHOS 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) { diff --git a/code/sdk/zhihui/UI/producttest/src/testTP.cpp b/code/sdk/zhihui/UI/producttest/src/testTP.cpp index a52ddb394..698bd4f13 100644 --- a/code/sdk/zhihui/UI/producttest/src/testTP.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testTP.cpp @@ -3,6 +3,8 @@ #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 @@ -206,14 +208,38 @@ namespace OHOS - 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; } diff --git a/code/sdk/zhihui/UI/producttest/src/testView.cpp b/code/sdk/zhihui/UI/producttest/src/testView.cpp index d61afc662..7044a578d 100644 --- a/code/sdk/zhihui/UI/producttest/src/testView.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testView.cpp @@ -1111,4 +1111,517 @@ namespace OHOS 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 diff --git a/code/sdk/zhihui/UI/producttest/src/testbt.cpp b/code/sdk/zhihui/UI/producttest/src/testbt.cpp index 5ff2a9294..7225da643 100644 --- a/code/sdk/zhihui/UI/producttest/src/testbt.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testbt.cpp @@ -19,6 +19,8 @@ #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" @@ -400,15 +402,38 @@ namespace OHOS 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) { diff --git a/code/sdk/zhihui/UI/producttest/src/testbutton.cpp b/code/sdk/zhihui/UI/producttest/src/testbutton.cpp index 576dcd8c2..22574cba2 100644 --- a/code/sdk/zhihui/UI/producttest/src/testbutton.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testbutton.cpp @@ -5,6 +5,8 @@ #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" diff --git a/code/sdk/zhihui/UI/producttest/src/testcat1.cpp b/code/sdk/zhihui/UI/producttest/src/testcat1.cpp index f6cd75965..01c722d82 100644 --- a/code/sdk/zhihui/UI/producttest/src/testcat1.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testcat1.cpp @@ -10,6 +10,8 @@ #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 { @@ -352,15 +354,38 @@ 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; diff --git a/code/sdk/zhihui/UI/producttest/src/testchanging.cpp b/code/sdk/zhihui/UI/producttest/src/testchanging.cpp index b6ddea1c1..eb2612160 100644 --- a/code/sdk/zhihui/UI/producttest/src/testchanging.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testchanging.cpp @@ -9,6 +9,8 @@ #endif #include "producttest/include/testView.h" +#include "producttest/include/testModel.h" +#include "uicomponents/UIComponents.h" #include "cmsis_os2.h" #ifdef __cplusplus #if __cplusplus @@ -220,15 +222,38 @@ namespace OHOS 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) { diff --git a/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp b/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp index fb770f1ce..4c0962ae5 100644 --- a/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp @@ -5,6 +5,8 @@ #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 @@ -311,15 +313,38 @@ namespace OHOS 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; } diff --git a/code/sdk/zhihui/UI/producttest/src/testhrsenson.cpp b/code/sdk/zhihui/UI/producttest/src/testhrsenson.cpp index c78b6de87..01d78efed 100644 --- a/code/sdk/zhihui/UI/producttest/src/testhrsenson.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testhrsenson.cpp @@ -5,6 +5,8 @@ #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" @@ -306,15 +308,38 @@ namespace OHOS 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; diff --git a/code/sdk/zhihui/UI/producttest/src/testluminance.cpp b/code/sdk/zhihui/UI/producttest/src/testluminance.cpp index dc606ebfb..c0f18bc35 100644 --- a/code/sdk/zhihui/UI/producttest/src/testluminance.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testluminance.cpp @@ -5,6 +5,8 @@ #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" @@ -149,15 +151,38 @@ namespace OHOS 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) { diff --git a/code/sdk/zhihui/UI/producttest/src/testmagnetic.cpp b/code/sdk/zhihui/UI/producttest/src/testmagnetic.cpp index 08557d6c6..fcf38f1c4 100644 --- a/code/sdk/zhihui/UI/producttest/src/testmagnetic.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testmagnetic.cpp @@ -4,6 +4,8 @@ #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" @@ -300,15 +302,38 @@ namespace OHOS 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) { diff --git a/code/sdk/zhihui/UI/producttest/src/testmicrophone.cpp b/code/sdk/zhihui/UI/producttest/src/testmicrophone.cpp index 87e89221b..24bc9055e 100644 --- a/code/sdk/zhihui/UI/producttest/src/testmicrophone.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testmicrophone.cpp @@ -6,6 +6,8 @@ #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 @@ -320,15 +322,38 @@ namespace OHOS 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) { diff --git a/code/sdk/zhihui/UI/producttest/src/testmotor.cpp b/code/sdk/zhihui/UI/producttest/src/testmotor.cpp index 827921286..604033e23 100644 --- a/code/sdk/zhihui/UI/producttest/src/testmotor.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testmotor.cpp @@ -7,6 +7,8 @@ #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 @@ -222,15 +224,38 @@ namespace OHOS 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) { diff --git a/code/sdk/zhihui/UI/producttest/src/testspeak.cpp b/code/sdk/zhihui/UI/producttest/src/testspeak.cpp index 9dfadbd99..4d62f2c4a 100644 --- a/code/sdk/zhihui/UI/producttest/src/testspeak.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testspeak.cpp @@ -5,6 +5,8 @@ #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" @@ -249,15 +251,38 @@ namespace OHOS 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) {