未验证 提交 4dacb3c6 编写于 作者: O openharmony_ci 提交者: Gitee

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

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