提交 f588518c 编写于 作者: L lixinyi1094590959 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/xts_acts into master

Signed-off-by: Nlixinyi1094590959 <lixinyi38@huawei.com>
......@@ -142,7 +142,7 @@ export default function layoutConstraintsJsunit() {
console.info("[testLayoutConstraints005] component strJson:" + strJson);
let obj = JSON.parse(strJson);
console.info("[testLayoutConstraints005] aspectRatio: " + obj.$attrs.aspectRatio);
expect(obj.$attrs.aspectRatio).assertEqual(1);
expect(obj.$attrs.aspectRatio).assertEqual("");
done();
});
......
......@@ -15,11 +15,15 @@
@Entry
@Component
struct RichEditorExample {
@State spanStart: number = -1;
@State spanEnd: number = -1;
@State spanNum: number = -1;
@State text1: string = '';
@State text2: string = '';
@State current: number = 5
@State Richdelete: Boolean = false;
controller1:RichEditorController = new RichEditorController();
RichEditorInsertValue: RichEditorInsertValue = { insertOffset:10, insertValue:"aaaaaa" }
controller: RichEditorController = new RichEditorController()
build() {
Column() {
......@@ -109,24 +113,60 @@ struct RichEditorExample {
Column() {
RichEditor({ controller: this.controller })
.key('Stage_RichEditor_Test_2100')
.key('Stage_RichEditor_Test_2200')
.aboutToIMEInput((RichEditorInsertValue) => {
let InsertValue: RichEditorInsertValue = { insertOffset:10, insertValue:"aaaaaa" }
InsertValue.insertValue.toString()
RichEditorInsertValue.insertValue.toString()
InsertValue.insertOffset.toString()
RichEditorInsertValue.insertOffset.toString()
console.log("wxh test app aboutToIMEInput")
return true
})
.key('Stage_RichEditor_Test_2300')
.onIMEInputComplete((RichEditorTextSpanResult) => {
let TextSpanResult: RichEditorTextSpanResult = { spanPosition:{ spanIndex:10, spanRange:[10,10]},value:"aaaaa",textStyle:(null),offsetInSpan:[10,100]}
let SpanPosition: RichEditorSpanPosition = { spanIndex:20, spanRange:[20,20]}
SpanPosition.spanRange.toString()
SpanPosition.spanIndex.toString()
TextSpanResult.spanPosition.toString()
RichEditorTextSpanResult.spanPosition.toString()
TextSpanResult.offsetInSpan.toString()
RichEditorTextSpanResult.offsetInSpan.toString()
console.log("wxh test app onIMEInputComplete")
return ({ spanPosition:{ spanIndex:10, spanRange:[10,10]},value:"aaaaa",textStyle:(null),offsetInSpan:[10,100]})
})
.key('Stage_RichEditor_Test_2400')
.aboutToDelete((RichEditorDeleteValue) => {
let DeleteValue: RichEditorDeleteValue = { offset:10,direction:(RichEditorDeleteDirection.BACKWARD),length:10,richEditorDeleteSpans:(null)}
let DeleteValue1: RichEditorDeleteValue = { offset:10,direction:(RichEditorDeleteDirection.FORWARD),length:10,richEditorDeleteSpans:(null)}
DeleteValue.richEditorDeleteSpans.toString()
DeleteValue1.richEditorDeleteSpans.toString()
RichEditorDeleteValue.richEditorDeleteSpans.toString()
console.log("wxh test app aboutToDelete")
return true
})
}).key('Stage_RichEditor_Test_2600')
.onDeleteComplete(() => {
let DeleteValue: RichEditorDeleteValue = { offset:10,direction:(RichEditorDeleteDirection.BACKWARD),length:10,richEditorDeleteSpans:(null)}
let DeleteValue1: RichEditorDeleteValue = { offset:10,direction:(RichEditorDeleteDirection.FORWARD),length:10,richEditorDeleteSpans:(null)}
let ImageSpanResult: RichEditorImageSpanResult = { spanPosition:{ spanIndex:10, spanRange:[10,10]},valuePixelMap:(null),valueResourceStr:("aaa"),imageStyle:{ size:[10,10],verticalAlign:(ImageSpanAlignment.TOP),objectFit:(ImageFit.Auto)},offsetInSpan:[10,100]}
ImageSpanResult.offsetInSpan.toString()
ImageSpanResult.spanPosition.spanIndex.toString()
ImageSpanResult.spanPosition.spanRange.toString()
ImageSpanResult.valuePixelMap.isEditable.valueOf()
ImageSpanResult.valueResourceStr.toString()
ImageSpanResult.imageStyle.size.toString()
ImageSpanResult.imageStyle.verticalAlign.toString()
ImageSpanResult.imageStyle.objectFit.toString()
this.Richdelete = true;
console.log("wxh test app onDeleteComplete")
}).key('Stage_RichEditor_Test_2100')
}).key('Stage_RichEditor_Test_2700')
.onReady(() => {
let TextSpan: RichEditorTextSpan = { spanPosition:{ spanIndex:10, spanRange:[10,10]},value:"aaaaa",textStyle:{ }}
let ImageSpan: RichEditorImageSpan = { spanPosition:{ spanIndex:10, spanRange:[10,10]},value:"aaaaa",imageStyle:{ size:[10,10],verticalAlign:(ImageSpanAlignment.CENTER),objectFit:(ImageFit.Contain)}}
TextSpan.spanPosition.spanRange.toString()
TextSpan.spanPosition.spanIndex.toString()
for (let i = 0; i < 10; i++) {
this.controller.addTextSpan("实例文字", {
offset: 6,
......@@ -139,7 +179,6 @@ struct RichEditorExample {
decoration: { type: TextDecorationType.Underline, color: Color.Red }
}
})
this.controller.addImageSpan($r('app.media.icon'), {
offset: 0,
imageStyle: {
......@@ -148,6 +187,19 @@ struct RichEditorExample {
})
}
})
.key('Stage_RichEditor_Test_2500')
.onSelect((value: RichEditorSelection) => {
let Selection: RichEditorSelection = { selection:[10,10],spans:(null)}
Selection.selection.toString()
Selection.spans.toString()
this.spanStart = value.selection[0]
this.spanEnd = value.selection[1]
this.spanNum = value.spans.length
console.log("mim_log: onSelect selection start: " + value.selection[0])
console.log("mim_log: onSelect selection end: " + value.selection[1])
console.log("mim_log: onSelect spans length: " + value.spans.length);
return { selection:[10,10],spans:(null)}
})
.borderWidth(1).borderColor(Color.Green)
}
......
......@@ -41,28 +41,28 @@ export default function ActsRichEditorTest() {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
it('Stage_RichEditor_Test_0100', 0, async function (done) {
console.info('Stage_RichEditor_Test_0100 START');
try{
let controller = new RichEditorController()
let res = controller.addTextSpan("实例文字0", {
offset: 5,
style: {
fontColor: Color.Red,
fontSize: 8,
fontStyle: FontStyle.Italic,
fontWeight: FontWeight.Lighter,
fontFamily: "sans-serif",
decoration: { type: TextDecorationType.None, color: Color.Brown }
}
})
console.info('Stage_Font_0100 START :'+ JSON.stringify(res));
expect(typeof(res)).assertEqual('number')
expect(res).assertEqual(0)
console.info('Stage_RichEditor_Test_0100 END ');
} catch(err) {
expect().assertFail()
console.info('Stage_RichEditor_Test_0100 ERR '+ JSON.stringify(err));
}
done();
try{
let controller = new RichEditorController()
let res = controller.addTextSpan("实例文字0", {
offset: 5,
style: {
fontColor: Color.Red,
fontSize: 8,
fontStyle: FontStyle.Italic,
fontWeight: FontWeight.Lighter,
fontFamily: "sans-serif",
decoration: { type: TextDecorationType.None, color: Color.Brown }
}
})
console.info('Stage_Font_0100 START :'+ JSON.stringify(res));
expect(typeof(res)).assertEqual('number')
expect(res).assertEqual(0)
console.info('Stage_RichEditor_Test_0100 END ');
} catch(err) {
expect().assertFail()
console.info('Stage_RichEditor_Test_0100 ERR '+ JSON.stringify(err));
}
done();
});
it('Stage_RichEditor_Test_0200', 0, async function (done) {
......@@ -396,57 +396,196 @@ export default function ActsRichEditorTest() {
it('Stage_RichEditor_Test_2100', 0, async function (done) {
console.info('Stage_RichEditor_Test_2100 START');
setTimeout(()=>{
try{
let RichEditorInsertValue: RichEditorInsertValue = { insertOffset:10, insertValue:"aaaaaa" }
let RichEditorSpanPosition: RichEditorSpanPosition = { spanIndex:10, spanRange:[10,10]}
let RichEditorTextSpan: RichEditorTextSpan = { spanPosition:{ spanIndex:10, spanRange:[10,10]},value:"aaaaa",textStyle:{ }}
let RichEditorImageSpanStyle: RichEditorImageSpanStyle = { size:[10,10],verticalAlign:(ImageSpanAlignment.CENTER),objectFit:(ImageFit.Contain)}
let RichEditorTextSpanResult: RichEditorTextSpanResult = { spanPosition:{ spanIndex:10, spanRange:[10,10]},value:"aaaaa",textStyle:(null),offsetInSpan:[10,100]}
let RichEditorImageSpanStyleResult: RichEditorImageSpanStyleResult = { size:[10,10],verticalAlign:(ImageSpanAlignment.BASELINE),objectFit:(ImageFit.Cover)}
let RichEditorImageSpanResult: RichEditorImageSpanResult = { spanPosition:{ spanIndex:10, spanRange:[10,10]},valuePixelMap:(null),valueResourceStr:("aaa"),imageStyle:{ size:[10,10],verticalAlign:(ImageSpanAlignment.TOP),objectFit:(ImageFit.Auto)},offsetInSpan:[10,100]}
let RichEditorImageSpan: RichEditorImageSpan = { spanPosition:{ spanIndex:10, spanRange:[10,10]},value:"aaaaa",imageStyle:{ size:[10,10],verticalAlign:(ImageSpanAlignment.CENTER),objectFit:(ImageFit.Contain)}}
let RichEditorImageSpanOptions: RichEditorImageSpanOptions = { offset:10,imageStyle:{ size:[10,10],verticalAlign:(ImageSpanAlignment.CENTER),objectFit:(ImageFit.Contain)}}
let RichEditorUpdateImageSpanStyleOptions: RichEditorUpdateImageSpanStyleOptions = { imageStyle:{ size:[10,10],verticalAlign:(ImageSpanAlignment.CENTER),objectFit:(ImageFit.Contain)}}
let RichEditorSelection: RichEditorSelection = { selection:[10,10],spans:(null)}
let RichEditorDeleteValue: RichEditorDeleteValue = { offset:10,direction:(0),length:10,richEditorDeleteSpans:(null)}
let RichEditorDeleteValue1: RichEditorDeleteValue = { offset:10,direction:(1),length:10,richEditorDeleteSpans:(null)}
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(RichEditorInsertValue))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(RichEditorSpanPosition))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(RichEditorTextSpan))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(RichEditorImageSpanStyle))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(RichEditorTextSpanResult))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(RichEditorImageSpanStyleResult))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(RichEditorImageSpanResult))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(RichEditorImageSpan))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(RichEditorImageSpanOptions))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(RichEditorUpdateImageSpanStyleOptions))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(RichEditorSelection))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(RichEditorDeleteValue))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(RichEditorDeleteValue1))
expect(typeof RichEditorInsertValue).assertEqual("object")
expect(typeof RichEditorSpanPosition).assertEqual("object")
expect(typeof RichEditorTextSpan).assertEqual("object")
expect(typeof RichEditorImageSpanStyle).assertEqual("object")
expect(typeof RichEditorTextSpanResult).assertEqual("object")
expect(typeof RichEditorImageSpanStyleResult).assertEqual("object")
expect(typeof RichEditorImageSpanResult).assertEqual("object")
expect(typeof RichEditorImageSpan).assertEqual("object")
expect(typeof RichEditorImageSpanOptions).assertEqual("object")
expect(typeof RichEditorUpdateImageSpanStyleOptions).assertEqual("object")
expect(typeof RichEditorSelection).assertEqual("object")
expect(typeof RichEditorDeleteValue).assertEqual("object")
expect(typeof RichEditorDeleteValue1).assertEqual("object")
console.info('Stage_RichEditor_Test_2100 END ');
} catch(err) {
expect().assertFail()
console.info('Stage_RichEditor_Test_2100 ERR '+ JSON.stringify(err));
}
done();
},500)
});
it('Stage_RichEditor_Test_2200', 0, async function (done) {
console.info('Stage_RichEditor_Test_2200 START');
setTimeout(()=>{
try{
let RichEditorInsertValue: RichEditorInsertValue = { insertOffset:10, insertValue:"aaaaaa" }
console.info("Stage_RichEditor_Test_2200 InsertValue is: " + JSON.stringify(RichEditorInsertValue))
expect(typeof RichEditorInsertValue).assertEqual("object")
expect(RichEditorInsertValue.insertOffset).assertEqual(10)
expect(RichEditorInsertValue.insertValue).assertEqual("aaaaaa")
console.info('Stage_RichEditor_Test_2200 END ');
} catch(err) {
expect().assertFail()
console.info('Stage_RichEditor_Test_2200 ERR '+ JSON.stringify(err));
}
done();
},500)
});
it('Stage_RichEditor_Test_2300', 0, async function (done) {
console.info('Stage_RichEditor_Test_2300 START');
setTimeout(()=>{
try{
let RichEditorTextSpanResult: RichEditorTextSpanResult = { spanPosition:{ spanIndex:10, spanRange:[10,10]},value:"aaaaa",textStyle:(null),offsetInSpan:[10,100]}
let RichEditorSpanPosition: RichEditorSpanPosition = { spanIndex:20, spanRange:[20,20]}
console.info("Stage_RichEditor_Test_2300 InsertValue is: " + JSON.stringify(RichEditorTextSpanResult))
console.info("Stage_RichEditor_Test_2300 InsertValue is: " + JSON.stringify(RichEditorSpanPosition))
expect(typeof RichEditorTextSpanResult).assertEqual("object")
expect(typeof RichEditorSpanPosition).assertEqual("object")
expect(RichEditorTextSpanResult.spanPosition.spanIndex).assertEqual(10)
expect(RichEditorTextSpanResult.spanPosition.spanRange[0]).assertEqual(10)
expect(RichEditorTextSpanResult.spanPosition.spanRange[1]).assertEqual(10)
expect(RichEditorSpanPosition.spanIndex).assertEqual(20)
expect(RichEditorSpanPosition.spanRange[0]).assertEqual(20)
expect(RichEditorSpanPosition.spanRange[1]).assertEqual(20)
expect(RichEditorTextSpanResult.offsetInSpan[0]).assertEqual(10)
expect(RichEditorTextSpanResult.offsetInSpan[1]).assertEqual(100)
console.info('Stage_RichEditor_Test_2300 END ');
} catch(err) {
expect().assertFail()
console.info('Stage_RichEditor_Test_2300 ERR '+ JSON.stringify(err));
}
done();
},500)
});
it('Stage_RichEditor_Test_2400', 0, async function (done) {
console.info('Stage_RichEditor_Test_2400 START');
setTimeout(()=>{
try{
let RichEditorDeleteValue: RichEditorDeleteValue = { offset:10,direction:(0),length:10,richEditorDeleteSpans:(null)}
let RichEditorDeleteValue1: RichEditorDeleteValue = { offset:10,direction:(1),length:10,richEditorDeleteSpans:(null)}
console.info("Stage_RichEditor_Test_2400 InsertValue is: " + JSON.stringify(RichEditorDeleteValue))
console.info("Stage_RichEditor_Test_2400 InsertValue is: " + JSON.stringify(RichEditorDeleteValue1))
expect(typeof RichEditorDeleteValue).assertEqual("object")
expect(typeof RichEditorDeleteValue1).assertEqual("object")
expect(RichEditorDeleteValue.richEditorDeleteSpans).assertEqual(null)
expect(RichEditorDeleteValue1.richEditorDeleteSpans).assertEqual(null)
console.info('Stage_RichEditor_Test_2400 END ');
} catch(err) {
expect().assertFail()
console.info('Stage_RichEditor_Test_2400 ERR '+ JSON.stringify(err));
}
done();
},500)
});
it('Stage_RichEditor_Test_2500', 0, async function (done) {
console.info('Stage_RichEditor_Test_2500 START');
setTimeout(()=>{
try{
let RichEditorSelection: RichEditorSelection = { selection:[10,10],spans:(null)}
console.info("Stage_RichEditor_Test_2500 InsertValue is: " + JSON.stringify(RichEditorSelection))
expect(typeof RichEditorSelection).assertEqual("object")
expect(RichEditorSelection.selection[0]).assertEqual(10)
expect(RichEditorSelection.selection[1]).assertEqual(10)
expect(RichEditorSelection.spans).assertEqual(null)
console.info('Stage_RichEditor_Test_2500 END ');
} catch(err) {
expect().assertFail()
console.info('Stage_RichEditor_Test_2500 ERR '+ JSON.stringify(err));
}
done();
},500)
});
it('Stage_RichEditor_Test_2600', 0, async function (done) {
console.info('Stage_RichEditor_Test_2600 START');
setTimeout(()=>{
try{
let InsertValue: RichEditorInsertValue = { insertOffset:10, insertValue:"aaaaaa" }
let SpanPosition: RichEditorSpanPosition = { spanIndex:10, spanRange:[10,10]}
let TextSpan: RichEditorTextSpan = { spanPosition:{ spanIndex:10, spanRange:[10,10]},value:"aaaaa",textStyle:{ }}
let ImageSpanStyle: RichEditorImageSpanStyle = { size:[10,10],verticalAlign:(ImageSpanAlignment.CENTER),objectFit:(ImageFit.Contain)}
let TextSpanResult: RichEditorTextSpanResult = { spanPosition:{ spanIndex:10, spanRange:[10,10]},value:"aaaaa",textStyle:(null),offsetInSpan:[10,100]}
let ImageSpanStyleResult: RichEditorImageSpanStyleResult = { size:[10,10],verticalAlign:(ImageSpanAlignment.BASELINE),objectFit:(ImageFit.Cover)}
let ImageSpanResult: RichEditorImageSpanResult = { spanPosition:{ spanIndex:10, spanRange:[10,10]},valuePixelMap:(null),valueResourceStr:("aaa"),imageStyle:{ size:[10,10],verticalAlign:(ImageSpanAlignment.TOP),objectFit:(ImageFit.Auto)},offsetInSpan:[10,100]}
let ImageSpan: RichEditorImageSpan = { spanPosition:{ spanIndex:10, spanRange:[10,10]},value:"aaaaa",imageStyle:{ size:[10,10],verticalAlign:(ImageSpanAlignment.CENTER),objectFit:(ImageFit.Contain)}}
let ImageSpanOptions: RichEditorImageSpanOptions = { offset:10,imageStyle:{ size:[10,10],verticalAlign:(ImageSpanAlignment.CENTER),objectFit:(ImageFit.Contain)}}
let ImageSpanStyleOptions: RichEditorUpdateImageSpanStyleOptions = { imageStyle:{ size:[10,10],verticalAlign:(ImageSpanAlignment.CENTER),objectFit:(ImageFit.Contain)}}
let Selection: RichEditorSelection = { selection:[10,10],spans:(null)}
let DeleteValue: RichEditorDeleteValue = { offset:10,direction:(0),length:10,richEditorDeleteSpans:(null)}
let DeleteValue1: RichEditorDeleteValue = { offset:10,direction:(1),length:10,richEditorDeleteSpans:(null)}
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(InsertValue))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(SpanPosition))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(TextSpan))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(ImageSpanStyle))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(TextSpanResult))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(ImageSpanStyleResult))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(ImageSpanResult))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(ImageSpan))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(ImageSpanOptions))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(ImageSpanStyleOptions))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(Selection))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(DeleteValue))
console.info("Stage_RichEditor_Test_2100 InsertValue is: " + JSON.stringify(DeleteValue1))
expect(typeof InsertValue).assertEqual("object")
expect(typeof SpanPosition).assertEqual("object")
expect(typeof TextSpan).assertEqual("object")
expect(typeof ImageSpanStyle).assertEqual("object")
expect(typeof TextSpanResult).assertEqual("object")
expect(typeof ImageSpanStyleResult).assertEqual("object")
expect(typeof ImageSpanResult).assertEqual("object")
expect(typeof ImageSpan).assertEqual("object")
expect(typeof ImageSpanOptions).assertEqual("object")
expect(typeof ImageSpanStyleOptions).assertEqual("object")
expect(typeof Selection).assertEqual("object")
expect(typeof DeleteValue).assertEqual("object")
expect(typeof DeleteValue1).assertEqual("object")
console.info('Stage_RichEditor_Test_2100 END ');
let RichEditorImageSpanResult: RichEditorImageSpanResult = { spanPosition:{ spanIndex:10, spanRange:[10,10]},valuePixelMap:(null),valueResourceStr:("aaa"),imageStyle:{ size:[10,10],verticalAlign:(ImageSpanAlignment.TOP),objectFit:(ImageFit.Auto)},offsetInSpan:[10,100]}
console.info("Stage_RichEditor_Test_2600 InsertValue is: " + JSON.stringify(RichEditorImageSpanResult))
expect(typeof RichEditorImageSpanResult).assertEqual("object")
expect(RichEditorImageSpanResult.spanPosition.spanRange[0]).assertEqual(10)
expect(RichEditorImageSpanResult.spanPosition.spanRange[1]).assertEqual(10)
expect(RichEditorImageSpanResult.spanPosition.spanIndex).assertEqual(10)
expect(RichEditorImageSpanResult.valuePixelMap).assertEqual(null)
expect(RichEditorImageSpanResult.valueResourceStr).assertEqual("aaa")
expect(RichEditorImageSpanResult.imageStyle.size[0]).assertEqual(10)
expect(RichEditorImageSpanResult.imageStyle.size[1]).assertEqual(10)
expect(RichEditorImageSpanResult.imageStyle.verticalAlign).assertEqual(ImageSpanAlignment.TOP)
expect(RichEditorImageSpanResult.imageStyle.objectFit).assertEqual(ImageFit.Auto)
expect(RichEditorImageSpanResult.offsetInSpan[0]).assertEqual(10)
expect(RichEditorImageSpanResult.offsetInSpan[1]).assertEqual(100)
console.info('Stage_RichEditor_Test_2600 END ');
} catch(err) {
expect().assertFail()
console.info('Stage_RichEditor_Test_2100 ERR '+ JSON.stringify(err));
console.info('Stage_RichEditor_Test_2600 ERR '+ JSON.stringify(err));
}
done();
},500)
});
it('Stage_RichEditor_Test_2700', 0, async function (done) {
console.info('Stage_RichEditor_Test_2700 START');
setTimeout(()=>{
try{
let RichEditorTextSpan: RichEditorTextSpan = { spanPosition:{ spanIndex:10, spanRange:[10,10]},value:"aaaaa",textStyle:{ }}
let RichEditorImageSpan: RichEditorImageSpan = { spanPosition:{ spanIndex:10, spanRange:[10,10]},value:"aaaaa",imageStyle:{ size:[10,10],verticalAlign:(ImageSpanAlignment.CENTER),objectFit:(ImageFit.Contain)}}
console.info("Stage_RichEditor_Test_2700 InsertValue is: " + JSON.stringify(RichEditorTextSpan))
console.info("Stage_RichEditor_Test_2700 InsertValue is: " + JSON.stringify(RichEditorImageSpan))
expect(typeof RichEditorTextSpan).assertEqual("object")
expect(typeof RichEditorImageSpan).assertEqual("object")
expect(RichEditorTextSpan.spanPosition.spanIndex).assertEqual(10)
expect(RichEditorTextSpan.spanPosition.spanRange[0]).assertEqual(10)
expect(RichEditorTextSpan.spanPosition.spanRange[1]).assertEqual(10)
expect(RichEditorImageSpan.spanPosition.spanIndex).assertEqual(10)
expect(RichEditorImageSpan.spanPosition.spanRange[0]).assertEqual(10)
expect(RichEditorImageSpan.spanPosition.spanRange[1]).assertEqual(10)
console.info('Stage_RichEditor_Test_2700 END ');
} catch(err) {
expect().assertFail()
console.info('Stage_RichEditor_Test_2700 ERR '+ JSON.stringify(err));
}
done();
},500)
});
})
}
......
......@@ -98,7 +98,7 @@ export default function ListJsunit() {
let gridRight = CommonFunc.getComponentRect('list');
let right = gridRight.right
let driver = await UiDriver.create()
await driver.swipe(Math.round(top + 50), Math.round(right - 50), Math.round(bottom - 50), Math.round(right - 50));
await driver.swipe(Math.round(top + 50), Math.round(right - 50), 20, Math.round(right - 50));
await CommonFunc.sleep(1000);
let onScrollText = await driver.findComponent(BY.key('onScrollText'));
......@@ -135,12 +135,12 @@ export default function ListJsunit() {
expect(text5).assertEqual('onScrollStop');
// Verify the functions of onReachEnd
await driver.swipe(Math.round(bottom - 50), Math.round(right - 50), Math.round(top + 50), Math.round(right - 50));
await driver.swipe(Math.round(bottom - 50), Math.round(right - 50), Math.round(top + 50), Math.round(right - 50));
await driver.swipe(Math.round(right), Math.round(top -100), 10, Math.round(top - 100));
await driver.swipe(Math.round(right), Math.round(top -100), 10, Math.round(top - 100));
await CommonFunc.sleep(1000);
await driver.swipe(Math.round(bottom - 50), Math.round(right - 50), Math.round(top + 50), Math.round(right - 50));
await driver.swipe(Math.round(bottom - 50), Math.round(right - 50), Math.round(top + 50), Math.round(right - 50));
await driver.swipe(Math.round(bottom - 50), Math.round(right - 50), Math.round(top + 50), Math.round(right - 50));
await driver.swipe(Math.round(right), Math.round(top -100), 10, Math.round(top - 100));
await driver.swipe(Math.round(right), Math.round(top -100), 10, Math.round(top - 100));
await driver.swipe(Math.round(right), Math.round(top -100), 10, Math.round(top - 100));
await CommonFunc.sleep(1000);
let onReachEndText = await driver.findComponent(BY.key('onReachEndText'));
let text= await onReachEndText.getText();
......@@ -278,7 +278,7 @@ export default function ListJsunit() {
expect(obj.$attrs.divider.color).assertEqual('#FF00000A');
expect(obj.$attrs.divider.startMargin).assertEqual('0.00vp');
expect(obj.$attrs.divider.endMargin).assertEqual('-10.00vp');
expect(obj.$attrs.scrollBar).assertEqual('BarState.Off');
expect(obj.$attrs.scrollBar).assertEqual('BarState.Auto');
await CommonFunc.sleep(1000);
expect(obj.$attrs.cachedCount).assertEqual('1');
expect(obj.$attrs.edgeEffect).assertEqual('EdgeEffect.None');
......
......@@ -31,6 +31,7 @@ struct List_ListInitialIndex1{
.key('List_ListInitialIndex1_'+ item)
}, item => item)
}
.cachedCount(0)
.width(300)
.height(500)
.listDirection(Axis.Vertical)
......
......@@ -31,6 +31,7 @@ struct List_ListInitialIndex2{
.key('List_ListInitialIndex2_'+ item)
}, item => item)
}
.cachedCount(0)
.width(300)
.height(500)
.listDirection(Axis.Vertical)
......
......@@ -31,6 +31,7 @@ struct List_ListInitialIndex3{
.key('List_ListInitialIndex3_'+ item)
}, item => item)
}
.cachedCount(0)
.width(300)
.height(500)
.listDirection(Axis.Vertical)
......
......@@ -31,6 +31,7 @@ struct List_ListInitialIndex4{
.key('List_ListInitialIndex4_'+ item)
}, item => item)
}
.cachedCount(0)
.width(300)
.height(500)
.listDirection(Axis.Vertical)
......
......@@ -31,6 +31,7 @@ struct List_ListInitialIndex5{
.key('List_ListInitialIndex5_'+ item)
}, item => item)
}
.cachedCount(0)
.width(300)
.height(500)
.listDirection(Axis.Vertical)
......
......@@ -31,6 +31,7 @@ struct List_ListInitialIndex6{
.key('List_ListInitialIndex6_'+ item)
}, item => item)
}
.cachedCount(0)
.width(300)
.height(500)
.listDirection(Axis.Vertical)
......
......@@ -103,7 +103,7 @@ do_make()
MUSL_ARGS="--gn-args use_musl=false --gn-args use_custom_libcxx=true --gn-args use_custom_clang=true"
fi
fi
./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target $BUILD_TARGET --build-target "deploy_testtools" --gn-args is_standard_system=true $MUSL_ARGS --target-cpu $TARGET_ARCH
./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target $BUILD_TARGET --build-target "deploy_testtools" --gn-args is_standard_system=true $MUSL_ARGS --target-cpu $TARGET_ARCH --get-warning-list=false --stat-ccache=false --compute-overlap-rate=false --deps-guard=false --generate-ninja-trace=false --gn-args skip_generate_module_list_file=true
else
if [ "$BUILD_TARGET" = "acts acts_ivi acts_intellitv acts_wearable" ]; then
./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target "acts" --build-target "acts_ivi" --build-target "acts_intellitv" --build-target "acts_wearable" --build-target "deploy_testtools"
......
......@@ -25,8 +25,8 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const KEY_TEST_NUMBER_ARRAY_ELEMENT = 'key_test_number_array';
const KEY_TEST_STRING_ARRAY_ELEMENT = 'key_test_string_array';
const KEY_TEST_BOOL_ARRAY_ELEMENT = 'key_test_bool_array';
var mPreferences;
var context;
let mPreferences;
let context;
export default function preferencesPromiseTest(){
describe('preferencesPromiseTest', function () {
......@@ -49,20 +49,16 @@ export default function preferencesPromiseTest(){
it('testPreferencesPutStringArray0131', 0, async function (done) {
await mPreferences.clear();
var stringArr = ['1', '2', '3'];
let promise1 = mPreferences.put(KEY_TEST_STRING_ARRAY_ELEMENT, stringArr);
await promise1;
let promise2 = mPreferences.get(KEY_TEST_STRING_ARRAY_ELEMENT, ['123', '321']);
promise2.then((pre) => {
await mPreferences.put(KEY_TEST_STRING_ARRAY_ELEMENT, stringArr);
await mPreferences.get(KEY_TEST_STRING_ARRAY_ELEMENT, ['123', '321']).then((pre) => {
for (let i = 0; i < stringArr.length; i++) {
expect(stringArr[i]).assertEqual(pre[i]);
}
done();
}).catch((err) => {
expect(null).assertFail();
done();
})
await promise2;
done();
});
/**
......@@ -73,19 +69,16 @@ export default function preferencesPromiseTest(){
it('testPreferencesPutNumberArray0132', 0, async function (done) {
await mPreferences.clear();
var numberArr = [11, 22, 33, 44, 55];
let promise1 = mPreferences.put(KEY_TEST_NUMBER_ARRAY_ELEMENT, numberArr);
await promise1;
let promise2 = mPreferences.get(KEY_TEST_NUMBER_ARRAY_ELEMENT, [123, 321]);
promise2.then((pre) => {
await mPreferences.put(KEY_TEST_NUMBER_ARRAY_ELEMENT, numberArr);
await mPreferences.get(KEY_TEST_NUMBER_ARRAY_ELEMENT, [123, 321]).then((pre) => {
for (let i = 0; i < numberArr.length; i++) {
expect(numberArr[i]).assertEqual(pre[i]);
}
done();
}).catch((err) => {
expect(null).assertFail();
done();
})
await promise2;
done();
});
/**
......@@ -96,19 +89,16 @@ export default function preferencesPromiseTest(){
it('testPreferencesPutBoolArray0133', 0, async function (done) {
await mPreferences.clear();
var boolArr = [true, true, false];
let promise1 = mPreferences.put(KEY_TEST_BOOL_ARRAY_ELEMENT, boolArr);
await promise1;
let promise2 = mPreferences.get(KEY_TEST_BOOL_ARRAY_ELEMENT, [false, true]);
promise2.then((pre) => {
await mPreferences.put(KEY_TEST_BOOL_ARRAY_ELEMENT, boolArr);
await mPreferences.get(KEY_TEST_BOOL_ARRAY_ELEMENT, [false, true]).then((pre) => {
for (let i = 0; i < boolArr.length; i++) {
expect(boolArr[i]).assertEqual(pre[i]);
}
done();
}).catch((err) => {
expect(null).assertFail();
done();
})
await promise2;
done();
});
/**
......@@ -130,8 +120,7 @@ export default function preferencesPromiseTest(){
await mPreferences.flush();
let promise = mPreferences.getAll();
promise.then((obj) => {
await mPreferences.getAll().then((obj) => {
expect(false).assertEqual(obj.key_test_boolean);
expect("123").assertEqual(obj.key_test_string);
expect(123.1).assertEqual(obj.key_test_float);
......@@ -149,12 +138,11 @@ export default function preferencesPromiseTest(){
for (let i = 0; i < nArr.length; i++) {
expect(nArr[i]).assertEqual(doubleArr[i]);
}
done();
}).catch((err) => {
expect(null).assertFail();
done();
})
await promise;
done();
})
/**
......@@ -165,15 +153,14 @@ export default function preferencesPromiseTest(){
it('testPreferencesClear0011', 0, async function (done) {
await mPreferences.put(KEY_TEST_STRING_ELEMENT, "test");
await mPreferences.flush();
const promise = mPreferences.clear();
promise.then(async (ret) => {
await mPreferences.clear().then(async (ret) => {
let per = await mPreferences.get(KEY_TEST_STRING_ELEMENT, "defaultvalue");
expect("defaultvalue").assertEqual(per);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
await promise;
done();
})
/**
......@@ -183,14 +170,13 @@ export default function preferencesPromiseTest(){
*/
it('testPreferencesHasKey0031', 0, async function (done) {
await mPreferences.put(KEY_TEST_STRING_ELEMENT, "test");
const promise = mPreferences.has(KEY_TEST_STRING_ELEMENT);
promise.then((ret) => {
await mPreferences.has(KEY_TEST_STRING_ELEMENT).then((ret) => {
expect(true).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
await promise;
done();
})
/**
......@@ -200,13 +186,13 @@ export default function preferencesPromiseTest(){
*/
it('testPreferencesHasKey0032', 0, async function (done) {
await mPreferences.put(KEY_TEST_INT_ELEMENT, 1);
const promise = mPreferences.has(KEY_TEST_INT_ELEMENT);
promise.then((ret) => {
await mPreferences.has(KEY_TEST_INT_ELEMENT).then((ret) => {
expect(true).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
await promise;
done();
})
......@@ -217,14 +203,13 @@ export default function preferencesPromiseTest(){
*/
it('testPreferencesHasKey0033', 0, async function (done) {
await mPreferences.put(KEY_TEST_FLOAT_ELEMENT, 2.0);
const promise = mPreferences.has(KEY_TEST_FLOAT_ELEMENT);
promise.then((ret) => {
await mPreferences.has(KEY_TEST_FLOAT_ELEMENT).then((ret) => {
expect(true).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
await promise;
done();
})
/**
......@@ -234,14 +219,13 @@ export default function preferencesPromiseTest(){
*/
it('testPreferencesHasKey0034', 0, async function (done) {
await mPreferences.put(KEY_TEST_BOOLEAN_ELEMENT, false);
const promise = mPreferences.has(KEY_TEST_BOOLEAN_ELEMENT);
promise.then((ret) => {
await mPreferences.has(KEY_TEST_BOOLEAN_ELEMENT).then((ret) => {
expect(true).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
await promise;
done();
})
/**
......@@ -251,14 +235,14 @@ export default function preferencesPromiseTest(){
*/
it('testPreferencesHasKey0035', 0, async function (done) {
await mPreferences.put(KEY_TEST_LONG_ELEMENT, 0);
const promise = mPreferences.has(KEY_TEST_LONG_ELEMENT);
promise.then((ret) => {
await mPreferences.has(KEY_TEST_LONG_ELEMENT).then((ret) => {
expect(true).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
await promise;
done();
})
/**
......@@ -268,14 +252,13 @@ export default function preferencesPromiseTest(){
*/
it('testPreferencesGetDefValue0061', 0, async function (done) {
await mPreferences.clear();
const promise = mPreferences.get(KEY_TEST_STRING_ELEMENT, "defaultValue");
promise.then((ret) => {
await mPreferences.get(KEY_TEST_STRING_ELEMENT, "defaultValue").then((ret) => {
expect('defaultValue').assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
await promise;
done();
})
/**
......@@ -286,14 +269,13 @@ export default function preferencesPromiseTest(){
it('testPreferencesGetFloat0071', 0, async function (done) {
await mPreferences.clear();
await mPreferences.put(KEY_TEST_FLOAT_ELEMENT, 3.0);
const promise = mPreferences.get(KEY_TEST_FLOAT_ELEMENT, 0.0);
promise.then((ret) => {
await mPreferences.get(KEY_TEST_FLOAT_ELEMENT, 0.0).then((ret) => {
expect(3.0).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
await promise;
done();
})
/**
......@@ -304,14 +286,13 @@ export default function preferencesPromiseTest(){
it('testPreferencesGetInt0081', 0, async function (done) {
await mPreferences.clear();
await mPreferences.put(KEY_TEST_INT_ELEMENT, 3);
const promise = mPreferences.get(KEY_TEST_INT_ELEMENT, 0.0);
promise.then((ret) => {
await mPreferences.get(KEY_TEST_INT_ELEMENT, 0.0).then((ret) => {
expect(3).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
await promise;
done();
})
/**
......@@ -322,14 +303,13 @@ export default function preferencesPromiseTest(){
it('testPreferencesGetLong0091', 0, async function (done) {
await mPreferences.clear();
await mPreferences.put(KEY_TEST_LONG_ELEMENT, 3);
const promise = mPreferences.get(KEY_TEST_LONG_ELEMENT, 0);
promise.then((ret) => {
await mPreferences.get(KEY_TEST_LONG_ELEMENT, 0).then((ret) => {
expect(3).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
await promise;
done();
})
/**
......@@ -341,14 +321,13 @@ export default function preferencesPromiseTest(){
await mPreferences.clear();
await mPreferences.put(KEY_TEST_STRING_ELEMENT, "test");
await mPreferences.flush();
const promise = mPreferences.get(KEY_TEST_STRING_ELEMENT, "defaultvalue");
promise.then((ret) => {
await mPreferences.get(KEY_TEST_STRING_ELEMENT, "defaultvalue").then((ret) => {
expect('test').assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
await promise;
done();
})
/**
......@@ -358,8 +337,7 @@ export default function preferencesPromiseTest(){
*/
it('testPreferencesPutBoolean0121', 0, async function (done) {
await mPreferences.clear();
let promise = mPreferences.put(KEY_TEST_BOOLEAN_ELEMENT, true);
await promise;
await mPreferences.put(KEY_TEST_BOOLEAN_ELEMENT, true);
let per = await mPreferences.get(KEY_TEST_BOOLEAN_ELEMENT, false);
expect(true).assertEqual(per);
await mPreferences.flush();
......@@ -375,8 +353,7 @@ export default function preferencesPromiseTest(){
*/
it('testPreferencesPutFloat0131', 0, async function (done) {
await mPreferences.clear();
const promise = mPreferences.put(KEY_TEST_FLOAT_ELEMENT, 4.0);
await promise;
await mPreferences.put(KEY_TEST_FLOAT_ELEMENT, 4.0);
let per = await mPreferences.get(KEY_TEST_FLOAT_ELEMENT, 0.0);
expect(4.0).assertEqual(per);
await mPreferences.flush();
......@@ -392,8 +369,7 @@ export default function preferencesPromiseTest(){
*/
it('testPreferencesPutInt0141', 0, async function (done) {
await mPreferences.clear();
let promise = mPreferences.put(KEY_TEST_INT_ELEMENT, 4);
await promise;
await mPreferences.put(KEY_TEST_INT_ELEMENT, 4);
let per = await mPreferences.get(KEY_TEST_INT_ELEMENT, 0);
expect(4).assertEqual(per);
await mPreferences.flush();
......@@ -408,8 +384,7 @@ export default function preferencesPromiseTest(){
* @tc.desc put long promise interface test
*/
it('testPreferencesPutLong0151', 0, async function (done) {
let promise = mPreferences.put(KEY_TEST_LONG_ELEMENT, 4);
await promise;
await mPreferences.put(KEY_TEST_LONG_ELEMENT, 4);
let per = await mPreferences.get(KEY_TEST_LONG_ELEMENT, 0);
expect(4).assertEqual(per);
await mPreferences.flush();
......@@ -424,8 +399,7 @@ export default function preferencesPromiseTest(){
* @tc.desc put String promise interface test
*/
it('testPreferencesPutString0161', 0, async function (done) {
let promise = mPreferences.put(KEY_TEST_STRING_ELEMENT, '');
await promise;
await mPreferences.put(KEY_TEST_STRING_ELEMENT, '');
let per = await mPreferences.get(KEY_TEST_STRING_ELEMENT, "defaultvalue")
expect('').assertEqual(per);
await mPreferences.flush();
......@@ -441,14 +415,13 @@ export default function preferencesPromiseTest(){
*/
it('testPreferencesGetDefValue00162', 0, async function (done) {
await mPreferences.clear();
let promise = mPreferences.get(KEY_TEST_BOOLEAN_ELEMENT, true);
promise.then((ret) => {
await mPreferences.get(KEY_TEST_BOOLEAN_ELEMENT, true).then((ret) => {
expect(true).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
await promise;
done();
})
})
}
\ No newline at end of file
......@@ -23,490 +23,457 @@ const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean';
const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const MAX_KEY_LENGTH = 'X'.repeat(80)
const MAX_VALUE_LENGTH = 'y'.repeat(8192)
var mPref;
let mPref;
export default function storagePromiseTest() {
describe('storagePromiseTest', function () {
beforeAll(async function (done) {
console.info('beforeAll')
const promise = storage.getStorage(PATH);
promise.then((Storage)=>{
mPref = Storage;
});
await promise;
done();
})
describe('storagePromiseTest', function () {
beforeAll(async function () {
console.info('beforeAll')
await storage.getStorage(PATH).then((Storage) => {
mPref = Storage;
});
})
afterAll(async function (done) {
console.info('afterAll')
const promise = storage.deleteStorage(PATH);
promise.then(()=>{
console.info('Delete Storage finish');
});
await promise;
done();
})
afterAll(async function () {
console.info('afterAll')
await storage.deleteStorage(PATH).then(() => {
console.info('Delete Storage finish');
});
})
/**
* @tc.name clear promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Promise_0010
* @tc.desc clear promise interface test
*/
it('testClear0011', 0, async function (done) {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
mPref.flushSync();
const promise = mPref.clear();
promise.then((ret) => {
expect("defaultvalue").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name clear promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Promise_0010
* @tc.desc clear promise interface test
*/
it('testClear0011', 0, async function (done) {
await mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
await mPref.flushSync();
await mPref.clear().then((ret) => {
expect("defaultvalue").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name has string interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0020
* @tc.desc has string interface test
*/
it('testHasKey0031', 0, async function (done) {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
const promise = mPref.has(KEY_TEST_STRING_ELEMENT);
promise.then((ret) => {
expect(true).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name has string interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0020
* @tc.desc has string interface test
*/
it('testHasKey0031', 0, async function (done) {
await mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
await mPref.has(KEY_TEST_STRING_ELEMENT).then((ret) => {
expect(true).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name has int interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0140
* @tc.desc has int interface test
*/
it('testHasKey0032', 0, async function (done) {
mPref.putSync(KEY_TEST_INT_ELEMENT, 1);
const promise = mPref.has(KEY_TEST_INT_ELEMENT);
promise.then((ret) => {
expect(true).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name has int interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0140
* @tc.desc has int interface test
*/
it('testHasKey0032', 0, async function (done) {
await mPref.putSync(KEY_TEST_INT_ELEMENT, 1);
await mPref.has(KEY_TEST_INT_ELEMENT).then((ret) => {
expect(true).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name has float interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0150
* @tc.desc has float interface test
*/
it('testHasKey0033', 0, async function (done) {
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 2.0);
const promise = mPref.has(KEY_TEST_FLOAT_ELEMENT);
promise.then((ret) => {
expect(true).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name has float interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0150
* @tc.desc has float interface test
*/
it('testHasKey0033', 0, async function (done) {
await mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 2.0);
await mPref.has(KEY_TEST_FLOAT_ELEMENT).then((ret) => {
expect(true).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name has boolean interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0160
* @tc.desc has boolean interface test
*/
it('testHasKey0034', 0, async function (done) {
mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, false);
const promise = mPref.has(KEY_TEST_BOOLEAN_ELEMENT);
promise.then((ret) => {
expect(true).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name has boolean interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0160
* @tc.desc has boolean interface test
*/
it('testHasKey0034', 0, async function (done) {
await mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, false);
await mPref.has(KEY_TEST_BOOLEAN_ELEMENT).then((ret) => {
expect(true).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name has long interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0170
* @tc.desc has long interface test
*/
it('testHasKey0035', 0, async function (done) {
mPref.putSync(KEY_TEST_LONG_ELEMENT, 0);
const promise = mPref.has(KEY_TEST_LONG_ELEMENT);
promise.then((ret) => {
expect(true).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name has long interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0170
* @tc.desc has long interface test
*/
it('testHasKey0035', 0, async function (done) {
await mPref.putSync(KEY_TEST_LONG_ELEMENT, 0);
await mPref.has(KEY_TEST_LONG_ELEMENT).then((ret) => {
expect(true).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name get string promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0030
* @tc.desc get string promise interface test
*/
it('testGetDefValue0061', 0, async function (done) {
mPref.clearSync();
const promise = mPref.get(KEY_TEST_STRING_ELEMENT, "defaultValue");
promise.then((ret) => {
expect('defaultValue').assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name get string promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0030
* @tc.desc get string promise interface test
*/
it('testGetDefValue0061', 0, async function (done) {
await mPref.clearSync();
await mPref.get(KEY_TEST_STRING_ELEMENT, "defaultValue").then((ret) => {
expect('defaultValue').assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name get float promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0040
* @tc.desc get float promise interface test
*/
it('testGetFloat0071', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 3.0);
const promise = mPref.get(KEY_TEST_FLOAT_ELEMENT, 0.0);
promise.then((ret) => {
expect(3.0).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name get float promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0040
* @tc.desc get float promise interface test
*/
it('testGetFloat0071', 0, async function (done) {
await mPref.clearSync();
await mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 3.0);
await mPref.get(KEY_TEST_FLOAT_ELEMENT, 0.0).then((ret) => {
expect(3.0).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name get int promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0050
* @tc.desc get int promise interface test
*/
it('testGetInt0081', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
const promise = mPref.get(KEY_TEST_INT_ELEMENT, 0.0);
promise.then((ret) => {
expect(3).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name get int promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0050
* @tc.desc get int promise interface test
*/
it('testGetInt0081', 0, async function (done) {
await mPref.clearSync();
await mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
await mPref.get(KEY_TEST_INT_ELEMENT, 0.0).then((ret) => {
expect(3).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name get long promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0060
* @tc.desc get long promise interface test
*/
it('testGetLong0091', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_LONG_ELEMENT, 3);
const promise = mPref.get(KEY_TEST_LONG_ELEMENT, 0);
promise.then((ret) => {
expect(3).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name get long promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0060
* @tc.desc get long promise interface test
*/
it('testGetLong0091', 0, async function (done) {
await mPref.clearSync();
await mPref.putSync(KEY_TEST_LONG_ELEMENT, 3);
await mPref.get(KEY_TEST_LONG_ELEMENT, 0).then((ret) => {
expect(3).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name get String promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0070
* @tc.desc get String promise interface test
*/
it('testGetString101', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
mPref.flushSync();
const promise = mPref.get(KEY_TEST_STRING_ELEMENT, "defaultvalue");
promise.then((ret) => {
expect('test').assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name get String promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0070
* @tc.desc get String promise interface test
*/
it('testGetString101', 0, async function (done) {
await mPref.clearSync();
await mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
await mPref.flushSync();
await mPref.get(KEY_TEST_STRING_ELEMENT, "defaultvalue").then((ret) => {
expect('test').assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name put boolean promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0090
* @tc.desc put boolean promise interface test
*/
it('testPutBoolean0121', 0, async function (done) {
mPref.clearSync();
const promise = mPref.put(KEY_TEST_BOOLEAN_ELEMENT, true);
promise.then((ret) => {
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
mPref.flushSync();
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name put boolean promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0090
* @tc.desc put boolean promise interface test
*/
it('testPutBoolean0121', 0, async function (done) {
await mPref.clearSync();
await mPref.put(KEY_TEST_BOOLEAN_ELEMENT, true).then(async (ret) => {
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
await mPref.flushSync();
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name put float promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0100
* @tc.desc put float promise interface test
*/
it('testPutFloat0131', 0, async function (done) {
mPref.clearSync();
const promise = mPref.put(KEY_TEST_FLOAT_ELEMENT, 4.0);
promise.then((ret) => {
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
mPref.flushSync();
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name put float promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0100
* @tc.desc put float promise interface test
*/
it('testPutFloat0131', 0, async function (done) {
await mPref.clearSync();
await mPref.put(KEY_TEST_FLOAT_ELEMENT, 4.0).then(async (ret) => {
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
await mPref.flushSync();
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name put int promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0110
* @tc.desc put int promise interface test
*/
it('testPutInt0141', 0, async function (done) {
mPref.clearSync();
const promise = mPref.put(KEY_TEST_INT_ELEMENT, 4);
promise.then((ret) => {
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name put int promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0110
* @tc.desc put int promise interface test
*/
it('testPutInt0141', 0, async function (done) {
await mPref.clearSync();
await mPref.put(KEY_TEST_INT_ELEMENT, 4).then((ret) => {
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name put long promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0120
* @tc.desc put long promise interface test
*/
it('testPutLong0151', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_LONG_ELEMENT, 4);
const promise = mPref.put(KEY_TEST_LONG_ELEMENT, 4);
promise.then((ret) => {
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name put long promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0120
* @tc.desc put long promise interface test
*/
it('testPutLong0151', 0, async function (done) {
await mPref.clearSync();
await mPref.putSync(KEY_TEST_LONG_ELEMENT, 4);
await mPref.put(KEY_TEST_LONG_ELEMENT, 4).then(async (ret) => {
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
await mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name put String promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0130
* @tc.desc put String promise interface test
*/
it('testPutString0161', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
const promise = mPref.put(KEY_TEST_STRING_ELEMENT, '');
promise.then((ret) => {
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
mPref.flushSync();
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name put String promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0130
* @tc.desc put String promise interface test
*/
it('testPutString0161', 0, async function (done) {
await mPref.clearSync();
await mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
await mPref.put(KEY_TEST_STRING_ELEMENT, '').then(async (ret) => {
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
await mPref.flushSync();
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name deleteSync promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0180
* @tc.desc deleteSync promise interface test
*/
it('testPutString0171', 0, async function (done) {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
const promise = mPref.put(KEY_TEST_STRING_ELEMENT, '');
promise.then((ret) => {
expect('').
assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "default"));
mPref.deleteSync(KEY_TEST_STRING_ELEMENT);
expect("default").
assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "default"));
}).catch((err) => {
expect('').assertFail();
});
await promise;
done();
})
/**
* @tc.name deleteSync promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0180
* @tc.desc deleteSync promise interface test
*/
it('testPutString0171', 0, async function (done) {
await mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
await mPref.put(KEY_TEST_STRING_ELEMENT, '').then(async (ret) => {
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "default"));
await mPref.deleteSync(KEY_TEST_STRING_ELEMENT);
expect("default").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "default"));
done();
}).catch((err) => {
expect('').assertFail();
done();
});
})
/**
* @tc.name flush promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0190
* @tc.desc flush promise interface test
*/
it('testFlush00181', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
const promise = mPref.put(KEY_TEST_STRING_ELEMENT, 'test');
promise.then((ret) => {
expect('test').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
mPref.flush();
expect('test').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name Maximum length of key test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0200
* @tc.desc Maximum length of key test
*/
it('testMaxLengthofKey0200', 0, async function(done){
mPref.clearSync();
const promise = mPref.put(MAX_KEY_LENGTH,"value1")
promise.then((ret)=>{
expect("value1").assertEqual(mPref.getSync(MAX_KEY_LENGTH,"defaultvalue"))
}).catch((err)=>{
expect(null).assertFail();
/**
* @tc.name flush promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0190
* @tc.desc flush promise interface test
*/
it('testFlush00181', 0, async function (done) {
await mPref.clearSync();
await mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
await mPref.put(KEY_TEST_STRING_ELEMENT, 'test').then(async (ret) => {
expect('test').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
await mPref.flush();
expect('test').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
await promise;
done();
})
/**
* @tc.name Maximum length of value test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0210
* @tc.desc Maximum length of value test
*/
it('testMaxLengthofValue0210', 0, async function (done) {
mPref.clearSync();
mPref.putSync("test", "abc");
const promise = mPref.put("test", MAX_VALUE_LENGTH);
promise.then((ret) => {
expect(MAX_VALUE_LENGTH).assertEqual(mPref.getSync("test", "defaultvalue"));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name Maximum length of key test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0200
* @tc.desc Maximum length of key test
*/
it('testMaxLengthofKey0200', 0, async function (done) {
await mPref.clearSync();
await mPref.put(MAX_KEY_LENGTH, "value1").then((ret) => {
expect("value1").assertEqual(mPref.getSync(MAX_KEY_LENGTH, "defaultvalue"));
done();
}).catch((err) => {
expect(null).assertFail();
done();
})
})
/**
* @tc.name Maximum length of value test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0220
* @tc.desc Maximum length of value test
*/
it('testMaxLengthofValue0220', 0, async function (done) {
mPref.clearSync();
mPref.putSync("test",MAX_VALUE_LENGTH)
const promise = mPref.put("test", "y".repeat(8192));
promise.then((ret) => {
* @tc.name Maximum length of value test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0210
* @tc.desc Maximum length of value test
*/
it('testMaxLengthofValue0210', 0, async function (done) {
await mPref.clearSync();
await mPref.putSync("test", "abc");
await mPref.put("test", MAX_VALUE_LENGTH).then((ret) => {
expect(MAX_VALUE_LENGTH).assertEqual(mPref.getSync("test", "defaultvalue"));
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
await promise;
done();
})
/**
* @tc.name delete promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0230
* @tc.desc delete promise interface test
*/
it('testDelete0230', 0, async function (done) {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
expect("abc").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "default"));
const promise = mPref.delete(KEY_TEST_STRING_ELEMENT);
promise.then((ret)=>{
expect("default").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT,"default"));
}).catch((err)=>{
expect('').assertFail();
});
await promise;
done();
})
* @tc.name Maximum length of value test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0220
* @tc.desc Maximum length of value test
*/
/**
* @tc.name Maximum length of key test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0240
* @tc.desc Maximum length of key test
*/
it('testMaxLengthofKey0240', 0, async function(done){
mPref.putSync(MAX_KEY_LENGTH, "value1");
expect("value1").assertEqual(mPref.getSync(MAX_KEY_LENGTH, "default"));
const promise = mPref.delete(MAX_KEY_LENGTH);
promise.then((ret)=>{
expect("default").assertEqual(mPref.getSync(MAX_KEY_LENGTH,"default"));
}).catch((err)=>{
expect(null).assertFail();
});
await promise;
done();
})
it('testMaxLengthofValue0220', 0, async function (done) {
await mPref.clearSync();
await mPref.putSync("test", MAX_VALUE_LENGTH);
await mPref.put("test", "y".repeat(8192)).then((ret) => {
expect(MAX_VALUE_LENGTH).assertEqual(mPref.getSync("test", "defaultvalue"));
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name delete promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0230
* @tc.desc delete promise interface test
*/
it('testDelete0230', 0, async function (done) {
await mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
expect("abc").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "default"));
await mPref.delete(KEY_TEST_STRING_ELEMENT).then((ret) => {
expect("default").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "default"));
done();
}).catch((err) => {
expect('').assertFail();
done();
});
})
/**
* @tc.name Maximum length of key test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0240
* @tc.desc Maximum length of key test
*/
it('testMaxLengthofKey0240', 0, async function (done) {
await mPref.putSync(MAX_KEY_LENGTH, "value1");
expect("value1").assertEqual(mPref.getSync(MAX_KEY_LENGTH, "default"));
await mPref.delete(MAX_KEY_LENGTH).then((ret) => {
expect("default").assertEqual(mPref.getSync(MAX_KEY_LENGTH, "default"));
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
/**
* @tc.name Maximum length of value test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0250
* @tc.desc Maximum length of value test
*/
it('testMaxLengthofValue0250', 0, async function (done) {
mPref.clearSync();
mPref.putSync("test",MAX_VALUE_LENGTH)
const promise = mPref.put("test", "y".repeat(8192));
promise.then((ret) => {
/**
* @tc.name Maximum length of value test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0250
* @tc.desc Maximum length of value test
*/
it('testMaxLengthofValue0250', 0, async function (done) {
await mPref.clearSync();
await mPref.putSync("test", MAX_VALUE_LENGTH)
await mPref.put("test", "y".repeat(8192)).then((ret) => {
expect(MAX_VALUE_LENGTH).assertEqual(mPref.getSync("test", "defaultvalue"));
}).catch((err) => {
expect(null).assertFail();
done();
});
await mPref.putSync("test", MAX_VALUE_LENGTH)
expect(MAX_VALUE_LENGTH).assertEqual(mPref.getSync("test", "defaultvalue"));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
mPref.putSync("test",MAX_VALUE_LENGTH)
expect(MAX_VALUE_LENGTH).assertEqual(mPref.getSync("test", "defaultvalue"));
done();
})
done();
})
/**
* @tc.name get string promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0260
* @tc.desc get string promise interface test
*/
it('testGetDefValue0260', 0, async function (done) {
await mPref.clear();
const promise = mPref.get(KEY_TEST_BOOLEAN_ELEMENT, true);
promise.then((ret) => {
expect(true).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
/**
* @tc.name get string promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0260
* @tc.desc get string promise interface test
*/
it('testGetDefValue0260', 0, async function (done) {
await mPref.clear();
await mPref.get(KEY_TEST_BOOLEAN_ELEMENT, true).then((ret) => {
expect(true).assertEqual(ret);
done();
}).catch((err) => {
expect(null).assertFail();
done();
});
})
})
})
}
......@@ -75,6 +75,7 @@ group("multimedia") {
"medialibrary/mediaLibrary_mediafetchoptions:mediaLibrary_mediafetchoptions_hap",
"medialibrary/mediaLibrary_trash:mediaLibrary_trash_js_hap",
"photoAccess/photoAccess:photoAccess_js_hap",
"photoAccess/photoAccessNoLocation:photoAccess_nolocation_js_hap",
"photoAccess/photoAccessSystem:photoAccess_system_js_hap",
]
} else {
......
......@@ -20,6 +20,7 @@ import ndkTest from 'libImagePixelMapNDKTest.so'
export default function ImagePixelMapNDKTest() {
describe('ImagePixelMapNDKTest', function () {
let globalpixelmap;
const RESULT_SUCCESS = 0;
const BYTESNUMBER = 16;
function logger(caseName) {
......@@ -57,7 +58,17 @@ export default function ImagePixelMapNDKTest() {
beforeEach(function () { console.info('beforeEach case'); })
afterEach(function () { console.info('afterEach case'); })
afterEach(async function () {
if (globalpixelmap != undefined) {
console.info('globalpixelmap release start');
try {
await globalpixelmap.release();
} catch (error) {
console.info('globalpixelmap release fail');
}
}
console.info('afterEach case');
})
afterAll(function () { console.info('afterAll case'); })
......@@ -100,6 +111,7 @@ export default function ImagePixelMapNDKTest() {
done();
return;
}
globalpixelmap = pixelmap;
let testFunction1 = functionTest(log, res, pixelmap);
testFunction1.test(pixelMapInterface,
(value) => {
......@@ -125,6 +137,7 @@ export default function ImagePixelMapNDKTest() {
done();
return;
}
globalpixelmap = pixelmap;
let testFunction1 = functionTest(log, res, pixelmap);
testFunction1.test(pixelMapInterface,
(value) => {
......@@ -156,6 +169,7 @@ export default function ImagePixelMapNDKTest() {
if (pixelmap == undefined) {
return;
}
globalpixelmap = pixelmap;
expect(true).assertTrue();
done();
} catch (error) {
......
......@@ -38,6 +38,7 @@ export async function driveFn(num) {
console.info(`UiDriver start`)
for (let i = 0; i < num; i++) {
let button = await driver.findComponent(BY.text('允许'))
if(button == null) continue;
console.info(`button is ${JSON.stringify(button)}`)
await msleepAsync(2000)
await button.click()
......
......@@ -16,6 +16,7 @@
import deviceInfo from '@ohos.deviceInfo'
import media from '@ohos.multimedia.media'
import camera from '@ohos.multimedia.camera'
import display from '@ohos.display';
import * as mediaTestBase from '../../../../../MediaTestBase.js';
import * as avRecorderTestBase from '../../../../../AVRecorderTestBase.js';
import * as avVideoRecorderTestBase from '../../../../../AvVideoRecorderTestBase.js';
......@@ -41,7 +42,7 @@ export default function avVideoRecorderTestOne() {
audioCodec : media.CodecMimeType.AUDIO_AAC,
audioSampleRate : 48000,
fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 100000, // 视频比特率
videoBitrate : 280000, // 视频比特率
videoCodec : media.CodecMimeType.VIDEO_MPEG4,
videoFrameWidth : 640, // 视频分辨率的宽
videoFrameHeight : 480, // 视频分辨率的高
......@@ -51,7 +52,7 @@ export default function avVideoRecorderTestOne() {
let avConfig = {
audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES,
profile : avProfile,
profile: avProfile,
url : 'fd://35', // 参考应用文件访问与管理开发示例新建并读写一个文件
rotation : 0, // 视频旋转角度,默认为0不旋转,支持的值为0、90、180、270
location : { latitude : 30, longitude : 130 },
......@@ -59,7 +60,7 @@ export default function avVideoRecorderTestOne() {
let avProfileMpeg = {
fileFormat: media.ContainerFormatType.CFT_MPEG_4,
videoBitrate: 100000,
videoBitrate: 280000,
videoCodec: media.CodecMimeType.VIDEO_MPEG4,
videoFrameWidth: 640,
videoFrameHeight: 480,
......@@ -80,7 +81,7 @@ export default function avVideoRecorderTestOne() {
audioCodec: media.CodecMimeType.AUDIO_AAC,
audioSampleRate: 48000,
fileFormat: media.ContainerFormatType.CFT_MPEG_4,
videoBitrate: 100000,
videoBitrate: 280000,
videoCodec: media.CodecMimeType.VIDEO_MPEG4,
videoFrameWidth: 640,
videoFrameHeight: 480,
......@@ -98,7 +99,7 @@ export default function avVideoRecorderTestOne() {
}
let avProfileH264 = {
fileFormat: media.ContainerFormatType.CFT_MPEG_4,
videoBitrate: 100000,
videoBitrate: 280000,
videoCodec: media.CodecMimeType.VIDEO_AVC,
videoFrameWidth: 640,
videoFrameHeight: 480,
......@@ -119,7 +120,7 @@ export default function avVideoRecorderTestOne() {
audioCodec: media.CodecMimeType.AUDIO_AAC,
audioSampleRate: 48000,
fileFormat: media.ContainerFormatType.CFT_MPEG_4,
videoBitrate: 100000,
videoBitrate: 280000,
videoCodec: media.CodecMimeType.VIDEO_AVC,
videoFrameWidth: 640,
videoFrameHeight: 480,
......@@ -172,16 +173,10 @@ export default function avVideoRecorderTestOne() {
let previewOutput;
let cameraOutputCap;
let videoSurfaceId = null;
let myProfile = null;
beforeAll(async function () {
console.info('beforeAll in1');
if (deviceInfo.deviceType === 'default') {
avConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
console.info(TAG + 'rk3568 avConfig.videoSourceType is :' + avConfig.videoSourceType)
} else {
avConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
console.info(TAG + 'rk3568 avConfig.videoSourceType is :' + avConfig.videoSourceType)
}
let permissionName1 = 'ohos.permission.MICROPHONE';
let permissionName2 = 'ohos.permission.MEDIA_LOCATION';
let permissionName3 = 'ohos.permission.READ_MEDIA';
......@@ -191,6 +186,36 @@ export default function avVideoRecorderTestOne() {
await mediaTestBase.getPermission(permissionNames);
await mediaTestBase.msleepAsync(5000);
await mediaTestBase.driveFn(4)
let context = globalThis.contextVideo;
console.info('initCamera 002');
cameraManager = camera.getCameraManager(context)
console.info('initCamera 003');
if (!cameraManager) {
console.error("camera.getCameraManager error")
return;
}
let cameras = cameraManager.getSupportedCameras();
let cameraDevice = cameras[0];
console.info('initCamera 006');
let cameraOutputCapability = cameraManager.getSupportedOutputCapability(cameraDevice);
console.info('initCamera 007');
let defaultDisplay = null;
try {
defaultDisplay = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
let availableVideoProfileList = [];
getVideoProfile(cameraOutputCapability.videoProfiles, defaultDisplay.width, defaultDisplay.height, availableVideoProfileList, 0);
myProfile = availableVideoProfileList[0];
let configs = [avConfig, avConfigMpeg, avConfigMpegAac, avConfigH264, avConfigH264Aac]
for (let i = 0; i < configs.length; i++) {
checkDevice(configs[i])
}
avConfigH264.profile.videoBitrate = 280000;
avConfigH264Aac.profile.videoBitrate = 280000;
console.info('beforeAll out');
})
......@@ -216,31 +241,41 @@ export default function avVideoRecorderTestOne() {
console.info('afterAll case');
})
async function initCamera(avRecorder, avConfig, recorderTime, steps, done) {
console.info('initCamera 001');
// 创建CameraManager对象
let context = globalThis.contextVideo;
console.info('initCamera 002');
cameraManager = camera.getCameraManager(context)
console.info('initCamera 003');
if (!cameraManager) {
console.error("camera.getCameraManager error")
return;
function getVideoProfile(sizeList, width, height, toList, index) {
console.log('display width: ' + width + ', height: ' + height);
let aVvideoProfile = undefined;
for (let i = 0; i < sizeList.length; i++) {
const size = sizeList[i].size;
if(isCorrectSize(size, width, height)) {
if(!aVvideoProfile || size.width > aVvideoProfile.size.width) {
aVvideoProfile = sizeList[i];
}
}
}
toList[index] = aVvideoProfile;
console.log('choosen aVvideoProfile: ' + JSON.stringify(aVvideoProfile));
}
function isCorrectSize(size, standardWidth, standardHeight) {
return (size.width <= standardWidth) && (size.height <= standardHeight);
}
function checkDevice(avConfig) {
if (deviceInfo.deviceType === 'default') {
avConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
console.info('initCamera 004');
console.info('initCamera 005');
avConfig.profile.videoFrameWidth = myProfile.size.width;
avConfig.profile.videoFrameHeight = myProfile.size.height;
}
async function initCamera(avRecorder, avConfig, recorderTime, steps, done) {
// 获取相机列表
let cameras = cameraManager.getSupportedCameras();
let cameraDevice = cameras[0];
console.info('initCamera 006');
// 查询相机设备在模式下支持的输出能力
let cameraOutputCapability = cameraManager.getSupportedOutputCapability(cameraDevice);
console.info('initCamera 007');
console.info('getSupportedOutputCapability success');
console.log(`cameraOutputCapability previewProfiles: ${cameraOutputCapability.previewProfiles}`);
console.log(`cameraOutputCapability photoProfiles: ${cameraOutputCapability.photoProfiles}`);
console.log(`cameraOutputCapability videoProfiles: ${cameraOutputCapability.videoProfiles}`);
// 创建相机输入流
try {
cameraInput = cameraManager.createCameraInput(cameraDevice);
......@@ -254,7 +289,8 @@ export default function avVideoRecorderTestOne() {
})
// 创建VideoOutput对象
let profile = cameraOutputCapability.videoProfiles[0];
// let profile = cameraOutputCapability.videoProfiles[0];
let profile = myProfile;
try {
videoOutput = cameraManager.createVideoOutput(profile, videoSurfaceId)
console.info('createVideoOutput success');
......@@ -2638,7 +2674,7 @@ export default function avVideoRecorderTestOne() {
audioCodec : media.CodecMimeType.AUDIO_AAC,
audioSampleRate : 48000,
fileFormat : media.ContainerFormatType.CFT_MPEG_4, // 视频文件封装格式,只支持MP4
videoBitrate : 100000, // 视频比特率
videoBitrate : 280000, // 视频比特率
videoCodec : media.CodecMimeType.VIDEO_MPEG4, // 视频文件编码格式,支持mpeg4和avc两种格式
videoFrameWidth : 640, // 视频分辨率的宽
videoFrameHeight : 480, // 视频分辨率的高
......@@ -2656,11 +2692,7 @@ export default function avVideoRecorderTestOne() {
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avNewConfig.url = fdPath;
if (deviceInfo.deviceType === 'default') {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
checkDevice(avNewConfig)
let mySteps = new Array(
// setAvRecorderCallback
CREATE_PROMISE_EVENT, SETONCALLBACK_EVENT,
......@@ -2693,7 +2725,7 @@ export default function avVideoRecorderTestOne() {
audioCodec : media.CodecMimeType.AUDIO_AAC,
audioSampleRate : -1,
fileFormat : media.ContainerFormatType.CFT_MPEG_4, // 视频文件封装格式,只支持MP4
videoBitrate : 100000, // 视频比特率
videoBitrate : 280000, // 视频比特率
videoCodec : media.CodecMimeType.VIDEO_MPEG4, // 视频文件编码格式,支持mpeg4和avc两种格式
videoFrameWidth : 640, // 视频分辨率的宽
videoFrameHeight : 480, // 视频分辨率的高
......@@ -2711,11 +2743,7 @@ export default function avVideoRecorderTestOne() {
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avNewConfig.url = fdPath;
if (deviceInfo.deviceType === 'default') {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
checkDevice(avNewConfig)
let mySteps = new Array(
// setAvRecorderCallback
CREATE_PROMISE_EVENT, SETONCALLBACK_EVENT,
......@@ -2766,11 +2794,7 @@ export default function avVideoRecorderTestOne() {
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avNewConfig.url = fdPath;
if (deviceInfo.deviceType === 'default') {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
checkDevice(avNewConfig)
let mySteps = new Array(
// setAvRecorderCallback
CREATE_PROMISE_EVENT, SETONCALLBACK_EVENT,
......@@ -2803,7 +2827,7 @@ export default function avVideoRecorderTestOne() {
audioCodec : media.CodecMimeType.AUDIO_AAC,
audioSampleRate : 48000,
fileFormat : media.ContainerFormatType.CFT_MPEG_4, // 视频文件封装格式,只支持MP4
videoBitrate : 100000, // 视频比特率
videoBitrate : 280000, // 视频比特率
videoCodec : media.CodecMimeType.VIDEO_MPEG4, // 视频文件编码格式,支持mpeg4和avc两种格式
videoFrameWidth : 640, // 视频分辨率的宽
videoFrameHeight : 480, // 视频分辨率的高
......@@ -2821,11 +2845,7 @@ export default function avVideoRecorderTestOne() {
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avNewConfig.url = fdPath;
if (deviceInfo.deviceType === 'default') {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
checkDevice(avNewConfig)
let mySteps = new Array(
// setAvRecorderCallback
CREATE_PROMISE_EVENT, SETONCALLBACK_EVENT,
......@@ -4150,7 +4170,7 @@ export default function avVideoRecorderTestOne() {
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_1000 start')
let avNewProfile = {
fileFormat : media.ContainerFormatType.CFT_MPEG_4, // 视频文件封装格式,只支持MP4
videoBitrate : 100000, // 视频比特率
videoBitrate : 280000, // 视频比特率
videoCodec : media.CodecMimeType.VIDEO_MPEG4, // 视频文件编码格式,支持mpeg4和avc两种格式
videoFrameWidth : 640, // 视频分辨率的宽
videoFrameHeight : 480, // 视频分辨率的高
......@@ -4167,11 +4187,7 @@ export default function avVideoRecorderTestOne() {
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avNewConfig.url = fdPath;
if (deviceInfo.deviceType === 'default') {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
checkDevice(avNewConfig)
let mySteps = new Array(
// setAvRecorderCallback
CREATE_PROMISE_EVENT, SETONCALLBACK_EVENT,
......@@ -4206,7 +4222,7 @@ export default function avVideoRecorderTestOne() {
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_1100 start')
let avNewProfile = {
fileFormat : media.ContainerFormatType.CFT_MPEG_4, // 视频文件封装格式,只支持MP4
videoBitrate : 100000, // 视频比特率
videoBitrate : 280000, // 视频比特率
videoCodec : media.CodecMimeType.VIDEO_MPEG4, // 视频文件编码格式,支持mpeg4和avc两种格式
videoFrameWidth : 640, // 视频分辨率的宽
videoFrameHeight : 480, // 视频分辨率的高
......@@ -4223,11 +4239,7 @@ export default function avVideoRecorderTestOne() {
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avNewConfig.url = fdPath;
if (deviceInfo.deviceType === 'default') {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
checkDevice(avNewConfig)
let mySteps = new Array(
// setAvRecorderCallback
CREATE_PROMISE_EVENT, SETONCALLBACK_EVENT,
......@@ -4264,7 +4276,7 @@ export default function avVideoRecorderTestOne() {
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_1200 start')
let avNewProfile = {
fileFormat : media.ContainerFormatType.CFT_MPEG_4, // 视频文件封装格式,只支持MP4
videoBitrate : 100000, // 视频比特率
videoBitrate : 280000, // 视频比特率
videoCodec : media.CodecMimeType.VIDEO_MPEG4, // 视频文件编码格式,支持mpeg4和avc两种格式
videoFrameWidth : 640, // 视频分辨率的宽
videoFrameHeight : 480, // 视频分辨率的高
......@@ -4281,11 +4293,7 @@ export default function avVideoRecorderTestOne() {
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avNewConfig.url = fdPath;
if (deviceInfo.deviceType === 'default') {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
checkDevice(avNewConfig)
let mySteps = new Array(
// setAvRecorderCallback
CREATE_PROMISE_EVENT, SETONCALLBACK_EVENT,
......@@ -4324,7 +4332,7 @@ export default function avVideoRecorderTestOne() {
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_1300 start')
let avNewProfile = {
fileFormat : media.ContainerFormatType.CFT_MPEG_4, // 视频文件封装格式,只支持MP4
videoBitrate : 100000, // 视频比特率
videoBitrate : 280000, // 视频比特率
videoCodec : media.CodecMimeType.VIDEO_MPEG4, // 视频文件编码格式,支持mpeg4和avc两种格式
videoFrameWidth : 640, // 视频分辨率的宽
videoFrameHeight : 480, // 视频分辨率的高
......@@ -4341,11 +4349,7 @@ export default function avVideoRecorderTestOne() {
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avNewConfig.url = fdPath;
if (deviceInfo.deviceType === 'default') {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
checkDevice(avNewConfig)
let mySteps = new Array(
// setAvRecorderCallback
CREATE_PROMISE_EVENT, SETONCALLBACK_EVENT,
......@@ -4382,7 +4386,7 @@ export default function avVideoRecorderTestOne() {
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_1400 start')
let avNewProfile = {
fileFormat : media.ContainerFormatType.CFT_MPEG_4, // 视频文件封装格式,只支持MP4
videoBitrate : 100000, // 视频比特率
videoBitrate : 280000, // 视频比特率
videoCodec : media.CodecMimeType.VIDEO_MPEG4, // 视频文件编码格式,支持mpeg4和avc两种格式
videoFrameWidth : 640, // 视频分辨率的宽
videoFrameHeight : 480, // 视频分辨率的高
......@@ -4399,11 +4403,7 @@ export default function avVideoRecorderTestOne() {
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avNewConfig.url = fdPath;
if (deviceInfo.deviceType === 'default') {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
checkDevice(avNewConfig)
let mySteps = new Array(
// setAvRecorderCallback
CREATE_PROMISE_EVENT, SETONCALLBACK_EVENT,
......@@ -5176,7 +5176,7 @@ export default function avVideoRecorderTestOne() {
audioSampleRate : 48000,
audioCodec : media.CodecMimeType.AUDIO_AAC,
fileFormat : media.ContainerFormatType.CFT_MPEG_4, // 视频文件封装格式,只支持MP4
videoBitrate : 100000,
videoBitrate : 280000,
videoCodec : media.CodecMimeType.VIDEO_MPEG4,
videoFrameWidth : 640,
videoFrameHeight : 480,
......@@ -5194,11 +5194,7 @@ export default function avVideoRecorderTestOne() {
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avNewConfig.url = fdPath;
if (deviceInfo.deviceType === 'default') {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
checkDevice(avNewConfig)
let mySteps = new Array(
// init avRecorder
CREATE_CALLBACK_EVENT, SETONCALLBACK_EVENT, PREPARE_CALLBACK_EVENT,
......@@ -5227,7 +5223,7 @@ export default function avVideoRecorderTestOne() {
audioSampleRate : -1,
audioCodec : media.CodecMimeType.AUDIO_AAC,
fileFormat : media.ContainerFormatType.CFT_MPEG_4, // 视频文件封装格式,只支持MP4
videoBitrate : 100000,
videoBitrate : 280000,
videoCodec : media.CodecMimeType.VIDEO_MPEG4,
videoFrameWidth : 640,
videoFrameHeight : 480,
......@@ -5245,11 +5241,7 @@ export default function avVideoRecorderTestOne() {
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avNewConfig.url = fdPath;
if (deviceInfo.deviceType === 'default') {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
checkDevice(avNewConfig)
let mySteps = new Array(
// init avRecorder
CREATE_CALLBACK_EVENT, SETONCALLBACK_EVENT, PREPARE_CALLBACK_EVENT,
......@@ -5296,11 +5288,7 @@ export default function avVideoRecorderTestOne() {
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avNewConfig.url = fdPath;
if (deviceInfo.deviceType === 'default') {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
checkDevice(avNewConfig)
let mySteps = new Array(
// init avRecorder
CREATE_CALLBACK_EVENT, SETONCALLBACK_EVENT, PREPARE_CALLBACK_EVENT,
......@@ -5329,7 +5317,7 @@ export default function avVideoRecorderTestOne() {
audioCodec : media.CodecMimeType.AUDIO_AAC,
audioSampleRate : 48000,
fileFormat : media.ContainerFormatType.CFT_MPEG_4, // 视频文件封装格式,只支持MP4
videoBitrate : 100000, // 视频比特率
videoBitrate : 280000, // 视频比特率
videoCodec : media.CodecMimeType.VIDEO_MPEG4, // 视频文件编码格式,支持mpeg4和avc两种格式
videoFrameWidth : 640, // 视频分辨率的宽
videoFrameHeight : 480, // 视频分辨率的高
......@@ -5347,11 +5335,7 @@ export default function avVideoRecorderTestOne() {
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avNewConfig.url = fdPath;
if (deviceInfo.deviceType === 'default') {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_ES
} else {
avNewConfig.videoSourceType = media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV
}
checkDevice(avNewConfig)
let mySteps = new Array(
// init avRecorder
CREATE_CALLBACK_EVENT, SETONCALLBACK_EVENT, PREPARE_CALLBACK_EVENT,
......@@ -6524,45 +6508,6 @@ export default function avVideoRecorderTestOne() {
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_MPEG4_1000 end')
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_MPEG4_1100
* @tc.name : 11.AVRecorder recording videoFrameRate:60
* @tc.desc : Recorder video
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_MPEG4_1100', 0, async function (done) {
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_MPEG4_1100 start')
avProfileMpegAac.videoFrameRate = 60
let fileName = avVideoRecorderTestBase.resourceName()
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avConfigMpegAac.url = fdPath;
let mySteps = new Array(
// init avRecorder
CREATE_PROMISE_EVENT, SETONCALLBACK_EVENT, PREPARE_PROMISE_EVENT,
// init camera
GETINPUTSURFACE_PROMISE_EVENT, INITCAMERA_EVENT,
// start recorder
STARTCAMERA_EVENT, STARTRECORDER_PROMISE_EVENT,
// pause recorder
PAUSERECORDER_PROMISE_EVENT, STOPCAMERA_EVENT,
// resume recorder
STARTCAMERA_EVENT, RESUMERECORDER_PROMISE_EVENT,
// stop recorder
STOPRECORDER_PROMISE_EVENT, STOPCAMERA_EVENT,
// release avRecorder and camera
RELEASECORDER_PROMISE_EVENT, RELEASECAMERA_EVENT,
// end
END_EVENT
);
eventEmitter.emit(mySteps[0], avRecorder, avConfigMpegAac, recorderTime, mySteps, done);
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_MPEG4_1100 end')
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_MPEG4_1200
* @tc.name : 12.AVRecorder Record MPEG4
......@@ -6596,7 +6541,7 @@ export default function avVideoRecorderTestOne() {
// end
END_EVENT
);
eventEmitter.emit(mySteps[0], avRecorder, avConfigMpegAac, recorderTime, mySteps, done);
eventEmitter.emit(mySteps[0], avRecorder, avConfigMpeg, recorderTime, mySteps, done);
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_MPEG4_1200 end')
})
......@@ -7015,47 +6960,6 @@ export default function avVideoRecorderTestOne() {
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_CALLBACK_MPEG4_1000 end')
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_CALLBACK_MPEG4_1100
* @tc.name : 11.AVRecorder recording videoFrameRate:60
* @tc.desc : Recorder video
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_CALLBACK_MPEG4_1100', 0, async function (done) {
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_CALLBACK_MPEG4_1100 start')
avProfileMpegAac.videoFrameRate = 60
let fileName = avVideoRecorderTestBase.resourceName()
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avConfigMpegAac.url = fdPath;
let mySteps = new Array(
// init avRecorder
CREATE_CALLBACK_EVENT, SETONCALLBACK_EVENT, PREPARE_CALLBACK_EVENT,
// init camera
GETINPUTSURFACE_CALLBACK_EVENT, INITCAMERA_EVENT,
// start recorder
STARTCAMERA_EVENT, STARTRECORDER_CALLBACK_EVENT,
// pause recorder
PAUSERECORDER_CALLBACK_EVENT, STOPCAMERA_EVENT,
// resume recorder
STARTCAMERA_EVENT, RESUMERECORDER_CALLBACK_EVENT,
// stop recorder
STOPRECORDER_CALLBACK_EVENT, STOPCAMERA_EVENT,
// release avRecorder and camera
RELEASECORDER_CALLBACK_EVENT, RELEASECAMERA_EVENT,
// end
END_EVENT
);
eventEmitter.emit(mySteps[0], avRecorder, avConfigMpegAac, recorderTime, mySteps, done);
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_CALLBACK_MPEG4_1100 end')
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_CALLBACK_MPEG4_1200
* @tc.name : 12.AVRecorder Record MPEG4
......@@ -7490,45 +7394,6 @@ export default function avVideoRecorderTestOne() {
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_H264_1000 end')
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_H264_1100
* @tc.name : 11.AVRecorder recording videoFrameRate:60
* @tc.desc : Recorder video
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_H264_1100', 0, async function (done) {
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_H264_1100 start')
avProfileH264Aac.videoFrameRate = 60
let fileName = avVideoRecorderTestBase.resourceName()
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avConfigH264Aac.url = fdPath;
let mySteps = new Array(
// init avRecorder
CREATE_PROMISE_EVENT, SETONCALLBACK_EVENT, PREPARE_PROMISE_EVENT,
// init camera
GETINPUTSURFACE_PROMISE_EVENT, INITCAMERA_EVENT,
// start recorder
STARTCAMERA_EVENT, STARTRECORDER_PROMISE_EVENT,
// pause recorder
PAUSERECORDER_PROMISE_EVENT, STOPCAMERA_EVENT,
// resume recorder
STARTCAMERA_EVENT, RESUMERECORDER_PROMISE_EVENT,
// stop recorder
STOPRECORDER_PROMISE_EVENT, STOPCAMERA_EVENT,
// release avRecorder and camera
RELEASECORDER_PROMISE_EVENT, RELEASECAMERA_EVENT,
// end
END_EVENT
);
eventEmitter.emit(mySteps[0], avRecorder, avConfigH264Aac, recorderTime, mySteps, done);
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_H264_1100 end')
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_PROMISE_H264_1200
* @tc.name : 12.AVRecorder Record MPEG4
......@@ -7981,47 +7846,6 @@ export default function avVideoRecorderTestOne() {
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_CALLBACK_H264_1000 end')
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_CALLBACK_H264_1100
* @tc.name : 11.AVRecorder recording videoFrameRate:60
* @tc.desc : Recorder video
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_CALLBACK_H264_1100', 0, async function (done) {
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_CALLBACK_H264_1100 start')
avProfileH264Aac.videoFrameRate = 60
let fileName = avVideoRecorderTestBase.resourceName()
fdObject = await mediaTestBase.getAvRecorderFd(fileName, "video");
fdPath = "fd://" + fdObject.fdNumber;
avConfigH264Aac.url = fdPath;
let mySteps = new Array(
// init avRecorder
CREATE_CALLBACK_EVENT, SETONCALLBACK_EVENT, PREPARE_CALLBACK_EVENT,
// init camera
GETINPUTSURFACE_CALLBACK_EVENT, INITCAMERA_EVENT,
// start recorder
STARTCAMERA_EVENT, STARTRECORDER_CALLBACK_EVENT,
// pause recorder
PAUSERECORDER_CALLBACK_EVENT, STOPCAMERA_EVENT,
// resume recorder
STARTCAMERA_EVENT, RESUMERECORDER_CALLBACK_EVENT,
// stop recorder
STOPRECORDER_CALLBACK_EVENT, STOPCAMERA_EVENT,
// release avRecorder and camera
RELEASECORDER_CALLBACK_EVENT, RELEASECAMERA_EVENT,
// end
END_EVENT
);
eventEmitter.emit(mySteps[0], avRecorder, avConfigH264Aac, recorderTime, mySteps, done);
console.info(TAG + 'SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_CALLBACK_H264_1100 end')
})
/* *
* @tc.number : SUB_MULTIMEDIA_AVRECORDER_VIDEO_FUNCTION_CALLBACK_H264_1200
* @tc.name : 12.AVRecorder Record MPEG4
......
......@@ -135,10 +135,26 @@
"hilog -Q domainoff",
"hilog -b D -D 0xD002B70",
"scanner",
"sleep 5"
"sleep 10"
],
"teardown-command": [
"power-shell setmode 600"
"power-shell setmode 600",
"rm -rf /storage/media/100/local/files/Audios/*",
"rm -rf /storage/media/100/local/files/Audios/.*",
"rm -rf /storage/media/100/local/files/Camera/*",
"rm -rf /storage/media/100/local/files/Camera/.*",
"rm -rf /storage/media/100/local/files/Documents/*",
"rm -rf /storage/media/100/local/files/Documents/.*",
"rm -rf /storage/media/100/local/files/Download/*",
"rm -rf /storage/media/100/local/files/Download/.*",
"rm -rf /storage/media/100/local/files/Pictures/*",
"rm -rf /storage/media/100/local/files/Pictures/.*",
"rm -rf /storage/media/100/local/files/Videos/*",
"rm -rf /storage/media/100/local/files/Videos/.*",
"sleep 5",
"rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*",
"kill -9 `pidof com.ohos.medialibrary.medialibrarydata`",
"scanner"
]
},
{
......
{
"app": {
"bundleName": "ohos.acts.multimedia.photoaccess",
"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) 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("photoAccess_nolocation_js_hap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":photoAccessNoLocation_js_assets",
":photoAccessNoLocation_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsPhotoAccessNoLocationTest"
part_name = "media_library"
subsystem_name = "multimedia"
}
ohos_app_scope("photoAccessNoLocation_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("photoAccessNoLocation_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("photoAccessNoLocation_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":photoAccessNoLocation_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for photoAccess Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "ohos.acts.multimedia.photoaccess",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 10000
},
"kits": [
{
"type": "ShellKit",
"pre-push": [],
"run-command": [
"rm -rf /storage/media/100/local/files/Audios/*",
"rm -rf /storage/media/100/local/files/Audios/.*",
"rm -rf /storage/media/100/local/files/Camera/*",
"rm -rf /storage/media/100/local/files/Camera/.*",
"rm -rf /storage/media/100/local/files/Documents/*",
"rm -rf /storage/media/100/local/files/Documents/.*",
"rm -rf /storage/media/100/local/files/Download/*",
"rm -rf /storage/media/100/local/files/Download/.*",
"rm -rf /storage/media/100/local/files/Pictures/*",
"rm -rf /storage/media/100/local/files/Pictures/.*",
"rm -rf /storage/media/100/local/files/Videos/*",
"rm -rf /storage/media/100/local/files/Videos/.*",
"sleep 5",
"rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*",
"kill -9 `pidof com.ohos.medialibrary.medialibrarydata`",
"scanner",
"sleep 5",
"mkdir /storage/media/100/local/temp",
"param set persist.ace.testmode.enabled 1"
]
},
{
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/medialibrary/getExif.jpg ->/storage/media/100/local/temp/getExif.jpg"
]
},
{
"type": "ShellKit",
"run-command": [
"mediatool send /storage/media/100/local/temp/getExif.jpg",
"chmod -R 777 /storage/media/100/local/files/*",
"hilog -p off",
"hilog -Q pidoff",
"hilog -Q domainoff",
"hilog -b D -D 0xD002B70",
"scanner",
"sleep 10"
],
"teardown-command": [
"power-shell setmode 600",
"rm -rf /storage/media/100/local/files/Audios/*",
"rm -rf /storage/media/100/local/files/Audios/.*",
"rm -rf /storage/media/100/local/files/Camera/*",
"rm -rf /storage/media/100/local/files/Camera/.*",
"rm -rf /storage/media/100/local/files/Documents/*",
"rm -rf /storage/media/100/local/files/Documents/.*",
"rm -rf /storage/media/100/local/files/Download/*",
"rm -rf /storage/media/100/local/files/Download/.*",
"rm -rf /storage/media/100/local/files/Pictures/*",
"rm -rf /storage/media/100/local/files/Pictures/.*",
"rm -rf /storage/media/100/local/files/Videos/*",
"rm -rf /storage/media/100/local/files/Videos/.*",
"sleep 5",
"rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*",
"kill -9 `pidof com.ohos.medialibrary.medialibrarydata`",
"scanner"
]
},
{
"test-file-name": [
"ActsPhotoAccessNoLocationTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() : void {
console.log("[Demo] MyAbilityStage onCreate");
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
import Ability from '@ohos.app.ability.UIAbility'
export default class MainAbility extends Ability {
onCreate(want, launchParam) : void {
// Ability is creating, initialize resources for this ability
console.log('[Demo] MainAbility onCreate');
globalThis.abilityWant = want;
}
onDestroy() : void {
// Ability is destroying, release resources for this ability
console.log('[Demo] MainAbility onDestroy');
}
onWindowStageCreate(windowStage) : void {
console.log('[Demo] MainAbility onWindowStageCreate windowStage=' + windowStage);
globalThis.windowStage = windowStage;
globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, 'MainAbility/pages/index/index', null);
}
onWindowStageDestroy() : void {
//Main window is destroyed, release UI related resources
console.log('[Demo] MainAbility onWindowStageDestroy');
}
onForeground() : void {
// Ability has brought to foreground
console.log('[Demo] MainAbility onForeground');
}
onBackground() : void {
// Ability has back to background
console.log('[Demo] MainAbility onBackground');
}
};
\ 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 router from '@ohos.router';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
})
}
.width('100%')
.height('100%')
}
}
\ 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 Ability from '@ohos.app.ability.UIAbility'
export default class TestAbility extends Ability {
onCreate(want, launchParam) : void {
console.log('TestAbility onCreate');
}
onDestroy() : void {
console.log('TestAbility onDestroy');
}
onWindowStageCreate(windowStage) : void {
console.log('TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/index', (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
};
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data));
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() : void {
console.log('TestAbility onWindowStageDestroy');
}
onForeground() : void {
console.log('TestAbility onForeground');
}
onBackground() : void {
console.log('TestAbility onBackground');
}
};
\ 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 router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('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
/*
* 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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) : string {
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() : Promise<void> {
console.log('onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err) : Promise<void> {
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');
let abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility';
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
let cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters);
const 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) 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 getExifNoLocationTest from './getExifNoLocation'
export default function testsuite () {
getExifNoLocationTest()
}
/*
* 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 abilityAccessCtrl from '@ohos.abilityAccessCtrl';
import bundleManager from '@ohos.bundle.bundleManager';
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import {
photoKeys,
photoFetchOption,
getFileAsset,
} from '../../../../../../common'
export default function getExifNoLocationTest () {
describe('getExifNoLocationTest', function () {
beforeAll(async function () {
console.info('beforeAll case')
const atManager = abilityAccessCtrl.createAtManager();
const appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
const userId = 100;
const appInfo = await bundleManager.getApplicationInfo('ohos.acts.multimedia.photoaccess', appFlags, userId);
const tokenID = appInfo.accessTokenId;
try {
await atManager.grantUserGrantedPermission(tokenID, 'ohos.permission.READ_IMAGEVIDEO', 1);
} catch (error) {
console.info(`getPermission failed`);
}
})
async function getExifCallback (done, testNum, fetchOps) {
try {
const asset = await getFileAsset(testNum, fetchOps);
asset.getExif(async (err, result) => {
try {
if (err !== undefined) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
console.info(`${testNum} result: ${result}`)
expect(result.length > 0).assertTrue();
expect(!result.includes('GPSLongitude')).assertTrue();
expect(!result.includes('GPSLatitudeRef')).assertTrue();
expect(!result.includes('GPSLongitudeRef')).assertTrue();
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
}
async function getExifPromise (done, testNum, fetchOps) {
try {
const asset = await getFileAsset(testNum, fetchOps);
const result = await asset.getExif();
console.info(`${testNum} result: ${result}`)
expect(result.length > 0).assertTrue();
expect(!result.includes('GPSLongitude')).assertTrue();
expect(!result.includes('GPSLatitudeRef')).assertTrue();
expect(!result.includes('GPSLongitudeRef')).assertTrue();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_EXIF_NOLOCATION_0400
* @tc.name : getExif_callback_004
* @tc.desc : getExif.jpg, fetchColumn with all_exif, no MEDIA_LOCATION permission, check GPSLongitude
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('getExif_callback_004', 0, async function (done) {
const testNum = 'getExif_callback_004';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'getExif.jpg');
await getExifCallback(done, testNum, fetchOps);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_EXIF_NOLOCATION_0400
* @tc.name : getExif_promise_004
* @tc.desc : getExif.jpg, fetchColumn with all_exif, no MEDIA_LOCATION permission, check GPSLongitude
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('getExif_promise_004', 0, async function (done) {
const testNum = 'getExif_promise_004';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'getExif.jpg');
await getExifPromise(done, testNum, fetchOps);
});
})
}
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"tablet",
"default",
"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.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.READ_IMAGEVIDEO"
},
{
"name": "ohos.permission.WRITE_IMAGEVIDEO"
}
]
}
}
\ No newline at end of file
{
"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": "ActsPhotoAccessNoLocationTest"
},
{
"name": "form_description",
"value": "photoAccessSystem"
},
{
"name": "serviceability_description",
"value": "photoAccessSystem"
},
{
"name": "description_application",
"value": "photoAccessSystem test"
},
{
"name": "app_name",
"value": "ActsPhotoAccessNoLocationTest"
}
]
}
\ No newline at end of file
{
"src": [
"MainAbility/pages/index/index"
]
}
\ No newline at end of file
......@@ -39,15 +39,20 @@
"pre-push": [],
"push": [
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/01.jpg",
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/noExif.jpg",
"./resource/medialibrary/getExif.jpg ->/storage/media/100/local/temp/getExif.jpg",
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/userCommentCb01.jpg",
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/userCommentCb02.jpg",
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/userCommentCb03.jpg",
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/userCommentCb04.jpg",
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/userCommentCb05.jpg",
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/userCommentCb06.jpg",
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/userCommentPro01.jpg",
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/userCommentPro02.jpg",
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/userCommentPro03.jpg",
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/userCommentPro04.jpg",
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/userCommentPro05.jpg",
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp/userCommentPro06.jpg",
"./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp/01.mp4"
]
},
......@@ -140,11 +145,16 @@
"mediatool send /storage/media/100/local/temp/userCommentCb02.jpg",
"mediatool send /storage/media/100/local/temp/userCommentCb03.jpg",
"mediatool send /storage/media/100/local/temp/userCommentCb04.jpg",
"mediatool send /storage/media/100/local/temp/userCommentCb05.jpg",
"mediatool send /storage/media/100/local/temp/userCommentCb06.jpg",
"mediatool send /storage/media/100/local/temp/userCommentPro01.jpg",
"mediatool send /storage/media/100/local/temp/userCommentPro02.jpg",
"mediatool send /storage/media/100/local/temp/userCommentPro03.jpg",
"mediatool send /storage/media/100/local/temp/userCommentPro04.jpg",
"mediatool send /storage/media/100/local/temp/userCommentPro05.jpg",
"mediatool send /storage/media/100/local/temp/userCommentPro06.jpg",
"mediatool send /storage/media/100/local/temp/getExif.jpg",
"mediatool send /storage/media/100/local/temp/noExif.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/getPhotoIndex01.jpg",
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/getPhotoIndex02.jpg",
......@@ -173,7 +183,7 @@
"hilog -Q domainoff",
"hilog -b D -D 0xD002B70",
"scanner",
"sleep 5"
"sleep 10"
],
"teardown-command": [
"power-shell setmode 600",
......
......@@ -13,13 +13,15 @@
* limitations under the License.
*/
import photoAccessHelper from '@ohos.file.photoAccessHelper';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import {
photoKeys,
photoFetchOption,
getFileAsset,
getPermission,
fetchOption
fetchOption,
} from '../../../../../../common'
export default function getExifTest () {
......@@ -29,10 +31,41 @@ export default function getExifTest () {
await getPermission()
})
const exifInfo = {
ImageWidth: '3456',
UserComment: 'gray',
}
const exifInfo = new Map([
['ApertureValue', '1.69 EV (f/1.8)'],
['BitsPerSample', '8, 8, 8'],
['DateTimeOriginal', '2019:11:15 20:48:30'],
['DateTime', '2019:11:15 20:48:30'],
['ExposureBiasValue', '0.00 EV'],
['ExposureTime', '1/33 sec.'],
['Flash', 'Flash fired, auto mode'],
['FNumber', 'f/1.8'],
['FocalLength', '4.0 mm'],
['FocalLengthIn35mmFilm', '26'],
['GPSLongitude', '0'],
['GPSLatitudeRef', ''],
['GPSLongitudeRef', ''],
['GPSTimeStamp', '13:31:27.00'],
['GPSDateStamp', '2023:04:13'],
['ImageDescription', 'A gray picture'],
['ImageLength', '4608'],
['ImageWidth', '3456'],
['ISOSpeedRatings', '200'],
['LightSource', 'Daylight'],
['Make', 'HW'],
['MakerNote', ''],
['MeteringMode', 'Pattern'],
['Model', 'STK-LX1'],
['Orientation', '0'],
['PhotoMode', ''],
['PixelXDimension', '3456'],
['PixelYDimension', '4608'],
['RecommendedExposureIndex', '200'],
['SceneType', 'Directly photographed'],
['SensitivityType', 'Standard output sensitivity (SOS)'],
['StandardOutputSensitivity', ''],
['WhiteBalance', 'Auto white balance'],
])
async function getExifCallback (done, testNum, fetchOps) {
try {
......@@ -46,9 +79,10 @@ export default function getExifTest () {
console.info(`${testNum} result: ${result}`)
expect(result.length > 0).assertTrue();
const msg = JSON.parse(result);
console.info(`${testNum} ImageWidth: ${msg.ImageWidth}, UserComment: ${msg.UserComment}`)
expect(msg.ImageWidth).assertEqual(exifInfo.ImageWidth);
expect(msg.UserComment).assertEqual(exifInfo.UserComment);
exifInfo.forEach((value, key, map) => {
console.info(`${testNum} key: ${key}, value: ${value}, msg[key]: ${msg[key]}`)
expect(value).assertEqual(msg[key].toString())
});
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
......@@ -66,11 +100,11 @@ export default function getExifTest () {
try {
const asset = await getFileAsset(testNum, fetchOps);
asset.getExif(async (err, result) => {
console.info(`${testNum} err: ${err}, result: ${result}`);
try {
if (err !== undefined) {
console.info(`${testNum} err: ${err}`);
} else {
console.info(`${testNum} result: ${result}`);
expect(false).assertTrue();
}
} catch (error) {
......@@ -92,9 +126,10 @@ export default function getExifTest () {
console.info(`${testNum} result: ${result}`)
expect(result.length > 0).assertTrue();
const msg = JSON.parse(result);
console.info(`${testNum} ImageWidth: ${msg.ImageWidth}, UserComment: ${msg.UserComment}`)
expect(msg.ImageWidth).assertEqual(exifInfo.ImageWidth);
expect(msg.UserComment).assertEqual(exifInfo.UserComment);
exifInfo.forEach((value, key, map) => {
console.info(`${testNum} key: ${key}, value: ${value}, msg[key]: ${msg[key]}`)
expect(value).assertEqual(msg[key].toString())
});
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
......@@ -118,21 +153,25 @@ export default function getExifTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_EXIF_0000
* @tc.name : getExif_callback_000
* @tc.desc : getExif.jpg, fetchColumn with all_exif, check ImageWidth、UserComment
* @tc.desc : getExif.jpg, fetchColumn with all_exif, check exif
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('getExif_callback_000', 0, async function (done) {
const testNum = 'getExif_callback_000';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'getExif.jpg');
const predicates = new dataSharePredicates.DataSharePredicates();
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: ['all_exif'],
predicates: predicates.equalTo(photoKeys.DISPLAY_NAME, 'getExif.jpg'),
};
await getExifCallback(done, testNum, fetchOps);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_EXIF_0100
* @tc.name : getExif_callback_001
* @tc.desc : getExif.jpg, fetchColumn without all_exif, check ImageWidth、UserComment
* @tc.desc : getExif.jpg, fetchColumn without all_exif, check exif
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
......@@ -144,19 +183,187 @@ export default function getExifTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_EXIF_0200
* @tc.name : getExif_callback_002
* @tc.desc : 01.jpg, fetchColumn with all_exif, check ImageWidth、UserComment
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_EXIF_0300
* @tc.name : getExif_callback_003
* @tc.desc : noExif.jpg, fetchColumn with all_exif and user_comment, check UserComment
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getExif_callback_003', 2, async function (done) {
const testNum = 'getExif_callback_003';
const predicates = new dataSharePredicates.DataSharePredicates();
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: ['all_exif', photoKeys.USER_COMMENT],
predicates: predicates.equalTo(photoKeys.DISPLAY_NAME, 'getExif.jpg'),
};
try {
const asset = await getFileAsset(testNum, fetchOps);
asset.getExif(async (err, result) => {
try {
if (err !== undefined) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
console.info(`${testNum} result: ${result}`)
expect(result.includes('UserComment')).assertTrue();
const msg = JSON.parse(result);
expect(msg.UserComment).assertEqual('gray');
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_EXIF_0500
* @tc.name : getExif_callback_005
* @tc.desc : getExif.jpg, fetchColumn with all_exif, has MEDIA_LOCATION permission, check GPSLongitude
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getExif_callback_005', 2, async function (done) {
const testNum = 'getExif_callback_005';
const predicates = new dataSharePredicates.DataSharePredicates();
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: ['all_exif'],
predicates: predicates.equalTo(photoKeys.DISPLAY_NAME, 'getExif.jpg'),
};
try {
const asset = await getFileAsset(testNum, fetchOps);
asset.getExif(async (err, result) => {
try {
if (err !== undefined) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
console.info(`${testNum} result: ${result}`)
expect(result.includes('GPSLongitude')).assertTrue();
expect(result.includes('GPSLatitudeRef')).assertTrue();
expect(result.includes('GPSLongitudeRef')).assertTrue();
const msg = JSON.parse(result);
expect(msg.GPSLongitude).assertEqual(0);
expect(msg.GPSLatitudeRef).assertEqual('');
expect(msg.GPSLongitudeRef).assertEqual('');
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_EXIF_0600
* @tc.name : getExif_callback_006
* @tc.desc : noExif.jpg, fetchColumn with all_exif, check ImageWidth
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getExif_callback_006', 2, async function (done) {
const testNum = 'getExif_callback_006';
const predicates = new dataSharePredicates.DataSharePredicates();
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: ['all_exif'],
predicates: predicates.equalTo(photoKeys.DISPLAY_NAME, 'noExif.jpg'),
};
try {
const asset = await getFileAsset(testNum, fetchOps);
asset.getExif(async (err, result) => {
try {
if (err !== undefined) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
console.info(`${testNum} result: ${result}`);
expect(result.includes('ImageWidth')).assertTrue();
const msg = JSON.parse(result);
expect(msg.ImageWidth).assertEqual('');
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_EXIF_0700
* @tc.name : getExif_callback_007
* @tc.desc : noExif.jpg, fetchColumn withoutout all_exif, check ImageWidth
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getExif_callback_002', 2, async function (done) {
const testNum = 'getExif_callback_002';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
it('getExif_callback_007', 2, async function (done) {
const testNum = 'getExif_callback_007';
const predicates = new dataSharePredicates.DataSharePredicates();
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: [],
predicates: predicates.equalTo(photoKeys.DISPLAY_NAME, 'noExif.jpg'),
};
await getExifAbnormalCallback(done, testNum, fetchOps);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_EXIF_0900
* @tc.name : getExif_callback_009
* @tc.desc : noExif.jpg, fetchColumn with all_exif and USER_COMMENT, check UserComment
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getExif_callback_009', 2, async function (done) {
const testNum = 'getExif_callback_009';
const predicates = new dataSharePredicates.DataSharePredicates();
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: ['all_exif', photoKeys.USER_COMMENT],
predicates: predicates.equalTo(photoKeys.DISPLAY_NAME, 'noExif.jpg'),
};
try {
const asset = await getFileAsset(testNum, fetchOps);
asset.getExif(async (err, result) => {
try {
if (err !== undefined) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
console.info(`${testNum} result: ${result}`)
expect(result.includes('UserComment')).assertTrue();
const msg = JSON.parse(result);
expect(msg.UserComment).assertEqual('');
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_EXIF_0000
* @tc.name : getExif_promise_000
......@@ -186,17 +393,145 @@ export default function getExifTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_EXIF_0200
* @tc.name : getExif_promise_002
* @tc.desc : 01.jpg, fetchColumn with all_exif, check ImageWidth、UserComment
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_EXIF_0300
* @tc.name : getExif_promise_003
* @tc.desc : noExif.jpg, fetchColumn with all_exif and user_comment, check UserComment
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getExif_promise_003', 2, async function (done) {
const testNum = 'getExif_promise_003';
const predicates = new dataSharePredicates.DataSharePredicates();
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: ['all_exif', photoKeys.USER_COMMENT],
predicates: predicates.equalTo(photoKeys.DISPLAY_NAME, 'getExif.jpg'),
};
try {
const asset = await getFileAsset(testNum, fetchOps);
const result = await asset.getExif();
console.info(`${testNum} result: ${result}`);
expect(result.includes('UserComment')).assertTrue();
const msg = JSON.parse(result);
expect(msg.UserComment).assertEqual('gray');
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_EXIF_0500
* @tc.name : getExif_promise_005
* @tc.desc : getExif.jpg, fetchColumn with all_exif, has MEDIA_LOCATION permission, check GPSLongitude
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getExif_promise_005', 2, async function (done) {
const testNum = 'getExif_promise_005';
const predicates = new dataSharePredicates.DataSharePredicates();
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: ['all_exif'],
predicates: predicates.equalTo(photoKeys.DISPLAY_NAME, 'getExif.jpg'),
};
try {
const asset = await getFileAsset(testNum, fetchOps);
const result = await asset.getExif();
console.info(`${testNum} result: ${result}`);
expect(result.includes('GPSLongitude')).assertTrue();
expect(result.includes('GPSLatitudeRef')).assertTrue();
expect(result.includes('GPSLongitudeRef')).assertTrue();
const msg = JSON.parse(result);
expect(msg.GPSLongitude).assertEqual(0);
expect(msg.GPSLatitudeRef).assertEqual('');
expect(msg.GPSLongitudeRef).assertEqual('');
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_EXIF_0600
* @tc.name : getExif_promise_006
* @tc.desc : noExif.jpg, fetchColumn with all_exif, check ImageWidth
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getExif_promise_006', 2, async function (done) {
const testNum = 'getExif_promise_006';
const predicates = new dataSharePredicates.DataSharePredicates();
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: ['all_exif'],
predicates: predicates.equalTo(photoKeys.DISPLAY_NAME, 'noExif.jpg'),
};
try {
const asset = await getFileAsset(testNum, fetchOps);
const result = await asset.getExif();
console.info(`${testNum} result: ${result}`);
expect(result.includes('ImageWidth')).assertTrue();
const msg = JSON.parse(result);
expect(msg.ImageWidth).assertEqual('');
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_EXIF_0700
* @tc.name : getExif_promise_007
* @tc.desc : noExif.jpg, fetchColumn withoutout all_exif, check ImageWidth
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getExif_promise_002', 2, async function (done) {
const testNum = 'getExif_promise_002';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
it('getExif_promise_007', 2, async function (done) {
const testNum = 'getExif_promise_007';
const predicates = new dataSharePredicates.DataSharePredicates();
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: [],
predicates: predicates.equalTo(photoKeys.DISPLAY_NAME, 'noExif.jpg'),
};
await getExifAbnormalPromise(done, testNum, fetchOps);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_EXIF_0900
* @tc.name : getExif_promise_009
* @tc.desc : noExif.jpg, fetchColumn with all_exif and USER_COMMENT, check UserComment
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getExif_promise_009', 2, async function (done) {
const testNum = 'getExif_promise_009';
const predicates = new dataSharePredicates.DataSharePredicates();
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: ['all_exif', photoKeys.USER_COMMENT],
predicates: predicates.equalTo(photoKeys.DISPLAY_NAME, 'noExif.jpg'),
};
try {
const asset = await getFileAsset(testNum, fetchOps);
const result = await asset.getExif();
console.info(`${testNum} result: ${result}`)
expect(result.includes('UserComment')).assertTrue();
const msg = JSON.parse(result);
expect(msg.UserComment).assertEqual('');
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
......@@ -18,7 +18,7 @@ import {
photoKeys,
photoFetchOption,
getFileAsset,
getPermission
getPermission,
} from '../../../../../../common'
export default function setUserCommentTest () {
......@@ -109,7 +109,7 @@ export default function setUserCommentTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_SET_USER_COMMENT_0000
* @tc.name : setUserComment_callback_000
* @tc.desc : userComment is string('setUserComment_callback_000')
* @tc.desc : userComment is string('setUserComment_callback_000'), query by get
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
......@@ -166,10 +166,66 @@ export default function setUserCommentTest () {
await setUserCommentAbnormalCallback(done, testNum, fetchOps, userComment);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_SET_USER_COMMENT_0400
* @tc.name : setUserComment_callback_004
* @tc.desc : userComment is string('aaa...aaa'(141))
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('setUserComment_callback_004', 2, async function (done) {
const testNum = 'setUserComment_callback_004';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'userCommentCb05.jpg');
let userComment = '';
for (let i = 0; i < 141; i++) {
userComment += 'a';
}
await setUserCommentAbnormalCallback(done, testNum, fetchOps, userComment);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_SET_USER_COMMENT_0500
* @tc.name : setUserComment_callback_005
* @tc.desc : userComment is string('setUserComment_callback_005'), query by getExif
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('setUserComment_callback_005', 2, async function (done) {
const testNum = 'setUserComment_callback_005';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'userCommentCb06.jpg');
const userComment = testNum;
try {
const asset = await getFileAsset(testNum, fetchOps);
asset.setUserComment(userComment, async (err) => {
try {
if (err !== undefined) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
} else {
const newAsset = await getFileAsset(testNum, fetchOps);
const result = await newAsset.getExif();
const msg = JSON.parse(result);
console.info(`${testNum} curUserComment: ${msg.UserComment}`);
expect(msg.UserComment).assertEqual(userComment);
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_SET_USER_COMMENT_0000
* @tc.name : setUserComment_promise_000
* @tc.desc : userComment is string('setUserComment_promise_000')
* @tc.desc : userComment is string('setUserComment_promise_000'), query by get
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
......@@ -191,7 +247,7 @@ export default function setUserCommentTest () {
*/
it('setUserComment_promise_001', 2, async function (done) {
const testNum = 'setUserComment_promise_001';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'userCommentCb02.jpg');
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'userCommentPro02.jpg');
const userComment = '';
await setUserCommentPromise(done, testNum, fetchOps, userComment);
});
......@@ -206,7 +262,7 @@ export default function setUserCommentTest () {
*/
it('setUserComment_promise_002', 2, async function (done) {
const testNum = 'setUserComment_promise_002';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'userCommentCb03.jpg');
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'userCommentPro03.jpg');
const userComment = undefined;
await setUserCommentAbnormalPromise(done, testNum, fetchOps, userComment);
});
......@@ -221,9 +277,55 @@ export default function setUserCommentTest () {
*/
it('setUserComment_promise_003', 2, async function (done) {
const testNum = 'setUserComment_promise_003';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'userCommentCb04.jpg');
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'userCommentPro04.jpg');
const userComment = 123;
await setUserCommentAbnormalPromise(done, testNum, fetchOps, userComment);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_SET_USER_COMMENT_0400
* @tc.name : setUserComment_promise_004
* @tc.desc : userComment is string('bbb...bbb'(141))
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('setUserComment_promise_004', 2, async function (done) {
const testNum = 'setUserComment_promise_004';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'userCommentPro05.jpg');
let userComment = '';
for (let i = 0; i < 141; i++) {
userComment += 'b';
}
await setUserCommentAbnormalPromise(done, testNum, fetchOps, userComment);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_SET_USER_COMMENT_0500
* @tc.name : setUserComment_promise_005
* @tc.desc : userComment is string('setUserComment_promise_005'), query by getExif
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('setUserComment_promise_005', 2, async function (done) {
const testNum = 'setUserComment_promise_005';
const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'userCommentPro06.jpg');
const userComment = testNum;
try {
const asset = await getFileAsset(testNum, fetchOps);
await asset.setUserComment(userComment);
const newAsset = await getFileAsset(testNum, fetchOps);
const result = await newAsset.getExif();
const msg = JSON.parse(result);
console.info(`${testNum} curUserComment: ${msg.UserComment}`);
expect(msg.UserComment).assertEqual(userComment);
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
......@@ -23,34 +23,6 @@ describe('ActsNetworkSearchTest', function () {
const SLOT_0 = 0;
const SLOT_2 = -1;
function sleep(timeout) {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.info(`Telephony_NetworkSearch_CellInformation sleep ${timeout}ms`);
resolve();
}, timeout);
})
}
async function turnOnRadio() {
let isOn = await radio.isRadioOn();
if (!isOn) {
await radio.turnOnRadio();
console.info('Telephony_NetworkSearch_CellInformation turnOnRadio success');
await sleep(5000);
}
}
beforeAll(async function () {
await radio.setPreferredNetwork(SLOT_0, radio.PREFERRED_NETWORK_MODE_AUTO);
await turnOnRadio();
})
afterAll(async function () {
await radio.setPreferredNetwork(SLOT_0, radio.PREFERRED_NETWORK_MODE_AUTO);
await turnOnRadio();
})
afterEach(async function () {
try {
expect(radio.RadioTechnology.RADIO_TECHNOLOGY_UNKNOWN === 0).assertTrue();
......
......@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import sms from '@ohos.telephony.sms';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function SmsMmsErrorTest() {
......@@ -126,6 +127,7 @@ describe('SmsMmsErrorTest', function () {
it('Telephony_SmsMms_sendMessage_Promise_0100', 0, async function (done) {
try {
let sendCallback = function (err, data) {
expect(data.isLastPart !== '').assertTrue();
console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}
let deliveryCallback = function (err, data) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册