1/** 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" 16import router from '@ohos.router'; 17import {UiComponent, Driver, Component, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest'; 18import CommonFunc from '../MainAbility/utils/Common'; 19import {MessageManager,Callback} from '../MainAbility/utils/MessageManager'; 20export default function LineMetricsTwoTest() { 21 describe('LineMetricsTwoTest', ()=> { 22 beforeEach(async (done:Function)=> { 23 let beforeEachMsg = " ====beforeEach====" 24 console.info( beforeEachMsg + " 1 "); 25 let options :router.RouterOptions= { 26 url: 'MainAbility/pages/LineMetricsTwo', 27 } 28 let result = await router.push(options); 29 console.info( beforeEachMsg + " 2 "); 30 await CommonFunc.sleep(5000); 31 done(); 32 }); 33 /** 34 * @tc.number SUB_BASIC_WMS_SPCIAL_XTS_GRAPHICTEXT_JS_API_002 35 * @tc.name testLineMetricsTest_2 36 * @tc.desc api 37 * @tc.level: Level 2 38 * @tc.type : 39 * @tc.size : 40 */ 41 it('testLineMetricsTest_2', 0, async (done:Function)=> { 42 let msg = "====testLineMetricsTest_2====" 43 console.info('testLineMetricsTest_2 START'); 44 let driver = await Driver.create() 45 await CommonFunc.sleep(1000); 46 let button = await driver.findComponent(ON.id('LineMetrics_4')); 47 await button.click(); 48 await CommonFunc.sleep(1000); 49 let strJson1 = getInspectorByKey('LineMetrics_1'); 50 let strJson2 = getInspectorByKey('LineMetrics_2'); 51 let strJson3 = getInspectorByKey('LineMetrics_3'); 52 let strJson5 = getInspectorByKey('LineMetrics_5'); 53 let strJson6 = getInspectorByKey('LineMetrics_6'); 54 let obj1:ESObject = JSON.parse(strJson1); 55 let obj2:ESObject = JSON.parse(strJson2); 56 let obj3:ESObject = JSON.parse(strJson3); 57 let obj5:ESObject = JSON.parse(strJson5); 58 let obj6:ESObject = JSON.parse(strJson6); 59 expect(obj1.$attrs.content).assertEqual('1'); 60 expect(obj2.$attrs.content).assertEqual('7'); 61 expect(obj3.$attrs.content).assertEqual('10'); 62 expect(obj5.$attrs.content).assertEqual('5'); 63 expect(obj6.$attrs.content).assertEqual('6'); 64 console.log(msg + " obj5.$attrs.content: " + obj5.$attrs.content) 65 console.log(msg + " obj6.$attrs.content: " + obj6.$attrs.content) 66 console.info('[LineMetricsTest_0200] END'); 67 expect(true).assertTrue() 68 done(); 69 }); 70 }) 71} 72 73