提交 aef1b25e 编写于 作者: Z zhangxinyue

add a new test suite

Signed-off-by: Nzhangxinyue <zhangxinyue38@huawei.com>
上级 ea1678a9
......@@ -25,6 +25,7 @@ group("arkui") {
"ace_ets_test:ActsAceEtsTest",
"ace_ets_third_test:ActsAceEtsThirdTest",
"ace_ets_web_dev:ActsAceWebDevTest",
"ace_ets_web_dev_two:ActsAceWebDevTwoTest",
"ace_ets_xcomponent:ActsAceXComponentEtsTest",
"ace_js_attribute_api:ActsAceJsApiTest",
"ace_napi_test:ActsAceNapiEtsTest",
......
{
"app": {
"bundleName": "com.open.harmony.acewebtwotest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAceWebDevTwoTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":ace_ets_web_dev_js_assets",
":ace_ets_web_dev_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAceWebDevTwoTest"
}
ohos_app_scope("ace_ets_web_dev_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ace_ets_web_dev_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("ace_ets_web_dev_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":ace_ets_web_dev_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.open.harmony.acewebtwotest",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [{
"test-file-name": [
"ActsAceWebDevTwoTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}]
}
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage)
globalThis.windowStage = windowStage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/web", null)
}
onWindowStageDestroy() {
//Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
};
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
let loadedUrl;
@Entry
@Component
struct Index {
controller:WebController = new WebController()
responseweb: WebResourceResponse = new WebResourceResponse()
@State str:string="emitStoreWebArchive"
@State text:string=""
@State textRatio:number=100
@State zoomAccessValue:boolean=true
host: string = "www.spincast.org"
realm: string = "protected example"
username_password: string[]
origin: string="file:///"
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("web page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
private jsObj={
test:(res)=>{
Utils.emitEvent(res,102);
},
toString:(str)=>{
console.info("ets toString:"+String(str));
},
register:(res)=>{
Utils.emitEvent(res,86);
return "web222"
}
}
aboutToAppear(){
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build(){
Column(){
Web({src:$rawfile('index.html'),controller:this.controller})
.databaseAccess(true)
.zoomAccess(this.zoomAccessValue)
.textZoomRatio(this.textRatio)
.onConsole((event) => {
let level = event.message.getMessageLevel()
let msg = event.message.getMessage()
let lineNumber = event.message.getLineNumber().toString()
let sourceId = event.message.getSourceId()
console.log("lineNumber:" + lineNumber)
setTimeout(()=>{
Utils.emitEvent(lineNumber,420)
},3000)
setTimeout(()=>{
Utils.emitEvent(sourceId,422)
},3000)
return false
})
.onSearchResultReceive(ret=>{
var searchResult = ret.activeMatchOrdinal.toString() +
ret.numberOfMatches.toString()
console.log("searchResult" + searchResult)
setTimeout(()=>{
Utils.emitEvent(searchResult,426)
},3000)
})
Row(){
Button("web click").key('webcomponent').onClick(async ()=>{
console.info("key==>"+this.str)
switch(this.str){
case "emitStoreWebArchive":{
let webAsyncController = new web_webview.WebAsyncController(this.controller)
webAsyncController.storeWebArchive("/data/storage/el2/base/",true,(filename) => {
if(filename != null) {
Utils.emitEvent(filename,400)
}
})
break;
}
case "emitAllowGeolocation":{
web_webview.GeolocationPermissions.allowGeolocation("file:///")
web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => {
if (error) {
console.log('error:' + JSON.stringify(error));
this.text = this.origin + ",error ," + JSON.stringify(error);
return;
}
this.text = this.origin + ", result: " + result;
Utils.emitEvent(this.text,402)
})
break;
}
case "emitDeleteGeolocation":{
web_webview.GeolocationPermissions.deleteGeolocation("file:///")
web_webview.GeolocationPermissions.getStoredGeolocation((error,origins) => {
if (error) {
console.log('error:' + JSON.stringify(error));
this.text = origins + ",error ," + JSON.stringify(error);
return;
}
this.text = origins.join();
Utils.emitEvent(this.text,404)
})
break;
}
case "emitDeleteAllGeolocation":{
web_webview.GeolocationPermissions.allowGeolocation("file:///")
web_webview.GeolocationPermissions.deleteAllGeolocation()
web_webview.GeolocationPermissions.getStoredGeolocation((error,origins) => {
if (error) {
console.log('error:' + JSON.stringify(error));
this.text = origins + ",error ," + JSON.stringify(error);
return;
}
this.text = origins.join();
Utils.emitEvent(this.text,406)
})
break;
}
case "emitIsCookieAllowed":{
web_webview.WebCookieManager.putAcceptCookieEnabled(false);
setTimeout(()=>{
Utils.emitEvent(web_webview.WebCookieManager.isCookieAllowed(),408)
},3000)
break;
}
case "emitSaveCookieAsync":{
web_webview.WebCookieManager.saveCookieAsync(function(result){
Utils.emitEvent(result,410)
})
break;
}
case "emitIsThirdPartyCookieAllowed":{
web_webview.WebCookieManager.putAcceptThirdPartyCookieEnabled(false);
setTimeout(()=>{
var result = web_webview.WebCookieManager.isThirdPartyCookieAllowed();
console.log(result.toString());
Utils.emitEvent(web_webview.WebCookieManager.isThirdPartyCookieAllowed(),412)
},3000)
break;
}
case "emitExistCookie":{
this.controller.getCookieManager().deleteEntireCookie();
setTimeout(()=>{
var result = web_webview.WebCookieManager.existCookie();
console.log(result.toString());
Utils.emitEvent(result,414)
},3000)
break ;
}
case "emitOnConsole":{
this.controller.runJavaScript({script:"consoleTest()"})
break;
}
case "emitLoaData":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"})
setTimeout(()=>{
this.controller.loadData({
data: "<html><title>index</title></html>",
mimeType: "text/html",
encoding: "UTF-8"
})
},3000)
setTimeout(()=>{
this.text = this.controller.getTitle();
Utils.emitEvent(this.text,424)
},4000)
break ;
}
case "emitZoomAccess":{
this.zoomAccessValue = false
this.controller.refresh()
var origin = this.controller.getPageHeight()
var zoomInCalled = false
setTimeout(()=>{
this.controller.zoomIn()
if (this.controller.getPageHeight() > origin) {
zoomInCalled = true
}
console.log("final" + this.controller.getPageHeight())
Utils.emitEvent(zoomInCalled,428);
},3000);
break ;
}
case "emitSaveHttpAuthCredentials":{
web_webview.WebDataBase.saveHttpAuthCredentials(this.host, this.realm, "Stromgol", "Laroche");
setTimeout(()=>{
let result = web_webview.WebDataBase.existHttpAuthCredentials();
Utils.emitEvent(result,442)
},3000)
break;
}
case "emitGetHttpAuthCredentials":{
this.username_password = web_webview.WebDataBase.getHttpAuthCredentials(this.host, this.realm);
setTimeout(()=>{
let result = this.username_password[0];
Utils.emitEvent(result,444)
},3000)
break;
}
case "emitDeleteHttpAuthCredentials":{
web_webview.WebDataBase.deleteHttpAuthCredentials();
setTimeout(()=>{
let result = web_webview.WebDataBase.existHttpAuthCredentials();
Utils.emitEvent(result,446)
},3000)
break;
}
case "emitSearchAllAsync":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"})
setTimeout(()=>{
this.controller.searchAllAsync("首页");
},3000)
break ;
}
default:
console.info("can not match case")
}
})
}
}
}
}
/*
* Copyright (c) 2022 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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import webJsunit from './WebJsunit.test'
export default function testsuite() {
webJsunit()
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import events_emitter from '@ohos.events.emitter';
import { expect } from "@ohos/hypium";
export default class Utils {
static sleep(time){
return new Promise((resolve,reject)=>{
setTimeout(()=>{
resolve("ok")
},time)
}).then(()=>{
console.info(`sleep ${time} over...`)
})
}
static registerEvent(testCaseName,expectedValue,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertEqual(expectedValue);
console.info(`[${testCaseName}] END`);
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static emitEvent(actualValue,eventId){
try {
let backData = {
data: {
"ACTION": actualValue
}
}
let backEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
console.info("webFlag start to emit action state");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("webFlag emit action state err: " + JSON.stringify(err));
}
}
static registerEventTwo(testCaseName,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.actualValue).assertLarger(backData.data.expectedValue-100);
expect(backData.data.actualValue).assertLess(backData.data.expectedValue-(-100));
console.info(`[${testCaseName}] END`);
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static emitEventTwo(expectedValue,actualValue,eventId){
try {
let backData = {
data: {
"expectedValue":expectedValue,
"actualValue":actualValue
}
}
let backEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
console.info("webFlag start to emit action state");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("webFlag emit action state err: " + JSON.stringify(err));
}
}
static registerContainEvent(testCaseName,expectedValue,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertContain(expectedValue);
console.info(`[${testCaseName}] END`);
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static commitKey(emitKey){
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import { describe, beforeEach, afterEach, it, expect } from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
let emitKey = "emitUserAgent";
export default function webJsunit() {
describe('ActsAceWebDevTest', function () {
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("web beforeEach start");
done();
})
afterEach(async function (done) {
console.info("web afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_066
*tc.name storeWebArchive
*tc.desic Save current page
*/
it('storeWebArchive',0,async function(done){
emitKey="emitAllowGeolocation";
Utils.registerContainEvent("storeWebArchive","/data/storage/el2/base/",400,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_067
*tc.name allowGeolocation
*tc.desic allow specific url to access the geolocation
*/
it('allowGeolocation',0,async function(done){
emitKey="emitDeleteGeolocation";
Utils.registerEvent("allowGeolocation","file:///, result: true",402,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_068
*tc.name deleteGeolocation
*tc.desic delete specific restored geolocation
*/
it('deletGeolocation',0,async function(done){
emitKey="emitDeleteAllGeolocation";
Utils.registerEvent("deletGeolocation","",404,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_069
*tc.name deletAllGeolocation
*tc.desic delete all restored geolocation
*/
it('deletAllGeolocation',0,async function(done){
emitKey="emitIsCookieAllowed";
Utils.registerEvent("deletAllGeolocation","",406,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_070
*tc.name isCookieAllowed
*tc.desic return whether the cookie is allowed
*/
it('isCookieAllowed',0,async function(done){
emitKey="emitSaveCookieAsync";
Utils.registerEvent("isCookieAllowed",false,408,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_071
*tc.name saveCookieAsync
*tc.desic return whether the cookie is allowed
*/
it('saveCookieAsync',0,async function(done){
emitKey="emitIsThirdPartyCookieAllowed";
Utils.registerEvent("saveCookieAsync",true,410,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_072
*tc.name isThirdPartyCookieAllowed
*tc.desic return whether the third party cookie is allowed
*/
it('isThirdPartyCookieAllowed',0,async function(done){
emitKey="emitExistCookie";
Utils.registerEvent("isThirdPartyCookieAllowed",false,412,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_073
*tc.name existCookie
*tc.desic return whether there exits cookie
*/
it('existCookie',0,async function(done){
emitKey="emitOnConsole";
Utils.registerEvent("existCookie",false,414,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_076
*tc.name getLineNumber
*tc.desic return the number of console message lines
*/
it('getLineNumber',0,async function(done){
emitKey="emitOnConsole";
Utils.registerEvent("getLineNumber","51",420,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_077
*tc.name getSourceId
*tc.desic return the source url
*/
it('getSourceId',0,async function(done){
emitKey="emitLoaData";
Utils.registerEvent("getSourceId","file:///data/storage/el1/bundle/phone/resources/rawfile/index.html",422,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_078
*tc.name loadData
*tc.desic load specific strings
*/
it('loadData',0,async function(done){
emitKey="emitZoomAccess";
Utils.registerEvent("loadData","index",424,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_080
*tc.name zoomAccess
*tc.desic set whether it is allowed to zoom
*/
it('zoomAccess',0,async function(done){
emitKey="emitSaveHttpAuthCredentials";
Utils.registerEvent("zoomAccess",false,428,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_087
*tc.name saveHttpAuthCredentials
*tc.desic save credentials
*/
it('saveHttpAuthCredentials',0,async function(done){
emitKey="emitGetHttpAuthCredentials";
Utils.registerEvent("saveHttpAuthCredentials",true,442,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_088
*tc.name getHttpAuthCredentials
*tc.desic delete credentials
*/
it('getHttpAuthCredentials',0,async function(done){
emitKey="emitDeleteHttpAuthCredentials";
Utils.registerEvent("getHttpAuthCredentials","Stromgol",444,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_089
*tc.name deleteHttpAuthCredentials
*tc.desic delete credentials
*/
it('deleteHttpAuthCredentials',0,async function(done){
emitKey="emitSearchAllAsync";
Utils.registerEvent("deleteHttpAuthCredentials",false,446,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_079
*tc.name searchAllAsync
*tc.desic search specific words
*/
it('searchAllAsync',0,async function(done){
emitKey="emitSearchAllAsync";
Utils.registerEvent("searchAllAsync","01",426,done);
sendEventByKey('webcomponent',10,'');
})
})
}
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
}],
"requestPermissions": [
{
"name": "ohos.permission.LOCATION"
},
{
"name": "ohos.permission.INTERNET"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"MainAbility/pages/web"
]
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<body>
<div id="pageHeight"></div>
<p style="background-color:green;font-family:arial;color:red;font-size:300px;text-align:center"> <a href="http://www.w3school.com.cn">This is a link</a></p>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>index</title>
<style>
#pageHeight{
height:1300px
}
</style>
</head>
<body>
<div id="container">首页</div>
<div id="pageHeight"></div>
<a href="file:///data/storage/el1/bundle/phone/resources/rawfile/second.html" id="fileAccess">打开rawfile文件</a>
<img src="file:///data/storage/el1/bundle/phone/resources/rawfile/icon.png" alt="icon" id="imgs">
</body>
<script>
let ele=document.getElementById("imgs");
let loadImage;
ele.onload=function(){
loadImage="load complete"
}
function getUserAgent(){
return navigator.userAgent
}
function test(){
backToEts.test("backToEts")
}
function testRunJavaScript(){
return "testRunJavaScript"
}
function getPageHeight(){
let height=document.body.scrollHeight
return height
}
function proxy(){
objName.register("backToEts")
}
function registerTest(){
let str=objName.register();
console.log(str);
return str
}
function jsAccess(){
console.log("web111")
}
function consoleTest(){
console.log("console test")
}
function alertTest(){
alert('alert test')
}
function confirmTest(){
confirm("confirm test")
}
function getImgResult(){
return loadImage
}
function toPrompt(){
let result=prompt("age","20");
console.log("result:"+result)
}
function openRawFile(){
document.getElementById("fileAccess").click()
}
</script>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>second</title>
</head>
<body>
<div style="height: 1300px;background-color: #999999;">second pages</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript">
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
var msg;
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "W3Cschool教程")');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "www.w3cschool.cn")');
msg = '<p>数据表已创建,且插入了两条数据。</p>';
document.querySelector('#status').innerHTML = msg;
});
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM LOGS', [], function (tx, results) {
var len = results.rows.length, i;
msg = "<p>查询记录条数: " + len + "</p>";
document.querySelector('#status').innerHTML += msg;
for (i = 0; i < len; i++){
msg = "<p><b>" + results.rows.item(i).log + "</b></p>";
document.querySelector('#status').innerHTML += msg;
}
}, null);
});
</script>
</head>
<body>
<div id="status" name="status">状态信息</div>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册