modify.Signed-off-by: <zhouke35@huawei.com>.

Signed-off-by: zhouke <zhouke35@huawei.com>
This commit is contained in:
zhouke
2022-09-14 10:58:33 +08:00
parent 226526c585
commit 4fbd7373ca
+9 -9
View File
@@ -41,9 +41,9 @@ namespace OHOS::uitest {
void Visit(const Widget &widget) override
{
string type = widget.GetAttr(ATTR_NAMES[UiAttr::TYPE], "") + "/";
string value = widget.GetAttr(ATTR_NAMES[UiAttr::TEXT], "") + "/";
string hashcode = widget.GetAttr(ATTR_NAMES[UiAttr::HASHCODE], "") + ";";
auto type = widget.GetAttr(ATTR_NAMES[UiAttr::TYPE], "") + "/";
auto value = widget.GetAttr(ATTR_NAMES[UiAttr::TEXT], "") + "/";
auto hashcode = widget.GetAttr(ATTR_NAMES[UiAttr::HASHCODE], "") + ";";
receiver_ = receiver_ + type + value + hashcode;
if (value != "/") {
leafNodes_.push_back(type + value + hashcode);
@@ -80,7 +80,7 @@ namespace OHOS::uitest {
void WidgetOperator::ScrollToEnd(bool toTop, ApiCallErr &error) const
{
string prevSnapshot = "", preKeySnapshot = "";
string prevSnapshot = "", targetSnapshot = "";
while (true) {
auto scrollWidget = driver_.RetrieveWidget(widget_, error);
if (scrollWidget == nullptr || error.code_ != NO_ERROR) {
@@ -89,11 +89,11 @@ namespace OHOS::uitest {
string snapshot;
vector<string> leafNodes;
TakeScopeUiSnapshot(driver_, *scrollWidget, snapshot, leafNodes);
if ((prevSnapshot == snapshot) || (snapshot.find(preKeySnapshot) != string::npos && preKeySnapshot != "")) {
if ((prevSnapshot == snapshot) || (snapshot.find(targetSnapshot) != string::npos && targetSnapshot != "")) {
return;
}
prevSnapshot = snapshot;
preKeySnapshot = (toTop ? leafNodes.front() : leafNodes.back());
targetSnapshot = (toTop ? leafNodes.front() : leafNodes.back());
auto bounds = scrollWidget->GetBounds();
if (options_.scrollWidgetDeadZone_ > 0) {
// scroll widget from its deadZone maybe unresponsive
@@ -217,7 +217,7 @@ namespace OHOS::uitest {
{
PointerMatrix scrollEvents;
bool scrollingUp = true;
string prevSnapshot = "", preKeySnapshot = "";
string prevSnapshot = "", targetSnapshot = "";
vector<reference_wrapper<const Widget>> receiver;
while (true) {
auto scrollWidget = driver_.RetrieveWidget(widget_, error);
@@ -235,7 +235,7 @@ namespace OHOS::uitest {
string snapshot;
vector<string> leafNodes;
TakeScopeUiSnapshot(driver_, *scrollWidget, snapshot, leafNodes);
if ((snapshot == prevSnapshot) || (snapshot.find(preKeySnapshot) != string::npos && preKeySnapshot != "")) {
if ((snapshot == prevSnapshot) || (snapshot.find(targetSnapshot) != string::npos && targetSnapshot != "")) {
// scrolling down to bottom, search completed with failure
if (!scrollingUp) {
auto msg = string("Scroll search widget failed: ") + selector.Describe();
@@ -247,7 +247,7 @@ namespace OHOS::uitest {
}
}
prevSnapshot = snapshot;
preKeySnapshot = (scrollingUp ? leafNodes.front() : leafNodes.back());
targetSnapshot = (scrollingUp ? leafNodes.front() : leafNodes.back());
// execute scrolling on the scroll_widget without update UI
auto bounds = scrollWidget->GetBounds();
if (options_.scrollWidgetDeadZone_ > 0) {