Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
e33e2fff
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e33e2fff
编写于
3月 10, 2022
作者:
Z
zhangrao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add
Signed-off-by:
N
zhangrao
<
zhangrao@huawei.com
>
上级
433e12dd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
349 addition
and
1 deletion
+349
-1
ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/fontWeight.ets
...onent/entry/src/main/ets/MainAbility/pages/fontWeight.ets
+52
-0
ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/sideBar.ets
...omponent/entry/src/main/ets/MainAbility/pages/sideBar.ets
+95
-0
ace/ace_ets_component/entry/src/main/ets/MainAbility/test/List.test.ets
...mponent/entry/src/main/ets/MainAbility/test/List.test.ets
+3
-1
ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SideBarJsunit.test.ets
...ntry/src/main/ets/MainAbility/test/SideBarJsunit.test.ets
+199
-0
未找到文件。
ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/fontWeight.ets
0 → 100755
浏览文件 @
e33e2fff
// @ts-nocheck
/**
* 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 events_emitter from '@ohos.emitter'
@Entry
@Component
struct ContentTable {
private foodItem: FoodData
@State fontWeight: FontWeight = FontWeight.Medium
@Builder IngredientItem(title:string, name: string, value: string) {
Flex() {
Text(title)
.fontSize(17.4)
.fontWeight(this.fontWeight)
.layoutWeight(1)
Flex() {
Text(name)
.fontSize(17.4)
.flexGrow(1)
Text(value)
.fontSize(17.4)
}
.layoutWeight(2)
}
.key('fontWeight')
}
build() {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) {
this.IngredientItem('Calories', 'Calories', this.foodItem.calories + 'kcal')
this.IngredientItem('Nutrition', 'Protein', this.foodItem.protein + 'g')
this.IngredientItem('', 'Fat', this.foodItem.fat + 'g')
this.IngredientItem('', 'Carbohydrates', this.foodItem.carbohydrates + 'g')
this.IngredientItem('', 'VitaminC', this.foodItem.vitaminC + 'mg')
}
.height(280)
.padding({ top: 30, right: 30, left: 30 })
}
}
\ No newline at end of file
ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/sideBar.ets
0 → 100755
浏览文件 @
e33e2fff
// @ts-nocheck
/**
* 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 events_emitter from '@ohos.emitter'
@Entry
@Component
struct SideBarExample {
normalIcon : Resource = ($rawfile("ic_health_heart.png"))
selectedIcon: Resource = ($rawfile("test.png"))
@State arr: number[] = [1, 2, 3]
@State current: number = 1
@State widthValue: number = 10
@State heightValue: number = 10
@State controlButton: ButtonStyle = ButtonStyle.left
@State iconsValue: object= { shown: string=10, hidden: string=10, switching:string=10 };
private stateChangCallBack = (eventData) => {
if (eventData != null) {
console.info("sideBar page state change called:" + JSON.stringify(eventData));
if (eventData.data.widthValue != null) {
this.widthValue = eventData.data.widthValue;
}
if (eventData.data.heightValue != null) {
this.heightValue = JSON.parse(eventData.data.heightValue);
}
if (eventData.data.iconsValue != null) {
this.iconsValue = eventData.data.iconsValue;
}
if (eventData.data.controlButton != null) {
this.controlButton = eventData.data.controlButton;
}
}
}
onPageShow() {
console.info('sideBar page show called');
var stateChangeEvent = {
eventId: 45,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(stateChangeEvent, this.stateChangCallBack);
}
build() {
SideBarContainer(SideBarContainerType.Embed)
{
Column() {
ForEach(this.arr, (item, index) => {
Column({ space: 5 }) {
Image(this.current === item ? this.selectedIcon : this.normalIcon).width(64).height(64)
Text("Index0" + item)
.fontSize(25)
.fontColor(this.current === item ? '#0A59F7' : '#999')
.fontFamily('source-sans-pro,cursive,sans-serif')
}
.onClick(() => {
this.current = item
})
}, item => item)
}.width('100%')
.backgroundColor('#19000000')
RowSplit() {
Column(){
Text('Split page one').fontSize(30)
}
Column(){
Text('Split page two').fontSize(30)
}
}.width('100%')
}
.key('sidebar')
.width(this.widthValue)
.height(this.heightValue)
.controlButton(this.controlButton)
.sideBarWidth(240)
.minSideBarWidth(210)
.maxSideBarWidth(260)
.onChange((value: boolean) => {
console.info('status:' + value)
})
}
}
ace/ace_ets_component/entry/src/main/ets/MainAbility/test/List.test.ets
浏览文件 @
e33e2fff
...
...
@@ -106,7 +106,7 @@ import flexWrapJsunit from './FlexWrapJsunit.test.ets';
import datePickerJsunit from './DatePickerJsunit.test.ets';
import enmusVerticalAlignJsunit from './EnmusVerticalAlignJsunit.test.ets';
import enmusHorizontalAlignJsunit from './EnmusHorizontalAlignJsunit.test.ets';
import direction2Jsunit from './
d
irection2Jsunit.test.ets';
import direction2Jsunit from './
D
irection2Jsunit.test.ets';
import patternLockJsunit from './PatternLockJsunit.test.ets';
import enumsImageJsunit from './EnmusImageJsunit.test.ets';
import sliderJsunit from './sliderJsunit.test.ets'
...
...
@@ -134,6 +134,7 @@ import playModeJsunit from './PlayModeJsunit.test.ets';
import SwipeDirectionJsunit from './SwipeDirectionJsunit.test.ets';
import GestureModeJsunit from './GestureModeJsunit.test.ets';
import PanDirectionJsunit from './PanDirectionJsunit.test.ets';
import sideBarJsunit from './SideBarJsunit.test.ets';
export default function testsuite() {
gaugeJsunit();
...
...
@@ -258,5 +259,6 @@ export default function testsuite() {
SwipeDirectionJsunit();
GestureModeJsunit();
PanDirectionJsunit();
sideBarJsunit();
systemAppJsunit(); //此测试文件会终止APP运行,提代码请将文件放在此文件之前
}
\ No newline at end of file
ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SideBarJsunit.test.ets
0 → 100755
浏览文件 @
e33e2fff
// @ts-nocheck
/**
* 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router';
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils';
export default function sidebarJsunit() {
describe('appInfoTest', function () {
beforeEach(async function (done) {
let options = {
uri: 'pages/sideBar',
}
try {
router.clear();
let pages = router.getState();
console.info("get sideBar state success " + JSON.stringify(pages));
if (!("sideBar" == pages.name)) {
console.info("get sideBar success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push sideBar page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push sideBar page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(2000);
console.info("sideBar after each called");
});
it('testSideBar001', 0, async function (done) {
console.info('[testSideBar001] START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('sidebar');
console.info("[testSideBar001] component strJson:" + strJson);
let obj = JSON.parse(strJson);
console.info("[testSideBar001] width:" + obj.$attrs.width);
expect(obj.$attrs.width).assertEqual('10.000000vp');
done();
});
it('testSideBar002', 0, async function (done) {
console.info('testSideBar002 START');
await Utils.sleep(1000);
try {
var eventData = {
data: {
"widthValue": '20',
}
}
var innerEvent = {
eventId: 45,
priority: events_emitter.EventPriority.LOW
}
console.info("testSideBar002 start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("testSideBar002 change component color error: " + err.message);
}
await Utils.sleep(2000);
let strJson = getInspectorByKey('sidebar');
let obj = JSON.parse(strJson);
console.info("testSideBar002 component obj is: " + JSON.stringify(obj.$attrs.widthValue));
expect(obj.$attrs.widthValue).assertEqual('20');
done();
});
it('testSideBar003', 0, async function (done) {
console.info('[testSideBar003] START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('sidebar');
console.info("[testSideBar003] component strJson:" + strJson);
let obj = JSON.parse(strJson);
console.info("[testSideBar003] height:" + obj.$attrs.height);
expect(obj.$attrs.height).assertEqual('10.000000vp');
done();
});
it('testSideBar004', 0, async function (done) {
console.info('[testSideBar004] START');
try {
let eventData = {
data: {
"heightValue":"30"
}
}
let indexEvent = {
eventId: 45,
priority: events_emitter.EventPriority.LOW
}
console.info("[testSideBar004] start to publish emit");
events_emitter.emit(indexEvent, eventData);
} catch (err) {
console.log("[testSideBar004] change component data error: " + err.message);
}
await Utils.sleep(4000);
let strJson = getInspectorByKey('sidebar');
console.info("[testSideBar004] component strJson:" + strJson);
let obj = JSON.parse(strJson);
console.info("[testSideBar004] height:" + obj.$attrs.height);
expect(obj.$attrs.height).assertEqual('30');
done();
});
it('testSidebar005', 0, async function (done) {
console.info('[testSidebar005] START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('sidebar');
console.info("[testSidebar005] component strJson:" + strJson);
let obj = JSON.parse(strJson);
console.info("[testSidebar005] icons:" + obj.$attrs.icons);
expect(obj.$attrs.icons).assertEqual('10.000000vp');
done();
});
it('testSidebar006', 0, async function (done) {
console.info('[testSidebar006] START');
await Utils.sleep(1000);
let iconsValue: object= {shown: string=20, hidden: string=30, switching:string=10 };
try {
var eventData = {
data: {
"iconsValue": JSON.stringify(iconsValue)
}
}
var innerEvent = {
eventId: 45,
priority: events_emitter.EventPriority.LOW
}
console.info("[testSidebar006] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[testSidebar006] change component data error: " + err.message);
}
await Utils.sleep(2000);
let strJsonNew = getInspectorByKey('sidebar');
let objNew = JSON.parse(strJsonNew);
console.info("[testSidebar006] component objNew is: " + JSON.stringify(objNew));
expect(objNew.$attrs.icons.shown).assertEqual("20.000000");
expect(objNew.$attrs.icons.hidden).assertEqual("30.000000");
expect(objNew.$attrs.icons.switching).assertEqual("10.000000");
done();
});
it('testSidebar007', 0, async function (done) {
console.info('[testSidebar007] START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('sidebar');
console.info("[testSidebar007] component strJson:" + strJson);
let obj = JSON.parse(strJson);
console.info("[testSidebar007] controlButton:" + obj.$attrs.controlButton);
expect(obj.$attrs.controlButton).assertEqual('10.000000vp');
done();
});
it('testSidebar008', 0, async function (done) {
console.info('[testSidebar008] START');
await Utils.sleep(1000);
try {
var eventData = {
data: {
"controlButton": controlButton.top
}
}
var innerEvent = {
eventId: 45,
priority: events_emitter.EventPriority.LOW
}
console.info("[testSidebar008] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[testSidebar008] change component data error: " + err.message);
}
await Utils.sleep(2000);
let strJsonNew = getInspectorByKey('sidebar');
let objNew = JSON.parse(strJsonNew);
console.info("[testSidebar008] component objNew is: " + JSON.stringify(objNew));
expect(objNew.$attrs.controlButton).assertEqual("controlButton.top");
done();
});
})
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录