Commit cf281f96 by 毛勇泽

搭建项目

parent 485b1780
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
"vendor": "example", "vendor": "example",
"versionCode": 1000000, "versionCode": 1000000,
"versionName": "1.0.0", "versionName": "1.0.0",
"icon": "$media:app_icon", "icon": "$media:logo",
"label": "$string:app_name" "label": "$string:app_name",
"distributedNotificationEnabled": true
} }
} }
...@@ -22,6 +22,66 @@ ...@@ -22,6 +22,66 @@
] ]
} }
] ]
},
{
"name": "common",
"srcPath": "./common",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
},
{
"name": "DirectConnect",
"srcPath": "./features/DirectConnect",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
},
{
"name": "MaterialManagement",
"srcPath": "./features/MaterialManagement",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
},
{
"name": "PageManagement",
"srcPath": "./features/PageManagement",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
},
{
"name": "SystemMaintenance",
"srcPath": "./features/SystemMaintenance",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
} }
] ]
} }
\ No newline at end of file
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
\ No newline at end of file
{
"apiType": 'stageMode',
"buildOption": {
},
"entryModules": [
"entry"
],
"targets": [
{
"name": "default",
"runtimeOS": "HarmonyOS"
},
{
"name": "ohosTest",
}
]
}
\ No newline at end of file
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
export { hapTasks } from '@ohos/hvigor-ohos-plugin';
export { BreakpointSystem, BreakPointType } from './src/main/ets/utils/BreakpointSystem';
export { Logger } from './src/main/ets/utils/Logger';
export { BreakpointConstants } from './src/main/ets/constants/BreakpointConstants';
export { GridConstants } from './src/main/ets/constants/GridConstants';
export { StyleConstants } from './src/main/ets/constants/StyleConstants';
export { CommonDataSource } from './src/main/ets/utils/CommonDataSource';
\ No newline at end of file
{
"name": "common",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "index.ets",
"author": "",
"license": "",
"dependencies": {}
}
/*
* 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.
*/
/**
* Constants for breakpoint.
*/
export class BreakpointConstants {
/**
* Breakpoints that represent small device types.
*/
static readonly BREAKPOINT_SM: string = 'sm';
/**
* Breakpoints that represent middle device types.
*/
static readonly BREAKPOINT_MD: string = 'md';
/**
* Breakpoints that represent large device types.
*/
static readonly BREAKPOINT_LG: string = 'lg';
/**
* Current breakpoints that to query the device types.
*/
static readonly CURRENT_BREAKPOINT: string = 'currentBreakpoint';
/**
* Range of the small device width.
*/
static readonly RANGE_SM: string = '(320vp<=width<520vp)';
/**
* Range of the middle device width.
*/
static readonly RANGE_MD: string = '(520vp<=width<840vp)';
/**
* Range of the large device width.
*/
static readonly RANGE_LG: string = '(840vp<=width)';
}
\ 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.
*/
/**
* Constants for Grid components.
*/
export class GridConstants {
/**
* Current component width: 4 grids.
*/
static readonly COLUMN_FOUR: number = 4;
/**
* Current component width: 8 grids.
*/
static readonly COLUMN_EIGHT: number = 8;
/**
* Current component width: 12 grids.
*/
static readonly COLUMN_TWELVE: number = 12;
/**
* Current component width: 1 grids.
*/
static readonly SPAN_ONE: number = 1;
/**
* Current component width: 2 grids.
*/
static readonly SPAN_TWO: number = 2;
/**
* Current component width: 3 grids.
*/
static readonly SPAN_THREE: number = 3;
/**
* Current component width: 4 grids.
*/
static readonly SPAN_FOUR: number = 4;
/**
* Current component width: 8 grids.
*/
static readonly SPAN_EIGHT: number = 8;
/**
* Current component width: 12 grids.
*/
static readonly SPAN_TWELVE: number = 12;
/**
* Current component offset 2 grids.
*/
static readonly OFFSET_TWO: number = 2;
/**
* Current component offset 3 grids.
*/
static readonly OFFSET_THREE: number = 3;
/**
* Current component offset 6 grids.
*/
static readonly OFFSET_SIX: number = 6;
/**
* Current component offset 8 grids.
*/
static readonly OFFSET_EIGHT: number = 8;
/**
* Current component gutter 12.
*/
static readonly GUTTER_TWELVE: number = 12;
}
\ 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.
*/
/**
* Constants for common style.
*/
export class StyleConstants {
/**
* Component width percentage: 100%.
*/
static readonly FULL_WIDTH: string = '100%';
/**
* Component height percentage: 100%.
*/
static readonly FULL_HEIGHT: string = '100%';
/**
* Component height percentage: 70%.
*/
static readonly SEVENTY_HEIGHT: string = '70%';
/**
* Component height percentage: 60%.
*/
static readonly SIXTY_HEIGHT: string = '60%';
/**
* Component width percentage: 60%.
*/
static readonly SIXTY_WIDTH: string = '60%';
/**
* Component height percentage: 50%.
*/
static readonly FIFTY_HEIGHT: string = '50%';
/**
* Component height percentage: 50%.
*/
static readonly HUNDRED_FIFTEEN_WIDTH: string = '115%';
/**
* Component space vp : 4.
*/
static readonly FOUR_SPACE: string = '4vp';
/**
* Component space vp : 12.
*/
static readonly TWELVE_SPACE: string = '12vp';
/**
* Component space vp : 14.
*/
static readonly ITEM_SPACE: string = '14vp';
/**
* Component space vp : 15.
*/
static readonly FIFTEEN_SPACE: string = '15vp';
/**
* Font weight value: 700.
*/
static readonly FONT_WEIGHT_SEVEN: number = 700;
/**
* Font weight value: 500.
*/
static readonly FONT_WEIGHT_FIVE: number = 500;
/**
* Font weight value: 400.
*/
static readonly FONT_WEIGHT_FOUR: number = 400;
/**
* Text line value: 2.
*/
static readonly TWO_TEXT_LINE: number = 2;
/**
* Component opacity value: 1.
*/
static readonly FULL_OPACITY: number = 1;
/**
* Component opacity value: 0.6.
*/
static readonly SIXTY_OPACITY: number = 0.6;
/**
* Component opacity value: 0.8.
*/
static readonly EIGHTY_OPACITY: number = 0.8;
/**
* Component layout value: 1.
*/
static readonly LAYOUT_WEIGHT: number = 1;
/**
* Flex basic value: 1.
*/
static readonly FLEX_BASIC: number = 1;
/**
* Flex shrink value: 1.
*/
static readonly FLEX_SHRINK: number = 1;
/**
* Flex grow value: 1.
*/
static readonly FLEX_GROW: number = 1;
/**
* Swiper or list display count value: 1.
*/
static readonly DISPLAY_ONE: number = 1;
/**
* Swiper or list display count value: 2.
*/
static readonly DISPLAY_TWO: number = 2;
/**
* Swiper or list display count value: 3.
*/
static readonly DISPLAY_THREE: number = 3;
/**
* Swiper or list display count value: 4.
*/
static readonly DISPLAY_FOUR: number = 4;
/**
* Image aspect ratio value: 2.23.
*/
static readonly IMAGE_ASPECT_RATIO: number = 2.25;
/**
* Number of value: 0.5.
*/
static readonly HALF_ONE: number = 0.5;
/**
* Number of value: -1.
*/
static readonly MINUS_ONE: number = -1;
}
\ 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 mediaQuery from '@ohos.mediaquery';
import { BreakpointConstants } from '../constants/BreakpointConstants';
declare interface BreakPointTypeOption<T> {
sm?: T
md?: T
lg?: T
xl?: T
xxl?: T
}
export class BreakPointType<T> {
options: BreakPointTypeOption<T>
constructor(option: BreakPointTypeOption<T>) {
this.options = option
}
getValue(currentBreakPoint: string): T {
return this.options[currentBreakPoint] as T
}
}
export class BreakpointSystem {
private currentBreakpoint: string = '';
private smListener?: mediaQuery.MediaQueryListener;
private mdListener?: mediaQuery.MediaQueryListener;
private lgListener?: mediaQuery.MediaQueryListener;
private updateCurrentBreakpoint(breakpoint: string) {
if (this.currentBreakpoint !== breakpoint) {
this.currentBreakpoint = breakpoint;
AppStorage.Set<string>(BreakpointConstants.CURRENT_BREAKPOINT, this.currentBreakpoint);
}
}
private isBreakpointSM = (mediaQueryResult: mediaQuery.MediaQueryResult) => {
if (mediaQueryResult.matches) {
this.updateCurrentBreakpoint(BreakpointConstants.BREAKPOINT_SM);
}
}
private isBreakpointMD = (mediaQueryResult: mediaQuery.MediaQueryResult) => {
if (mediaQueryResult.matches) {
this.updateCurrentBreakpoint(BreakpointConstants.BREAKPOINT_MD);
}
}
private isBreakpointLG = (mediaQueryResult: mediaQuery.MediaQueryResult) => {
if (mediaQueryResult.matches) {
this.updateCurrentBreakpoint(BreakpointConstants.BREAKPOINT_LG);
}
}
public register() {
this.smListener = mediaQuery.matchMediaSync(BreakpointConstants.RANGE_SM);
this.smListener.on('change', this.isBreakpointSM);
this.mdListener = mediaQuery.matchMediaSync(BreakpointConstants.RANGE_MD);
this.mdListener.on('change', this.isBreakpointMD);
this.lgListener = mediaQuery.matchMediaSync(BreakpointConstants.RANGE_LG);
this.lgListener.on('change', this.isBreakpointLG);
}
public unregister() {
this.smListener?.off('change', this.isBreakpointSM);
this.mdListener?.off('change', this.isBreakpointMD);
this.lgListener?.off('change', this.isBreakpointLG);
}
}
\ 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.
*/
export class CommonDataSource<T> implements IDataSource {
private dataArray: T[] = [];
private listeners: DataChangeListener[] = [];
constructor(element: T[]) {
this.dataArray = element;
}
public getData(index: number) {
return this.dataArray[index]
}
public totalCount(): number {
return this.dataArray.length;
}
public addData(index: number, data: T[]): void {
this.dataArray = this.dataArray.concat(data);
this.notifyDataAdd(index);
}
public pushData(data: T): void {
this.dataArray.push(data);
this.notifyDataAdd(this.dataArray.length - 1);
}
unregisterDataChangeListener(listener: DataChangeListener): void {
const pos = this.listeners.indexOf(listener);
if (pos >= 0) {
this.listeners.splice(pos, 1);
}
}
registerDataChangeListener(listener: DataChangeListener): void {
if (this.listeners.indexOf(listener) < 0) {
this.listeners.push(listener);
}
}
notifyDataReload(): void {
this.listeners.forEach((listener: DataChangeListener) => {
listener.onDataReloaded();
})
}
notifyDataAdd(index: number): void {
this.listeners.forEach((listener: DataChangeListener) => {
listener.onDataAdd(index);
})
}
notifyDataChange(index: number): void {
this.listeners.forEach((listener: DataChangeListener) => {
listener.onDataChange(index);
})
}
notifyDataDelete(index: number): void {
this.listeners.forEach((listener: DataChangeListener) => {
listener.onDataDelete(index);
})
}
notifyDataMove(from: number, to: number): void {
this.listeners.forEach((listener: DataChangeListener) => {
listener.onDataMove(from, to);
})
}
}
\ 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';
/**
* Common log for all features.
*
* @param {string} prefix Identifies the log tag.
*/
let domain: number = 0xFF00;
let prefix: string = 'MultiShopping';
let format: string = `%{public}s, %{public}s`;
export class Logger {
static debug(...args: string[]) {
hilog.debug(domain, prefix, format, args);
}
static info(...args: string[]) {
hilog.info(domain, prefix, format, args);
}
static warn(...args: string[]) {
hilog.warn(domain, prefix, format, args);
}
static error(...args: string[]) {
hilog.error(domain, prefix, format, args);
}
static fatal(...args: string[]) {
hilog.fatal(domain, prefix, format, args);
}
static isLoggable(level: LogLevel) {
hilog.isLoggable(domain, prefix, level);
}
}
/**
* Log level define
*
* @syscap SystemCapability.HiviewDFX.HiLog
*/
enum LogLevel {
DEBUG = 3,
INFO = 4,
WARN = 5,
ERROR = 6,
FATAL = 7
}
{
"module": {
"name": "common",
"type": "feature",
"description": "$string:module_desc",
"mainElement": "common",
"deviceTypes": [
"phone",
"tablet"
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
},
{
"name": "page_background",
"value": "#f1f3f5"
},
{
"name": "focus_color",
"value": "#e92f4f"
},
{
"name": "three_alpha_black",
"value": "#08000000"
},
{
"name": "five_alpha_black",
"value": "#0d000000"
},
{
"name": "ten_alpha_black",
"value": "#1A000000"
},
{
"name": "twenty_alpha_black",
"value": "#33000000"
},
{
"name": "forty_alpha_black",
"value": "#66000000"
},
{
"name": "sixty_alpha_black",
"value": "#99000000"
},
{
"name": "eighty_alpha_black",
"value": "#cc000000"
},
{
"name": "zero_alpha_black",
"value": "#00000000"
},
{
"name": "sixty_alpha_white",
"value": "#99FFFFFF"
},
{
"name": "eighty_alpha_white",
"value": "#CCFFFFFF"
}
]
}
\ No newline at end of file
{
"float": [
{
"name": "micro_font_size",
"value": "10fp"
},
{
"name": "smaller_font_size",
"value": "12fp"
},
{
"name": "small_font_size",
"value": "14fp"
},
{
"name": "middle_font_size",
"value": "16fp"
},
{
"name": "big_font_size",
"value": "18fp"
},
{
"name": "bigger_font_size",
"value": "20fp"
},
{
"name": "huge_font_size",
"value": "24fp"
},
{
"name": "vp_one",
"value": "1vp"
},
{
"name": "vp_two",
"value": "2vp"
},
{
"name": "vp_four",
"value": "4vp"
},
{
"name": "vp_six",
"value": "6vp"
},
{
"name": "vp_eight",
"value": "8vp"
},
{
"name": "vp_ten",
"value": "10vp"
},
{
"name": "vp_twelve",
"value": "12vp"
},
{
"name": "vp_fourteen",
"value": "14vp"
},
{
"name": "vp_sixteen",
"value": "16vp"
},
{
"name": "vp_eighteen",
"value": "18vp"
},
{
"name": "vp_twenty",
"value": "20vp"
},
{
"name": "vp_twenty_four",
"value": "24vp"
},
{
"name": "vp_fifty_six",
"value": "56vp"
},
{
"name": "commodity_item_height",
"value": "263vp"
},
{
"name": "commodity_list_margin",
"value": "-6vp"
},
{
"name": "commodity_desc_height",
"value": "20vp"
},
{
"name": "commodity_item_image_size",
"value": "132vp"
},
{
"name": "count_text_width",
"value": "32vp"
},
{
"name": "count_width",
"value": "78vp"
},
{
"name": "empty_image_size",
"value": "60vp"
},
{
"name": "capsule_height",
"value": "40vp"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "common_desc",
"value": "description"
},
{
"name": "common_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "common_desc",
"value": "description"
},
{
"name": "common_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "common_desc",
"value": "description"
},
{
"name": "common_label",
"value": "label"
}
]
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function abilityTest() {
describe('ActsAbilityTest', function () {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(function () {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
})
beforeEach(function () {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
})
afterEach(function () {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
})
afterAll(function () {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
})
it('assertContain',0, function () {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
let a = 'abc'
let b = 'b'
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
expect(a).assertContain(b)
expect(a).assertEqual(a)
})
})
}
\ No newline at end of file
import abilityTest from './Ability.test'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
import UIAbility from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import hilog from '@ohos.hilog';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import window from '@ohos.window';
export default class TestAbility extends UIAbility {
onCreate(want, launchParam) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('testability/pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
async function onAbilityCreateCallback() {
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}
\ No newline at end of file
{
"module": {
"name": "common_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "TestAbility",
"srcEntry": "./ets/testability/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"exported": 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"
}
]
}
\ 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"
}
]
}
\ No newline at end of file
{
"src": [
"testability/pages/Index"
]
}
{ {
"name": "entry", "name": "entry",
"version": "1.0.0", "version": "1.0.0",
"devDependencies": {},
"repository": {},
"description": "Please describe the basic information.", "description": "Please describe the basic information.",
"main": "", "main": "",
"author": "", "author": "",
"license": "", "license": "entry",
"dependencies": {} "dependencies": {
"@ohos/direct": "file:../features/DirectConnect",
"@ohos/material": "file:../features/MaterialManagement",
"@ohos/common": "file:../common",
"@ohos/pagemanagement": "file:../features/PageManagement",
"@ohos/system": "file:../features/SystemMaintenance"
}
} }
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License,Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export class PageConstants {
/**
* Delay time to router MainPage.
*/
static readonly DELAY_TIME: number = 2000;
/**
* The value of letter space: 16vp.
*/
static readonly LETTER_SPACE: string = '16vp';
/**
* The value of tab bar button space: 6vp.
*/
static readonly BUTTON_SPACE: string = '6vp';
/**
* MainPage url.
*/
static readonly MAIN_PAGE_URL: string = 'pages/MainPage';
/**
* CommodityDetailPage url.
*/
static readonly COMMODITY_DETAIL_PAGE_URL: string = 'pages/CommodityDetailPage';
/**
* Index of home tab.
*/
static readonly HOME_INDEX: number = 0;
/**
* Index of newProduct tab.
*/
static readonly NEW_PRODUCT_INDEX: number = 1;
/**
* Index of shopCart tab.
*/
static readonly SHOP_CART_INDEX: number = 2;
/**
* Index of personal tab.
*/
static readonly PERSONAL_INDEX: number = 3;
/**
* Image aspect ratio value: 1.
*/
static readonly IMAGE_ASPECT_RATIO: number = 1;
/**
* Key of router get params: tabIndex.
*/
static readonly TABLE_INDEX_KEY: string = 'tabIndex';
/**
* Key of router get params: orderList.
*/
static readonly ORDER_LIST_KEY: string = 'orderList';
/**
* Key of router get params: order.
*/
static readonly ORDER_KEY: string = 'order';
/**
* Key of router get params: orderIds.
*/
static readonly ORDER_IDS_KEY: string = 'orderIds';
/**
* Key of router get params: id.
*/
static readonly ID_KEY: string = 'id';
}
\ No newline at end of file
...@@ -15,7 +15,7 @@ export default class EntryAbility extends UIAbility { ...@@ -15,7 +15,7 @@ export default class EntryAbility extends UIAbility {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index', (err, data) => { windowStage.loadContent('pages/SplashPage', (err, data) => {
if (err.code) { if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return; return;
......
import { Materials } from './materials/index'
@Entry
@Component
struct Index {
@State activeIndex: number = 0
@Builder NavigationToolbar() {
Text("!1111")
}
tabberConfig = [
{
url: "tabbar/saomiao.png",
index: 0
},
{
url: "tabbar/wuzi.png",
index: 1
},
{
url: "tabbar/baoguo_lanshou_o.png",
index: 2
},
{
url: "tabbar/saomiao.png",
index: 3
}
]
build() {
Flex({ direction: FlexDirection.Column }) {
Column() {
if (this.activeIndex == 0) {
Materials()
}
}.flexGrow(1)
Row() {
Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) {
ForEach(this.tabberConfig,(item) => {
})
Image($rawfile("tabbar/saomiao.png")).width("25").height("25")
Image($rawfile("tabbar/wuzi.png")).width("30").height("30")
Image($rawfile("tabbar/baoguo_lanshou_o.png")).width("30").height("30")
Image($rawfile("tabbar/xitong.png")).width("30").height("30")
}
}.padding({ top: 15, bottom: 15 })
}
}
}
\ No newline at end of file
import router from '@ohos.router';
import { PageConstants } from '../constants/PageConstants';
import { buttonInfo, ButtonInfoModel } from '../viewmodel/MainPageData';
import { DirectConnect } from '@ohos/direct';
import { MaterialManagement } from '@ohos/material';
import { PageManagement } from '@ohos/pagemanagement';
import { SystemMaintenance } from '@ohos/system';
import {
BreakpointSystem,
Logger,
StyleConstants,
BreakpointConstants
} from '@ohos/common';
@Entry
@Component
struct MainPage {
@StorageProp('currentBreakpoint') currentBreakpoint: string = 'sm';
@StorageLink('IndexPage') currentPageIndex: number = 0;
private breakpointSystem = new BreakpointSystem();
aboutToAppear() {
this.breakpointSystem.register();
}
aboutToDisappear() {
this.breakpointSystem.unregister();
}
onPageShow() {
}
build() {
Column() {
Tabs({
barPosition: this.currentBreakpoint === BreakpointConstants.BREAKPOINT_LG ? BarPosition.Start : BarPosition.End,
index: this.currentPageIndex
}) {
TabContent() {
DirectConnect()
}
.tabBar(this.BottomNavigation(buttonInfo[PageConstants.HOME_INDEX]))
TabContent() {
MaterialManagement()
}
.tabBar(this.BottomNavigation(buttonInfo[PageConstants.NEW_PRODUCT_INDEX]))
TabContent() {
PageManagement()
}
.tabBar(this.BottomNavigation(buttonInfo[PageConstants.SHOP_CART_INDEX]))
TabContent() {
SystemMaintenance()
}
.tabBar(this.BottomNavigation(buttonInfo[PageConstants.PERSONAL_INDEX]))
}
.barWidth(this.currentBreakpoint === BreakpointConstants.BREAKPOINT_LG ?
$r('app.float.bar_width') : StyleConstants.FULL_WIDTH)
.barHeight(this.currentBreakpoint === BreakpointConstants.BREAKPOINT_LG ?
StyleConstants.SIXTY_HEIGHT : '56vp')
.vertical(this.currentBreakpoint === BreakpointConstants.BREAKPOINT_LG)
.scrollable(false)
.onChange((index: number) => {
this.currentPageIndex = index;
// if (index === PageConstants.PERSONAL_INDEX) {
// this.queryShopCart();
// } else if (index === PageConstants.PERSONAL_INDEX) {
// this.queryOrderList();
// }
})
}
.backgroundColor('#f1f3f5')
}
@Builder BottomNavigation(button: ButtonInfoModel) {
Column({ space: PageConstants.BUTTON_SPACE }) {
Image(this.currentPageIndex === button.index ? button.selectImg : button.img)
.objectFit(ImageFit.Contain)
.width($r('app.float.main_image_size'))
.height($r('app.float.main_image_size'))
Text(button.title)
.fontColor(this.currentPageIndex === button.index ? '#e92f4f' : Color.Black)
.opacity(this.currentPageIndex === button.index ? StyleConstants.FULL_OPACITY : StyleConstants.SIXTY_OPACITY)
.fontWeight(StyleConstants.FONT_WEIGHT_FIVE)
.textAlign(TextAlign.Center)
.fontSize('10fp')
}
.width(StyleConstants.FULL_WIDTH)
.height(StyleConstants.FULL_HEIGHT)
.alignItems(HorizontalAlign.Center)
.justifyContent(FlexAlign.Center)
}
}
\ No newline at end of file
import router from '@ohos.router';
import { PageConstants } from '../constants/PageConstants';
@Entry
@Component
struct SplashPage {
private timeOutId: number = 0;
build() {
Row() {
Column() {
Image($rawfile("await/await1.png"))
.objectFit(ImageFit.Contain)
}
.width('100%')
}
.height('100%')
}
aboutToAppear() {
this.timeOutId = setTimeout(() => {
router.replaceUrl({ url: PageConstants.MAIN_PAGE_URL })
.catch((err: Error) => {
console.error("error:跳转"+JSON.stringify(err))
})
}, PageConstants.DELAY_TIME);
}
aboutToDisappear() {
clearTimeout(this.timeOutId);
}
}
\ No newline at end of file
@Entry
@Component
export struct Materials {
build(){
Text("物资管理")
}
}
\ 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.
*/
export class ButtonInfoModel {
index: number = 0;
img: Resource = $rawfile("tabbar/saomiao.png");
selectImg: Resource = $rawfile("tabbar/saomiao3.png");
title: Resource = $r('app.string.direct');
}
const buttonInfo: ButtonInfoModel[] = [
{
index: 0,
img: $rawfile("tabbar/saomiao.png"),
selectImg: $rawfile("tabbar/saomiao3.png"),
title: $r('app.string.wz_management')
},
{
index: 1,
img: $rawfile("tabbar/wuzi.png"),
selectImg: $rawfile("tabbar/houqinwuzi.png"),
title: $r('app.string.wz_management')
},
{
index: 2,
img: $rawfile("tabbar/baoguo_lanshou_o.png"),
selectImg: $rawfile("tabbar/baoguo_shouhuo_o.png"),
title: $r('app.string.page_management')
},
{
index: 3,
img: $rawfile("tabbar/saomiao.png"),
selectImg: $rawfile("tabbar/saomiao.png"),
title: $r('app.string.system_maintenance')
}
]
export { buttonInfo }
\ No newline at end of file
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"name": "EntryAbility", "name": "EntryAbility",
"srcEntry": "./ets/entryability/EntryAbility.ts", "srcEntry": "./ets/entryability/EntryAbility.ts",
"description": "$string:EntryAbility_desc", "description": "$string:EntryAbility_desc",
"icon": "$media:icon", "icon": "$media:logo",
"label": "$string:EntryAbility_label", "label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon", "startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background", "startWindowBackground": "$color:start_window_background",
......
{
"float": [
{
"name": "splash_image_size",
"value": "120vp"
},
{
"name": "splash_image_size_lg",
"value": "160vp"
},
{
"name": "splash_text_margin_bottom",
"value": "136vp"
},
{
"name": "text_image_width",
"value": "114vp"
},
{
"name": "text_image_height",
"value": "27vp"
},
{
"name": "main_image_size",
"value": "24vp"
},
{
"name": "bar_width",
"value": "96vp"
}
]
}
\ No newline at end of file
{ {
"src": [ "src": [
"pages/Index" "pages/SplashPage",
"pages/MainPage"
] ]
} }
...@@ -10,7 +10,24 @@ ...@@ -10,7 +10,24 @@
}, },
{ {
"name": "EntryAbility_label", "name": "EntryAbility_label",
"value": "label" "value": "仓库终端"
},
{
"name": "direct",
"value": "直连扫描"
},
{
"name": "wz_management",
"value": "物资管理"
},
{
"name": "page_management",
"value": "包裹管理"
},
{
"name": "system_maintenance",
"value": "系统维护"
} }
] ]
} }
\ No newline at end of file
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
\ No newline at end of file
{
"apiType": 'stageMode',
"buildOption": {
},
"entryModules": [
"entry"
],
"targets": [
{
"name": "default",
"runtimeOS": "HarmonyOS"
},
{
"name": "ohosTest",
}
]
}
\ No newline at end of file
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
export { hapTasks } from '@ohos/hvigor-ohos-plugin';
export { DirectConnect } from './src/main/ets/pages/DirectConnect';
{
"name": "directconnect",
"version": "1.0.0",
"name": "@ohos/direct",
"description": "Please describe the basic information.",
"main": "index.ets",
"author": "",
"license": "",
"dependencies": {}
}
@Component
export struct DirectConnect {
@State message: string = 'DirectConnect'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "DirectConnect",
"type": "feature",
"description": "$string:module_desc",
"mainElement": "DirectConnect",
"deviceTypes": [
"phone",
"tablet"
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "DirectConnect_desc",
"value": "description"
},
{
"name": "DirectConnect_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "DirectConnect_desc",
"value": "description"
},
{
"name": "DirectConnect_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "DirectConnect_desc",
"value": "description"
},
{
"name": "DirectConnect_label",
"value": "label"
}
]
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function abilityTest() {
describe('ActsAbilityTest', function () {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(function () {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
})
beforeEach(function () {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
})
afterEach(function () {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
})
afterAll(function () {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
})
it('assertContain',0, function () {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
let a = 'abc'
let b = 'b'
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
expect(a).assertContain(b)
expect(a).assertEqual(a)
})
})
}
\ No newline at end of file
import abilityTest from './Ability.test'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
import UIAbility from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import hilog from '@ohos.hilog';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import window from '@ohos.window';
export default class TestAbility extends UIAbility {
onCreate(want, launchParam) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('testability/pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
async function onAbilityCreateCallback() {
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}
\ No newline at end of file
{
"module": {
"name": "DirectConnect_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "TestAbility",
"srcEntry": "./ets/testability/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"exported": 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"
}
]
}
\ 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"
}
]
}
\ No newline at end of file
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
\ No newline at end of file
{
"apiType": 'stageMode',
"buildOption": {
},
"entryModules": [
"entry"
],
"targets": [
{
"name": "default",
"runtimeOS": "HarmonyOS"
},
{
"name": "ohosTest",
}
]
}
\ No newline at end of file
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
export { hapTasks } from '@ohos/hvigor-ohos-plugin';
export { MaterialManagement } from './src/main/ets/pages/MaterialManagement';
{
"name": "materialmanagement",
"version": "1.0.0",
"name": "@ohos/material",
"description": "Please describe the basic information.",
"main": "index.ets",
"author": "",
"license": "",
"dependencies": {}
}
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
@Component
export struct MaterialManagement {
@State message: string = 'MaterialManagement'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "MaterialManagement",
"type": "feature",
"description": "$string:module_desc",
"mainElement": "MaterialManagement",
"deviceTypes": [
"phone",
"tablet"
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "MaterialManagement_desc",
"value": "description"
},
{
"name": "MaterialManagement_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "MaterialManagement_desc",
"value": "description"
},
{
"name": "MaterialManagement_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "MaterialManagement_desc",
"value": "description"
},
{
"name": "MaterialManagement_label",
"value": "label"
}
]
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function abilityTest() {
describe('ActsAbilityTest', function () {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(function () {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
})
beforeEach(function () {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
})
afterEach(function () {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
})
afterAll(function () {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
})
it('assertContain',0, function () {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
let a = 'abc'
let b = 'b'
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
expect(a).assertContain(b)
expect(a).assertEqual(a)
})
})
}
\ No newline at end of file
import abilityTest from './Ability.test'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
import UIAbility from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import hilog from '@ohos.hilog';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import window from '@ohos.window';
export default class TestAbility extends UIAbility {
onCreate(want, launchParam) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('testability/pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
async function onAbilityCreateCallback() {
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}
\ No newline at end of file
{
"module": {
"name": "MaterialManagement_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "TestAbility",
"srcEntry": "./ets/testability/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"exported": 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"
}
]
}
\ 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"
}
]
}
\ No newline at end of file
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
\ No newline at end of file
{
"apiType": 'stageMode',
"buildOption": {
},
"entryModules": [
"entry"
],
"targets": [
{
"name": "default",
"runtimeOS": "HarmonyOS"
},
{
"name": "ohosTest",
}
]
}
\ No newline at end of file
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
export { hapTasks } from '@ohos/hvigor-ohos-plugin';
export { PageManagement } from './src/main/ets/pages/PageManagement';
{
"name": "pagemanagement",
"version": "1.0.0",
"name": "@ohos/pagemanagement",
"description": "Please describe the basic information.",
"main": "index.ets",
"author": "",
"license": "",
"dependencies": {}
}
@Component
export struct PageManagement {
@State message: string = 'PageManagement'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "PageManagement",
"type": "feature",
"description": "$string:module_desc",
"mainElement": "PageManagement",
"deviceTypes": [
"phone",
"tablet"
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "PageManagement_desc",
"value": "description"
},
{
"name": "PageManagement_label",
"value": "label"
}
]
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论