Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
f24488d1
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看板
未验证
提交
f24488d1
编写于
1月 10, 2022
作者:
O
openharmony_ci
提交者:
Gitee
1月 10, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1515 js api8 testcase update.
Merge pull request !1515 from xsterling/master
上级
d216ca15
846c5141
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
515 addition
and
271 deletion
+515
-271
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStoreCallbackJsunit.test.js
.../main/js/default/test/DeviceKvStoreCallbackJsunit.test.js
+46
-33
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStorePromiseJsunit.test.js
...c/main/js/default/test/DeviceKvStorePromiseJsunit.test.js
+35
-17
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/FieldNodeJsunit.test.js
...test/hap/src/main/js/default/test/FieldNodeJsunit.test.js
+0
-3
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerCallbackJsunit.test.js
.../src/main/js/default/test/KvManagerCallbackJsunit.test.js
+13
-5
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerPromiseJsunit.test.js
...p/src/main/js/default/test/KvManagerPromiseJsunit.test.js
+10
-3
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvStoreResultSetJsunit.test.js
...p/src/main/js/default/test/KvStoreResultSetJsunit.test.js
+6
-5
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/QueryJsunit.test.js
...grjstest/hap/src/main/js/default/test/QueryJsunit.test.js
+324
-169
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SchemaJsunit.test.js
...rjstest/hap/src/main/js/default/test/SchemaJsunit.test.js
+22
-1
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStoreCallbackJsunit.test.js
.../main/js/default/test/SingleKvStoreCallbackJsunit.test.js
+30
-17
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStoreEnumJsunit.test.js
.../src/main/js/default/test/SingleKvStoreEnumJsunit.test.js
+1
-5
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStorePromiseJsunit.test.js
...c/main/js/default/test/SingleKvStorePromiseJsunit.test.js
+28
-13
未找到文件。
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStoreCallbackJsunit.test.js
浏览文件 @
f24488d1
...
...
@@ -32,6 +32,9 @@ const TEST_STORE_ID = 'storeId';
var
kvManager
=
null
;
var
kvStore
=
null
;
var
localDeviceId
=
null
;
const
USED_DEVICE_IDS
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
const
UNUSED_DEVICE_IDS
=
[];
/* add you test device-ids here */
var
syncDeviceIds
=
USED_DEVICE_IDS
.
concat
(
UNUSED_DEVICE_IDS
);
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
...
...
@@ -137,6 +140,7 @@ describe('DeviceKvStoreCallbackTest', function () {
done
();
});
});
kvStore
=
null
;
})
/**
...
...
@@ -851,22 +855,25 @@ describe('DeviceKvStoreCallbackTest', function () {
console
.
log
(
'
testDeviceKvStoreOnSyncComplete101 dataChange
'
);
expect
(
data
!=
null
).
assertTrue
();
});
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync101
'
,
VALUE_TEST_SYNC_ELEMENT
,
function
(
err
,
data
)
{
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync101
'
,
VALUE_TEST_SYNC_ELEMENT
).
then
((
data
)
=>
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete101 put success
'
);
expect
(
err
==
undefined
).
assertTrue
();
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
factory
.
SyncMode
.
PULL_ONLY
;
try
{
kvStore
.
sync
(
devices
,
mode
);
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete101 sync no peer device :e:
'
+
e
);
}
done
();
expect
(
data
==
undefined
).
assertTrue
();
}).
catch
((
error
)
=>
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete101 put failed:
'
+
e
);
expect
(
null
).
assertFail
();
});
try
{
var
mode
=
factory
.
SyncMode
.
PULL_ONLY
;
console
.
log
(
'
kvStore.sync to
'
+
JSON
.
stringify
(
syncDeviceIds
));
kvStore
.
sync
(
syncDeviceIds
,
mode
);
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete101 sync no peer device :e:
'
+
e
);
}
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete101 no peer device :e:
'
+
e
);
done
();
expect
(
null
).
assertFail
();
}
done
();
})
/**
...
...
@@ -880,22 +887,25 @@ describe('DeviceKvStoreCallbackTest', function () {
console
.
log
(
'
testDeviceKvStoreOnSyncComplete102 dataChange
'
);
expect
(
data
!=
null
).
assertTrue
();
});
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync101
'
,
VALUE_TEST_SYNC_ELEMENT
,
function
(
err
,
data
)
{
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync101
'
,
VALUE_TEST_SYNC_ELEMENT
).
then
((
data
)
=>
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete102 put success
'
);
expect
(
err
==
undefined
).
assertTrue
();
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
factory
.
SyncMode
.
PUSH_ONLY
;
try
{
kvStore
.
sync
(
devices
,
mode
);
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete101 sync no peer device :e:
'
+
e
);
}
done
();
expect
(
data
==
undefined
).
assertTrue
();
}).
catch
((
error
)
=>
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete102 put failed:
'
+
e
);
expect
(
null
).
assertFail
();
});
try
{
var
mode
=
factory
.
SyncMode
.
PUSH_ONLY
;
console
.
log
(
'
kvStore.sync to
'
+
JSON
.
stringify
(
syncDeviceIds
));
kvStore
.
sync
(
syncDeviceIds
,
mode
);
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete102 sync no peer device :e:
'
+
e
);
}
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete102 no peer device :e:
'
+
e
);
done
();
expect
(
null
).
assertFail
();
}
done
();
})
/**
...
...
@@ -909,22 +919,25 @@ describe('DeviceKvStoreCallbackTest', function () {
console
.
log
(
'
testDeviceKvStoreOnSyncComplete103 dataChange
'
);
expect
(
data
!=
null
).
assertTrue
();
});
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync101
'
,
VALUE_TEST_SYNC_ELEMENT
,
function
(
err
,
data
)
{
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync101
'
,
VALUE_TEST_SYNC_ELEMENT
).
then
((
data
)
=>
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete103 put success
'
);
expect
(
err
==
undefined
).
assertTrue
();
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
factory
.
SyncMode
.
PUSH_PULL
;
try
{
kvStore
.
sync
(
devices
,
mode
);
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete101 sync no peer device :e:
'
+
e
);
}
done
();
expect
(
data
==
undefined
).
assertTrue
();
}).
catch
((
error
)
=>
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete103 put failed:
'
+
e
);
expect
(
null
).
assertFail
();
});
try
{
var
mode
=
factory
.
SyncMode
.
PUSH_PULL
;
console
.
log
(
'
kvStore.sync to
'
+
JSON
.
stringify
(
syncDeviceIds
));
kvStore
.
sync
(
syncDeviceIds
,
mode
);
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete103 sync no peer device :e:
'
+
e
);
}
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete103 no peer device :e:
'
+
e
);
done
();
expect
(
null
).
assertFail
();
}
done
();
})
/**
...
...
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStorePromiseJsunit.test.js
浏览文件 @
f24488d1
...
...
@@ -32,6 +32,9 @@ const TEST_STORE_ID = 'storeId';
var
kvManager
=
null
;
var
kvStore
=
null
;
var
localDeviceId
=
null
;
const
USED_DEVICE_IDS
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
const
UNUSED_DEVICE_IDS
=
[];
/* add you test device-ids here */
var
syncDeviceIds
=
USED_DEVICE_IDS
.
concat
(
UNUSED_DEVICE_IDS
);
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
...
...
@@ -137,13 +140,13 @@ describe('DeviceKvStorePromiseTest', function () {
console
.
log
(
'
afterEach closeKVStore success
'
);
await
kvManager
.
deleteKVStore
(
TEST_BUNDLE_NAME
,
TEST_STORE_ID
).
then
(()
=>
{
console
.
log
(
'
afterEach deleteKVStore success
'
);
kvStore
=
null
;
}).
catch
((
err
)
=>
{
console
.
log
(
'
afterEach deleteKVStore err
'
+
err
);
});
}).
catch
((
err
)
=>
{
console
.
log
(
'
afterEach closeKVStore err
'
+
err
);
});
kvStore
=
null
;
done
();
})
...
...
@@ -860,14 +863,19 @@ describe('DeviceKvStorePromiseTest', function () {
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
,
VALUE_TEST_SYNC_ELEMENT
).
then
((
data
)
=>
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete001 put success
'
);
expect
(
data
==
undefined
).
assertTrue
();
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
factory
.
SyncMode
.
PULL_ONLY
;
kvStore
.
sync
(
devices
,
mode
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete001 no peer device :e:
'
+
error
);
console
.
log
(
'
testDeviceKvStoreOnSyncComplete001 put failed:
'
+
e
);
expect
(
null
).
assertFail
();
});
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete001 put e
'
+
e
);
try
{
var
mode
=
factory
.
SyncMode
.
PULL_ONLY
;
console
.
log
(
'
kvStore.sync to
'
+
JSON
.
stringify
(
syncDeviceIds
));
kvStore
.
sync
(
syncDeviceIds
,
mode
);
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete001 sync no peer device :e:
'
+
e
);
}
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete001 e
'
+
e
);
expect
(
null
).
assertFail
();
}
done
();
...
...
@@ -887,13 +895,18 @@ describe('DeviceKvStorePromiseTest', function () {
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
,
VALUE_TEST_SYNC_ELEMENT
).
then
((
data
)
=>
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete002 put success
'
);
expect
(
data
==
undefined
).
assertTrue
();
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
factory
.
SyncMode
.
PUSH_ONLY
;
kvStore
.
sync
(
devices
,
mode
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete002 no peer device :e:
'
+
error
);
console
.
log
(
'
testDeviceKvStoreOnSyncComplete002 put failed:
'
+
e
);
expect
(
null
).
assertFail
();
});
}
catch
(
e
)
{
try
{
var
mode
=
factory
.
SyncMode
.
PUSH_ONLY
;
console
.
log
(
'
kvStore.sync to
'
+
JSON
.
stringify
(
syncDeviceIds
));
kvStore
.
sync
(
syncDeviceIds
,
mode
);
}
catch
(
error
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete002 no peer device :e:
'
+
error
);
}
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete002 put e
'
+
e
);
expect
(
null
).
assertFail
();
}
...
...
@@ -914,13 +927,18 @@ describe('DeviceKvStorePromiseTest', function () {
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
,
VALUE_TEST_SYNC_ELEMENT
).
then
((
data
)
=>
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete003 put success
'
);
expect
(
data
==
undefined
).
assertTrue
();
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
factory
.
SyncMode
.
PUSH_PULL
;
kvStore
.
sync
(
devices
,
mode
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete003 no peer device :e:
'
+
error
);
console
.
log
(
'
testDeviceKvStoreOnSyncComplete003 put failed:
'
+
e
);
expect
(
null
).
assertFail
();
});
}
catch
(
e
)
{
try
{
var
mode
=
factory
.
SyncMode
.
PUSH_PULL
;
console
.
log
(
'
kvStore.sync to
'
+
JSON
.
stringify
(
syncDeviceIds
));
kvStore
.
sync
(
syncDeviceIds
,
mode
);
}
catch
(
error
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete003 no peer device :e:
'
+
error
);
}
}
catch
(
e
)
{
console
.
log
(
'
testDeviceKvStoreOnSyncComplete003 put e
'
+
e
);
expect
(
null
).
assertFail
();
}
...
...
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/FieldNodeJsunit.test.js
浏览文件 @
f24488d1
...
...
@@ -15,9 +15,6 @@
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
ddm
from
'
@ohos.data.distributedData
'
;
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
}
describe
(
'
FieldNodeTest
'
,
function
()
{
/**
...
...
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerCallbackJsunit.test.js
浏览文件 @
f24488d1
...
...
@@ -67,6 +67,7 @@ describe('KVManagerCallbackTest', function () {
done
();
});
});
kvStore
=
null
;
})
/**
...
...
@@ -725,16 +726,23 @@ describe('KVManagerCallbackTest', function () {
it
(
'
testKVManagerCloseKVStore104
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
testKVManagerCloseKVStore104
'
);
try
{
await
kvManager
.
getKVStore
(
TEST_STORE_ID
,
options
,
async
function
(
err
,
store
)
{
console
.
log
(
'
testKVManagerCloseKVStore104 getKVStore success
'
);
kvStore
=
store
;
await
kvManager
.
closeKVStore
(
TEST_BUNDLE_NAME
,
TEST_STORE_ID
,
kvStore
);
});
console
.
log
(
'
testKVManagerCloseKVStore104 closeKVStore redo.
'
);
await
kvManager
.
closeKVStore
(
TEST_BUNDLE_NAME
,
TEST_STORE_ID
,
kvStore
,
function
(
err
,
data
)
{
console
.
log
(
'
testKVManagerCloseKVStore104 closeKVStore success
'
);
expect
((
err
==
undefined
)
&&
(
data
==
undefined
)).
assertTrue
();
done
();
console
.
log
(
'
testKVManagerCloseKVStore104 closeKVStore twice
'
+
err
);
if
(
err
==
undefined
)
{
expect
(
null
).
assertFail
();
}
});
}
catch
(
e
)
{
console
.
log
(
'
testKVManagerCloseKVStore104 e
'
+
e
);
console
.
log
(
'
testKVManagerCloseKVStore104
closeKVStore twice
e
'
+
e
);
expect
(
null
).
assertFail
();
done
();
}
done
();
})
/**
...
...
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerPromiseJsunit.test.js
浏览文件 @
f24488d1
...
...
@@ -73,6 +73,7 @@ describe('KVManagerPromiseTest', function () {
}).
catch
((
err
)
=>
{
console
.
log
(
'
afterEach closeKVStore err
'
+
err
);
});
kvStore
=
null
;
done
();
})
...
...
@@ -659,11 +660,17 @@ describe('KVManagerPromiseTest', function () {
*/
it
(
'
testKVManagerCloseKVStore004
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
testKVManagerCloseKVStore004
'
);
await
kvManager
.
getKVStore
(
TEST_STORE_ID
,
options
,
async
function
(
err
,
store
)
{
console
.
log
(
'
testKVManagerCloseKVStore004 getKVStore success
'
);
kvStore
=
store
;
await
kvManager
.
closeKVStore
(
TEST_BUNDLE_NAME
,
TEST_STORE_ID
,
kvStore
);
});
console
.
log
(
'
testKVManagerCloseKVStore104 closeKVStore redo.
'
);
await
kvManager
.
closeKVStore
(
TEST_BUNDLE_NAME
,
TEST_STORE_ID
,
kvStore
).
then
(()
=>
{
console
.
log
(
'
testKVManagerCloseKVStore004 closeKVStore success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
testKVManagerCloseKVStore004 closeKVStore err
'
+
err
);
console
.
log
(
'
testKVManagerCloseKVStore004 closeKVStore twice
'
);
expect
(
null
).
assertFail
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
testKVManagerCloseKVStore004 closeKVStore twice err
'
+
err
);
});
done
();
})
...
...
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvStoreResultSetJsunit.test.js
浏览文件 @
f24488d1
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
factory
from
'
@ohos.data.distributedData
'
import
factory
from
'
@ohos.data.distributedData
'
;
const
TEST_BUNDLE_NAME
=
'
ohos.acts.distributeddatamgr
'
;
const
TEST_STORE_ID
=
'
storeId
'
;
...
...
@@ -120,13 +120,14 @@ describe('KvStoreResultSetTest', function() {
console
.
log
(
'
afterEach closeKVStore success
'
);
await
kvManager
.
deleteKVStore
(
TEST_BUNDLE_NAME
,
TEST_STORE_ID
).
then
(()
=>
{
console
.
log
(
'
afterEach deleteKVStore success
'
);
kvStore
=
null
;
}).
catch
((
err
)
=>
{
console
.
log
(
'
afterEach deleteKVStore err
'
+
err
);
});
}).
catch
((
err
)
=>
{
console
.
log
(
'
afterEach closeKVStore err
'
+
err
);
});
kvStore
=
null
;
resultSet
=
null
;
done
();
})
...
...
@@ -581,12 +582,12 @@ describe('KvStoreResultSetTest', function() {
expect
(
moved
&&
(
resultSet
.
getPosition
()
==
0
)).
assertTrue
();
moved
=
resultSet
.
moveToPrevious
();
console
.
log
(
"
testKvStoreResultSetMoveToPrevious005 from 0 to -1 return
"
+
moved
);
expect
(
moved
).
assertFals
e
();
expect
(
moved
==
false
).
assertTru
e
();
console
.
log
(
"
testKvStoreResultSetMoveToPrevious005 from 0 to
"
+
resultSet
.
getPosition
());
expect
(
-
1
).
assertEqual
(
resultSet
.
getPosition
());
}
catch
(
e
)
{
console
.
log
(
"
testKvStoreResultSetMoveToPrevious005 fail
"
+
e
);
expect
(
null
).
assert
True
();
expect
(
null
).
assert
Fail
();
}
done
();
})
...
...
@@ -965,7 +966,7 @@ describe('KvStoreResultSetTest', function() {
expect
(
moved
).
assertTrue
();
moved
=
resultSet
.
moveToNext
();
console
.
log
(
"
testKvStoreResultSetIsAfterLast002 moveToNext moved=
"
+
moved
);
expect
(
moved
).
assertFals
e
();
expect
(
moved
==
false
).
assertTru
e
();
var
flag
=
resultSet
.
isAfterLast
();
console
.
log
(
"
testKvStoreResultSetIsAfterLast002 isAfterLast true=
"
+
flag
);
expect
(
flag
).
assertTrue
();
...
...
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/QueryJsunit.test.js
浏览文件 @
f24488d1
此差异已折叠。
点击以展开。
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SchemaJsunit.test.js
浏览文件 @
f24488d1
...
...
@@ -136,13 +136,13 @@ describe('SchemaTest', function() {
console
.
log
(
'
afterEach closeKVStore success
'
);
await
kvManager
.
deleteKVStore
(
TEST_BUNDLE_NAME
,
TEST_STORE_ID
).
then
(()
=>
{
console
.
log
(
'
afterEach deleteKVStore success
'
);
kvStore
=
null
;
}).
catch
((
err
)
=>
{
console
.
log
(
'
afterEach deleteKVStore err
'
+
err
);
});
}).
catch
((
err
)
=>
{
console
.
log
(
'
afterEach closeKVStore err
'
+
err
);
});
kvStore
=
null
;
done
();
})
...
...
@@ -262,4 +262,25 @@ describe('SchemaTest', function() {
}
done
();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_SCHEMA_TOJSONSTRING_0400
* @tc.name [JS-API8]Schema.ToJsonString()
* @tc.desc Test Js Api Schema.ToJsonString() testcase 004
*/
it
(
'
testToJsonString004
'
,
0
,
async
function
(
done
)
{
try
{
let
english
=
new
ddm
.
FieldNode
(
'
english
'
);
english
.
type
=
ddm
.
ValueType
.
STRING
;
let
schema
=
new
ddm
.
Schema
();
schema
.
root
.
appendChild
(
english
);
console
.
log
(
"
schema without indexes:
"
+
schema
.
toJsonString
());
schema
.
indexes
=
[];
// indexex set to empty array -> invalid indexes.
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
"
schema exception is ok:
"
+
e
);
}
done
();
})
})
\ No newline at end of file
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStoreCallbackJsunit.test.js
浏览文件 @
f24488d1
...
...
@@ -31,6 +31,9 @@ const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr';
const
TEST_STORE_ID
=
'
storeId
'
;
var
kvManager
=
null
;
var
kvStore
=
null
;
const
USED_DEVICE_IDS
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
const
UNUSED_DEVICE_IDS
=
[];
/* add you test device-ids here */
var
syncDeviceIds
=
USED_DEVICE_IDS
.
concat
(
UNUSED_DEVICE_IDS
);
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
...
...
@@ -104,6 +107,7 @@ describe('SingleKvStoreCallbackTest', function () {
done
();
});
});
kvStore
=
null
;
})
/**
...
...
@@ -821,16 +825,19 @@ describe('SingleKvStoreCallbackTest', function () {
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync101
'
,
VALUE_TEST_SYNC_ELEMENT
,
function
(
err
,
data
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete101 put success
'
);
expect
(
err
==
undefined
).
assertTrue
();
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
factory
.
SyncMode
.
PULL_ONLY
;
kvStore
.
sync
(
devices
,
mode
,
10
);
done
();
});
try
{
var
mode
=
factory
.
SyncMode
.
PULL_ONLY
;
console
.
log
(
'
kvStore.sync to
'
+
JSON
.
stringify
(
syncDeviceIds
));
kvStore
.
sync
(
syncDeviceIds
,
mode
,
10
);
}
catch
(
e
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete101 sync no peer device :e:
'
+
e
);
}
}
catch
(
e
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete101 e
'
+
e
);
expect
(
null
).
assertFail
();
done
();
}
done
();
})
/**
...
...
@@ -844,19 +851,22 @@ describe('SingleKvStoreCallbackTest', function () {
console
.
log
(
'
testSingleKvStoreOnSyncComplete102 dataChange
'
);
expect
(
data
!=
null
).
assertTrue
();
});
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync10
1
'
,
VALUE_TEST_SYNC_ELEMENT
,
function
(
err
,
data
)
{
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync10
2
'
,
VALUE_TEST_SYNC_ELEMENT
,
function
(
err
,
data
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete102 put success
'
);
expect
(
err
==
undefined
).
assertTrue
();
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
factory
.
SyncMode
.
PUSH_ONLY
;
kvStore
.
sync
(
devices
,
mode
,
10
);
done
();
});
try
{
var
mode
=
factory
.
SyncMode
.
PUSH_ONLY
;
console
.
log
(
'
kvStore.sync to
'
+
JSON
.
stringify
(
syncDeviceIds
));
kvStore
.
sync
(
syncDeviceIds
,
mode
,
10
);
}
catch
(
e
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete102 sync no peer device :e:
'
+
e
);
}
}
catch
(
e
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete102 e
'
+
e
);
expect
(
null
).
assertFail
();
done
();
}
done
();
})
/**
...
...
@@ -870,19 +880,22 @@ describe('SingleKvStoreCallbackTest', function () {
console
.
log
(
'
testSingleKvStoreOnSyncComplete103 dataChange
'
);
expect
(
data
!=
null
).
assertTrue
();
});
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync10
1
'
,
VALUE_TEST_SYNC_ELEMENT
,
function
(
err
,
data
)
{
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync10
3
'
,
VALUE_TEST_SYNC_ELEMENT
,
function
(
err
,
data
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete103 put success
'
);
expect
(
err
==
undefined
).
assertTrue
();
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
factory
.
SyncMode
.
PUSH_PULL
;
kvStore
.
sync
(
devices
,
mode
,
10
);
done
();
});
try
{
var
mode
=
factory
.
SyncMode
.
PUSH_PULL
;
console
.
log
(
'
kvStore.sync to
'
+
JSON
.
stringify
(
syncDeviceIds
));
kvStore
.
sync
(
syncDeviceIds
,
mode
,
10
);
}
catch
(
e
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete103 sync no peer device :e:
'
+
e
);
}
}
catch
(
e
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete103 e
'
+
e
);
expect
(
null
).
assertFail
();
done
();
}
done
();
})
/**
...
...
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStoreEnumJsunit.test.js
浏览文件 @
f24488d1
...
...
@@ -48,7 +48,7 @@ describe('KvStoreEnumTest', function () {
var
maxValueLength
=
factory
.
Constants
.
MAX_VALUE_LENGTH
;
console
.
info
(
'
maxValueLength =
'
+
maxValueLength
);
expect
(
maxValueLength
==
4194303
).
assertTrue
();
expect
(
factory
.
Constants
.
MAX_VALUE_LENGTH
).
assertEqual
(
4194303
);
expect
(
factory
.
Constants
.
MAX_VALUE_LENGTH
).
assertEqual
(
4194303
);
})
/**
...
...
@@ -63,7 +63,6 @@ describe('KvStoreEnumTest', function () {
console
.
info
(
'
can NOT set value to MAX_VALUE_LENGTH :
'
+
e
);
expect
(
factory
.
Constants
.
MAX_VALUE_LENGTH
).
assertEqual
(
4194303
);
}
})
/**
...
...
@@ -72,9 +71,6 @@ describe('KvStoreEnumTest', function () {
* @tc.desc Test Js Enum Value Constants.MAX_KEY_LENGTH_DEVICE
*/
it
(
'
testConstantsMaxKeyLengthDevice_001
'
,
0
,
function
()
{
expect
(
factory
.
Constants
.
MAX_VALUE_LENGTH
).
assertEqual
(
4194303
);
var
maxKeyLengthDevice
=
factory
.
Constants
.
MAX_KEY_LENGTH_DEVICE
;
console
.
info
(
'
maxKeyLengthDevice =
'
+
maxKeyLengthDevice
);
expect
(
maxKeyLengthDevice
==
896
).
assertTrue
()
...
...
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStorePromiseJsunit.test.js
浏览文件 @
f24488d1
...
...
@@ -31,6 +31,9 @@ const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr';
const
TEST_STORE_ID
=
'
storeId
'
;
var
kvManager
=
null
;
var
kvStore
=
null
;
const
USED_DEVICE_IDS
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
const
UNUSED_DEVICE_IDS
=
[];
/* add you test device-ids here */
var
syncDeviceIds
=
USED_DEVICE_IDS
.
concat
(
UNUSED_DEVICE_IDS
);
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
...
...
@@ -107,13 +110,13 @@ describe('SingleKvStorePromiseTest', function () {
console
.
log
(
'
afterEach closeKVStore success
'
);
await
kvManager
.
deleteKVStore
(
TEST_BUNDLE_NAME
,
TEST_STORE_ID
).
then
(()
=>
{
console
.
log
(
'
afterEach deleteKVStore success
'
);
kvStore
=
null
;
}).
catch
((
err
)
=>
{
console
.
log
(
'
afterEach deleteKVStore err
'
+
err
);
});
}).
catch
((
err
)
=>
{
console
.
log
(
'
afterEach closeKVStore err
'
+
err
);
});
kvStore
=
null
;
done
();
})
...
...
@@ -830,15 +833,19 @@ describe('SingleKvStorePromiseTest', function () {
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
,
VALUE_TEST_SYNC_ELEMENT
).
then
((
data
)
=>
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete001 put success
'
);
expect
(
data
==
undefined
).
assertTrue
();
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
factory
.
SyncMode
.
PULL_ONLY
;
kvStore
.
sync
(
devices
,
mode
,
10
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete001 put fail
'
+
error
);
expect
(
null
).
assertFail
();
});
try
{
var
mode
=
factory
.
SyncMode
.
PULL_ONLY
;
console
.
log
(
'
kvStore.sync to
'
+
JSON
.
stringify
(
syncDeviceIds
));
kvStore
.
sync
(
syncDeviceIds
,
mode
,
10
);
}
catch
(
e
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete001 sync no peer device :e:
'
+
e
);
}
}
catch
(
e
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete001
put
e
'
+
e
);
console
.
log
(
'
testSingleKvStoreOnSyncComplete001 e
'
+
e
);
expect
(
null
).
assertFail
();
}
done
();
...
...
@@ -858,15 +865,19 @@ describe('SingleKvStorePromiseTest', function () {
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
,
VALUE_TEST_SYNC_ELEMENT
).
then
((
data
)
=>
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete002 put success
'
);
expect
(
data
==
undefined
).
assertTrue
();
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
factory
.
SyncMode
.
PUSH_ONLY
;
kvStore
.
sync
(
devices
,
mode
,
10
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete002 put fail
'
+
error
);
expect
(
null
).
assertFail
();
});
try
{
var
mode
=
factory
.
SyncMode
.
PUSH_ONLY
;
console
.
log
(
'
kvStore.sync to
'
+
JSON
.
stringify
(
syncDeviceIds
));
kvStore
.
sync
(
syncDeviceIds
,
mode
,
10
);
}
catch
(
e
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete002 sync no peer device :e:
'
+
e
);
}
}
catch
(
e
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete002
put
e
'
+
e
);
console
.
log
(
'
testSingleKvStoreOnSyncComplete002 e
'
+
e
);
expect
(
null
).
assertFail
();
}
done
();
...
...
@@ -886,15 +897,19 @@ describe('SingleKvStorePromiseTest', function () {
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
,
VALUE_TEST_SYNC_ELEMENT
).
then
((
data
)
=>
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete003 put success
'
);
expect
(
data
==
undefined
).
assertTrue
();
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
factory
.
SyncMode
.
PUSH_PULL
;
kvStore
.
sync
(
devices
,
mode
,
10
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete003 put fail
'
+
error
);
expect
(
null
).
assertFail
();
});
try
{
var
mode
=
factory
.
SyncMode
.
PUSH_PULL
;
console
.
log
(
'
kvStore.sync to
'
+
JSON
.
stringify
(
syncDeviceIds
));
kvStore
.
sync
(
syncDeviceIds
,
mode
,
10
);
}
catch
(
e
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete003 sync no peer device :e:
'
+
e
);
}
}
catch
(
e
)
{
console
.
log
(
'
testSingleKvStoreOnSyncComplete003
put
e
'
+
e
);
console
.
log
(
'
testSingleKvStoreOnSyncComplete003 e
'
+
e
);
expect
(
null
).
assertFail
();
}
done
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录