未验证 提交 64ea3045 编写于 作者: O openharmony_ci 提交者: Gitee

!8980 UX二期 swiper 菜单 list自动回滚 文本框组件相关XTS

Merge pull request !8980 from sunjiakun/UXII8.2
......@@ -21,6 +21,8 @@ group("componentUxTest") {
"ace_ets_component_clickeffect:ActsAceClickEffectTest",
"ace_ets_component_datapanel:ActsAceDatapanelTest",
"ace_ets_component_datepicker:ActsAceDatePickerTest",
"ace_ets_component_list:ActsAceListTest",
"ace_ets_component_menu:ActsAceMenuTest",
"ace_ets_component_popup:ActsAcePopupTest",
"ace_ets_component_progress:ActsAceProgressTest",
"ace_ets_component_radio:ActsAceRadioTest",
......@@ -31,6 +33,7 @@ group("componentUxTest") {
"ace_ets_component_swiper:ActsAceSwiperTest",
"ace_ets_component_tabs:ActsAceTabsTest",
"ace_ets_component_text:ActsAceTextTest",
"ace_ets_component_textarea:ActsAceTextAreaTest",
"ace_ets_component_textinput:ActsAceTextInputTest",
"ace_ets_component_textpicker:ActsAceTextPickerTest",
"ace_ets_component_timepicker:ActsAceTimePickerTest",
......
{
"app": {
"bundleName": "com.example.listtest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string":[
{
"name":"app_name",
"value":"MyApplication"
}
]
}
\ No newline at end of file
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAceListTest") {
hap_profile = "src/main/module.json"
js_build_mode = "debug"
deps = [
":ace_ets_component_list_js_assets",
":ace_ets_component_list_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAceListTest"
part_name = "ace_engine"
subsystem_name = "arkui"
}
ohos_app_scope("ace_ets_component_list_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ace_ets_component_list_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("ace_ets_component_list_resources") {
sources = [ "src/main/resources" ]
deps = [ ":ace_ets_component_list_profile" ]
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.listtest",
"module-name": "entry_test",
"shell-timeout": "600000",
"testcase-timeout": 240000
},
"kits": [{
"test-file-name": [
"ActsAceListTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602"
]
}
]
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import testsuite from '../test/List.test'
import Window from '@ohos.window'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
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) ?? '');
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import hilog from '@ohos.hilog';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import Curves from '@ohos.curves';
@Entry
@Component
struct Index {
private scrollerForList: Scroller = new Scroller()
@State message: string = 'Hello World'
aboutToAppear(){
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)
}
build() {
Row() {
Column() {
List({ space: "4vp", initialIndex: 0 ,scroller: this.scrollerForList }) {
ListItem(){
Button("scrollTo自定义弹簧曲线测试(Curves.springCurve(7, 1, 227, 33))")
.key("scrollerForList")
.onClick(() => {
let curve = Curves.springCurve(7, 1, 227, 33)
this.scrollerForList.scrollTo({ xOffset: 0,
yOffset: this.scrollerForList.currentOffset().yOffset + 600,
animation:true })
})
.height(45)
.width('80%')
.fontSize(13)
}
}
.key("RollBack")
.multiSelectable(true)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
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]}`;
}
}
return targetParams.trim();
}
async function onAbilityCreateCallback() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err): Promise<void> {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility';
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters);
let debug = abilityDelegatorArguments.parameters['-D'];
if (debug == 'true') {
cmd += ' -D';
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err, d) => {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
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');
}
}
/*
* 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 listTest from './list'
export default function testsuite() {
listTest()
}
\ No newline at end of file
/*
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function abilityTest() {
describe('ActsAceListTest', function () {
/**
* @tc.number ArkUX_Stage_List_RollBack_0100
* @tc.name Testing the rolling back effect of the list and adding new parameters
* @tc.desc ScrollerForList calls the interface scrollTo(), and the animation parameter is passed in as true
*/
it('ArkUX_Stage_List_RollBack_0100', 0, function () {
try {
sendEventByKey("scrollerForList", 10, "")
let obj = JSON.stringify(JSON.parse(getInspectorByKey("RollBack")).$attrs.scrollerForList)
expect(obj).assertEqual(undefined)
} catch (err) {
console.info('ArkUX_Stage_List_RollBack_0100 ERR ' + JSON.stringify(err));
expect().assertFail();
}
})
})
}
{
"module": {
"name": "entry_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"metadata": [{
"name": "ArkTSPartialUpdate",
"value": "true"
}],
"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"
]
}
]
}
]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
},
{
"name": "Divider_color",
"value": "#000000"
},
{
"name": "badge_BorderColor",
"value": "#FFFD0000"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
},
{
"name": "Divider_width",
"value": "10px"
},
{
"name": "Divider_startMargin",
"value": "5px"
},
{
"name": "Divider_endMargin",
"value": "5px"
},
{
"name": "badge_Size_test",
"value": "7vp"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.menutest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string":[
{
"name":"app_name",
"value":"MyApplication"
}
]
}
\ No newline at end of file
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAceMenuTest") {
hap_profile = "src/main/module.json"
js_build_mode = "debug"
deps = [
":ace_ets_component_menu_js_assets",
":ace_ets_component_menu_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAceMenuTest"
part_name = "ace_engine"
subsystem_name = "arkui"
}
ohos_app_scope("ace_ets_component_menu_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ace_ets_component_menu_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("ace_ets_component_menu_resources") {
sources = [ "src/main/resources" ]
deps = [ ":ace_ets_component_menu_profile" ]
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.menutest",
"module-name": "entry_test",
"shell-timeout": "600000",
"testcase-timeout": 240000
},
"kits": [{
"test-file-name": [
"ActsAceMenuTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602"
]
}
]
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import testsuite from '../test/List.test'
import Window from '@ohos.window'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
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) ?? '');
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//@ts-nocheck
import hilog from '@ohos.hilog';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
@Entry
@Component
struct Index {
@State select: boolean = true
@State arrowOffset: number = 0
private iconStr: ResourceStr = $r("app.media.icon")
@Builder
ThreeLevelMenu() {
Menu() {
MenuItem({ content: "复制", labelInfo: "Ctrl+C" })
MenuItem({ content: "粘贴", labelInfo: "Ctrl+V" })
}
}
@Builder
MyMenu(){
Menu() {
MenuItem({ startIcon: $r("app.media.icon"), content: "菜单选项" }).selectIcon(true).selected(false)
MenuItem({ startIcon: $r("app.media.icon"), content: "菜单选项" }).selectIcon(true).selected(false)
MenuItem({
startIcon: this.iconStr,
content: "菜单选项",
}).selectIcon(true).selected(false)
MenuItemGroup({ header: '小标题' }) {
MenuItem({ startIcon: this.iconStr, content: "菜单选项" })
.selectIcon(true)
.selected(this.select)
.onChange((selected) => {
console.info("menuItem select" + selected);
})
MenuItem({
startIcon: this.iconStr,
content: "菜单选项",
}).selectIcon(true).selected(false)
MenuItem({
startIcon: $r("app.media.icon"),
content: "菜单选项",
}).selectIcon(true).selected(false)
}
}
}
aboutToAppear() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
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)
}
build() {
Column() {
Column() {
Text('右键点击弹出菜单')
.key("menu")
.fontWeight(FontWeight.Bold)
.fontSize(30)
.padding({ top: 20 })
.bindContextMenu(this.MyMenu, ResponseType.RightClick, {enableArrow: true,arrowOffset:this.arrowOffset})
}.height('40%')
}.height('100%')
.width('100%')
.backgroundColor('#f0f0f0')
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
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]}`;
}
}
return targetParams.trim();
}
async function onAbilityCreateCallback() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err): Promise<void> {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility';
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters);
let debug = abilityDelegatorArguments.parameters['-D'];
if (debug == 'true') {
cmd += ' -D';
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err, d) => {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
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');
}
}
/*
* 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 menuTest from './menu'
export default function testsuite() {
menuTest()
}
\ No newline at end of file
/*
* 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'
function sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve("ok")
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
export default function menuTest() {
describe('ActsMenuTest', function () {
/**
* @tc.number ArkUX_Stage_Menu_EnableArrow_0100
* @tc.name Tests whether the directional menu arrow is displayed
* @tc.desc Tests whether the directional menu arrow is displayed
*/
it('ArkUX_Stage_Menu_EnableArrow_0100', 0, async function () {
let obj = JSON.parse(getInspectorByKey("menu"))
console.info('ArkUX_Stage_Menu_EnableArrow_0100 enableArrow :' + JSON.stringify(obj.$attrs.enableArrow));
expect(obj.$attrs.enableArrow).assertEqual(undefined)
})
/**
* @tc.number ArkUX_Stage_Menu_ArrowOffset_0100
* @tc.name Test directional menu arrow shows location distance
* @tc.desc Test directional menu arrow shows location distance
*/
it('ArkUX_Stage_Menu_ArrowOffset_0100', 0, async function () {
let obj = JSON.parse(getInspectorByKey("menu"))
console.info('ArkUX_Stage_Menu_ArrowOffset_0100 arrowOffset :' + JSON.stringify(obj.$attrs.arrowOffset));
expect(obj.$attrs.arrowOffset).assertEqual(undefined)
})
})
}
\ No newline at end of file
{
"module": {
"name": "entry_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"metadata": [{
"name": "ArkTSPartialUpdate",
"value": "true"
}],
"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"
]
}
]
}
]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
},
{
"name": "Divider_color",
"value": "#000000"
},
{
"name": "badge_BorderColor",
"value": "#FFFD0000"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
},
{
"name": "Divider_width",
"value": "10px"
},
{
"name": "Divider_startMargin",
"value": "5px"
},
{
"name": "Divider_endMargin",
"value": "5px"
},
{
"name": "badge_Size_test",
"value": "7vp"
}
]
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.swipertest",
"module-name": "phone",
"module-name": "entry_test",
"shell-timeout": "600000",
"testcase-timeout": 240000
},
......
{
"module": {
"name": "phone",
"name": "entry_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
......
{
"app": {
"bundleName": "com.example.textareatest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string":[
{
"name":"app_name",
"value":"MyApplication"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAceTextAreaTest") {
hap_profile = "src/main/module.json"
js_build_mode = "debug"
deps = [
":ace_ets_component_textinput_js_assets",
":ace_ets_component_textinput_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAceTextAreaTest"
part_name = "ace_engine"
subsystem_name = "arkui"
}
ohos_app_scope("ace_ets_component_textinput_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ace_ets_component_textinput_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("ace_ets_component_textinput_resources") {
sources = [ "src/main/resources" ]
deps = [ ":ace_ets_component_textinput_profile" ]
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.textareatest",
"module-name": "entry_test",
"shell-timeout": "600000",
"testcase-timeout": 240000
},
"kits": [{
"test-file-name": [
"ActsAceTextAreaTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602"
]
}
]
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import testsuite from '../test/List.test'
import Window from '@ohos.window'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
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) ?? '');
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import hilog from '@ohos.hilog';
import events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
@Entry
@Component
struct Index {
onPageShow() {
let valueChangeEvent = {
eventId: 10,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent, this.valueChangeCallBack)
console.info("key==>pages res : onPageShow")
}
private valueChangeCallBack = (eventData) => {
console.info("key==> page valueChangeCallBack");
if(eventData.data.type == "TextNum"){
console.info("valueChangeCallBack TextNum:"+ JSON.stringify(eventData));
this.flag = true
this.isNum = true
this.textNum = Number(eventData.data.text)
}
if(eventData.data.type == "TextStr"){
console.info("valueChangeCallBack TextStr:"+ JSON.stringify(eventData));
this.flag = true
this.isNum = false
this.textStr = eventData.data.text
}
if(eventData.data.type == "TextErr" && eventData.data.text == "null"){
console.info("valueChangeCallBack TextNull:"+ JSON.stringify(eventData));
this.flag = false
this.isNull = true
}
if(eventData.data.type == "TextErr" && eventData.data.text == "undefined"){
console.info("valueChangeCallBack TextErr:"+ JSON.stringify(eventData));
this.flag = false
this.isNull = false
}
if(eventData.data.type == "BoolTrue"){
console.info("valueChangeCallBack TextAreaShowCounterTrue:"+ JSON.stringify(eventData));
this.boolFlag = true
this.bool = true
}
if(eventData.data.type == "BoolFalse"){
console.info("valueChangeCallBack TextAreaShowCounterTrue:"+ JSON.stringify(eventData));
this.boolFlag = true
this.bool = false
}
if(eventData.data.type == "BoolErrNum"){
console.info("valueChangeCallBack TextAreaMaxLengthStr:"+ JSON.stringify(eventData));
this.boolFlag = false
this.boolIsNum = true
this.boolNum = Number(eventData.data.text)
}
if(eventData.data.type == "BoolErrStr"){
console.info("valueChangeCallBack TextAreaMaxLengthStr:"+ JSON.stringify(eventData));
this.boolFlag = false
this.boolIsNum = false
this.boolIsStr = true
this.boolStr = eventData.data.text
}
if(eventData.data.type == "BoolErrNull"){
console.info("valueChangeCallBack TextAreaMaxLengthStr:"+ JSON.stringify(eventData));
this.boolFlag = false
this.boolIsNum = false
this.boolIsStr = false
this.boolIsNull = true
}
if(eventData.data.type == "BoolErrUndefined"){
console.info("valueChangeCallBack TextAreaMaxLengthStr:"+ JSON.stringify(eventData));
this.boolFlag = false
this.boolIsNum = false
this.boolIsStr = false
this.boolIsNull = false
}
}
aboutToAppear() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
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)
}
@State flag: boolean = false
@State isNum: boolean = false
@State isNull: boolean = false
@State errFlag: boolean = false
@State textNum: number = 2
@State textStr: string = ''
@State boolFlag: boolean = false
@State bool: boolean = false
@State boolIsNum: boolean = false
@State boolIsStr: boolean = false
@State boolIsNull: boolean = false
@State boolNum: number = 2
@State boolStr: string = ''
@Builder ShowUnit() {
Column() {
Select([{value:'aaa',icon: "/common/1.png"},
{value:'bbb',icon: "/common/2.png"},
{value:'ccc',icon: "/common/3.png"},
{value:'ddd',icon: "/common/4.png"}])
.selected(2)
.value('TTT')
.font({size: 30, weight:400, family: 'serif', style: FontStyle.Normal })
.selectedOptionFont({size: 40, weight: 500, family: 'serif', style: FontStyle.Normal })
.optionFont({size: 30, weight: 400, family: 'serif', style: FontStyle.Normal })
.onSelect((index:number)=>{
console.info("Select:" + index)
})
}
}
@State text: string = 'Hello World'
controller: TextAreaController = new TextAreaController()
build() {
Column({ space: 5 }) {
TextArea({
text: 'The text area can hold an unlimited amount of text. input your word...',
controller: this.controller
})
.key("TextArea")
.placeholderFont({ size: 16, weight: 400 })
.width(336)
.height(56)
.margin(20)
.fontSize(16)
.maxLength(this.flag?(this.isNum? this.textNum: this.textStr):(this.isNull? null: undefined))
.showCounter(this.boolFlag?this.bool:(this.boolIsNum?this.boolNum:(this.boolIsStr?this.boolStr:
(this.boolIsNull? null: undefined))))
.backgroundColor('#FFFFFF')
.onChange((value: string) => {
this.text = value
})
TextArea({
text: 'The text area can hold an unlimited amount of text. input your word...',
controller: this.controller
})
.key("TextAreaNo")
.placeholderFont({ size: 16, weight: 400 })
.width(336)
.height(56)
.margin(20)
.fontSize(16)
.backgroundColor('#FFFFFF')
.onChange((value: string) => {
this.text = value
})
}.width('100%')
.margin({ top: 5 })
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
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]}`;
}
}
return targetParams.trim();
}
async function onAbilityCreateCallback() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err): Promise<void> {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility';
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters);
let debug = abilityDelegatorArguments.parameters['-D'];
if (debug == 'true') {
cmd += ' -D';
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err, d) => {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
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');
}
}
/*
* 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 textAreaTest from './textarea'
export default function testsuite() {
textAreaTest()
}
\ No newline at end of file
{
"module": {
"name": "entry_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"metadata": [{
"name": "ArkTSPartialUpdate",
"value": "true"
}],
"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"
]
}
]
}
]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
},
{
"name": "Divider_color",
"value": "#000000"
},
{
"name": "TextInput_Color",
"value": "#FFFD0000"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
},
{
"name": "Divider_width",
"value": "10px"
},
{
"name": "Divider_startMargin",
"value": "5px"
},
{
"name": "Divider_endMargin",
"value": "5px"
},
{
"name": "textInput_Size_test",
"value": "4px"
}
]
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.textinputtest",
"module-name": "phone",
"module-name": "entry_test",
"shell-timeout": "600000",
"testcase-timeout": 240000
},
......
/*
* 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 hilog from '@ohos.hilog';
import events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
@Entry
@Component
struct Index {
onPageShow() {
let valueChangeEvent = {
eventId: 10,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent, this.valueChangeCallBack)
console.info("key==>pages res : onPageShow")
}
private valueChangeCallBack = (eventData) => {
console.info("key==> page valueChangeCallBack");
if(eventData.data.type == "TextNum"){
console.info("valueChangeCallBack TextNum:"+ JSON.stringify(eventData));
this.flag = true
this.isNum = true
this.textNum = Number(eventData.data.text)
}
if(eventData.data.type == "TextStr"){
console.info("valueChangeCallBack TextStr:"+ JSON.stringify(eventData));
this.flag = true
this.isNum = false
this.textStr = eventData.data.text
}
if(eventData.data.type == "TextErr" && eventData.data.text == "null"){
console.info("valueChangeCallBack TextNull:"+ JSON.stringify(eventData));
this.flag = false
this.isNull = true
}
if(eventData.data.type == "TextErr" && eventData.data.text == "undefined"){
console.info("valueChangeCallBack TextErr:"+ JSON.stringify(eventData));
this.flag = false
this.isNull = false
}
if(eventData.data.type == "BoolTrue"){
console.info("valueChangeCallBack TextAreaShowCounterTrue:"+ JSON.stringify(eventData));
this.boolFlag = true
this.bool = true
}
if(eventData.data.type == "BoolFalse"){
console.info("valueChangeCallBack TextAreaShowCounterTrue:"+ JSON.stringify(eventData));
this.boolFlag = true
this.bool = false
}
if(eventData.data.type == "BoolErrNum"){
console.info("valueChangeCallBack TextAreaMaxLengthStr:"+ JSON.stringify(eventData));
this.boolFlag = false
this.boolIsNum = true
this.boolNum = Number(eventData.data.text)
}
if(eventData.data.type == "BoolErrStr"){
console.info("valueChangeCallBack TextAreaMaxLengthStr:"+ JSON.stringify(eventData));
this.boolFlag = false
this.boolIsNum = false
this.boolIsStr = true
this.boolStr = eventData.data.text
}
if(eventData.data.type == "BoolErrNull"){
console.info("valueChangeCallBack TextAreaMaxLengthStr:"+ JSON.stringify(eventData));
this.boolFlag = false
this.boolIsNum = false
this.boolIsStr = false
this.boolIsNull = true
}
if(eventData.data.type == "BoolErrUndefined"){
console.info("valueChangeCallBack TextAreaMaxLengthStr:"+ JSON.stringify(eventData));
this.boolFlag = false
this.boolIsNum = false
this.boolIsStr = false
this.boolIsNull = false
}
if(eventData.data.type == "passWordIcon" ){
console.info("valueChangeCallBack ResourceIcon:"+ JSON.stringify(eventData));
this.passwordIcon = JSON.parse(eventData.data.icon)
}
}
aboutToAppear() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
}
@State flag: boolean = false
@State isNum: boolean = false
@State isNull: boolean = false
@State errFlag: boolean = false
@State textNum: number = 2
@State textStr: string = ''
@State boolFlag: boolean = false
@State bool: boolean = false
@State boolIsNum: boolean = false
@State boolIsStr: boolean = false
@State boolIsNull: boolean = false
@State boolNum: number = 2
@State boolStr: string = ''
@State onIconFlag: boolean = false
@State offIconFlag: boolean = false
@State passwordIcon: PasswordIcon = {
onIconSrc : "",
offIconSrc :""
}
@Builder ShowUnit() {
Column() {
Select([{value:'aaa',icon: "/common/1.png"},
{value:'bbb',icon: "/common/2.png"},
{value:'ccc',icon: "/common/3.png"},
{value:'ddd',icon: "/common/4.png"}])
.selected(2)
.value('TTT')
.font({size: 30, weight:400, family: 'serif', style: FontStyle.Normal })
.selectedOptionFont({size: 40, weight: 500, family: 'serif', style: FontStyle.Normal })
.optionFont({size: 30, weight: 400, family: 'serif', style: FontStyle.Normal })
.onSelect((index:number)=>{
console.info("Select:" + index)
})
}
}
@State text: string = 'Hello World'
controller: TextAreaController = new TextAreaController()
build() {
Column({ space: 5 }) {
TextInput({ text: 'input your password...' })
.key("TextInput")
.width(400)
.height(40)
.margin(20)
.maxLength(5)
.type(InputType.Password)
.showUnderline(this.boolFlag?this.bool:(this.boolIsNum?this.boolNum:(this.boolIsStr?this.boolStr:(this.boolIsNull? null: undefined))))
.showError(this.flag?(this.isNum? this.textNum: this.textStr):(this.isNull? null: undefined))
.passwordIcon(this.passwordIcon)
TextInput({ text: 'input your password...' })
.key("TextInputResources")
.width(400)
.height(40)
.margin(20)
.showUnit(this.ShowUnit.bind(this))
.showError($r("app.string.TextInput_ShowError_test"))
TextInput({ text: 'input your password...' })
.key("TextInputNO")
.width(400)
.height(40)
.margin(20)
}.width('100%')
.margin({ top: 5 })
}
}
\ No newline at end of file
......@@ -13,7 +13,9 @@
* limitations under the License.
*/
import textInputTest from './textinput'
import textinputSec from './textinputSec'
export default function testsuite() {
textInputTest()
textinputSec()
}
\ No newline at end of file
{
"module": {
"name": "phone",
"name": "entry_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
......
......@@ -27,6 +27,10 @@
{
"name": "textInput_Size_test",
"value": "4px"
},
{
"name": "TextInput_ShowError_test",
"value": "string"
}
]
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>ic_appbar_back</title>
<defs>
<path d="M5.31079777,13.7499686 L11.2803301,19.7196699 L11.3140714,19.7556673 C11.5727547,20.0502619 11.5615076,20.4991526 11.2803301,20.7803301 C10.9991526,21.0615076 10.5502619,21.0727547 10.2556673,20.8140714 L10.2196699,20.7803301 L3.18929777,13.7499686 L5.31079777,13.7499686 Z M10.2196699,3.21966991 C10.5125631,2.9267767 10.9874369,2.9267767 11.2803301,3.21966991 C11.5615076,3.5008474 11.5727547,3.94973814 11.3140714,4.24433269 L11.2803301,4.28033009 L4.3105,11.25 L21,11.25 C21.3994202,11.25 21.7259152,11.56223 21.7487268,11.9559318 L21.75,12 C21.75,12.3994202 21.43777,12.7259152 21.0440682,12.7487268 L21,12.75 L3.10355339,12.75 C2.8383369,12.75 2.58398299,12.6446432 2.39644661,12.4571068 C2.01893979,12.0796 2.00635623,11.4753589 2.35869593,11.0827365 L2.39644661,11.0428932 L10.2196699,3.21966991 Z" id="path-1"></path>
</defs>
<g id="ic_appbar_back" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="形状结合" fill="#000000" fill-rule="nonzero" xlink:href="#path-1"></use>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>ic_appbar_fa</title>
<g id="ic_appbar_fa" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M22,11.35 C22.4142136,11.35 22.75,11.6857864 22.75,12.1 C22.75,18.0370611 17.9370611,22.85 12,22.85 C6.06293894,22.85 1.25,18.0370611 1.25,12.1 C1.25,11.6857864 1.58578644,11.35 2,11.35 C2.41421356,11.35 2.75,11.6857864 2.75,12.1 C2.75,17.2086339 6.89136606,21.35 12,21.35 C17.1086339,21.35 21.25,17.2086339 21.25,12.1 C21.25,11.6857864 21.5857864,11.35 22,11.35 Z M12,6.2518259 C15.1756373,6.2518259 17.75,8.82618859 17.75,12.0018259 C17.75,15.1774632 15.1756373,17.7518259 12,17.7518259 C8.82436269,17.7518259 6.25,15.1774632 6.25,12.0018259 C6.25,8.82618859 8.82436269,6.2518259 12,6.2518259 Z M12,7.74669317 C9.65278981,7.74669317 7.75,9.64948298 7.75,11.9966932 C7.75,14.3439034 9.65278981,16.2466932 12,16.2466932 C14.3472102,16.2466932 16.25,14.3439034 16.25,11.9966932 C16.25,9.64948298 14.3472102,7.74669317 12,7.74669317 Z M22.1659792,7.89855908 C22.3728687,8.41062859 22.1254714,8.99346002 21.6134019,9.20034953 C21.1013324,9.40723904 20.518501,9.15984177 20.3116115,8.64777227 C20.104722,8.13570277 20.3521192,7.55287133 20.8641887,7.34598182 C21.3762582,7.13909231 21.9590897,7.38648958 22.1659792,7.89855908 Z M3.1519358,7.35266082 C3.6603166,7.56845567 3.89750437,8.15551601 3.68170953,8.6638968 C3.46591468,9.1722776 2.87885434,9.40946537 2.37047355,9.19367053 C1.86209275,8.97787569 1.62490498,8.39081534 1.84069982,7.88243455 C2.05649466,7.37405376 2.64355501,7.13686598 3.1519358,7.35266082 Z M19.7781746,4.32182541 C20.1686989,4.7123497 20.1686989,5.34551468 19.7781746,5.73603897 C19.3876503,6.12656326 18.7544853,6.12656326 18.363961,5.73603897 C17.9734367,5.34551468 17.9734367,4.7123497 18.363961,4.32182541 C18.7544853,3.93130112 19.3876503,3.93130112 19.7781746,4.32182541 Z M5.63603897,4.32182541 C6.02656326,4.7123497 6.02656326,5.34551468 5.63603897,5.73603897 C5.24551468,6.12656326 4.6123497,6.12656326 4.22182541,5.73603897 C3.83130112,5.34551468 3.83130112,4.7123497 4.22182541,4.32182541 C4.6123497,3.93130112 5.24551468,3.93130112 5.63603897,4.32182541 Z M9.10034953,2.48659808 C9.30723904,2.99866758 9.05984177,3.58149902 8.54777227,3.78838853 C8.03570277,3.99527804 7.45287133,3.74788077 7.24598182,3.23581127 C7.03909231,2.72374177 7.28648958,2.14091033 7.79855908,1.93402082 C8.31062859,1.72713131 8.89346002,1.97452858 9.10034953,2.48659808 Z M16.2175655,1.94069982 C16.7259462,2.15649466 16.963134,2.74355501 16.7473392,3.2519358 C16.5315443,3.7603166 15.944484,3.99750437 15.4361032,3.78170953 C14.9277224,3.56591468 14.6905346,2.97885434 14.9063295,2.47047355 C15.1221243,1.96209275 15.7091847,1.72490498 16.2175655,1.94069982 Z M12,1.1 C12.5522847,1.1 13,1.54771525 13,2.1 C13,2.65228475 12.5522847,3.1 12,3.1 C11.4477153,3.1 11,2.65228475 11,2.1 C11,1.54771525 11.4477153,1.1 12,1.1 Z" id="形状结合" fill="#000000" fill-rule="nonzero"></path>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>ic_cancel</title>
<defs>
<path opacity=".6" d="M14.123,12.708 L19.2032418,17.7890282 L19.2409924,17.8288715 C19.5933321,18.2214939 19.5807486,18.8257349 19.2032418,19.2032418 C18.8427578,19.5637257 18.2755267,19.5914553 17.8832355,19.2864304 L17.7890282,19.2032418 L12.708,14.123 L14.123,12.708 Z M6.11289944,4.70970461 L6.20710678,4.79289322 L11.998,10.583 L17.7890282,4.79289322 C18.1795525,4.40236893 18.8127175,4.40236893 19.2032418,4.79289322 C19.5807486,5.17040003 19.5933321,5.77464109 19.2409924,6.16726352 L19.2032418,6.20710678 L13.413,11.997 L13.416,12.001 L12.001,13.416 L11.998,13.412 L6.20710678,19.2032418 C5.81658249,19.5937661 5.18341751,19.5937661 4.79289322,19.2032418 C4.4153864,18.8257349 4.40280284,18.2214939 4.75514254,17.8288715 L4.79289322,17.7890282 L10.583,11.998 L4.79289322,6.20710678 L4.75514254,6.16726352 C4.40280284,5.77464109 4.4153864,5.17040003 4.79289322,4.79289322 C5.15337718,4.43240926 5.72060824,4.40467972 6.11289944,4.70970461 Z" id="path-1"></path>
</defs>
<g id="ic_cancel" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="形状结合" fill="#000000" fill-rule="nonzero" xlink:href="#path-1"></use>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg viewBox="0 0 56 56" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>ic/56x56/OK/White</title>
<desc>Created with Sketch.</desc>
<g id="ic/56x56/OK/White" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="ic/OK">
<rect id="矩形" fill="#45A5FF" opacity="0" x="0" y="0" width="56" height="56"></rect>
<polyline id="路径" stroke="#FFFFFF" stroke-width="6" stroke-linecap="round" stroke-linejoin="round" fill-rule="nonzero" points="7.46666667 27.2361548 21.966801 42 49.4666667 14"></polyline>
</g>
</g>
</svg>
\ No newline at end of file
{
"src": [
"TestAbility/pages/Index"
"TestAbility/pages/Index",
"TestAbility/pages/TextinputSec"
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册