mirror of
https://gitee.com/openharmony/xts_tools
synced 2024-11-27 10:00:40 +00:00
!237 新建UI自动化对比工具代码仓
Merge pull request !237 from zhangshuang-xiaohuihui/master
This commit is contained in:
commit
a6fa62dd50
25
UIcompare/component/code/demo/AppScope/app.json5
Normal file
25
UIcompare/component/code/demo/AppScope/app.json5
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.example.component",
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
"icon": "$media:app_icon",
|
||||
"label": "$string:app_name",
|
||||
"distributedNotificationEnabled": true
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "app_name",
|
||||
"value": "component"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
41
UIcompare/component/code/demo/build-profile.json5
Normal file
41
UIcompare/component/code/demo/build-profile.json5
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"app": {
|
||||
"signingConfigs": [],
|
||||
"compileSdkVersion": 9,
|
||||
"compatibleSdkVersion": 9,
|
||||
"products": [
|
||||
{
|
||||
"name": "default",
|
||||
"signingConfig": "default",
|
||||
}
|
||||
]
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"name": "entry",
|
||||
"srcPath": "./entry",
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
"applyToProducts": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
27
UIcompare/component/code/demo/entry/build-profile.json5
Normal file
27
UIcompare/component/code/demo/entry/build-profile.json5
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"apiType": 'stageMode',
|
||||
"buildOption": {
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"name": "ohosTest",
|
||||
}
|
||||
]
|
||||
}
|
16
UIcompare/component/code/demo/entry/hvigorfile.ts
Normal file
16
UIcompare/component/code/demo/entry/hvigorfile.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
||||
export { hapTasks } from '@ohos/hvigor-ohos-plugin';
|
5
UIcompare/component/code/demo/entry/package-lock.json
generated
Normal file
5
UIcompare/component/code/demo/entry/package-lock.json
generated
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "entry",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1
|
||||
}
|
13
UIcompare/component/code/demo/entry/package.json
Normal file
13
UIcompare/component/code/demo/entry/package.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "entry",
|
||||
"version": "1.0.0",
|
||||
"ohos": {
|
||||
"org": "UICompare",
|
||||
"buildTool": "hvigor",
|
||||
"directoryLevel": "module"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"license": "ISC",
|
||||
"dependencies": {}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import hilog from '@ohos.hilog';
|
||||
import window from '@ohos.window';
|
||||
|
||||
export default class EntryAbility extends UIAbility {
|
||||
onCreate(want, launchParam) {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage) {
|
||||
// Main window is created, set main page for this ability
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
||||
|
||||
windowStage.loadContent('pages/Index', (err, data) => {
|
||||
if (err.code) {
|
||||
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
||||
return;
|
||||
}
|
||||
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
|
||||
});
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
// Main window is destroyed, release UI related resources
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
// Ability has brought to foreground
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
// Ability has back to background
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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 {
|
||||
@State message: string = 'Hello World'
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
Text(this.message)
|
||||
.fontSize(50)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
.height('100%')
|
||||
}
|
||||
}
|
51
UIcompare/component/code/demo/entry/src/main/module.json5
Normal file
51
UIcompare/component/code/demo/entry/src/main/module.json5
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"module": {
|
||||
"name": "entry",
|
||||
"type": "entry",
|
||||
"description": "$string:module_desc",
|
||||
"mainElement": "EntryAbility",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": false,
|
||||
"pages": "$profile:main_pages",
|
||||
"abilities": [
|
||||
{
|
||||
"name": "EntryAbility",
|
||||
"srcEntrance": "./ets/entryability/EntryAbility.ts",
|
||||
"description": "$string:EntryAbility_desc",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:EntryAbility_label",
|
||||
"startWindowIcon": "$media:icon",
|
||||
"startWindowBackground": "$color:start_window_background",
|
||||
"visible": true,
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "start_window_background",
|
||||
"value": "#FFFFFF"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "module description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "label"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"src": [
|
||||
"pages/Index"
|
||||
]
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "module description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "label"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "模块描述"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "label"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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'
|
||||
|
||||
export default function abilityTest() {
|
||||
describe('ActsAbilityTest', function () {
|
||||
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
|
||||
beforeAll(function () {
|
||||
// Presets an action, which is performed only once before all test cases of the test suite start.
|
||||
// This API supports only one parameter: preset action function.
|
||||
})
|
||||
beforeEach(function () {
|
||||
// Presets an action, which is performed before each unit test case starts.
|
||||
// The number of execution times is the same as the number of test cases defined by **it**.
|
||||
// This API supports only one parameter: preset action function.
|
||||
})
|
||||
afterEach(function () {
|
||||
// Presets a clear action, which is performed after each unit test case ends.
|
||||
// The number of execution times is the same as the number of test cases defined by **it**.
|
||||
// This API supports only one parameter: clear action function.
|
||||
})
|
||||
afterAll(function () {
|
||||
// Presets a clear action, which is performed after all test cases of the test suite end.
|
||||
// This API supports only one parameter: clear action function.
|
||||
})
|
||||
it('assertContain',0, function () {
|
||||
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
|
||||
let a = 'abc'
|
||||
let b = 'b'
|
||||
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
|
||||
expect(a).assertContain(b)
|
||||
expect(a).assertEqual(a)
|
||||
})
|
||||
})
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
|
||||
import Settings from './model/Settings'
|
||||
import windowSnap from './model/snapShot'
|
||||
import Logger from './model/Logger'
|
||||
import {
|
||||
UiComponent,
|
||||
UiDriver,
|
||||
Component,
|
||||
Driver,
|
||||
UiWindow,
|
||||
ON,
|
||||
BY,
|
||||
MatchPattern,
|
||||
DisplayRotation,
|
||||
ResizeDirection,
|
||||
WindowMode,
|
||||
PointerMatrix
|
||||
} from '@ohos.UiTest';
|
||||
|
||||
/*
|
||||
* demoTest_001:更改page路由
|
||||
* demoTest_002:更改page路由,像素密度
|
||||
* demoTest_003:更改page路由,窗口大小,位置,像素密度
|
||||
* demoTest_004:更改page路由,页面内元素属性
|
||||
* demoTest_005:更改page路由,注入点击事件
|
||||
*
|
||||
* demoTest_004:更改属性需要配合页面路由配置globalThis.value.message
|
||||
* demoTest_005:注入事件,引用'@ohos.UiTest',findComponent需要根据页面路由内组件配置情况更改
|
||||
*
|
||||
* Settings.createWindow(config.url):
|
||||
* 创建窗口,更改窗口基本配置,更改方式详见model/Settings createWindow方法
|
||||
*
|
||||
* windowSnap.snapShot(globalThis.context):
|
||||
* 窗口截屏&图片文件保存,存储在设备端
|
||||
* 存储文件固定,单挑用例执行后覆盖,用于自动化UI对比
|
||||
* 支持调试更改文件名为时间戳格式,更改model/snapShot createAndGetFile方法 注释L35,放开L32,L33
|
||||
*
|
||||
* Logger日志使用方法:
|
||||
* import Logger form './model/Logger'
|
||||
* Logger.info(TAG,`config = ${config}, err = ${JSON.stringify(exception)}`)
|
||||
* */
|
||||
|
||||
|
||||
export default function demoTest() {
|
||||
|
||||
function sleep(time) {
|
||||
return new Promise((resolve) => setTimeout(resolve, time))
|
||||
}
|
||||
|
||||
describe('demoTest', function () {
|
||||
|
||||
afterEach(async function (done) {
|
||||
if (Settings.windowClass == null) {
|
||||
return
|
||||
}
|
||||
|
||||
Settings.windowClass.destroyWindow((err) => {
|
||||
if (err.code) {
|
||||
Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
Logger.info('TEST', `Succeeded in destroy the window.`);
|
||||
})
|
||||
await sleep(1000);
|
||||
done()
|
||||
})
|
||||
|
||||
it('demoTest_001',0,async function (done){
|
||||
//更改page路由
|
||||
let config={
|
||||
uri:"testability/pages/demo",
|
||||
}
|
||||
Settings.createWindow(config.uri)
|
||||
await sleep(1000)
|
||||
windowSnap.snapShot(globalThis.context)
|
||||
await sleep(1000)
|
||||
|
||||
done()
|
||||
})
|
||||
|
||||
it('demoTest_002', 0, async function (done) {
|
||||
// 更改page路由,像素密度
|
||||
let config = {
|
||||
uri: "testability/pages/demo",
|
||||
}
|
||||
Settings.createWindow(config.uri, {
|
||||
dpi: 200
|
||||
})
|
||||
await sleep(1000);
|
||||
windowSnap.snapShot(globalThis.context)
|
||||
await sleep(1000);
|
||||
done();
|
||||
})
|
||||
|
||||
it('demoTest_003', 0, async function (done) {
|
||||
// 更改page路由,窗口大小,位置,像素密度
|
||||
let config = {
|
||||
uri: "testability/pages/Index",
|
||||
}
|
||||
Settings.createWindow(config.uri, {
|
||||
X: 200,
|
||||
Y: 200,
|
||||
width: 200,
|
||||
height: 300,
|
||||
dpi: 100
|
||||
})
|
||||
await sleep(1000);
|
||||
windowSnap.snapShot(globalThis.context)
|
||||
await sleep(1000);
|
||||
done();
|
||||
})
|
||||
|
||||
it('demoTest_004', 0, async function (done) {
|
||||
//更改page路由,页面内元素属性
|
||||
let config = {
|
||||
uri: "testability/pages/demo",
|
||||
}
|
||||
Settings.createWindow(config.uri)
|
||||
await sleep(1000)
|
||||
globalThis.value.message.notify({
|
||||
name: "fontColor", value: Color.Pink
|
||||
})
|
||||
await sleep(1000)
|
||||
windowSnap.snapShot(globalThis.context)
|
||||
await sleep(1000)
|
||||
done()
|
||||
})
|
||||
|
||||
it('demoTest_005', 0, async function (done) {
|
||||
//更改page路由,注入点击事件
|
||||
let config = {
|
||||
uri: "testability/pages/demo",
|
||||
}
|
||||
Settings.createWindow(config.uri)
|
||||
await sleep(1000)
|
||||
let driver = await UiDriver.create()
|
||||
let btn = await driver.findComponent(BY.key('button_demo'))
|
||||
await sleep(1000)
|
||||
await btn.click()
|
||||
windowSnap.snapShot(globalThis.context)
|
||||
await sleep(1000)
|
||||
done()
|
||||
})
|
||||
})
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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 demoTest from './Demo.test'
|
||||
|
||||
export default function testsuite() {
|
||||
demoTest()
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 日期工具
|
||||
*/
|
||||
export default class DateTimeUtil {
|
||||
|
||||
/**
|
||||
* 时分秒
|
||||
*/
|
||||
getTime() {
|
||||
const DATETIME = new Date()
|
||||
return this.concatTime(DATETIME.getHours(), DATETIME.getMinutes(),DATETIME.getSeconds())
|
||||
}
|
||||
|
||||
/**
|
||||
* 年月日
|
||||
*/
|
||||
getDate() {
|
||||
const DATETIME = new Date()
|
||||
return this.concatDate(DATETIME.getFullYear(),DATETIME.getMonth() + 1, DATETIME.getDate())
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期不足两位补充0
|
||||
* @param value-数据值
|
||||
*/
|
||||
fill(value) {
|
||||
return (value > 9 ? '' : '0') + value
|
||||
}
|
||||
|
||||
/**
|
||||
* 年月日格式修饰
|
||||
* @param year
|
||||
* @param month
|
||||
* @param date
|
||||
*/
|
||||
concatDate(year:number,month:number, date:number) {
|
||||
return `${year}${this.fill(month)}${this.fill(date)}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 时分秒格式修饰
|
||||
* @param hours
|
||||
* @param minutes
|
||||
* @param seconds
|
||||
*/
|
||||
concatTime(hours:number, minutes:number,seconds:number) {
|
||||
return `${this.fill(hours)}${this.fill(minutes)}${this.fill(seconds)}`
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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';
|
||||
|
||||
class Logger {
|
||||
private domain: number;
|
||||
private prefix: string;
|
||||
private format: string = "%{public}s, %{public}s";
|
||||
|
||||
constructor(prefix: string) {
|
||||
this.prefix = prefix;
|
||||
this.domain = 0xFF00;
|
||||
}
|
||||
|
||||
debug(...args: any[]) {
|
||||
hilog.debug(this.domain, this.prefix, this.format, args);
|
||||
}
|
||||
|
||||
info(...args: any[]) {
|
||||
hilog.info(this.domain, this.prefix, this.format, args);
|
||||
}
|
||||
|
||||
warn(...args: any[]) {
|
||||
hilog.warn(this.domain, this.prefix, this.format, args);
|
||||
}
|
||||
|
||||
error(...args: any[]) {
|
||||
hilog.error(this.domain, this.prefix, this.format, args);
|
||||
}
|
||||
}
|
||||
|
||||
export default new Logger('[Screenshot]');
|
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
import screen from '@ohos.screen';
|
||||
import window from '@ohos.window';
|
||||
import Logger from './Logger';
|
||||
|
||||
const TAG: string = '[Settings]';
|
||||
|
||||
class Settings {
|
||||
sleep(time) {
|
||||
return new Promise((resolve) => setTimeout(resolve, time));
|
||||
}
|
||||
|
||||
windowClass: window.Window = null
|
||||
|
||||
changeWindowPosition(windowClass, X, Y) {
|
||||
//为悬浮窗设置位置
|
||||
windowClass.moveWindowTo(X, Y, (err) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to move the window. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
changeWindowSize(windowClass, width, height) {
|
||||
//为悬浮窗设置大小
|
||||
windowClass.resize(width, height, (err) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to change the window size. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
loadContent(windowClass, pageURI) {
|
||||
//为悬浮窗加载对应的目标页面
|
||||
windowClass.setUIContent(pageURI, (err) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to load the content. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
Logger.info(TAG, `Succeeded in loading the content.`);
|
||||
|
||||
//显示悬浮窗
|
||||
windowClass.showWindow((err) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to show the window. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
Logger.info(TAG, `Succeeded in showing the window.`);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
changeDpi(dpi) {
|
||||
let screenClass = null;
|
||||
screen.getAllScreens((err, data) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to get all screens. Cause : ${JSON.stringify(err)}`);
|
||||
return;
|
||||
}
|
||||
Logger.info(TAG, `Succeeded in getting all screens. Data:${JSON.stringify(data)}`);
|
||||
|
||||
screenClass = data[0];
|
||||
//设置设备dpi
|
||||
screenClass.setDensityDpi(dpi, (err, data) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to set the pixel density. Code : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
Logger.info(TAG, `Succeeded in setting the pixel density`);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
destroyWindow(windowClass) {
|
||||
//销毁窗口
|
||||
windowClass.destroyWindow((err) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to destroy the window. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
Logger.info(TAG, `Succeeded in destroy the window.`);
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
* 窗口页面更新
|
||||
* Setting.createWindow(pageURI: String, {X,Y,width,height,dpi}?:{X?:number,Y?:number,width?:number,height?:number,dpi?:number}):void
|
||||
* 必填:
|
||||
* pageURI:页面路由
|
||||
* 选填:
|
||||
* X,Y:窗口相对于左上角的位置,默认X=100,Y=100 单位为px
|
||||
* width,height:窗口宽高,默认width=600,height=1250 可配置范围:[0,2560],单位为vp
|
||||
* dpi:像素密度,默认dpi=330,可配置范围:80-640
|
||||
* */
|
||||
|
||||
createWindow(pageURI: String, {X=100,Y=100,width=600,height=1250,dpi=400}={}) {
|
||||
Logger.info(TAG, `params,pageURI=${pageURI},X=${X},Y=${Y},width=${width},height=${height},dpi=${dpi}`)
|
||||
|
||||
this.changeDpi(dpi)
|
||||
this.sleep(1000)
|
||||
let windowClass = null
|
||||
let config = {
|
||||
name: "floatWindow",
|
||||
windowType: window.WindowType.TYPE_FLOAT,
|
||||
ctx: globalThis.context
|
||||
};
|
||||
window.createWindow(config, (err, data) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to create the floatWindow. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
Logger.info(TAG, `Succeeded in creating the floatWindow. Data : ${JSON.stringify(err)}`);
|
||||
windowClass = data;
|
||||
this.windowClass = data;
|
||||
|
||||
this.changeWindowPosition(windowClass, X, Y);
|
||||
this.changeWindowSize(windowClass, width, height);
|
||||
this.loadContent(windowClass, pageURI)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default new Settings()
|
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
/**
|
||||
* 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 default class Utils {
|
||||
static rect_left;
|
||||
static rect_top;
|
||||
static rect_right;
|
||||
static rect_bottom;
|
||||
static rect_value;
|
||||
|
||||
static sleep(time) {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve()
|
||||
}, time)
|
||||
}).then(() => {
|
||||
console.info(`sleep ${time} over...`)
|
||||
})
|
||||
}
|
||||
|
||||
static getComponentRect(key) {
|
||||
let strJson = getInspectorByKey(key);
|
||||
let obj = JSON.parse(strJson);
|
||||
console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
|
||||
let rectInfo = JSON.parse('[' + obj.$rect + ']')
|
||||
console.info("[getInspectorByKey] rectInfo is: " + rectInfo);
|
||||
this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
|
||||
this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
|
||||
this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
|
||||
this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]
|
||||
return this.rect_value = {
|
||||
"left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom
|
||||
}
|
||||
}
|
||||
|
||||
static async swipe(downX, downY, upX, upY, steps) {
|
||||
console.info('start to swipe')
|
||||
this.drags(downX, downY, upX, upY, steps, false)
|
||||
}
|
||||
|
||||
static async drag(downX, downY, upX, upY, steps) {
|
||||
console.info('start to drag')
|
||||
this.drags(downX, downY, upX, upY, steps, true)
|
||||
}
|
||||
|
||||
static async drags(downX, downY, upX, upY, steps, drag) {
|
||||
var xStep;
|
||||
var yStep;
|
||||
var swipeSteps;
|
||||
var ret;
|
||||
xStep = 0;
|
||||
yStep = 0;
|
||||
ret = false;
|
||||
swipeSteps = steps;
|
||||
if (swipeSteps == 0) {
|
||||
swipeSteps = 1;
|
||||
}
|
||||
xStep = (upX - downX) / swipeSteps;
|
||||
yStep = (upY - downY) / swipeSteps;
|
||||
console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep)
|
||||
var downPonit: TouchObject = {
|
||||
id: 1,
|
||||
x: downX,
|
||||
y: downY,
|
||||
type: TouchType.Down,
|
||||
}
|
||||
console.info('down touch started: ' + JSON.stringify(downPonit))
|
||||
sendTouchEvent(downPonit);
|
||||
console.info('start to move')
|
||||
if (drag) {
|
||||
await this.sleep(500)
|
||||
}
|
||||
for (var i = 1;i <= swipeSteps; i++) {
|
||||
var movePoint: TouchObject = {
|
||||
id: 1,
|
||||
x: downX + (xStep * i),
|
||||
y: downY + (yStep * i),
|
||||
type: TouchType.Move
|
||||
}
|
||||
console.info('move touch started: ' + JSON.stringify(movePoint))
|
||||
ret = sendTouchEvent(movePoint)
|
||||
if (ret == false) {
|
||||
break;
|
||||
}
|
||||
await this.sleep(5)
|
||||
}
|
||||
console.info('start to up')
|
||||
if (drag) {
|
||||
await this.sleep(100)
|
||||
}
|
||||
var upPoint: TouchObject = {
|
||||
id: 1,
|
||||
x: upX,
|
||||
y: upY,
|
||||
type: TouchType.Up,
|
||||
}
|
||||
console.info('up touch started: ' + JSON.stringify(upPoint))
|
||||
sendTouchEvent(upPoint)
|
||||
await this.sleep(500)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,135 @@
|
||||
/*
|
||||
* 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.
|
||||
*/s
|
||||
// @ts-nocheck
|
||||
import window from '@ohos.window';
|
||||
import Logger from './Logger';
|
||||
import image from '@ohos.multimedia.image';
|
||||
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
|
||||
import fs from '@ohos.file.fs';
|
||||
import DateTimeUtil from './DateTimeUtil';
|
||||
|
||||
const TAG: string = '[windowSnap]';
|
||||
const INFO = {
|
||||
"img": {
|
||||
prefix: 'IMG_',
|
||||
suffix: '.webp',
|
||||
directory: mediaLibrary.DirectoryType.DIR_IMAGE,
|
||||
mediaType: mediaLibrary.MediaType.IMAGE
|
||||
},
|
||||
"txt": {
|
||||
prefix: 'TXT_',
|
||||
suffix: '.txt',
|
||||
directory: mediaLibrary.DirectoryType.DIR_DOCUMENTS,
|
||||
mediaType: mediaLibrary.MediaType.FILE
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 文件名为时间戳格式:
|
||||
* let dateTimeUtil=new DateTimeUtil()
|
||||
* let name=`${dateTimeUtil.getDate()}_${dateTimeUtil.getTime()}`
|
||||
* 文件名固定,用于自动化UI对比
|
||||
* let name = "test"
|
||||
* */
|
||||
class windowSnap {
|
||||
async createAndGetFile(context: any, type) {
|
||||
Logger.info(TAG, `createAndGetFile start`)
|
||||
let mediaTest = mediaLibrary.getMediaLibrary(context)
|
||||
let info = INFO[type]
|
||||
// 修改文件名
|
||||
let name = "test"
|
||||
let displayName = `${info.prefix}${name}${info.suffix}`
|
||||
let option = {
|
||||
selections: mediaLibrary.FileKey.DISPLAY_NAME + '=?',
|
||||
selectionArgs: [displayName],
|
||||
}
|
||||
let fetchFileResult = await mediaTest.getFileAssets(option);
|
||||
if (fetchFileResult.getCount()) {
|
||||
let asset = await fetchFileResult.getFirstObject();
|
||||
await mediaTest.deleteAsset(asset.uri)
|
||||
}
|
||||
let publicPath = await mediaTest.getPublicDirectory(info.directory)
|
||||
Logger.info(TAG, `publicPath=${publicPath},displayName=${displayName}`)
|
||||
return await mediaTest.createAsset(info.mediaType, displayName, publicPath)
|
||||
}
|
||||
|
||||
async savePicture(data: image.PixelMap, context: any) {
|
||||
let packOpts: image.PackingOption = {
|
||||
format: "image/webp", quality: 100
|
||||
}
|
||||
let imagePackerApi = image.createImagePacker()
|
||||
let arrayBuffer = await imagePackerApi.packing(data, packOpts)
|
||||
let fileAsset = await this.createAndGetFile(context, "img")
|
||||
let fd = await fileAsset.open('Rw')
|
||||
imagePackerApi.release()
|
||||
try {
|
||||
await fs.write(fd, arrayBuffer)
|
||||
} catch (err) {
|
||||
Logger.error(TAG, `write failed ,code is ${err.code},message is ${err.message}`)
|
||||
}
|
||||
await fileAsset.close(fd)
|
||||
Logger.info(TAG, `write picture done`)
|
||||
}
|
||||
|
||||
async saveTXT(data, context) {
|
||||
let fileAsset = await this.createAndGetFile(context, "txt")
|
||||
let fd = await fileAsset.open('Rw')
|
||||
try {
|
||||
await fs.write(fd, data)
|
||||
} catch (err) {
|
||||
Logger.error(TAG, `write failed ,code is ${err.code},message is ${err.message}`)
|
||||
}
|
||||
await fileAsset.close(fd)
|
||||
Logger.info(TAG, `write txt done`)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取窗口结合&文件保存
|
||||
* 入参必填 ability的context
|
||||
|
||||
* snapShot
|
||||
* savePicture:设备端保存路径:/storage/media/100/local/files/Pictures/IMG_test.webp
|
||||
* saveTXT:设备端保存路径:/storage/media/100/local/files/Documents/TXT_test.txt
|
||||
*
|
||||
* const readBuffer = new ArrayBuffer(data.getPixelBytesNumber())
|
||||
* //保存成像素值
|
||||
* data.readPixelsToBuffer(readBuffer, () => { this.saveTXT(readBuffer, context)})
|
||||
*
|
||||
**/
|
||||
async snapShot(context) {
|
||||
//获取窗口
|
||||
Logger.info(TAG, 'start snapshot')
|
||||
let windowClass = null;
|
||||
try {
|
||||
windowClass = window.findWindow('floatWindow');
|
||||
Logger.info(TAG, 'find window success')
|
||||
} catch (exception) {
|
||||
Logger.error(TAG, 'Failed to find the window. Cause:' + JSON.stringify(exception))
|
||||
}
|
||||
//截屏
|
||||
windowClass.snapshot((err, data) => {
|
||||
if (err.code) {
|
||||
console.error(TAG, 'Failed to snapshot window. Cause:' + JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
|
||||
this.savePicture(data, context)
|
||||
|
||||
data.release();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default new windowSnap()
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
import bundleManager from '@ohos.bundle.bundleManager';
|
||||
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
|
||||
import hilog from '@ohos.hilog';
|
||||
import { Hypium } from '@ohos/hypium';
|
||||
import testsuite from '../test/List.test';
|
||||
import window from '@ohos.window';
|
||||
import Logger from '../test/model/Logger'
|
||||
|
||||
const TAG: string = '[createWindow]'
|
||||
|
||||
export default class TestAbility extends UIAbility {
|
||||
sleep(time) {
|
||||
return new Promise((resolve) => setTimeout(resolve, time));
|
||||
}
|
||||
|
||||
onCreate(want, launchParam) {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
|
||||
var abilityDelegator: any
|
||||
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
|
||||
var abilityDelegatorArguments: any
|
||||
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
|
||||
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage) {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
|
||||
globalThis.context = this.context
|
||||
|
||||
//系统授权,读写权限
|
||||
let atManager = abilityAccessCtrl.createAtManager();
|
||||
let appFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION;
|
||||
let permissionFlags = 0;
|
||||
bundleManager.getBundleInfoForSelf(appFlags, (err, data) => {
|
||||
if (err) {
|
||||
Logger.error(TAG, 'getAllApplicationInfo failed: %{public}s', err.message);
|
||||
console.error("")
|
||||
}
|
||||
let tokenID = data.appInfo.accessTokenId; //系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
|
||||
atManager.grantUserGrantedPermission(tokenID, 'ohos.permission.READ_MEDIA', permissionFlags, (err, data) => {
|
||||
if (err) {
|
||||
Logger.info(TAG, `grantUserGrantedPermission fail, err->${JSON.stringify(err)}`)
|
||||
}
|
||||
})
|
||||
atManager.grantUserGrantedPermission(tokenID, 'ohos.permission.WRITE_MEDIA', permissionFlags, (err, data) => {
|
||||
if (err) {
|
||||
Logger.info(TAG, `grantUserGrantedPermission fail, err->${JSON.stringify(err)}`)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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
|
||||
@Component
|
||||
struct Index {
|
||||
aboutToAppear() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
|
||||
}
|
||||
@State message: string = 'Hello World'
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
Text(this.message)
|
||||
.fontSize(50)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
Button() {
|
||||
Text('next page')
|
||||
.fontSize(20)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
}
|
||||
.type(ButtonType.Capsule)
|
||||
.margin({
|
||||
top: 20
|
||||
})
|
||||
.backgroundColor('#0D9FFB')
|
||||
.width('35%')
|
||||
.height('5%')
|
||||
.onClick(()=>{
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
.height('100%')
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 { MessageManager, Callback } from '../../test/model/MessageManager';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
@State message: string = 'Hello'
|
||||
@State fontColor: Color = Color.Brown
|
||||
messageManager: MessageManager = new MessageManager()
|
||||
|
||||
onPageShow() {
|
||||
console.info('NavDestination onPageShow')
|
||||
globalThis.value = {
|
||||
name: 'messageManager', message: this.messageManager
|
||||
}
|
||||
let callback: Callback = (message: any) => {
|
||||
console.error('message = ' + message.name + "--" + message.value)
|
||||
if (message.name == 'fontColor') {
|
||||
this.fontColor = message.value
|
||||
}
|
||||
}
|
||||
this.messageManager.registerCallback(callback)
|
||||
}
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
Text(this.message)
|
||||
.fontSize(20)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
.fontColor(Color.Green)
|
||||
.margin({ top: 20 })
|
||||
.key('text_demo')
|
||||
|
||||
Button('click')
|
||||
.fontSize(16)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
.backgroundColor(this.fontColor)
|
||||
.margin({ top: 20 })
|
||||
.key('button_demo')
|
||||
.onClick(() => {
|
||||
this.message = 'Hi All'
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.backgroundColor(Color.Orange)
|
||||
|
||||
}
|
||||
.defaultFocus(true)
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.app.ability.abilityDelegatorRegistry';
|
||||
|
||||
var abilityDelegator = undefined
|
||||
var abilityDelegatorArguments = undefined
|
||||
|
||||
async function onAbilityCreateCallback() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
|
||||
}
|
||||
|
||||
async function addAbilityMonitorCallback(err: any) {
|
||||
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
|
||||
}
|
||||
|
||||
export default class OpenHarmonyTestRunner implements TestRunner {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
onPrepare() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
|
||||
}
|
||||
|
||||
async onRun() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
|
||||
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
|
||||
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
|
||||
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
|
||||
let lMonitor = {
|
||||
abilityName: testAbilityName,
|
||||
onAbilityCreate: onAbilityCreateCallback,
|
||||
};
|
||||
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
|
||||
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
|
||||
var debug = abilityDelegatorArguments.parameters['-D']
|
||||
if (debug == 'true')
|
||||
{
|
||||
cmd += ' -D'
|
||||
}
|
||||
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
|
||||
abilityDelegator.executeShellCommand(cmd,
|
||||
(err: any, d: any) => {
|
||||
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
|
||||
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
|
||||
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
|
||||
})
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"module": {
|
||||
"name": "entry_test",
|
||||
"type": "feature",
|
||||
"description": "$string:module_test_desc",
|
||||
"mainElement": "TestAbility",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": false,
|
||||
"pages": "$profile:test_pages",
|
||||
"requestPermissions": [
|
||||
{
|
||||
"name": "ohos.permission.SYSTEM_FLOAT_WINDOW",
|
||||
"usedScene": {
|
||||
"abilities":[
|
||||
"EntryAbility"
|
||||
],
|
||||
"when": "inuse"
|
||||
}
|
||||
},{
|
||||
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
|
||||
},{
|
||||
"name": "ohos.permission.WRITE_MEDIA"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.READ_MEDIA"
|
||||
}
|
||||
],
|
||||
"abilities": [
|
||||
{
|
||||
"name": "TestAbility",
|
||||
"srcEntrance": "./ets/testability/TestAbility.ets",
|
||||
"description": "$string:TestAbility_desc",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:TestAbility_label",
|
||||
"visible": true,
|
||||
"startWindowIcon": "$media:icon",
|
||||
"startWindowBackground": "$color:start_window_background",
|
||||
"skills": [
|
||||
{
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
],
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "start_window_background",
|
||||
"value": "#FFFFFF"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_test_desc",
|
||||
"value": "test ability description"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_desc",
|
||||
"value": "the test ability"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_label",
|
||||
"value": "test label"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"src": [
|
||||
"testability/pages/Index",
|
||||
"testability/pages/demo"
|
||||
]
|
||||
}
|
16
UIcompare/component/code/demo/hvigorfile.ts
Normal file
16
UIcompare/component/code/demo/hvigorfile.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
||||
export { appTasks } from '@ohos/hvigor-ohos-plugin';
|
1089
UIcompare/component/code/demo/package-lock.json
generated
Normal file
1089
UIcompare/component/code/demo/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
17
UIcompare/component/code/demo/package.json
Normal file
17
UIcompare/component/code/demo/package.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "component",
|
||||
"version": "1.0.0",
|
||||
"ohos": {
|
||||
"org": "UICompare",
|
||||
"buildTool": "hvigor",
|
||||
"directoryLevel": "project"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@ohos/hypium": "1.0.5",
|
||||
"@ohos/hvigor": "1.4.0",
|
||||
"@ohos/hvigor-ohos-plugin": "1.4.0"
|
||||
}
|
||||
}
|
25
UIcompare/general/code/demo/AppScope/app.json5
Normal file
25
UIcompare/general/code/demo/AppScope/app.json5
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.example.general",
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
"icon": "$media:app_icon",
|
||||
"label": "$string:app_name",
|
||||
"distributedNotificationEnabled": true
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "app_name",
|
||||
"value": "general"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
41
UIcompare/general/code/demo/build-profile.json5
Normal file
41
UIcompare/general/code/demo/build-profile.json5
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"app": {
|
||||
"signingConfigs": [],
|
||||
"compileSdkVersion": 9,
|
||||
"compatibleSdkVersion": 9,
|
||||
"products": [
|
||||
{
|
||||
"name": "default",
|
||||
"signingConfig": "default",
|
||||
}
|
||||
]
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"name": "entry",
|
||||
"srcPath": "./entry",
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
"applyToProducts": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
27
UIcompare/general/code/demo/entry/build-profile.json5
Normal file
27
UIcompare/general/code/demo/entry/build-profile.json5
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"apiType": 'stageMode',
|
||||
"buildOption": {
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"name": "ohosTest",
|
||||
}
|
||||
]
|
||||
}
|
16
UIcompare/general/code/demo/entry/hvigorfile.ts
Normal file
16
UIcompare/general/code/demo/entry/hvigorfile.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
||||
export { hapTasks } from '@ohos/hvigor-ohos-plugin';
|
5
UIcompare/general/code/demo/entry/package-lock.json
generated
Normal file
5
UIcompare/general/code/demo/entry/package-lock.json
generated
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "entry",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1
|
||||
}
|
13
UIcompare/general/code/demo/entry/package.json
Normal file
13
UIcompare/general/code/demo/entry/package.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "entry",
|
||||
"version": "1.0.0",
|
||||
"ohos": {
|
||||
"org": "UICompare",
|
||||
"buildTool": "hvigor",
|
||||
"directoryLevel": "module"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"license": "ISC",
|
||||
"dependencies": {}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import hilog from '@ohos.hilog';
|
||||
import window from '@ohos.window';
|
||||
|
||||
export default class EntryAbility extends UIAbility {
|
||||
onCreate(want, launchParam) {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage) {
|
||||
// Main window is created, set main page for this ability
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
||||
|
||||
windowStage.loadContent('pages/Index', (err, data) => {
|
||||
if (err.code) {
|
||||
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
||||
return;
|
||||
}
|
||||
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
|
||||
});
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
// Main window is destroyed, release UI related resources
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
// Ability has brought to foreground
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
// Ability has back to background
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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 {
|
||||
@State message: string = 'Hello World'
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
Text(this.message)
|
||||
.fontSize(50)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
.height('100%')
|
||||
}
|
||||
}
|
51
UIcompare/general/code/demo/entry/src/main/module.json5
Normal file
51
UIcompare/general/code/demo/entry/src/main/module.json5
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"module": {
|
||||
"name": "entry",
|
||||
"type": "entry",
|
||||
"description": "$string:module_desc",
|
||||
"mainElement": "EntryAbility",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": false,
|
||||
"pages": "$profile:main_pages",
|
||||
"abilities": [
|
||||
{
|
||||
"name": "EntryAbility",
|
||||
"srcEntrance": "./ets/entryability/EntryAbility.ts",
|
||||
"description": "$string:EntryAbility_desc",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:EntryAbility_label",
|
||||
"startWindowIcon": "$media:icon",
|
||||
"startWindowBackground": "$color:start_window_background",
|
||||
"visible": true,
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "start_window_background",
|
||||
"value": "#FFFFFF"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "module description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "label"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"src": [
|
||||
"pages/Index"
|
||||
]
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "module description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "label"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "模块描述"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "label"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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'
|
||||
|
||||
export default function abilityTest() {
|
||||
describe('ActsAbilityTest', function () {
|
||||
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
|
||||
beforeAll(function () {
|
||||
// Presets an action, which is performed only once before all test cases of the test suite start.
|
||||
// This API supports only one parameter: preset action function.
|
||||
})
|
||||
beforeEach(function () {
|
||||
// Presets an action, which is performed before each unit test case starts.
|
||||
// The number of execution times is the same as the number of test cases defined by **it**.
|
||||
// This API supports only one parameter: preset action function.
|
||||
})
|
||||
afterEach(function () {
|
||||
// Presets a clear action, which is performed after each unit test case ends.
|
||||
// The number of execution times is the same as the number of test cases defined by **it**.
|
||||
// This API supports only one parameter: clear action function.
|
||||
})
|
||||
afterAll(function () {
|
||||
// Presets a clear action, which is performed after all test cases of the test suite end.
|
||||
// This API supports only one parameter: clear action function.
|
||||
})
|
||||
it('assertContain',0, function () {
|
||||
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
|
||||
let a = 'abc'
|
||||
let b = 'b'
|
||||
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
|
||||
expect(a).assertContain(b)
|
||||
expect(a).assertEqual(a)
|
||||
})
|
||||
})
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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 BackgroundColorTest from './generalAttributes/BackgroundColorTest.test'
|
||||
|
||||
export default function testsuite() {
|
||||
BackgroundColorTest()
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 { AttrsManager } from '../model/AttrsManager';
|
||||
import Utils from '../model/Utils'
|
||||
import { it, afterEach } from '@ohos/hypium';
|
||||
import windowSnap from '../model/snapShot';
|
||||
import Settings from '../model/Settings';
|
||||
import Logger from '../model/Logger'
|
||||
import router from '@ohos.router';
|
||||
|
||||
export default class CommonTest {
|
||||
static initTest(pageConfig, supportView, testValues) {
|
||||
|
||||
afterEach(async function (done) {
|
||||
if (Settings.windowClass == null) {
|
||||
return
|
||||
}
|
||||
|
||||
Settings.windowClass.destroyWindow((err) => {
|
||||
if (err.code) {
|
||||
Logger.error('TEST', `Failed to destroy the window. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
Logger.info('TEST', `Succeeded in destroy the window.`);
|
||||
})
|
||||
await Utils.sleep(1000);
|
||||
done()
|
||||
})
|
||||
|
||||
//根据要测试的组件和属性值循环创建case
|
||||
supportView.forEach(targetView => {
|
||||
testValues.forEach(testValue => {
|
||||
let caseTag = pageConfig.testName + "_" + targetView + "_" + testValue.describe
|
||||
//create cases
|
||||
it(caseTag, 0, async (done) => {
|
||||
pageConfig['targetView'] = targetView;
|
||||
pageConfig['componentKey'] = targetView;
|
||||
|
||||
//创建窗口,设置窗口页面
|
||||
Settings.createWindow(pageConfig.pageUrl)
|
||||
|
||||
await Utils.sleep(1000);
|
||||
|
||||
//跳转页面并传递参数
|
||||
await router.pushUrl({
|
||||
url: pageConfig.pageUrl,
|
||||
params: {
|
||||
view: pageConfig
|
||||
}
|
||||
})
|
||||
|
||||
//在此处可以获取页面中的组件进行一些操作,例如获取组件并点击
|
||||
// await Utils.clickComponentByKey(targetView)
|
||||
|
||||
await Utils.sleep(1000);
|
||||
|
||||
//更改属性值
|
||||
AttrsManager.change(caseTag, testValue.setValue);
|
||||
|
||||
//截图
|
||||
await Utils.sleep(1000);
|
||||
windowSnap.snapShot(globalThis.context, caseTag)
|
||||
await Utils.sleep(1000);
|
||||
|
||||
done()
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* 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 class Constants {
|
||||
static readonly EVENT_ID_CHANGE_DATA = 101
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 CommonTest from '../common/CommonTest';
|
||||
import { describe } from '@ohos/hypium';
|
||||
|
||||
//测试通用属性-backgroundColor
|
||||
export default function backgroundColorTest() {
|
||||
|
||||
//supportView包含了所有测试组件,根据当前通用数据所适用的组件进行修改,遍历生成case
|
||||
// this param is required.
|
||||
let supportView = [
|
||||
'AlphabetIndexer', 'Blank', 'Button', 'Checkbox', 'CheckboxGroup', 'DataPanel', 'DatePicker',
|
||||
'Divider', 'Gauge', 'Image', 'LoadingProgress', 'Marquee', 'Menu', 'MenuItem', 'MenuItemGroup', 'Navigation',
|
||||
'NavRouter', 'NavDestination', 'PatternLock', 'Progress', 'QRCode', 'Radio', 'Rating', 'RichText', 'ScrollBar',
|
||||
'Search', 'Select', 'Slider', 'Span', 'Stepper', 'StepperItem', 'Text', 'TextArea', 'TextClock', 'TextInput',
|
||||
'TextPicker', 'TextTimer', 'TimePicker', 'Toggle', 'Badge', 'Column', 'ColumnSplit', 'Counter', 'Flex',
|
||||
'FlowItem', 'GridCol', 'GridRow', 'Grid', 'GridItem', 'List', 'ListItem', 'ListItemGroup', 'Navigator', 'Panel',
|
||||
'Refresh', 'RelativeContainer', 'Row', 'RowSplit', 'Scroll', 'SideBarContainer', 'Stack', 'Swiper', 'Tabs',
|
||||
'TabContent', 'WaterFlow', 'Video', 'Circle', 'Ellipse', 'Line', 'Polyline', 'Polygon', 'Path', 'Rect', 'Shape', 'Canvas'
|
||||
]
|
||||
|
||||
//页面配置信息
|
||||
// this param is required.
|
||||
let pageConfig = {
|
||||
testName: 'BackgroundColorTest', //截图命名的一部分
|
||||
pageUrl: 'testability/pages/BackgroundColorPage' //用于设置窗口页面
|
||||
}
|
||||
|
||||
//要测试的属性值,遍历生成case
|
||||
// this param is required.
|
||||
let testValues = [{
|
||||
describe: 'Color', //截图命名的一部分
|
||||
setValue: Color.Green, //要测试的属性值
|
||||
}, {
|
||||
describe: 'Number',
|
||||
setValue: 0xa23535, //酒红色
|
||||
}, {
|
||||
describe: 'String',
|
||||
setValue: 'rgb(255,105,180)', //hot pink
|
||||
}, {
|
||||
describe: 'Resource',
|
||||
setValue: $r('app.color.backgroundColor_color'),
|
||||
}]
|
||||
|
||||
|
||||
// create test suite
|
||||
describe("BackgroundColorTest", () => {
|
||||
// create test cases by config.
|
||||
|
||||
CommonTest.initTest(pageConfig, supportView, testValues)
|
||||
})
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 { Constants } from '../constants/Constants';
|
||||
import events_emitter from '@ohos.events.emitter';
|
||||
|
||||
export class AttrsManager {
|
||||
callBack;
|
||||
|
||||
static change(caseName, setValue) {
|
||||
let eventData = { data: { src: JSON.stringify({ value: setValue }) } }
|
||||
this.emitEvent(caseName, Constants.EVENT_ID_CHANGE_DATA, eventData);
|
||||
}
|
||||
|
||||
registerDataChange(callBack) {
|
||||
this.callBack = callBack
|
||||
this.onEvent(Constants.EVENT_ID_CHANGE_DATA);
|
||||
}
|
||||
|
||||
private onEvent(eventId: number) {
|
||||
var stateChangeEvent = {
|
||||
eventId: eventId,
|
||||
priority: events_emitter.EventPriority.LOW
|
||||
}
|
||||
events_emitter.off(eventId)
|
||||
events_emitter.on(stateChangeEvent, this.stateChangeCallBack);
|
||||
}
|
||||
|
||||
private static emitEvent(tag, eventId, eventData) {
|
||||
var innerEvent = {
|
||||
eventId: eventId,
|
||||
priority: events_emitter.EventPriority.LOW
|
||||
}
|
||||
events_emitter.emit(innerEvent, eventData);
|
||||
}
|
||||
|
||||
private stateChangeCallBack = (eventData) => {
|
||||
if (eventData != null) {
|
||||
if (eventData.data.src != null) {
|
||||
let src = JSON.parse(eventData.data.src);
|
||||
this.callBack(src.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let attrsManager = new AttrsManager();
|
||||
|
||||
export default attrsManager as AttrsManager;
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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';
|
||||
|
||||
class Logger {
|
||||
private domain: number
|
||||
private prefix: string
|
||||
private format: string = "%{public}s,%{public}s"
|
||||
|
||||
constructor(prefix: string) {
|
||||
this.prefix = prefix
|
||||
this.domain = 0xFF00
|
||||
}
|
||||
|
||||
debug(...args: any[]) {
|
||||
hilog.debug(this.domain, this.prefix, this.format, args)
|
||||
}
|
||||
|
||||
info(...args: any[]) {
|
||||
hilog.info(this.domain, this.prefix, this.format, args)
|
||||
}
|
||||
|
||||
warn(...args: any[]) {
|
||||
hilog.warn(this.domain, this.prefix, this.format, args)
|
||||
}
|
||||
|
||||
error(...args: any[]) {
|
||||
hilog.error(this.domain, this.prefix, this.format, args)
|
||||
}
|
||||
}
|
||||
|
||||
export default new Logger('[Screenshot]')
|
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
import screen from '@ohos.screen';
|
||||
import window from '@ohos.window';
|
||||
import Logger from './Logger';
|
||||
|
||||
const TAG: string = '[Setting]';
|
||||
|
||||
class Settings {
|
||||
sleep(time) {
|
||||
return new Promise((resolve) => setTimeout(resolve, time));
|
||||
}
|
||||
|
||||
windowClass: window.Window = null
|
||||
|
||||
changeWindowPosition(windowClass, X, Y) {
|
||||
//为悬浮窗设置位置
|
||||
windowClass.moveWindowTo(X, Y, (err) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to move the window. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
changeWindowSize(windowClass, width, height) {
|
||||
//为悬浮窗设置大小
|
||||
windowClass.resize(width, height, (err) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to change the window size. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
loadContent(windowClass, pageURI) {
|
||||
//为悬浮窗加载对应的目标页面
|
||||
windowClass.setUIContent(pageURI, (err) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to load the window. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
Logger.info(TAG, `Succeeded in loading the content.`);
|
||||
|
||||
//显示悬浮窗
|
||||
windowClass.showWindow((err) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to show the window. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
Logger.info(TAG, `Succeeded in showing the window.`);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
changeDpi(dpi) {
|
||||
let screenClass = null;
|
||||
screen.getAllScreens((err, data) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to get all screens. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
Logger.info(TAG, `Succeeded in getting all screens. Data:${JSON.stringify(data)}`);
|
||||
|
||||
screenClass = data[0];
|
||||
//设置设备dpi
|
||||
screenClass.setDensityDpi(dpi, (err, data) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to set the pixel density. Code : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
Logger.info(TAG, `Succeeded in setting the pixel density`);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
destroyWindow(windowClass) {
|
||||
//销毁窗口
|
||||
windowClass.destroyWindow((err) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to destroy the window. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
Logger.info(TAG, `Succeeded in destroy the window.`);
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
* 窗口页面更新
|
||||
* Setting.createWindow(pageURI: String, {X,Y,width,height,dpi}?:{X?:number,Y?:number,width?:number,height?:number,dpi?:number}):void
|
||||
* 必填:
|
||||
* pageURI:页面路由
|
||||
* 选填:
|
||||
* X,Y:窗口相对于左上角的位置,默认X=100,Y=100 单位为px
|
||||
* width,height:窗口宽高,默认width=600,height=1250 可配置范围:[0,2560],单位为vp
|
||||
* dpi:像素密度,默认dpi=330,可配置范围:80-640
|
||||
* */
|
||||
|
||||
createWindow(pageURI: String, {X=100,Y=100,width=600,height=1250,dpi=400}={}) {
|
||||
Logger.info(TAG, `params,pageURI=${pageURI},X=${X},Y=${Y},width=${width},height=${height},dpi=${dpi}`)
|
||||
|
||||
this.changeDpi(dpi)
|
||||
this.sleep(1000)
|
||||
let windowClass = null
|
||||
let config = {
|
||||
name: "floatWindow",
|
||||
windowType: window.WindowType.TYPE_FLOAT,
|
||||
ctx: globalThis.context
|
||||
};
|
||||
window.createWindow(config, (err, data) => {
|
||||
if (err.code) {
|
||||
Logger.error(TAG, `Failed to create the floatWindow. Cause : ${JSON.stringify(err)}`)
|
||||
return;
|
||||
}
|
||||
Logger.info(TAG, `Succeeded in creating the floatWindow. Data : ${JSON.stringify(err)}`);
|
||||
windowClass = data;
|
||||
this.windowClass = data;
|
||||
|
||||
this.changeWindowPosition(windowClass, X, Y);
|
||||
this.changeWindowSize(windowClass, width, height);
|
||||
this.loadContent(windowClass, pageURI)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default new Settings()
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
import { UiDriver, Driver, BY } from '@ohos.UiTest';
|
||||
|
||||
export default class Utils {
|
||||
static sleep(time) {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve()
|
||||
}, time)
|
||||
})
|
||||
}
|
||||
|
||||
static async clickComponentByKey(componentKey) {
|
||||
let driver = await UiDriver.create();
|
||||
let component = await driver.findComponent(BY.key(componentKey));
|
||||
await component.click();
|
||||
}
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
import window from '@ohos.window';
|
||||
import Logger from './Logger';
|
||||
import image from '@ohos.multimedia.image';
|
||||
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
|
||||
import fs from '@ohos.file.fs';
|
||||
|
||||
const TAG: string = '[windowSnap]';
|
||||
const INFO = {
|
||||
"img": {
|
||||
prefix: 'IMG_',
|
||||
suffix: '.webp',
|
||||
directory: mediaLibrary.DirectoryType.DIR_IMAGE,
|
||||
mediaType: mediaLibrary.MediaType.IMAGE
|
||||
},
|
||||
"txt": {
|
||||
prefix: 'TXT_',
|
||||
suffix: '.txt',
|
||||
directory: mediaLibrary.DirectoryType.DIR_DOCUMENTS,
|
||||
mediaType: mediaLibrary.MediaType.FILE
|
||||
}
|
||||
}
|
||||
|
||||
class windowSnap {
|
||||
async createAndGetFile(context: any, type, caseName) {
|
||||
Logger.info(TAG, `createAndGetFile start`)
|
||||
let mediaTest = mediaLibrary.getMediaLibrary(context)
|
||||
let info = INFO[type]
|
||||
//文件名用于自动化UI对比
|
||||
let name = caseName ? caseName : "test"
|
||||
let displayName = `${info.prefix}${name}${info.suffix}`
|
||||
let option = {
|
||||
selections: mediaLibrary.FileKey.DISPLAY_NAME + '=?',
|
||||
selectionArgs: [displayName],
|
||||
}
|
||||
let fetchFileResult = await mediaTest.getFileAssets(option);
|
||||
if (fetchFileResult.getCount()) {
|
||||
let asset = await fetchFileResult.getFirstObject();
|
||||
await mediaTest.deleteAsset(asset.uri)
|
||||
}
|
||||
let publicPath = await mediaTest.getPublicDirectory(info.directory)
|
||||
Logger.info(TAG, `publicPath=${publicPath},displayName=${displayName}`)
|
||||
return await mediaTest.createAsset(info.mediaType, displayName, publicPath)
|
||||
}
|
||||
|
||||
async savePicture(data: image.PixelMap, context: any, caseName) {
|
||||
let packOpts: image.PackingOption = {
|
||||
format: "image/webp", quality: 100
|
||||
}
|
||||
let imagePackerApi = image.createImagePacker()
|
||||
let arrayBuffer = await imagePackerApi.packing(data, packOpts)
|
||||
let fileAsset = await this.createAndGetFile(context, "img", caseName)
|
||||
let fd = await fileAsset.open('Rw')
|
||||
imagePackerApi.release()
|
||||
try {
|
||||
await fs.write(fd, arrayBuffer)
|
||||
} catch (err) {
|
||||
Logger.error(TAG, `write failed ,code is ${err.code},message is ${err.message}`)
|
||||
}
|
||||
await fileAsset.close(fd)
|
||||
Logger.info(TAG, `write picture done`)
|
||||
}
|
||||
|
||||
async saveTXT(data, context) {
|
||||
let fileAsset = await this.createAndGetFile(context, "txt")
|
||||
let fd = await fileAsset.open('Rw')
|
||||
try {
|
||||
await fs.write(fd, data)
|
||||
} catch (err) {
|
||||
Logger.error(TAG, `write failed ,code is ${err.code},message is ${err.message}`)
|
||||
}
|
||||
await fileAsset.close(fd)
|
||||
Logger.info(TAG, `write txt done`)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取窗口结合&文件保存
|
||||
* 入参必填 ability的context
|
||||
|
||||
* snapShot
|
||||
* savePicture:设备端保存路径:/storage/media/100/local/files/Pictures
|
||||
* saveTXT:设备端保存路径:/storage/media/100/local/files/Documents/TXT_test.txt
|
||||
*
|
||||
* const readBuffer = new ArrayBuffer(data.getPixelBytesNumber())
|
||||
* //保存成像素值
|
||||
* data.readPixelsToBuffer(readBuffer, () => { this.saveTXT(readBuffer, context)})
|
||||
*
|
||||
**/
|
||||
async snapShot(context, caseName) {
|
||||
//获取窗口
|
||||
Logger.info(TAG, 'start snapshot')
|
||||
let windowClass = null;
|
||||
try {
|
||||
windowClass = window.findWindow('floatWindow');
|
||||
Logger.info(TAG, 'find window success')
|
||||
} catch (exception) {
|
||||
Logger.error(TAG, 'Failed to find the window. Cause:' + JSON.stringify(exception))
|
||||
}
|
||||
//截屏
|
||||
windowClass.snapshot((err, data) => {
|
||||
if (err.code) {
|
||||
console.error(TAG, 'Failed to snapshot window. Cause:' + JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
|
||||
this.savePicture(data, context, caseName)
|
||||
|
||||
data.release();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default new windowSnap()
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
import bundleManager from '@ohos.bundle.bundleManager';
|
||||
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
|
||||
import hilog from '@ohos.hilog';
|
||||
import { Hypium } from '@ohos/hypium';
|
||||
import testsuite from '../test/List.test';
|
||||
import window from '@ohos.window';
|
||||
import Logger from '../test/model/Logger'
|
||||
|
||||
const TAG: string = '[createWindow]'
|
||||
|
||||
export default class TestAbility extends UIAbility {
|
||||
sleep(time) {
|
||||
return new Promise((resolve) => setTimeout(resolve, time));
|
||||
}
|
||||
|
||||
onCreate(want, launchParam) {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
|
||||
var abilityDelegator: any
|
||||
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
|
||||
var abilityDelegatorArguments: any
|
||||
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
|
||||
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage) {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
|
||||
globalThis.context = this.context
|
||||
|
||||
//系统授权,读写权限
|
||||
let atManager = abilityAccessCtrl.createAtManager();
|
||||
let appFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION;
|
||||
let permissionFlags = 0;
|
||||
bundleManager.getBundleInfoForSelf(appFlags, (err, data) => {
|
||||
if (err) {
|
||||
Logger.error(TAG, 'getAllApplicationInfo failed: %{public}s', err.message);
|
||||
console.error("")
|
||||
}
|
||||
let tokenID = data.appInfo.accessTokenId; //系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
|
||||
atManager.grantUserGrantedPermission(tokenID, 'ohos.permission.READ_MEDIA', permissionFlags, (err, data) => {
|
||||
if (err) {
|
||||
Logger.info(TAG, `grantUserGrantedPermission fail, err->${JSON.stringify(err)}`)
|
||||
}
|
||||
})
|
||||
atManager.grantUserGrantedPermission(tokenID, 'ohos.permission.WRITE_MEDIA', permissionFlags, (err, data) => {
|
||||
if (err) {
|
||||
Logger.info(TAG, `grantUserGrantedPermission fail, err->${JSON.stringify(err)}`)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
|
||||
}
|
||||
}
|
@ -0,0 +1,343 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
import AttrsManager from '../../test/model/AttrsManager'
|
||||
import router from '@ohos.router';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct BackgroundColorPage {
|
||||
@State _generalAttr: number = 0xecd4a8; //通用属性初始值
|
||||
@State targetView: string = router.getParams() ? router.getParams()['view']['targetView'] : "" //当前测试的组件
|
||||
@State componentKey: string = router.getParams() ? router.getParams()['view']['componentKey'] : "" //组件唯一标识
|
||||
|
||||
@Styles commonStyle(){
|
||||
.width(150)
|
||||
.height(200)
|
||||
.backgroundColor(this._generalAttr)
|
||||
.key(this.componentKey)
|
||||
}
|
||||
|
||||
//ScrollBar组件
|
||||
private scroller: Scroller = new Scroller()
|
||||
|
||||
onPageShow() {
|
||||
AttrsManager.registerDataChange(value => this._generalAttr = value)
|
||||
}
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
if (this.targetView == 'AlphabetIndexer') {
|
||||
AlphabetIndexer({ arrayValue: ['A', 'B', 'C'], selected: 0 })
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Blank') {
|
||||
Blank()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Button') {
|
||||
Button()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Checkbox') {
|
||||
Checkbox()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'CheckboxGroup') {
|
||||
CheckboxGroup()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'DataPanel') {
|
||||
DataPanel({ values: [50, 12, 8, 5] })
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'DatePicker') {
|
||||
DatePicker()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Divider') {
|
||||
Divider()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Gauge') {
|
||||
Gauge({ value: 75 })
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Image') {
|
||||
Image($r("app.media.icon")).objectFit(ImageFit.Contain)
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'LoadingProgress') {
|
||||
LoadingProgress()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Marquee') {
|
||||
Marquee({
|
||||
start: true,
|
||||
src: "Marquee"
|
||||
})
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Menu') {
|
||||
Menu() {
|
||||
MenuItem({ content: "MenuItem1" })
|
||||
}
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'MenuItem') {
|
||||
MenuItem({ content: "MenuItem1" })
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'MenuItemGroup') {
|
||||
MenuItemGroup({ header: "MenuItemGroup小标题" })
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Navigation') {
|
||||
Navigation()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'NavRouter') {
|
||||
NavRouter()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'NavDestination') {
|
||||
NavDestination()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'PatternLock') {
|
||||
PatternLock()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Progress') {
|
||||
Progress({ value: 10 })
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'QRCode') {
|
||||
QRCode('hello world')
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Radio') {
|
||||
Radio({ value: 'Radio1', group: 'radioGroup' })
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Rating') {
|
||||
Rating({ rating: 3.5 })
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'RichText') {
|
||||
RichText('<h1>h1小标题</h1>')
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'ScrollBar') {
|
||||
ScrollBar({ scroller: this.scroller, direction: ScrollBarDirection.Vertical, state: BarState.On }) {
|
||||
Text()
|
||||
.width(20)
|
||||
.height(100)
|
||||
.borderRadius(10)
|
||||
.backgroundColor('#C0C0C0')
|
||||
}
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Search') {
|
||||
Search()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Select') {
|
||||
Select([{ value: 'aaa' },
|
||||
{ value: 'bbb' }])
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Slider') {
|
||||
Slider()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Span') {
|
||||
Text() {
|
||||
Span('This is the Span component')
|
||||
.commonStyle()
|
||||
}
|
||||
} else if (this.targetView == 'Stepper') {
|
||||
Stepper()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'StepperItem') {
|
||||
Stepper() {
|
||||
StepperItem()
|
||||
.commonStyle()
|
||||
}
|
||||
} else if (this.targetView == 'Text') {
|
||||
Text('text')
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'TextArea') {
|
||||
TextArea()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'TextClock') {
|
||||
TextClock()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'TextInput') {
|
||||
TextInput()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'TextPicker') {
|
||||
TextPicker({ range: ['apple1', 'orange2', 'peach3', 'grape4'] })
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'TextTimer') {
|
||||
TextTimer({ isCountDown: true, count: 30000 })
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'TimePicker') {
|
||||
TimePicker()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Toggle') {
|
||||
Toggle({ type: ToggleType.Switch })
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Badge') {
|
||||
Badge({
|
||||
value: 'New',
|
||||
style: { badgeSize: 16 }
|
||||
}) {
|
||||
Text('list2')
|
||||
}
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Column') {
|
||||
Column()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'ColumnSplit') {
|
||||
ColumnSplit() {
|
||||
Text('1')
|
||||
}
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Counter') {
|
||||
Counter()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Flex') {
|
||||
Flex()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'GridCol') {
|
||||
GridRow() {
|
||||
GridCol()
|
||||
.commonStyle()
|
||||
}
|
||||
} else if (this.targetView == 'GridRow') {
|
||||
GridRow() {
|
||||
GridCol() {
|
||||
Row().height('20vp')
|
||||
}
|
||||
}
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Grid') {
|
||||
Grid() {
|
||||
GridItem()
|
||||
}
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'GridItem') {
|
||||
Grid() {
|
||||
GridItem()
|
||||
.commonStyle()
|
||||
}
|
||||
} else if (this.targetView == 'List') {
|
||||
List()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'ListItem') {
|
||||
List() {
|
||||
ListItem()
|
||||
.commonStyle()
|
||||
}
|
||||
} else if (this.targetView == 'ListItemGroup') {
|
||||
List() {
|
||||
ListItemGroup() {
|
||||
ListItem() {
|
||||
Text('N')
|
||||
}
|
||||
}
|
||||
.commonStyle()
|
||||
}
|
||||
} else if (this.targetView == 'Navigator') {
|
||||
Navigator({ target: 'pages/BackgroundColorPage' })
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Panel') {
|
||||
Panel(true)
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Refresh') {
|
||||
Refresh({ refreshing: true })
|
||||
.commonStyle()
|
||||
}
|
||||
else if (this.targetView == 'RelativeContainer') {
|
||||
RelativeContainer() {
|
||||
Row()
|
||||
.width(100)
|
||||
.height(100)
|
||||
.backgroundColor("#FF3333")
|
||||
.alignRules({
|
||||
top: { anchor: "__container__", align: VerticalAlign.Top },
|
||||
left: { anchor: "__container__", align: HorizontalAlign.Start }
|
||||
})
|
||||
.id("row1")
|
||||
}
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Row') {
|
||||
Row()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'RowSplit') {
|
||||
RowSplit() {
|
||||
Text('1')
|
||||
}
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Scroll') {
|
||||
Scroll() {
|
||||
Text('N')
|
||||
}
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'SideBarContainer') {
|
||||
SideBarContainer() {
|
||||
Text("Index0")
|
||||
}
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Stack') {
|
||||
Stack()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Swiper') {
|
||||
Swiper()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Swiper') {
|
||||
Swiper()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Tabs') {
|
||||
Tabs()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'TabContent') {
|
||||
Tabs() {
|
||||
TabContent()
|
||||
.commonStyle()
|
||||
}
|
||||
} else if (this.targetView == 'FlowItem') {
|
||||
WaterFlow() {
|
||||
FlowItem()
|
||||
.commonStyle()
|
||||
}
|
||||
} else if (this.targetView == 'WaterFlow') {
|
||||
WaterFlow()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Video') {
|
||||
Video({
|
||||
src: $r('app.media.tree')
|
||||
})
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Circle') {
|
||||
Circle()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Ellipse') {
|
||||
Ellipse()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Line') {
|
||||
Line()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Polyline') {
|
||||
Polyline()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Polygon') {
|
||||
Polygon()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Path') {
|
||||
Path()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Rect') {
|
||||
Rect()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Shape') {
|
||||
Shape()
|
||||
.commonStyle()
|
||||
} else if (this.targetView == 'Canvas') {
|
||||
Canvas()
|
||||
.commonStyle()
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.backgroundColor(Color.Orange)
|
||||
}
|
||||
.defaultFocus(true)
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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
|
||||
@Component
|
||||
struct Index {
|
||||
aboutToAppear() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
|
||||
}
|
||||
@State message: string = 'Hello World'
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
Text(this.message)
|
||||
.fontSize(50)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
Button() {
|
||||
Text('next page')
|
||||
.fontSize(20)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
}.type(ButtonType.Capsule)
|
||||
.margin({
|
||||
top: 20
|
||||
})
|
||||
.backgroundColor('#0D9FFB')
|
||||
.width('35%')
|
||||
.height('5%')
|
||||
.onClick(()=>{
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
.height('100%')
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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.app.ability.abilityDelegatorRegistry';
|
||||
|
||||
var abilityDelegator = undefined
|
||||
var abilityDelegatorArguments = undefined
|
||||
|
||||
async function onAbilityCreateCallback() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
|
||||
}
|
||||
|
||||
async function addAbilityMonitorCallback(err: any) {
|
||||
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
|
||||
}
|
||||
|
||||
export default class OpenHarmonyTestRunner implements TestRunner {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
onPrepare() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
|
||||
}
|
||||
|
||||
async onRun() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
|
||||
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
|
||||
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
|
||||
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
|
||||
let lMonitor = {
|
||||
abilityName: testAbilityName,
|
||||
onAbilityCreate: onAbilityCreateCallback,
|
||||
};
|
||||
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
|
||||
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
|
||||
var debug = abilityDelegatorArguments.parameters['-D']
|
||||
if (debug == 'true') {
|
||||
cmd += ' -D'
|
||||
}
|
||||
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
|
||||
abilityDelegator.executeShellCommand(cmd,
|
||||
(err: any, d: any) => {
|
||||
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
|
||||
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
|
||||
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
|
||||
})
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
|
||||
}
|
||||
}
|
69
UIcompare/general/code/demo/entry/src/ohosTest/module.json5
Normal file
69
UIcompare/general/code/demo/entry/src/ohosTest/module.json5
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"module": {
|
||||
"name": "entry_test",
|
||||
"type": "feature",
|
||||
"description": "$string:module_test_desc",
|
||||
"mainElement": "TestAbility",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": false,
|
||||
"pages": "$profile:test_pages",
|
||||
"abilities": [
|
||||
{
|
||||
"name": "TestAbility",
|
||||
"srcEntrance": "./ets/testability/TestAbility.ets",
|
||||
"description": "$string:TestAbility_desc",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:TestAbility_label",
|
||||
"visible": true,
|
||||
"startWindowIcon": "$media:icon",
|
||||
"startWindowBackground": "$color:start_window_background",
|
||||
"skills": [
|
||||
{
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
],
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"requestPermissions": [
|
||||
{
|
||||
"name": "ohos.permission.SYSTEM_FLOAT_WINDOW",
|
||||
"usedScene": {
|
||||
"abilities":[
|
||||
"EntryAbility"
|
||||
],
|
||||
"when": "inuse"
|
||||
}
|
||||
},{
|
||||
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
|
||||
},{
|
||||
"name": "ohos.permission.WRITE_MEDIA"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.READ_MEDIA"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "start_window_background",
|
||||
"value": "#FFFFFF"
|
||||
},
|
||||
{
|
||||
"name": "backgroundColor_color",
|
||||
"value": "#5a5f5a"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"float": [
|
||||
{
|
||||
"name": "200vp",
|
||||
"value": "200vp"
|
||||
},
|
||||
{
|
||||
"name": "100vp",
|
||||
"value": "100vp"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_test_desc",
|
||||
"value": "test ability description"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_desc",
|
||||
"value": "the test ability"
|
||||
},
|
||||
{
|
||||
"name": "TestAbility_label",
|
||||
"value": "test label"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
Binary file not shown.
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"src": [
|
||||
"testability/pages/BackgroundColorPage"
|
||||
]
|
||||
}
|
16
UIcompare/general/code/demo/hvigorfile.ts
Normal file
16
UIcompare/general/code/demo/hvigorfile.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
||||
export { appTasks } from '@ohos/hvigor-ohos-plugin';
|
1089
UIcompare/general/code/demo/package-lock.json
generated
Normal file
1089
UIcompare/general/code/demo/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
17
UIcompare/general/code/demo/package.json
Normal file
17
UIcompare/general/code/demo/package.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "general",
|
||||
"version": "1.0.0",
|
||||
"ohos": {
|
||||
"org": "UICompare",
|
||||
"buildTool": "hvigor",
|
||||
"directoryLevel": "project"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@ohos/hypium": "1.0.5",
|
||||
"@ohos/hvigor": "1.4.0",
|
||||
"@ohos/hvigor-ohos-plugin": "1.4.0"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user