mirror of
https://gitee.com/openharmony/accessibility
synced 2024-11-27 00:51:07 +00:00
!1424 无障碍修改findElement接口,改为从elementInfo中取windowId
Merge pull request !1424 from qianchuang/master
This commit is contained in:
commit
035271e2b0
@ -233,10 +233,12 @@ public:
|
||||
/**
|
||||
* @brief Get node information based on element id in active window.
|
||||
* @param elementId The target element id.
|
||||
* @param windowId The target window id.
|
||||
* @param targetElementInfo The element info of specified content.
|
||||
* @return Return RET_OK if gets info successfully, otherwise refer to the RetError for the failure.
|
||||
*/
|
||||
virtual RetError GetByElementId(const int64_t elementId, AccessibilityElementInfo &targetElementInfo) override;
|
||||
virtual RetError GetByElementId(const int64_t elementId, const int32_t windowId,
|
||||
AccessibilityElementInfo &targetElementInfo) override;
|
||||
|
||||
/**
|
||||
* @brief Get node information based on inspectorKey in active window.
|
||||
|
@ -937,7 +937,7 @@ RetError AccessibleAbilityClientImpl::GetParentElementInfo(const AccessibilityEl
|
||||
return SearchElementInfoByElementId(windowId, parentElementId, cacheMode_, parent, treeId);
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityClientImpl::GetByElementId(const int64_t elementId,
|
||||
RetError AccessibleAbilityClientImpl::GetByElementId(const int64_t elementId, const int32_t windowId,
|
||||
AccessibilityElementInfo &targetElementInfo)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
@ -957,16 +957,15 @@ RetError AccessibleAbilityClientImpl::GetByElementId(const int64_t elementId,
|
||||
return RET_ERR_NO_CONNECTION;
|
||||
}
|
||||
|
||||
int32_t activeWindow = serviceProxy_->GetActiveWindow();
|
||||
int32_t treeId = (static_cast<uint64_t>(elementId) >> ELEMENT_MOVE_BIT);
|
||||
HILOG_DEBUG("window:[%{public}d],treeId:%{public}d,elementId:%{public}" PRId64 "",
|
||||
activeWindow, treeId, elementId);
|
||||
if (GetCacheElementInfo(activeWindow, elementId, targetElementInfo)) {
|
||||
windowId, treeId, elementId);
|
||||
if (GetCacheElementInfo(windowId, elementId, targetElementInfo)) {
|
||||
HILOG_DEBUG("get element info from cache");
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
return SearchElementInfoByElementId(activeWindow, elementId, cacheMode_, targetElementInfo, treeId);
|
||||
return SearchElementInfoByElementId(windowId, elementId, cacheMode_, targetElementInfo, treeId);
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityClientImpl::GetCursorPosition(const AccessibilityElementInfo &elementInfo, int32_t &position)
|
||||
|
@ -214,11 +214,12 @@ RetError AccessibleAbilityClientImpl::GetParentElementInfo(const AccessibilityEl
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityClientImpl::GetByElementId(const int64_t elementId,
|
||||
RetError AccessibleAbilityClientImpl::GetByElementId(const int64_t elementId, const int32_t windowId,
|
||||
AccessibilityElementInfo &targetElementInfo)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
(void)elementId;
|
||||
(void)windowId;
|
||||
(void)targetElementInfo;
|
||||
return RET_OK;
|
||||
}
|
||||
|
@ -583,8 +583,9 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetByElementId_001, TestSize.Level1)
|
||||
GTEST_LOG_(INFO) << "GetByElementId_001 start";
|
||||
Connect();
|
||||
int64_t elementId = 10;
|
||||
int32_t windowId = 1;
|
||||
AccessibilityElementInfo targetElementInfo {};
|
||||
EXPECT_EQ(instance_->GetByElementId(elementId, targetElementInfo), RET_ERR_TIME_OUT);
|
||||
EXPECT_EQ(instance_->GetByElementId(elementId, windowId, targetElementInfo), RET_ERR_TIME_OUT);
|
||||
GTEST_LOG_(INFO) << "GetByElementId_001 end";
|
||||
}
|
||||
|
||||
@ -597,8 +598,9 @@ HWTEST_F(AccessibleAbilityClientImplTest, GetByElementId_002, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "GetByElementId_002 start";
|
||||
int64_t elementId = 10;
|
||||
int32_t windowId = 1;
|
||||
AccessibilityElementInfo targetElementInfo {};
|
||||
EXPECT_EQ(instance_->GetByElementId(elementId, targetElementInfo), RET_ERR_NO_CONNECTION);
|
||||
EXPECT_EQ(instance_->GetByElementId(elementId, windowId, targetElementInfo), RET_ERR_NO_CONNECTION);
|
||||
GTEST_LOG_(INFO) << "GetByElementId_002 end";
|
||||
}
|
||||
|
||||
|
@ -184,10 +184,12 @@ public:
|
||||
/**
|
||||
* @brief Get node information based on element id in active window.
|
||||
* @param elementId The target element id.
|
||||
* @param windowId The target window id.
|
||||
* @param targetElementInfo The element info of specified content.
|
||||
* @return Return RET_OK if gets info successfully, otherwise refer to the RetError for the failure.
|
||||
*/
|
||||
virtual RetError GetByElementId(const int64_t elementId, AccessibilityElementInfo &targetElementInfo) = 0;
|
||||
virtual RetError GetByElementId(const int64_t elementId, const int32_t windowId,
|
||||
AccessibilityElementInfo &targetElementInfo) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get node information based on inspectorKey in active window.
|
||||
|
@ -2007,9 +2007,10 @@ void NAccessibilityElement::FindElementExecute(napi_env env, void* data)
|
||||
case FindElementCondition::FIND_ELEMENT_CONDITION_ELEMENT_ID:
|
||||
{
|
||||
int64_t elementId = std::stoll(callbackInfo->condition_);
|
||||
HILOG_DEBUG("elementId is %{public}" PRId64 "", elementId);
|
||||
int32_t windowId = callbackInfo->accessibilityElement_.elementInfo_->GetWindowId();
|
||||
HILOG_DEBUG("elementId is %{public}" PRId64 " windowId: %{public}d", elementId, windowId);
|
||||
callbackInfo->ret_ = AccessibleAbilityClient::GetInstance()->GetByElementId(
|
||||
elementId, callbackInfo->nodeInfo_);
|
||||
elementId, windowId, callbackInfo->nodeInfo_);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user