From 4f66d7d576129f8e9998abfe019958dcbad3dfb4 Mon Sep 17 00:00:00 2001 From: Caisking Date: Sat, 23 Aug 2025 17:00:32 +0800 Subject: [PATCH] =?utf8?q?=E5=85=B3=E9=97=AD=E4=B8=8D=E5=BF=85=E8=A6=81?= =?utf8?q?=E7=9A=84=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../UI/producttest/BUTTON_VIEWID_FIX.md | 10 ++--- .../zhihui/UI/producttest/src/testModel.cpp | 6 +-- .../UI/producttest/src/testPresenter.cpp | 20 +++++----- .../zhihui/UI/producttest/src/testQRCode.cpp | 8 ++-- .../zhihui/UI/producttest/src/testView.cpp | 38 +++++++++---------- .../zhihui/UI/producttest/src/testgsenson.cpp | 2 +- .../UI/producttest/src/testmagnetic.cpp | 2 +- 7 files changed, 43 insertions(+), 43 deletions(-) diff --git a/code/sdk/zhihui/UI/producttest/BUTTON_VIEWID_FIX.md b/code/sdk/zhihui/UI/producttest/BUTTON_VIEWID_FIX.md index 96b883bad..45f385bdb 100644 --- a/code/sdk/zhihui/UI/producttest/BUTTON_VIEWID_FIX.md +++ b/code/sdk/zhihui/UI/producttest/BUTTON_VIEWID_FIX.md @@ -126,7 +126,7 @@ test_status_t test_status_list[MAX_TEST_ITEM] = { ```cpp // 获取测试项描述 std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(viewId); -printf("目前测试项的描述是:%s\n",viewDesc.c_str()); +WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"目前测试项的描述是:%s\n",viewDesc.c_str()); // 安全检查:确保viewDesc不为空 if (viewDesc.empty()) @@ -162,10 +162,10 @@ if (viewDesc.empty()) ### 1. **添加详细日志输出** 在`AddResultButtons`中添加更多日志: ```cpp -printf("AddResultButtons: viewId=%d\n", viewId); -printf("AddResultButtons: viewDesc=%s\n", viewDesc.c_str()); -printf("AddResultButtons: okIdStr=%s\n", okIdStr.c_str()); -printf("AddResultButtons: failIdStr=%s\n", failIdStr.c_str()); +WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"AddResultButtons: viewId=%d\n", viewId); +WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"AddResultButtons: viewDesc=%s\n", viewDesc.c_str()); +WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"AddResultButtons: okIdStr=%s\n", okIdStr.c_str()); +WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"AddResultButtons: failIdStr=%s\n", failIdStr.c_str()); ``` ### 2. **验证枚举值范围** diff --git a/code/sdk/zhihui/UI/producttest/src/testModel.cpp b/code/sdk/zhihui/UI/producttest/src/testModel.cpp index 46623fcb2..a70ae57d7 100644 --- a/code/sdk/zhihui/UI/producttest/src/testModel.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testModel.cpp @@ -66,7 +66,7 @@ namespace OHOS // 通过测试项描述进行更新 bool testModel::SetResult(std::string viewIdstr) { - printf("目前传过来的idstr:%s\n", viewIdstr.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"目前传过来的idstr:%s\n", viewIdstr.c_str()); // 解析执行结果 test_status_enum status = TEST_STATUS_NONE; if (strncmp(viewIdstr.c_str(), "TestOK", 6) == 0) @@ -85,7 +85,7 @@ namespace OHOS // 提取测试项描述(跳过前面的"TestOK"或"TestNO") std::string desc = viewIdstr.substr(6); - printf("提取的测试项:%s\n", desc.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"提取的测试项:%s\n", desc.c_str()); // 查找匹配的测试项并更新状态 for (int i = 0; i < MAX_TEST_ITEM; i++) @@ -223,7 +223,7 @@ namespace OHOS void testModel::testModelupdata(int type) { - printf("testModelupdata : %d\n", type); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"testModelupdata : %d\n", type); switch (type) { case 1: diff --git a/code/sdk/zhihui/UI/producttest/src/testPresenter.cpp b/code/sdk/zhihui/UI/producttest/src/testPresenter.cpp index efea0a5f4..ac60704e1 100644 --- a/code/sdk/zhihui/UI/producttest/src/testPresenter.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testPresenter.cpp @@ -159,14 +159,14 @@ namespace OHOS bool testPresenter::OnClick(UIView &view, const ClickEvent &event) { // === VIEWID 点击追踪调试 === - printf("=== ONCLICK VIEWID DEBUG ===\n"); - printf("按钮被点击,view.GetViewId() = %s\n", view.GetViewId()); - printf("view.GetViewId() 地址 = %p\n", view.GetViewId()); - printf("view.GetViewId() 长度 = %zu\n", strlen(view.GetViewId())); - printf("按钮类型 = %d\n", view.GetViewType()); - printf("按钮位置 = (%d, %d)\n", view.GetX(), view.GetY()); - printf("按钮大小 = %dx%d\n", view.GetWidth(), view.GetHeight()); - printf("=== ONCLICK VIEWID DEBUG END ===\n"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"=== ONCLICK VIEWID DEBUG ===\n"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"按钮被点击,view.GetViewId() = %s\n", view.GetViewId()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"view.GetViewId() 地址 = %p\n", view.GetViewId()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"view.GetViewId() 长度 = %zu\n", strlen(view.GetViewId())); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"按钮类型 = %d\n", view.GetViewType()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"按钮位置 = (%d, %d)\n", view.GetX(), view.GetY()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"按钮大小 = %dx%d\n", view.GetWidth(), view.GetHeight()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"=== ONCLICK VIEWID DEBUG END ===\n"); testView *p_SystemView = testView::GetInstance(); int len=MAX_TESTVIEWID;//sizeof(Test_ViewMapper_t)/sizeof(Test_ViewMapper_t[0]); @@ -509,7 +509,7 @@ extern "C" if(testView::GetInstance()) testView::GetInstance()->ChangeView(TESTVIEW,TP); else - printf("xxxxxxxxxxxxxxxxxxxxx\r\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"xxxxxxxxxxxxxxxxxxxxx\r\n"); } void factorytest_enter_test_lcd_view(void) @@ -517,7 +517,7 @@ extern "C" if( testView::GetInstance()) testView::GetInstance()->ChangeView(TESTVIEW,LCD); else - printf("xxxxxxxxxxxxxxxxxxxxx\r\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"xxxxxxxxxxxxxxxxxxxxx\r\n"); } void factorytest_enter_test_button_view(void) diff --git a/code/sdk/zhihui/UI/producttest/src/testQRCode.cpp b/code/sdk/zhihui/UI/producttest/src/testQRCode.cpp index 310163bb5..87c1900ef 100644 --- a/code/sdk/zhihui/UI/producttest/src/testQRCode.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testQRCode.cpp @@ -180,10 +180,10 @@ namespace OHOS // 调试:打印内容长度 - printf("=== 二维码内容长度检查 ===\n"); - printf("内容长度: %zu 字符\n", content.length()); - printf("内容预览:\n%s\n", content.c_str()); - printf("=== 内容长度检查结束 ===\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"=== 二维码内容长度检查 ===\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"内容长度: %zu 字符\n", content.length()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"内容预览:\n%s\n", content.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"=== 内容长度检查结束 ===\n"); return content; } diff --git a/code/sdk/zhihui/UI/producttest/src/testView.cpp b/code/sdk/zhihui/UI/producttest/src/testView.cpp index 7044a578d..84ce48a51 100644 --- a/code/sdk/zhihui/UI/producttest/src/testView.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testView.cpp @@ -288,7 +288,7 @@ namespace OHOS return false; } - printf("目前测试项id:%d",viewId); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"目前测试项id:%d",viewId); // 创建新按钮(如果当前按钮为空) if (oktestBtn == nullptr) @@ -322,10 +322,10 @@ namespace OHOS // 获取当前测试项状态 test_status_enum status = testModel::GetInstance()->GetResult(viewId); - printf("目前该项的测试状态为:%d\n",status); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"目前该项的测试状态为:%d\n",status); // 获取测试项描述 std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(viewId); - printf("目前测试项的描述是:%s\n",viewDesc.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"目前测试项的描述是:%s\n",viewDesc.c_str()); // 安全检查:确保viewDesc不为空 if (viewDesc.empty()) @@ -354,17 +354,17 @@ namespace OHOS // 设置按钮标识 - 修复悬空指针问题 okButtonViewId = "TestOK" + viewDesc; - printf("=== VIEWID DEBUG ===\n"); - printf("设置前 oktestBtn->GetViewId() = %s\n", oktestBtn->GetViewId()); - printf("准备设置 viewId = %s\n", okButtonViewId.c_str()); - printf("okButtonViewId 字符串地址 = %p\n", okButtonViewId.c_str()); - printf("okButtonViewId 字符串长度 = %zu\n", okButtonViewId.length()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"=== VIEWID DEBUG ===\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"设置前 oktestBtn->GetViewId() = %s\n", oktestBtn->GetViewId()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"准备设置 viewId = %s\n", okButtonViewId.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"okButtonViewId 字符串地址 = %p\n", okButtonViewId.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"okButtonViewId 字符串长度 = %zu\n", okButtonViewId.length()); oktestBtn->SetViewId(okButtonViewId.c_str()); - printf("设置后 oktestBtn->GetViewId() = %s\n", oktestBtn->GetViewId()); - printf("设置后 oktestBtn->GetViewId() 地址 = %p\n", oktestBtn->GetViewId()); - printf("=== VIEWID DEBUG END ===\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"设置后 oktestBtn->GetViewId() = %s\n", oktestBtn->GetViewId()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"设置后 oktestBtn->GetViewId() 地址 = %p\n", oktestBtn->GetViewId()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"=== VIEWID DEBUG END ===\n"); // UIView::OnClickListener *clickListener = static_cast(testPresenter::GetInstance()); oktestBtn->SetOnClickListener(presenter_); @@ -392,17 +392,17 @@ namespace OHOS // 设置按钮标识(修复了原代码中的错误)- 修复悬空指针问题 failButtonViewId = "TestNO" + viewDesc; - printf("=== VIEWID DEBUG FAIL BUTTON ===\n"); - printf("设置前 failtestBtn->GetViewId() = %s\n", failtestBtn->GetViewId()); - printf("准备设置 viewId = %s\n", failButtonViewId.c_str()); - printf("failButtonViewId 字符串地址 = %p\n", failButtonViewId.c_str()); - printf("failButtonViewId 字符串长度 = %zu\n", failButtonViewId.length()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"=== VIEWID DEBUG FAIL BUTTON ===\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"设置前 failtestBtn->GetViewId() = %s\n", failtestBtn->GetViewId()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"准备设置 viewId = %s\n", failButtonViewId.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"failButtonViewId 字符串地址 = %p\n", failButtonViewId.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"failButtonViewId 字符串长度 = %zu\n", failButtonViewId.length()); failtestBtn->SetViewId(failButtonViewId.c_str()); - printf("设置后 failtestBtn->GetViewId() = %s\n", failtestBtn->GetViewId()); - printf("设置后 failtestBtn->GetViewId() 地址 = %p\n", failtestBtn->GetViewId()); - printf("=== VIEWID DEBUG FAIL BUTTON END ===\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"设置后 failtestBtn->GetViewId() = %s\n", failtestBtn->GetViewId()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"设置后 failtestBtn->GetViewId() 地址 = %p\n", failtestBtn->GetViewId()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"=== VIEWID DEBUG FAIL BUTTON END ===\n"); // UIView::OnClickListener *clickListener = static_cast(testPresenter::GetInstance()); failtestBtn->SetOnClickListener(presenter_); diff --git a/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp b/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp index 4c0962ae5..ed0d26364 100644 --- a/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp @@ -175,7 +175,7 @@ namespace OHOS // FactoryTestResult *g_ret = OHOS::testPresenter::GetInstance()->GetFactoryTestResult(); // if (g_ret) { - // printf("gsensor test result:%d\n", g_ret->gsensor); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"gsensor test result:%d\n", g_ret->gsensor); // } #endif diff --git a/code/sdk/zhihui/UI/producttest/src/testmagnetic.cpp b/code/sdk/zhihui/UI/producttest/src/testmagnetic.cpp index fcf38f1c4..5a32c16d6 100644 --- a/code/sdk/zhihui/UI/producttest/src/testmagnetic.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testmagnetic.cpp @@ -171,7 +171,7 @@ namespace OHOS // FactoryTestResult *g_ret = OHOS::testPresenter::GetInstance()->GetFactoryTestResult(); // if(g_ret) - // printf("mag test result:%d\n",g_ret->mag); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"mag test result:%d\n",g_ret->mag); char buf[16]={0}; sprintf(buf,"angle:%.2f",angle_value); -- 2.17.1