提交 58a52533 编写于 作者: N nan-xiansen

【resourceschedule】【master】workschedule:adapter api error code modify.

Signed-off-by: Nnan-xiansen <nanjinbin@huawei.com>
Change-Id: I357cfd20fab38294f77f589dc8b323b027863a40
上级 b275bddf
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import workscheduler from '@ohos.workScheduler' import workscheduler from '@ohos.resourceschedule.workScheduler'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
...@@ -33,6 +33,7 @@ describe("WorkSchedulerPerformanceTest", function () { ...@@ -33,6 +33,7 @@ describe("WorkSchedulerPerformanceTest", function () {
function performanceStartWork() { function performanceStartWork() {
it('WorkSchedulerPerformance_001', 0, async function(done) { it('WorkSchedulerPerformance_001', 0, async function(done) {
workscheduler.stopAndClearWorks()
let totalTime = 0 let totalTime = 0
let workInfo = { let workInfo = {
workId: 201, workId: 201,
...@@ -41,16 +42,20 @@ function performanceStartWork() { ...@@ -41,16 +42,20 @@ function performanceStartWork() {
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService" abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
} }
let startTime = new Date().getTime() let startTime = new Date().getTime()
workscheduler.startWork(workInfo) try{
workscheduler.startWork(workInfo)
} catch (error) {
expect(true).assertEqual(false)
}
totalTime = new Date().getTime() - startTime totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_001: startWork WaitTime: ' + totalTime + 'ms') console.info('WorkSchedulerPerformance_001: startWork WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done() done()
}) })
} }
function performanceStopWork() { function performanceStopWork() {
it('WorkSchedulerPerformance_002', 0, async function(done) { it('WorkSchedulerPerformance_002', 0, async function(done) {
workscheduler.stopAndClearWorks()
let totalTime = 0 let totalTime = 0
let workingInfo = { let workingInfo = {
workId: 202, workId: 202,
...@@ -58,7 +63,11 @@ function performanceStopWork() { ...@@ -58,7 +63,11 @@ function performanceStopWork() {
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function", bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService" abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
} }
workscheduler.startWork(workingInfo) try{
workscheduler.startWork(workingInfo)
} catch (error) {
expect(true).assertEqual(false)
}
let workInfo = { let workInfo = {
workId: 202, workId: 202,
batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW, batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW,
...@@ -66,150 +75,214 @@ function performanceStopWork() { ...@@ -66,150 +75,214 @@ function performanceStopWork() {
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService" abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
} }
let startTime = new Date().getTime() let startTime = new Date().getTime()
try{
workscheduler.stopWork(workInfo, false)
} catch (error) {
expect(true).assertEqual(false)
}
workscheduler.stopWork(workInfo, false) workscheduler.stopWork(workInfo, false)
totalTime= new Date().getTime() - startTime totalTime= new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_002: stopWork WaitTime: ' + totalTime + 'ms') console.info('WorkSchedulerPerformance_002: stopWork WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done() done()
}) })
} }
function performanceGetWorkStatusCallback() { function performanceGetWorkStatusCallback() {
it('WorkSchedulerPerformance_003', 0, async function(done) { it('WorkSchedulerPerformance_003', 0, async function(done) {
workscheduler.stopAndClearWorks()
let workInfo = { let workInfo = {
workId: 203, workId: 203,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY, storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function", bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService" abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
} }
workscheduler.startWork(workInfo) try{
workscheduler.startWork(workInfo)
} catch (error) {
expect(true).assertEqual(false)
done()
}
let startTime = new Date().getTime() let startTime = new Date().getTime()
await workscheduler.getWorkStatus(203, (err, res) => { try{
let totalTime = new Date().getTime() - startTime await workscheduler.getWorkStatus(203, (err, res) => {
console.info('WorkSchedulerPerformance_003: getWorkStatus callback WaitTime: ' + totalTime + 'ms') let totalTime = new Date().getTime() - startTime
workscheduler.stopAndClearWorks() console.info('WorkSchedulerPerformance_003: getWorkStatus callback WaitTime: ' + totalTime + 'ms')
done()
})
} catch (error) {
done() done()
}) }
}) })
} }
function performanceGetWorkStatusPromise() { function performanceGetWorkStatusPromise() {
it('WorkSchedulerPerformance_004', 0, async function(done) { it('WorkSchedulerPerformance_004', 0, async function(done) {
workscheduler.stopAndClearWorks()
let workInfo = { let workInfo = {
workId: 204, workId: 204,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY, storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function", bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService" abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
} }
workscheduler.startWork(workInfo) try{
workscheduler.startWork(workInfo)
} catch (error) {
expect(true).assertEqual(false)
done()
}
let startTime = new Date().getTime() let startTime = new Date().getTime()
startTime = new Date().getTime() startTime = new Date().getTime()
await workscheduler.getWorkStatus(204) try{
.then((res) => { await workscheduler.getWorkStatus(204)
let totalTime = new Date().getTime() - startTime .then((res) => {
console.info('WorkSchedulerPerformance_004: getWorkStatus promise WaitTime: ' + totalTime + 'ms') let totalTime = new Date().getTime() - startTime
workscheduler.stopAndClearWorks() console.info('WorkSchedulerPerformance_004: getWorkStatus promise WaitTime: ' + totalTime + 'ms')
done() done()
}) })
.catch((err) => { .catch((err) => {
done() done()
}) })
} catch (error) {
done()
}
}) })
} }
function performanceObtainAllWorksCallback() { function performanceObtainAllWorksCallback() {
it('WorkSchedulerPerformance_005', 0, async function(done) { it('WorkSchedulerPerformance_005', 0, async function(done) {
workscheduler.stopAndClearWorks()
let workInfo = { let workInfo = {
workId: 205, workId: 205,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY, storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function", bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService" abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
} }
workscheduler.startWork(workInfo) try{
workscheduler.startWork(workInfo)
} catch (error) {
expect(true).assertEqual(false)
done()
}
let startTime = new Date().getTime() let startTime = new Date().getTime()
await workscheduler.obtainAllWorks((err, res) => { try{
let totalTime = new Date().getTime() - startTime await workscheduler.obtainAllWorks((err, res) => {
console.info('WorkSchedulerPerformance_005: obtainAllWorks callback WaitTime: ' + totalTime + 'ms') let totalTime = new Date().getTime() - startTime
workscheduler.stopAndClearWorks() console.info('WorkSchedulerPerformance_005: obtainAllWorks callback WaitTime: ' + totalTime + 'ms')
done()
})
} catch (error) {
done() done()
}) }
}) })
} }
function performanceObtainAllWorksPromise() { function performanceObtainAllWorksPromise() {
it('WorkSchedulerPerformance_006', 0, async function(done) { it('WorkSchedulerPerformance_006', 0, async function(done) {
workscheduler.stopAndClearWorks()
let workInfo = { let workInfo = {
workId: 206, workId: 206,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY, storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function", bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService" abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
} }
workscheduler.startWork(workInfo) try{
workscheduler.startWork(workInfo)
} catch (error) {
expect(true).assertEqual(false)
done()
}
let startTime = new Date().getTime() let startTime = new Date().getTime()
await workscheduler.obtainAllWorks() try{
.then((res) => { await workscheduler.obtainAllWorks()
let totalTime = new Date().getTime() - startTime .then((res) => {
console.info('WorkSchedulerPerformance_006: obtainAllWorks promise WaitTime: ' + totalTime + 'ms') let totalTime = new Date().getTime() - startTime
workscheduler.stopAndClearWorks() console.info('WorkSchedulerPerformance_006: obtainAllWorks promise WaitTime: ' + totalTime + 'ms')
done() done()
}) })
.catch((err) => { .catch((err) => {
done() done()
}) })
} catch (error) {
done()
}
}) })
} }
function performanceIsLastWorkTimeOutCallback() { function performanceIsLastWorkTimeOutCallback() {
it('WorkSchedulerPerformance_007', 0, async function(done) { it('WorkSchedulerPerformance_007', 0, async function(done) {
workscheduler.stopAndClearWorks()
let workInfo = { let workInfo = {
workId: 207, workId: 207,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY, storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function", bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService" abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
} }
workscheduler.startWork(workInfo) try{
workscheduler.startWork(workInfo)
} catch (error) {
expect(true).assertEqual(false)
done()
}
let startTime = new Date().getTime() let startTime = new Date().getTime()
await workscheduler.isLastWorkTimeOut(207, (err, res) => { try{
let totalTime = new Date().getTime() - startTime await workscheduler.isLastWorkTimeOut(207, (err, res) => {
console.info('WorkSchedulerPerformance_007: isLastWorkTimeOut callback WaitTime: ' + totalTime + 'ms') let totalTime = new Date().getTime() - startTime
workscheduler.stopAndClearWorks() console.info('WorkSchedulerPerformance_007: isLastWorkTimeOut callback WaitTime: ' + totalTime + 'ms')
done()
})
} catch (error) {
done() done()
}) }
}) })
} }
function performanceIsLastWorkTimeOutPromise() { function performanceIsLastWorkTimeOutPromise() {
it('WorkSchedulerPerformance_008', 0, async function(done) { it('WorkSchedulerPerformance_008', 0, async function(done) {
workscheduler.stopAndClearWorks()
let workInfo = { let workInfo = {
workId: 208, workId: 208,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY, storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function", bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService" abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
} }
workscheduler.startWork(workInfo) try{
workscheduler.startWork(workInfo)
} catch (error) {
expect(true).assertEqual(false)
done()
}
let startTime = new Date().getTime() let startTime = new Date().getTime()
await workscheduler.isLastWorkTimeOut(208) try{
.then((res) => { await workscheduler.isLastWorkTimeOut(208)
let totalTime = new Date().getTime() - startTime .then((res) => {
console.info('WorkSchedulerPerformance_008: isLastWorkTimeOut promise WaitTime: ' + totalTime + 'ms') let totalTime = new Date().getTime() - startTime
workscheduler.stopAndClearWorks() console.info('WorkSchedulerPerformance_008: isLastWorkTimeOut promise WaitTime: ' + totalTime + 'ms')
done() done()
}) })
.catch((err) => { .catch((err) => {
done() done()
}) })
} catch (error) {
done()
}
}) })
} }
function performanceStopAndClearWorks() { function performanceStopAndClearWorks() {
it('WorkSchedulerPerformance_009', 0, function() { it('WorkSchedulerPerformance_009', 0, function() {
workscheduler.stopAndClearWorks()
let workInfo = { let workInfo = {
workId: 209, workId: 209,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY, storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function", bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService" abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
} }
workscheduler.startWork(workInfo) try{
workscheduler.startWork(workInfo)
} catch (error) {
expect(true).assertEqual(false)
done()
}
let startTime = new Date().getTime() let startTime = new Date().getTime()
workscheduler.stopAndClearWorks() workscheduler.stopAndClearWorks()
let totalTime = new Date().getTime() - startTime let totalTime = new Date().getTime() - startTime
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册