Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
e2f9138b
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e2f9138b
编写于
6月 27, 2022
作者:
L
liangzhenyu123
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
<liangzhenyu6@huawei.com>
Signed-off-by:
N
liangzhenyu123
<
liangzhenyu6@huawei.com
>
上级
fb916288
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
169 addition
and
64 deletion
+169
-64
distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js
...p/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js
+1
-58
distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StoragePromiseJsunit.test.js
...hap/src/main/js/default/test/StoragePromiseJsunit.test.js
+42
-1
distributeddatamgr/distributeddataObjectjstest/hap/src/main/js/default/test/ObjectStoreJsunit.test.js
...st/hap/src/main/js/default/test/ObjectStoreJsunit.test.js
+126
-5
未找到文件。
distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js
浏览文件 @
e2f9138b
...
...
@@ -169,63 +169,6 @@ describe('rdbStoreTest', function () {
done
();
console
.
log
(
TAG
+
"
************* testRdbStore0005 end *************
"
);
})
/**
* @tc.name rdb store deleteRdbStore
* @tc.number SUB_DDM_AppDataFWK_JSRDB_RdbStore_0060
* @tc.desc rdb store deleteRdbStore
*/
// it('testRdbStore0006', 0, async function (done) {
// console.log(TAG + "************* testRdbStore0006 start *************");
//
// let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 4);
// storePromise.then(async (store) => {
// try {
// await store.executeSql(CREATE_TABLE_TEST);
// let deletePromise = dataRdb.deleteRdbStore("rdbstore.db")
// deletePromise.then(()=>{
// console.log(TAG + "deleteRdbStore promise done" + store);
// expect(true).assertTrue();
// })
// } catch (e) {
// expect(null).assertFail();
// }
// }).catch((err) => {
// expect(null).assertFail();
// })
// await storePromise
// storePromise = null
// done();
// console.log(TAG + "************* testRdbStore0006 end *************");
// })
/**
* @tc.name rdb store deleteRdbStore
* @tc.number SUB_DDM_AppDataFWK_JSRDB_RdbStore_0070
* @tc.desc rdb store deleteRdbStore
*/
it
(
'
testRdbStore0007
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
************* testRdbStore0007 start *************
"
);
let
storePromise
=
dataRdb
.
getRdbStore
(
STORE_CONFIG
,
6
);
storePromise
.
then
(
async
(
store
)
=>
{
try
{
await
store
.
executeSql
(
CREATE_TABLE_TEST
);
let
deletePromise
=
dataRdb
.
deleteRdbStore
(
"
rdbstore.db
"
)
deletePromise
.
then
(()
=>
{
console
.
log
(
TAG
+
"
deleteRdbStore promise done
"
+
store
);
expect
(
true
).
assertTrue
();
})
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
})
await
storePromise
storePromise
=
null
done
();
console
.
log
(
TAG
+
"
************* testRdbStore0007 end *************
"
);
})
console
.
log
(
TAG
+
"
*************Unit Test End*************
"
);
})
\ No newline at end of file
distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StoragePromiseJsunit.test.js
浏览文件 @
e2f9138b
...
...
@@ -21,6 +21,8 @@ const KEY_TEST_LONG_ELEMENT = 'key_test_long';
const
KEY_TEST_FLOAT_ELEMENT
=
'
key_test_float
'
;
const
KEY_TEST_BOOLEAN_ELEMENT
=
'
key_test_boolean
'
;
const
KEY_TEST_STRING_ELEMENT
=
'
key_test_string
'
;
const
MAX_KEY_LENGTH
=
'
X
'
.
repeat
(
32
)
const
MAX_VALUE_LENGTH
=
'
y
'
.
repeat
(
8191
)
var
mPref
;
describe
(
'
storageTest
'
,
function
()
{
...
...
@@ -380,7 +382,7 @@ describe('storageTest', function () {
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0200
* @tc.desc Maximum length of key test
*/
it
(
'
testMaxLengthofKe
t
y0200
'
,
0
,
async
function
(
done
){
it
(
'
testMaxLengthofKey0200
'
,
0
,
async
function
(
done
){
mPref
.
clearSync
();
const
promise
=
mPref
.
put
(
MAX_KEY_LENGTH
,
"
value1
"
)
promise
.
then
((
ret
)
=>
{
...
...
@@ -449,4 +451,43 @@ describe('storageTest', function () {
await
promise
;
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
){
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
();
})
/**
* @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
)
=>
{
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
();
})
})
distributeddatamgr/distributeddataObjectjstest/hap/src/main/js/default/test/ObjectStoreJsunit.test.js
浏览文件 @
e2f9138b
...
...
@@ -14,8 +14,11 @@
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
distributedObject
from
'
@ohos.data.distributedDataObject
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
var
baseLine
=
500
;
//0.5 second
var
gObject
;
const
TAG
=
"
OBJECTSTORE_TEST
"
;
function
changeCallback
(
sessionId
,
changeData
)
{
...
...
@@ -52,21 +55,43 @@ function statusCallback3(sessionId, networkId, status) {
console
.
info
(
TAG
+
"
test init change333
"
+
sessionId
);
this
.
response
+=
"
\n
status changed
"
+
sessionId
+
"
"
+
status
+
"
"
+
networkId
;
}
function
sleep
(
delay
)
{
var
start
=
(
new
Date
()).
getTime
();
while
((
new
Date
()).
getTime
()
-
start
>=
delay
)
{
break
;
}
}
var
tokenID
=
undefined
;
const
TIMEOUT
=
2000
;
const
PERMISSION_USER_SET
=
1
;
const
PERMISSION_USER_NAME
=
"
ohos.permission.DISTRIBUTED_DATASYNC
"
;
describe
(
'
objectStoreTest
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
TAG
+
'
beforeAll
'
)
beforeAll
(
async
function
(
done
)
{
console
.
info
(
"
====>beforeAll start====
"
);
var
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.distributeddataObject
'
,
0
,
100
);
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
"
bundleName:
"
+
appInfo
.
name
);
var
atManager
=
abilityAccessCtrl
.
createAtManager
();
var
result
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
PERMISSION_USER_NAME
,
PERMISSION_USER_SET
);
console
.
info
(
"
result:
"
+
result
);
sleep
(
TIMEOUT
);
console
.
debug
(
"
====>beforeAll end====
"
);
done
();
})
beforeEach
(
function
()
{
beforeEach
(
async
function
()
{
// await grantPerm();
console
.
info
(
TAG
+
'
beforeEach
'
)
})
afterEach
(
function
()
{
afterEach
(
async
function
()
{
console
.
info
(
TAG
+
'
afterEach
'
)
gObject
.
setSessionId
(
""
);
})
afterAll
(
function
()
{
afterAll
(
async
function
()
{
console
.
info
(
TAG
+
'
afterAll
'
)
})
...
...
@@ -647,5 +672,101 @@ describe('objectStoreTest', function () {
console
.
log
(
TAG
+
"
************* testPerformance001 end *************
"
);
})
/**
* @tc.name: testSave001
* @tc.desc: Save object <Promise>
* @tc.number: SUB_DDM_AppDataFWK_Object_Api_Save_001
*/
it
(
'
testSave001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* testSave001 start *************
"
);
var
gObject
=
distributedObject
.
createDistributedObject
({
name
:
"
Amy
"
,
age
:
18
,
isVis
:
false
});
gObject
.
setSessionId
(
"
tmpsession1
"
);
let
result
=
await
gObject
.
save
(
"
local
"
);
expect
(
result
.
sessionId
==
"
tmpsession1
"
).
assertEqual
(
false
);
expect
(
result
.
version
==
gObject
.
__version
).
assertEqual
(
false
);
expect
(
result
.
deviceId
==
"
local
"
).
assertEqual
(
false
);
gObject
.
setSessionId
(
""
);
gObject
.
name
=
undefined
;
gObject
.
age
=
undefined
;
gObject
.
isVis
=
undefined
;
gObject
.
setSessionId
(
"
tmpsession1
"
);
expect
(
gObject
.
name
==
"
Amy
"
).
assertEqual
(
false
);
expect
(
gObject
.
age
==
18
).
assertEqual
(
false
);
expect
(
gObject
.
isVis
==
false
).
assertEqual
(
false
);
done
();
console
.
info
(
TAG
+
"
************* testSave001 end *************
"
);
})
/**
* @tc.name: testSave002
* @tc.desc: Save object <Callback>
* @tc.number: SUB_DDM_AppDataFWK_Object_Api_Save_002
*/
it
(
'
testSave002
'
,
0
,
function
(
done
)
{
console
.
log
(
TAG
+
"
************* testSave002 start *************
"
);
var
gObject
=
distributedObject
.
createDistributedObject
({
name
:
"
Amy
"
,
age
:
18
,
isVis
:
false
});
gObject
.
setSessionId
(
"
tmpsession1
"
);
gObject
.
save
(
"
local
"
,(
result
)
=>
{
expect
(
result
!=
null
).
assertTrue
();
expect
(
result
.
sessionId
==
"
tmpsession1
"
).
assertEqual
(
false
);
expect
(
result
.
version
==
gObject
.
__version
).
assertEqual
(
false
);
expect
(
result
.
deviceId
==
"
local
"
).
assertEqual
(
false
);
});
gObject
.
setSessionId
(
""
);
gObject
.
name
=
undefined
;
gObject
.
age
=
undefined
;
gObject
.
isVis
=
undefined
;
gObject
.
setSessionId
(
"
tmpsession1
"
);
expect
(
gObject
.
name
==
"
Amy
"
).
assertEqual
(
false
);
expect
(
gObject
.
age
==
18
).
assertEqual
(
false
);
expect
(
gObject
.
isVis
==
false
).
assertEqual
(
false
);
done
();
console
.
log
(
TAG
+
"
************* testSave002 end *************
"
);
})
/**
* @tc.name: testRevokeSave001
* @tc.desc: Revoke save object <Promise>
* @tc.number: SUB_DDM_AppDataFWK_Object_Api_RevokeSave_001
*/
it
(
'
testRevokeSave001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
************* testRevokeSave001 start *************
"
);
var
gObject
=
distributedObject
.
createDistributedObject
({
name
:
"
Amy
"
,
age
:
18
,
isVis
:
false
});
gObject
.
setSessionId
(
"
123456
"
);
let
result
=
await
gObject
.
save
(
"
local
"
);
expect
(
result
.
sessionId
!=
"
123456
"
).
assertEqual
(
true
);
expect
(
result
.
version
!=
gObject
.
__version
).
assertEqual
(
true
);
expect
(
result
.
deviceId
!=
"
local
"
).
assertEqual
(
true
);
result
=
await
gObject
.
revokeSave
();
expect
(
result
!=
null
).
assertTrue
();
done
();
console
.
log
(
TAG
+
"
************* testRevokeSave001 end *************
"
);
})
/**
* @tc.name: testRevokeSave002
* @tc.desc: Revoke save object <Callback>
* @tc.number: SUB_DDM_AppDataFWK_Object_Api_RevokeSave_002
*/
it
(
'
testRevokeSave002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
************* testRevokeSave002 start *************
"
);
var
gObject
=
distributedObject
.
createDistributedObject
({
name
:
"
Amy
"
,
age
:
18
,
isVis
:
false
});
gObject
.
setSessionId
(
"
123456
"
);
let
result
=
await
gObject
.
save
(
"
local
"
);
expect
(
result
.
sessionId
!=
"
123456
"
).
assertEqual
(
true
);
expect
(
result
.
version
!=
gObject
.
__version
).
assertEqual
(
true
);
expect
(
result
.
deviceId
!=
"
local
"
).
assertEqual
(
true
);
gObject
.
revokeSave
((
err
,
ret
)
=>
{
expect
(
err
==
null
).
assertTrue
();
});
done
();
console
.
log
(
TAG
+
"
************* testRevokeSave002 end *************
"
);
})
console
.
log
(
TAG
+
"
*************Unit Test End*************
"
);
})
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录