Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
553cad03
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看板
提交
553cad03
编写于
8月 18, 2021
作者:
O
openharmony_ci
提交者:
Gitee
8月 18, 2021
浏览文件
操作
浏览文件
下载
差异文件
!432 add distributeddatamgr js unit test.
Merge pull request !432 from yangzhouwei/master
上级
bb1383f2
0dd9ab1f
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
1133 addition
and
0 deletion
+1133
-0
distributeddatamgr/BUILD.gn
distributeddatamgr/BUILD.gn
+1
-0
distributeddatamgr/distributeddatamgrjstest/hap/BUILD.gn
distributeddatamgr/distributeddatamgrjstest/hap/BUILD.gn
+18
-0
distributeddatamgr/distributeddatamgrjstest/hap/Test.json
distributeddatamgr/distributeddatamgrjstest/hap/Test.json
+19
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry-test-signed.hap
...atamgr/distributeddatamgrjstest/hap/entry-test-signed.hap
+0
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry/package.json
...eddatamgr/distributeddatamgrjstest/hap/entry/package.json
+1
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/config.json
...r/distributeddatamgrjstest/hap/entry/src/main/config.json
+57
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/app.js
...ributeddatamgrjstest/hap/entry/src/main/js/default/app.js
+22
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/i18n/en-US.json
...tamgrjstest/hap/entry/src/main/js/default/i18n/en-US.json
+8
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/i18n/zh-CN.json
...tamgrjstest/hap/entry/src/main/js/default/i18n/zh-CN.json
+8
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.css
...stest/hap/entry/src/main/js/default/pages/index/index.css
+23
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.hml
...stest/hap/entry/src/main/js/default/pages/index/index.hml
+5
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.js
...jstest/hap/entry/src/main/js/default/pages/index/index.js
+33
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/List.test.js
...uteddatamgrjstest/hap/entry/src/main/js/test/List.test.js
+2
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/SingleKvStoreCallbackJsunit.test.js
...ntry/src/main/js/test/SingleKvStoreCallbackJsunit.test.js
+328
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/SingleKvStorePromiseJsunit.test.js
...entry/src/main/js/test/SingleKvStorePromiseJsunit.test.js
+596
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/resources/base/element/string.json
...est/hap/entry/src/main/resources/base/element/string.json
+12
-0
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/resources/base/media/icon.png
...grjstest/hap/entry/src/main/resources/base/media/icon.png
+0
-0
未找到文件。
distributeddatamgr/BUILD.gn
浏览文件 @
553cad03
...
@@ -17,6 +17,7 @@ group("distributeddatamgr") {
...
@@ -17,6 +17,7 @@ group("distributeddatamgr") {
if (is_standard_system) {
if (is_standard_system) {
deps = [
deps = [
"appdatamgrjstest/hap:appdatamgr_js_test",
"appdatamgrjstest/hap:appdatamgr_js_test",
"distributeddatamgrjstest/hap:distributeddatamgr_js_test",
"distributedfilejstest:distributedfile_js_test",
"distributedfilejstest:distributedfile_js_test",
]
]
} else {
} else {
...
...
distributeddatamgr/distributeddatamgrjstest/hap/BUILD.gn
0 → 100644
浏览文件 @
553cad03
# Copyright (C) 2021 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("distributeddatamgr_js_test") {
test_hap_name = "DistributeddatamgrJsTest"
hap_source_path = "entry-test-signed.hap"
}
distributeddatamgr/distributeddatamgrjstest/hap/Test.json
0 → 100644
浏览文件 @
553cad03
{
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"21600000"
,
"package"
:
"ohos.acts.distributeddatamgr"
,
"abilityName"
:
"decc.testkit.runner.JsEntryAbility"
,
"shell-timeout"
:
"21600000"
},
"kits"
:
[
{
"test-file-name"
:
[
"DistributeddatamgrJsTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
}
]
}
distributeddatamgr/distributeddatamgrjstest/hap/entry-test-signed.hap
0 → 100644
浏览文件 @
553cad03
文件已添加
distributeddatamgr/distributeddatamgrjstest/hap/entry/package.json
0 → 100644
浏览文件 @
553cad03
{}
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/config.json
0 → 100644
浏览文件 @
553cad03
{
"app"
:
{
"bundleName"
:
"ohos.acts.distributeddatamgr"
,
"vendor"
:
"example"
,
"version"
:
{
"code"
:
1000000
,
"name"
:
"1.0.0"
}
},
"deviceConfig"
:
{},
"module"
:
{
"package"
:
"ohos.acts.distributeddatamgr"
,
"name"
:
".MyApplication"
,
"mainAbility"
:
"ohos.acts.distributeddatamgr.MainAbility"
,
"deviceType"
:
[
"phone"
],
"distro"
:
{
"deliveryWithInstall"
:
true
,
"moduleName"
:
"entry"
,
"moduleType"
:
"entry"
,
"installationFree"
:
false
},
"abilities"
:
[
{
"skills"
:
[
{
"entities"
:
[
"entity.system.home"
],
"actions"
:
[
"action.system.home"
]
}
],
"name"
:
"ohos.acts.distributeddatamgr.MainAbility"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:mainability_description"
,
"label"
:
"$string:app_name"
,
"type"
:
"page"
,
"launchType"
:
"standard"
}
],
"js"
:
[
{
"pages"
:
[
"pages/index/index"
],
"name"
:
"default"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
true
}
}
]
}
}
\ No newline at end of file
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/app.js
0 → 100644
浏览文件 @
553cad03
/*
* Copyright (c) 2021 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.
*/
export
default
{
onCreate
()
{
console
.
info
(
'
TestApplication onCreate
'
);
},
onDestroy
()
{
console
.
info
(
'
TestApplication onDestroy
'
);
}
};
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/i18n/en-US.json
0 → 100644
浏览文件 @
553cad03
{
"strings"
:
{
"hello"
:
"Hello"
,
"world"
:
"World"
},
"Files"
:
{
}
}
\ No newline at end of file
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/i18n/zh-CN.json
0 → 100644
浏览文件 @
553cad03
{
"strings"
:
{
"hello"
:
"您好"
,
"world"
:
"世界"
},
"Files"
:
{
}
}
\ No newline at end of file
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.css
0 → 100644
浏览文件 @
553cad03
/*
* Copyright (c) 2021 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.
*/
.container
{
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
}
.title
{
font-size
:
100px
;
}
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.hml
0 → 100644
浏览文件 @
553cad03
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{title}}
</text>
</div>
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/default/pages/index/index.js
0 → 100644
浏览文件 @
553cad03
/*
* Copyright (c) 2021 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
{
Core
}
from
'
deccjsunit/index
'
export
default
{
data
:
{
title
:
""
},
onInit
()
{
this
.
title
=
this
.
$t
(
'
strings.world
'
);
},
onShow
()
{
console
.
info
(
'
onShow finish
'
)
const
core
=
Core
.
getInstance
()
core
.
init
()
require
(
'
../../../test/List.test
'
)
core
.
execute
()
},
onReady
()
{
},
}
\ No newline at end of file
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/List.test.js
0 → 100644
浏览文件 @
553cad03
require
(
'
./SingleKvStorePromiseJsunit.test.js
'
)
require
(
'
./SingleKvStoreCallbackJsunit.test.js
'
)
\ No newline at end of file
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/SingleKvStoreCallbackJsunit.test.js
0 → 100644
浏览文件 @
553cad03
/*
* Copyright (c) 2021 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
'
deccjsunit/index
'
import
factory
from
'
@ohos.data.distributeddata
'
const
KEY_TEST_INT_ELEMENT
=
'
key_test_int_2
'
;
const
KEY_TEST_FLOAT_ELEMENT
=
'
key_test_float_2
'
;
const
KEY_TEST_BOOLEAN_ELEMENT
=
'
key_test_boolean_2
'
;
const
KEY_TEST_STRING_ELEMENT
=
'
key_test_string_2
'
;
const
VALUE_TEST_INT_ELEMENT
=
1234
;
const
VALUE_TEST_FLOAT_ELEMENT
=
4321.12
;
const
VALUE_TEST_BOOLEAN_ELEMENT
=
true
;
const
VALUE_TEST_STRING_ELEMENT
=
'
value-string-002
'
;
const
SINGLE_VERSION
=
1
;
const
SECURITY_LEVEL
=
3
;
var
kvManager
=
null
;
var
kvStore
=
null
;
describe
(
'
KvStoreTest
'
,
function
()
{
const
config
=
{
bundleName
:
'
ohos.acts.distributeddatamgr
'
,
userInfo
:
{
userId
:
'
0
'
,
userType
:
0
}
}
const
options
=
{
createIfMissing
:
true
,
encrypt
:
false
,
backup
:
false
,
autoSync
:
true
,
kvStoreType
:
SINGLE_VERSION
,
schema
:
''
,
securityLevel
:
SECURITY_LEVEL
,
}
it
(
'
testCreateKVManager102
'
,
0
,
async
function
(
done
)
{
try
{
await
factory
.
createKVManager
(
null
,
function
(
err
,
manager
)
{
kvManager
=
manager
;
expect
(
false
).
assertEqual
(
manager
==
null
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testCreateKVManager103
'
,
0
,
async
function
(
done
)
{
try
{
await
factory
.
createKVManager
(
''
,
function
(
err
,
manager
)
{
kvManager
=
manager
;
expect
(
false
).
assertEqual
(
manager
==
null
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testCreateKVManager101
'
,
0
,
async
function
(
done
)
{
try
{
await
factory
.
createKVManager
(
config
,
function
(
err
,
manager
)
{
kvManager
=
manager
;
expect
(
false
).
assertEqual
(
manager
==
null
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testGetKVStore101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvManager
.
getKVStore
(
options
,
function
(
err
,
store
)
{
kvStore
=
store
;
expect
(
false
).
assertEqual
(
store
==
null
);
});
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
}
done
();
})
it
(
'
testGetKVStore101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvManager
.
getKVStore
(
'
storeId
'
,
options
,
function
(
err
,
store
)
{
kvStore
=
store
;
expect
(
false
).
assertEqual
(
store
==
null
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutString101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
,
VALUE_TEST_STRING_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testGetString101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvStore
.
get
(
KEY_TEST_STRING_ELEMENT
,
function
(
err
,
data
)
{
expect
(
VALUE_TEST_STRING_ELEMENT
).
assertEqual
(
data
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutString102
'
,
0
,
async
function
(
done
)
{
try
{
var
str
=
''
;
for
(
var
i
=
0
;
i
<
4095
;
i
++
)
{
str
+=
'
x
'
;
}
await
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
+
'
102
'
,
str
,
function
(
err
,
data
)
{
kvStore
.
get
(
KEY_TEST_STRING_ELEMENT
+
'
102
'
,
function
(
err
,
data
)
{
expect
(
str
).
assertEqual
(
data
);
});
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutInt101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
,
VALUE_TEST_INT_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testGetInt101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvStore
.
get
(
KEY_TEST_INT_ELEMENT
,
function
(
err
,
data
)
{
expect
(
VALUE_TEST_INT_ELEMENT
).
assertEqual
(
data
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutBoolean101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvStore
.
put
(
KEY_TEST_BOOLEAN_ELEMENT
,
VALUE_TEST_BOOLEAN_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testGetBoolean101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvStore
.
get
(
KEY_TEST_BOOLEAN_ELEMENT
,
function
(
err
,
data
)
{
expect
(
VALUE_TEST_BOOLEAN_ELEMENT
).
assertEqual
(
data
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutFloat101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
,
VALUE_TEST_FLOAT_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testGetFloat101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvStore
.
get
(
KEY_TEST_FLOAT_ELEMENT
,
function
(
err
,
data
)
{
expect
(
VALUE_TEST_FLOAT_ELEMENT
).
assertEqual
(
data
);
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testDeleteString101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvStore
.
delete
(
KEY_TEST_STRING_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testDeleteInt101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvStore
.
delete
(
KEY_TEST_INT_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testDeleteFloat101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvStore
.
delete
(
KEY_TEST_FLOAT_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testDeleteBoolean101
'
,
0
,
async
function
(
done
)
{
try
{
await
kvStore
.
delete
(
KEY_TEST_BOOLEAN_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
});
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testOnChange100
'
,
0
,
async
function
(
done
)
{
try
{
kvStore
.
on
(
'
dataChange
'
,
0
,
function
(
data
)
{
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
,
VALUE_TEST_FLOAT_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testOnChange101
'
,
0
,
async
function
(
done
)
{
try
{
kvStore
.
on
(
'
dataChange
'
,
1
,
function
(
data
)
{
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
,
VALUE_TEST_FLOAT_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testOnChange102
'
,
0
,
async
function
(
done
)
{
try
{
kvStore
.
on
(
'
dataChange
'
,
2
,
function
(
data
)
{
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
+
'
102
'
,
VALUE_TEST_FLOAT_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
})
\ No newline at end of file
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/js/test/SingleKvStorePromiseJsunit.test.js
0 → 100644
浏览文件 @
553cad03
/*
* Copyright (c) 2021 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
'
deccjsunit/index
'
import
factory
from
'
@ohos.data.distributeddata
'
const
KEY_TEST_INT_ELEMENT
=
'
key_test_int
'
;
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
VALUE_TEST_INT_ELEMENT
=
123
;
const
VALUE_TEST_FLOAT_ELEMENT
=
321.12
;
const
VALUE_TEST_BOOLEAN_ELEMENT
=
true
;
const
VALUE_TEST_STRING_ELEMENT
=
'
value-string-001
'
;
const
SINGLE_VERSION
=
1
;
const
SECURITY_LEVEL
=
3
;
var
kvManager
=
null
;
var
kvStore
=
null
;
describe
(
'
KvStoreTest
'
,
function
()
{
const
config
=
{
bundleName
:
'
ohos.acts.distributeddatamgr
'
,
userInfo
:
{
userId
:
'
0
'
,
userType
:
0
}
}
const
options
=
{
createIfMissing
:
true
,
encrypt
:
false
,
backup
:
false
,
autoSync
:
true
,
kvStoreType
:
SINGLE_VERSION
,
schema
:
''
,
securityLevel
:
SECURITY_LEVEL
,
}
it
(
'
testCreateKVManager001
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
factory
.
createKVManager
(
config
);
promise
.
then
((
manager
)
=>
{
kvManager
=
manager
;
expect
(
false
).
assertEqual
(
manager
==
null
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testGetKVStore001
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvManager
.
getKVStore
(
options
);
promise
.
then
((
store
)
=>
{
kvStore
=
store
;
expect
(
false
).
assertEqual
(
store
==
null
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
expect
(
null
).
assertFail
();
await
promise
;
}
catch
(
e
)
{
}
done
();
})
it
(
'
testGetKVStore001
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvManager
.
getKVStore
(
'
storeId
'
,
options
);
promise
.
then
((
store
)
=>
{
kvStore
=
store
;
expect
(
false
).
assertEqual
(
store
==
null
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutString003
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
,
null
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutString004
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
,
''
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutString0051
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
,
VALUE_TEST_STRING_ELEMENT
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testGetString001
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvStore
.
get
(
KEY_TEST_STRING_ELEMENT
);
promise
.
then
((
data
)
=>
{
expect
(
VALUE_TEST_STRING_ELEMENT
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
}
catch
(
e
){
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutString0021
'
,
0
,
async
function
(
done
)
{
try
{
var
str
=
''
;
for
(
var
i
=
0
;
i
<
4095
;
i
++
)
{
str
+=
'
x
'
;
}
const
promise
=
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
+
'
002
'
,
str
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_STRING_ELEMENT
+
'
002
'
);
promise1
.
then
((
data
)
=>
{
expect
(
str
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise1
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutString005
'
,
0
,
async
function
(
done
)
{
try
{
const
promise1
=
kvStore
.
get
(
KEY_TEST_STRING_ELEMENT
+
'
005
'
);
promise1
.
then
((
data
)
=>
{
expect
(
null
).
assertFail
();
}).
catch
((
err
)
=>
{
});
await
promise1
;
}
catch
(
e
)
{
}
done
();
})
it
(
'
testPutInt001
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
,
VALUE_TEST_INT_ELEMENT
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testGetInt001
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
001
'
,
VALUE_TEST_INT_ELEMENT
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_INT_ELEMENT
+
'
001
'
);
promise1
.
then
((
data
)
=>
{
expect
(
VALUE_TEST_INT_ELEMENT
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise1
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutInt002
'
,
0
,
async
function
(
done
)
{
try
{
var
intValue
=
987654321
;
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
002
'
,
intValue
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_INT_ELEMENT
+
'
002
'
);
promise1
.
then
((
data
)
=>
{
expect
(
intValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise1
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutInt003
'
,
0
,
async
function
(
done
)
{
try
{
var
intValue
=
Number
.
MAX_VALUE
;
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
003
'
,
intValue
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_INT_ELEMENT
+
'
003
'
);
promise1
.
then
((
data
)
=>
{
expect
(
intValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise1
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutInt004
'
,
0
,
async
function
(
done
)
{
try
{
var
intValue
=
Number
.
MIN_VALUE
;
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
004
'
,
intValue
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_INT_ELEMENT
+
'
004
'
);
promise1
.
then
((
data
)
=>
{
expect
(
intValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise1
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testPutBoolean001
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvStore
.
put
(
KEY_TEST_BOOLEAN_ELEMENT
,
VALUE_TEST_BOOLEAN_ELEMENT
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testGetBoolean002
'
,
0
,
async
function
(
done
)
{
var
boolValue
=
false
;
const
promise
=
kvStore
.
put
(
KEY_TEST_BOOLEAN_ELEMENT
+
'
002
'
,
boolValue
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_BOOLEAN_ELEMENT
+
'
002
'
);
promise1
.
then
((
data
)
=>
{
expect
(
boolValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise1
;
done
();
})
it
(
'
testPutFloat001
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
,
VALUE_TEST_FLOAT_ELEMENT
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testGetFloat002
'
,
0
,
async
function
(
done
)
{
try
{
var
floatValue
=
123456.654321
;
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
,
floatValue
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
);
promise1
.
then
((
data
)
=>
{
expect
(
floatValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise1
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testGetFloat003
'
,
0
,
async
function
(
done
)
{
try
{
var
floatValue
=
123456.0
;
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
+
'
003
'
,
floatValue
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_FLOAT_ELEMENT
+
'
003
'
);
promise1
.
then
((
data
)
=>
{
expect
(
floatValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise1
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testGetFloat004
'
,
0
,
async
function
(
done
)
{
try
{
var
floatValue
=
123456.00
;
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
+
'
004
'
,
floatValue
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_FLOAT_ELEMENT
+
'
004
'
);
promise1
.
then
((
data
)
=>
{
expect
(
floatValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise1
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testDeleteString001
'
,
0
,
async
function
(
done
)
{
try
{
var
str
=
'
this is a test string
'
;
const
promise
=
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
+
'
003
'
,
str
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
delete
(
KEY_TEST_STRING_ELEMENT
+
'
003
'
);
promise1
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise1
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testDeleteString002
'
,
0
,
async
function
(
done
)
{
try
{
var
str
=
''
;
for
(
var
i
=
0
;
i
<
4096
;
i
++
)
{
str
+=
'
x
'
;
}
const
promise
=
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
+
'
003
'
,
str
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
delete
(
KEY_TEST_STRING_ELEMENT
+
'
003
'
);
promise1
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise1
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testDeleteString003
'
,
0
,
async
function
(
done
)
{
try
{
const
promise1
=
kvStore
.
delete
(
KEY_TEST_STRING_ELEMENT
+
'
unkonwn
'
);
promise1
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise1
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testDeleteInt001
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvStore
.
delete
(
KEY_TEST_INT_ELEMENT
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testDeleteFloat001
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvStore
.
delete
(
KEY_TEST_FLOAT_ELEMENT
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testDeleteFloat002
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
,
VALUE_TEST_FLOAT_ELEMENT
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
delete
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
);
promise1
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise1
;
const
promise2
=
kvStore
.
delete
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
);
promise2
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise2
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testDeleteBoolean001
'
,
0
,
async
function
(
done
)
{
try
{
const
promise
=
kvStore
.
delete
(
KEY_TEST_BOOLEAN_ELEMENT
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testOnChange001
'
,
0
,
async
function
(
done
)
{
try
{
kvStore
.
on
(
'
dataChange
'
,
0
,
function
(
data
)
{
console
.
log
(
'
testOnChange001 0
'
+
data
)
expect
(
true
).
assertEqual
(
data
!=
null
);
});
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
,
VALUE_TEST_FLOAT_ELEMENT
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testOnChange002
'
,
0
,
async
function
(
done
)
{
try
{
kvStore
.
on
(
'
dataChange
'
,
1
,
function
(
data
)
{
//remote
console
.
log
(
'
testOnChange001 1
'
+
data
)
expect
(
true
).
assertEqual
(
data
!=
null
);
});
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
002
'
,
VALUE_TEST_INT_ELEMENT
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testOnChange003
'
,
0
,
async
function
(
done
)
{
try
{
kvStore
.
on
(
'
dataChange
'
,
2
,
function
(
data
)
{
console
.
log
(
'
testOnChange001 2
'
+
data
)
expect
(
true
).
assertEqual
(
data
!=
null
);
});
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
003
'
,
VALUE_TEST_INT_ELEMENT
);
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
})
\ No newline at end of file
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/resources/base/element/string.json
0 → 100644
浏览文件 @
553cad03
{
"string"
:
[
{
"name"
:
"app_name"
,
"value"
:
"DistributeddatamgrJsTest"
},
{
"name"
:
"mainability_description"
,
"value"
:
"hap sample empty page"
}
]
}
distributeddatamgr/distributeddatamgrjstest/hap/entry/src/main/resources/base/media/icon.png
0 → 100644
浏览文件 @
553cad03
6.6 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录