Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
1c3dff38
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看板
提交
1c3dff38
编写于
3月 20, 2023
作者:
Y
yanglifeng1217
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
<modified>
Signed-off-by:
N
yanglifeng1217
<
yanglifeng5@huawei.com
>
上级
a19e1e1b
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
303 addition
and
265 deletion
+303
-265
distributeddatamgr/dataObjectjstest/hap/src/main/js/test/ObjectStoreJsunit.test.js
...jectjstest/hap/src/main/js/test/ObjectStoreJsunit.test.js
+135
-97
distributeddatamgr/dataObjectjstest/hap/src/main/js/test/ObjectStoreJsunitV9.test.js
...ctjstest/hap/src/main/js/test/ObjectStoreJsunitV9.test.js
+161
-162
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreDistributedJsunit.test.js
...src/main/js/test/RelationalStoreDistributedJsunit.test.js
+7
-6
未找到文件。
distributeddatamgr/dataObjectjstest/hap/src/main/js/test/ObjectStoreJsunit.test.js
浏览文件 @
1c3dff38
...
...
@@ -18,7 +18,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import
bundle
from
'
@ohos.bundle
'
var
baseLine
=
3000
;
//3 second
var
gObject
;
const
CATCH_ERR
=
-
1
;
const
TAG
=
"
OBJECTSTORE_TEST
"
;
function
changeCallback
(
sessionId
,
changeData
)
{
...
...
@@ -699,18 +699,18 @@ export default function objectStoreTest() {
expect
(
complexObject
.
list
[
0
].
mother
==
"
jack2 mom2
"
).
assertEqual
(
true
);
expect
(
complexObject
.
list
[
1
].
father
==
"
jack2 Dad2
"
).
assertEqual
(
true
);
console
.
log
(
TAG
+
"
start unWatch change
"
);
console
.
info
(
TAG
+
"
start unWatch change
"
);
complexObject
.
off
(
"
change
"
);
console
.
log
(
TAG
+
"
end unWatch success
"
);
console
.
info
(
TAG
+
"
end unWatch success
"
);
}
var
endTime
=
new
Date
().
getTime
();
var
totalTime
=
endTime
-
startTime
;
console
.
log
(
"
testPerformance001 totalTime =
"
+
totalTime
);
console
.
log
(
"
testPerformance001 baseLine =
"
+
baseLine
);
console
.
info
(
"
testPerformance001 totalTime =
"
+
totalTime
);
console
.
info
(
"
testPerformance001 baseLine =
"
+
baseLine
);
expect
(
totalTime
<
baseLine
).
assertEqual
(
true
);
complexObject
.
setSessionId
(
""
);
done
();
console
.
log
(
TAG
+
"
************* testPerformance001 end *************
"
);
console
.
info
(
TAG
+
"
************* testPerformance001 end *************
"
);
})
/**
...
...
@@ -720,26 +720,32 @@ export default function objectStoreTest() {
*/
it
(
'
testSave001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* testSave001 start *************
"
);
var
gObject
=
distributedObject
.
createDistributedObject
({
name
:
"
Amy
"
,
age
:
18
,
isVis
:
false
});
gObject
.
setSessionId
(
"
tmpsession01
"
);
let
result
=
await
gObject
.
save
(
"
local
"
);
done
();
expect
(
result
.
sessionId
==
"
tmpsession01
"
).
assertEqual
(
true
);
expect
(
result
.
version
==
gObject
.
__version
).
assertEqual
(
true
);
expect
(
result
.
deviceId
==
"
local
"
).
assertEqual
(
true
);
gObject
.
setSessionId
(
""
);
gObject
.
name
=
undefined
;
gObject
.
age
=
undefined
;
gObject
.
isVis
=
undefined
;
gObject
.
setSessionId
(
"
tmpsession01
"
);
expect
(
gObject
.
name
==
"
Amy
"
).
assertEqual
(
true
);
expect
(
gObject
.
age
==
18
).
assertEqual
(
true
);
expect
(
gObject
.
isVis
==
false
).
assertEqual
(
true
);
gObject
.
setSessionId
(
""
);
done
();
var
g_object
=
distributedObject
.
createDistributedObject
({
name
:
"
Amy
"
,
age
:
18
,
isVis
:
false
});
expect
(
g_object
==
undefined
).
assertEqual
(
false
);
g_object
.
setSessionId
(
"
testSession001
"
);
expect
(
"
testSession001
"
==
g_object
.
__sessionId
).
assertEqual
(
true
);
g_object
.
save
(
"
local
"
).
then
((
ret
)
=>
{
expect
(
ret
.
sessionId
==
"
testSession001
"
).
assertEqual
(
true
);
expect
(
ret
.
version
==
g_object
.
__version
).
assertEqual
(
true
);
expect
(
ret
.
deviceId
==
"
local
"
).
assertEqual
(
true
);
done
();
g_object
.
setSessionId
(
""
);
g_object
.
name
=
undefined
;
g_object
.
age
=
undefined
;
g_object
.
isVis
=
undefined
;
g_object
.
setSessionId
(
"
testSession001
"
);
expect
(
g_object
.
name
==
"
Amy
"
).
assertEqual
(
true
);
expect
(
g_object
.
age
==
18
).
assertEqual
(
true
);
expect
(
g_object
.
isVis
==
false
).
assertEqual
(
true
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
testSave001 err
'
+
`, error code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
expect
(
"
801
"
).
assertEqual
(
err
.
code
.
toString
());
done
();
});
console
.
info
(
TAG
+
"
************* testSave001 end *************
"
);
})
...
...
@@ -748,67 +754,81 @@ export default function objectStoreTest() {
* @tc.desc: Save object
* @tc.number: SUB_DDM_AppDataFWK_Object_Api_Save_002
*/
it
(
'
testSave002
'
,
0
,
function
(
done
)
{
it
(
'
testSave002
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* testSave002 start *************
"
);
var
gObject
=
distributedObject
.
createDistributedObject
({
name
:
"
Amy
"
,
age
:
18
,
isVis
:
false
});
if
(
gObject
!=
undefined
&&
gObject
!=
null
)
{
gObject
.
setSessionId
(
"
tmpsession02
"
);
console
.
info
(
TAG
+
"
testSave002 joinSession tmpsession02 success:
"
+
gObject
.
__sessionId
);
}
gObject
.
save
(
"
local
"
,
(
result
)
=>
{
console
.
info
(
"
save callback
"
);
expect
(
result
.
sessionId
==
"
tmpsession02
"
).
assertEqual
(
true
);
expect
(
result
.
version
==
gObject
.
__version
).
assertEqual
(
true
);
var
g_object
=
distributedObject
.
createDistributedObject
({
name
:
"
Amy
"
,
age
:
18
,
isVis
:
false
});
expect
(
g_object
==
undefined
).
assertEqual
(
false
);
g_object
.
setSessionId
(
"
testSession002
"
);
expect
(
"
testSession002
"
==
g_object
.
__sessionId
).
assertEqual
(
true
);
g_object
.
save
(
"
local
"
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
info
(
'
testSave002 err
'
+
`, error code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
expect
(
"
801
"
).
assertEqual
(
err
.
code
.
toString
());
done
();
return
;
}
expect
(
result
.
sessionId
==
"
testSession002
"
).
assertEqual
(
true
);
expect
(
result
.
version
==
g_object
.
__version
).
assertEqual
(
true
);
expect
(
result
.
deviceId
==
"
local
"
).
assertEqual
(
true
);
console
.
info
(
"
save end
"
);
console
.
info
(
"
save success
"
);
gObject
.
setSessionId
(
""
);
gObject
.
name
=
undefined
;
gObject
.
age
=
undefined
;
gObject
.
isVis
=
undefined
;
console
.
info
(
"
save setSessionId
"
);
gObject
.
setSessionId
(
"
tmpsession02
"
);
expect
(
gObject
.
name
==
"
Amy
"
).
assertEqual
(
true
);
expect
(
gObject
.
age
==
18
).
assertEqual
(
true
);
expect
(
gObject
.
isVis
==
false
).
assertEqual
(
true
);
done
();
gObject
.
setSessionId
(
""
);
});
done
();
g_object
.
setSessionId
(
""
);
g_object
.
name
=
undefined
;
g_object
.
age
=
undefined
;
g_object
.
isVis
=
undefined
;
g_object
.
setSessionId
(
"
testSession002
"
);
expect
(
g_object
.
name
==
"
Amy
"
).
assertEqual
(
true
);
expect
(
g_object
.
age
==
18
).
assertEqual
(
true
);
expect
(
g_object
.
isVis
==
false
).
assertEqual
(
true
);
})
console
.
info
(
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
)
{
it
(
'
testRevokeSave001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* testRevokeSave001 start *************
"
);
var
RObject
=
distributedObject
.
createDistributedObject
({
name
:
"
Amy
"
,
age
:
18
,
isVis
:
false
});
RObject
.
setSessionId
(
"
tmpsession03
"
);
expect
(
"
tmpsession03
"
==
RObject
.
__sessionId
).
assertEqual
(
true
);
let
result
=
await
RObject
.
save
(
"
local
"
);
done
();
expect
(
result
.
sessionId
==
"
tmpsession03
"
).
assertEqual
(
true
);
expect
(
result
.
version
==
RObject
.
__version
).
assertEqual
(
true
);
expect
(
result
.
deviceId
==
"
local
"
).
assertEqual
(
true
);
result
=
await
RObject
.
revokeSave
();
RObject
.
setSessionId
(
""
);
RObject
.
name
=
undefined
;
RObject
.
age
=
undefined
;
RObject
.
isVis
=
undefined
;
RObject
.
setSessionId
(
"
tmpsession03
"
);
expect
(
RObject
.
name
==
"
Amy
"
).
assertEqual
(
false
);
expect
(
RObject
.
age
==
18
).
assertEqual
(
false
);
expect
(
RObject
.
isVis
==
false
).
assertEqual
(
false
);
RObject
.
setSessionId
(
""
);
done
();
var
g_object
=
distributedObject
.
createDistributedObject
({
name
:
"
Amy
"
,
age
:
18
,
isVis
:
false
});
expect
(
g_object
==
undefined
).
assertEqual
(
false
);
g_object
.
setSessionId
(
"
testSession003
"
);
expect
(
"
testSession003
"
==
g_object
.
__sessionId
).
assertEqual
(
true
);
g_object
.
save
(
"
local
"
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
info
(
'
testRevokeSave001 err
'
+
`, error code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
expect
(
"
801
"
).
assertEqual
(
err
.
code
.
toString
());
done
();
return
;
}
expect
(
result
.
sessionId
==
"
testSession003
"
).
assertEqual
(
true
);
expect
(
result
.
version
==
g_object
.
__version
).
assertEqual
(
true
);
expect
(
result
.
deviceId
==
"
local
"
).
assertEqual
(
true
);
g_object
.
revokeSave
((
err
,
result
)
=>
{
if
(
err
)
{
expect
(
"
801
"
).
assertEqual
(
err
.
code
.
toString
());
done
();
return
;
}
expect
(
"
testSession003
"
==
result
.
sessionId
).
assertEqual
(
true
);
g_object
.
setSessionId
(
""
);
g_object
.
name
=
undefined
;
g_object
.
age
=
undefined
;
g_object
.
isVis
=
undefined
;
g_object
.
setSessionId
(
"
testSession003
"
);
expect
(
g_object
.
name
==
undefined
).
assertEqual
(
true
);
expect
(
g_object
.
age
==
undefined
).
assertEqual
(
true
);
expect
(
g_object
.
isVis
==
undefined
).
assertEqual
(
true
);
done
();
})
});
console
.
info
(
TAG
+
"
************* testRevokeSave001 end *************
"
);
})
...
...
@@ -817,31 +837,49 @@ export default function objectStoreTest() {
* @tc.desc: Revoke save object <Callback>
* @tc.number: SUB_DDM_AppDataFWK_Object_Api_RevokeSave_002
*/
it
(
'
testRevokeSave002
'
,
0
,
async
function
(
done
)
{
it
(
'
testRevokeSave002
'
,
0
,
async
function
(
)
{
console
.
info
(
TAG
+
"
************* testRevokeSave002 start *************
"
);
var
RObject
=
distributedObject
.
createDistributedObject
({
name
:
"
Amy
"
,
age
:
18
,
isVis
:
false
});
RObject
.
setSessionId
(
"
tmpsession04
"
);
expect
(
"
tmpsession04
"
==
RObject
.
__sessionId
).
assertEqual
(
true
);
let
result
=
await
RObject
.
save
(
"
local
"
);
done
();
RObject
.
revokeSave
((
response
)
=>
{
console
.
info
(
TAG
+
"
revokeSave callback
"
);
console
.
info
(
"
revokeSave sessionId:
"
+
response
.
sessionId
);
console
.
info
(
TAG
+
"
revokeSave end
"
);
RObject
.
setSessionId
(
""
);
RObject
.
name
=
undefined
;
RObject
.
age
=
undefined
;
RObject
.
isVis
=
undefined
;
RObject
.
setSessionId
(
"
tmpsession04
"
);
expect
(
RObject
.
name
==
"
Amy
"
).
assertEqual
(
false
);
expect
(
RObject
.
age
==
18
).
assertEqual
(
false
);
expect
(
RObject
.
isVis
==
false
).
assertEqual
(
false
);
RObject
.
setSessionId
(
""
);
var
g_object
=
distributedObject
.
createDistributedObject
({
name
:
"
Amy
"
,
age
:
18
,
isVis
:
false
});
expect
(
g_object
==
undefined
).
assertEqual
(
false
);
g_object
.
setSessionId
(
"
testSession004
"
);
expect
(
"
testSession004
"
==
g_object
.
__sessionId
).
assertEqual
(
true
);
let
result
=
await
g_object
.
save
(
"
local
"
).
catch
((
err
)
=>
{
expect
(
"
801
"
).
assertEqual
(
err
.
code
.
toString
());
return
CATCH_ERR
;
});
done
();
if
(
result
===
CATCH_ERR
)
{
return
;
}
expect
(
result
.
sessionId
.
toString
()
==
"
testSession004
"
).
assertEqual
(
true
);
expect
(
result
.
version
.
toString
()
==
g_object
.
__version
.
toString
()).
assertEqual
(
true
);
expect
(
result
.
deviceId
.
toString
()
==
"
local
"
).
assertEqual
(
true
);
result
=
await
g_object
.
revokeSave
().
catch
((
err
)
=>
{
console
.
info
(
'
testRevokeSave002 err
'
+
`, error code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
expect
(
"
801
"
).
assertEqual
(
err
.
code
.
toString
());
return
CATCH_ERR
;
});
if
(
result
===
CATCH_ERR
)
{
return
;
}
g_object
.
setSessionId
(
""
);
g_object
.
name
=
undefined
;
g_object
.
age
=
undefined
;
g_object
.
isVis
=
undefined
;
g_object
.
setSessionId
(
"
testSession004
"
);
expect
(
g_object
.
name
==
undefined
).
assertEqual
(
true
);
expect
(
g_object
.
age
==
undefined
).
assertEqual
(
true
);
expect
(
g_object
.
isVis
==
undefined
).
assertEqual
(
true
);
console
.
info
(
TAG
+
"
************* testRevokeSave002 end *************
"
);
})
console
.
info
(
TAG
+
"
*************Unit Test End*************
"
);
})
}
\ No newline at end of file
distributeddatamgr/dataObjectjstest/hap/src/main/js/test/ObjectStoreJsunitV9.test.js
浏览文件 @
1c3dff38
此差异已折叠。
点击以展开。
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreDistributedJsunit.test.js
浏览文件 @
1c3dff38
...
...
@@ -17,6 +17,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
import
data_Rdb
from
'
@ohos.data.relationalStore
'
;
import
ability_featureAbility
from
'
@ohos.ability.featureAbility
'
;
const
ERRCODE
=
801
;
var
context
=
ability_featureAbility
.
getContext
();
var
sqlStatement
=
"
CREATE TABLE IF NOT EXISTS employee (
"
+
"
id INTEGER PRIMARY KEY AUTOINCREMENT,
"
+
...
...
@@ -100,8 +101,8 @@ describe('relationalStoreDistributedTest', function () {
console
.
info
(
TAG
+
"
set none to be distributed table success
"
);
expect
(
rdbStore
).
assertEqual
(
rdbStore
)
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
set
none to be distributed table failed
"
);
expect
(
null
).
assertFail
(
);
console
.
info
(
TAG
+
"
set
Distributed002 failed
"
+
`, error code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
expect
(
err
.
code
).
assertEqual
(
ERRCODE
);
}
done
()
console
.
info
(
TAG
+
"
************* testRdbStoreDistributed002 end *************
"
);
...
...
@@ -119,8 +120,8 @@ describe('relationalStoreDistributedTest', function () {
console
.
info
(
TAG
+
"
set employee to be distributed table success
"
);
expect
(
rdbStore
).
assertEqual
(
rdbStore
)
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
set
employee to be distributed table failed
"
);
expect
(
null
).
assertFail
(
);
console
.
info
(
TAG
+
"
set
Distributed003 failed
"
+
`, error code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
expect
(
err
.
code
).
assertEqual
(
ERRCODE
);
}
done
()
console
.
info
(
TAG
+
"
************* testRdbStoreDistributed003 end *************
"
);
...
...
@@ -138,8 +139,8 @@ describe('relationalStoreDistributedTest', function () {
console
.
info
(
TAG
+
"
set employee and product to be distributed table success
"
);
expect
(
rdbStore
).
assertEqual
(
rdbStore
)
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
set
employee and product to be distributed table failed
"
);
expect
(
null
).
assertFail
(
);
console
.
info
(
TAG
+
"
set
Distributed004 failed
"
+
`, error code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
expect
(
err
.
code
).
assertEqual
(
ERRCODE
);
}
done
()
console
.
info
(
TAG
+
"
************* testRdbStoreDistributed004 end *************
"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录