提交 541981e1 编写于 作者: Z zhangxiao150

修改由状态变量机制变化导致的Search fail的xts

Signed-off-by: Nzhangxiao150 <zhangxiao150@huawei.com>
Change-Id: Ia142b00c8b9e8f61fd133a7256a01e80078d0e4e
上级 e6018159
......@@ -18,6 +18,7 @@ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry
import { Hypium } from '@ohos/hypium';
import hilog from '@ohos.hilog';
import testsuite from '../../test/List.test'
import {MessageManager,Callback} from '../../test/MessageManager.ets';
@Entry
@Component
......@@ -103,6 +104,47 @@ struct SliderExample {
this.textColorResource = eventData.data.textColorResource;
}
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('search onPageShow')
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value)
if (message.name == 'caretWidthResource') {
this.caretWidthResource = message.value
}
if (message.name == 'caretColorResource') {
this.caretColorResource = message.value
}
if (message.name == 'leftSearchIconColorResource') {
this.leftSearchIconColorResource = message.value
}
if (message.name == 'searchSrcPathResource') {
this.searchSrcPathResource = message.value
}
if (message.name == 'rightCancelIconColorResource') {
this.rightCancelIconColorResource = message.value
}
if (message.name == 'rightIconSrcPathResource') {
this.rightIconSrcPathResource = message.value
}
if (message.name == 'searchButtonFontSizeResource') {
this.searchButtonFontSizeResource = message.value
}
if (message.name == 'searchButtonFontColorResource') {
this.searchButtonFontColorResource = message.value
}
if (message.name == 'textColorResource') {
this.textColorResource = message.value
}
}
this.messageManager.registerCallback(callback)
}
aboutToAppear(){
var stateChangeEvent = {
eventId: 183,
......
/**
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface Callback {
(message:any):void
}
export class MessageManager {
callback:Callback
callbacks:Map<string,Callback> = new Map()
constructor() {
}
registerCallback(callback:Callback , type?:string) {
if (type == undefined) {
console.error('registerCallback callback set')
this.callback = callback
return
}
this.callbacks.set(type,callback)
}
notify(message:any, type?:string) {
if (type == undefined) {
this.callback(message)
return
}
let tmpCallback:Callback = this.callbacks.get(type)
if (tmpCallback === undefined) {
console.error('callbacks has no callback for type ' + type)
return
}
tmpCallback(message)
}
clear() {
this.callbacks.clear()
this.callback = null
}
}
......@@ -16,6 +16,7 @@
import { describe, beforeEach, afterEach, it, expect } from '@ohos/hypium'
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import {MessageManager,Callback} from './MessageManager';
let emitKey = "emitUserAgent";
export default function search() {
......@@ -298,21 +299,7 @@ export default function search() {
console.info("[ArkUI_Stage_Search_CaretStyle_0600]: " + JSON.stringify(newJson));
let caretWidthResource = $r('sys.float.ohos_id_text_margin_vertical');
try {
var eventData = {
data: {
"caretWidthResource": caretWidthResource
}
}
var innerEvent = {
eventId: 183,
priority: events_emitter.EventPriority.LOW
}
console.info("[ArkUI_Stage_Search_CaretStyle_0600] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[ArkUI_Stage_Search_CaretStyle_0600] change component data error: " + err.message);
}
globalThis.value.message.notify({name:'caretWidthResource',value:caretWidthResource});
await Utils.sleep(2000);
let strJson = getInspectorByKey('searchTestResource');
......@@ -660,21 +647,7 @@ export default function search() {
console.info("[ArkUI_Stage_Search_CaretStyle_1600]: " + JSON.stringify(newJson));
let caretColorResource = $r('sys.color.ohos_id_color_connected');
try {
var eventData = {
data: {
"caretColorResource": caretColorResource
}
}
var innerEvent = {
eventId: 183,
priority: events_emitter.EventPriority.LOW
}
console.info("[ArkUI_Stage_Search_CaretStyle_1600] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[ArkUI_Stage_Search_CaretStyle_1600] change component data error: " + err.message);
}
globalThis.value.message.notify({name:'caretColorResource',value:caretColorResource});
await Utils.sleep(2000);
let strJson = getInspectorByKey('searchTestResource');
......@@ -1456,21 +1429,7 @@ export default function search() {
console.info("[ArkUI_Stage_Search_SearchIcon_1700]: " + JSON.stringify(newJson));
let leftSearchIconColorResource = $r('sys.color.ohos_id_color_connected');
try {
var eventData = {
data: {
"leftSearchIconColorResource": leftSearchIconColorResource
}
}
var innerEvent = {
eventId: 183,
priority: events_emitter.EventPriority.LOW
}
console.info("[ArkUI_Stage_Search_SearchIcon_1700] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[ArkUI_Stage_Search_SearchIcon_1700] change component data error: " + err.message);
}
globalThis.value.message.notify({name:'leftSearchIconColorResource',value:leftSearchIconColorResource});
await Utils.sleep(2000);
let strJson = getInspectorByKey('searchTestResource');
......@@ -1794,21 +1753,7 @@ export default function search() {
console.info("[ArkUI_Stage_Search_SearchIcon_2600]: " + JSON.stringify(newJson));
let searchSrcPathResource = $r('sys.media.ohos_app_icon');
try {
var eventData = {
data: {
"searchSrcPathResource": searchSrcPathResource
}
}
var innerEvent = {
eventId: 183,
priority: events_emitter.EventPriority.LOW
}
console.info("[ArkUI_Stage_Search_SearchIcon_2600] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[ArkUI_Stage_Search_SearchIcon_2600] change component data error: " + err.message);
}
globalThis.value.message.notify({name:'searchSrcPathResource',value:searchSrcPathResource});
await Utils.sleep(2000);
let strJson = getInspectorByKey('searchTestResource');
......@@ -2746,21 +2691,7 @@ export default function search() {
console.info("[ArkUI_Stage_Search_CancelButton_2200]: " + JSON.stringify(newJson));
let rightCancelIconColorResource = $r('sys.color.ohos_id_color_connected');
try {
var eventData = {
data: {
"rightCancelIconColorResource": rightCancelIconColorResource
}
}
var innerEvent = {
eventId: 183,
priority: events_emitter.EventPriority.LOW
}
console.info("[ArkUI_Stage_Search_CancelButton_2200] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[ArkUI_Stage_Search_CancelButton_2200] change component data error: " + err.message);
}
globalThis.value.message.notify({name:'rightCancelIconColorResource',value:rightCancelIconColorResource});
await Utils.sleep(2000);
let strJson = getInspectorByKey('searchTestResource');
......@@ -3084,21 +3015,7 @@ export default function search() {
console.info("[ArkUI_Stage_Search_CancelButton_3100]: " + JSON.stringify(newJson));
let rightIconSrcPathResource = $r('sys.media.ohos_app_icon');
try {
var eventData = {
data: {
"rightIconSrcPathResource": rightIconSrcPathResource
}
}
var innerEvent = {
eventId: 183,
priority: events_emitter.EventPriority.LOW
}
console.info("[ArkUI_Stage_Search_CancelButton_3100] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[ArkUI_Stage_Search_CancelButton_3100] change component data error: " + err.message);
}
globalThis.value.message.notify({name:'rightIconSrcPathResource',value:rightIconSrcPathResource});
await Utils.sleep(2000);
let strJson = getInspectorByKey('searchTestResource');
......@@ -3484,21 +3401,7 @@ export default function search() {
console.info("[ArkUI_Stage_Search_SearchButton_0700]: " + JSON.stringify(newJson));
let searchButtonFontSizeResource = $r('sys.float.ohos_id_text_paragraph_margin_m');
try {
var eventData = {
data: {
"searchButtonFontSizeResource": searchButtonFontSizeResource
}
}
var innerEvent = {
eventId: 183,
priority: events_emitter.EventPriority.LOW
}
console.info("[ArkUI_Stage_Search_SearchButton_0700] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[ArkUI_Stage_Search_SearchButton_0700] change component data error: " + err.message);
}
globalThis.value.message.notify({name:'searchButtonFontSizeResource',value:searchButtonFontSizeResource});
await Utils.sleep(5000);
let strJson = getInspectorByKey('searchTestResource');
......@@ -3846,21 +3749,7 @@ export default function search() {
console.info("[ArkUI_Stage_Search_SearchButton_1700]: " + JSON.stringify(newJson));
let searchButtonFontColorResource = $r('sys.color.ohos_id_color_connected');
try {
var eventData = {
data: {
"searchButtonFontColorResource": searchButtonFontColorResource
}
}
var innerEvent = {
eventId: 183,
priority: events_emitter.EventPriority.LOW
}
console.info("[ArkUI_Stage_Search_SearchButton_1700] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[ArkUI_Stage_Search_SearchButton_1700] change component data error: " + err.message);
}
globalThis.value.message.notify({name:'searchButtonFontColorResource',value:searchButtonFontColorResource});
await Utils.sleep(2000);
let strJson = getInspectorByKey('searchTestResource');
......@@ -4180,21 +4069,7 @@ export default function search() {
console.info("[ArkUI_Stage_Search_FontColor_0500]: " + JSON.stringify(newJson));
let textColorResource = $r('sys.color.ohos_id_color_connected');
try {
var eventData = {
data: {
"textColorResource": textColorResource
}
}
var innerEvent = {
eventId: 183,
priority: events_emitter.EventPriority.LOW
}
console.info("[ArkUI_Stage_Search_FontColor_0500] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[ArkUI_Stage_Search_FontColor_0500] change component data error: " + err.message);
}
globalThis.value.message.notify({name:'textColorResource',value:textColorResource});
await Utils.sleep(2000);
let strJson = getInspectorByKey('searchTestResource');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册