提交 074a8805 编写于 作者: X xinking129

add format

Signed-off-by: Nxinking129 <xinxin13@huawei.com>
上级 dadc99bd
/*
* 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.
*/
import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
import commonEvent from '@ohos.commonEvent';
let commonStateArr: number[] = [-1,-1,-1,-1]
let commonEventData={
parameters:{
let commonStateArr: number[] = [-1, -1, -1, -1]
let commonEventData = {
parameters: {
commonStateArr: commonStateArr
}
}
......@@ -12,19 +26,19 @@ let onForeGroundTAG = -1
let TAG = 'StateChangeTestTAG'
let ApplicationStateChangeCallbackFir = {
onApplicationForeground() {
console.log(TAG,'ApplicationStateChangeCallbackFir onApplicationForeground')
console.log(TAG, 'ApplicationStateChangeCallbackFir onApplicationForeground')
commonEventData.parameters.commonStateArr[0] = 1
setTimeout(() => {
console.info('Enter onApplicationForeground publish!')
commonEvent.publish('processState',commonEventData, (err) => {
commonEvent.publish('processState', commonEventData, (err) => {
console.info("====>processState publish err: " + JSON.stringify(err))
})
},1000)
}, 1000)
},
onApplicationBackground() {
console.log(TAG,'ApplicationStateChangeCallbackFir onApplicationBackground')
console.log(TAG, 'ApplicationStateChangeCallbackFir onApplicationBackground')
commonEventData.parameters.commonStateArr[1] = 1
if (globalThis.want.action == 'NeedBackGroundOff' || globalThis.want.action == 'MultiAppRegister'
......@@ -37,22 +51,22 @@ let ApplicationStateChangeCallbackFir = {
let ApplicationStateChangeCallbackSec = {
onApplicationForeground() {
console.log(TAG,'ApplicationStateChangeCallbackSec onApplicationForeground')
console.log(TAG, 'ApplicationStateChangeCallbackSec onApplicationForeground')
commonEventData.parameters.commonStateArr[2] = 1
},
onApplicationBackground() {
console.log(TAG,'ApplicationStateChangeCallbackSec onApplicationBackground')
console.log(TAG, 'ApplicationStateChangeCallbackSec onApplicationBackground')
commonEventData.parameters.commonStateArr[3] = 1
if (globalThis.want.action == 'doubleNeedBackGroundOff') {
setTimeout(() => {
globalThis.applicationContext.off('applicationStateChange',ApplicationStateChangeCallbackSec)
},500)
globalThis.applicationContext.off('applicationStateChange', ApplicationStateChangeCallbackSec)
}, 500)
}
else if(globalThis.want.action == 'DoubleRegisterOff') {
else if (globalThis.want.action == 'DoubleRegisterOff') {
setTimeout(() => {
console.info('entered DoubleRegisterOff')
globalThis.applicationContext.off('applicationStateChange')
},500)
}, 500)
}
}
}
......@@ -77,7 +91,7 @@ export default class EntryAbility extends Ability {
if (globalThis.want.action == 'doubleRegister' || globalThis.want.action == 'doubleNeedBackGroundOff'
|| globalThis.want.action == 'DoubleRegisterOff') {
console.info("double in action is logic entered!")
globalThis.applicationContext.on('applicationStateChange', ApplicationStateChangeCallbackSec)
globalThis.applicationContext.on('applicationStateChange', ApplicationStateChangeCallbackSec)
}
}
......@@ -114,13 +128,13 @@ export default class EntryAbility extends Ability {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Abilityone onForeground');
onForeGroundTAG += 1
if(onForeGroundTAG == 1 && (globalThis.want.action == 'NeedBackGroundOff' || globalThis.want.action == 'MultiAppRegister'
|| globalThis.want.action == 'DoubleRegisterOff')) {
if (onForeGroundTAG == 1 && (globalThis.want.action == 'NeedBackGroundOff' || globalThis.want.action == 'MultiAppRegister'
|| globalThis.want.action == 'DoubleRegisterOff')) {
setTimeout(() => {
commonEvent.publish('processState',commonEventData, (err) => {
commonEvent.publish('processState', commonEventData, (err) => {
console.info("====>processState publish err: " + JSON.stringify(err))
})
},2000)
}, 2000)
}
}
......
/*
* 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.
*/
@Entry
@Component
struct Index {
......
/*
* 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.
*/
import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
......@@ -7,23 +21,23 @@ import commonEvent from '@ohos.commonEvent'
let TAG = 'getRunningProcess'
let commonStateArr
let commonEventData = {
parameters:{
parameters: {
commonStateArr: commonStateArr
}
}
let ApplicationStateChangeCallbackFir = {
onApplicationForeground() {
console.log(TAG,'ApplicationStateChangeCallbackFir onApplicationForeground')
console.log(TAG, 'ApplicationStateChangeCallbackFir onApplicationForeground')
},
onApplicationBackground() {
console.log(TAG,'ApplicationStateChangeCallbackFir onApplicationBackground')
console.log(TAG, 'ApplicationStateChangeCallbackFir onApplicationBackground')
setTimeout(() => {
console.info('Enter onApplicationForeground publish!')
commonEventData.parameters.commonStateArr = 1
commonEvent.publish('processState',commonEventData, (err) => {
commonEvent.publish('processState', commonEventData, (err) => {
console.info("====>processState publish err: " + JSON.stringify(err))
})
},1000)
}, 1000)
}
}
let ForegroundTAG = -1
......@@ -72,12 +86,12 @@ export default class EntryAbility extends Ability {
onForeground() {
// Ability has brought to foreground
ForegroundTAG++
if(ForegroundTAG == 1) {
if (ForegroundTAG == 1) {
setTimeout(() => {
commonEvent.publish('processState',commonEventData, (err) => {
commonEvent.publish('processState', commonEventData, (err) => {
console.info("====>processState publish err: " + JSON.stringify(err))
})
},3000)
}, 3000)
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
......
/*
* 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.
*/
import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
......@@ -48,7 +62,7 @@ export default class EntryAbility1 extends Ability {
globalThis.abilityContext2.terminateSelf((err) => {
console.log('terminateSelf result:' + JSON.stringify(err));
})
},3000)
}, 3000)
}
onBackground() {
......
/*
* 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.
*/
@Entry
@Component
struct Index {
......
/*
* 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.
*/
@Entry
@Component
struct Index1 {
......
/*
* 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.
*/
import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
......@@ -6,11 +20,11 @@ let TAG = 'StateChangeTestTAG'
let ApplicationStateChangeCallbackSec = {
onApplicationForeground() {
console.info('==== ApplicationStateChange Foreground ====');
console.log(TAG,'App2 ApplicationStateChangeCallbackSec onApplicationForeground')
console.log(TAG, 'App2 ApplicationStateChangeCallbackSec onApplicationForeground')
},
onApplicationBackground() {
console.info('==== ApplicationStateChange Background ====');
console.log(TAG,'App2 ApplicationStateChangeCallbackSec onApplicationBackground')
console.log(TAG, 'App2 ApplicationStateChangeCallbackSec onApplicationBackground')
}
}
export default class EntryAbility extends Ability {
......@@ -63,7 +77,7 @@ export default class EntryAbility extends Ability {
globalThis.abilityContext.terminateSelf((err) => {
console.log('terminateSelf result:' + JSON.stringify(err));
})
},3000)
}, 3000)
}
onBackground() {
......
/*
* 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.
*/
@Entry
@Component
struct Index {
......
/*
* 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.
*/
import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
......@@ -6,9 +20,9 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant'
let sequence = 0;
let TAG = 'GetRunningProcessInformation'
let commonStateArr: number[] = [-1,-1,-1,-1]
let commonEventData={
parameters:{
let commonStateArr: number[] = [-1, -1, -1, -1]
let commonEventData = {
parameters: {
commonStateArr: commonStateArr
}
}
......@@ -22,7 +36,7 @@ globalThis.StartFloatingAbility = () => {
windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FLOATING,
};
globalThis.abilityContext.startAbility(want, options, (error) => {
console.log(TAG,"start floating ability error.code = " + error.code)
console.log(TAG, "start floating ability error.code = " + error.code)
})
}
......@@ -38,12 +52,12 @@ globalThis.StartNormalAbility = () => {
}
globalThis.GetRunningProcessInfoCallback = () => {
globalThis.applicationContext.getRunningProcessInformation((err,data) => {
globalThis.applicationContext.getRunningProcessInformation((err, data) => {
if (err) {
console.log(TAG,`getRunningProcessInformation err: ` + JSON.stringify(err));
console.log(TAG, `getRunningProcessInformation err: ` + JSON.stringify(err));
}
else {
console.log(TAG,'Oncreate Callback State: ' + JSON.stringify(data[0].state));
console.log(TAG, 'Oncreate Callback State: ' + JSON.stringify(data[0].state));
commonStateArr[sequence++] = data[0].state
}
})
......@@ -51,15 +65,15 @@ globalThis.GetRunningProcessInfoCallback = () => {
globalThis.GetRunningProcessInfoPromise = () => {
globalThis.applicationContext.getRunningProcessInformation().then((data) => {
console.log(TAG,'Oncreate Promise State: ' + JSON.stringify(data[0].state));
console.log(TAG, 'Oncreate Promise State: ' + JSON.stringify(data[0].state));
commonStateArr[sequence++] = data[0].state
}).catch((err) => {
console.log(TAG,`getRunningProcessInformation err: ` + JSON.stringify(err));
console.log(TAG, `getRunningProcessInformation err: ` + JSON.stringify(err));
});
}
globalThis.PublishStateArray = () => {
commonEvent.publish('processState',commonEventData, (err) => {
commonEvent.publish('processState', commonEventData, (err) => {
console.info("====>processState publish err: " + JSON.stringify(err))
})
}
......
/*
* 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.
*/
@Entry
@Component
struct Index {
......
/*
* 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.
*/
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
......
/*
* 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.
*/
import hilog from '@ohos.hilog'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { Component, Driver, UiWindow, ON, UiDriver } from '@ohos.UiTest'
......
/*
* 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.
*/
import abilityTest from './Ability.test'
export default function testsuite() {
......
/*
* 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.
*/
import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
......
/*
* 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.
*/
import hilog from '@ohos.hilog';
@Entry
......
/*
* 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.
*/
import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
......
/*
* 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.
*/
@Entry
@Component
struct Index {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册