diff --git a/adapter/preview/build/component_test.gni b/adapter/preview/build/component_test.gni index 7017fca92f0..cedaf470000 100644 --- a/adapter/preview/build/component_test.gni +++ b/adapter/preview/build/component_test.gni @@ -11,4 +11,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -enable_component_test = false +enable_component_test = true diff --git a/frameworks/component_test/test_config.cpp b/frameworks/component_test/test_config.cpp index 24770077536..8c955d9e510 100644 --- a/frameworks/component_test/test_config.cpp +++ b/frameworks/component_test/test_config.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "component_test\test_config.h" +#include "component_test/test_config.h" #include #include diff --git a/test/component_test/tools/middle_ground/get_csv_data.js b/test/component_test/tools/middle_ground/get_csv_data.js index 194c3ccb04a..acd5b257fcb 100644 --- a/test/component_test/tools/middle_ground/get_csv_data.js +++ b/test/component_test/tools/middle_ground/get_csv_data.js @@ -32,7 +32,7 @@ async function getFolders(filePath) { async function createCsvData(casePath) { const csvContext = []; let index = 1; - const projectPath = path.join(casePath, "test", "componenttest", "test_cases", "components"); + const projectPath = path.join(casePath, "test", "component_test", "test_cases", "components"); try { const projectNames = await getFolders(projectPath); diff --git a/test/component_test/tools/middle_ground/util/index.js b/test/component_test/tools/middle_ground/util/index.js index 410598ffe07..8fe6a6e010c 100644 --- a/test/component_test/tools/middle_ground/util/index.js +++ b/test/component_test/tools/middle_ground/util/index.js @@ -75,11 +75,9 @@ function setFile(flieData) { fs.writeFile(filePathData, data, (err) => { if (err) throw err; - console.log('数据已被写入到文件'); }); try { fs.writeFileSync(filePathData, data); - console.log('数据已被写入到文件'); return filePathData; } catch (err) { throw err; diff --git a/test/component_test/tools/previewer_host/main.js b/test/component_test/tools/previewer_host/main.js index 3fbc5438da8..1ad76f6548e 100644 --- a/test/component_test/tools/previewer_host/main.js +++ b/test/component_test/tools/previewer_host/main.js @@ -30,142 +30,134 @@ const args = process.argv.slice(2); const originUrl = args[0]; const testFilePath = args[1]; -function parameters(sdkPath, access_token, downloadPath, resultPath, casePath, devEcoPath, concurrentQuantity) { - this.sdkPath = sdkPath; - this.access_token = access_token; - this.downloadPath = downloadPath; - this.resultPath = resultPath; - this.casePath = casePath; - this.devEcoPath = devEcoPath; - this.concurrentQuantity = concurrentQuantity; +function Parameters(sdkPath, access_token, downloadPath, resultPath, casePath, devEcoPath, concurrentQuantity) { + this.sdkPath = sdkPath; + this.access_token = access_token; + this.downloadPath = downloadPath; + this.resultPath = resultPath; + this.casePath = casePath; + this.devEcoPath = devEcoPath; + this.concurrentQuantity = concurrentQuantity; } const createQueueWithHvigor = () => { - return async.queue(async (param, callback) => { - await runHvigor(param.sdkPath, param.testFile, param.resultPath, param.casePath, param.ohpmBat, param.nodePath - , param.hvigorPath); - callback(); - }, 1); + return async.queue(async (param, callback) => { + await runHvigor(param.sdkPath, param.testFile, param.resultPath, param.casePath, param.ohpmBat, param.nodePath + , param.hvigorPath); + callback(); + }, 1); }; const createQueueWithConcurrency = (concurrencyLimit) => { - return async.queue(async (param, callback) => { - await test(param.sdkPath, param.testFile, param.resultPath, param.casePath, param.ohpmBat, param.nodePath - , param.hvigorPath); - callback(); - }, concurrencyLimit); + return async.queue(async (param, callback) => { + await test(param.sdkPath, param.testFile, param.resultPath, param.casePath, param.ohpmBat, param.nodePath + , param.hvigorPath); + callback(); + }, concurrencyLimit); }; function TestParam(sdkPath, testFile, resultPath, casePath, ohpmBat, nodePath, hvigorPath) { - this.sdkPath = sdkPath; - this.testFile = testFile; - this.resultPath = resultPath; - this.casePath = casePath; - this.ohpmBat = ohpmBat; - this.nodePath = nodePath; - this.hvigorPath = hvigorPath; + this.sdkPath = sdkPath; + this.testFile = testFile; + this.resultPath = resultPath; + this.casePath = casePath; + this.ohpmBat = ohpmBat; + this.nodePath = nodePath; + this.hvigorPath = hvigorPath; } async function run(url, htmlName, testFiles, downloadPath, resultFolder, sdkPath, casePath, - concurrentQuantity, datetime, ohpmBat, nodePath, hvigorPath) { - let startTime = new Date().getTime(); - await prepareHostEnv(url, downloadPath, sdkPath) - .catch(error => { - throw error; - }); - let originPIDs = await getNodePIDs(); - let projectName; - const queueHvigor = createQueueWithHvigor(); - for (let i = 0; i < testFiles.length; i++) { - const resultPath = path.join(resultFolder, datetime, testFiles[i][0]); - let testFile = testFiles[i]; - if (projectName != testFile[0]) { - await queueHvigor.push(new TestParam(sdkPath, testFile, resultPath, casePath, ohpmBat, nodePath, hvigorPath)); - projectName = testFile[0]; + concurrentQuantity, datetime, ohpmBat, nodePath, hvigorPath) { + let startTime = new Date().getTime(); + let downloadResultPath = path.join(downloadPath, "downloadResult"); + await prepareHostEnv(url, downloadResultPath, sdkPath) + .catch(error => { + throw error; + }); + let originPIDs = await getNodePIDs(); + let projectName = ""; + const queueHvigor = createQueueWithHvigor(); + for (let i = 0; i < testFiles.length; i++) { + const resultPath = path.join(resultFolder, datetime, testFiles[i][0]); + let testFile = testFiles[i]; + if (projectName !== testFile[0]) { + queueHvigor.push(new TestParam(sdkPath, testFile, resultPath, casePath, ohpmBat, nodePath, hvigorPath)); + projectName = testFile[0]; + } } - } - queueHvigor.drain(() => { - console.log('Successfully runHvigor all'); - }); - const queue = createQueueWithConcurrency(concurrentQuantity); - for (let i = 0; i < testFiles.length; i++) { - const resultPath = path.join(resultFolder, datetime, testFiles[i][0]); - let testFile = testFiles[i]; - queue.push(new TestParam(sdkPath, testFile, resultPath, casePath, ohpmBat, nodePath, hvigorPath), () => { - console.log("complete", i + 1); + queueHvigor.drain(() => { + const queue = createQueueWithConcurrency(concurrentQuantity); + for (let i = 0; i < testFiles.length; i++) { + const resultPath = path.join(resultFolder, datetime, testFiles[i][0]); + let testFile = testFiles[i]; + queue.push(new TestParam(sdkPath, testFile, resultPath, casePath, ohpmBat, nodePath, hvigorPath)); + } + queue.drain(async () => { + const htmlPath = path.join(resultFolder, datetime); + readDir(htmlPath) + .then((file, err) => { + if (err) { + console.error(err); + } + if (file.length > 0) { + generateHTML(htmlPath, htmlName, startTime); + } else { + console.error('resultPath directory is empty.'); + } + }); + getNodePIDs() + .then((pIds, err) => { + if (err) { + console.error(err); + } + let runOverPIDs = [...pIds]; + for (let i = 0; i < originPIDs.length; i++) { + for (let j = 0; j < runOverPIDs.length; j++) { + if (originPIDs[i] === runOverPIDs[j]) { + runOverPIDs.splice(j, 1); + } + } + } + deleteNodePIDs(runOverPIDs) + .then((code, err) => { + if (err) { + console.error(err); + } + }).catch((error) => { + console.error(error); + }); + }); + await deleteDir(sdkPath); + await renameDir(`${sdkPath}-backup`, sdkPath); + }) }); - } - queue.drain(() => { - console.log('Successfully processed all items'); - const htmlPath = path.join(resultFolder, datetime); - readDir(htmlPath) - .then((file, err) => { - if (err) { - console.error(err); - } - if (file.length > 0) { - generateHTML(htmlPath, htmlName, startTime); - } else { - console.error('resultPath directory is empty.'); - } - }); - console.log('Started to kill node'); - getNodePIDs() - .then((pIds, err) => { - if (err) { - console.error(err); - } - let runOverPIDs = [...pIds]; - for (let i = 0; i < originPIDs.length; i++) { - for (let j = 0; j < runOverPIDs.length; j++) { - if (originPIDs[i] === runOverPIDs[j]) { - runOverPIDs.splice(j, 1); - } - } - }; - deleteNodePIDs(runOverPIDs) - .then((code, err) => { - if (err) { - console.error(err); - } - console.log(code); - }).catch((error) => { - console.log(error); - }); - }); - }); } async function main() { - const testFiles = await parseJson(testFilePath); - const datetime = getDateTime(); - let prNumber = originUrl.split("/")[originUrl.split("/").length - 1]; - const htmlName = `${datetime}_${prNumber}.html`; - let jsonData = parseJson('param.json'); - let param = new parameters(jsonData.sdkPath, jsonData.access_token, jsonData.downloadPath, jsonData.resultPath, - jsonData.casePath, jsonData.devEcoPath, jsonData.concurrentQuantity); - let ohpmBat = `${param.devEcoPath}\\tools\\ohpm\\bin\\ohpm.bat`; - let nodePath = `${param.devEcoPath}\\tools\\node\\node.exe`; - let hvigorPath = `${param.devEcoPath}\\tools\\hvigor\\bin\\hvigorw.js`; - try { - const evolveUrl = originUrl.slice(18); - let requestUrl = - `https://gitee.com/api/v5/repos/${evolveUrl}/comments?access_token=${param.access_token}` + - `&page=1&per_page=50&direction=desc`; - await run(requestUrl, htmlName, testFiles, param.downloadPath, param.resultPath, param.sdkPath, - param.casePath, jsonData.concurrentQuantity, datetime, ohpmBat, nodePath, hvigorPath) - .catch(err => { + const testFiles = await parseJson(testFilePath); + const datetime = getDateTime(); + let prNumber = originUrl.split("/")[originUrl.split("/").length - 1]; + const htmlName = `${datetime}_${prNumber}.html`; + let jsonData = parseJson('param.json'); + let param = new Parameters(jsonData.sdkPath, jsonData.access_token, jsonData.downloadPath, jsonData.resultPath, + jsonData.casePath, jsonData.devEcoPath, jsonData.concurrentQuantity); + let ohpmBat = `${param.devEcoPath}\\tools\\ohpm\\bin\\ohpm.bat`; + let nodePath = `${param.devEcoPath}\\tools\\node\\node.exe`; + let hvigorPath = `${param.devEcoPath}\\tools\\hvigor\\bin\\hvigorw.js`; + try { + const evolveUrl = originUrl.slice(18); + let requestUrl = + `https://gitee.com/api/v5/repos/${evolveUrl}/comments?access_token=${param.access_token}` + + `&page=1&per_page=50&direction=desc`; + await run(requestUrl, htmlName, testFiles, param.downloadPath, param.resultPath, param.sdkPath, + param.casePath, jsonData.concurrentQuantity, datetime, ohpmBat, nodePath, hvigorPath) + .catch(err => { + throw err; + }); + } catch (err) { + process.exit(1); throw err; - }); - console.log('测试执行完毕,恢复previewer的sdk'); - deleteDir(sdkPath); - console.log(`删除了${sdkPath}`); - renameDir(`${sdkPath}-backup`, sdkPath); - console.log('已恢复至初始状态'); - } catch (err) { - process.exit(1); - throw err; - } + } } main(); \ No newline at end of file diff --git a/test/component_test/tools/previewer_host/main/cmd.js b/test/component_test/tools/previewer_host/main/cmd.js index 66f1a3470ec..a52a6c8b0bc 100644 --- a/test/component_test/tools/previewer_host/main/cmd.js +++ b/test/component_test/tools/previewer_host/main/cmd.js @@ -32,7 +32,7 @@ let origin = 40001; async function test(sdkPath, testFile, resultPath, casePath, ohpmBat, nodePath, hvigorPath) { return new Promise(async (resolve, reject) => { - const testCasePath = `${casePath}\\test\\componenttest\\test_cases\\components\\${testFile[0]}`; + const testCasePath = `${casePath}\\test\\component_test\\test_cases\\components\\${testFile[0]}`; const previewerExePath = `${sdkPath}\\previewer\\common\\bin`; const jParam = `${testCasePath}\\entry\\.preview\\default\\intermediates\\loader_out\\default\\ets`; const ljPathParam = `${testCasePath}\\entry\\.preview\\default\\intermediates\\loader\\default\\loader.json`; @@ -70,11 +70,9 @@ const runCommand = (command, args, options) => { let stdoutData = ""; let stderrData = ""; child.stdout.on('data', data => { - console.log(data.toString()); stdoutData += data.toString(); }); child.stderr.on('data', (data) => { - console.log(data.toString()); stderrData += data.toString(); if (data.toString().includes("ERROR")) { resolve(false) @@ -91,7 +89,7 @@ const runCommand = (command, args, options) => { }; async function runHvigor(sdkPath, testFile, resultPath, casePath, ohpmBat, nodePath, hvigorPath) { - const testCasePath = `${casePath}\\test\\componenttest\\test_cases\\components\\${testFile[0]}`; + const testCasePath = `${casePath}\\test\\component_test\\test_cases\\components\\${testFile[0]}`; const fParam = `${testCasePath}\\.idea\\previewer\\default\\defaultSettingConfig_Default.json`; const caseResultPath = `${resultPath}\\${testFile[2]}.json`.replaceAll("\\", "\\\\"); runCommand(`"${ohpmBat}"`, [ @@ -211,7 +209,6 @@ async function runPreviewer( '-componentTest', `"${componentTestParam}"` ], { detached: true, cwd: previewerExePath, shell: true }); previewerProcess.on('close', (code) => { - console.log(`Previewer process exited with code ${code}`); resolve(true); }); previewerProcess.on('error', (err) => { diff --git a/test/component_test/tools/previewer_host/main/collect_results_and_visualize.js b/test/component_test/tools/previewer_host/main/collect_results_and_visualize.js index edd1eb77125..2570b2fcc95 100644 --- a/test/component_test/tools/previewer_host/main/collect_results_and_visualize.js +++ b/test/component_test/tools/previewer_host/main/collect_results_and_visualize.js @@ -311,5 +311,5 @@ async function generateHTML(resultPath, htmlName, startTime) { `; fs.writeFileSync(path.join(resultPath, htmlName), htmlContent); - console.log(`HTML file with stacked bar chart generated: ${htmlName}`); + console.info(`HTML file with stacked bar chart generated: ${htmlName}`); } \ No newline at end of file diff --git a/test/component_test/tools/previewer_host/main/gitee_rest_api.js b/test/component_test/tools/previewer_host/main/gitee_rest_api.js index 65d3d78a5a3..27e68827871 100644 --- a/test/component_test/tools/previewer_host/main/gitee_rest_api.js +++ b/test/component_test/tools/previewer_host/main/gitee_rest_api.js @@ -18,7 +18,9 @@ const path = require('path'); const { JSDOM } = require('jsdom'); const os = require('os'); const unzipper = require('unzipper'); -const { clearDir, deleteDir, existDir, mkdir, moveDir, readDir, renameDir } = require('../utils/file.js'); +const { + clearDir, deleteDir, existDir, mkdir, moveDir, readDir, renameDir, isExistFile, copyFile +} = require('../utils/file.js'); const http = require("http"); module.exports = { prepareHostEnv }; @@ -28,7 +30,6 @@ async function getPullsNumberComments(url) { if (response.ok) { const data = await response.json(); for (let i = 0; i < data.length; i++) { - const date = new Date(data[i].updated_at); if (data[i].body.includes("代码门禁通过")) { const dom = new JSDOM(data[i].body); const document = dom.window.document; @@ -49,21 +50,30 @@ async function getPullsNumberComments(url) { } async function downloadFile(url, destinationPath) { - return new Promise((resolve, reject) => { + return new Promise(async (resolve, reject) => { const fileStream = fs.createWriteStream(destinationPath); - const request = http.get(url, (response) => { - if (response.statusCode !== 200) { + const request = await http.get(url, (response) => { + if (response.statusCode === 404) { + console.error("当前PR地址已失效,请更换可用的PR地址后重试"); reject(false); - } else { - console.log("开始下载"); - response.pipe(fileStream); - fileStream.on('finish', () => { - fileStream.close(); - resolve(true); - }); + return; } + if (response.statusCode !== 200) { + console.error("下载失败"); + reject(false); + return; + } + response.pipe(fileStream); + fileStream.on('finish', () => { + fileStream.close(() => resolve(true)); + }); + fileStream.on('error', (error) => { + console.error("下载文件错误", error); + reject(false); + }); }); request.on('error', (error) => { + console.error("请求出错", error); reject(false); }); }); @@ -89,7 +99,6 @@ async function extractLargeZip(zipFilePath, outputDir) { throw error; }) .on('close', () => { - console.log('解压完成'); resolve(); }); }); @@ -100,15 +109,12 @@ function judgePlatform() { } async function extractZipFile(zipFilePath, outputDirectory) { - console.log('zip 文件路径:', zipFilePath); - console.log('输出目录:', outputDirectory); try { await new Promise((resolve, reject) => { fs.createReadStream(zipFilePath) .pipe(unzipper.Extract({ path: outputDirectory })) .on('error', reject) .on('finish', () => { - console.log('解压完成'); resolve(); }); }); @@ -125,52 +131,55 @@ async function downloadSdk(url, downloadPath) { try { const pullsNumberCommentsResponse = await getPullsNumberComments(url); if (pullsNumberCommentsResponse !== null && pullsNumberCommentsResponse.hrefValue !== "") { - const downloadResult = await downloadFile( - pullsNumberCommentsResponse.hrefValue, path.join(downloadPath, "ohos-sdk.zip")); - resolve(downloadResult); + await downloadFile(pullsNumberCommentsResponse.hrefValue, + path.join(downloadPath, "ohos-sdk.zip")).then((res, rej) => { + if (res) { + resolve(true); + } else { + reject(false); + } + }) } else { - console.warn("暂时没有ohos-sdk"); + console.error("暂无可用sdk"); + reject(false); } } catch (error) { - throw error; + console.error("下载过程中发生错误"); + reject(false); } }); } async function prepareHostEnv(url, downloadPath, sdkPath) { try { + let ohosSdkPath; + let etsPath = path.join(sdkPath, "ets\\api"); const existSdk = await existDir(downloadPath); if (existSdk) { - console.log(`清空${downloadPath}文件夹`); await clearDir(downloadPath); } else { - console.log(`创建${downloadPath}文件夹`); await mkdir(downloadPath); } const existSdkPath = await existDir(sdkPath); + const existBackUpSdkPath = await existDir(`${sdkPath}-backup`); + if (existBackUpSdkPath) { + await deleteDir(`${sdkPath}-backup`); + } if (existSdkPath) { - console.log(`备份${sdkPath}文件夹`); await renameDir(sdkPath, `${sdkPath}-backup`); await mkdir(sdkPath); } else { - console.log(`创建${sdkPath}文件夹`); await mkdir(sdkPath); } - - const downloadResult = await downloadSdk(url, downloadPath); - console.log("SDK下载成功:", downloadResult); - console.log("解压下载的文件"); - + await downloadSdk(url, downloadPath); await extractLargeZip(path.join(downloadPath, "ohos-sdk.zip"), downloadPath); - let ohosSdkPath; if (judgePlatform) { - ohosSdkPath = path.join(downloadPath, 'ohos-sdk\\windows'); + ohosSdkPath = path.join(downloadPath, 'windows'); } else { - ohosSdkPath = path.join(downloadPath, 'ohos-sdk\\linux'); + ohosSdkPath = path.join(downloadPath, 'linux'); } - console.log(`当前操作系统是${os.platform()}`); let zipFiles = await readDir(ohosSdkPath); for (let i = 0; i < zipFiles.length; i++) { @@ -183,8 +192,25 @@ async function prepareHostEnv(url, downloadPath, sdkPath) { await moveDir(sdks[i], sdkPath); } } - await deleteDir(downloadPath); + let etsFile = path.join(etsPath, "@ohos.arkui.componentTest.d.ts"); + if (await isExistFile(etsFile)) { + await copyFile("previewer_host\\resource\\componentTest.ts", etsFile) + } } catch (error) { + console.log("准备环境过程出错,恢复初始状态"); + + if (await isExistFile(downloadPath)) { + await clearDir(downloadPath); + } + + if (await isExistFile(sdkPath)) { + await deleteDir(sdkPath); + } + + if (await isExistFile(`${sdkPath}-backup`)) { + await renameDir(`${sdkPath}-backup`, sdkPath); + } + console.log("环境清理完成"); throw error; } } \ No newline at end of file diff --git a/test/component_test/tools/previewer_host/resource/componentTest.ts b/test/component_test/tools/previewer_host/resource/componentTest.ts new file mode 100644 index 00000000000..6d8b38e5cba --- /dev/null +++ b/test/component_test/tools/previewer_host/resource/componentTest.ts @@ -0,0 +1,1047 @@ +/* + * Copyright (C) 2024 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 "ASIS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * @kit ArkUI + */ + +/** + * Enumerates the value TestCaseType. + * + * @enum {number} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ +declare enum TestCaseType { + /** + * FUNCTION. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + FUNCTION = 0, + /** + * PERFORMANCE. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + PERFORMANCE = 1, + /** + * POWER. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + POWER = 2, + /** + * RELIABILITY. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + RELIABILITY = 3, + /** + * SECURITY. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + SECURITY = 4, + /** + * GLOBAL. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + GLOBAL = 5, + /** + * COMPATIBILITY. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + COMPATIBILITY = 6, + /** + * USER. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + USER = 7, + /** + * STANDARD. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + STANDARD = 8, + /** + * SAFETY. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + SAFETY = 9, + /** + * RESILIENCE. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + RESILIENCE = 10 +} + +/** + * Enumerates the value TestCaseSize. + * + * @enum {number} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ +declare enum TestCaseSize { + /** + * SMALLTEST. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + SMALLTEST = 0, + /** + * MEDIUMTEST. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + MEDIUMTEST = 1, + /** + * LARGETEST. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + LARGETEST = 2 +} + +/** + * Enumerates the value TestCaseLevel. + * + * @enum {number} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ +declare enum TestCaseLevel { + /** + * LEVEL0. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + LEVEL0 = 0, + /** + * LEVEL1. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + LEVEL1 = 1, + /** + * LEVEL2. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + LEVEL2 = 2, + /** + * LEVEL3. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + LEVEL3 = 3, + /** + * LEVEL4. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + LEVEL4 = 4 +} + +/** + * Represents the attribute of the test case. + * + * @typedef TestCaseAttribute + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ +declare interface TestCaseAttribute { + /** + * test case type. + * + * @type {TestCaseType} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + type?: TestCaseType; + /** + * test case size. + * + * @type {TestCaseSize} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + size?: TestCaseSize; + /** + * test case level. + * + * @type {TestCaseLevel} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + level: TestCaseLevel; +} + +/** + * Enumerates the string value match type. + * + * @enum {number} + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ +declare enum MatchType { + /** + * Equals to a string. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + EQUALS = 0, + /** + * Contains a substring. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + CONTAINS = 1, + /** + * StartsWith a substring. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + STARTS_WITH = 2, + /** + * EndsWith a substring. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + ENDS_WITH = 3 +} + +/** + * Represents the point on the device screen. + * + * @typedef Point + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ +declare interface Point { + /** + * The x-coordinate of the coordinate point. + * + * @type { number } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + readonly x: number; + /** + * The y-coordinate of the coordinate point. + * + * @type { number } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + readonly y: number; +} + +/** + * Represents the rectangle area on the device screen. + * + * @typedef Rect + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ +declare interface Rect { + /** + * The x-coordinate of the top left corner of the rectangle. + * + * @type { number } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + readonly left: number; + /** + * The y-coordinate of the top left corner of the rectangle. + * + * @type { number } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + readonly top: number; + /** + * The x-coordinate at the bottom right corner of the rectangle. + * + * @type { number } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + readonly right: number; + /** + * The y-coordinate at the bottom right corner of the rectangle. + * + * @type { number } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + readonly bottom: number; +} + +/** + * Enumerates the direction for the UI operation . + * + * @enum { number } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ +declare enum UiDirection { + /** + * Left. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + LEFT = 0, + /** + * Right. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + RIGHT = 1, + /** + * Up. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + UP = 2, + /** + * Down. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + DOWN = 3 +} + +/** + * Describes the attribute requirements for the target Components. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ +declare class Matcher { + /** + * Create an {@link Matcher} object. + * + * @returns { Matcher } the {@link Matcher} object. + * @throws { BusinessError } 17000001 - if the test framework failed to initialize. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + static create(): Matcher; + /** + * Specifies the text for the target Component. + * + * @param { string } text - the text value. + * @param { MatchType } [matchType] - the {@link MatchType} of the text value,Set it default {@link MatchType.EQUALS} if null or undefined. + * @returns { Matcher } this {@link Matcher} object. + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + text(text: string, matchType?: MatchType): Matcher; + /** + * Specifies the id of the target Component. + * + * @param { string } id - the id value. + * @returns { Matcher } this {@link Matcher} object. + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + id(id: string): Matcher; + /** + * Specifies the type of the target Component. + * + * @param { string } type - the type value. + * @returns { Matcher } this {@link Matcher} object. + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + type(type: string): Matcher; + /** + * Specifies the clickable of the target Component. + * + * @param { boolean } b - the clickable status,default to true.Set it default if null or undefined. + * @returns { Matcher } this {@link Matcher} object. + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + clickable(b?: boolean): Matcher; + /** + * Specifies the longPressable of the target Component. + * + * @param { boolean } b - the longPressable status,default to true.Set it default if null or undefined. + * @returns { Matcher } this {@link Matcher} object. + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + longPressable(b?: boolean): Matcher; + /** + * Specifies the scrollable of the target Component. + * + * @param { boolean } b - the scrollable status,default to true.Set it default if null or undefined. + * @returns { Matcher } this {@link Matcher} object. + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + scrollable(b?: boolean): Matcher; + /** + * Specifies the enabled of the target Component. + * + * @param { boolean } b - the enabled status,default to true.Set it default if null or undefined. + * @returns { Matcher } this {@link Matcher} object. + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + enabled(b?: boolean): Matcher; + /** + * Specifies the focused of the target Component. + * + * @param { boolean } b - the focused status,default to true.Set it default if null or undefined. + * @returns { Matcher } this {@link Matcher} object. + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + focused(b?: boolean): Matcher; + /** + * Specifies the selected of the target Component. + * + * @param { boolean } b - the selected status,default to true.Set it default if null or undefined. + * @returns { Matcher } this {@link Matcher} object. + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + selected(b?: boolean): Matcher; + /** + * Specifies the checked of the target Component. + * + * @param { boolean } b - the checked status,default to false.Set it default if null or undefined. + * @returns { Matcher } this {@link Matcher} object. + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + checked(b?: boolean): Matcher; + /** + * Specifies the checkable of the target Component. + * + * @param { boolean } b - the checkable status,default to false.Set it default if null or undefined. + * @returns { Matcher } this {@link Matcher} object. + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + checkable(b?: boolean): Matcher; +} + +/** + * Represents an Component of the ohos application,user can perform operations or query attributes on it. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + * @test + */ +declare class Component { + /** + * Tap this {@link Component}. + * + * @returns { Promise } + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + tap(): Promise; + /** + * Double tap this {@link Component}. + * + * @returns { Promise } + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + doubleTap(): Promise; + /** + * Press this {@link Component}. + * + * @returns { Promise } + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + press(duration?: number): Promise; + /** + * Pinch enlarge this {@link Component} to the target scale. + * + * @param { number } scale - the scale of the pinch enlarge this {@link Component}'s size. + * @returns { Promise } + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + pinchOut(scale: number): Promise; + /** + * Pinch shrink this {@link Component} to the target scale. + * + * @param { number } scale - the scale of the pinch shrink this {@link Component}'s size. + * @returns { Promise } + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + pinchIn(scale: number): Promise; + /** + * Inject text to this {@link Component}, applicable to TextInput. + * + * @param { string } text - the text to inject. + * @returns { Promise } + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + inputText(text: string): Promise; + /** + * Clear text to this {@link Component}, applicable to TextInput. + * + * @returns { Promise } + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + clearText(): Promise; + /** + * Scroll on this {@link Component} to the top,applicable to scrollable one. + * + * @param { number } [speed] - the speed of swipe(pixels per second),ranges from 200 to 40000.Set it default 600 if out of range or null or undefined. + * @returns { Promise } + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + scrollToTop(speed?: number): Promise; + /** + * Scroll on this {@link Component} to the bottom,applicable to scrollable one. + * + * @param { number } [speed] - the speed of swipe(pixels per second),ranges from 200 to 40000. Set it default 600 if out of range or null or undefined. + * @returns { Promise } + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + scrollToBottom(speed?: number): Promise; + /** + * Get the id attribute value. + * + * @returns { Promise } the id value. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + getId(): Promise; + /** + * Get the text attribute value. + * + * @returns { Promise } the text value. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + getText(): Promise; + /** + * Get the type attribute value. + * + * @returns { Promise } the type value. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + getType(): Promise; + /** + * Get the clickable status of this {@link Component}. + * + * @returns { Promise } the clickable status. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + isClickable(): Promise; + /** + * Get the long pressable status of this {@link Component}. + * + * @returns { Promise } the long pressable status. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + isLongPressable(): Promise; + /** + * Get the isScrollable status of this {@link Component}. + * + * @returns { Promise } the isScrollable status. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + isScrollable(): Promise; + /** + * Get the isEnabled status of this {@link Component}. + * + * @returns { Promise } the isEnabled status. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + isEnabled(): Promise; + /** + * Get the isFocused status of this {@link Component}. + * + * @returns { Promise } the isFocused status. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + isFocused(): Promise; + /** + * Get the isSelected status of this {@link Component}. + * + * @returns { Promise } the isSelected status. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + isSelected(): Promise; + /** + * Get the isChecked status of this {@link Component}. + * + * @returns { Promise } the isChecked status. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + isChecked(): Promise; + /** + * Get the isCheckable status of this {@link Component}. + * + * @returns { Promise } the isCheckable status. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + isCheckable(): Promise; + /** + * Get the inspector info of this {@link Component}. + * + * @returns { Promise } the inspector info value. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + getInspectorInfo(): Promise; + /** + * Get the inspector tree of this {@link Component}. + * + * @returns { Promise } the inspector tree value. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + getInspectorTree(): Promise; + /** + * Get the child count of this {@link Component}. + * + * @returns { Promise } the child count value. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + getChildCount(): Promise; + /** + * Get the bounds rect of this {@link Component}. + * + * @returns { Promise } the bounds rect object. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + getBounds(): Promise; +} + +/** + * The unified facade of UiTest framework,can be used to find {@link Component},trigger keyEvents,perform + * coordinates-based UI actions,capture screen and so on. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + * @test + */ +declare class Tester { + /** + * Create an {@link Tester} object. + * + * @returns { Tester } the {@link Tester} object. + * @throws { BusinessError } 17000001 - if the test framework failed to initialize. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + static create(): Tester; + /** + * Delay with specified duration. + * + * @param { number } duration - the delay duration in milliseconds. + * @returns { Promise } + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + pump(delayMs?: number): Promise; + /** + * Find the first matched {@link Component} on current UI. + * + * @param { Matcher } pattern The attribute requirements of the target {@link Component}. + * @returns { Promise } the first matched {@link Component} or undefined. + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + findComponent(pattern: Matcher): Promise; + /** + * Find all the matched {@link Component}s on current UI. + * + * @param { Matcher } pattern The attribute requirements of the target {@link Component}. + * @returns { Promise> } the matched {@link Component}s list. + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + findComponents(pattern: Matcher): Promise>; + /** + * Assert t the matched {@link Component}s exists on current UI;if not,assertError will be raised. + * + * @param { Matcher } pattern The attribute requirements of the target {@link Component}. + * @returns { Promise } + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @throws { BusinessError } 17000003 - if the assertion failed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + assertComponentExist(pattern: Matcher): Promise; + /** + * TODO + * + * @param pattern + */ + scrollUntilExist(pattern: Matcher): Promise; + /** + * Press the specified key. + * + * @param { number } keyCode - the target keyCode. + * @returns { Promise } + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + triggerkey(keyCode: number): Promise; + /** + * Press two or three key combinations + * + * @param { Array } [keys] - the target keyCodes. + * @returns { Promise } + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + triggerCombineKeys(keys: Array): Promise; + /** + * Tap on the specified location on the screen. + * + * @param { number } x The x-coordinate. + * @param { number } y The y-coordinate. + * @returns { Promise } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 11 + */ + tap(x: number, y: number): Promise; + /** + * DoubleTap on the specified location on the screen. + * + * @param { number } x The x-coordinate. + * @param { number } y The y-coordinate. + * @returns { Promise } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 11 + */ + doubleTap(x: number, y: number): Promise; + /** + * Press on the specified location on the screen. + * + * @param { number } x The x-coordinate. + * @param { number } y The y-coordinate. + * @param { number } duration The press duration. + * @returns { Promise } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 11 + */ + press(x: number, y: number, duration?: number): Promise; + /** + * TODO + * + * @param deltax + * @param deltaY + */ + scroll(deltax: number, deltaY: number): Promise; + /** + * Drag on the screen between the specified points. + * + * @param { number } startx - the x-coordinate of the starting point. + * @param { number } starty - the y-coordinate of the starting point. + * @param { number } endx - the x-coordinate of the ending point. + * @param { number } endy - the y-coordinate of the ending point. + * @param { number } [speed] the speed of drag(pixels per second),ranges from 200 to 40000. Set it default 600 if out of range or null or undefined. + * @returns { Promise } + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + drag(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise; + /** + * Inject fling on the device display. + * + * @param { Point } from - the coordinate point where the finger touches the screen. + * @param { Point } to - the coordinate point where the finger leaves the screen. + * @param { number } stepLen - the length of each step, in pixels. + * @param { number } [speed] - the speed of fling(pixels per second),ranges from 200 to 40000. Set it default 600 if out of range or null or undefined. + * @returns { Promise } + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + fling(from: Point, to: Point, steplen: number, speed: number): Promise; + /** + * Inject fling on the device display. + * + * @param { UiDirection } direction - the direction of this action. + * @param { number } speed - the speed of fling (pixels per second),default is 600,the value ranges from 200 to 40000,set it 600 if out of range. + * @returns { Promise } + * @throws { BusinessError } 401 - if the input parameters are invalid. + * @throws { BusinessError } 17000002 - if the async function was not called with await. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 11 + */ + fling(direction: UiDirection, speed: number): Promise; +} + +type allExpectType = Object | undefined | null; +type allActualType = Object | undefined | null; + +// global functions +declare function loadComponentTestEntry(entry: () => void): void; + +declare function defineTest(testName: string, attr: TestCaseAttribute, testBody: () => void, delayMs?: number): void; +declare function assertContain(expectValue: allExpectType, actualValue: allActualType): void; +declare function assertEqual(expectValue: allExpectType, actualValue: allActualType): void; +declare function assertFalse(actualValue: allExpectType): void; +declare function assertTrue(actualValue: allExpectType): void; + +export { + TestCaseType, + TestCaseSize, + TestCaseLevel, + TestCaseAttribute, + MatchType, + Point, + Rect, + UiDirection, + Matcher, + Component, + Tester, + loadComponentTestEntry, + defineTest, + assertContain, + assertEqual, + assertFalse, + assertTrue +}; diff --git a/test/component_test/tools/previewer_host/utils/file.js b/test/component_test/tools/previewer_host/utils/file.js index ffad981e3ea..03a113af15e 100644 --- a/test/component_test/tools/previewer_host/utils/file.js +++ b/test/component_test/tools/previewer_host/utils/file.js @@ -22,8 +22,10 @@ module.exports = { readDir, clearDir, deleteDir, + delFile, renameDir, moveDir, + moveSourceToTarget, writeJsonFile, isExistFile, recursiveCreateFolders, @@ -90,6 +92,14 @@ async function deleteDir(folderPath) { } } +async function delFile(filePath) { + try { + await fs.rm(filePath, { recursive: true }); + } catch (err) { + if (err.code !== 'ENOENT') throw err; + } +} + async function renameDir(oldName, newName) { try { await fs.rename(oldName, newName); diff --git a/test/component_test/tools/previewer_host/utils/sys.js b/test/component_test/tools/previewer_host/utils/sys.js index 383e8572656..e1e54e7b3fa 100644 --- a/test/component_test/tools/previewer_host/utils/sys.js +++ b/test/component_test/tools/previewer_host/utils/sys.js @@ -74,7 +74,6 @@ async function deleteNodePIDs(PIDs) { deleteProcess.stdout.on('data', data => { stdout += data.toString(); - console.log(data.toString()); }); deleteProcess.stderr.on('data', data => { @@ -87,7 +86,6 @@ async function deleteNodePIDs(PIDs) { console.error(`delete process error exited with code ${code}`); reject(code); } else { - console.log(`process exited with code ${code}`); resolve(code); } });