1.XTS测试问题修改,ArkTs整改之后XTS也需要更新

Signed-off-by: zhoulisheng1 <zhoulisheng1@huawei.com>
This commit is contained in:
zhoulisheng1 2023-09-26 16:05:21 +08:00
parent 493823611b
commit 283b805f28
4 changed files with 35 additions and 20 deletions

View File

@ -44,7 +44,7 @@ export default class EntryAbility extends UIAbility {
} }
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
}); });
this.context.resourceManager
ImageKnife.with(this.context); ImageKnife.with(this.context);
// 全局配置网络加载进度条 // 全局配置网络加载进度条
ImageKnifeGlobal.getInstance().getImageKnife().setDefaultLifeCycle(ImageKnifeDrawFactory.createProgressLifeCycle("#10a5ff", 0.5)) ImageKnifeGlobal.getInstance().getImageKnife().setDefaultLifeCycle(ImageKnifeDrawFactory.createProgressLifeCycle("#10a5ff", 0.5))

View File

@ -39,13 +39,13 @@ export default function lruCacheTest() {
}) })
it('testLruCacheSize',0, ()=> { it('testLruCacheSize',0, ()=> {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let memoryCache = new LruCache<string, any>(100); let memoryCache = new LruCache<string, string>(100);
expect(memoryCache.size).assertEqual(0); expect(memoryCache.size).assertEqual(0);
expect(memoryCache.maxsize).assertEqual(100) expect(memoryCache.maxsize).assertEqual(100)
}) })
it('testLruCachePut',1, ()=> { it('testLruCachePut',1, ()=> {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let memoryCache = new LruCache<string, any>(5); let memoryCache = new LruCache<string, string>(5);
memoryCache.put("1","1"); memoryCache.put("1","1");
memoryCache.put("2","2"); memoryCache.put("2","2");
memoryCache.put("3","3"); memoryCache.put("3","3");
@ -59,7 +59,7 @@ export default function lruCacheTest() {
}) })
it('testLruCacheGet',2, ()=> { it('testLruCacheGet',2, ()=> {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let memoryCache = new LruCache<string, any>(5); let memoryCache = new LruCache<string, string>(5);
memoryCache.put("1","1"); memoryCache.put("1","1");
memoryCache.put("2","2"); memoryCache.put("2","2");
memoryCache.put("3","3"); memoryCache.put("3","3");
@ -73,7 +73,7 @@ export default function lruCacheTest() {
}) })
it('testLruCacheAlgorithm',3, ()=> { it('testLruCacheAlgorithm',3, ()=> {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let memoryCache = new LruCache<string, any>(5); let memoryCache = new LruCache<string, string>(5);
memoryCache.put("1","1"); memoryCache.put("1","1");
memoryCache.put("2","2"); memoryCache.put("2","2");
memoryCache.put("3","3"); memoryCache.put("3","3");
@ -82,17 +82,24 @@ export default function lruCacheTest() {
memoryCache.get("1"); memoryCache.get("1");
memoryCache.get("2"); memoryCache.get("2");
let count:number = 1
memoryCache.foreachLruCache( (value, key, index)=> { let callback =(key:string,value:string)=>{
if(index == 0){ if(count == 5){
expect(key).assertEqual("2") expect(key).assertEqual("2")
expect(value).assertEqual("2") expect(value).assertEqual("2")
}
console.log('dodo count='+count+' key='+key+' value='+value)
count++;
} }
}) memoryCache.foreachLruCache( (value:string, key:string, map:Map<string,string>)=> {
callback(key,value)
})
expect(memoryCache.size).assertEqual(5)
}) })
it('testLruCacheRemove',4, ()=> { it('testLruCacheRemove',4, ()=> {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let memoryCache = new LruCache<string, any>(5); let memoryCache = new LruCache<string, string>(5);
memoryCache.put("1","1"); memoryCache.put("1","1");
memoryCache.put("2","2"); memoryCache.put("2","2");
memoryCache.put("3","3"); memoryCache.put("3","3");
@ -104,16 +111,23 @@ export default function lruCacheTest() {
memoryCache.remove("2"); memoryCache.remove("2");
memoryCache.foreachLruCache( (value, key, index)=> { let count:number = 1
if(index == 0){ let callback =(key:string,value:string)=>{
expect(key).assertEqual("1") if(count == 4){
expect(value).assertEqual("1") expect(key).assertEqual("1")
expect(value).assertEqual("1")
}
console.log('dodo count='+count+' key='+key+' value='+value)
count++;
} }
}) memoryCache.foreachLruCache( (value:string, key:string, map:Map<string,string>)=> {
callback(key,value)
})
expect(memoryCache.size).assertEqual(4)
}) })
it('testLruCacheResize',5, ()=> { it('testLruCacheResize',5, ()=> {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let memoryCache = new LruCache<string, any>(5); let memoryCache = new LruCache<string, string>(5);
memoryCache.put("1","1"); memoryCache.put("1","1");
memoryCache.put("2","2"); memoryCache.put("2","2");
memoryCache.put("3","3"); memoryCache.put("3","3");

View File

@ -44,7 +44,7 @@ export default function RequestOptionTest() {
}) })
it('TestConfigLoadSrc',1, ()=> { it('TestConfigLoadSrc',1, ()=> {
let option = new RequestOption(); let option = new RequestOption();
expect(option.loadSrc).assertEqual(undefined) expect(option.loadSrc).assertEqual('')
option.loadSrc = $r('app.media.icon') option.loadSrc = $r('app.media.icon')
expect(JSON.stringify(option.loadSrc)).assertEqual(JSON.stringify($r('app.media.icon'))) expect(JSON.stringify(option.loadSrc)).assertEqual(JSON.stringify($r('app.media.icon')))
}) })

View File

@ -30,7 +30,8 @@ export default class TestAbility extends UIAbility {
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
(ImageKnifeGlobal.getInstance().setHapContext(this.context.createModuleContext("entry_test"))) // 初始化xts的ImageKnife
ImageKnife.with(this.context.createModuleContext("entry_test"));
} }
onDestroy() { onDestroy() {