Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
f2e73260
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,发现更多精彩内容 >>
You need to sign in or sign up before continuing.
未验证
提交
f2e73260
编写于
9月 08, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 08, 2022
浏览文件
操作
浏览文件
下载
差异文件
!5380 FA模型支持dataability权限校验需求xts用例
Merge pull request !5380 from mingxihua/master
上级
09927009
ea183f78
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
578 addition
and
0 deletion
+578
-0
ability/ability_runtime/actsfwkdataaccessortest/actsdataabilityrelyhap/entry/src/main/config.json
...sortest/actsdataabilityrelyhap/entry/src/main/config.json
+12
-0
ability/ability_runtime/actsfwkdataaccessortest/actsdataabilityrelyhap/entry/src/main/ets/TestDataAbility3/data.ts
...bilityrelyhap/entry/src/main/ets/TestDataAbility3/data.ts
+216
-0
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/test/DataAbilityHelperJsStPermission.test.js
.../src/main/js/test/DataAbilityHelperJsStPermission.test.js
+348
-0
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/test/List.test.js
...est/actsfwkdataaccessortest/src/main/js/test/List.test.js
+2
-0
未找到文件。
ability/ability_runtime/actsfwkdataaccessortest/actsdataabilityrelyhap/entry/src/main/config.json
浏览文件 @
f2e73260
...
...
@@ -69,6 +69,18 @@
"type"
:
"data"
,
"visible"
:
true
,
"uri"
:
"dataability://com.example.myapplication.DataAbility2"
},
{
"srcPath"
:
"TestDataAbility3"
,
"name"
:
".TestDataAbility3"
,
"icon"
:
"$media:icon"
,
"srcLanguage"
:
"ets"
,
"description"
:
"$string:description_testdataability"
,
"type"
:
"data"
,
"visible"
:
true
,
"uri"
:
"dataability://com.example.myapplication.DataAbility3"
,
"readPermission"
:
"ohos.permission.READ_CONTACTS"
,
"writePermission"
:
"ohos.permission.WRITE_CONTACTS"
}
],
"js"
:
[
...
...
ability/ability_runtime/actsfwkdataaccessortest/actsdataabilityrelyhap/entry/src/main/ets/TestDataAbility3/data.ts
0 → 100644
浏览文件 @
f2e73260
/*
* 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
dataAbility
from
'
@ohos.data.dataAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
fileio
from
'
@ohos.fileio
'
import
dataRdb
from
'
@ohos.data.rdb
'
const
TABLE_NAME
=
'
book
'
const
STORE_CONFIG
=
{
name
:
'
book.db
'
}
const
SQL_CREATE_TABLE
=
'
CREATE TABLE IF NOT EXISTS book
'
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, age INTEGER, introduction TEXT NOT NULL)
'
let
rdbStore
:
any
=
undefined
const
TAG
=
'
ACTS_ DataAbility.data
'
const
context
=
featureAbility
.
getContext
()
let
defaultReturn
=
1
;
let
returnError
=
0
;
let
returnError1
=
-
1
;
let
returnError2
=
-
2
;
let
returnError3
=
-
3
;
let
dataAbilityUri
=
(
"
dataability:///com.example.myapplication.DataAbility3
"
);
export
default
{
onInitialized
(
abilityInfo
)
{
console
.
debug
(
'
ACTS_ DataAbility onInitialized,abilityInfo=
'
+
abilityInfo
.
bundleName
)
dataRdb
.
getRdbStore
(
context
,
STORE_CONFIG
,
1
,
(
err
,
store
)
=>
{
console
.
debug
(
'
ACTS_ [data]getRdbStoreThen
'
)
store
.
executeSql
(
SQL_CREATE_TABLE
,
[])
rdbStore
=
store
});
},
insert
(
uri
,
valueBucket
,
callback
)
{
console
.
debug
(
TAG
+
'
insert start 1121
'
)
console
.
debug
(
TAG
+
'
valueBucket json=>
'
+
JSON
.
stringify
(
valueBucket
))
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
console
.
debug
(
TAG
+
'
valueBucket.age =>
'
+
valueBucket
.
age
)
console
.
debug
(
TAG
+
'
valueBucket.name =>
'
+
valueBucket
.
name
)
console
.
debug
(
TAG
+
'
valueBucket.salary =>
'
+
valueBucket
.
salary
)
if
(
valueBucket
.
age
!=
24
)
{
err
=
"
Error age
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
name
!=
"
ActsDataAbilityHelperPermissionTest
"
)
{
err
=
"
Error name
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
salary
!=
2024.20
)
{
err
=
"
Error salary
"
callback
(
err
,
returnError2
);
}
err
=
"
Error insert
"
console
.
debug
(
TAG
+
'
rdbStore.insert
'
)
rdbStore
.
insert
(
TABLE_NAME
,
valueBucket
,
function
(
err
,
resultSet
)
{
console
.
log
(
TAG
+
"
insert callback resultSet:
"
+
resultSet
+
"
,json=
"
+
JSON
.
stringify
(
resultSet
)
+
'
,err
'
+
err
)
callback
(
err
,
defaultReturn
);
})
},
query
(
uri
,
columns
,
predicates
,
callback
)
{
console
.
debug
(
TAG
+
'
query start
'
)
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
let
rdbPredicates
=
dataAbility
.
createRdbPredicates
(
TABLE_NAME
,
predicates
)
rdbStore
.
query
(
rdbPredicates
,
columns
,
callback
)
},
update
(
uri
,
valueBucket
,
predicates
,
callback
)
{
console
.
debug
(
TAG
+
'
update start
'
)
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
console
.
debug
(
TAG
+
'
valueBucket.age =>
'
+
valueBucket
.
age
)
console
.
debug
(
TAG
+
'
valueBucket.name =>
'
+
valueBucket
.
name
)
console
.
debug
(
TAG
+
'
valueBucket.salary =>
'
+
valueBucket
.
salary
)
if
(
valueBucket
.
age
!=
24
)
{
err
=
"
Error age
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
name
!=
"
ActsDataAbilityHelperPermissionTest
"
)
{
err
=
"
Error name
"
callback
(
err
,
returnError2
);
}
if
(
valueBucket
.
salary
!=
2024.20
)
{
err
=
"
Error salary
"
callback
(
err
,
returnError2
);
}
err
=
"
Error update
"
let
rdbPredicates
=
dataAbility
.
createRdbPredicates
(
TABLE_NAME
,
predicates
)
rdbStore
.
update
(
valueBucket
,
rdbPredicates
,
function
(
err
,
resultSet
)
{
console
.
log
(
TAG
+
"
insert callback resultSet:
"
+
resultSet
+
"
,json=
"
+
JSON
.
stringify
(
resultSet
)
+
'
,err
'
+
err
)
callback
(
err
,
defaultReturn
);
})
},
delete
(
uri
,
predicates
,
callback
)
{
console
.
debug
(
TAG
+
'
delete start
'
)
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
let
rdbPredicates
=
dataAbility
.
createRdbPredicates
(
TABLE_NAME
,
predicates
)
rdbStore
.
delete
(
rdbPredicates
,
function
(
err
,
resultSet
)
{
console
.
log
(
TAG
+
"
insert callback resultSet:
"
+
resultSet
+
"
,json=
"
+
JSON
.
stringify
(
resultSet
)
+
'
,err
'
+
err
)
callback
(
err
,
defaultReturn
);
})
},
call
(
uri
,
method
,
arg
,
extras
,
callback
)
{
console
.
debug
(
TAG
+
'
call start
'
)
console
.
debug
(
TAG
+
'
uri---->
'
+
uri
)
console
.
debug
(
TAG
+
'
method---->
'
+
uri
)
},
batchInsert
(
uri
,
values
,
callback
)
{
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
for
(
var
j
=
0
;
j
<
values
.
length
;
j
++
)
{
rdbStore
.
insert
(
"
EMPLOYEE
"
,
values
[
j
],
function
(
err
,
ret
)
{
console
.
log
(
TAG
+
"
batchInsert callback ret:
"
+
JSON
.
stringify
(
ret
))
})
}
console
.
log
(
TAG
+
"
batchInsert values.length:
"
+
values
.
length
+
'
,json=
'
+
JSON
.
stringify
(
values
.
length
))
callback
(
err
,
values
.
length
);
},
openFile
(
uri
,
mode
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by openFile ================
'
);
let
defaultReturn
=
1
;
let
returnError1
=
-
1
;
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
returnError1
);
}
if
(
!
(
mode
==
(
"
r
"
)
||
mode
==
(
"
w
"
)
||
mode
==
(
"
wt
"
)
||
mode
==
(
"
wa
"
)
||
mode
==
(
"
rw
"
)
||
mode
==
(
"
rwt
"
)))
{
if
(
mode
==
(
"
A1@k#4%$,.<>)(oioiu*((*&(&*giIGT^%&^Ug;sdfk;losd*7873iug8%&^$&%]ERFUy&^%&&R7
"
))
{
defaultReturn
=
returnError2
;
}
else
defaultReturn
=
returnError3
;
}
console
.
info
(
TAG
+
"
path = /data/test
"
);
let
path
=
"
/data/test
"
fileio
.
stat
(
path
).
then
(
function
(
stat
)
{
console
.
info
(
TAG
+
"
openFile getFileInfo successfully callback ret:
"
+
JSON
.
stringify
(
stat
));
}).
catch
(
function
(
err
)
{
console
.
info
(
TAG
+
"
openFile getFileInfo failed with error callback ret:
"
+
err
);
defaultReturn
=
returnError1
;
});
console
.
info
(
TAG
+
"
path ==>
"
+
path
);
callback
(
"
success
"
,
defaultReturn
);
},
normalizeUri
(
uri
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by normalizeUri ================
'
);
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
""
);
}
callback
(
"
success
"
,
uri
);
},
denormalizeUri
(
uri
,
callback
)
{
console
.
info
(
TAG
+
'
==================== DataAbility test interface by denormalizeUri ================
'
);
console
.
info
(
TAG
+
"
denormalizeUri uri:
"
+
JSON
.
stringify
(
uri
));
let
err
=
"
Error Uri
"
if
(
uri
!=
dataAbilityUri
)
{
console
.
debug
(
TAG
+
'
uri != dataAbilityUri
'
)
callback
(
err
,
""
);
}
callback
(
"
success
"
,
uri
);
}
};
\ No newline at end of file
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/test/DataAbilityHelperJsStPermission.test.js
0 → 100644
浏览文件 @
f2e73260
/*
* 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-1.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
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohosDataAbility
from
'
@ohos.data.dataAbility
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
ActsDataAbilityHelperPermissionTest
()
{
describe
(
'
ActsDataAbilityHelperPermissionTest
'
,
function
()
{
let
dataAbilityUri
=
(
"
dataability:///com.example.myapplication.DataAbility3
"
);
let
DAHelper
;
beforeAll
(
async
(
done
)
=>
{
console
.
debug
(
'
= ACTS_beforeAll ====<begin
'
);
try
{
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
dataAbilityUri
);
console
.
debug
(
'
ACTS_beforeAll DAHelper ====>:
'
+
DAHelper
+
"
,JSON.
"
+
JSON
.
stringify
(
DAHelper
));
if
(
DAHelper
==
null
){
console
.
debug
(
'
ACTS_beforeAll DAHelper ====>: DAHelper == null
'
);
}
}
catch
(
err
)
{
console
.
error
(
'
=ACTS_beforeAll acquireDataAbilityHelper catch(err)====>:
'
+
err
);
}
console
.
debug
(
'
= ACTS_beforeAll ====<end
'
);
done
();
})
afterAll
((
done
)
=>
{
console
.
debug
(
'
= ACTS_afterAll ====<begin
'
);
console
.
debug
(
'
= ACTS_afterAll ====<end
'
);
done
();
})
/*
* @tc.number: ACTS_AcquireDataAbilityHelper_0100
* @tc.name: GetDataAbilityHelper : Connects an ability to a Service ability
* @tc.desc: Check the return value of the interface ()
*/
it
(
'
ACTS_AcquireDataAbilityHelper_0100
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
ACTS_AcquireDataAbilityHelper_0100====<begin
'
);
console
.
debug
(
"
=ACTS_AcquireDataAbilityHelper_0100 dataAbilityUri====>
"
+
dataAbilityUri
)
try
{
if
(
DAHelper
==
null
){
var
abilityHelper
=
featureAbility
.
acquireDataAbilityHelper
(
dataAbilityUri
)
console
.
log
(
'
ACTS_AcquireDataAbilityHelper_0100 abilityHelper ====>:
'
+
abilityHelper
+
"
,JSON.
"
+
JSON
.
stringify
(
abilityHelper
))
DAHelper
=
abilityHelper
;
}
expect
(
typeof
(
DAHelper
)).
assertEqual
(
"
object
"
);
}
catch
(
err
)
{
console
.
error
(
'
=ACTS_GetDataAbilityHelper_0100 acquireDataAbilityHelper catch(err)====>:
'
+
err
);
expect
(
false
).
assertTrue
();
}
expect
(
true
).
assertTrue
();
console
.
log
(
'
ACTS_AcquireDataAbilityHelper_0100====<end
'
)
done
();
})
/*
* @tc.number: ACTS_Insert_0100
* @tc.name: Insert : Indicates the path of the data to operate
* @tc.desc: Check the return value of the interface (by Promise)
*/
it
(
'
ACTS_Insert_0100
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
ACTS_Insert_0100====<begin
'
);
expect
(
typeof
(
DAHelper
)).
assertEqual
(
"
object
"
);
console
.
log
(
'
Insert_0100 DAHelper ====>:
'
+
DAHelper
)
let
valueBucketM
;
try
{
DAHelper
.
insert
(
dataAbilityUri
,
valueBucketM
)
.
then
(
function
(
data
)
{
console
.
debug
(
"
=ACTS_Insert_0100 then data====>
"
+
(
"
json data 【
"
)
+
JSON
.
stringify
(
data
)
+
(
"
】
"
));
expect
(
JSON
.
stringify
(
data
)).
assertEqual
(
"
-1
"
)
console
.
log
(
'
ACTS_Insert_0100====<end
'
);
done
();
}).
catch
(
function
(
err
)
{
console
.
debug
(
"
=ACTS_Insert_0100 catch err ====>
"
+
(
"
json err 【
"
)
+
JSON
.
stringify
(
err
)
+
(
"
】
"
));
expect
(
false
).
assertTrue
();
console
.
log
(
'
ACTS_Insert_0100====<end .catch
'
);
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
=ACTS_Insert_0100 catch(err)====>:
'
+
err
);
expect
(
false
).
assertTrue
();
console
.
log
(
'
ACTS_Insert_0100====<end catch
'
);
done
();
}
})
/*
* @tc.number: ACTS_BatchInsert_0100
* @tc.name: Inserts multiple data records into the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it
(
'
ACTS_BatchInsert_0100
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
ACTS_BatchInsert_0100====<begin
'
);
expect
(
typeof
(
DAHelper
)).
assertEqual
(
"
object
"
);
console
.
log
(
'
featureAbility BatchInsert getDataAbilityHelper ====>:
'
+
DAHelper
)
var
valueBucketM
;
try
{
DAHelper
.
batchInsert
(
dataAbilityUri
,
valueBucketM
).
then
((
data
)
=>
{
console
.
debug
(
"
=ACTS_BatchInsert_0100 then data====>
"
+
(
"
json data 【
"
)
+
JSON
.
stringify
(
data
)
+
(
"
】; ====>
"
));
expect
(
JSON
.
stringify
(
data
)).
assertEqual
(
"
-1
"
)
console
.
log
(
'
ACTS_BatchInsert_0100====<end
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
debug
(
"
=ACTS_BatchInsert_0100 catch err ====>
"
+
(
"
json err 【
"
)
+
JSON
.
stringify
(
err
)
+
(
"
】
"
));
console
.
log
(
'
ACTS_BatchInsert_0100====<end .catch
'
);
expect
(
false
).
assertTrue
();
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
=ACTS_BatchInsert_0100 catch(err)====>:
'
+
err
);
console
.
log
(
'
ACTS_BatchInsert_0100====<end catch
'
);
expect
(
false
).
assertTrue
();
done
();
}
})
/*
* @tc.number: ACTS_Query_0100
* @tc.name: Queries one or more data records in the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it
(
'
ACTS_Query_0100
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
ACTS_Query_0100====<begin
'
);
expect
(
typeof
(
DAHelper
)).
assertEqual
(
"
object
"
);
var
columnsArray
=
new
Array
(
""
);
try
{
let
predicates
=
new
ohosDataAbility
.
DataAbilityPredicates
();
DAHelper
.
query
(
dataAbilityUri
,
columnsArray
,
predicates
).
then
((
data
)
=>
{
console
.
debug
(
"
=ACTS_Query_0100 then data====>
"
+
(
"
json data 【
"
)
+
JSON
.
stringify
(
data
)
+
(
"
】
"
));
expect
(
data
).
assertEqual
(
null
);
console
.
log
(
'
ACTS_Query_0100====<end
'
);
done
();
}).
catch
(
err
=>
{
console
.
debug
(
"
=ACTS_Query_0100 catch err ====>
"
+
(
"
json err 【
"
)
+
JSON
.
stringify
(
err
)
+
(
"
】
"
));
console
.
log
(
'
ACTS_Query_0100====<end .catch
'
);
expect
(
false
).
assertTrue
();
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
=ACTS_Query_0100 catch(err)====>:
'
+
err
);
console
.
log
(
'
ACTS_Query_0100====<end catch
'
);
expect
(
false
).
assertTrue
();
done
();
}
})
/*
* @tc.number: ACTS_Update_0100
* @tc.name: Updates one or more data records in the database.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it
(
'
ACTS_Update_0100
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
ACTS_Update_0100====<begin
'
);
expect
(
typeof
(
DAHelper
)).
assertEqual
(
"
object
"
);
console
.
log
(
'
featureAbility Update getDataAbilityHelper ====>:
'
+
DAHelper
)
try
{
let
valueBucketNull
=
{};
let
predicates
=
new
ohosDataAbility
.
DataAbilityPredicates
();
console
.
debug
(
"
=ACTS_Update_0100 predicates====>
"
+
(
"
json predicates 【
"
)
+
JSON
.
stringify
(
predicates
)
+
(
"
】
"
)
+
"
,
"
+
predicates
);
DAHelper
.
update
(
dataAbilityUri
,
valueBucketNull
,
predicates
).
then
((
data
)
=>
{
console
.
debug
(
"
=ACTS_Update_0100 then data====>
"
+
(
"
json data 【
"
)
+
JSON
.
stringify
(
data
)
+
(
"
】
"
));
expect
(
JSON
.
stringify
(
data
)).
assertEqual
(
"
-1
"
)
console
.
log
(
'
ACTS_Update_0100====<end
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
debug
(
"
=ACTS_Update_0100 catch err ====>
"
+
(
"
json err 【
"
)
+
JSON
.
stringify
(
err
)
+
(
"
】
"
));
expect
(
false
).
assertTrue
();
console
.
log
(
'
ACTS_Update_0100====<end .catch
'
);
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
=ACTS_Update_0100 catch(err)====>:
'
+
err
);
expect
(
false
).
assertTrue
();
console
.
log
(
'
ACTS_Update_0100====<end catch
'
);
done
();
}
})
/*
* @tc.number: ACTS_Delete_0100
* @tc.name: Deletes one or more data records. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it
(
'
ACTS_Delete_0100
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
ACTS_Delete_0100====<begin
'
);
expect
(
typeof
(
DAHelper
)).
assertEqual
(
"
object
"
);
console
.
log
(
'
featureAbility getDataAbilityHelper ====>:
'
+
DAHelper
);
try
{
let
predicates
=
new
ohosDataAbility
.
DataAbilityPredicates
();
console
.
debug
(
"
=ACTS_Delete_0100 predicates====>
"
+
(
"
json predicates 【
"
)
+
JSON
.
stringify
(
predicates
)
+
(
"
】
"
)
+
"
,
"
+
predicates
);
DAHelper
.
delete
(
dataAbilityUri
,
predicates
).
then
((
data
)
=>
{
console
.
debug
(
"
=ACTS_Delete_0100 then data====>
"
+
(
"
json data 【
"
)
+
JSON
.
stringify
(
data
)
+
(
"
】
"
));
expect
(
JSON
.
stringify
(
data
)).
assertEqual
(
"
-1
"
)
console
.
log
(
'
ACTS_Delete_0100====<end
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
debug
(
"
=ACTS_Delete_0100 catch err ====>
"
+
(
"
json err 【
"
)
+
JSON
.
stringify
(
err
)
+
(
"
】
"
));
expect
(
false
).
assertTrue
();
console
.
log
(
'
ACTS_Delete_0100====<end .catch
'
);
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
=ACTS_Delete_0100 catch(err)====>:
'
+
err
);
expect
(
false
).
assertTrue
();
console
.
log
(
'
ACTS_Delete_0100====<end catch
'
);
done
();
}
})
/*
* @tc.number: ACTS_OpenFile_0100
* @tc.name: Opens a file. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by promise)
*/
it
(
'
ACTS_OpenFile_0100
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
ACTS_OpenFile_0100====<begin
'
);
var
mode
=
"
r
"
;
try
{
DAHelper
.
openFile
(
dataAbilityUri
,
mode
,
).
then
((
data
)
=>
{
console
.
debug
(
"
=ACTS_OpenFile_0100 then data====>
"
+
(
"
json data 【
"
)
+
JSON
.
stringify
(
data
)
+
(
"
】
"
));
expect
(
JSON
.
stringify
(
data
)).
assertEqual
(
"
-1
"
)
done
();
}).
catch
(
err
=>
{
console
.
debug
(
"
=ACTS_OpenFile_0100 catch err ====>
"
+
(
"
json err 【
"
)
+
JSON
.
stringify
(
err
)
+
(
"
】
"
));
expect
(
false
).
assertTrue
();
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
=ACTS_OpenFile_0100 getType catch(err)====>:
'
+
err
);
expect
(
false
).
assertTrue
();
done
();
}
})
/*
* @tc.number: ACTS_NormalizeUri_0100
* @tc.name: Converts the given uri that refer to the Data ability into a normalized URI.
* @tc.desc: Check the return value of the interface (by promise)
*/
it
(
'
ACTS_NormalizeUri_0100
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
ACTS_NormalizeUri_0100====<begin
'
);
let
ret
=
false
;
expect
(
typeof
(
DAHelper
)).
assertEqual
(
"
object
"
);
console
.
log
(
'
featureAbility normalizeUri getDataAbilityHelper ====>:
'
+
DAHelper
);
try
{
DAHelper
.
normalizeUri
(
dataAbilityUri
,
).
then
((
data
)
=>
{
console
.
debug
(
"
=ACTS_NormalizeUri_0100 then data====>
"
+
(
"
json data 【
"
)
+
JSON
.
stringify
(
data
)
+
(
"
】
"
));
expect
(
data
.
length
).
assertEqual
(
0
);
console
.
log
(
'
ACTS_NormalizeUri_0100====<end
'
);
done
();
}).
catch
(
err
=>
{
console
.
debug
(
"
=ACTS_NormalizeUri_0100 catch err ====>
"
+
(
"
json err 【
"
)
+
JSON
.
stringify
(
err
)
+
(
"
】
"
));
console
.
log
(
'
ACTS_NormalizeUri_0100====<end .catch
'
);
expect
(
false
).
assertTrue
();
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
=ACTS_NormalizeUri_0100 normalizeUri promise catch(err)====>:
'
+
err
);
console
.
log
(
'
ACTS_NormalizeUri_0100====<end catch
'
);
expect
(
false
).
assertTrue
();
done
();
}
})
/*
* @tc.number: ACTS_DenormalizeUri_0100
* @tc.name: Converts the given normalized uri generated by normalizeUri into a denormalized one.
* @tc.desc: Check the return value of the interface (by promise)
*/
it
(
'
ACTS_DenormalizeUri_0100
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
ACTS_DenormalizeUri_0100====<begin
'
);
let
ret
=
false
;
expect
(
typeof
(
DAHelper
)).
assertEqual
(
"
object
"
);
console
.
log
(
'
featureAbility DenormalizeUri getDataAbilityHelper ====>:
'
+
DAHelper
);
try
{
DAHelper
.
denormalizeUri
(
dataAbilityUri
,
).
then
((
data
)
=>
{
console
.
debug
(
"
=ACTS_DenormalizeUri_0100 then data====>
"
+
(
"
json data 【
"
)
+
JSON
.
stringify
(
data
)
+
(
"
】
"
));
expect
(
data
.
length
).
assertEqual
(
0
);
console
.
log
(
'
ACTS_DenormalizeUri_0100====<end
'
);
done
();
}).
catch
(
err
=>
{
console
.
debug
(
"
=ACTS_DenormalizeUri_0100 catch err ====>
"
+
(
"
json err 【
"
)
+
JSON
.
stringify
(
err
)
+
(
"
】
"
));
console
.
log
(
'
ACTS_DenormalizeUri_0100====<end .catch
'
);
expect
(
false
).
assertTrue
();
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
=ACTS_DenormalizeUri_0100 denormalizeUri promise catch(err)====>:
'
+
err
);
console
.
log
(
'
ACTS_DenormalizeUri_0100====<end catch
'
);
expect
(
false
).
assertTrue
();
done
();
}
})
})}
\ No newline at end of file
ability/ability_runtime/actsfwkdataaccessortest/actsfwkdataaccessortest/src/main/js/test/List.test.js
浏览文件 @
f2e73260
...
...
@@ -13,6 +13,8 @@
* limitations under the License.
*/
import
ActsDataAbilityHelperTest
from
'
./DataAbilityHelperJsSt.test.js
'
import
ActsDataAbilityHelperPermissionTest
from
'
./DataAbilityHelperJsStPermission.test.js
'
export
default
function
testsuite
()
{
ActsDataAbilityHelperTest
()
ActsDataAbilityHelperPermissionTest
()
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录