提交 976d4a2c 编写于 作者: B bayanxing

add test cases

Signed-off-by: Nbayanxing <bayanxing@kaihongdigi.com>
上级 2f000296
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="ce9894ed-6879-4b8e-a046-5d8d0188b266" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ExternalProjectsManager">
<system id="GRADLE">
<state>
<projects_view>
<tree_state>
<expand />
<select />
</tree_state>
</projects_view>
</state>
</system>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="29SRufnT8pJJTbMAzxBK3ertGAy" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="show.inlinked.gradle.project.popup" value="false" />
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
</project>
\ No newline at end of file
......@@ -107,9 +107,158 @@ describe('appInfoTest', function () {
done();
})
/**
* @tc.number BatteryCommonEventTest_010
* @tc.name subscribe battery completed common event
* @tc.desc Battery acquisition kit
*/
it('BatteryCommonEventTest_010', 0, function (done) {
createShutdownSubscriber();
done();
})
/**
* @tc.number BatteryCommonEventTest_011
* @tc.name subscribe battery completed common event
* @tc.desc Battery acquisition kit
*/
it('BatteryCommonEventTest_011', 0, function (done) {
createScreenOnSubscriber();
done();
})
console.log("*************Battery commonEvent Test End*************");
})
function createScreenOnSubscriber() {
var commonEventSubscribeInfo = {
events: [commonEvent.Support.COMMON_EVENT_SCREEN_ON],
};
commonEvent.createSubscriber(commonEventSubscribeInfo)
.then(subscriber => {
console.info('createScreenOnSubscriber success');
var mySubscriber = subscriber;
console.log(subscriber);
if (subscriber == "" || subscriber == undefined || subscriber == null) {
console.info("createSubscriber failed");
}
mySubscriber.getCode()
.then((data) => {
console.info('Subscriber getCode success : ' + JSON.stringify(data));
}).catch((error) => {
console.error('Subscriber getCode error because: ' + JSON.stringify(error));
})
mySubscriber.getData()
.then((data) => {
console.info('Subscriber getData success : ' + JSON.stringify(data));
}).catch((error) => {
console.error('Subscriber getData error because: ' + JSON.stringify(error));
})
console.info('subscribe Screen_On begin ');
commonEvent.subscribe(mySubscriber, (error, commonEventData) => {
console.error('err code: ' + JSON.stringify(error));
console.info('subscribe callback: ' + JSON.stringify(commonEventData));
console.info("commonEventData event: " + commonEventData.event);
console.info("commonEventData bundleName: " + commonEventData.bundleName);
console.info("commonEventData data: " + commonEventData.data);
console.info("commonEventData parameter: " + commonEventData.parameters[0]);
var capacity = commonEventData.parameters['0'];
console.info("capacity is:" + capacity);
expect(capacity >= 0 && capacity <= 100).assertTrue();
});
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
});
}
function createScreenOffSubscriber() {
var commonEventSubscribeInfo = {
events: [commonEvent.Support.COMMON_EVENT_SCREEN_OFF],
};
commonEvent.createSubscriber(commonEventSubscribeInfo)
.then(subscriber => {
console.info('createScreenOffSubscriber success');
var mySubscriber = subscriber;
console.log(subscriber);
if (subscriber == "" || subscriber == undefined || subscriber == null) {
console.info("createSubscriber failed");
}
mySubscriber.getCode()
.then((data) => {
console.info('Subscriber getCode success : ' + JSON.stringify(data));
}).catch((error) => {
console.error('Subscriber getCode error because: ' + JSON.stringify(error));
})
mySubscriber.getData()
.then((data) => {
console.info('Subscriber getData success : ' + JSON.stringify(data));
}).catch((error) => {
console.error('Subscriber getData error because: ' + JSON.stringify(error));
})
console.info('subscribe Screen_Off begin ');
commonEvent.subscribe(mySubscriber, (error, commonEventData) => {
console.error('err code: ' + JSON.stringify(error));
console.info('subscribe callback: ' + JSON.stringify(commonEventData));
console.info("commonEventData event: " + commonEventData.event);
console.info("commonEventData bundleName: " + commonEventData.bundleName);
console.info("commonEventData data: " + commonEventData.data);
console.info("commonEventData parameter: " + commonEventData.parameters[0]);
var capacity = commonEventData.parameters['0'];
console.info("capacity is:" + capacity);
expect(capacity >= 0 && capacity <= 100).assertTrue();
});
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
});
}
function createShutdownSubscriber() {
var commonEventSubscribeInfo = {
events: [commonEvent.Support.COMMON_EVENT_SHUTDOWN],
};
commonEvent.createSubscriber(commonEventSubscribeInfo)
.then(subscriber => {
console.info('createShutdownSubscriber success');
var mySubscriber = subscriber;
console.log(subscriber);
if (subscriber == "" || subscriber == undefined || subscriber == null) {
console.info("createSubscriber failed");
}
mySubscriber.getCode()
.then((data) => {
console.info('Subscriber getCode success : ' + JSON.stringify(data));
}).catch((error) => {
console.error('Subscriber getCode error because: ' + JSON.stringify(error));
})
mySubscriber.getData()
.then((data) => {
console.info('Subscriber getData success : ' + JSON.stringify(data));
}).catch((error) => {
console.error('Subscriber getData error because: ' + JSON.stringify(error));
})
console.info('subscribe shutdown begin ');
commonEvent.subscribe(mySubscriber, (error, commonEventData) => {
console.error('err code: ' + JSON.stringify(error));
console.info('subscribe callback: ' + JSON.stringify(commonEventData));
console.info("commonEventData event: " + commonEventData.event);
console.info("commonEventData bundleName: " + commonEventData.bundleName);
console.info("commonEventData data: " + commonEventData.data);
console.info("commonEventData parameter: " + commonEventData.parameters[0]);
var capacity = commonEventData.parameters['0'];
console.info("capacity is:" + capacity);
expect(capacity >= 0 && capacity <= 100).assertTrue();
});
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
});
}
function createLockedBootCompletedSubscriber() {
var commonEventSubscribeInfo = {
events: [commonEvent.Support.COMMON_EVENT_LOCKED_BOOT_COMPLETED],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册