Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
40d32c8e
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
40d32c8e
编写于
10月 11, 2022
作者:
L
liangzhenyu123
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
系统API相关用例下架
Signed-off-by:
N
liangzhenyu123
<
liangzhenyu6@huawei.com
>
上级
858c54ec
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
394 deletion
+6
-394
distributeddatamgr/dataSharejstest/hap/src/main/js/test/List.test.js
...datamgr/dataSharejstest/hap/src/main/js/test/List.test.js
+0
-2
distributeddatamgr/dataSharejstest/hap/src/main/js/test/RdbStoreDataShareJsunit.test.js
...test/hap/src/main/js/test/RdbStoreDataShareJsunit.test.js
+0
-391
distributeddatamgr/preferencesjstest/hap/src/main/js/test/StorageSyncJsunit.test.js
...ncesjstest/hap/src/main/js/test/StorageSyncJsunit.test.js
+6
-1
未找到文件。
distributeddatamgr/dataSharejstest/hap/src/main/js/test/List.test.js
浏览文件 @
40d32c8e
...
...
@@ -13,8 +13,6 @@
* limitations under the License.
*/
import
dataAbilityPredicatesTest
from
'
./DataAbilityPredicatesJsunit.test.js
'
import
rdbStoreDataSharePredicatesTest
from
'
./RdbStoreDataShareJsunit.test.js
'
export
default
function
testsuite
()
{
dataAbilityPredicatesTest
()
rdbStoreDataSharePredicatesTest
()
}
distributeddatamgr/dataSharejstest/hap/src/main/js/test/RdbStoreDataShareJsunit.test.js
已删除
100644 → 0
浏览文件 @
858c54ec
/*
* Copyright (C) 2022 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
dataRdb
from
'
@ohos.data.rdb
'
import
abilityFeatureAbility
from
'
@ohos.ability.featureAbility
'
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
const
TAG
=
"
[RDB_JSKITS_TEST]
"
const
CREATE_TABLE_TEST
=
"
CREATE TABLE IF NOT EXISTS test (
"
+
"
id INTEGER PRIMARY KEY AUTOINCREMENT,
"
+
"
name TEXT NOT NULL,
"
+
"
age INTEGER,
"
+
"
salary REAL,
"
+
"
blobType BLOB)
"
const
DROP_TABLE_TEST
=
"
drop table test
"
const
STORE_CONFIG
=
{
name
:
"
DataShareTest.db
"
,
}
var
rdbStore
=
undefined
var
context
=
abilityFeatureAbility
.
getContext
()
export
default
function
rdbStoreDataSharePredicatesTest
()
{
describe
(
'
rdbStoreDataSharePredicatesTest
'
,
function
()
{
beforeAll
(
async
function
()
{
console
.
info
(
TAG
+
'
beforeAll
'
)
rdbStore
=
await
dataRdb
.
getRdbStore
(
context
,
STORE_CONFIG
,
1
)
})
beforeEach
(
async
function
()
{
console
.
info
(
TAG
+
'
beforeEach
'
)
await
rdbStore
.
executeSql
(
CREATE_TABLE_TEST
,
null
)
})
afterEach
(
async
function
()
{
console
.
info
(
TAG
+
'
afterEach
'
)
await
rdbStore
.
executeSql
(
DROP_TABLE_TEST
,
null
)
})
afterAll
(
async
function
()
{
console
.
info
(
TAG
+
'
afterAll
'
)
rdbStore
=
null
await
dataRdb
.
deleteRdbStore
(
context
,
"
DataShareTest.db
"
)
})
console
.
info
(
TAG
+
"
*************Unit Test Begin*************
"
)
/**
* @tc.name rdb DataShare insert test
* @tc.number SUB_DataShare_Rdb_Func0001
* @tc.desc rdb DataShare Func insert test
*/
it
(
'
testRdbStoreDataShareFunc0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0001 start *************
"
)
let
u8
=
new
Uint8Array
([
1
,
2
,
3
])
const
valueBucket
=
{
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
let
insertPromise
=
rdbStore
.
insert
(
"
test
"
,
valueBucket
)
insertPromise
.
then
(
async
(
ret
)
=>
{
expect
(
1
).
assertEqual
(
ret
)
console
.
info
(
TAG
+
"
Insert done:
"
+
ret
)
}).
catch
((
err
)
=>
{
console
.
info
(
TAG
+
"
Insert err:
"
+
err
)
expect
(
false
).
assertTrue
()
})
await
insertPromise
console
.
info
(
"
insert end
"
)
let
predicates
=
new
dataRdb
.
RdbPredicates
(
"
test
"
)
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
let
resultSet
=
await
rdbStore
.
query
(
predicates
)
try
{
console
.
info
(
TAG
+
"
resultSet query done
"
)
expect
(
true
).
assertEqual
(
resultSet
.
goToFirstRow
())
const
name
=
resultSet
.
getString
(
resultSet
.
getColumnIndex
(
"
name
"
))
const
age
=
resultSet
.
getLong
(
resultSet
.
getColumnIndex
(
"
age
"
))
const
salary
=
resultSet
.
getDouble
(
resultSet
.
getColumnIndex
(
"
salary
"
))
const
blobType
=
resultSet
.
getBlob
(
resultSet
.
getColumnIndex
(
"
blobType
"
))
expect
(
"
zhangsan
"
).
assertEqual
(
name
)
expect
(
18
).
assertEqual
(
age
)
expect
(
100.5
).
assertEqual
(
salary
)
expect
(
1
).
assertEqual
(
blobType
[
0
])
expect
(
2
).
assertEqual
(
blobType
[
1
])
expect
(
3
).
assertEqual
(
blobType
[
2
])
}
catch
(
err
)
{
expect
(
false
).
assertTrue
()
}
resultSet
=
null
done
()
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0001 end *************
"
)
})
/**
* @tc.name rdb DataShare update test
* @tc.number SUB_DataShare_Rdb_Func0002
* @tc.desc rdb DataShare update promise Func test
*/
it
(
'
testRdbStoreDataShareFunc0002
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0002 start *************
"
)
let
u8
=
new
Uint8Array
([
1
,
2
,
3
])
let
valueBucket
=
{
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
)
u8
=
new
Uint8Array
([
4
,
5
,
6
])
valueBucket
=
{
"
name
"
:
"
lisi
"
,
"
age
"
:
28
,
"
salary
"
:
200.5
,
"
blobType
"
:
u8
,
}
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
()
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
let
promiseUpdate
=
rdbStore
.
update
(
"
test
"
,
valueBucket
,
predicates
)
promiseUpdate
.
then
(
async
(
ret
)
=>
{
expect
(
1
).
assertEqual
(
ret
)
console
.
info
(
TAG
+
"
Update done:
"
+
ret
)
}).
catch
((
err
)
=>
{
console
.
info
(
TAG
+
"
Update err:
"
+
err
)
expect
(
false
).
assertTrue
()
})
await
promiseUpdate
let
rdbPredicates
=
await
new
dataRdb
.
RdbPredicates
(
"
test
"
)
rdbPredicates
.
equalTo
(
"
name
"
,
"
lisi
"
)
let
resultSet
=
await
rdbStore
.
query
(
rdbPredicates
)
expect
(
true
).
assertEqual
(
resultSet
.
goToFirstRow
())
const
id
=
resultSet
.
getLong
(
resultSet
.
getColumnIndex
(
"
id
"
))
const
name
=
resultSet
.
getString
(
resultSet
.
getColumnIndex
(
"
name
"
))
const
age
=
resultSet
.
getLong
(
resultSet
.
getColumnIndex
(
"
age
"
))
const
salary
=
resultSet
.
getDouble
(
resultSet
.
getColumnIndex
(
"
salary
"
))
const
blobType
=
resultSet
.
getBlob
(
resultSet
.
getColumnIndex
(
"
blobType
"
))
expect
(
"
lisi
"
).
assertEqual
(
name
)
expect
(
28
).
assertEqual
(
age
)
expect
(
200.5
).
assertEqual
(
salary
)
expect
(
4
).
assertEqual
(
blobType
[
0
])
expect
(
5
).
assertEqual
(
blobType
[
1
])
expect
(
6
).
assertEqual
(
blobType
[
2
])
console
.
info
(
TAG
+
"
dataShare update: {id=
"
+
id
+
"
, name=
"
+
name
+
"
,
"
+
"
age=
"
+
age
+
"
, salary=
"
+
salary
+
"
, blobType=
"
+
blobType
)
resultSet
=
null
done
()
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0002 end *************
"
)
})
/**
* @tc.name rdb DataShare update test
* @tc.number SUB_DataShare_Rdb_Func0003
* @tc.desc rdb DataShare update callback Func test
*/
it
(
'
testRdbStoreDataShareFunc0003
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0003 start *************
"
)
let
u8
=
new
Uint8Array
([
1
,
2
,
3
])
let
valueBucket
=
{
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
)
u8
=
new
Uint8Array
([
4
,
5
,
6
])
valueBucket
=
{
"
name
"
:
"
lisi
"
,
"
age
"
:
28
,
"
salary
"
:
200.5
,
"
blobType
"
:
u8
,
}
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
()
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
await
rdbStore
.
update
(
"
test
"
,
valueBucket
,
predicates
,
async
function
(
err
,
ret
)
{
if
(
err
)
{
console
.
info
(
"
Update err:
"
+
err
)
expect
(
false
).
assertTrue
()
}
expect
(
1
).
assertEqual
(
ret
)
console
.
info
(
"
Update done:
"
+
ret
)
let
rdbPredicates
=
await
new
dataRdb
.
RdbPredicates
(
"
test
"
)
rdbPredicates
.
equalTo
(
"
name
"
,
"
lisi
"
)
let
resultSet
=
await
rdbStore
.
query
(
rdbPredicates
)
expect
(
1
).
assertEqual
(
resultSet
.
rowCount
)
expect
(
true
).
assertEqual
(
resultSet
.
goToFirstRow
())
const
id
=
resultSet
.
getLong
(
resultSet
.
getColumnIndex
(
"
id
"
))
const
name
=
resultSet
.
getString
(
resultSet
.
getColumnIndex
(
"
name
"
))
const
age
=
resultSet
.
getLong
(
resultSet
.
getColumnIndex
(
"
age
"
))
const
salary
=
resultSet
.
getDouble
(
resultSet
.
getColumnIndex
(
"
salary
"
))
const
blobType
=
resultSet
.
getBlob
(
resultSet
.
getColumnIndex
(
"
blobType
"
))
expect
(
"
lisi
"
).
assertEqual
(
name
)
expect
(
28
).
assertEqual
(
age
)
expect
(
200.5
).
assertEqual
(
salary
)
expect
(
4
).
assertEqual
(
blobType
[
0
])
expect
(
5
).
assertEqual
(
blobType
[
1
])
expect
(
6
).
assertEqual
(
blobType
[
2
])
console
.
info
(
TAG
+
"
dataShare update: {id=
"
+
id
+
"
, name=
"
+
name
+
"
,
"
+
"
age=
"
+
age
+
"
, salary=
"
+
salary
+
"
, blobType=
"
+
blobType
)
resultSet
=
null
})
done
()
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0003 end *************
"
)
})
/**
* @tc.name rdb DataShare query test
* @tc.number SUB_DataShare_Rdb_Func0004
* @tc.desc rdb DataShare query promise Func test
*/
it
(
'
testRdbStoreDataShareFunc0004
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0004 start *************
"
)
let
u8
=
new
Uint8Array
([
4
,
5
,
6
])
let
valueBucket
=
{
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
)
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
()
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
let
queryPromise
=
rdbStore
.
query
(
"
test
"
,
predicates
)
queryPromise
.
then
((
resultSet
)
=>
{
console
.
info
(
TAG
+
"
DataShare Query done:
"
)
expect
(
true
).
assertEqual
(
resultSet
.
goToFirstRow
())
const
name
=
resultSet
.
getString
(
resultSet
.
getColumnIndex
(
"
name
"
))
const
age
=
resultSet
.
getLong
(
resultSet
.
getColumnIndex
(
"
age
"
))
const
salary
=
resultSet
.
getDouble
(
resultSet
.
getColumnIndex
(
"
salary
"
))
const
blobType
=
resultSet
.
getBlob
(
resultSet
.
getColumnIndex
(
"
blobType
"
))
expect
(
"
zhangsan
"
).
assertEqual
(
name
)
expect
(
18
).
assertEqual
(
age
)
expect
(
100.5
).
assertEqual
(
salary
)
expect
(
4
).
assertEqual
(
blobType
[
0
])
expect
(
5
).
assertEqual
(
blobType
[
1
])
expect
(
6
).
assertEqual
(
blobType
[
2
])
}).
catch
((
err
)
=>
{
console
.
info
(
TAG
+
"
Query err:
"
+
err
)
expect
(
false
).
assertTrue
()
})
await
queryPromise
done
()
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0004 end *************
"
)
})
/**
* @tc.name rdb DataShare query test
* @tc.number SUB_DataShare_Rdb_Func0005
* @tc.desc rdb DataShare query callback Func test
*/
it
(
'
testRdbStoreDataShareFunc0005
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0005 start *************
"
)
let
u8
=
new
Uint8Array
([
4
,
5
,
6
])
let
valueBucket
=
{
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
)
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
()
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
await
rdbStore
.
query
(
"
test
"
,
predicates
,
[
"
ID
"
,
"
NAME
"
,
"
AGE
"
,
"
SALARY
"
,
"
blobType
"
],
function
(
err
,
resultSet
)
{
if
(
err
)
{
console
.
info
(
"
Query err:
"
+
err
)
expect
(
false
).
assertTrue
()
}
expect
(
true
).
assertEqual
(
resultSet
.
goToFirstRow
())
const
name
=
resultSet
.
getString
(
resultSet
.
getColumnIndex
(
"
name
"
))
const
age
=
resultSet
.
getLong
(
resultSet
.
getColumnIndex
(
"
age
"
))
const
salary
=
resultSet
.
getDouble
(
resultSet
.
getColumnIndex
(
"
salary
"
))
const
blobType
=
resultSet
.
getBlob
(
resultSet
.
getColumnIndex
(
"
blobType
"
))
expect
(
"
zhangsan
"
).
assertEqual
(
name
)
expect
(
18
).
assertEqual
(
age
)
expect
(
100.5
).
assertEqual
(
salary
)
expect
(
4
).
assertEqual
(
blobType
[
0
])
expect
(
5
).
assertEqual
(
blobType
[
1
])
expect
(
6
).
assertEqual
(
blobType
[
2
])
})
done
()
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0005 end *************
"
)
})
/**
* @tc.name rdb DataShare delete test
* @tc.number SUB_DataShare_Rdb_Func0006
* @tc.desc rdb DataShare delete Func test
*/
it
(
'
testRdbStoreDataShareFunc0006
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0006 start *************
"
)
let
u8
=
new
Uint8Array
([
1
,
2
,
3
])
let
valueBucket
=
{
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
)
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
()
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
let
deletePromise
=
rdbStore
.
delete
(
"
test
"
,
predicates
)
deletePromise
.
then
(
async
(
ret
)
=>
{
expect
(
1
).
assertEqual
(
ret
)
console
.
info
(
TAG
+
"
Delete done:
"
+
ret
)
}).
catch
((
err
)
=>
{
console
.
info
(
TAG
+
"
Delete err:
"
+
err
)
expect
(
false
).
assertTrue
()
})
await
deletePromise
let
rdbPredicates
=
await
new
dataRdb
.
RdbPredicates
(
"
test
"
)
rdbPredicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
let
resultSet
=
await
rdbStore
.
query
(
rdbPredicates
)
expect
(
false
).
assertEqual
(
resultSet
.
goToFirstRow
())
resultSet
=
null
done
()
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0006 end *************
"
)
})
/**
* @tc.name rdb DataShare delete test
* @tc.number SUB_DataShare_Rdb_Func0007
* @tc.desc rdb DataShare delete Func test
*/
it
(
'
testRdbStoreDataShareFunc0007
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0007 start *************
"
)
let
u8
=
new
Uint8Array
([
1
,
2
,
3
])
let
valueBucket
=
{
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
)
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
()
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
await
rdbStore
.
delete
(
"
test
"
,
predicates
,
async
function
(
err
,
ret
)
{
if
(
err
)
{
console
.
info
(
"
Delete err:
"
+
err
)
expect
(
false
).
assertTrue
()
}
expect
(
1
).
assertEqual
(
ret
)
console
.
info
(
"
Delete done:
"
+
ret
)
let
rdbPredicates
=
await
new
dataRdb
.
RdbPredicates
(
"
test
"
)
rdbPredicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
let
resultSet
=
await
rdbStore
.
query
(
rdbPredicates
)
expect
(
false
).
assertEqual
(
resultSet
.
goToFirstRow
())
resultSet
=
null
})
done
()
console
.
info
(
TAG
+
"
************* testRdbStoreDataShareFunc0007 end *************
"
)
})
console
.
info
(
TAG
+
"
*************Unit Test End*************
"
)
})}
distributeddatamgr/preferencesjstest/hap/src/main/js/test/StorageSyncJsunit.test.js
浏览文件 @
40d32c8e
...
...
@@ -36,6 +36,11 @@ describe('storageSyncTest', function () {
storage
.
deleteStorageSync
(
PATH
);
})
/**
* @tc.name Clear test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Clear_0010
* @tc.desc Clear test
*/
it
(
'
testClear001
'
,
0
,
function
()
{
mPref
.
putSync
(
KEY_TEST_STRING_ELEMENT
,
"
test
"
);
mPref
.
putSync
(
KEY_TEST_INT_ELEMENT
,
3
);
...
...
@@ -290,7 +295,7 @@ describe('storageSyncTest', function () {
/**
* @tc.name get defaultValue callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0
17
0
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0
21
0
* @tc.desc get defaultValue callback interface test
*/
it
(
'
testGetDefValue001
'
,
0
,
async
function
(
done
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录