From 593488fb78000ffae96313a7f629a64d0cd5563e Mon Sep 17 00:00:00 2001 From: chen8281 Date: Thu, 11 Sep 2025 19:08:04 +0800 Subject: [PATCH 1/3] overload Signed-off-by: chen8281 --- uitest/ets/ani/ets/@ohos.UiTest.ets | 35 ++--------------------------- uitest/ets/ani/src/uitest_ani.cpp | 29 ++++++++++++++++-------- 2 files changed, 22 insertions(+), 42 deletions(-) diff --git a/uitest/ets/ani/ets/@ohos.UiTest.ets b/uitest/ets/ani/ets/@ohos.UiTest.ets index 31c17cbd..cd15a558 100644 --- a/uitest/ets/ani/ets/@ohos.UiTest.ets +++ b/uitest/ets/ani/ets/@ohos.UiTest.ets @@ -276,24 +276,6 @@ export class Component { }); return promise; } - - scrollSearch(on: On):Promise { - let promise = new Promise((resolve, reject) => { - let promise1 = taskpool.execute(():Component|null => this.scrollSearchSync(on, true, 80)); - promise1.then((e:NullishType)=>{ - if (e) { - let value : Component = e as Component; - resolve(value); - } else { - resolve(null) - } - }, (err: Object): void => { - let br = err as BusinessError; - reject(br); - }); - }); - return promise; - } pinchIn(scale: double):Promise { let promise = new Promise((resolve: (value: PromiseLike) => void, reject: (error: Error) => void) => { @@ -1380,19 +1362,6 @@ export class Component { }); return promise; } - - mouseScroll(p: Point, down: boolean, d:int, key1?: int, key2?: int): Promise { - let promise = new Promise((resolve: (value: PromiseLike) => void, reject: (error: Error) => void) => { - let promise1 = taskpool.execute(():boolean => this.mouseScrollSync(p, down, d, key1, key2, 20)); - promise1.then((e:NullishType)=>{ - resolve(Promise.resolve()); - }, (err: Error): void => { - let br = err as BusinessError; - reject(br); - }); - }); - return promise; - } mouseScroll(p: Point, down: boolean, d:int, key1?: int, key2?: int, speed?: int): Promise { let promise = new Promise((resolve: (value: PromiseLike) => void, reject: (error: Error) => void) => { @@ -1592,8 +1561,8 @@ export class UIEventObserver { this.nativeUIEventObserver = UIEventObserver; } } - native once(type: String, callback: Callback): void; - + native onceToastShow(callback: Callback): void; + native onceDialogShow(callback: Callback): void; } export const ON: On = new On(); \ No newline at end of file diff --git a/uitest/ets/ani/src/uitest_ani.cpp b/uitest/ets/ani/src/uitest_ani.cpp index be37141a..70399478 100644 --- a/uitest/ets/ani/src/uitest_ani.cpp +++ b/uitest/ets/ani/src/uitest_ani.cpp @@ -668,11 +668,10 @@ static ani_boolean BindOn(ani_env *env) HiLog::Error(LABEL, "%{public}s Not found className !!!", __func__); return false; } - static constexpr const char *SIGNATURE = "C{std.core.String}E{@ohos.UiTest.MatchPattern}:C{@ohos.UiTest.On}"; std::array methods = { - ani_native_function{"id", SIGNATURE, reinterpret_cast(id)}, + ani_native_function{"id", nullptr, reinterpret_cast(id)}, ani_native_function{"text", nullptr, reinterpret_cast(text)}, - ani_native_function{"type", SIGNATURE, reinterpret_cast(type)}, + ani_native_function{"type", nullptr, reinterpret_cast(type)}, ani_native_function{"hint", nullptr, reinterpret_cast(hint)}, ani_native_function{"description", nullptr, reinterpret_cast(description)}, ani_native_function{"inWindow", nullptr, reinterpret_cast(inWindow)}, @@ -1605,8 +1604,7 @@ static ani_boolean BindDriver(ani_env *env) ani_native_function{"penSwipeSync", nullptr, reinterpret_cast(penSwipeSync)}, ani_native_function{"penClickSync", nullptr, reinterpret_cast(penClickSync)}, ani_native_function{"penDoubleClickSync", nullptr, reinterpret_cast(penDoubleClickSync)}, - ani_native_function{"penLongClickSync", - "C{@ohos.UiTest.Point}C{std.core.Double}:z", reinterpret_cast(penLongClickSync)}, + ani_native_function{"penLongClickSync", "L@ohos/UiTest/Point;Lstd/core/Double;:Z", reinterpret_cast(penLongClickSync)}, ani_native_function{"mouseScrollSync", nullptr, reinterpret_cast(mouseScrollSync)}, ani_native_function{"mouseMoveWithTrackSync", nullptr, reinterpret_cast(mouseMoveWithTrackSync)}, ani_native_function{"mouseMoveToSync", nullptr, reinterpret_cast(mouseMoveToSync)}, @@ -1623,7 +1621,7 @@ static ani_boolean BindDriver(ani_env *env) HiLog::Error(LABEL, "%{public}s Cannot bind native methods to !!!", __func__); return false; } - ani_native_function createMethod {"create", ":C{@ohos.UiTest.Driver}", reinterpret_cast(create)}; + ani_native_function createMethod {"create", ":L@ohos/UiTest/Driver;", reinterpret_cast(create)}; if (ANI_OK != env->Class_BindStaticNativeMethods(cls, &createMethod, 1)) { HiLog::Error(LABEL, "%{public}s Cannot bind static native methods to !!!", __func__); return false; @@ -2135,17 +2133,29 @@ static ani_boolean BindComponent(ani_env *env) } return true; } -static void once(ani_env *env, ani_object obj, ani_string type, ani_object callback) +static void once(ani_env *env, ani_object obj, string type, ani_object callback) { ApiCallInfo callInfo_; ApiReplyInfo reply_; callInfo_.callerObjRef_ = aniStringToStdString(env, unwrapp(env, obj, "nativeUIEventObserver")); callInfo_.apiId_ = "UIEventObserver.once"; - callInfo_.paramList_.push_back(aniStringToStdString(env, type)); + callInfo_.paramList_.push_back(type); UiEventObserverAni::Get().PreprocessCallOnce(env, callInfo_, obj, callback, reply_); Transact(callInfo_, reply_); UnmarshalReply(env, callInfo_, reply_); } +static void onceToastShow(ani_env *env, ani_object obj, ani_object callback) +{ + nlohmann::json paramList_ = nlohmann::json::array(); + paramList_.push_back("toastShow"); + once(env, obj, paramList_, callback); +} +static void onceDialogShow(ani_env *env, ani_object obj, ani_object callback) +{ + nlohmann::json paramList_ = nlohmann::json::array(); + paramList_.push_back("dialogShow"); + once(env, obj, paramList_, callback); +} static ani_boolean BindUiEventObserver(ani_env *env) { ani_class cls; @@ -2154,7 +2164,8 @@ static ani_boolean BindUiEventObserver(ani_env *env) return false; } std::array methods = { - ani_native_function{"once", nullptr, reinterpret_cast(once)}, + ani_native_function{"onceToastShow", nullptr, reinterpret_cast(onceToastShow)}, + ani_native_function{"onceDialogShow", nullptr, reinterpret_cast(onceDialogShow)}, }; if (ANI_OK != env->Class_BindNativeMethods(cls, methods.data(), methods.size())) { -- Gitee From 53e63825cea745500a108b4d912742eef93bea61 Mon Sep 17 00:00:00 2001 From: chen8281 Date: Fri, 12 Sep 2025 10:22:44 +0800 Subject: [PATCH 2/3] uitest Signed-off-by: chen8281 --- uitest/ets/ani/src/uitest_ani.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/uitest/ets/ani/src/uitest_ani.cpp b/uitest/ets/ani/src/uitest_ani.cpp index 70399478..109f4b6e 100644 --- a/uitest/ets/ani/src/uitest_ani.cpp +++ b/uitest/ets/ani/src/uitest_ani.cpp @@ -668,10 +668,12 @@ static ani_boolean BindOn(ani_env *env) HiLog::Error(LABEL, "%{public}s Not found className !!!", __func__); return false; } + static constexpr const char *SIGNATURE = "C{std.core.String}E{@ohos.UiTest.MatchPattern}:C{@ohos.UiTest.On}"; + std::array methods = { - ani_native_function{"id", nullptr, reinterpret_cast(id)}, + ani_native_function{"id", SIGNATURE, reinterpret_cast(id)}, ani_native_function{"text", nullptr, reinterpret_cast(text)}, - ani_native_function{"type", nullptr, reinterpret_cast(type)}, + ani_native_function{"type", SIGNATURE, reinterpret_cast(type)}, ani_native_function{"hint", nullptr, reinterpret_cast(hint)}, ani_native_function{"description", nullptr, reinterpret_cast(description)}, ani_native_function{"inWindow", nullptr, reinterpret_cast(inWindow)}, @@ -1604,8 +1606,7 @@ static ani_boolean BindDriver(ani_env *env) ani_native_function{"penSwipeSync", nullptr, reinterpret_cast(penSwipeSync)}, ani_native_function{"penClickSync", nullptr, reinterpret_cast(penClickSync)}, ani_native_function{"penDoubleClickSync", nullptr, reinterpret_cast(penDoubleClickSync)}, - ani_native_function{"penLongClickSync", "L@ohos/UiTest/Point;Lstd/core/Double;:Z", reinterpret_cast(penLongClickSync)}, - ani_native_function{"mouseScrollSync", nullptr, reinterpret_cast(mouseScrollSync)}, + ani_native_function{"penLongClickSync", "C{@ohos.UiTest.Point}C{std.core.Double}:z", reinterpret_cast(penLongClickSync)}, ani_native_function{"mouseScrollSync", nullptr, reinterpret_cast(mouseScrollSync)}, ani_native_function{"mouseMoveWithTrackSync", nullptr, reinterpret_cast(mouseMoveWithTrackSync)}, ani_native_function{"mouseMoveToSync", nullptr, reinterpret_cast(mouseMoveToSync)}, ani_native_function{"mouseDragSync", nullptr, reinterpret_cast(mouseDragSync)}, @@ -1621,7 +1622,7 @@ static ani_boolean BindDriver(ani_env *env) HiLog::Error(LABEL, "%{public}s Cannot bind native methods to !!!", __func__); return false; } - ani_native_function createMethod {"create", ":L@ohos/UiTest/Driver;", reinterpret_cast(create)}; + ani_native_function createMethod {"create", ":C{@ohos.UiTest.Driver}", reinterpret_cast(create)}; if (ANI_OK != env->Class_BindStaticNativeMethods(cls, &createMethod, 1)) { HiLog::Error(LABEL, "%{public}s Cannot bind static native methods to !!!", __func__); return false; -- Gitee From 2a16568fa4f433f653fe7e786082516faac1b427 Mon Sep 17 00:00:00 2001 From: chen8281 Date: Fri, 12 Sep 2025 11:49:32 +0800 Subject: [PATCH 3/3] bugfix Signed-off-by: chen8281 --- uitest/ets/ani/src/uitest_ani.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uitest/ets/ani/src/uitest_ani.cpp b/uitest/ets/ani/src/uitest_ani.cpp index 109f4b6e..71383aa6 100644 --- a/uitest/ets/ani/src/uitest_ani.cpp +++ b/uitest/ets/ani/src/uitest_ani.cpp @@ -2134,13 +2134,13 @@ static ani_boolean BindComponent(ani_env *env) } return true; } -static void once(ani_env *env, ani_object obj, string type, ani_object callback) +static void once(ani_env *env, ani_object obj, nlohmann::json paramList, ani_object callback) { ApiCallInfo callInfo_; ApiReplyInfo reply_; callInfo_.callerObjRef_ = aniStringToStdString(env, unwrapp(env, obj, "nativeUIEventObserver")); callInfo_.apiId_ = "UIEventObserver.once"; - callInfo_.paramList_.push_back(type); + callInfo_.paramList_ = paramList; UiEventObserverAni::Get().PreprocessCallOnce(env, callInfo_, obj, callback, reply_); Transact(callInfo_, reply_); UnmarshalReply(env, callInfo_, reply_); -- Gitee