IssueNo: #I76QN4:Contact,MultiHap ohpm适配

Description: Contact, MultiHap Ohpm adaptation.
Sig: SIG_applications_app_samples
Feature or Bugfix: Feature
Binary Source: No

Signed-off-by: zwx1094577 <zhongyuyan1@huawei.com>
This commit is contained in:
zwx1094577 2023-05-19 14:54:45 +08:00
parent 5276b3d9d5
commit 2e86ca1853
35 changed files with 831 additions and 475 deletions

View File

@ -67,7 +67,7 @@ entry/src/main/ets/
1. 本示例仅支持标准系统上运行支持设备RK3568。
2. 本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上版本才可编译运行。
2. 本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400, built on April 7, 2023)及以上版本才可编译运行。
3. 本示例已适配API version 9版本SDK版本号3.2.11.9。

View File

@ -22,7 +22,8 @@
"name": "default",
"signingConfig": "default"
}
]
],
"signingConfigs": []
},
"modules": [
{

View File

@ -0,0 +1,24 @@
/*
* 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.
*/
{
"license": "ISC",
"devDependencies": {},
"name": "entry",
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {}
}

View File

@ -1,5 +0,0 @@
{
"name": "entry",
"version": "1.0.0",
"lockfileVersion": 1
}

View File

@ -1,14 +0,0 @@
{
"license": "ISC",
"devDependencies": {},
"name": "entry",
"ohos": {
"org": "huawei",
"directoryLevel": "module",
"buildTool": "hvigor"
},
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {}
}

View File

@ -34,7 +34,7 @@ export struct Setting {
.height(32)
.margin({ left: 32, top: 32 })
.objectFit(ImageFit.Contain)
.id('back')
.id('addBack')
.onClick(() => {
router.back()
})

View File

@ -13,13 +13,13 @@
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { Driver, ON, MatchPattern } from '@ohos.UiTest'
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'
import Logger from '../../../main/ets/data/Logger'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import { Driver, ON, MatchPattern } from '@ohos.UiTest';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import Logger from '../../../main/ets/data/Logger';
const BUNDLE = 'Contact'
const TAG: string = '[Sample_Contact]'
const BUNDLE = 'Contact';
const TAG: string = '[Sample_Contact]';
export default function abilityTest() {
describe('ActsAbilityTest', function () {
@ -27,367 +27,372 @@ export default function abilityTest() {
* 打开应用
*/
it(BUNDLE + 'StartAbility_001', 0, async function (done) {
Logger.info(TAG, BUNDLE + 'StartAbility_001 begin')
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
Logger.info(TAG, BUNDLE + 'StartAbility_001 begin');
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
try {
await abilityDelegator.startAbility({
bundleName: 'ohos.samples.contact',
abilityName: 'EntryAbility'
})
done()
done();
} catch (expection) {
expect(0).assertEqual(expection.code)
Logger.info(TAG, `StartAbility end ${JSON.stringify(expection)}`)
done()
expect(0).assertEqual(expection.code);
Logger.info(TAG, `StartAbility end ${JSON.stringify(expection)}`);
done();
}
Logger.info(TAG, BUNDLE + 'StartAbility_001 end')
Logger.info(TAG, BUNDLE + 'StartAbility_001 end');
})
/**
* 获取权限
*/
it(BUNDLE + 'RequestPermissionFunction_001', 0, async () => {
Logger.info(TAG, BUNDLE + 'RequestPermissionFunction_001 begin')
let driver = await Driver.create()
await driver.delayMs(1000)
Logger.info(TAG, BUNDLE + 'RequestPermissionFunction_001 begin');
let driver = Driver.create();
await driver.delayMs(1000);
// 获取通讯录访问权限
Logger.info(TAG, BUNDLE + 'RequestPermissionFunction_001 requestPermission')
await driver.assertComponentExist(ON.text('允许'))
let btnAccept = await driver.findComponent(ON.text('允许'))
await btnAccept.click()
Logger.info(TAG, BUNDLE + 'RequestPermissionFunction_001 end')
Logger.info(TAG, BUNDLE + 'RequestPermissionFunction_001 requestPermission');
await driver.assertComponentExist(ON.text('允许'));
let btnAccept = await driver.findComponent(ON.text('允许'));
await btnAccept.click();
Logger.info(TAG, BUNDLE + 'RequestPermissionFunction_001 end');
})
/**
* 点击切换tab
*/
it(BUNDLE + 'SwitchTabFunction_001', 0, async () => {
Logger.info(TAG, BUNDLE + 'SwitchTabFunction_001 begin')
let driver = await Driver.create()
await driver.delayMs(1000)
Logger.info(TAG, BUNDLE + 'SwitchTabFunction_001 begin');
let driver = Driver.create();
await driver.delayMs(1000);
// 点击电话
Logger.info(TAG, BUNDLE + 'SwitchTabFunction_001 clickTelephone')
await driver.assertComponentExist(ON.id('tab0'))
let telephone = await driver.findComponent(ON.id('tab0'))
await telephone.click()
await driver.delayMs(1000)
Logger.info(TAG, BUNDLE + 'SwitchTabFunction_001 clickTelephone');
await driver.assertComponentExist(ON.id('tab0'));
let telephone = await driver.findComponent(ON.id('tab0'));
await telephone.click();
await driver.delayMs(1000);
// 点击收藏
Logger.info(TAG, BUNDLE + 'SwitchTabFunction_001 clickTelephone')
await driver.assertComponentExist(ON.id('tab2'))
let collection = await driver.findComponent(ON.id('tab2'))
await collection.click()
await driver.delayMs(1000)
Logger.info(TAG, BUNDLE + 'SwitchTabFunction_001 clickTelephone');
await driver.assertComponentExist(ON.id('tab2'));
let collection = await driver.findComponent(ON.id('tab2'));
await collection.click();
await driver.delayMs(1000);
// 点击联系人
Logger.info(TAG, BUNDLE + 'SwitchTabFunction_001 clickTelephone')
await driver.assertComponentExist(ON.id('tab1'))
let contact = await driver.findComponent(ON.id('tab1'))
await contact.click()
Logger.info(TAG, BUNDLE + 'SwitchTabFunction_001 clickTelephone');
await driver.assertComponentExist(ON.id('tab1'));
let contact = await driver.findComponent(ON.id('tab1'));
await contact.click();
// 成功跳转联系人页面(即进入应用主页)
await driver.assertComponentExist(ON.id('add'))
await driver.assertComponentExist(ON.id('setting'))
await driver.delayMs(1000)
Logger.info(TAG, BUNDLE + 'SwitchTabFunction_001 end')
await driver.assertComponentExist(ON.id('add'));
await driver.assertComponentExist(ON.id('setting'));
await driver.delayMs(1000);
Logger.info(TAG, BUNDLE + 'SwitchTabFunction_001 end');
})
/**
* 点击首页添加按钮
*/
it(BUNDLE + 'AddFunction_001', 0, async () => {
Logger.info(TAG, BUNDLE + 'AddFunction_001 begin')
let driver = await Driver.create()
await driver.delayMs(1000)
Logger.info(TAG, BUNDLE + 'AddFunction_001 begin');
let driver = Driver.create();
await driver.delayMs(1000);
// 点击添加按钮
await driver.assertComponentExist(ON.id('add'))
let btnAdd = await driver.findComponent(ON.id('add'))
await btnAdd.click()
await driver.delayMs(1000)
await driver.assertComponentExist(ON.id('add'));
let btnAdd = await driver.findComponent(ON.id('add'));
await btnAdd.click();
await driver.delayMs(1000);
// 跳转新建联系人页面
await driver.assertComponentExist(ON.id('cancel'))
await driver.assertComponentExist(ON.id('confirm'))
await driver.assertComponentExist(ON.id('cancel'));
await driver.assertComponentExist(ON.id('confirm'));
// 点击取消
let btnCancel = await driver.findComponent(ON.id('cancel'))
await btnCancel.click()
await driver.delayMs(1000)
let btnCancel = await driver.findComponent(ON.id('cancel'));
await btnCancel.click();
await driver.delayMs(1000);
// 返回主页
await driver.assertComponentExist(ON.id('add'))
await driver.assertComponentExist(ON.id('setting'))
await driver.assertComponentExist(ON.id('add'));
await driver.assertComponentExist(ON.id('setting'));
// 再次点击添加按钮
await btnAdd.click()
await btnAdd.click();
await driver.delayMs(1000)
// 跳转新建联系人页面
await driver.assertComponentExist(ON.id('cancel'))
await driver.assertComponentExist(ON.id('confirm'))
Logger.info(TAG, BUNDLE + 'AddFunction_001 end')
await driver.assertComponentExist(ON.id('cancel'));
await driver.assertComponentExist(ON.id('confirm'));
Logger.info(TAG, BUNDLE + 'AddFunction_001 end');
})
/**
* 添加联系人
*/
it(BUNDLE + 'AddContactFunction_001', 0, async () => {
Logger.info(TAG, BUNDLE + 'AddContactFunction_001 begin')
let driver = await Driver.create()
await driver.delayMs(1000)
Logger.info(TAG, BUNDLE + 'AddContactFunction_001 begin');
let driver = Driver.create();
await driver.delayMs(1000);
// 输入姓名
await driver.assertComponentExist(ON.id('inputName'))
let name = await driver.findComponent(ON.id('inputName'))
await name.inputText('zs')
let nameValue = await name.getText()
Logger.info(TAG, `AddContactFunction_001 name:${nameValue}`)
expect(nameValue).assertEqual('zs')
await driver.assertComponentExist(ON.id('inputName'));
let name = await driver.findComponent(ON.id('inputName'));
await name.inputText('zs');
let nameValue = await name.getText();
Logger.info(TAG, `AddContactFunction_001 name:${nameValue}`);
expect(nameValue).assertEqual('zs');
// 输入地址
await driver.assertComponentExist(ON.id('inputAddress'))
let address = await driver.findComponent(ON.id('inputAddress'))
await address.inputText('hangzhou')
let addressValue = await address.getText()
Logger.info(TAG, `AddContactFunction_001 address:${addressValue}`)
expect(addressValue).assertEqual('hangzhou')
await driver.assertComponentExist(ON.id('inputAddress'));
let address = await driver.findComponent(ON.id('inputAddress'));
await address.inputText('hangzhou');
let addressValue = await address.getText();
Logger.info(TAG, `AddContactFunction_001 address:${addressValue}`);
expect(addressValue).assertEqual('hangzhou');
// 输入电话
await driver.assertComponentExist(ON.id('inputTelephone'))
let telephone = await driver.findComponent(ON.id('inputTelephone'))
await driver.assertComponentExist(ON.id('inputTelephone'));
let telephone = await driver.findComponent(ON.id('inputTelephone'));
// 不符合规则号码
await telephone.inputText('12321465987')
let illegalTelephoneValue = await telephone.getText()
Logger.info(TAG, `AddContactFunction_001 illegalTelephone:${illegalTelephoneValue}`)
expect(illegalTelephoneValue).assertEqual('12321465987')
await telephone.inputText('12321465987');
let illegalTelephoneValue = await telephone.getText();
Logger.info(TAG, `AddContactFunction_001 illegalTelephone:${illegalTelephoneValue}`);
expect(illegalTelephoneValue).assertEqual('12321465987');
// 输入邮箱
await driver.assertComponentExist(ON.id('inputMail'))
let mail = await driver.findComponent(ON.id('inputMail'))
await mail.inputText('1505678900@163.com')
let mailValue = await mail.getText()
Logger.info(TAG, `AddContactFunction_001 mail:${mailValue}`)
expect(mailValue).assertEqual('1505678900@163.com')
await driver.assertComponentExist(ON.id('inputMail'));
let mail = await driver.findComponent(ON.id('inputMail'));
await mail.inputText('1505678900@163.com');
let mailValue = await mail.getText();
Logger.info(TAG, `AddContactFunction_001 mail:${mailValue}`);
expect(mailValue).assertEqual('1505678900@163.com');
// 点击确认按钮
await driver.assertComponentExist(ON.id('confirm'))
let btnConfirm = await driver.findComponent(ON.id('confirm'))
await btnConfirm.click()
await driver.assertComponentExist(ON.id('confirm'));
let btnConfirm = await driver.findComponent(ON.id('confirm'));
await btnConfirm.click();
// 返回主页失败添加联系人失败当前仍停留在添加联系人页面并弹出toast提示please input phone numbertoast弹窗暂不支持测试
await driver.assertComponentExist(ON.id('cancel'))
await driver.assertComponentExist(ON.id('confirm'))
await driver.assertComponentExist(ON.id('cancel'));
await driver.assertComponentExist(ON.id('confirm'));
// 再次输入电话,输入符合规则号码
await telephone.inputText('15321465987')
let legalTelephoneValue = await telephone.getText()
Logger.info(TAG, `AddContactFunction_001 legalTelephone:${legalTelephoneValue}`)
expect(legalTelephoneValue).assertEqual('15321465987')
await telephone.inputText('15321465987');
let legalTelephoneValue = await telephone.getText();
Logger.info(TAG, `AddContactFunction_001 legalTelephone:${legalTelephoneValue}`);
expect(legalTelephoneValue).assertEqual('15321465987');
// 点击确认按钮
await btnConfirm.click()
await btnConfirm.click();
// 返回主页
await driver.assertComponentExist(ON.id('add'))
await driver.assertComponentExist(ON.id('setting'))
Logger.info(TAG, BUNDLE + 'AddContactFunction_001 end')
await driver.assertComponentExist(ON.id('add'));
await driver.assertComponentExist(ON.id('setting'));
Logger.info(TAG, BUNDLE + 'AddContactFunction_001 end');
})
/**
* 编辑联系人
*/
it(BUNDLE + 'EditContactFunction_001', 0, async () => {
Logger.info(TAG, BUNDLE + 'EditContactFunction_001 begin')
let driver = await Driver.create()
await driver.delayMs(1000)
Logger.info(TAG, BUNDLE + 'EditContactFunction_001 begin');
let driver = Driver.create();
await driver.delayMs(1000);
// 点击联系人列表
await driver.assertComponentExist(ON.id('contactList'))
let contactList = await driver.findComponent(ON.id('contactList'))
await contactList.click()
await driver.assertComponentExist(ON.id('contactList'));
let contactList = await driver.findComponent(ON.id('contactList'));
await contactList.click();
// 跳转联系人卡片详情页
await driver.assertComponentExist(ON.id('back'))
await driver.assertComponentExist(ON.id('editContact'))
await driver.assertComponentExist(ON.id('deleteContact'))
await driver.assertComponentExist(ON.id('back'));
await driver.assertComponentExist(ON.id('editContact'));
await driver.assertComponentExist(ON.id('deleteContact'));
// 点击编辑按钮
let btnEdit = await driver.findComponent(ON.id('editContact'))
await btnEdit.click()
let btnEdit = await driver.findComponent(ON.id('editContact'));
await btnEdit.click();
// 跳转到编辑联系人页面
await driver.assertComponentExist(ON.id('cancelEdit'))
await driver.assertComponentExist(ON.id('confirmEdit'))
await driver.assertComponentExist(ON.id('cancelEdit'));
await driver.assertComponentExist(ON.id('confirmEdit'));
// 点击取消
await driver.assertComponentExist(ON.id('cancelEdit'))
let btnCancel = await driver.findComponent(ON.id('cancelEdit'))
await btnCancel.click()
await driver.delayMs(1000)
await driver.assertComponentExist(ON.id('cancelEdit'));
let btnCancel = await driver.findComponent(ON.id('cancelEdit'));
await btnCancel.click();
await driver.delayMs(1000);
// 跳转联系人卡片详情页
await driver.assertComponentExist(ON.id('back'))
await driver.assertComponentExist(ON.id('editContact'))
await driver.assertComponentExist(ON.id('deleteContact'))
await driver.assertComponentExist(ON.id('back'));
await driver.assertComponentExist(ON.id('editContact'));
await driver.assertComponentExist(ON.id('deleteContact'));
// 再次点击编辑按钮
await driver.delayMs(1000)
await btnEdit.click()
await driver.delayMs(1000);
await btnEdit.click();
// 跳转到编辑联系人页面
await driver.assertComponentExist(ON.id('cancelEdit'))
await driver.assertComponentExist(ON.id('confirmEdit'))
await driver.assertComponentExist(ON.id('cancelEdit'));
await driver.assertComponentExist(ON.id('confirmEdit'));
// 更新联系人姓名
await driver.assertComponentExist(ON.id('updateName'))
let updateName = await driver.findComponent(ON.id('updateName'))
await updateName.inputText('lisi')
let nameValue = await updateName.getText()
Logger.info(TAG, `EditContactFunction_001 name:${nameValue}`)
expect(nameValue).assertEqual('lisi')
await driver.assertComponentExist(ON.id('updateName'));
let updateName = await driver.findComponent(ON.id('updateName'));
await updateName.inputText('lisi');
let nameValue = await updateName.getText();
Logger.info(TAG, `EditContactFunction_001 name:${nameValue}`);
expect(nameValue).assertEqual('lisi');
// 更新联系人地址
await driver.assertComponentExist(ON.id('updateAddress'))
let updateAddress = await driver.findComponent(ON.id('updateAddress'))
await updateAddress.inputText('beijing')
let addressValue = await updateAddress.getText()
Logger.info(TAG, `EditContactFunction_001 address:${addressValue}`)
expect(addressValue).assertEqual('beijing')
await driver.assertComponentExist(ON.id('updateAddress'));
let updateAddress = await driver.findComponent(ON.id('updateAddress'));
await updateAddress.inputText('beijing');
let addressValue = await updateAddress.getText();
Logger.info(TAG, `EditContactFunction_001 address:${addressValue}`);
expect(addressValue).assertEqual('beijing');
// 更新电话(输入不符合规则号码)
await driver.assertComponentExist(ON.id('updateTelephone'))
let updateTelephone = await driver.findComponent(ON.id('updateTelephone'))
await updateTelephone.inputText('12326421968')
let illegalUpdatePhoneNumber = await updateTelephone.getText()
Logger.info(TAG, `EditContactFunction_001 illegalUpdatePhoneNumber:${illegalUpdatePhoneNumber}`)
expect(illegalUpdatePhoneNumber).assertEqual('12326421968')
await driver.assertComponentExist(ON.id('updateTelephone'));
let updateTelephone = await driver.findComponent(ON.id('updateTelephone'));
await updateTelephone.inputText('12326421968');
let illegalUpdatePhoneNumber = await updateTelephone.getText();
Logger.info(TAG, `EditContactFunction_001 illegalUpdatePhoneNumber:${illegalUpdatePhoneNumber}`);
expect(illegalUpdatePhoneNumber).assertEqual('12326421968');
// 更新邮箱
await driver.assertComponentExist(ON.id('updateMail'))
let updateMail = await driver.findComponent(ON.id('updateMail'))
await updateMail.inputText('1506589700@qq.com')
let mailValue = await updateMail.getText()
Logger.info(TAG, `EditContactFunction_001 mail:${mailValue}`)
expect(mailValue).assertEqual('1506589700@qq.com')
await driver.assertComponentExist(ON.id('updateMail'));
let updateMail = await driver.findComponent(ON.id('updateMail'));
await updateMail.inputText('1506589700@qq.com');
let mailValue = await updateMail.getText();
Logger.info(TAG, `EditContactFunction_001 mail:${mailValue}`);
expect(mailValue).assertEqual('1506589700@qq.com');
// 点击确认按钮
await driver.assertComponentExist(ON.id('confirmEdit'))
let btnConfirm = await driver.findComponent(ON.id('confirmEdit'))
await btnConfirm.click()
await driver.assertComponentExist(ON.id('confirmEdit'));
let btnConfirm = await driver.findComponent(ON.id('confirmEdit'));
await btnConfirm.click();
// 返回主页失败更新联系人失败当前仍停留在更新联系人页面并弹出toast提示please input phone numbertoast弹窗暂不支持测试
await driver.assertComponentExist(ON.id('cancelEdit'))
await driver.assertComponentExist(ON.id('confirmEdit'))
await driver.assertComponentExist(ON.id('cancelEdit'));
await driver.assertComponentExist(ON.id('confirmEdit'));
// 再次输入电话,输入符合规则号码
await updateTelephone.inputText('15321143568')
let legalUpdatePhoneNumber = await updateTelephone.getText()
Logger.info(TAG, `EditContactFunction_001 legalUpdatePhoneNumber:${legalUpdatePhoneNumber}`)
expect(legalUpdatePhoneNumber).assertEqual('15321143568')
await updateTelephone.inputText('15321143568');
let legalUpdatePhoneNumber = await updateTelephone.getText();
Logger.info(TAG, `EditContactFunction_001 legalUpdatePhoneNumber:${legalUpdatePhoneNumber}`);
expect(legalUpdatePhoneNumber).assertEqual('15321143568');
// 点击确认按钮
await btnConfirm.click()
await btnConfirm.click();
// 跳转回主页
await driver.assertComponentExist(ON.id('add'))
await driver.assertComponentExist(ON.id('setting'))
Logger.info(TAG, BUNDLE + 'EditContactFunction_001 end')
await driver.assertComponentExist(ON.id('add'));
await driver.assertComponentExist(ON.id('setting'));
Logger.info(TAG, BUNDLE + 'EditContactFunction_001 end');
})
/**
* 查询联系人
*/
it(BUNDLE + 'QueryContactFunction_001', 0, async () => {
Logger.info(TAG, BUNDLE + 'QueryContactFunction_001 begin')
let driver = await Driver.create()
await driver.delayMs(1000)
Logger.info(TAG, BUNDLE + 'QueryContactFunction_001 begin');
let driver = Driver.create();
await driver.delayMs(1000);
// 输入要查询的联系人号码
await driver.assertComponentExist(ON.id('inputContact'))
let inputContact = await driver.findComponent(ON.id('inputContact'))
await inputContact.inputText('15321143568')
let contactInfo = await inputContact.getText()
Logger.info(TAG, `QueryContactFunction_001 contact:${contactInfo}`)
expect(contactInfo).assertEqual('15321143568')
await driver.assertComponentExist(ON.id('inputContact'));
let inputContact = await driver.findComponent(ON.id('inputContact'));
await inputContact.inputText('15321143568');
let contactInfo = await inputContact.getText();
Logger.info(TAG, `QueryContactFunction_001 contact:${contactInfo}`);
expect(contactInfo).assertEqual('15321143568');
// 点击键盘回车键跳转到卡片详情页
await driver.triggerKey(2054)
await driver.triggerKey(2054);
// 跳转联系人卡片详情页
await driver.assertComponentExist(ON.id('back'))
await driver.assertComponentExist(ON.id('editContact'))
await driver.assertComponentExist(ON.id('deleteContact'))
Logger.info(TAG, BUNDLE + 'QueryContactFunction_001 end')
await driver.assertComponentExist(ON.id('back'));
await driver.assertComponentExist(ON.id('editContact'));
await driver.assertComponentExist(ON.id('deleteContact'));
Logger.info(TAG, BUNDLE + 'QueryContactFunction_001 end');
})
/**
* 删除联系人
*/
it(BUNDLE + 'DeleteContactFunction_001', 0, async () => {
Logger.info(TAG, BUNDLE + 'DeleteContactFunction_001 begin')
let driver = await Driver.create()
await driver.delayMs(1000)
Logger.info(TAG, BUNDLE + 'DeleteContactFunction_001 begin');
let driver = Driver.create();
await driver.delayMs(1000);
// 点击删除按钮删除联系人
await driver.assertComponentExist(ON.id('deleteContact'))
let deleteContact = await driver.findComponent(ON.id('deleteContact'))
await deleteContact.click()
await driver.assertComponentExist(ON.id('deleteContact'));
let deleteContact = await driver.findComponent(ON.id('deleteContact'));
await deleteContact.click();
// 弹出警告弹窗
await driver.assertComponentExist(ON.text('确认'))
await driver.assertComponentExist(ON.text('取消'))
await driver.assertComponentExist(ON.text('确认'));
await driver.assertComponentExist(ON.text('取消'));
// 点击取消按钮,弹窗消失
await driver.assertComponentExist(ON.text('取消'))
let btnCancel = await driver.findComponent(ON.text('取消'))
await btnCancel.click()
await driver.assertComponentExist(ON.text('取消'));
let btnCancel = await driver.findComponent(ON.text('取消'));
await btnCancel.click();
// 停留在联系人卡片详情页
await driver.assertComponentExist(ON.id('back'))
await driver.assertComponentExist(ON.id('editContact'))
await driver.assertComponentExist(ON.id('deleteContact'))
await driver.assertComponentExist(ON.id('back'));
await driver.assertComponentExist(ON.id('editContact'));
await driver.assertComponentExist(ON.id('deleteContact'));
// 再次点击删除
await deleteContact.click()
await driver.delayMs(1000)
await deleteContact.click();
await driver.delayMs(1000);
// 点击确认
await driver.assertComponentExist(ON.text('确认'))
let btnConfirm = await driver.findComponent(ON.text('确认'))
await btnConfirm.click()
await driver.assertComponentExist(ON.text('确认'));
let btnConfirm = await driver.findComponent(ON.text('确认'));
await btnConfirm.click();
// 跳转回主页
await driver.assertComponentExist(ON.id('add'))
await driver.assertComponentExist(ON.id('setting'))
Logger.info(TAG, BUNDLE + 'DeleteContactFunction_001 end')
await driver.assertComponentExist(ON.id('add'));
await driver.assertComponentExist(ON.id('setting'));
Logger.info(TAG, BUNDLE + 'DeleteContactFunction_001 end');
})
/**
* 设置
*/
it(BUNDLE + 'ClickSettingFunction_001', 0, async () => {
Logger.info(TAG, BUNDLE + 'ClickMoreFunction_001 begin')
let driver = await Driver.create()
await driver.delayMs(1000)
Logger.info(TAG, BUNDLE + 'ClickMoreFunction_001 begin');
let driver = Driver.create();
await driver.delayMs(1000);
// 点击设置按钮
await driver.assertComponentExist(ON.id('setting'))
let btnSetting = await driver.findComponent(ON.id('setting'))
await btnSetting.click()
await driver.assertComponentExist(ON.id('setting'));
let btnSetting = await driver.findComponent(ON.id('setting'));
await btnSetting.click();
// 跳转到设置页面
await driver.assertComponentExist(ON.id('back'))
await driver.assertComponentExist(ON.id('addContact'))
await driver.assertComponentExist(ON.id('importFile'))
await driver.assertComponentExist(ON.id('exportFile'))
await driver.assertComponentExist(ON.id('addBack'));
await driver.assertComponentExist(ON.id('addContact'));
await driver.assertComponentExist(ON.id('importFile'));
await driver.assertComponentExist(ON.id('exportFile'));
// 点击导入文件
let importFile = await driver.findComponent(ON.id('importFile'))
await importFile.click()
let importFile = await driver.findComponent(ON.id('importFile'));
await importFile.click();
// 点击导出文件
let exportFile = await driver.findComponent(ON.id('exportFile'))
await exportFile.click()
let exportFile = await driver.findComponent(ON.id('exportFile'));
await exportFile.click();
// 点击新建联系人
let addNewContact = await driver.findComponent(ON.id('addContact'))
await addNewContact.click()
let addNewContact = await driver.findComponent(ON.id('addContact'));
await addNewContact.click();
// 跳转到新建联系人界面
await driver.assertComponentExist(ON.id('cancel'))
await driver.assertComponentExist(ON.id('confirm'))
await driver.assertComponentExist(ON.id('cancel'));
await driver.assertComponentExist(ON.id('confirm'));
// 输入姓名
await driver.assertComponentExist(ON.id('inputName'))
let contactName = await driver.findComponent(ON.id('inputName'))
await contactName.inputText('liyi')
let name = await contactName.getText()
Logger.info(TAG, `ClickSettingFunction_001 name:${name}`)
expect(name).assertEqual('liyi')
await driver.assertComponentExist(ON.id('inputName'));
let contactName = await driver.findComponent(ON.id('inputName'));
await contactName.inputText('liyi');
let name = await contactName.getText();
Logger.info(TAG, `ClickSettingFunction_001 name:${name}`);
expect(name).assertEqual('liyi');
// 输入地址
await driver.assertComponentExist(ON.id('inputAddress'))
let address = await driver.findComponent(ON.id('inputAddress'))
await address.inputText('shanghai')
let addressValue = await address.getText()
Logger.info(TAG, `ClickSettingFunction_001 address:${addressValue}`)
expect(addressValue).assertEqual('shanghai')
await driver.assertComponentExist(ON.id('inputAddress'));
let address = await driver.findComponent(ON.id('inputAddress'));
await address.inputText('shanghai');
let addressValue = await address.getText();
Logger.info(TAG, `ClickSettingFunction_001 address:${addressValue}`);
expect(addressValue).assertEqual('shanghai');
// 输入电话
await driver.assertComponentExist(ON.id('inputTelephone'))
let phone = await driver.findComponent(ON.id('inputTelephone'))
await driver.assertComponentExist(ON.id('inputTelephone'));
let phone = await driver.findComponent(ON.id('inputTelephone'));
// 不符合规则号码
await phone.inputText('12695874569')
let illegalPhoneNumber = await phone.getText()
Logger.info(TAG, `ClickSettingFunction_001 illegalPhoneNumber:${illegalPhoneNumber}`)
expect(illegalPhoneNumber).assertEqual('12695874569')
await phone.inputText('12695874569');
let illegalPhoneNumber = await phone.getText();
Logger.info(TAG, `ClickSettingFunction_001 illegalPhoneNumber:${illegalPhoneNumber}`);
expect(illegalPhoneNumber).assertEqual('12695874569');
// 输入邮箱
await driver.assertComponentExist(ON.id('inputMail'))
let mail = await driver.findComponent(ON.id('inputMail'))
await mail.inputText('1607365260@139.com')
let mailValue = await mail.getText()
Logger.info(TAG, `ClickSettingFunction_001 mail:${mailValue}`)
expect(mailValue).assertEqual('1607365260@139.com')
await driver.assertComponentExist(ON.id('inputMail'));
let mail = await driver.findComponent(ON.id('inputMail'));
await mail.inputText('1607365260@139.com');
let mailValue = await mail.getText();
Logger.info(TAG, `ClickSettingFunction_001 mail:${mailValue}`);
expect(mailValue).assertEqual('1607365260@139.com');
// 点击确认按钮
await driver.assertComponentExist(ON.id('confirm'))
let btnConfirm = await driver.findComponent(ON.id('confirm'))
await btnConfirm.click()
await driver.assertComponentExist(ON.id('confirm'));
let btnConfirm = await driver.findComponent(ON.id('confirm'));
await btnConfirm.click();
// 返回主页失败添加联系人失败当前仍停留在添加联系人页面并弹出toast提示please input phone numbertoast弹窗暂不支持测试
await driver.assertComponentExist(ON.id('cancel'))
await driver.assertComponentExist(ON.id('confirm'))
await driver.assertComponentExist(ON.id('cancel'));
await driver.assertComponentExist(ON.id('confirm'));
// 再次输入电话,输入符合规则号码
await phone.inputText('17322305685')
let legalPhoneNumber = await phone.getText()
Logger.info(TAG, `ClickSettingFunction_001 legalPhoneNumber:${legalPhoneNumber}`)
expect(legalPhoneNumber).assertEqual('17322305685')
await phone.inputText('17322305685');
let legalPhoneNumber = await phone.getText();
Logger.info(TAG, `ClickSettingFunction_001 legalPhoneNumber:${legalPhoneNumber}`);
expect(legalPhoneNumber).assertEqual('17322305685');
// 点击确认按钮
await btnConfirm.click()
await btnConfirm.click();
// 返回主页
await driver.assertComponentExist(ON.id('add'))
await driver.assertComponentExist(ON.id('setting'))
Logger.info(TAG, BUNDLE + 'ClickSettingFunction_001 end')
await driver.assertComponentExist(ON.id('add'));
await driver.assertComponentExist(ON.id('setting'));
Logger.info(TAG, BUNDLE + 'ClickSettingFunction_001 end');
})
})
}

View File

@ -13,8 +13,8 @@
* limitations under the License.
*/
import abilityTest from './Ability.test'
import abilityTest from './Ability.test';
export default function testsuite() {
abilityTest()
abilityTest();
}

View File

@ -0,0 +1,21 @@
/*
* 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.
*/
{
"hvigorVersion": "2.0.0",
"dependencies": {
"@ohos/hvigor-ohos-plugin": "2.0.0"
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,61 @@
#!/bin/bash
# ----------------------------------------------------------------------------
# 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.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Hvigor startup script, version 1.0.0
#
# Required ENV vars:
# ------------------
# NODE_HOME - location of a Node home dir
# or
# Add /usr/local/nodejs/bin to the PATH environment variable
# ----------------------------------------------------------------------------
HVIGOR_APP_HOME=$(dirname $(readlink -f $0))
HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js
warn() {
echo ""
echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
}
error() {
echo ""
echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
}
fail() {
error "$@"
exit 1
}
# Determine node to start hvigor wrapper script
if [ -n "${NODE_HOME}" ];then
EXECUTABLE_NODE="${NODE_HOME}/bin/node"
if [ ! -x "$EXECUTABLE_NODE" ];then
fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed"
fi
else
EXECUTABLE_NODE="node"
which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path"
fi
# Check hvigor wrapper script
if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then
fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}"
fi
# start hvigor-wrapper script
exec "${EXECUTABLE_NODE}" \
"${HVIGOR_WRAPPER_SCRIPT}" "$@"

View File

@ -0,0 +1,72 @@
:: 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.
@echo off
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Hvigor startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js
set NODE_EXE=node.exe
goto start
:start
@rem Find node.exe
if defined NODE_HOME goto findNodeFromNodeHome
%NODE_EXE% --version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
echo.
echo Please set the NODE_HOME variable in your environment to match the
echo location of your NodeJs installation.
goto fail
:findNodeFromNodeHome
set NODE_HOME=%NODE_HOME:"=%
set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE%
if exist "%NODE_EXE_PATH%" goto execute
echo.
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
echo.
echo Please set the NODE_HOME variable in your environment to match the
echo location of your NodeJs installation.
goto fail
:execute
@rem Execute hvigor
"%NODE_EXE%" %WRAPPER_MODULE_PATH% %*
:fail
exit /b 1

View File

@ -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.
*/
{
"license": "ISC",
"devDependencies": {
"@ohos/hypium": "1.0.6"
},
"name": "contact",
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {}
}

View File

@ -1,18 +0,0 @@
{
"license": "ISC",
"devDependencies": {},
"name": "contact",
"ohos": {
"org": "huawei",
"directoryLevel": "project",
"buildTool": "hvigor"
},
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {
"@ohos/hypium": "1.0.3",
"@ohos/hvigor-ohos-plugin": "1.3.1",
"@ohos/hvigor": "1.3.1"
}
}

View File

@ -96,7 +96,7 @@ feature应用的特性模块一个应用中可以包含一个或者多个f
2.本示例已适配API version 9版本SDK版本号3.2.11.9
3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上版本才可编译运行。
3.本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400, built on April 7, 2023)及以上版本才可编译运行。
### 下载

View File

@ -0,0 +1,24 @@
/*
* 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.
*/
{
"license": "ISC",
"devDependencies": {},
"name": "audiofeature",
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {}
}

View File

@ -1,5 +0,0 @@
{
"name": "audio_feature",
"version": "1.0.0",
"lockfileVersion": 1
}

View File

@ -1,14 +0,0 @@
{
"license":"ISC",
"devDependencies":{},
"name":"audiofeature",
"ohos":{
"org":"huawei",
"directoryLevel":"module",
"buildTool":"hvigor"
},
"description":"example description",
"repository":{},
"version":"1.0.0",
"dependencies":{}
}

View File

@ -15,8 +15,7 @@
{
"app": {
"signingConfigs": [
],
"signingConfigs": [],
"compileSdkVersion": 9,
"compatibleSdkVersion": 9,
"products": [

View File

@ -0,0 +1,24 @@
/*
* 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.
*/
{
"license": "ISC",
"devDependencies": {},
"name": "entry",
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {}
}

View File

@ -1,5 +0,0 @@
{
"name": "entry",
"version": "1.0.0",
"lockfileVersion": 1
}

View File

@ -1,14 +0,0 @@
{
"license":"ISC",
"devDependencies":{},
"name":"entry",
"ohos":{
"org":"huawei",
"directoryLevel":"module",
"buildTool":"hvigor"
},
"description":"example description",
"repository":{},
"version":"1.0.0",
"dependencies":{}
}

View File

@ -20,60 +20,59 @@ var abilityDelegator = undefined;
var abilityDelegatorArguments = undefined;
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
]);
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
]);
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
return targetParams.trim();
}
return targetParams.trim();
}
async function onAbilityCreateCallback() {
Logger.info('testTag', '%{public}s', 'onAbilityCreateCallback');
Logger.info('testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
Logger.info('testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
Logger.info('testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
constructor() {
}
onPrepare() {
Logger.info('testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
onPrepare() {
Logger.info('testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
Logger.info('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;
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters);
var debug = abilityDelegatorArguments.parameters['-D'];
if (debug == 'true')
{
cmd += ' -D';
}
Logger.info('testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
Logger.info('testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
Logger.info('testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
Logger.info('testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
Logger.info('testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
async onRun() {
Logger.info('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;
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters);
var debug = abilityDelegatorArguments.parameters['-D'];
if (debug == 'true') {
cmd += ' -D';
}
Logger.info('testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
Logger.info('testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
Logger.info('testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
Logger.info('testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
Logger.info('testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}

View File

@ -20,43 +20,43 @@ import testsuite from '../test/List.test';
import Window from '@ohos.window';
export default class TestAbility extends UIAbility {
onCreate(want, launchParam) {
Logger.info('testTag', '%{public}s', 'TestAbility onCreate');
Logger.info('testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
Logger.info('testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
var abilityDelegator: any;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var abilityDelegatorArguments: any;
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
Logger.info('testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite);
}
onCreate(want, launchParam) {
Logger.info('testTag', '%{public}s', 'TestAbility onCreate');
Logger.info('testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
Logger.info('testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
var abilityDelegator: any;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var abilityDelegatorArguments: any;
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
Logger.info('testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite);
}
onDestroy() {
Logger.info('testTag', '%{public}s', 'TestAbility onDestroy');
}
onDestroy() {
Logger.info('testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
Logger.info('testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('testability/pages/Index', (err, data) => {
if (err.code) {
Logger.error('testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
Logger.info('testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageCreate(windowStage: Window.WindowStage) {
Logger.info('testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('testability/pages/Index', (err, data) => {
if (err.code) {
Logger.error('testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
Logger.info('testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
Logger.info('testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onWindowStageDestroy() {
Logger.info('testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
Logger.info('testTag', '%{public}s', 'TestAbility onForeground');
}
onForeground() {
Logger.info('testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
Logger.info('testTag', '%{public}s', 'TestAbility onBackground');
}
onBackground() {
Logger.info('testTag', '%{public}s', 'TestAbility onBackground');
}
}

View File

@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Logger from '../../utils/Logger';
@Entry
@ -20,29 +21,32 @@ struct Index {
aboutToAppear() {
Logger.info('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%')
}
}
@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%')
}
}

View File

@ -0,0 +1,21 @@
/*
* 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.
*/
{
"hvigorVersion": "2.0.0",
"dependencies": {
"@ohos/hvigor-ohos-plugin": "2.0.0"
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,61 @@
#!/bin/bash
# ----------------------------------------------------------------------------
# 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.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Hvigor startup script, version 1.0.0
#
# Required ENV vars:
# ------------------
# NODE_HOME - location of a Node home dir
# or
# Add /usr/local/nodejs/bin to the PATH environment variable
# ----------------------------------------------------------------------------
HVIGOR_APP_HOME=$(dirname $(readlink -f $0))
HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js
warn() {
echo ""
echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
}
error() {
echo ""
echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
}
fail() {
error "$@"
exit 1
}
# Determine node to start hvigor wrapper script
if [ -n "${NODE_HOME}" ];then
EXECUTABLE_NODE="${NODE_HOME}/bin/node"
if [ ! -x "$EXECUTABLE_NODE" ];then
fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed"
fi
else
EXECUTABLE_NODE="node"
which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path"
fi
# Check hvigor wrapper script
if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then
fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}"
fi
# start hvigor-wrapper script
exec "${EXECUTABLE_NODE}" \
"${HVIGOR_WRAPPER_SCRIPT}" "$@"

View File

@ -0,0 +1,72 @@
:: 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.
@echo off
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Hvigor startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js
set NODE_EXE=node.exe
goto start
:start
@rem Find node.exe
if defined NODE_HOME goto findNodeFromNodeHome
%NODE_EXE% --version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
echo.
echo Please set the NODE_HOME variable in your environment to match the
echo location of your NodeJs installation.
goto fail
:findNodeFromNodeHome
set NODE_HOME=%NODE_HOME:"=%
set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE%
if exist "%NODE_EXE_PATH%" goto execute
echo.
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
echo.
echo Please set the NODE_HOME variable in your environment to match the
echo location of your NodeJs installation.
goto fail
:execute
@rem Execute hvigor
"%NODE_EXE%" %WRAPPER_MODULE_PATH% %*
:fail
exit /b 1

View File

@ -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.
*/
{
"license": "ISC",
"devDependencies": {
"@ohos/hypium": "1.0.6"
},
"name": "multihap",
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {}
}

View File

@ -1,18 +0,0 @@
{
"license": "ISC",
"devDependencies": {},
"name": "multihap",
"ohos": {
"org": "huawei",
"directoryLevel": "project",
"buildTool": "hvigor"
},
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {
"@ohos/hypium": "1.0.2",
"@ohos/hvigor-ohos-plugin": "1.2.2",
"@ohos/hvigor": "1.2.2"
}
}

View File

@ -0,0 +1,24 @@
/*
* 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.
*/
{
"license": "ISC",
"devDependencies": {},
"name": "videofeature",
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {}
}

View File

@ -1,5 +0,0 @@
{
"name": "video_feature",
"version": "1.0.0",
"lockfileVersion": 1
}

View File

@ -1,14 +0,0 @@
{
"license":"ISC",
"devDependencies":{},
"name":"videofeature",
"ohos":{
"org":"huawei",
"directoryLevel":"module",
"buildTool":"hvigor"
},
"description":"example description",
"repository":{},
"version":"1.0.0",
"dependencies":{}
}