= new Map()
+
+ constructor() {
+
+ }
+
+ registerCallback(callback:Callback , type?:string) {
+ if (type == undefined) {
+ console.error('registerCallback callback set')
+ this.callback = callback
+ return
+ }
+ this.callbacks.set(type,callback)
+ }
+
+ notify(message:any, type?:string) {
+ if (type == undefined) {
+ this.callback(message)
+ return
+ }
+
+ let tmpCallback:Callback = this.callbacks.get(type)
+ if (tmpCallback === undefined) {
+ console.error('callbacks has no callback for type ' + type)
+ return
+ }
+ tmpCallback(message)
+ }
+
+ clear() {
+ this.callbacks.clear()
+ this.callback = null
+ }
+}
\ No newline at end of file
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexAlignSelf.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexAlignSelf.ets
new file mode 100644
index 0000000000000000000000000000000000000000..841c4e29cd1ec5a761a1003efb4d4a97a6b9dfa3
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexAlignSelf.ets
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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.
+ */
+
+@Entry
+@Component
+struct FlexAlignSelf_Auto {
+ private content: string = "FlexAlignSelf_Auto Page"
+ onPageShow() {
+ console.info('FlexAlignSelf_Center page show called');
+ }
+
+ onBuildDone() {
+ console.info('FlexAlignSelf_Auto page build done called');
+ }
+
+ build() {
+ Column() {
+ Column() {
+ Text('FlexTest12').fontSize(9).fontColor(0xCCCCCC).width('90%')
+ Flex({
+ direction: FlexDirection.Row,
+ alignItems: ItemAlign.Auto,
+ wrap: FlexWrap.NoWrap,
+ }) {
+ Text('1').width(150).height(50).backgroundColor(0xF5DEB3).alignSelf(ItemAlign.End).key('textAlignSelf01')
+ Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textAlignSelf02')
+ Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textAlignSelf03')
+ }
+ .key('flexAlignSelf')
+ .height(150)
+ .width(500)
+ .backgroundColor(0xAFEEEE)
+ }.width('100%').margin({ top: 5 })
+ }.width('100%')
+ }
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexBase.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexBase.ets
new file mode 100644
index 0000000000000000000000000000000000000000..8f92bfb23bbb9182168b82bdb413ed840992f62a
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexBase.ets
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 {MessageManager,Callback} from '../../../../common/MessageManager';
+@Entry
+@Component
+struct FlexBase_Auto {
+ @State testHeight: number = 150
+ @State testWidth: number = 450
+ messageManager:MessageManager = new MessageManager()
+ private content: string = "FlexBase_Auto Page"
+ onPageShow() {
+ console.info('FlexBase_Center onPageShow');
+ globalThis.value = {
+ name:'messageManager',message:this.messageManager
+ }
+ let callback:Callback = (message:any) => {
+ console.error('message = ' + message.name + "--" + message.value);
+ if (message.name == 'height') {
+ this.testHeight = message.value;
+ }
+ if (message.name == 'width') {
+ this.testWidth = message.value;
+ }
+ }
+ this.messageManager.registerCallback(callback);
+
+ }
+
+ onBuildDone() {
+ console.info('FlexBase_Auto page build done called');
+ }
+
+ build() {
+ Column() {
+ Column() {
+ Text('FlexBase_1').fontSize(9).fontColor(0xCCCCCC).width('90%')
+ Flex({
+ direction: FlexDirection.Row,
+ alignItems: ItemAlign.Auto,
+ wrap: FlexWrap.NoWrap,
+ }) {
+ Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('textFlex01')
+ Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textFlex02')
+ Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textFlex03')
+ }
+ .key('flex01')
+ .height(this.testHeight)
+ .width(this.testWidth)
+ .backgroundColor(0xAFEEEE)
+ }.width('100%').margin({ top: 5 })
+ }.width('100%')
+ }
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexExceed.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexExceed.ets
new file mode 100644
index 0000000000000000000000000000000000000000..59a1816931e819ed3c20a5803aa0d114c131404b
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexExceed.ets
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 {MessageManager,Callback} from '../../../../common/MessageManager';
+@Entry
+@Component
+struct FlexExceed_Auto {
+ @State testPadding: number = 0
+ @State testMargin: number = 0
+ messageManager:MessageManager = new MessageManager()
+ private content: string = "FlexExceed_Auto Page"
+ onPageShow() {
+ console.info('FlexBase_Center onPageShow');
+ globalThis.value = {
+ name:'messageManager',message:this.messageManager
+ }
+ let callback:Callback = (message:any) => {
+ console.error('message = ' + message.name + "--" + message.value);
+ if (message.name == 'padding') {
+ this.testPadding = message.value;
+ }
+ if (message.name == 'margin') {
+ this.testMargin = message.value;
+ }
+ }
+ this.messageManager.registerCallback(callback);
+ }
+
+ onBuildDone() {
+ console.info('FlexExceed_Auto page build done called');
+ }
+
+ build() {
+ Column() {
+ Column() {
+ Text('FlexExceed_1').fontSize(9).fontColor(0xCCCCCC).width('90%')
+ Flex({
+ direction: FlexDirection.Row,
+ alignItems: ItemAlign.Auto,
+ wrap: FlexWrap.NoWrap,
+ }) {
+ Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('textExceed01')
+ Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textExceed02')
+ Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textExceed03')
+ }
+ .key('flexExceed01')
+ .height(200)
+ .width(500)
+ .margin(this.testMargin)
+ .padding(this.testPadding)
+ .backgroundColor(0xAFEEEE)
+ }.width('100%').margin({ top: 5 })
+ }.width('100%')
+ }
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexHeightModify.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexHeightModify.ets
new file mode 100644
index 0000000000000000000000000000000000000000..43bb068c017432773351ee1369ac022e7bc1af7d
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexHeightModify.ets
@@ -0,0 +1,60 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 {MessageManager,Callback} from '../../../../common/MessageManager';
+@Entry
+@Component
+struct FlexHeightModify_Auto {
+ @State testHeight: number = 50
+ messageManager:MessageManager = new MessageManager()
+ private content: string = "FlexHeightModify_Auto Page"
+ onPageShow() {
+ console.info('FlexHeightModify_Auto onPageShow');
+ globalThis.value = {
+ name:'messageManager',message:this.messageManager
+ }
+ let callback:Callback = (message:any) => {
+ console.error('message = ' + message.name + "--" + message.value);
+ if (message.name == 'height') {
+ this.testHeight = message.value;
+ }
+ }
+ this.messageManager.registerCallback(callback);
+ }
+
+ onBuildDone() {
+ console.info('FlexHeightModify_Auto page build done called');
+ }
+
+ build() {
+ Column() {
+ Column() {
+ Text('FlexHeightModify').fontSize(9).fontColor(0xCCCCCC).width('90%')
+ Flex({
+ direction: FlexDirection.Row,
+ alignItems: ItemAlign.Auto,
+ wrap: FlexWrap.NoWrap,
+ }) {
+ Text('1').width(150).height(this.testHeight).backgroundColor(0xF5DEB3).key('textHeightModify01')
+ Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textHeightModify02')
+ Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textHeightModify03')
+ }
+ .key('flexHeightModify')
+ .height(150)
+ .width(500)
+ .backgroundColor(0xAFEEEE)
+ }.width('100%').margin({ top: 5 })
+ }.width('100%')
+ }
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexMargin.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexMargin.ets
new file mode 100644
index 0000000000000000000000000000000000000000..c150dc5167ffbadce16914fc801e8efd935c994d
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexMargin.ets
@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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.
+ */
+
+@Entry
+@Component
+struct FlexMargin_Auto {
+
+ private content: string = "FlexMargin_Auto Page"
+ onPageShow() {
+ console.info('FlexMargin_Center page show called');
+ }
+
+ onBuildDone() {
+ console.info('FlexMargin_Auto page build done called');
+ }
+
+ build() {
+ Column() {
+ Column() {
+ Text('FlexTest05').fontSize(9).fontColor(0xCCCCCC).width('90%')
+ Flex({
+ direction: FlexDirection.Row,
+ alignItems: ItemAlign.Auto,
+ wrap: FlexWrap.NoWrap,
+ }) {
+ Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('textFlexMargin01')
+ Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textFlexMargin02')
+ Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textFlexMargin03')
+ }
+ .key('flexMargin')
+ .height(200)
+ .width(500)
+ .margin(10)
+ .backgroundColor(0xAFEEEE)
+ }.width('100%').margin({ top: 5 })
+ }.width('100%')
+ }
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexOffset.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexOffset.ets
new file mode 100644
index 0000000000000000000000000000000000000000..a67e7a5936e319ffb3f306c1c96a2c430e984985
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexOffset.ets
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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.
+ */
+
+@Entry
+@Component
+struct FlexOffset_Auto {
+ private content: string = "FlexOffset_Auto Page"
+
+ onPageShow() {
+ console.info('FlexOffset_Auto page show called');
+ }
+
+ onBuildDone() {
+ console.info('FlexOffset_Auto page build done called');
+ }
+
+ build() {
+ Column() {
+ Column() {
+ Text('FlexTest09').fontSize(9).fontColor(0xCCCCCC).width('90%')
+ Flex({
+ direction: FlexDirection.Row,
+ alignItems: ItemAlign.Auto,
+ wrap: FlexWrap.NoWrap,
+ }) {
+ Text('1').width(150).height(50).backgroundColor(0xF5DEB3).offset({ x: 15, y: 30 }).key('textOffset01')
+ Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textOffset02')
+ Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textOffset03')
+ }
+ .key('flexOffset')
+ .height(150)
+ .width(500)
+ .backgroundColor(0xAFEEEE)
+ }.width('100%').margin({ top: 5 })
+ }.width('100%')
+ }
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexPadding.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexPadding.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0899fa39a58af13603c929feb6a433a2600a1e1a
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexPadding.ets
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 {MessageManager,Callback} from '../../../../common/MessageManager';
+@Entry
+@Component
+struct FlexPadding_Auto {
+ @State testPadding: number = 0
+ messageManager:MessageManager = new MessageManager()
+ private content: string = "FlexPadding_Auto Page"
+ onPageShow() {
+ console.info('FlexBase_Center onPageShow');
+ globalThis.value = {
+ name:'messageManager',message:this.messageManager
+ }
+ let callback:Callback = (message:any) => {
+ console.error('message = ' + message.name + "--" + message.value);
+ if (message.name == 'padding') {
+ this.testPadding = message.value;
+ }
+ }
+ this.messageManager.registerCallback(callback);
+ }
+
+ onBuildDone() {
+ console.info('FlexPadding_Auto page build done called');
+ }
+
+ build() {
+ Column() {
+ Column() {
+ Text('FlexPadding_1').fontSize(9).fontColor(0xCCCCCC).width('90%')
+ Flex({
+ direction: FlexDirection.Row,
+ alignItems: ItemAlign.Auto,
+ wrap: FlexWrap.NoWrap,
+ }) {
+ Text('1').width(150).height(50).backgroundColor(0xF5DEB3).key('textFlexPadding01')
+ Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textFlexPadding02')
+ Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textFlexPadding03')
+ }
+ .key('flexPadding01')
+ .height(200)
+ .width(500)
+ .padding(this.testPadding)
+ .backgroundColor(0xAFEEEE)
+ }.width('100%').margin({ top: 5 })
+ }.width('100%')
+ }
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexTextMargin.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexTextMargin.ets
new file mode 100644
index 0000000000000000000000000000000000000000..3cc71f665e2e335abca6c87e2ec92be4c26fbe78
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexTextMargin.ets
@@ -0,0 +1,60 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 {MessageManager,Callback} from '../../../../common/MessageManager';
+@Entry
+@Component
+struct FlexTextMargin_Auto {
+ @State testMargin: number = 0
+ messageManager:MessageManager = new MessageManager()
+ private content: string = "FlexTextMargin_Auto Page"
+ onPageShow() {
+ console.info('FlexBase_Center onPageShow');
+ globalThis.value = {
+ name:'messageManager',message:this.messageManager
+ }
+ let callback:Callback = (message:any) => {
+ console.error('message = ' + message.name + "--" + message.value);
+ if (message.name == 'margin') {
+ this.testMargin = message.value;
+ }
+ }
+ this.messageManager.registerCallback(callback);
+ }
+
+ onBuildDone() {
+ console.info('FlexTextMargin_Auto page build done called');
+ }
+
+ build() {
+ Column() {
+ Column() {
+ Text('FlexTextMargin_1').fontSize(9).fontColor(0xCCCCCC).width('90%')
+ Flex({
+ direction: FlexDirection.Row,
+ alignItems: ItemAlign.Auto,
+ wrap: FlexWrap.NoWrap,
+ }) {
+ Text('1').width(150).height(50).backgroundColor(0xF5DEB3).margin(this.testMargin).key('textMargin01')
+ Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textMargin02')
+ Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textMargin03')
+ }
+ .key('flexTextMargin01')
+ .height(150)
+ .width(500)
+ .backgroundColor(0xAFEEEE)
+ }.width('100%')
+ }.width('100%')
+ }
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexVisibility.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexVisibility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..d4587e2736552e3a579d8bd0fbeb060dfa27551f
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexVisibility.ets
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 {MessageManager,Callback} from '../../../../common/MessageManager';
+@Entry
+@Component
+struct FlexVisibility_Auto {
+ @State testVisibility: number = Visibility.Visible
+ messageManager:MessageManager = new MessageManager()
+ private content: string = "FlexVisibility_Auto Page"
+ onPageShow() {
+ console.info('FlexVisibility_Auto onPageShow');
+ globalThis.value = {
+ name:'messageManager',message:this.messageManager
+ }
+ let callback:Callback = (message:any) => {
+ console.error('message = ' + message.name + "--" + message.value);
+ if (message.name == 'visibility') {
+ this.testVisibility = message.value;
+ }
+ }
+ this.messageManager.registerCallback(callback);
+ }
+ onBuildDone() {
+ console.info('FlexVisibility_Auto page build done called');
+ }
+
+ build() {
+ Column() {
+ Column() {
+ Text('FlexTest10').fontSize(9).fontColor(0xCCCCCC).width('90%')
+ Flex({
+ direction: FlexDirection.Row,
+ alignItems: ItemAlign.Auto,
+ wrap: FlexWrap.NoWrap,
+ }) {
+ Text('1').width(150).height(50).backgroundColor(0xF5DEB3).visibility(this.testVisibility).key('textVisible01')
+ Text('2').width(150).height(100).backgroundColor(0xD2B48C).key('textVisible02')
+ Text('3').width(150).height(150).backgroundColor(0xF5DEB3).key('textVisible03')
+ }
+ .key('flexVisible')
+ .height(150)
+ .width(500)
+ .backgroundColor(0xAFEEEE)
+ }.width('100%').margin({ top: 5 })
+ }.width('100%')
+ }
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/index/index.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/index/index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..156b4f744b8fdf79d323624ecf135a027e821980
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/index/index.ets
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 router from '@ohos.router';
+import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
+import { Hypium } from '@ohos/hypium'
+import testsuite from '../../../test/List.test'
+
+
+@Entry
+@Component
+struct Index {
+
+ aboutToAppear(){
+ console.info("start run testcase!!!!")
+ var abilityDelegator: any
+ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+ var abilityDelegatorArguments: any
+ abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ console.info('start run testcase!!!')
+ Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
+ }
+
+ build() {
+ Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
+ Text('Hello World')
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ Button() {
+ Text('next page')
+ .fontSize(25)
+ .fontWeight(FontWeight.Bold)
+ }.type(ButtonType.Capsule)
+ .margin({
+ top: 20
+ })
+ .backgroundColor('#0D9FFB')
+ .onClick(() => {
+
+ })
+ }
+ .width('100%')
+ .height('100%')
+ }
+}
\ No newline at end of file
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/TestAbility/TestAbility.ts b/arkui/ace_ets_layout_test/entry/src/main/ets/TestAbility/TestAbility.ts
new file mode 100644
index 0000000000000000000000000000000000000000..acac5240bdbc002e4a864ffbdd8d59be186d37e7
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/TestAbility/TestAbility.ts
@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 Ability from '@ohos.app.ability.UIAbility'
+
+export default class TestAbility extends Ability {
+ onCreate(want, launchParam) {
+ console.log('TestAbility onCreate')
+ }
+
+ onDestroy() {
+ console.log('TestAbility onDestroy')
+ }
+
+ onWindowStageCreate(windowStage) {
+ console.log('TestAbility onWindowStageCreate')
+ windowStage.loadContent("TestAbility/pages/index", (err, data) => {
+ if (err.code) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
+ });
+
+ globalThis.abilityContext = this.context;
+ }
+
+ onWindowStageDestroy() {
+ console.log('TestAbility onWindowStageDestroy')
+ }
+
+ onForeground() {
+ console.log('TestAbility onForeground')
+ }
+
+ onBackground() {
+ console.log('TestAbility onBackground')
+ }
+};
\ No newline at end of file
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/TestAbility/pages/index.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/TestAbility/pages/index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ec1e9440615c7a9c1af56204b9251428cbd57879
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/TestAbility/pages/index.ets
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 router from '@ohos.router';
+
+@Entry
+@Component
+struct Index {
+ aboutToAppear() {
+ console.info('TestAbility index aboutToAppear')
+ }
+ @State message: string = 'Hello World'
+ build() {
+ Row() {
+ Column() {
+ Text(this.message)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ Button() {
+ Text('next page')
+ .fontSize(20)
+ .fontWeight(FontWeight.Bold)
+ }.type(ButtonType.Capsule)
+ .margin({
+ top: 20
+ })
+ .backgroundColor('#0D9FFB')
+ .width('35%')
+ .height('5%')
+ .onClick(()=>{
+ })
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+ }
\ No newline at end of file
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/arkui/ace_ets_layout_test/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
new file mode 100644
index 0000000000000000000000000000000000000000..c9a13942e3703e5f27bc8b46c791ff03989ccdc1
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 TestRunner from '@ohos.application.testRunner'
+import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
+
+var abilityDelegator = undefined
+var abilityDelegatorArguments = undefined
+
+function translateParamsToString(parameters) {
+ const keySet = new Set([
+ '-s class', '-s notClass', '-s suite', '-s it',
+ '-s level', '-s testType', '-s size', '-s timeout',
+ '-s dryRun'
+ ])
+ let targetParams = '';
+ for (const key in parameters) {
+ if (keySet.has(key)) {
+ targetParams = `${targetParams} ${key} ${parameters[key]}`
+ }
+ }
+ return targetParams.trim()
+}
+
+async function onAbilityCreateCallback() {
+ console.log("onAbilityCreateCallback");
+}
+
+async function addAbilityMonitorCallback(err: any) {
+ console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
+}
+
+export default class OpenHarmonyTestRunner implements TestRunner {
+ constructor() {
+ }
+
+ onPrepare() {
+ console.info("OpenHarmonyTestRunner OnPrepare ")
+ }
+
+ async onRun() {
+ console.log('OpenHarmonyTestRunner onRun run')
+ abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+ var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
+ let lMonitor = {
+ abilityName: testAbilityName,
+ onAbilityCreate: onAbilityCreateCallback,
+ };
+ abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
+ var cmd = 'aa start -d 0 -a com.acts.arkui.layout.test.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
+ cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
+ var debug = abilityDelegatorArguments.parameters["-D"]
+ if (debug == 'true')
+ {
+ cmd += ' -D'
+ }
+ console.info('cmd : '+cmd)
+ abilityDelegator.executeShellCommand(cmd,
+ (err: any, d: any) => {
+ console.info('executeShellCommand : err : ' + JSON.stringify(err));
+ console.info('executeShellCommand : data : ' + d.stdResult);
+ console.info('executeShellCommand : data : ' + d.exitCode);
+ })
+ console.info('OpenHarmonyTestRunner onRun end')
+ }
+};
\ No newline at end of file
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexAlignSelfJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexAlignSelfJsunit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..618e31471a7a45b4ff9bae5abec535b8ab36123b
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexAlignSelfJsunit.test.ets
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
+import router from '@system.router';
+import CommonFunc from "../../../../MainAbility/common/Common";
+
+export default function flexAlignSelf_AutoJsunit() {
+ describe('flexItemAlignAutoTest', function () {
+ beforeEach(async function (done) {
+ let options = {
+ uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexAlignSelf',
+ }
+ try {
+ router.clear();
+ await CommonFunc.sleep(1000);
+ let pages = router.getState();
+ console.info("get FlexSecond state success " + JSON.stringify(pages));
+ if (!("FlexSecond" == pages.name)) {
+ console.info("get FlexSecond state success " + JSON.stringify(pages.name));
+ let result = await router.push(options)
+ console.info("push FlexSecond page success " + JSON.stringify(result));
+ }
+ } catch (err) {
+ console.error("push FlexSecond page error " + JSON.stringify(err));
+ }
+ await CommonFunc.sleep(2000);
+ done()
+ });
+
+ afterEach(async function () {
+ await CommonFunc.sleep(1000);
+ console.info("FlexSecond after each called");
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_1200
+ * @tc.name ItemAlign_Auto_FlexAlignSelf
+ * @tc.desc aceFlexAlignItemTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_1200', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_1200 START');
+ let strJson1 = getInspectorByKey('flexAlignSelf');
+ let obj1 = JSON.parse(strJson1);
+ let strJson2 = getInspectorByKey('textAlignSelf01');
+ let obj2 = JSON.parse(strJson2);
+ let textAlignSelf01 = CommonFunc.getComponentRect('textAlignSelf01');
+ let textAlignSelf02 = CommonFunc.getComponentRect('textAlignSelf02');
+ let textAlignSelf03 = CommonFunc.getComponentRect('textAlignSelf03');
+ let flexAlignSelf01 = CommonFunc.getComponentRect('flexAlignSelf');
+ expect(textAlignSelf01.left).assertEqual(flexAlignSelf01.left)
+ expect(textAlignSelf01.right).assertEqual(textAlignSelf02.left)
+ expect(textAlignSelf01.top).assertEqual(textAlignSelf02.top)
+ expect(textAlignSelf02.top).assertEqual(textAlignSelf03.top)
+ expect(textAlignSelf01.bottom).assertEqual(flexAlignSelf01.bottom)
+
+ expect(textAlignSelf01.bottom - textAlignSelf01.top).assertEqual(vp2px(50))
+ expect(textAlignSelf01.right - textAlignSelf01.left).assertEqual(vp2px(150))
+ expect(textAlignSelf02.bottom - textAlignSelf02.top).assertEqual(vp2px(100))
+ expect(textAlignSelf02.right - textAlignSelf02.left).assertEqual(vp2px(150))
+ expect(textAlignSelf03.bottom - textAlignSelf03.top).assertEqual(vp2px(150))
+ expect(textAlignSelf03.right - textAlignSelf03.left).assertEqual(vp2px(150))
+
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ expect(obj2.$attrs.alignSelf).assertEqual("ItemAlign.End")
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_1200 END');
+ done();
+ });
+ })
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexBaseJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexBaseJsunit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..d2a018cc381b31072f9e3f4271dc401818e9a13e
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexBaseJsunit.test.ets
@@ -0,0 +1,118 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
+import router from '@system.router';
+import CommonFunc from "../../../../MainAbility/common/Common";
+import {MessageManager,Callback} from '../../../../MainAbility/common/MessageManager';
+export default function flexBase_AutoJsunit() {
+ describe('flexItemAlignAutoTest', function () {
+ beforeEach(async function (done) {
+ let options = {
+ uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexBase',
+ }
+ try {
+ router.clear();
+ await CommonFunc.sleep(1000);
+ let pages = router.getState();
+ console.info("get FlexBase state success " + JSON.stringify(pages));
+ if (!("FlexBase" == pages.name)) {
+ console.info("get FlexBase state success " + JSON.stringify(pages.name));
+ let result = await router.push(options)
+ console.info("push FlexBase page success " + JSON.stringify(result));
+ }
+ } catch (err) {
+ console.error("push FlexBase page error " + JSON.stringify(err));
+ }
+ await CommonFunc.sleep(2000);
+ done()
+ });
+ afterEach(async function () {
+ await CommonFunc.sleep(1000);
+ console.info("FlexBase after each called");
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_0100
+ * @tc.name ItemAlign_Auto_FlexBase
+ * @tc.desc aceFlexAlignItemTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_0100', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0100 START');
+ globalThis.value.message.notify({name:'height', value:200});
+ globalThis.value.message.notify({name:'width', value:500});
+ await CommonFunc.sleep(2000);
+ let strJson1 = getInspectorByKey('flex01');
+ let obj1 = JSON.parse(strJson1);
+ let textFlex01 = CommonFunc.getComponentRect('textFlex01');
+ let textFlex02 = CommonFunc.getComponentRect('textFlex02');
+ let textFlex03 = CommonFunc.getComponentRect('textFlex03');
+ let flex01 = CommonFunc.getComponentRect('flex01');
+ expect(flex01.top).assertEqual(textFlex01.top)
+ expect(textFlex01.top).assertEqual(textFlex02.top)
+ expect(textFlex02.top).assertEqual(textFlex03.top)
+
+ expect(textFlex01.right).assertEqual(textFlex02.left)
+ expect(textFlex02.right).assertEqual(textFlex03.left)
+ expect(flex01.right - textFlex03.right).assertEqual(vp2px(50))
+
+ expect(textFlex01.bottom - textFlex01.top).assertEqual(vp2px(50))
+ expect(textFlex02.bottom - textFlex02.top).assertEqual(vp2px(100))
+ expect(textFlex03.bottom - textFlex03.top).assertEqual(vp2px(150))
+ expect(textFlex01.right - textFlex01.left).assertEqual(vp2px(150))
+ expect(textFlex02.right - textFlex02.left).assertEqual(vp2px(150))
+ expect(textFlex03.right - textFlex03.left).assertEqual(vp2px(150))
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0100 END');
+ done();
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_0200
+ * @tc.name ItemAlign_Auto_FlexBase
+ * @tc.desc aceFlexAlignItemTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_0200', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0200 START');
+ globalThis.value.message.notify({name:'height', value:140});
+ globalThis.value.message.notify({name:'width', value:420});
+ await CommonFunc.sleep(2000);
+ let strJson1 = getInspectorByKey('flex01');
+ let obj1 = JSON.parse(strJson1);
+ let textFlex01 = CommonFunc.getComponentRect('textFlex01');
+ let textFlex02 = CommonFunc.getComponentRect('textFlex02');
+ let textFlex03 = CommonFunc.getComponentRect('textFlex03');
+ let flex01 = CommonFunc.getComponentRect('flex01');
+ expect(flex01.top).assertEqual(textFlex01.top)
+ expect(textFlex01.top).assertEqual(textFlex02.top)
+ expect(textFlex02.top).assertEqual(textFlex03.top)
+
+ expect(textFlex03.right).assertEqual(flex01.right)
+ expect(textFlex03.bottom).assertLarger(flex01.bottom)
+ expect(textFlex01.bottom - textFlex01.top).assertEqual(vp2px(50))
+ expect(textFlex02.bottom - textFlex02.top).assertEqual(vp2px(100))
+ expect(textFlex03.bottom - textFlex03.top).assertEqual(vp2px(150))
+ expect(textFlex01.right - textFlex01.left).assertEqual(vp2px(140))
+ expect(textFlex02.right - textFlex02.left).assertEqual(vp2px(140))
+ expect(textFlex03.right - textFlex03.left).assertEqual(vp2px(140))
+
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0200 END');
+ done();
+ });
+ })
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexExceedJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexExceedJsunit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..399dd9604d1109d8f4053eb0eda4b034a530dc8e
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexExceedJsunit.test.ets
@@ -0,0 +1,113 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
+import router from '@system.router';
+import CommonFunc from "../../../../MainAbility/common/Common";
+import {MessageManager,Callback} from '../../../../MainAbility/common/MessageManager';
+export default function flexExceed_AutoJsunit() {
+ describe('flexItemAlignAutoTest', function () {
+ beforeEach(async function (done) {
+ let options = {
+ uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexExceed',
+ }
+ try {
+ router.clear();
+ await CommonFunc.sleep(1000);
+ let pages = router.getState();
+ console.info("get FlexExceed state success " + JSON.stringify(pages));
+ if (!("FlexExceed" == pages.name)) {
+ console.info("get FlexExceed state success " + JSON.stringify(pages.name));
+ let result = await router.push(options)
+ console.info("push FlexExceed page success " + JSON.stringify(result));
+ }
+ } catch (err) {
+ console.error("push FlexExceed page error " + JSON.stringify(err));
+ }
+ await CommonFunc.sleep(2000);
+ done()
+ });
+ afterEach(async function () {
+ await CommonFunc.sleep(1000);
+ console.info("FlexExceed after each called");
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_0600
+ * @tc.name ItemAlign_Auto_FlexExceed
+ * @tc.desc aceEtsTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_0600', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0600 START');
+ globalThis.value.message.notify({name:'padding', value:10})
+ globalThis.value.message.notify({name:'margin', value:10})
+ await CommonFunc.sleep(2000);
+ let strJson1 = getInspectorByKey('flexExceed01');
+ let obj1 = JSON.parse(strJson1);
+ let textExceed01 = CommonFunc.getComponentRect('textExceed01');
+ let textExceed02 = CommonFunc.getComponentRect('textExceed02');
+ let textExceed03 = CommonFunc.getComponentRect('textExceed03');
+ let flexExceed01 = CommonFunc.getComponentRect('flexExceed01');
+ expect(textExceed01.top).assertEqual(textExceed02.top)
+ expect(textExceed02.top).assertEqual(textExceed03.top)
+ expect(textExceed01.top).assertLarger(flexExceed01.top)
+ expect(textExceed01.left).assertLarger(flexExceed01.left)
+ expect(textExceed03.right).assertLess(flexExceed01.right)
+ expect(textExceed01.bottom - textExceed01.top).assertEqual(vp2px(50))
+ expect(textExceed02.bottom - textExceed02.top).assertEqual(vp2px(100))
+ expect(textExceed03.bottom - textExceed03.top).assertEqual(vp2px(150))
+ expect(textExceed01.right - textExceed01.left).assertEqual(vp2px(150))
+ expect(textExceed02.right - textExceed02.left).assertEqual(vp2px(150))
+ expect(textExceed03.right - textExceed03.left).assertEqual(vp2px(150))
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0600 END');
+ done();
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_0700
+ * @tc.name ItemAlign_Auto_FlexExceed
+ * @tc.desc aceFlexAlignItemTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_0700', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0700 START');
+ globalThis.value.message.notify({name:'padding', value:30});
+ globalThis.value.message.notify({name:'margin', value:30});
+ await CommonFunc.sleep(2000);
+ let strJson1 = getInspectorByKey('flexExceed01');
+ let obj1 = JSON.parse(strJson1);
+ let textExceed01 = CommonFunc.getComponentRect('textExceed01');
+ let textExceed02 = CommonFunc.getComponentRect('textExceed02');
+ let textExceed03 = CommonFunc.getComponentRect('textExceed03');
+ let flexExceed01 = CommonFunc.getComponentRect('flexExceed01');
+ expect(textExceed01.top).assertEqual(textExceed02.top)
+ expect(textExceed02.top).assertEqual(textExceed03.top)
+ expect(textExceed01.top).assertLarger(flexExceed01.top)
+ expect(textExceed01.left).assertLarger(flexExceed01.left)
+ expect(textExceed03.right).assertLess(flexExceed01.right)
+ expect(textExceed01.bottom - textExceed01.top).assertEqual(vp2px(50))
+ expect(textExceed02.bottom - textExceed02.top).assertEqual(vp2px(100))
+ expect(textExceed03.bottom - textExceed03.top).assertEqual(vp2px(150))
+ expect(textExceed01.right - textExceed01.left).assertEqual(vp2px(440/3))
+ expect(textExceed02.right - textExceed02.left).assertEqual(vp2px(440/3))
+ expect(textExceed03.right - textExceed03.left).assertEqual(vp2px(440/3))
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0700 END');
+ done();
+ });
+ })
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexHeightModifyJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexHeightModifyJsunit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..e8a0d81797613a30ba5726177682aabf2a27c2b4
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexHeightModifyJsunit.test.ets
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
+import router from '@system.router';
+import CommonFunc from "../../../../MainAbility/common/Common";
+import {MessageManager,Callback} from '../../../../MainAbility/common/MessageManager';
+export default function flexHeightModify_AutoJsunit() {
+ describe('flexItemAlignAutoTest', function () {
+ beforeEach(async function (done) {
+ let options = {
+ uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexHeightModify',
+ }
+ try {
+ router.clear();
+ await CommonFunc.sleep(1000);
+ let pages = router.getState();
+ console.info("get FlexHeightModify state success " + JSON.stringify(pages));
+ if (!("FlexHeightModify" == pages.name)) {
+ console.info("get FlexHeightModify state success " + JSON.stringify(pages.name));
+ let result = await router.push(options)
+ console.info("push FlexHeightModify page success " + JSON.stringify(result));
+ }
+ } catch (err) {
+ console.error("push FlexHeightModify page error " + JSON.stringify(err));
+ }
+ await CommonFunc.sleep(2000);
+ done()
+ });
+ afterEach(async function () {
+ await CommonFunc.sleep(1000);
+ console.info("FlexHeightModify after each called");
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_0800
+ * @tc.name ItemAlign_Auto_FlexHeightModify
+ * @tc.desc aceFlexAlignItemTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_0800', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0800 START');
+ globalThis.value.message.notify({name:'height', value:80})
+ await CommonFunc.sleep(2000);
+ let strJson1 = getInspectorByKey('flexHeightModify');
+ let obj1 = JSON.parse(strJson1);
+ let textHeightModify01 = CommonFunc.getComponentRect('textHeightModify01');
+ let textHeightModify02 = CommonFunc.getComponentRect('textHeightModify02');
+ let textHeightModify03 = CommonFunc.getComponentRect('textHeightModify03');
+ let flexHeightModify = CommonFunc.getComponentRect('flexHeightModify');
+
+ expect(textHeightModify01.top).assertEqual(textHeightModify02.top)
+ expect(textHeightModify02.top).assertEqual(textHeightModify03.top)
+ expect(textHeightModify01.top).assertEqual(flexHeightModify.top)
+
+ expect(textHeightModify01.left).assertEqual(flexHeightModify.left)
+ expect(textHeightModify02.left).assertEqual(textHeightModify01.right)
+
+ expect(textHeightModify01.bottom - textHeightModify01.top).assertEqual(vp2px(80))
+ expect(textHeightModify02.bottom - textHeightModify02.top).assertEqual(vp2px(100))
+ expect(textHeightModify03.bottom - textHeightModify03.top).assertEqual(vp2px(150))
+ expect(textHeightModify01.right - textHeightModify01.left).assertEqual(vp2px(150))
+ expect(textHeightModify02.right - textHeightModify02.left).assertEqual(vp2px(150))
+ expect(textHeightModify03.right - textHeightModify03.left).assertEqual(vp2px(150))
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0800 END');
+ done();
+ });
+ })
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexMarginJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexMarginJsunit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..17dab8740ebf8637088125ea0e6ea95ee78e098f
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexMarginJsunit.test.ets
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
+import router from '@system.router';
+import CommonFunc from "../../../../MainAbility/common/Common";
+
+export default function flexMargin_AutoJsunit() {
+ describe('flexItemAlignAutoTest', function () {
+ beforeEach(async function (done) {
+ let options = {
+ uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexMargin',
+ }
+ try {
+ router.clear();
+ await CommonFunc.sleep(1000);
+ let pages = router.getState();
+ console.info("get FlexMargin state success " + JSON.stringify(pages));
+ if (!("FlexMargin" == pages.name)) {
+ console.info("get FlexMargin state success " + JSON.stringify(pages.name));
+ let result = await router.push(options)
+ console.info("push FlexMargin page success " + JSON.stringify(result));
+ }
+ } catch (err) {
+ console.error("push FlexMargin page error " + JSON.stringify(err));
+ }
+ await CommonFunc.sleep(2000);
+ done()
+ });
+ afterEach(async function () {
+ await CommonFunc.sleep(1000);
+ console.info("FlexMargin after each called");
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_0500
+ * @tc.name ItemAlign_Auto_FlexMargin
+ * @tc.desc aceFlexAlignItemTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_0500', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0500 START');
+ let strJson1 = getInspectorByKey('flexMargin');
+ let obj1 = JSON.parse(strJson1);
+ let textFlexMargin01 = CommonFunc.getComponentRect('textFlexMargin01');
+ let textFlexMargin02 = CommonFunc.getComponentRect('textFlexMargin02');
+ let textFlexMargin03 = CommonFunc.getComponentRect('textFlexMargin03');
+ let flexMargin = CommonFunc.getComponentRect('flexMargin');
+
+ expect(textFlexMargin01.top).assertEqual(textFlexMargin02.top)
+ expect(textFlexMargin02.top).assertEqual(textFlexMargin03.top)
+ expect(textFlexMargin03.right).assertLess(flexMargin.right)
+ expect(textFlexMargin01.left).assertLarger(flexMargin.left)
+ expect(textFlexMargin01.bottom - textFlexMargin01.top).assertEqual(vp2px(50))
+ expect(textFlexMargin02.bottom - textFlexMargin02.top).assertEqual(vp2px(100))
+ expect(textFlexMargin03.bottom - textFlexMargin03.top).assertEqual(vp2px(150))
+ expect(textFlexMargin01.right - textFlexMargin01.left).assertEqual(vp2px(150))
+ expect(textFlexMargin02.right - textFlexMargin02.left).assertEqual(vp2px(150))
+ expect(textFlexMargin03.right - textFlexMargin03.left).assertEqual(vp2px(150))
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0500 END');
+ done();
+ });
+
+ })
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexOffsetJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexOffsetJsunit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0d7acbe46a2953577a2cbb44cd0cc9c2027a75af
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexOffsetJsunit.test.ets
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
+import router from '@system.router';
+import CommonFunc from "../../../../MainAbility/common/Common";
+
+export default function flexOffset_AutoJsunit() {
+ describe('flexItemAlignAutoTest', function () {
+ beforeEach(async function (done) {
+ let options = {
+ uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexOffset',
+ }
+ try {
+ router.clear();
+ await CommonFunc.sleep(1000);
+ let pages = router.getState();
+ console.info("get flexOffsetTest state success " + JSON.stringify(pages));
+ if (!("flexOffsetTest" == pages.name)) {
+ console.info("get flexOffsetTest state success " + JSON.stringify(pages.name));
+ let result = await router.push(options)
+ console.info("push flexOffsetTest page success " + JSON.stringify(result));
+ }
+ } catch (err) {
+ console.error("push flexOffsetTest page error " + JSON.stringify(err));
+ }
+ await CommonFunc.sleep(2000);
+ done()
+ });
+ afterEach(async function () {
+ await CommonFunc.sleep(1000);
+ console.info("flexOffsetTest after each called");
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_0900
+ * @tc.name ItemAlign_Auto_FlexOffset
+ * @tc.desc aceFlexAlignItemTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_0900', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0900 START');
+ let strJson1 = getInspectorByKey('flexOffset');
+ let obj1 = JSON.parse(strJson1);
+ let textOffset01 = CommonFunc.getComponentRect('textOffset01');
+ let textOffset02 = CommonFunc.getComponentRect('textOffset02');
+ let textOffset03 = CommonFunc.getComponentRect('textOffset03');
+ let flexOffset = CommonFunc.getComponentRect('flexOffset');
+ expect(textOffset01.right - textOffset02.left).assertEqual(vp2px(15))
+ expect(textOffset01.top - flexOffset.top).assertEqual(vp2px(30))
+ expect(textOffset01.left - flexOffset.left).assertEqual(vp2px(15))
+ expect(textOffset02.top).assertEqual(textOffset03.top)
+ expect(textOffset03.top).assertEqual(flexOffset.top)
+
+ expect(textOffset01.bottom - textOffset01.top).assertEqual(vp2px(50))
+ expect(textOffset02.bottom - textOffset02.top).assertEqual(vp2px(100))
+ expect(textOffset03.bottom - textOffset03.top).assertEqual(vp2px(150))
+ expect(textOffset01.right - textOffset01.left).assertEqual(vp2px(150))
+ expect(textOffset02.right - textOffset02.left).assertEqual(vp2px(150))
+ expect(textOffset03.right - textOffset03.left).assertEqual(vp2px(150))
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0900 END');
+ done();
+ });
+ })
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexPaddingJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexPaddingJsunit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..525dc009f6ac60bc5ef25cbd22696d6eba26b818
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexPaddingJsunit.test.ets
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
+import router from '@system.router';
+import CommonFunc from "../../../../MainAbility/common/Common";
+import {MessageManager,Callback} from '../../../../MainAbility/common/MessageManager';
+export default function flexPadding_AutoJsunit() {
+
+ describe('flexItemAlignAutoTest', function () {
+ beforeEach(async function (done) {
+ let options = {
+ uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexPadding',
+ }
+ try {
+ router.clear();
+ await CommonFunc.sleep(1000);
+ let pages = router.getState();
+ console.info("get FlexPadding state success " + JSON.stringify(pages));
+ if (!("FlexPadding" == pages.name)) {
+ console.info("get FlexPadding state success " + JSON.stringify(pages.name));
+ let result = await router.push(options)
+ console.info("push FlexPadding page success " + JSON.stringify(result));
+ }
+ } catch (err) {
+ console.error("push FlexPadding page error " + JSON.stringify(err));
+ }
+ await CommonFunc.sleep(2000);
+ done()
+ });
+ afterEach(async function () {
+ await CommonFunc.sleep(1000);
+ console.info("FlexPadding after each called");
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_0300
+ * @tc.name ItemAlign_Auto_testFlexPadding
+ * @tc.desc aceFlexAlignItemTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_0300', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0300 START');
+ globalThis.value.message.notify({name:'padding', value:10})
+ await CommonFunc.sleep(2000);
+ let strJson1 = getInspectorByKey('flexPadding01');
+ let obj1 = JSON.parse(strJson1);
+ let textFlexPadding01 = CommonFunc.getComponentRect('textFlexPadding01')
+ let textFlexPadding02 = CommonFunc.getComponentRect('textFlexPadding02')
+ let textFlexPadding03 = CommonFunc.getComponentRect('textFlexPadding03')
+ let flexPadding01 = CommonFunc.getComponentRect('flexPadding01')
+
+ expect(textFlexPadding01.top).assertEqual(textFlexPadding02.top)
+ expect(textFlexPadding02.top).assertEqual(textFlexPadding03.top)
+ expect(textFlexPadding01.top - flexPadding01.top).assertEqual(vp2px(10))
+ expect(textFlexPadding03.right).assertLess(flexPadding01.right)
+
+ expect(textFlexPadding01.bottom - textFlexPadding01.top).assertEqual(vp2px(50))
+ expect(textFlexPadding02.bottom - textFlexPadding02.top).assertEqual(vp2px(100))
+ expect(textFlexPadding03.bottom - textFlexPadding03.top).assertEqual(vp2px(150))
+
+ expect(textFlexPadding01.right - textFlexPadding01.left).assertEqual(vp2px(150))
+ expect(textFlexPadding02.right - textFlexPadding02.left).assertEqual(vp2px(150))
+ expect(textFlexPadding03.right - textFlexPadding03.left).assertEqual(vp2px(150))
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0300 END');
+ done();
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_0400
+ * @tc.name ItemAlign_Auto_FlexPadding
+ * @tc.desc aceFlexAlignItemTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_0400', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0400 START');
+ globalThis.value.message.notify({name:'padding', value:30});
+ await CommonFunc.sleep(2000);
+ let strJson1 = getInspectorByKey('flexPadding01');
+ let obj1 = JSON.parse(strJson1);
+ let textFlexPadding01 = CommonFunc.getComponentRect('textFlexPadding01');
+ let textFlexPadding02 = CommonFunc.getComponentRect('textFlexPadding02');
+ let textFlexPadding03 = CommonFunc.getComponentRect('textFlexPadding03');
+ let flexPadding01 = CommonFunc.getComponentRect('flexPadding01');
+ expect(textFlexPadding01.top).assertEqual(textFlexPadding02.top)
+ expect(textFlexPadding02.top).assertEqual(textFlexPadding03.top)
+ expect(textFlexPadding01.top - flexPadding01.top).assertEqual(vp2px(30))
+ expect(textFlexPadding03.right).assertLess(flexPadding01.right)
+
+ expect(textFlexPadding01.bottom - textFlexPadding01.top).assertEqual(vp2px(50))
+ expect(textFlexPadding02.bottom - textFlexPadding02.top).assertEqual(vp2px(100))
+ expect(textFlexPadding03.bottom - textFlexPadding03.top).assertEqual(vp2px(150))
+ expect(textFlexPadding01.right - textFlexPadding01.left).assertEqual(vp2px(440/3))
+ expect(textFlexPadding02.right - textFlexPadding02.left).assertEqual(vp2px(440/3))
+ expect(textFlexPadding03.right - textFlexPadding03.left).assertEqual(vp2px(440/3))
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0400 END');
+ done();
+ });
+ })
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexTextMarginJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexTextMarginJsunit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..a8c06de042200db7c9619e7298336fa7eb37b23e
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexTextMarginJsunit.test.ets
@@ -0,0 +1,114 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
+import router from '@system.router';
+import CommonFunc from "../../../../MainAbility/common/Common";
+import {MessageManager,Callback} from '../../../../MainAbility/common/MessageManager';
+export default function flexTextMargin_AutoJsunit() {
+
+ describe('flexItemAlignAutoTest', function () {
+ beforeEach(async function (done) {
+ let options = {
+ uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexTextMargin',
+ }
+ try {
+ router.clear();
+ await CommonFunc.sleep(1000);
+ let pages = router.getState();
+ console.info("get FlexTextMargin state success " + JSON.stringify(pages));
+ if (!("FlexTextMargin" == pages.name)) {
+ console.info("get FlexTextMargin state success " + JSON.stringify(pages.name));
+ let result = await router.push(options)
+ console.info("push FlexTextMargin page success " + JSON.stringify(result));
+ }
+ } catch (err) {
+ console.error("push FlexTextMargin page error " + JSON.stringify(err));
+ }
+ await CommonFunc.sleep(2000);
+ done()
+ });
+ afterEach(async function () {
+ await CommonFunc.sleep(1000);
+ console.info("FlexTextMargin after each called");
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_1300
+ * @tc.name ItemAlign_Auto_TextMargin
+ * @tc.desc aceFlexAlignItemTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_1300', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_1300 START');
+ globalThis.value.message.notify({name:'margin', value:10});
+ await CommonFunc.sleep(2000);
+ let strJson1 = getInspectorByKey('flexTextMargin01');
+ let obj1 = JSON.parse(strJson1);
+ let textMargin01 = CommonFunc.getComponentRect('textMargin01');
+ let textMargin02 = CommonFunc.getComponentRect('textMargin02');
+ let textMargin03 = CommonFunc.getComponentRect('textMargin03');
+ let flexTextMargin01 = CommonFunc.getComponentRect('flexTextMargin01');
+ expect(textMargin01.left - flexTextMargin01.left).assertEqual(vp2px(10))
+ expect(textMargin02.left).assertEqual(textMargin01.right)
+ expect(textMargin03.right).assertLess(flexTextMargin01.right)
+ expect(textMargin01.top).assertEqual(textMargin02.top)
+ expect(textMargin02.top).assertEqual(textMargin03.top)
+ expect(textMargin02.top).assertEqual(flexTextMargin01.top)
+ expect(textMargin01.bottom - textMargin01.top).assertEqual(vp2px(70))
+ expect(textMargin02.bottom - textMargin02.top).assertEqual(vp2px(100))
+ expect(textMargin03.bottom - textMargin03.top).assertEqual(vp2px(150))
+ expect(textMargin01.right - textMargin01.left).assertEqual(vp2px(170))
+ expect(textMargin02.right - textMargin02.left).assertEqual(vp2px(150))
+ expect(textMargin03.right - textMargin03.left).assertEqual(vp2px(150))
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_1300 END');
+ done();
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_1400
+ * @tc.name ItemAlign_Auto_TextMargin
+ * @tc.desc aceFlexAlignItemTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_1400', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_1400 START');
+ globalThis.value.message.notify({name:'margin', value:30});
+ await CommonFunc.sleep(2000);
+ let strJson1 = getInspectorByKey('flexTextMargin01');
+ let obj1 = JSON.parse(strJson1);
+ let textMargin01 = CommonFunc.getComponentRect('textMargin01');
+ let textMargin02 = CommonFunc.getComponentRect('textMargin02');
+ let textMargin03 = CommonFunc.getComponentRect('textMargin03');
+ let flexTextMargin01 = CommonFunc.getComponentRect('flexTextMargin01');
+ expect(textMargin01.left - flexTextMargin01.left).assertEqual(vp2px(30))
+ expect(textMargin02.left).assertEqual(textMargin01.right)
+ expect(textMargin03.right).assertEqual(flexTextMargin01.right)
+ expect(textMargin01.top).assertEqual(textMargin02.top)
+ expect(textMargin02.top).assertEqual(textMargin03.top)
+ expect(textMargin02.top).assertEqual(flexTextMargin01.top)
+ expect(textMargin01.bottom - textMargin01.top).assertEqual(vp2px(50))
+ expect(textMargin02.bottom - textMargin02.top).assertEqual(vp2px(100))
+ expect(textMargin03.bottom - textMargin03.top).assertEqual(vp2px(150))
+ expect(textMargin01.right - textMargin01.left).assertLess(vp2px(150))
+ expect(textMargin02.right - textMargin02.left).assertLess(vp2px(150))
+ expect(textMargin03.right - textMargin03.left).assertLess(vp2px(150))
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_1400 END');
+ done();
+ });
+ })
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexVisibilityJsunit.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexVisibilityJsunit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..c494c78f3a47bdc6d2df4cf7aaa967cd756c5627
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Flex/alignItems/ItemAlign_Auto/FlexVisibilityJsunit.test.ets
@@ -0,0 +1,119 @@
+/**
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
+import router from '@system.router';
+import CommonFunc from "../../../../MainAbility/common/Common";
+import {MessageManager,Callback} from '../../../../MainAbility/common/MessageManager';
+export default function flexVisibility_AutoJsunit() {
+ describe('flexItemAlignAutoTest', function () {
+ beforeEach(async function (done) {
+ let options = {
+ uri: 'MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexVisibility',
+ }
+ try {
+ router.clear();
+ await CommonFunc.sleep(1000);
+ let pages = router.getState();
+ console.info("get FlexVisibility state success " + JSON.stringify(pages));
+ if (!("FlexVisibility" == pages.name)) {
+ console.info("get FlexVisibility state success " + JSON.stringify(pages.name));
+ let result = await router.push(options)
+ console.info("push FlexVisibility page success " + JSON.stringify(result));
+ }
+ } catch (err) {
+ console.error("push FlexVisibility page error " + JSON.stringify(err));
+ }
+ await CommonFunc.sleep(2000);
+ done()
+ });
+
+ afterEach(async function () {
+ await CommonFunc.sleep(1000);
+ console.info("FlexVisibility after each called");
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_1000
+ * @tc.name ItemAlign_Auto_FlexVisibility
+ * @tc.desc aceFlexAlignItemTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_1000', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_1000 START');
+ globalThis.value.message.notify({name:'visibility', value:Visibility.None})
+ await CommonFunc.sleep(2000);
+ let strJson1 = getInspectorByKey('flexVisible');
+ let obj1 = JSON.parse(strJson1);
+ let strJson2 = getInspectorByKey('textVisible01');
+ let obj2 = JSON.parse(strJson2);
+ let textVisible01 = CommonFunc.getComponentRect('textVisible01')
+ let textVisible02 = CommonFunc.getComponentRect('textVisible02')
+ let textVisible03 = CommonFunc.getComponentRect('textVisible03')
+ let flexVisible = CommonFunc.getComponentRect('flexVisible')
+
+ expect(textVisible01.left).assertEqual(textVisible01.right)
+ expect(textVisible01.right).assertEqual(flexVisible.left)
+ expect(textVisible02.top).assertEqual(textVisible03.top)
+ expect(textVisible03.top).assertEqual(flexVisible.top)
+
+ expect(textVisible02.bottom - textVisible02.top).assertEqual(vp2px(100))
+ expect(textVisible03.bottom - textVisible03.top).assertEqual(vp2px(150))
+ expect(textVisible02.right - textVisible02.left).assertEqual(vp2px(150))
+ expect(textVisible03.right - textVisible03.left).assertEqual(vp2px(150))
+
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ expect(obj2.$attrs.visibility).assertEqual("Visibility.None");
+
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_1000 END');
+ done();
+ });
+
+ /**
+ * @tc.number SUB_ACE_FLEXALIGNITEMS_AUTO_1100
+ * @tc.name ItemAlign_Auto_FlexVisibility
+ * @tc.desc aceFlexAlignItemTest
+ */
+ it('SUB_ACE_FLEXALIGNITEMS_AUTO_1100', 0, async function (done) {
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_1100 START');
+ globalThis.value.message.notify({name:'visibility', value:Visibility.Hidden});
+ await CommonFunc.sleep(2000);
+ let strJson1 = getInspectorByKey('flexVisible');
+ let obj1 = JSON.parse(strJson1);
+ let strJson2 = getInspectorByKey('textVisible01');
+ let obj2 = JSON.parse(strJson2);
+ let textVisible01 = CommonFunc.getComponentRect('textVisible01');
+ let textVisible02 = CommonFunc.getComponentRect('textVisible02');
+ let textVisible03 = CommonFunc.getComponentRect('textVisible03');
+ let flexVisible = CommonFunc.getComponentRect('flexVisible');
+ expect(textVisible01.left).assertEqual(flexVisible.left)
+ expect(textVisible01.right).assertEqual(textVisible02.left)
+ expect(textVisible02.top).assertEqual(textVisible03.top)
+ expect(textVisible03.top).assertEqual(flexVisible.top)
+
+ expect(textVisible01.bottom - textVisible01.top).assertEqual(vp2px(50))
+ expect(textVisible02.bottom - textVisible02.top).assertEqual(vp2px(100))
+ expect(textVisible03.bottom - textVisible03.top).assertEqual(vp2px(150))
+ expect(textVisible01.right - textVisible01.left).assertEqual(vp2px(150))
+ expect(textVisible02.right - textVisible02.left).assertEqual(vp2px(150))
+ expect(textVisible03.right - textVisible03.left).assertEqual(vp2px(150))
+ expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
+ expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
+ expect(obj2.$attrs.visibility).assertEqual("Visibility.Hidden");
+ console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_1100 END');
+ done();
+ });
+ })
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..dc2433a7eb72ee8f7cc68ff22cb71e36526c15ec
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2023-2030 iSoftStone Information Technology (Group) 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 flexBase_AutoJsunit from './Flex/alignItems/ItemAlign_Auto/FlexBaseJsunit.test.ets';
+ import flexPadding_AutoJsunit from './Flex/alignItems/ItemAlign_Auto/FlexPaddingJsunit.test.ets';
+ import flexMargin_AutoJsunit from './Flex/alignItems/ItemAlign_Auto/FlexMarginJsunit.test.ets';
+ import flexExceed_AutoJsunit from './Flex/alignItems/ItemAlign_Auto/FlexExceedJsunit.test.ets';
+ import flexHeightModify_AutoJsunit from './Flex/alignItems/ItemAlign_Auto/FlexHeightModifyJsunit.test.ets';
+ import flexOffset_AutoJsunit from './Flex/alignItems/ItemAlign_Auto/FlexOffsetJsunit.test.ets';
+ import flexVisibility_AutoJsunit from './Flex/alignItems/ItemAlign_Auto/FlexVisibilityJsunit.test.ets';
+ import flexAlignSelf_AutoJsunit from './Flex/alignItems/ItemAlign_Auto/FlexAlignSelfJsunit.test.ets';
+ import flexTextMargin_AutoJsunit from './Flex/alignItems/ItemAlign_Auto/FlexTextMarginJsunit.test.ets';
+
+export default function testsuite() {
+ flexBase_AutoJsunit()
+ flexPadding_AutoJsunit()
+ flexMargin_AutoJsunit()
+ flexExceed_AutoJsunit()
+ flexHeightModify_AutoJsunit()
+ flexOffset_AutoJsunit()
+ flexVisibility_AutoJsunit()
+ flexAlignSelf_AutoJsunit()
+ flexTextMargin_AutoJsunit()
+}
\ No newline at end of file
diff --git a/arkui/ace_ets_layout_test/entry/src/main/module.json b/arkui/ace_ets_layout_test/entry/src/main/module.json
new file mode 100644
index 0000000000000000000000000000000000000000..c47f29d48c688a8aea01b5ce9864e76ac7acca6f
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/module.json
@@ -0,0 +1,39 @@
+{
+ "module": {
+ "name": "phone",
+ "type": "entry",
+ "srcEntrance": "./ets/Application/AbilityStage.ts",
+ "description": "$string:phone_entry_dsc",
+ "mainElement": "MainAbility",
+ "deviceTypes": [
+ "tablet",
+ "default",
+ "phone"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "uiSyntax": "ets",
+ "pages": "$profile:main_pages",
+ "abilities": [{
+ "name": "com.acts.arkui.layout.test.MainAbility",
+ "srcEntrance": "./ets/MainAbility/MainAbility.ts",
+ "description": "$string:phone_entry_main",
+ "icon": "$media:icon",
+ "label": "$string:entry_label",
+ "visible": true,
+ "orientation": "portrait",
+ "skills": [{
+ "actions": [
+ "action.system.home"
+ ],
+ "entities": [
+ "entity.system.home"
+ ]
+ }]
+ }],
+ "metadata":[{
+ "name":"ArkTSPartialUpdate",
+ "value":"true"
+ }]
+ }
+}
\ No newline at end of file
diff --git a/arkui/ace_ets_layout_test/entry/src/main/resources/base/element/string.json b/arkui/ace_ets_layout_test/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,32 @@
+{
+ "string": [
+ {
+ "name": "phone_entry_dsc",
+ "value": "i am an entry for phone"
+ },
+ {
+ "name": "phone_entry_main",
+ "value": "the phone entry ability"
+ },
+ {
+ "name": "entry_label",
+ "value": "ActsContextTest"
+ },
+ {
+ "name": "form_description",
+ "value": "my form"
+ },
+ {
+ "name": "serviceability_description",
+ "value": "my whether"
+ },
+ {
+ "name": "description_application",
+ "value": "demo for test"
+ },
+ {
+ "name": "app_name",
+ "value": "Demo"
+ }
+ ]
+}
diff --git a/arkui/ace_ets_layout_test/entry/src/main/resources/base/media/icon.png b/arkui/ace_ets_layout_test/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023
Binary files /dev/null and b/arkui/ace_ets_layout_test/entry/src/main/resources/base/media/icon.png differ
diff --git a/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json b/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..3eebebfe8292364be22ebccb8d0ce485ea126a6d
--- /dev/null
+++ b/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,14 @@
+{
+ "src": [
+ "MainAbility/pages/index/index",
+ "MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexBase",
+ "MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexPadding",
+ "MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexMargin",
+ "MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexExceed",
+ "MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexHeightModify",
+ "MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexOffset",
+ "MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexVisibility",
+ "MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexAlignSelf",
+ "MainAbility/pages/Flex/alignItems/ItemAlign_Auto/FlexTextMargin"
+ ]
+}
\ No newline at end of file
diff --git a/arkui/ace_ets_layout_test/signature/openharmony_sx.p7b b/arkui/ace_ets_layout_test/signature/openharmony_sx.p7b
new file mode 100644
index 0000000000000000000000000000000000000000..de77b14599538e5185cbddf4c765ef9c905d2c34
Binary files /dev/null and b/arkui/ace_ets_layout_test/signature/openharmony_sx.p7b differ
diff --git a/arkui/ace_ets_webView/entry/src/main/ets/MainAbility/pages/webCovered.ets b/arkui/ace_ets_webView/entry/src/main/ets/MainAbility/pages/webCovered.ets
new file mode 100644
index 0000000000000000000000000000000000000000..fa1fea1847e4b16a14102ec0d7e0a0b5323bd040
--- /dev/null
+++ b/arkui/ace_ets_webView/entry/src/main/ets/MainAbility/pages/webCovered.ets
@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 web_webview from '@ohos.web.webview';
+import image from "@ohos.multimedia.image"
+
+@Entry
+@Component
+struct WebComponent {
+ controller: web_webview.WebviewController = new web_webview.WebviewController();
+ @State icon: image.PixelMap = undefined;
+ @State family: string = "serif";
+ @State fontSize: number = 13;
+
+ build() {
+ Column() {
+ Button('getBackForwardEntries').key("webCovered01")
+ .onClick(() => {
+ try {
+ let list = this.controller.getBackForwardEntries();
+ let historyItem = list.getItemAtIndex(list.currentIndex);
+ console.log("HistoryItem: " + JSON.stringify(historyItem));
+ this.icon = historyItem.icon;
+ } catch (error) {
+ console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
+ }
+ })
+ try {
+ let backData = {
+ data: {
+ "ACTION": this.icon
+ }
+ }
+ let backEvent = {
+ eventId:01,
+ priority:events_emitter.EventPriority.LOW
+ }
+ console.info("webFlag start to emit action state");
+ events_emitter.emit(backEvent, backData);
+ } catch (err) {
+ console.info("webFlag emit action state err: " + JSON.stringify(err));
+ }
+ }
+ Web({ src: 'www.example.com', controller: this.controller }).key("webCovered02")
+ .webSerifFont(this.family)
+ .webSansSerifFont(this.family)
+ .minLogicalFontSize(this.fontSize)
+ .onTouchIconUrlReceived((event) => {
+ console.log('onTouchIconUrlReceived:' + JSON.stringify(event))
+ })
+
+ Divider().width("3%")
+
+ Web({ src: 'www.example.com', controller: this.controller }).key("webCovered03")
+ .onDataResubmitted((event) => {
+ console.log('onDataResubmitted')
+ event.handler.resend();
+ })
+ }
+ }
+}
\ No newline at end of file
diff --git a/arkui/ace_ets_webView/entry/src/main/ets/MainAbility/test/WebViewCoveredJsunit.test.ets b/arkui/ace_ets_webView/entry/src/main/ets/MainAbility/test/WebViewCoveredJsunit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..82a93d4e3d4c1235141bd13b104bf23891ad3566
--- /dev/null
+++ b/arkui/ace_ets_webView/entry/src/main/ets/MainAbility/test/WebViewCoveredJsunit.test.ets
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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.ets"
+import router from '@system.router';
+
+export default function webViewCoveredJsunit() {
+ function sleep(time) {
+ return new Promise((resolve, reject) => {
+ setTimeout(() => {
+ resolve()
+ }, time * 1000)
+ }).then(() => {
+ console.info(`sleep ${time} over...`)
+ })
+ }
+
+ describe('WebViewCoveredTest', function () {
+ beforeEach(async function (done) {
+ console.info("WebViewCoveredTest beforeEach start");
+ let options = {
+ uri: 'pages/webCovered',
+ }
+ try {
+ router.clear();
+ let pages = router.getState();
+ console.info("get WebViewCovered state success " + JSON.stringify(pages));
+ if (!("WebViewCovered" == pages.name)) {
+ console.info("get WebViewCovered state success " + JSON.stringify(pages.name));
+ let result = await router.push(options)
+ console.info("push WebViewCovered page success " + JSON.stringify(result));
+ }
+ } catch (err) {
+ console.error("push WebViewCovered page error " + JSON.stringify(result));
+ }
+ await sleep(4)
+ done()
+ });
+
+ afterEach(async function () {
+ await sleep(1)
+ console.info("WebViewCovered after each called");
+ });
+
+
+
+ it('WebViewCoveredJsunit_01', 0, async function (done) {
+ console.info('[WebViewCoveredJsunit01] START');
+ try{
+ let callBack=(backData)=>{
+ console.info('WebViewCoveredJsunit01 get result is:'+JSON.stringify(backData));
+ expect(backData.data.ACTION).assertEqual(historyItem.icon);
+ console.info('[WebViewCoveredJsunit01] END');
+ done()
+ }
+ let innerEvent = {
+ eventId:01,
+ priority:events_emitter.EventPriority.LOW
+ }
+ events_emitter.on(innerEvent,callBack)
+ }catch(err){
+ console.info('[WebViewCoveredJsunit01] err:'+JSON.stringify(err));
+ }
+ }
+ sendEventByKey('webCovered01',10,'');
+ done();
+ });
+
+ it('WebViewCoveredJsunit_02', 0, async function (done) {
+ console.info('[WebViewCoveredJsunit02] START');
+ await Utils.sleep(1000);
+ let strJson = getInspectorByKey('webCovered02');
+ let obj = JSON.parse(strJson);
+ console.info("[WebViewCoveredJsunit02] component obj is: " + JSON.stringify(obj));
+ expect(obj.$attrs.webSerifFont).assertEqual("serif");
+ expect(obj.$attrs.webSansSerifFont).assertEqual("serif");
+ expect(obj.$attrs.minLogicalFontSize).assertEqual(13);
+ done();
+ });
+ })
+}
+
diff --git a/arkui/ace_ets_web_dev/entry/src/main/module.json b/arkui/ace_ets_web_dev/entry/src/main/module.json
index b0beb41b6ea4b14c3d2421d183923a5146550f51..6fc4be01fd5c23e10ac20b2ab3cd5edb17ae9d49 100644
--- a/arkui/ace_ets_web_dev/entry/src/main/module.json
+++ b/arkui/ace_ets_web_dev/entry/src/main/module.json
@@ -14,6 +14,12 @@
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/module.json b/arkui/ace_ets_web_dev_three/entry/src/main/module.json
index 4194045678b29bd4e5bc2fd684a1372e15e99eeb..e23e2fa4adf7499fa14876bdb5380f6b98211e58 100644
--- a/arkui/ace_ets_web_dev_three/entry/src/main/module.json
+++ b/arkui/ace_ets_web_dev_three/entry/src/main/module.json
@@ -14,6 +14,12 @@
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
diff --git a/arkui/ace_ets_web_dev_two/entry/src/main/ets/MainAbility/pages/web.ets b/arkui/ace_ets_web_dev_two/entry/src/main/ets/MainAbility/pages/web.ets
index a567aa4731613fac5633bf1f07ccbd27e5512cbe..02cf227ab0869b78b04f0e70798d62859db7fbc6 100644
--- a/arkui/ace_ets_web_dev_two/entry/src/main/ets/MainAbility/pages/web.ets
+++ b/arkui/ace_ets_web_dev_two/entry/src/main/ets/MainAbility/pages/web.ets
@@ -32,7 +32,7 @@ struct Index {
host: string = "www.spincast.org"
realm: string = "protected example"
username_password: string[]
- origin: string="file:///"
+ origin: string="resource://rawfile/"
onPageShow(){
let valueChangeEvent={
eventId:10,
@@ -84,8 +84,12 @@ struct Index {
})
break;
}
- case "emitAllowGeolocation":{
- web_webview.GeolocationPermissions.allowGeolocation("file:///")
+ case "emitAllowGeolocation":{
+ try {
+ web_webview.GeolocationPermissions.allowGeolocation("resource://rawfile/");
+ } catch (error) {
+ console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
+ }
web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => {
if (error) {
console.log('error:' + JSON.stringify(error));
@@ -98,7 +102,7 @@ struct Index {
break;
}
case "emitDeleteGeolocation":{
- web_webview.GeolocationPermissions.deleteGeolocation("file:///")
+ web_webview.GeolocationPermissions.deleteGeolocation("resource://rawfile/")
web_webview.GeolocationPermissions.getStoredGeolocation((error,origins) => {
if (error) {
console.log('error:' + JSON.stringify(error));
@@ -111,7 +115,7 @@ struct Index {
break;
}
case "emitDeleteAllGeolocation":{
- web_webview.GeolocationPermissions.allowGeolocation("file:///")
+ web_webview.GeolocationPermissions.allowGeolocation("resource://rawfile/")
web_webview.GeolocationPermissions.deleteAllGeolocation()
web_webview.GeolocationPermissions.getStoredGeolocation((error,origins) => {
if (error) {
@@ -160,7 +164,7 @@ struct Index {
break;
}
case "emitLoaData":{
- this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"})
+ this.controller.loadUrl({url:"resource://rawfile/index.html"})
setTimeout(()=>{
this.controller.loadData({
data: "index",
diff --git a/arkui/ace_ets_web_dev_two/entry/src/main/ets/test/Utils.ets b/arkui/ace_ets_web_dev_two/entry/src/main/ets/test/Utils.ets
index 1a90ba6aedd9cd4c5662f10bd0f033f6136cb61a..9896396f70e8c45a502f4e3f26182dc800a1cb2d 100644
--- a/arkui/ace_ets_web_dev_two/entry/src/main/ets/test/Utils.ets
+++ b/arkui/ace_ets_web_dev_two/entry/src/main/ets/test/Utils.ets
@@ -29,9 +29,13 @@ export default class Utils {
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
+ try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertEqual(expectedValue);
console.info(`[${testCaseName}] END`);
+ }catch(err){
+ console.info(`[${testCaseName}] err:`+JSON.stringify(err));
+ }
done()
}
let innerEvent = {
@@ -64,10 +68,14 @@ export default class Utils {
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
+ try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.actualValue).assertLarger(backData.data.expectedValue-100);
expect(backData.data.actualValue).assertLess(backData.data.expectedValue-(-100));
console.info(`[${testCaseName}] END`);
+ }catch(err){
+ console.info(`[${testCaseName}] err:`+JSON.stringify(err));
+ }
done()
}
let innerEvent = {
@@ -101,9 +109,13 @@ export default class Utils {
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
+ try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertContain(expectedValue);
console.info(`[${testCaseName}] END`);
+ }catch(err){
+ console.info(`[${testCaseName}] err:`+JSON.stringify(err));
+ }
done()
}
let innerEvent = {
diff --git a/arkui/ace_ets_web_dev_two/entry/src/main/ets/test/WebJsunit.test.ets b/arkui/ace_ets_web_dev_two/entry/src/main/ets/test/WebJsunit.test.ets
index 6b9a620b156b2b28573337777e1f3fb5eabffb9a..eeffac7a099275ebb89b70c2027b195a683ad7b7 100644
--- a/arkui/ace_ets_web_dev_two/entry/src/main/ets/test/WebJsunit.test.ets
+++ b/arkui/ace_ets_web_dev_two/entry/src/main/ets/test/WebJsunit.test.ets
@@ -61,7 +61,7 @@ export default function webJsunit() {
*/
it('allowGeolocation',0,async function(done){
emitKey="emitDeleteGeolocation";
- Utils.registerEvent("allowGeolocation","file:///, result: true",402,done);
+ Utils.registerEvent("allowGeolocation","resource://rawfile/, result: true",402,done);
sendEventByKey('webcomponent',10,'');
})
/*
@@ -69,19 +69,19 @@ export default function webJsunit() {
*tc.name deleteGeolocation
*tc.desic delete specific restored geolocation
*/
- it('deletGeolocation',0,async function(done){
+ it('deleteGeolocation',0,async function(done){
emitKey="emitDeleteAllGeolocation";
- Utils.registerEvent("deletGeolocation","",404,done);
+ Utils.registerEvent("deleteGeolocation","",404,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_069
- *tc.name deletAllGeolocation
+ *tc.name deleteAllGeolocation
*tc.desic delete all restored geolocation
*/
- it('deletAllGeolocation',0,async function(done){
+ it('deleteAllGeolocation',0,async function(done){
emitKey="emitIsCookieAllowed";
- Utils.registerEvent("deletAllGeolocation","",406,done);
+ Utils.registerEvent("deleteAllGeolocation","",406,done);
sendEventByKey('webcomponent',10,'');
})
/*
@@ -141,7 +141,7 @@ export default function webJsunit() {
*/
it('getSourceId',0,async function(done){
emitKey="emitLoaData";
- Utils.registerEvent("getSourceId","file:///data/storage/el1/bundle/phone/resources/rawfile/index.html",422,done);
+ Utils.registerEvent("getSourceId","resource://rawfile/index.html",422,done);
sendEventByKey('webcomponent',10,'');
})
/*
diff --git a/arkui/ace_ets_web_dev_two/entry/src/main/module.json b/arkui/ace_ets_web_dev_two/entry/src/main/module.json
index b0beb41b6ea4b14c3d2421d183923a5146550f51..6fc4be01fd5c23e10ac20b2ab3cd5edb17ae9d49 100644
--- a/arkui/ace_ets_web_dev_two/entry/src/main/module.json
+++ b/arkui/ace_ets_web_dev_two/entry/src/main/module.json
@@ -14,6 +14,12 @@
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
diff --git a/arkui/libuv/src/ActsLibuvTest.cpp b/arkui/libuv/src/ActsLibuvTest.cpp
index eda5eaa8381349d8d3d922e6ba662463315e5f2d..f5c28b1f9d2f2347b2edeab63e4026ab9bfc3b10 100644
--- a/arkui/libuv/src/ActsLibuvTest.cpp
+++ b/arkui/libuv/src/ActsLibuvTest.cpp
@@ -19,11 +19,23 @@
extern "C"{
#include "runner.h"
}
+#include "uv.h"
+
+typedef void (*init_plugin_function)();
namespace OHOS {
using namespace std;
using namespace testing::ext;
+ static const char TESTFILE[] = "foo.gz";
+
+ static uv_once_t once_only = UV_ONCE_INIT;
+
+ int i = 0;
+ void Increment()
+ {
+ i++;
+ }
// Preset action of the test suite, which is executed before the first test case
void ActsLibuvTest::SetUpTestCase(void)
{
@@ -41,11 +53,168 @@ namespace OHOS {
{
}
- HWTEST_F(ActsLibuvTest, TestLibuvTestCase001, Function | MediumTest | Level2)
- {
- printf("------start ActsLibuvTest------\n");
- system("/data/local/tmp/libuvruntest");
- EXPECT_TRUE(true);
- printf("------end ActsLibuvTest------\n");
+/**
+ * @tc.number : ActsZlibTest_0100
+ * @tc.name : Test uv_version and uv_version_string test
+ * @tc.desc : [C- SOFTWARE -0200]
+*/
+HWTEST_F(ActsLibuvTest, TestLibuvTestUVVersion, Function | MediumTest | Level2)
+{
+ int version = uv_version();
+ ASSERT_EQ(version, UV_VERSION_HEX);
+ fprintf(stderr, "uv_version error: %d\n", version);
+
+ auto versionString = uv_version_string();
+ fprintf(stderr, "uv_version_string error: %s\n", versionString);
+
+ int replaceAllocator = uv_replace_allocator(nullptr, nullptr, nullptr, nullptr);
+ ASSERT_EQ(replaceAllocator, UV_EINVAL);
+ fprintf(stderr, "uv_replace_allocator error: %d\n", replaceAllocator);
+
+ uv_loop_t* loop = uv_loop_new();
+ ASSERT_TRUE(loop != nullptr);
+}
+
+/**
+ * @tc.number : ActsZlibTest_0200
+ * @tc.name : Test uv_loop_new
+ * @tc.desc : [C- SOFTWARE -0200]
+*/
+HWTEST_F(ActsLibuvTest, TestLibuvTestLoop, Function | MediumTest | Level2)
+{
+ uv_loop_t* newLoop;
+ newLoop = uv_loop_new();
+ ASSERT_TRUE(newLoop != NULL);
+ uv_loop_delete(newLoop);
+ ASSERT_TRUE(true);
+}
+
+/**
+ * @tc.number : ActsZlibTest_0300
+ * @tc.name : Test uv_err_name_r
+ * @tc.desc : [C- SOFTWARE -0200]
+*/
+
+HWTEST_F(ActsLibuvTest, TestLibuvTestErrName, Function | MediumTest | Level2)
+{
+ int err = 0;
+ char buf[40];
+ size_t buflen = 40;
+ char* newBuf = uv_err_name_r(err, buf, buflen);
+ fprintf(stderr, "uv_err_name_r error: %s\n", newBuf);
+ ASSERT_STREQ(newBuf, "Unknown system error 0");
+}
+
+/**
+ * @tc.number : ActsZlibTest_0400
+ * @tc.name : Test uv_req_get_data and uv_req_set_data and uv_req_get_type
+ * @tc.desc : [C- SOFTWARE -0200]
+*/
+HWTEST_F(ActsLibuvTest, TestLibuvTestReqGetData, Function | MediumTest | Level2)
+{
+ float f = 5.5f;
+ float* pf = &f;
+ uv_req_t* req = (uv_req_t *)malloc(sizeof(uv_req_t));
+ uv_req_t* setReq = (uv_req_t *)malloc(sizeof(uv_req_t));
+ req->data = pf;
+ req->type = UV_UNKNOWN_REQ;
+ fprintf(stderr, "uv_req_get_data: %f\n", *(float*)uv_req_get_data(req));
+ fprintf(stderr, "uv_req_get_type: %d\n", uv_req_get_type(req));
+ ASSERT_EQ(uv_req_get_data(req), pf);
+ ASSERT_EQ(uv_req_get_type(req), UV_UNKNOWN_REQ);
+
+ uv_req_set_data(setReq, pf);
+ ASSERT_EQ(uv_req_get_data(setReq), pf);
+}
+
+/**
+ * @tc.number : ActsZlibTest_0500
+ * @tc.name : Test uv_print_all_handles and uv_print_active_handles
+ * @tc.desc : [C- SOFTWARE -0200]
+*/
+HWTEST_F(ActsLibuvTest, TestLibuvTestPrintHandles, Function | MediumTest | Level2)
+{
+ uv_loop_t* loop = nullptr;
+ FILE *fp = fopen(TESTFILE, "w");
+ uv_print_all_handles(loop, fp);
+ uv_print_active_handles(loop, fp);
+ ASSERT_TRUE(true);
+}
+
+/**
+ * @tc.number : ActsZlibTest_0600
+ * @tc.name : Test uv_udp_get_send_queue_size and uv_udp_get_send_queue_count
+ * @tc.desc : [C- SOFTWARE -0200]
+*/
+HWTEST_F(ActsLibuvTest, TestLibuvTestUpdSendQueue, Function | MediumTest | Level2)
+{
+ size_t size, sizeC;
+ uv_udp_t* handle = (uv_udp_t *)malloc(sizeof(uv_udp_t));
+ handle->send_queue_size = 5;
+ handle->send_queue_count = 5;
+ size = uv_udp_get_send_queue_size(handle);
+ ASSERT_TRUE(size == 5);
+
+ sizeC = uv_udp_get_send_queue_count(handle);
+ ASSERT_TRUE(sizeC == 5);
+}
+
+/**
+ * @tc.number : ActsZlibTest_0700
+ * @tc.name : Test uv_fs_lchown
+ * @tc.desc : [C- SOFTWARE -0200]
+*/
+HWTEST_F(ActsLibuvTest, TestLibuvTestFsLchown, Function | MediumTest | Level2)
+{
+ int retC;
+ uv_loop_t loop;
+ uv_fs_t req;
+ const char *path = "/date/";
+ uv_uid_t uid = 10000;
+ uv_gid_t gid = 2020;
+ retC = uv_fs_lchown(&loop, &req, path, uid, gid, nullptr);
+ fprintf(stderr, "uv_err_name_r error: %d\n", retC);
+}
+
+/**
+ * @tc.number : ActsZlibTest_0800
+ * @tc.name : Test uv_disable_stdio_inheritance
+ * @tc.desc : [C- SOFTWARE -0200]
+*/
+HWTEST_F(ActsLibuvTest, TestLibuvTestDisableStdioInheritance, Function | MediumTest | Level2)
+{
+ uv_disable_stdio_inheritance();
+ ASSERT_TRUE(true);
+}
+
+/**
+ * @tc.number : ActsZlibTest_0900
+ * @tc.name : Test uv_dlsym
+ * @tc.desc : [C- SOFTWARE -0200]
+ */
+HWTEST_F(ActsLibuvTest, TestLibuvTestDlsym, Function | MediumTest | Level2) {
+ int argc = 3;
+ const char *tmp[] = {"aaaa", "bbbb", "cccc"};
+ const char **argv = tmp;
+ uv_lib_t *lib = (uv_lib_t *)malloc(sizeof(uv_lib_t));
+ while (--argc) {
+ uv_dlopen(argv[argc], lib);
+ ASSERT_TRUE(true);
+
+ init_plugin_function init_plugin;
+ uv_dlsym(lib, "initialize", (void **)&init_plugin);
+ ASSERT_TRUE(true);
}
}
+
+/**
+ * @tc.number : ActsZlibTest_1000
+ * @tc.name : Test uv_once
+ * @tc.desc : [C- SOFTWARE -0200]
+*/
+HWTEST_F(ActsLibuvTest, TestLibuvTestUvOnce, Function | MediumTest | Level2)
+{
+ uv_once(&once_only, Increment);
+ ASSERT_TRUE(true);
+}
+}
diff --git a/barrierfree/accessibilityerrcode/entry/src/main/module.json b/barrierfree/accessibilityerrcode/entry/src/main/module.json
index 1ef4f93d3740502407b8b4d6151aabda44878e12..4202226c794c6f948a905ba8ee1e5e28df7e0799 100644
--- a/barrierfree/accessibilityerrcode/entry/src/main/module.json
+++ b/barrierfree/accessibilityerrcode/entry/src/main/module.json
@@ -6,7 +6,7 @@
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
- "tablet",
+ "tablet",
"default",
"phone"
],
@@ -14,6 +14,12 @@
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [{
"name": "TestAbility",
"srcEntrance": "./ets/TestAbility/TestAbility.ts",
diff --git a/barrierfree/accessibilitysendaccessibilityevent/entry/src/main/module.json b/barrierfree/accessibilitysendaccessibilityevent/entry/src/main/module.json
index 1ef4f93d3740502407b8b4d6151aabda44878e12..4202226c794c6f948a905ba8ee1e5e28df7e0799 100644
--- a/barrierfree/accessibilitysendaccessibilityevent/entry/src/main/module.json
+++ b/barrierfree/accessibilitysendaccessibilityevent/entry/src/main/module.json
@@ -6,7 +6,7 @@
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
- "tablet",
+ "tablet",
"default",
"phone"
],
@@ -14,6 +14,12 @@
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [{
"name": "TestAbility",
"srcEntrance": "./ets/TestAbility/TestAbility.ts",
diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsaccesstokentest/src/main/js/test/ActsBmsAccessTokenTest.test.js b/bundlemanager/bundle_standard/bundlemanager/actsbmsaccesstokentest/src/main/js/test/ActsBmsAccessTokenTest.test.js
index 876541c79d1188d1dcbf59e77ffca59dd9a15c70..1320bd8beefef838ebb8898e27ab1207afa15c15 100644
--- a/bundlemanager/bundle_standard/bundlemanager/actsbmsaccesstokentest/src/main/js/test/ActsBmsAccessTokenTest.test.js
+++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsaccesstokentest/src/main/js/test/ActsBmsAccessTokenTest.test.js
@@ -63,14 +63,12 @@ describe('ActsBmsAccessTokenTest', function () {
await bundle.getBundleInfo(BUNDLE_NAME3, bundle.BundleFlag.GET_BUNDLE_WITH_REQUESTED_PERMISSION)
.then(bundleInfo => {
expect(bundleInfo.name).assertEqual(BUNDLE_NAME3);
- expect(bundleInfo.reqPermissions.length).assertEqual(3);
- expect(bundleInfo.reqPermissions[0]).assertEqual("ohos.permission.ALPHA");
- expect(bundleInfo.reqPermissions[1]).assertEqual("ohos.permission.BETA");
- expect(bundleInfo.reqPermissions[2]).assertEqual("ohos.permission.KEEP_BACKGROUND_RUNNING");
- expect(bundleInfo.reqPermissionStates.length).assertEqual(3);
+ expect(bundleInfo.reqPermissions.length).assertEqual(2);
+ expect(bundleInfo.reqPermissions[0]).assertEqual("ohos.permission.DISTRIBUTED_DATASYNC");
+ expect(bundleInfo.reqPermissions[1]).assertEqual("ohos.permission.KEEP_BACKGROUND_RUNNING");
+ expect(bundleInfo.reqPermissionStates.length).assertEqual(2);
expect(bundleInfo.reqPermissionStates[0]).assertEqual(bundle.GrantStatus.PERMISSION_DENIED);
- expect(bundleInfo.reqPermissionStates[1]).assertEqual(bundle.GrantStatus.PERMISSION_DENIED);
- expect(bundleInfo.reqPermissionStates[2]).assertEqual(bundle.GrantStatus.PERMISSION_GRANTED);
+ expect(bundleInfo.reqPermissionStates[1]).assertEqual(bundle.GrantStatus.PERMISSION_GRANTED);
done();
}).catch((err) => {
expect(err).assertFail();
@@ -87,18 +85,16 @@ describe('ActsBmsAccessTokenTest', function () {
await bundle.getBundleInfo(BUNDLE_NAME2, bundle.BundleFlag.GET_BUNDLE_WITH_REQUESTED_PERMISSION)
.then(bundleInfo => {
expect(bundleInfo.name).assertEqual(BUNDLE_NAME2);
- expect(bundleInfo.reqPermissions.length).assertEqual(5);
- expect(bundleInfo.reqPermissions[0]).assertEqual("ohos.permission.ALPHA");
- expect(bundleInfo.reqPermissions[1]).assertEqual("ohos.permission.KEEP_BACKGROUND_RUNNING");
- expect(bundleInfo.reqPermissions[2]).assertEqual("ohos.permission.LOCATION_IN_BACKGROUND");
- expect(bundleInfo.reqPermissions[3]).assertEqual("ohos.permission.USE_BLUETOOTH");
- expect(bundleInfo.reqPermissions[4]).assertEqual("ohos.permission.VIBRATE");
- expect(bundleInfo.reqPermissionStates.length).assertEqual(5);
- expect(bundleInfo.reqPermissionStates[0]).assertEqual(bundle.GrantStatus.PERMISSION_DENIED);
- expect(bundleInfo.reqPermissionStates[1]).assertEqual(bundle.GrantStatus.PERMISSION_GRANTED);
- expect(bundleInfo.reqPermissionStates[2]).assertEqual(bundle.GrantStatus.PERMISSION_DENIED);
+ expect(bundleInfo.reqPermissions.length).assertEqual(4);
+ expect(bundleInfo.reqPermissions[0]).assertEqual("ohos.permission.KEEP_BACKGROUND_RUNNING");
+ expect(bundleInfo.reqPermissions[1]).assertEqual("ohos.permission.LOCATION_IN_BACKGROUND");
+ expect(bundleInfo.reqPermissions[2]).assertEqual("ohos.permission.USE_BLUETOOTH");
+ expect(bundleInfo.reqPermissions[3]).assertEqual("ohos.permission.VIBRATE");
+ expect(bundleInfo.reqPermissionStates.length).assertEqual(4);
+ expect(bundleInfo.reqPermissionStates[0]).assertEqual(bundle.GrantStatus.PERMISSION_GRANTED);
+ expect(bundleInfo.reqPermissionStates[1]).assertEqual(bundle.GrantStatus.PERMISSION_DENIED);
+ expect(bundleInfo.reqPermissionStates[2]).assertEqual(bundle.GrantStatus.PERMISSION_GRANTED);
expect(bundleInfo.reqPermissionStates[3]).assertEqual(bundle.GrantStatus.PERMISSION_GRANTED);
- expect(bundleInfo.reqPermissionStates[4]).assertEqual(bundle.GrantStatus.PERMISSION_GRANTED);
done();
}).catch((err) => {
expect(err).assertFail();
@@ -115,20 +111,18 @@ describe('ActsBmsAccessTokenTest', function () {
await bundle.getBundleInfo(BUNDLE_NAME1, bundle.BundleFlag.GET_BUNDLE_WITH_REQUESTED_PERMISSION)
.then(bundleInfo => {
expect(bundleInfo.name).assertEqual(BUNDLE_NAME1);
- expect(bundleInfo.reqPermissions.length).assertEqual(6);
- expect(bundleInfo.reqPermissions[0]).assertEqual("ohos.permission.ALPHA");
- expect(bundleInfo.reqPermissions[1]).assertEqual("ohos.permission.BETA");
- expect(bundleInfo.reqPermissions[2]).assertEqual("ohos.permission.KEEP_BACKGROUND_RUNNING");
- expect(bundleInfo.reqPermissions[3]).assertEqual("ohos.permission.LOCATION_IN_BACKGROUND");
- expect(bundleInfo.reqPermissions[4]).assertEqual("ohos.permission.USE_BLUETOOTH");
- expect(bundleInfo.reqPermissions[5]).assertEqual("ohos.permission.VIBRATE");
- expect(bundleInfo.reqPermissionStates.length).assertEqual(6);
+ expect(bundleInfo.reqPermissions.length).assertEqual(5);
+ expect(bundleInfo.reqPermissions[0]).assertEqual("ohos.permission.DISTRIBUTED_DATASYNC");
+ expect(bundleInfo.reqPermissions[1]).assertEqual("ohos.permission.KEEP_BACKGROUND_RUNNING");
+ expect(bundleInfo.reqPermissions[2]).assertEqual("ohos.permission.LOCATION_IN_BACKGROUND");
+ expect(bundleInfo.reqPermissions[3]).assertEqual("ohos.permission.USE_BLUETOOTH");
+ expect(bundleInfo.reqPermissions[4]).assertEqual("ohos.permission.VIBRATE");
+ expect(bundleInfo.reqPermissionStates.length).assertEqual(5);
expect(bundleInfo.reqPermissionStates[0]).assertEqual(bundle.GrantStatus.PERMISSION_DENIED);
- expect(bundleInfo.reqPermissionStates[1]).assertEqual(bundle.GrantStatus.PERMISSION_DENIED);
- expect(bundleInfo.reqPermissionStates[2]).assertEqual(bundle.GrantStatus.PERMISSION_GRANTED);
- expect(bundleInfo.reqPermissionStates[3]).assertEqual(bundle.GrantStatus.PERMISSION_DENIED);
+ expect(bundleInfo.reqPermissionStates[1]).assertEqual(bundle.GrantStatus.PERMISSION_GRANTED);
+ expect(bundleInfo.reqPermissionStates[2]).assertEqual(bundle.GrantStatus.PERMISSION_DENIED);
+ expect(bundleInfo.reqPermissionStates[3]).assertEqual(bundle.GrantStatus.PERMISSION_GRANTED);
expect(bundleInfo.reqPermissionStates[4]).assertEqual(bundle.GrantStatus.PERMISSION_GRANTED);
- expect(bundleInfo.reqPermissionStates[5]).assertEqual(bundle.GrantStatus.PERMISSION_GRANTED);
done();
}).catch((err) => {
expect(err).assertFail();
diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/module.json b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/module.json
index 91ecfa07a1f6dd2aa839a7c32e46105d57a8c31b..b514f056d5ddad6cd78356f1d655e0e58c7c6ef9 100755
--- a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/module.json
+++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/module.json
@@ -13,6 +13,12 @@
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [
{
"name": "ohos.acts.bundle.stage.test.MainAbility",
diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenfive/src/main/config.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenfive/src/main/config.json
index d40bf5e8118628465f95cc16c2db826e94a12705..0cdbac17d399fbd439dcada34cef1645f9126747 100644
--- a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenfive/src/main/config.json
+++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenfive/src/main/config.json
@@ -67,34 +67,10 @@
}
}
],
- "definePermissions":[
- {
- "availableLevel":"normal",
- "description":"ALPHA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"ALPHA label",
- "name":"ohos.permission.ALPHA",
- "provisionEnable":true
- },
- {
- "availableLevel":"normal",
- "description":"BETA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"BETA label",
- "name":"ohos.permission.BETA",
- "provisionEnable":true
- }
- ],
"reqPermissions":[
{
- "name":"ohos.permission.ALPHA",
- "reason":"use ohos.permission.ALPHA"
- },
- {
- "name":"ohos.permission.BETA",
- "reason":"use ohos.permission.BETA"
+ "name":"ohos.permission.DISTRIBUTED_DATASYNC",
+ "reason":"use ohos.permission.DISTRIBUTED_DATASYNC"
},
{
"name": "ohos.permission.KEEP_BACKGROUND_RUNNING",
diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenfour/src/main/config.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenfour/src/main/config.json
index a386bf07254efae994638cd36eac5010b17df1c1..8c8a50bf07db8e2690f949631165ace7254f8e13 100644
--- a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenfour/src/main/config.json
+++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenfour/src/main/config.json
@@ -67,34 +67,10 @@
}
}
],
- "definePermissions":[
- {
- "availableLevel":"normal",
- "description":"ALPHA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"ALPHA label",
- "name":"ohos.permission.ALPHA",
- "provisionEnable":true
- },
- {
- "availableLevel":"normal",
- "description":"BETA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"BETA label",
- "name":"ohos.permission.BETA",
- "provisionEnable":true
- }
- ],
"reqPermissions":[
{
- "name":"ohos.permission.ALPHA",
- "reason":"use ohos.permission.ALPHA"
- },
- {
- "name":"ohos.permission.BETA",
- "reason":"use ohos.permission.BETA"
+ "name":"ohos.permission.DISTRIBUTED_DATASYNC",
+ "reason":"use ohos.permission.DISTRIBUTED_DATASYNC"
},
{
"name": "ohos.permission.KEEP_BACKGROUND_RUNNING",
diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenone/src/main/config.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenone/src/main/config.json
index ec79f8a8534201cd6b523ebc24049cb94c619555..e9cac756ffb2e7fa8e10a21f50a3ddf35d839a46 100644
--- a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenone/src/main/config.json
+++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenone/src/main/config.json
@@ -67,34 +67,10 @@
}
}
],
- "definePermissions":[
- {
- "availableLevel":"normal",
- "description":"ALPHA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"ALPHA label",
- "name":"ohos.permission.ALPHA",
- "provisionEnable":true
- },
- {
- "availableLevel":"normal",
- "description":"BETA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"BETA label",
- "name":"ohos.permission.BETA",
- "provisionEnable":true
- }
- ],
"reqPermissions":[
{
- "name":"ohos.permission.ALPHA",
- "reason":"use ohos.permission.ALPHA"
- },
- {
- "name":"ohos.permission.BETA",
- "reason":"use ohos.permission.BETA"
+ "name":"ohos.permission.DISTRIBUTED_DATASYNC",
+ "reason":"use ohos.permission.DISTRIBUTED_DATASYNC"
},
{
"name": "ohos.permission.KEEP_BACKGROUND_RUNNING",
diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenthree/src/main/config.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenthree/src/main/config.json
index bb4e6eef4ff7ff8578f8327a3fe31347134c7980..1c736b7b17c0db3276fefbee6edd6e51c23ad793 100644
--- a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenthree/src/main/config.json
+++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokenthree/src/main/config.json
@@ -67,31 +67,7 @@
}
}
],
- "definePermissions":[
- {
- "availableLevel":"normal",
- "description":"ALPHA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"ALPHA label",
- "name":"ohos.permission.ALPHA",
- "provisionEnable":true
- },
- {
- "availableLevel":"normal",
- "description":"BETA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"BETA label",
- "name":"ohos.permission.BETA",
- "provisionEnable":true
- }
- ],
"reqPermissions":[
- {
- "name":"ohos.permission.ALPHA",
- "reason":"use ohos.permission.ALPHA"
- },
{
"name": "ohos.permission.KEEP_BACKGROUND_RUNNING",
"reason": "use ohos.permission.KEEP_BACKGROUND_RUNNING"
diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokentwo/src/main/config.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokentwo/src/main/config.json
index f9480aebc045aff04e3ca6a9911a5322875de2df..e1393dafd830e6610ea70f59f4e2d528a77a77c6 100644
--- a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokentwo/src/main/config.json
+++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsaccesstokentwo/src/main/config.json
@@ -67,31 +67,7 @@
}
}
],
- "definePermissions":[
- {
- "availableLevel":"normal",
- "description":"ALPHA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"ALPHA label",
- "name":"ohos.permission.ALPHA",
- "provisionEnable":true
- },
- {
- "availableLevel":"normal",
- "description":"BETA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"BETA label",
- "name":"ohos.permission.BETA",
- "provisionEnable":true
- }
- ],
"reqPermissions":[
- {
- "name":"ohos.permission.ALPHA",
- "reason":"use ohos.permission.ALPHA"
- },
{
"name": "ohos.permission.KEEP_BACKGROUND_RUNNING",
"reason": "use ohos.permission.KEEP_BACKGROUND_RUNNING"
diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/config.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/config.json
index 88fdf0be0ea963283bcfce4a3e72dfcaa4d2978e..c584e50084390089c6640f8df4f4a1f75f74a7c9 100644
--- a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/config.json
+++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/config.json
@@ -67,34 +67,10 @@
}
}
],
- "definePermissions":[
- {
- "availableLevel":"normal",
- "description":"ALPHA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"ALPHA label",
- "name":"ohos.permission.ALPHA",
- "provisionEnable":true
- },
- {
- "availableLevel":"normal",
- "description":"BETA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"BETA label",
- "name":"ohos.permission.BETA",
- "provisionEnable":true
- }
- ],
"reqPermissions":[
{
- "name":"ohos.permission.ALPHA",
- "reason":"use ohos.permission.ALPHA"
- },
- {
- "name":"ohos.permission.BETA",
- "reason":"use ohos.permission.BETA"
+ "name":"ohos.permission.DISTRIBUTED_DATASYNC",
+ "reason":"use ohos.permission.DISTRIBUTED_DATASYNC"
},
{
"name": "ohos.permission.KEEP_BACKGROUND_RUNNING",
diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsmodulenametwo/src/main/config.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsmodulenametwo/src/main/config.json
index f316a0a99ce7a48f9dfe8342dd583803b7bf5fc2..e1df55808acc9740368fbbf20e2e1529fa9f8317 100644
--- a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsmodulenametwo/src/main/config.json
+++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsmodulenametwo/src/main/config.json
@@ -67,34 +67,10 @@
}
}
],
- "definePermissions":[
- {
- "availableLevel":"normal",
- "description":"ALPHA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"ALPHA label",
- "name":"ohos.permission.ALPHA",
- "provisionEnable":true
- },
- {
- "availableLevel":"normal",
- "description":"BETA description",
- "distributedSceneEnable":true,
- "grantMode":"user_grant",
- "label":"BETA label",
- "name":"ohos.permission.BETA",
- "provisionEnable":true
- }
- ],
"reqPermissions":[
{
- "name":"ohos.permission.ALPHA",
- "reason":"use ohos.permission.ALPHA"
- },
- {
- "name":"ohos.permission.BETA",
- "reason":"use ohos.permission.BETA"
+ "name":"ohos.permission.DISTRIBUTED_DATASYNC",
+ "reason":"use ohos.permission.DISTRIBUTED_DATASYNC"
},
{
"name": "ohos.permission.KEEP_BACKGROUND_RUNNING",
diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/entry/src/main/module.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/entry/src/main/module.json
index 4b1060dd278d3e03bd87c0333d5931f52bddf672..bac77fccb2a15849b6de8c3f63c8571ad421ffa3 100644
--- a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/entry/src/main/module.json
+++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/entry/src/main/module.json
@@ -13,6 +13,12 @@
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [
{
"name": "com.acts.bundle.stage.MainAbility",
diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/module.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/module.json
index 0e79ba40c968ed6d3393904014cfe7434bf251cf..9e7ad7a9d4b4e7e7e27827953e89d421052360f5 100644
--- a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/module.json
+++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/module.json
@@ -13,6 +13,12 @@
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [
{
"name": "com.acts.bundle.stage.MainAbility1",
diff --git a/commonlibrary/ets_utils/atomics_lib_standard/entry/src/main/module.json b/commonlibrary/ets_utils/atomics_lib_standard/entry/src/main/module.json
index 5e0e95211a9bc21345ee5f4e563841b898d6f5ac..7a28c05af07027ae51337156d719b3391c7439c6 100644
--- a/commonlibrary/ets_utils/atomics_lib_standard/entry/src/main/module.json
+++ b/commonlibrary/ets_utils/atomics_lib_standard/entry/src/main/module.json
@@ -13,6 +13,12 @@
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [
{
"name": "com.example.atomicsxts.MainAbility",
diff --git a/commonlibrary/ets_utils/intl_lib_standard/src/main/js/test/Intl.properties.test.js b/commonlibrary/ets_utils/intl_lib_standard/src/main/js/test/Intl.properties.test.js
index fcc527da5d415110a9c4743f593b473094387812..c77b3676e2ec10307ddbb8ea4602735501210e55 100644
--- a/commonlibrary/ets_utils/intl_lib_standard/src/main/js/test/Intl.properties.test.js
+++ b/commonlibrary/ets_utils/intl_lib_standard/src/main/js/test/Intl.properties.test.js
@@ -1476,7 +1476,7 @@ describe('etsIntlPtsFunTest', function () {
var array = [1, 'a', new Date('21 Dec 2022 14:12:00 UTC')];
var value = array.toLocaleString();
console.log('ArrayTest001 :' + value);
- expect(value).assertEqual('1,a,Invalid Date');
+ expect(value).assertEqual('1,a,12/21/2022, 10:12:00 PM');
})
/**
@@ -1489,9 +1489,9 @@ describe('etsIntlPtsFunTest', function () {
*/
it('SUB_ARK_ETS_INTL_ARRAY_PROTOTYPE_002', 0, function () {
var array = [1, 'a', new Date('21 Dec 2022 14:12:00 UTC')];
- var value = array.toLocaleString('zh');
+ var value = array.toLocaleString('en');
console.log('ArrayTest002 :' + value);
- expect(value).assertEqual('1zhazhInvalid Date');
+ expect(value).assertEqual('1enaen12/21/2022, 10:12:00 PM');
})
/**
@@ -1506,7 +1506,7 @@ describe('etsIntlPtsFunTest', function () {
var array = [1, 'a', new Date('21 Dec 2022 14:12:00 UTC')];
var value = array.toLocaleString('en', { timeZone: 'UTC' });
console.log('ArrayTest003 :' + value);
- expect(value).assertEqual('1enaenInvalid Date');
+ expect(value).assertEqual('1enaen12/21/2022, 2:12:00 PM');
})
/**
@@ -1599,7 +1599,7 @@ describe('etsIntlPtsFunTest', function () {
var array = ['¥7', 500, 8123, 12, undefined, new Date('21 Dec 2022 14:12:00 UTC')];
var value = array.toLocaleString('ja-JP', { style: 'currency', currency: 'JPY' });
console.log('ArrayTest009 :' + value);
- expect(value).assertEqual('¥7ja-JP¥500ja-JP¥8,123ja-JP¥12ja-JPja-JPInvalid Date');
+ expect(value).assertEqual('¥7ja-JP¥500ja-JP¥8,123ja-JP¥12ja-JPja-JP2022/12/21 22:12:00');
})
/**
diff --git a/commonlibrary/ets_utils/taskpool_lib_standard/src/main/config.json b/commonlibrary/ets_utils/taskpool_lib_standard/src/main/config.json
index 058be5ca296bc8251d687c7e1cea983288b09f42..38fad0eed7a5f576a9eec0079f8e3196ac3684b9 100644
--- a/commonlibrary/ets_utils/taskpool_lib_standard/src/main/config.json
+++ b/commonlibrary/ets_utils/taskpool_lib_standard/src/main/config.json
@@ -7,7 +7,7 @@
"name": "1.0.0"
},
"apiVersion": {
- "compatible": 9,
+ "compatible": 8,
"target": 9
}
},
diff --git a/commonlibrary/ets_utils/taskpool_lib_standard/src/main/js/test/TaskPool.test.js b/commonlibrary/ets_utils/taskpool_lib_standard/src/main/js/test/TaskPool.test.js
index 1df95620f8ed798f403702ae6ec070071e974bce..0fad975d14098533804da40edeef6ebf465d507b 100644
--- a/commonlibrary/ets_utils/taskpool_lib_standard/src/main/js/test/TaskPool.test.js
+++ b/commonlibrary/ets_utils/taskpool_lib_standard/src/main/js/test/TaskPool.test.js
@@ -14,7 +14,6 @@
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import taskpool from '@ohos.taskpool'
-import worker from "@ohos.worker"
export default function TaskPoolTest() {
describe('ActsAbilityTest', function () {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
@@ -31,6 +30,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass001', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result = await taskpool.execute(Sum, 10, 20);
@@ -40,6 +40,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass002', 0, async function (done) {
function Add(value1, value2) {
+ "use concurrent"
if (value1 & value2)
return true;
else
@@ -52,6 +53,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass003', 0, async function (done) {
function StrCat(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result = await taskpool.execute(StrCat, "abc", "def");
@@ -61,6 +63,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass004', 0, async function (done) {
function StrCat(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result = await taskpool.execute(StrCat, "abc", "def");
@@ -71,6 +74,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass005', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
function StrCat(value1, value2) {
return value1 + value2;
}
@@ -83,6 +87,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass006', 0, async function (done) {
function Sum(arg1, arg2) {
+ "use concurrent"
let value = [];
value[0] = arg1[0] + arg2[0];
value[1] = arg1[1] + arg2[1];
@@ -96,6 +101,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass007', 0, async function (done) {
function Sum(arg1, arg2) {
+ "use concurrent"
let value = arg1;
value.a = arg1.a + arg2.a;
value.b = arg1.b + arg2.b;
@@ -108,6 +114,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass008', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result = await taskpool.execute(Sum, 10);
@@ -117,6 +124,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass009', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result = await taskpool.execute(Sum, 10, 20, 30);
@@ -126,6 +134,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass010', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result1 = await taskpool.execute(Sum, 10, 20);
@@ -137,6 +146,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass011', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result1 = await taskpool.execute(Sum, 10, 20);
@@ -148,9 +158,11 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass012', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
function Multi(value1, value2) {
+ "use concurrent"
return value1 * value2;
}
var result1 = await taskpool.execute(Sum, 10, 20);
@@ -166,6 +178,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass013', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var task = new taskpool.Task(Sum, 10, 20);
@@ -176,6 +189,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass014', 0, async function (done) {
function Add(value1, value2) {
+ "use concurrent"
if (value1 & value2)
return true;
else
@@ -189,6 +203,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass015', 0, async function (done) {
function StrCat(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var task = new taskpool.Task(StrCat, "abc", "def");
@@ -199,6 +214,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass016', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
function StrCat(value1, value2) {
return value1 + value2;
}
@@ -212,6 +228,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass017', 0, async function (done) {
function Sum(arg1, arg2) {
+ "use concurrent"
let value = [];
value[0] = arg1[0] + arg2[0];
value[1] = arg1[1] + arg2[1];
@@ -226,6 +243,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass018', 0, async function (done) {
function Sum(arg1, arg2) {
+ "use concurrent"
let value = arg1;
value.a = arg1.a + arg2.a;
value.b = arg1.b + arg2.b;
@@ -239,6 +257,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass019', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var task = new taskpool.Task(Sum, 10);
@@ -249,6 +268,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass020', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var task = new taskpool.Task(Sum, 10, 20, 30);
@@ -259,6 +279,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass021', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var task = new taskpool.Task(Sum, 10, 20);
@@ -271,6 +292,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass022', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var task1 = new taskpool.Task(Sum, 10, 20);
@@ -284,6 +306,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass023', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var task1 = new taskpool.Task(Sum, 10, 20);
@@ -297,9 +320,11 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass024', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
function Multi(value1, value2) {
+ "use concurrent"
return value1 * value2;
}
var task1 = new taskpool.Task(Sum, 10, 20);
@@ -319,6 +344,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass025', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result;
@@ -337,6 +363,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass026', 0, async function (done) {
function Add(value1, value2) {
+ "use concurrent"
if (value1 & value2)
return true;
else
@@ -358,6 +385,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass027', 0, async function (done) {
function StrCat(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var task = new taskpool.Task(StrCat, "abc", "def")
@@ -376,6 +404,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass028', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
function StrCat(value1, value2) {
return value1 + value2;
}
@@ -397,6 +426,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass029', 0, async function (done) {
function Sum(arg1, arg2) {
+ "use concurrent"
let value = [];
value[0] = arg1[0] + arg2[0];
value[1] = arg1[1] + arg2[1];
@@ -419,6 +449,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass030', 0, async function (done) {
function Sum(arg1, arg2) {
+ "use concurrent"
let value = arg1;
value.a = arg1.a + arg2.a;
value.b = arg1.b + arg2.b;
@@ -440,6 +471,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass031', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var task = new taskpool.Task(Sum, 10);
@@ -458,6 +490,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass032', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var task = new taskpool.Task(Sum, 10, 20, 30);
@@ -476,6 +509,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass033', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result1;
@@ -504,6 +538,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass034', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result1;
@@ -531,6 +566,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass035', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result1;
@@ -557,9 +593,11 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass036', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
function Multi(value1, value2) {
+ "use concurrent"
return value1 * value2;
}
@@ -605,6 +643,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass037', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result;
@@ -622,6 +661,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass038', 0, async function (done) {
function Add(value1, value2) {
+ "use concurrent"
if (value1 & value2)
return true;
else
@@ -642,6 +682,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass039', 0, async function (done) {
function StrCat(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result;
@@ -659,6 +700,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass040', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
function StrCat(value1, value2) {
return value1 + value2;
}
@@ -679,6 +721,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass041', 0, async function (done) {
function Sum(arg1, arg2) {
+ "use concurrent"
let value = [];
value[0] = arg1[0] + arg2[0];
value[1] = arg1[1] + arg2[1];
@@ -700,6 +743,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass042', 0, async function (done) {
function Sum(arg1, arg2) {
+ "use concurrent"
let value = arg1;
value.a = arg1.a + arg2.a;
value.b = arg1.b + arg2.b;
@@ -720,6 +764,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass043', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result;
@@ -737,6 +782,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass044', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result;
@@ -754,6 +800,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass045', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result1;
@@ -779,6 +826,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass046', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
var result1;
@@ -804,9 +852,11 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass047', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
function Multi(value1, value2) {
+ "use concurrent"
return value1 * value2;
}
@@ -847,6 +897,7 @@ describe('ActsAbilityTest', function () {
it('TaskPoolTestClass048', 0, async function (done) {
function Sum(value1, value2) {
+ "use concurrent"
return value1 + value2;
}
try {
@@ -867,9 +918,11 @@ describe('ActsAbilityTest', function () {
*/
it('TaskPoolTestClass049', 0, async function (done) {
function addition(arg) {
+ "use concurrent"
return arg + 1;
}
function additionDelay(arg) {
+ "use concurrent"
var start = new Date().getTime();
while (new Date().getTime() - start < 3000) {
continue;
@@ -903,9 +956,11 @@ describe('ActsAbilityTest', function () {
*/
it('TaskPoolTestClass050', 0, function (done) {
function addition(arg) {
+ "use concurrent"
return arg + 1;
}
function additionDelay(arg) {
+ "use concurrent"
var start = new Date().getTime();
while (new Date().getTime() - start < 3000) {
continue;
@@ -939,9 +994,11 @@ describe('ActsAbilityTest', function () {
*/
it('TaskPoolTestClass051', 0, async function (done) {
function addition(arg) {
+ "use concurrent"
return arg + 1;
}
function additionDelay(arg) {
+ "use concurrent"
var start = new Date().getTime();
while (new Date().getTime() - start < 3000) {
continue;
@@ -981,9 +1038,11 @@ describe('ActsAbilityTest', function () {
*/
it('TaskPoolTestClass052', 0, function (done) {
function addition(arg) {
+ "use concurrent"
return arg + 1;
}
function additionDelay(arg) {
+ "use concurrent"
var start = new Date().getTime();
while (new Date().getTime() - start < 3000) {
continue;
@@ -1023,6 +1082,7 @@ describe('ActsAbilityTest', function () {
*/
it('TaskPoolTestClass053', 0, async function (done) {
function addition(arg) {
+ "use concurrent"
return arg + 1;
}
try {
@@ -1058,6 +1118,7 @@ describe('ActsAbilityTest', function () {
*/
it('TaskPoolTestClass054', 0, function (done) {
function addition(arg) {
+ "use concurrent"
return arg + 1;
}
try {
@@ -1099,6 +1160,7 @@ describe('ActsAbilityTest', function () {
*/
it('TaskPoolTestClass055', 0, async function (done) {
function addition(arg) {
+ "use concurrent"
return arg + 1;
}
try {
@@ -1128,6 +1190,7 @@ describe('ActsAbilityTest', function () {
*/
it('TaskPoolTestClass056', 0, function (done) {
function addition(arg) {
+ "use concurrent"
return arg + 1;
}
try {
@@ -1157,14 +1220,16 @@ describe('ActsAbilityTest', function () {
*/
it('TaskPoolTestClass057', 0, async function (done) {
function addition(arg) {
+ "use concurrent"
return arg + 1;
}
function additionDelay(arg) {
- var start = new Date().getTime();
- while (new Date().getTime() - start < 3000) {
- continue;
- }
- return arg + 1;
+ "use concurrent"
+ var start = new Date().getTime();
+ while (new Date().getTime() - start < 3000) {
+ continue;
+ }
+ return arg + 1;
}
try {
var task1 = new taskpool.Task(additionDelay, 100);
@@ -1200,14 +1265,16 @@ describe('ActsAbilityTest', function () {
*/
it('TaskPoolTestClass058', 0, function (done) {
function addition(arg) {
+ "use concurrent"
return arg + 1;
}
function additionDelay(arg) {
- var start = new Date().getTime();
- while (new Date().getTime() - start < 3000) {
- continue;
- }
- return arg + 1;
+ "use concurrent"
+ var start = new Date().getTime();
+ while (new Date().getTime() - start < 3000) {
+ continue;
+ }
+ return arg + 1;
}
try {
var task1 = new taskpool.Task(additionDelay, 100);
@@ -1243,6 +1310,7 @@ describe('ActsAbilityTest', function () {
*/
it('TaskPoolTestClass059', 0, async function (done) {
function addition(arg) {
+ "use concurrent"
return arg + 1;
}
try {
@@ -1288,6 +1356,7 @@ describe('ActsAbilityTest', function () {
*/
it('TaskPoolTestClass060', 0, function (done) {
function addition(arg) {
+ "use concurrent"
return arg + 1;
}
try {
diff --git a/commonlibrary/ets_utils/threadWorker_lib_standard/entry/src/main/module.json b/commonlibrary/ets_utils/threadWorker_lib_standard/entry/src/main/module.json
index 0fb89508f99c872e3167e7483f7f4fdde5320fea..33955c2a172c94dba67ed05a50faaa41e21539a0 100644
--- a/commonlibrary/ets_utils/threadWorker_lib_standard/entry/src/main/module.json
+++ b/commonlibrary/ets_utils/threadWorker_lib_standard/entry/src/main/module.json
@@ -13,6 +13,12 @@
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [
{
"name": "com.example.threadWorkertest.MainAbility",
diff --git a/commonlibrary/ets_utils/util2_lib_standard/src/main/js/test/util.test.js b/commonlibrary/ets_utils/util2_lib_standard/src/main/js/test/util.test.js
index b5715d03de1f92af2b73b8aab7bc7f78fb885b11..ae4e6ef5a16e2369ed13e540e690a8a4c7206ba3 100644
--- a/commonlibrary/ets_utils/util2_lib_standard/src/main/js/test/util.test.js
+++ b/commonlibrary/ets_utils/util2_lib_standard/src/main/js/test/util.test.js
@@ -4471,8 +4471,7 @@ describe('DecodeEncodeTest', function () {
* @tc.desc: The source encoding's name, lowercased.
*/
it('testencoding_textdecoder_001', 0, function () {
- var that = new util.TextDecoder()
- that.create('utf-8', { ignoreBOM : true })
+ var that = util.TextDecoder.create('utf-8', { ignoreBOM : true })
var retStr = that.encoding
expect(retStr).assertEqual('utf-8')
})
@@ -4482,8 +4481,7 @@ describe('DecodeEncodeTest', function () {
* @tc.desc: The source encoding's name, lowercased.
*/
it('testencoding_textdecoder_002', 0, function () {
- var that = new util.TextDecoder()
- that.create('utf-16le')
+ var that = util.TextDecoder.create('utf-16le')
var encodingStr = that.encoding
expect(encodingStr).assertEqual('utf-16le')
})
@@ -4493,8 +4491,7 @@ describe('DecodeEncodeTest', function () {
* @tc.desc: The source encoding's name, lowercased.
*/
it('testencoding_textdecoder_003', 0, function () {
- var that = new util.TextDecoder()
- that.create('utf-16be')
+ var that = util.TextDecoder.create('utf-16be')
var encodingStr = that.encoding
expect(encodingStr).assertEqual('utf-16be')
})
@@ -4504,8 +4501,7 @@ describe('DecodeEncodeTest', function () {
* @tc.desc: The source encoding's name, lowercased.
*/
it('testencoding_textdecoder_004', 0, function () {
- var that = new util.TextDecoder()
- that.create('utf-16be', { ignoreBOM : true })
+ var that = util.TextDecoder.create('utf-16be', { ignoreBOM : true })
var encodingStr = that.encoding
expect(encodingStr).assertEqual('utf-16be')
})
@@ -4515,8 +4511,7 @@ describe('DecodeEncodeTest', function () {
* @tc.desc: The source encoding's name, lowercased.
*/
it('testencoding_textdecoder_005', 0, function () {
- var that = new util.TextDecoder()
- that.create('utf-16be', { ignoreBOM : false })
+ var that = util.TextDecoder.create('utf-16be', { ignoreBOM : false })
var encodingStr = that.encoding
expect(encodingStr).assertEqual('utf-16be')
})
@@ -4527,8 +4522,7 @@ describe('DecodeEncodeTest', function () {
*/
it('testencoding_textdecoder_ThrowError_001', 0, function () {
try {
- var that = new util.TextDecoder()
- that.create(123, { ignoreBOM : false })
+ var that = util.TextDecoder.create(123, { ignoreBOM : false })
var encodingStr = that.encoding
expect(encodingStr).assertEqual('utf-16be')
} catch (e) {
@@ -4542,8 +4536,7 @@ describe('DecodeEncodeTest', function () {
*/
it('testencoding_textdecoder_ThrowError_002', 0, function () {
try {
- var that = new util.TextDecoder()
- that.create('utf-16be', 'ignoreBOM')
+ var that = util.TextDecoder.create('utf-16be', 'ignoreBOM')
var encodingStr = that.encoding
expect(encodingStr).assertEqual('utf-16be')
} catch (e) {
@@ -4557,8 +4550,7 @@ describe('DecodeEncodeTest', function () {
*/
it('testencoding_textdecoder_ThrowError_003', 0, function () {
try {
- var that = new util.TextDecoder()
- that.create('utf-16be', 123)
+ var that = util.TextDecoder.create('utf-16be', 123)
var encodingStr = that.encoding
expect(encodingStr).assertEqual('utf-16be')
} catch (e) {
diff --git a/commonlibrary/ets_utils/worker_lib_standard/entry/src/main/module.json b/commonlibrary/ets_utils/worker_lib_standard/entry/src/main/module.json
index 666911d2b80a3ec58073ca634e6887162b776abf..25c631915b5eacce12c7fed244b2d2e2a5a59220 100644
--- a/commonlibrary/ets_utils/worker_lib_standard/entry/src/main/module.json
+++ b/commonlibrary/ets_utils/worker_lib_standard/entry/src/main/module.json
@@ -13,6 +13,12 @@
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [
{
"name": "com.example.workertest.MainAbility",
diff --git a/communication/BUILD.gn b/communication/BUILD.gn
index 08aed112359ceafb33ebf26a836965a22be30eec..7e7ac0c773f2ad5994d3184d1a14272edafd26fc 100644
--- a/communication/BUILD.gn
+++ b/communication/BUILD.gn
@@ -17,6 +17,7 @@ group("communication") {
if (is_standard_system) {
deps = [
"bluetooth_ble:ActsBluetoothBleJsTest",
+ "bluetooth_manager:ActsBluetoothBleJs1Test",
"bluetooth_on:ActsBluetoothOnJsTest",
"bluetooth_profile:ActsBluetoothProFileJsTest",
"bluetooth_standard:ActsBluetoothJsTest",
diff --git a/communication/bluetooth_manager/BUILD.gn b/communication/bluetooth_manager/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..80a55acca99f0afc583948daeab8887ca174ee4c
--- /dev/null
+++ b/communication/bluetooth_manager/BUILD.gn
@@ -0,0 +1,35 @@
+# 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("ActsBluetoothBleJs1Test") {
+ hap_profile = "./src/main/config.json"
+ deps = [
+ ":bluetooth_js_assets",
+ ":bluetooth_resources",
+ ]
+
+ certificate_profile = "./signature/openharmony_sx.p7b"
+ hap_name = "ActsBluetoothBleManagerHapTest"
+ part_name = "bluetooth"
+ subsystem_name = "communication"
+}
+ohos_js_assets("bluetooth_js_assets") {
+ js2abc = true
+ hap_profile = "./src/main/config.json"
+ source_dir = "./src/main/js"
+}
+ohos_resources("bluetooth_resources") {
+ sources = [ "./src/main/resources" ]
+ hap_profile = "./src/main/config.json"
+}
diff --git a/communication/bluetooth_manager/Test.json b/communication/bluetooth_manager/Test.json
new file mode 100644
index 0000000000000000000000000000000000000000..41e1389539144d66bc62697644fd2242d70a98c9
--- /dev/null
+++ b/communication/bluetooth_manager/Test.json
@@ -0,0 +1,20 @@
+{
+ "description": "Configuration for bluetooth js api Tests",
+ "driver": {
+ "type": "OHJSUnitTest",
+ "test-timeout": "600000",
+ "shell-timeout": "600000",
+ "bundle-name": "ohos.acts.communication.bluetooth.bluetoothhost",
+ "package-name": "ohos.acts.communication.bluetooth.bluetoothhost",
+ "testcase-timeout": 70000
+ },
+ "kits": [
+ {
+ "test-file-name": [
+ "ActsBluetoothBleManagerHapTest.hap"
+ ],
+ "type": "AppInstallKit",
+ "cleanup-apps": true
+ }
+ ]
+}
\ No newline at end of file
diff --git a/communication/bluetooth_manager/signature/openharmony_sx.p7b b/communication/bluetooth_manager/signature/openharmony_sx.p7b
new file mode 100644
index 0000000000000000000000000000000000000000..5f165bc5913d474d4e5bd0e5a2f3b492f5087a63
Binary files /dev/null and b/communication/bluetooth_manager/signature/openharmony_sx.p7b differ
diff --git a/communication/bluetooth_manager/src/main/config.json b/communication/bluetooth_manager/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..2b3e44f06cc9c61f7c22faec8570caeaebc07f74
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/config.json
@@ -0,0 +1,137 @@
+{
+ "app": {
+ "bundleName": "ohos.acts.communication.bluetooth.bluetoothhost",
+ "vendor": "acts",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "ohos.acts.communication.bluetooth.bluetoothhost",
+ "name": ".entry",
+ "deviceType": [
+ "tablet",
+ "default",
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "formsEnabled": false,
+ "name": ".MainAbility",
+ "srcLanguage": "js",
+ "srcPath": "MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:MainAbility_desc",
+ "label": "$string:MainAbility_label",
+ "type": "page",
+ "visible": true,
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "formsEnabled": false,
+ "name": ".TestAbility",
+ "srcLanguage": "js",
+ "srcPath": "TestAbility",
+ "icon": "$media:icon",
+ "description": "$string:TestAbility_desc",
+ "label": "$string:TestAbility_label",
+ "type": "page",
+ "visible": true,
+ "launchType": "standard"
+ }
+ ],
+ "js": [
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": "default",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": false
+ }
+ },
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": ".TestAbility",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": false
+ }
+ }
+ ],
+ "reqPermissions": [
+ {
+ "name": "ohos.permission.USE_BLUETOOTH",
+ "reason": "",
+ "usedScene": {
+ "ability": [
+ "ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
+ ],
+ "when": "inuse"
+ }
+ },
+ {
+ "name": "ohos.permission.MANAGE_BLUETOOTH",
+ "reason": "",
+ "usedScene": {
+ "ability": [
+ "ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
+ ],
+ "when": "inuse"
+ }
+ },
+ {
+ "name": "ohos.permission.DISCOVER_BLUETOOTH",
+ "reason": "",
+ "usedScene": {
+ "ability": [
+ "ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
+ ],
+ "when": "inuse"
+ }
+ },
+ {
+ "name": "ohos.permission.LOCATION",
+ "reason": "",
+ "usedScene": {
+ "ability": [
+ "ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
+ ],
+ "when": "inuse"
+ }
+ }
+ ],
+ "testRunner": {
+ "name": "OpenHarmonyTestRunner",
+ "srcPath": "TestRunner"
+ },
+ "mainAbility": ".MainAbility",
+ "srcPath": ""
+ }
+}
\ No newline at end of file
diff --git a/graphic/webGL/src/main/js/default/app.js b/communication/bluetooth_manager/src/main/js/MainAbility/app.js
similarity index 97%
rename from graphic/webGL/src/main/js/default/app.js
rename to communication/bluetooth_manager/src/main/js/MainAbility/app.js
index 1a469fd202c18a1e070e0c088005d5bb68243a13..363f2555b1badec9fec342a93141db084083fcb8 100644
--- a/graphic/webGL/src/main/js/default/app.js
+++ b/communication/bluetooth_manager/src/main/js/MainAbility/app.js
@@ -12,10 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
export default {
onCreate() {
console.info('AceApplication onCreate');
-
},
onDestroy() {
console.info('AceApplication onDestroy');
diff --git a/communication/bluetooth_manager/src/main/js/MainAbility/i18n/en-US.json b/communication/bluetooth_manager/src/main/js/MainAbility/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..a4c13dcbdc39c537073f638393d7726ac9a5cdc4
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/js/MainAbility/i18n/en-US.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ }
+}
\ No newline at end of file
diff --git a/communication/bluetooth_manager/src/main/js/MainAbility/i18n/zh-CN.json b/communication/bluetooth_manager/src/main/js/MainAbility/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..b1c02368f72f929e4375a43170444de95dcc5984
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/js/MainAbility/i18n/zh-CN.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ }
+}
\ No newline at end of file
diff --git a/communication/bluetooth_manager/src/main/js/MainAbility/pages/index/index.css b/communication/bluetooth_manager/src/main/js/MainAbility/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..e84b0d6300d7a299aed5376be2cba12327f9d9d2
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/js/MainAbility/pages/index/index.css
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2022 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;
+}
diff --git a/communication/bluetooth_manager/src/main/js/MainAbility/pages/index/index.hml b/communication/bluetooth_manager/src/main/js/MainAbility/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..43848d302f5c5cd40b7aad5e19f6c7ea15373d91
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/js/MainAbility/pages/index/index.hml
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/communication/bluetooth_manager/src/main/js/MainAbility/pages/index/index.js b/communication/bluetooth_manager/src/main/js/MainAbility/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..014e63a263c208b0afc5eb3809a206d5b879f038
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/js/MainAbility/pages/index/index.js
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2022 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 {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ console.info('onShow finish')
+ },
+ onReady() {
+ console.info('onReady finish')
+ },
+}
+
diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/TestAbility/app.js b/communication/bluetooth_manager/src/main/js/TestAbility/app.js
similarity index 100%
rename from security/cryptoFramework/js_api_test_two/src/main/js/TestAbility/app.js
rename to communication/bluetooth_manager/src/main/js/TestAbility/app.js
diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/TestAbility/i18n/en-US.json b/communication/bluetooth_manager/src/main/js/TestAbility/i18n/en-US.json
similarity index 100%
rename from security/cryptoFramework/js_api_test_two/src/main/js/TestAbility/i18n/en-US.json
rename to communication/bluetooth_manager/src/main/js/TestAbility/i18n/en-US.json
diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/TestAbility/i18n/zh-CN.json b/communication/bluetooth_manager/src/main/js/TestAbility/i18n/zh-CN.json
similarity index 100%
rename from security/cryptoFramework/js_api_test_two/src/main/js/TestAbility/i18n/zh-CN.json
rename to communication/bluetooth_manager/src/main/js/TestAbility/i18n/zh-CN.json
diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/TestAbility/pages/index/index.css b/communication/bluetooth_manager/src/main/js/TestAbility/pages/index/index.css
similarity index 100%
rename from security/cryptoFramework/js_api_test_two/src/main/js/TestAbility/pages/index/index.css
rename to communication/bluetooth_manager/src/main/js/TestAbility/pages/index/index.css
diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/TestAbility/pages/index/index.hml b/communication/bluetooth_manager/src/main/js/TestAbility/pages/index/index.hml
similarity index 100%
rename from security/cryptoFramework/js_api_test_two/src/main/js/TestAbility/pages/index/index.hml
rename to communication/bluetooth_manager/src/main/js/TestAbility/pages/index/index.hml
diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/TestAbility/pages/index/index.js b/communication/bluetooth_manager/src/main/js/TestAbility/pages/index/index.js
similarity index 100%
rename from security/cryptoFramework/js_api_test_two/src/main/js/TestAbility/pages/index/index.js
rename to communication/bluetooth_manager/src/main/js/TestAbility/pages/index/index.js
diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/communication/bluetooth_manager/src/main/js/TestRunner/OpenHarmonyTestRunner.js
similarity index 100%
rename from security/cryptoFramework/js_api_test_two/src/main/js/TestRunner/OpenHarmonyTestRunner.js
rename to communication/bluetooth_manager/src/main/js/TestRunner/OpenHarmonyTestRunner.js
diff --git a/communication/bluetooth_manager/src/main/js/test/BleAdvertiser.test.js b/communication/bluetooth_manager/src/main/js/test/BleAdvertiser.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..71ea19e33ef3e3788abc4c999034df05ceaca177
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/js/test/BleAdvertiser.test.js
@@ -0,0 +1,948 @@
+
+/*
+ * Copyright (C) 2022 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 bluetooth from '@ohos.bluetoothManager';
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
+
+
+export default function bluetoothBLETest2() {
+describe('bluetoothBLETest2', function() {
+ let gattServer = null;
+ function sleep(delay) {
+ return new Promise(resovle => setTimeout(resovle, delay))
+ }
+
+ async function tryToEnableBt() {
+ let sta = bluetooth.getState();
+ switch(sta){
+ case 0:
+ console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
+ bluetooth.enableBluetooth();
+ await sleep(3000);
+ break;
+ case 1:
+ console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
+ await sleep(3000);
+ break;
+ case 2:
+ console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
+ break;
+ case 3:
+ console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
+ bluetooth.enableBluetooth();
+ await sleep(3000);
+ break;
+ default:
+ console.info('[bluetooth_js] enable success');
+ }
+ }
+ beforeAll(async function (done) {
+ console.info('beforeAll called')
+ await tryToEnableBt()
+ gattServer = bluetooth.BLE.createGattServer();
+ done()
+ })
+ beforeEach(async function (done) {
+ console.info('beforeEach called')
+ await tryToEnableBt()
+ done()
+
+ })
+ afterEach(function () {
+ console.info('afterEach called')
+ })
+ afterAll(function () {
+ console.info('afterAll called')
+ gattServer.close();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0100
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 0
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0100', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:150,
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising1 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0200
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0200', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:20,
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising2 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0300
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0300', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:10485,
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising3 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0400
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0400', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:16400,
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising4 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0500
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0500', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:19,
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising5 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0800
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0800', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:1000,
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ expect(error.code).assertEqual('2900099');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0900
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_0900', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:1000,
+ txPower:-127,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising9 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1000
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1000', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:1000,
+ txPower:1,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ expect(error.code).assertEqual('2900099');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1100
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1100', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:1000,
+ txPower:10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ console.error('[bluetooth_js]startAdvertising11 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1200
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1200', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:1000,
+ txPower:-130,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ console.error('[bluetooth_js]startAdvertising12 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1400
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1400', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:1000,
+ txPower:1,
+ connectable:false,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ expect(error.code).assertEqual('2900099');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1500
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1500', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:1000,
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising15 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1800
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1800', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:1000,
+ txPower:1,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:[""],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:[""],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising18 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1900
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_1900', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:1000,
+ txPower:1,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising19 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ done();
+ })
+
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_2100
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_2100', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:1000,
+ txPower:1,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ gattServer.stopAdvertising();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising21 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_StartAdvertise_0400
+ * @tc.name testStartAdvertising
+ * @tc.desc Test StartAdvertising api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_StartAdvertise_0400', 0, function () {
+ let isRet = true;
+ try{
+ gattServer.stopAdvertising();
+ expect(isRet).assertTrue();
+ }catch(error){
+ console.info("[bluetooth_js] GattclientClose err:" + JSON.stringify(error));
+ let isRet = false;
+ expect(isRet).assertFalse();
+ }
+ })
+
+})
+
+}
diff --git a/communication/bluetooth_manager/src/main/js/test/BleAdvertiser401.test.js b/communication/bluetooth_manager/src/main/js/test/BleAdvertiser401.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..e770c8ff82b68bbaa1a2c02511b3338974708d04
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/js/test/BleAdvertiser401.test.js
@@ -0,0 +1,588 @@
+
+/*
+ * Copyright (C) 2022 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 bluetooth from '@ohos.bluetooth';
+import bluetooth from '@ohos.bluetoothManager';
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
+
+
+export default function bluetoothBLETest5() {
+describe('bluetoothBLETest5', function() {
+ let gattServer = null;
+ function sleep(delay) {
+ return new Promise(resovle => setTimeout(resovle, delay))
+ }
+
+ async function tryToEnableBt() {
+ let sta = bluetooth.getState();
+ switch(sta){
+ case 0:
+ console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
+ bluetooth.enableBluetooth();
+ await sleep(3000);
+ break;
+ case 1:
+ console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
+ await sleep(3000);
+ break;
+ case 2:
+ console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
+ break;
+ case 3:
+ console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
+ bluetooth.enableBluetooth();
+ await sleep(3000);
+ break;
+ default:
+ console.info('[bluetooth_js] enable success');
+ }
+ }
+ beforeAll(async function (done) {
+ console.info('beforeAll called')
+ await tryToEnableBt()
+ gattServer = bluetooth.BLE.createGattServer();
+ done()
+ })
+ beforeEach(async function (done) {
+ console.info('beforeEach called')
+ await tryToEnableBt()
+ done()
+ })
+ afterEach(function () {
+ console.info('afterEach called')
+ })
+ afterAll(function () {
+ console.info('afterAll called')
+ gattServer.close();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3000
+ * @tc.name testStartAdvertising
+ * @tc.desc Test api 401 - parameters setting is null.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 0
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3000', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(advData,advResponse);
+ gattServer.stopAdvertising();
+ expect(true).assertFalse();
+ }catch(error) {
+ console.error('[bluetooth_js]startAdvertising30 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3100
+ * @tc.name testStartAdvertising
+ * @tc.desc Test api 401 - parameters setting is error type.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3100', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(null,advData,advResponse);
+ gattServer.stopAdvertising();
+ expect(true).assertFalse();
+ }catch(error) {
+ console.error('[bluetooth_js]startAdvertising31 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3200
+ * @tc.name testStartAdvertising
+ * @tc.desc Test api 401 - interval of setting is error type.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3200', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:'sss',
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData);
+ gattServer.stopAdvertising();
+ expect(true).assertFalse();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising32 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3300
+ * @tc.name testStartAdvertising
+ * @tc.desc Test api 401 - txPower of setting is error type.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3300', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:10385,
+ txPower:'ttt',
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData);
+ gattServer.stopAdvertising();
+ expect(true).assertFalse();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising33 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3400
+ * @tc.name testStartAdvertising
+ * @tc.desc Test api 401 - connectable of setting is error type.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3400', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:10385,
+ txPower:-10,
+ connectable:123123,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData);
+ gattServer.stopAdvertising();
+ expect(true).assertFalse();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising34 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3500
+ * @tc.name testStartAdvertising
+ * @tc.desc Test api 401 - parameters advData is null.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3500', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:10385,
+ txPower:-10,
+ connectable:true,
+ }
+ try {
+ gattServer.startAdvertising(setting);
+ gattServer.stopAdvertising();
+ expect(true).assertFalse();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising35 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3600
+ * @tc.name testStartAdvertising
+ * @tc.desc Test api 401 - serviceUuids of advData is null.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3600', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:10385,
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData);
+ gattServer.stopAdvertising();
+ expect(true).assertFalse();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising36 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3700
+ * @tc.name testStartAdvertising
+ * @tc.desc Test api 401 - manufactureData of advData is null.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3700', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:10385,
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData);
+ gattServer.stopAdvertising();
+ expect(true).assertFalse();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising37 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3800
+ * @tc.name testStartAdvertising
+ * @tc.desc Test api 401 - serviceData of advData is null.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3800', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:10385,
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData);
+ gattServer.stopAdvertising();
+ expect(true).assertFalse();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising38 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3900
+ * @tc.name testStartAdvertising
+ * @tc.desc Test api 401 - manufactureValue of advData is error type.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_3900', 0, async function (done) {
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:10385,
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:123
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData);
+ gattServer.stopAdvertising();
+ expect(true).assertFalse();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising39 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_4000
+ * @tc.name testStartAdvertising
+ * @tc.desc Test api 401 - serviceValue of advData is error type.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AdvertiseData_4000', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let setting={
+ interval:10385,
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:123123
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData);
+ gattServer.stopAdvertising();
+ expect(true).assertFalse();
+ }catch(error) {
+ console.error(`[bluetooth_js]startAdvertising40 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+
+
+
+
+})
+
+}
diff --git a/communication/bluetooth_manager/src/main/js/test/BleGattManager.test.js b/communication/bluetooth_manager/src/main/js/test/BleGattManager.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..5a86892e054d0f73073642947acd4d29347cac8a
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/js/test/BleGattManager.test.js
@@ -0,0 +1,972 @@
+/*
+ * Copyright (C) 2022 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 bluetooth from '@ohos.bluetoothManager';
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
+
+export default function bluetoothBLETest() {
+describe('bluetoothBLETest', function() {
+ let gattServer = null;
+ let gattClient = null;
+ function sleep(delay) {
+ return new Promise(resovle => setTimeout(resovle, delay))
+ }
+
+ async function tryToEnableBt() {
+ let sta = bluetooth.getState();
+ switch(sta){
+ case 0:
+ console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
+ bluetooth.enableBluetooth();
+ await sleep(3000);
+ break;
+ case 1:
+ console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
+ await sleep(3000);
+ break;
+ case 2:
+ console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
+ break;
+ case 3:
+ console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
+ bluetooth.enableBluetooth();
+ await sleep(3000);
+ break;
+ default:
+ console.info('[bluetooth_js] enable success');
+ }
+ }
+ beforeAll(function () {
+ console.info('beforeAll called')
+ gattServer = bluetooth.BLE.createGattServer();
+ gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
+ })
+ beforeEach(async function(done) {
+ console.info('beforeEach called')
+ await tryToEnableBt()
+ done()
+ })
+ afterEach(function () {
+ console.info('afterEach called')
+ })
+ afterAll(async function (done) {
+ console.info('afterAll called')
+ await sleep(6000);
+ gattClient.close();
+ done()
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_GattConnect_0100
+ * @tc.name test gatt connect and disconnect
+ * @tc.desc Test api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_GattConnect_0100', 0, async function (done) {
+ try {
+ gattClient.connect();
+ await sleep(2000);
+ gattClient.disconnect();
+ expect(true).assertFalse();
+ } catch(error) {
+ console.error(`[bluetooth_js]disconnect failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ done()
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Connect_0200
+ * @tc.name testGetConnectedBLEDevices
+ * @tc.desc Test api 201 - Permission denied.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_GattConnect_0200', 0, function () {
+ try {
+ let result = bluetooth.BLE.getConnectedBLEDevices();
+ console.info("[bluetooth_js] getConnDev:" + JSON.stringify(result)
+ + "length:" +result.length);
+ expect(result.length).assertEqual(0);
+ } catch (error) {
+ console.error(`[bluetooth_js]getConnDev failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Connect_0300
+ * test Client BLEconnectStateChange
+ * @tc.desc Test on and off api
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_GattConnect_0300', 0, async function (done) {
+ try {
+ function ConnectStateChanged(state) {
+ console.log('bluetooth connect state changed');
+ let connectState = state.state;
+ console.info('[bluetooth_js] state changed' + connectState)
+ expect(true).assertEqual(connectState!=null);
+ }
+ await gattClient.on('BLEConnectionStateChange', ConnectStateChanged);
+ gattClient.connect();
+ gattClient.disconnect();
+ await sleep(2000);
+ await gattClient.off("BLEConnectionStateChange");
+ done()
+ } catch (error) {
+ console.error(`[bluetooth_js]GattConnect_0300 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0100
+ * @tc.name testgetRssiValue
+ * @tc.desc Test getRssiValue api by promise.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0100', 0, async function (done) {
+ try {
+ await gattClient.getRssiValue().then((data) => {
+ console.info('[bluetooth_js] BLE read rssi: ' + JSON.stringify(data));
+ let rssiLength = Object.keys(data).length;
+ expect(rssiLength).assertEqual(0);
+ done();
+ }).catch(err => {
+ console.info('bluetooth getRssiValue has error: '+ JSON.stringify(err));
+ done();
+ });
+ } catch (error) {
+ console.error(`[bluetooth_js]GetRssiValue_0100 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0200
+ * @tc.name testgetRssiValue
+ * @tc.desc Test testGetDeviceName api by callback.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0200', 0, async function (done) {
+ try {
+ let promise = new Promise((resolve) => {
+ gattClient.getRssiValue((err, data)=> {
+ if (err) {
+ console.error('getRssi failed ');
+ }
+ console.info('[bluetooth_js]getRssi value:'+JSON.stringify(data));
+ expect(data).assertNull();
+ });
+ resolve()
+ })
+ await promise.then(done)
+ } catch (error) {
+ console.error(`[bluetooth_js]GetRssiValue_0200 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_GetDeviceName_0100
+ * @tc.name testGetDeviceName
+ * @tc.desc Test GetDeviceName api by promise.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_GetDeviceName_0100', 0, async function (done) {
+ await sleep(5000)
+ try {
+ await gattClient.getDeviceName().then((data) => {
+ console.info('[bluetooth_js] device name' + JSON.stringify(data))
+ expect(data).assertNull();
+ done();
+ }).catch(err => {
+ console.error('bluetooth getDeviceName has error: '+ err);
+ expect(true).assertFalse();
+ done();
+ });
+ } catch (error) {
+ console.error(`[bluetooth_js]GetDeviceName_0100 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_getDeviceName_0200
+ * @tc.name testGetDeviceName
+ * @tc.desc Test testGetDeviceName api by callback.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_GetDeviceName_0200', 0, async function (done) {
+ try {
+ gattClient.getDeviceName((err, data)=> {
+ if (err) {
+ console.error('getname1 failed ');
+ }
+ console.info('[bluetooth_js]getname value:'+JSON.stringify(data));
+ expect(data).assertNull();
+ });
+ await sleep(2000);
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]GetDeviceName_0200 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_GetService_0100
+ * @tc.name testGetServices
+ * @tc.desc Test GetServices api by promise.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_GetService_0100', 0, async function (done) {
+ try {
+ await gattClient.getServices().then((GattService) => {
+ console.info('[bluetooth_js] getServices successfully:'+JSON.stringify(GattService));
+ expect(GattService).assertNull();
+ done();
+ }).catch(err => {
+ console.error('[bluetooth_js] getServices has error:'+ JSON.stringify(err));
+ expect(true).assertEqual(true);
+ done();
+ });
+ } catch (error) {
+ console.error(`[bluetooth_js]GetService_0100 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_GetService_0200
+ * @tc.name testGetServices
+ * @tc.desc Test GetServices api by callback.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_GetService_0200', 0, async function (done) {
+ try {
+ gattClient.getServices((code, data)=> {
+ if(code.code==0){
+ console.info("bluetooth services size is ", data.length)
+ expect(true).assertEqual(data.length >= 0);
+ } else {
+ console.info('[bluetooth_js] get services code ' + JSON.stringify(code));
+ expect(true).assertEqual(code.code == -1);
+ }
+ done();
+ });
+ } catch (error) {
+ console.error(`[bluetooth_js]GetService_0200 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_MtuSize_0100
+ * @tc.name testSetBLEMtuSize
+ * @tc.desc Test SetBLEMtuSize api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_MtuSize_0100', 0, function () {
+ try {
+ gattClient.setBLEMtuSize(100);
+ console.info("[bluetooth_js]setBLEMtuSize success")
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]MtuSize_0100 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_MtuSize_0200
+ * @tc.name testSetBLEMtuSize
+ * @tc.desc Test SetBLEMtuSize api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_MtuSize_0200', 0, function () {
+ try {
+ gattClient.setBLEMtuSize(22);
+ console.info("[bluetooth_js]setBLEMtuSize success")
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]MtuSize_0200 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_MtuSize_0300
+ * @tc.name testSetBLEMtuSize
+ * @tc.desc Test SetBLEMtuSize api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_MtuSize_0300', 0, function () {
+ try {
+ gattClient.setBLEMtuSize(21);
+ console.info("[bluetooth_js]setBLEMtuSize success")
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]MtuSize_0300 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_MtuSize_0400
+ * @tc.name testSetBLEMtuSize
+ * @tc.desc Test SetBLEMtuSize api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_MtuSize_0400', 0, function () {
+ try {
+ gattClient.setBLEMtuSize(512);
+ console.info("[bluetooth_js]setBLEMtuSize success")
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]MtuSize_0400 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_MtuSize_0500
+ * @tc.name testSetBLEMtuSize
+ * @tc.desc Test SetBLEMtuSize api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_MtuSize_0500', 0, function () {
+ try {
+ gattClient.setBLEMtuSize(513);
+ console.info("[bluetooth_js]setBLEMtuSize success")
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]MtuSize_0500 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1900
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test ReadDescriptorValue api by promise.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1900', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ expect(true).assertEqual(data.length>=0);
+ done();
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue19 promise has error: ${err}`);
+ expect(true).assertEqual(true);
+ done();
+ })
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue19 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_2000
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test ReadDescriptorValue api by callback.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_2000', 0, async function(done) {
+ try {
+ function readCcc(code, BLECharacteristic) {
+ if (code.code != 0) {
+ return;
+ }
+ console.log('bluetooth characteristic uuid:'+ BLECharacteristic.characteristicUuid);
+ expect(true).assertEqual(data==null);
+ let value = new Uint8Array(BLECharacteristic.characteristicValue);
+ console.log('bluetooth characteristic value: '
+ + value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
+ }
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.readCharacteristicValue(characteristic,readCcc);
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue20 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_2100
+ * @tc.name test characteristicReadOn
+ * @tc.desc Test On and off api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_2100', 0, async function (done) {
+ try {
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 1123;
+ function ReadCharacteristicReq(CharacteristicReadReq) {
+ let deviceId = CharacteristicReadReq.deviceId;
+ let transId = CharacteristicReadReq.transId;
+ let offset = CharacteristicReadReq.offset;
+ let characteristicUuid = CharacteristicReadReq.characteristicUuid;
+
+ let serverResponse = {deviceId: deviceId, transId: transId,
+ status: 0, offset: offset, value:arrayBufferCCC};
+ gattServer.sendResponse(serverResponse);
+ }
+ let gattServer = bluetooth.BLE.createGattServer();
+ await gattServer.on("characteristicRead", ReadCharacteristicReq);
+ await gattServer.off("characteristicRead");
+ gattServer.close();
+ done()
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue21 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_1300
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test ReadDescriptorValue api by promise.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_1300', 0, async function (done) {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ await gattClient.readDescriptorValue(descriptor).then((object) => {
+ console.info('[bluetooth_js]readDescripValue null:' + JSON.stringify(object));
+ expect(true).assertEqual(object!=null);
+ done();
+ }).catch(err => {
+ console.error('[bluetooth_js]readDescrValue promise err:'+JSON.stringify(err))
+ expect(true).assertEqual(true);
+ done();
+ })
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error('[bluetooth_js]readDescrValue13 error code:'+JSON.stringify(error.code));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_1400
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test ReadDescriptorValue api by callback.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_1400', 0, async function (done) {
+ try {
+ function readDesc(code, BLEDescriptor) {
+ if (code.code != 0) {
+ console.info('[bluetooth_js] descriptor code: ' + BLEDescriptor.descriptorUuid);
+ expect(true).assertEqual(BLEDescriptor.descriptorUuid==null);
+ }
+ console.info('[bluetooth_js] descriptor uuid: ' + BLEDescriptor.descriptorUuid);
+ let value = new Uint8Array(BLEDescriptor.descriptorValue);
+ console.info('[bluetooth_js] descriptor value: '
+ + value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
+ }
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ gattClient.readDescriptorValue(descriptor,readDesc);
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]readDescrValue14 error code:'+JSON.stringify(error));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_1500
+ * @tc.name test ReadDescriptorOn
+ * @tc.desc Test On and Off api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_1500', 0, async function (done) {
+ try {
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 1011;
+ function ReadDescriptorReq(DescriptorReadReq) {
+ let deviceId = DescriptorReadReq.deviceId;
+ let transId = DescriptorReadReq.transId;
+ let offset = DescriptorReadReq.offset;
+ let characteristicUuid = DescriptorReadReq.characteristicUuid;
+
+ let serverResponse = {deviceId: deviceId, transId: transId,
+ status: 0, offset: offset, value:arrayBufferCCC};
+ gattServer.sendResponse(serverResponse);
+ console.info("[bluetooth_js] DesRedon jsondata:" +
+ 'deviceId:' + deviceId + 'transId:' +transId + 'offset:' +
+ offset +'descriptorUuid:' + DescriptorReadReq.descriptorUuid +
+ 'characteristicUuid:' +characteristicUuid +
+ 'serviceUuid:' + DescriptorReadReq.serviceUuid);
+ expect(true).assertEqual(DescriptorReadReq !=null);
+ }
+ let gattServer = bluetooth.BLE.createGattServer();
+ await gattServer.on("descriptorRead", ReadDescriptorReq);
+ await gattServer.off("descriptorRead");
+ gattServer.close();
+ done()
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue15 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1900
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test Client WriteCharacteristicValue api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1900', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]writeCharacteristicValue19 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_2000
+ * @tc.name test characteristicWriteOn
+ * @tc.desc Test on and off api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_2000', 0, async function (done) {
+ try {
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ function WriteCharacteristicReq(CharacteristicWriteReq) {
+ let deviceId = CharacteristicWriteReq.deviceId;
+ let transId = CharacteristicWriteReq.transId;
+ let offset = CharacteristicWriteReq.offset;
+ let isPrep = CharacteristicWriteReq.isPrep;
+ let needRsp = CharacteristicWriteReq.needRsp;
+ let value = new Uint8Array(CharacteristicWriteReq.value);
+ let characteristicUuid = CharacteristicWriteReq.characteristicUuid;
+
+ cccValue[0] = value[0];
+ let serverResponse = {deviceId: deviceId, transId: transId,
+ status: 0, offset: offset, value:arrayBufferCCC};
+ gattServer.sendResponse(serverResponse);
+ }
+ let gattServer = bluetooth.BLE.createGattServer();
+ gattServer.on("characteristicWrite", WriteCharacteristicReq);
+ gattServer.off("characteristicWrite");
+ gattServer.close();
+ done()
+ } catch (error) {
+ console.error(`[bluetooth_js]writeCharacteristicValue20 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_1100
+ * @tc.name testWriteDescriptorValue
+ * @tc.desc Test Client WriteDescriptorValue api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_1100', 0, function () {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ gattClient.writeDescriptorValue(descriptor);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]writeDescriptorValue11 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_1200
+ * @tc.name test WriteDescriptorOn
+ * @tc.desc Test on and off api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_1200', 0, async function (done) {
+ try {
+ let arrayBufferDesc = new ArrayBuffer(8);
+ let descValue = new Uint8Array(arrayBufferDesc);
+ function WriteDescriptorReq(DescriptorWriteReq) {
+ let deviceId = DescriptorWriteReq.deviceId;
+ let transId = DescriptorWriteReq.transId;
+ let offset = DescriptorWriteReq.offset;
+ let isPrep = DescriptorWriteReq.isPrep;
+ let needRsp = DescriptorWriteReq.needRsp;
+ let value = new Uint8Array(DescriptorWriteReq.value);
+ let descriptorUuid = DescriptorWriteReq.descriptorUuid;
+ descValue[0] = value[0];
+ let serverResponse = {deviceId: deviceId, transId: transId,
+ status: 0, offset: offset, value:arrayBufferDesc};
+ gattServer.sendResponse(serverResponse);
+ console.info("[bluetooth_js] desWriOn jsondata: " +'deviceId: '
+ + deviceId + 'transId:' + transId + 'offset:' + offset +'descriptorUuid:'
+ + descriptorUuid + 'charUuid:' + DescriptorWriteReq.characteristicUuid +
+ 'serviceUuid:' + DescriptorWriteReq.serviceUuid +
+ 'value:' + DescriptorWriteReq.value + 'needRsp' +
+ needRsp + 'isPrep:' +isPrep );
+ expect(true).assertEqual(DescriptorWriteReq !=null);
+ }
+ let gattServer = bluetooth.BLE.createGattServer();
+ gattServer.on("descriptorWrite", WriteDescriptorReq);
+ gattServer.off("descriptorWrite");
+ gattServer.close();
+ done()
+ } catch (error) {
+ console.error(`[bluetooth_js]writeDescriptorValue12 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_1200
+ * @tc.name testSetNotifyCharacteristicChanged
+ * @tc.desc Test SetNotifyCharacteristicChanged api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_1200', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let arrayBufferNotify = new ArrayBuffer(8);
+ let descNotifyValue = new Uint8Array(arrayBufferNotify);
+ descNotifyValue[0] = 1
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ let descriptorNotify = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBufferNotify};
+ descriptors[0] = descriptor;
+ descriptors[1] = descriptorNotify;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.setNotifyCharacteristicChanged(characteristic, true);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged12 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_1300
+ * @tc.name testSetNotifyCharacteristicChanged
+ * @tc.desc Test SetNotifyCharacteristicChanged api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_1300', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let arrayBufferNotify = new ArrayBuffer(8);
+ let descNotifyValue = new Uint8Array(arrayBufferNotify);
+ descNotifyValue[0] = 1
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ let descriptorNotify = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBufferNotify};
+ descriptors[0] = descriptor;
+ descriptors[1] = descriptorNotify;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.setNotifyCharacteristicChanged(characteristic, false);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged13 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_1400
+ * @tc.name test BLECharacteristicChangeON
+ * @tc.desc Test On and off api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_1400', 0, async function (done) {
+ try {
+ function CharacteristicChange(CharacteristicChangeReq) {
+ let serviceUuid = CharacteristicChangeReq.serviceUuid;
+ let characteristicUuid = CharacteristicChangeReq.characteristicUuid;
+ let value = new Uint8Array(CharacteristicChangeReq.characteristicValue);
+ expect(true).assertEqual(CharacteristicChangeReq !=null);
+ }
+ gattClient.on('BLECharacteristicChange', CharacteristicChange);
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.setNotifyCharacteristicChanged(characteristic, false);
+ gattClient.off('BLECharacteristicChange');
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged14 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_GattClose_0100
+ * @tc.name test gattClient close
+ * @tc.desc Test close api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_GattClose_0100', 0, async function (done) {
+ try {
+ let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
+ gattClient.close();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]GattClose_0100 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+})
+}
+
+
diff --git a/communication/bluetooth_manager/src/main/js/test/BleGattManager401.test.js b/communication/bluetooth_manager/src/main/js/test/BleGattManager401.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..ed7b5f7c00cd6c65d009b89d644994a864bf8e25
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/js/test/BleGattManager401.test.js
@@ -0,0 +1,2316 @@
+/*
+ * Copyright (C) 2022 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 bluetooth from '@ohos.bluetooth';
+import bluetooth from '@ohos.bluetoothManager';
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
+
+export default function bluetoothBLETest4() {
+describe('bluetoothBLETest4', function() {
+ let gattClient = null;
+ function sleep(delay) {
+ return new Promise(resovle => setTimeout(resovle, delay))
+ }
+
+ async function tryToEnableBt() {
+ let sta = bluetooth.getState();
+ switch(sta){
+ case 0:
+ console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
+ bluetooth.enableBluetooth();
+ await sleep(3000);
+ break;
+ case 1:
+ console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
+ await sleep(3000);
+ break;
+ case 2:
+ console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
+ break;
+ case 3:
+ console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
+ bluetooth.enableBluetooth();
+ await sleep(3000);
+ break;
+ default:
+ console.info('[bluetooth_js] enable success');
+ }
+ }
+ beforeAll(function () {
+ console.info('beforeAll called')
+ gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
+ })
+ beforeEach(async function(done) {
+ console.info('beforeEach called')
+ await tryToEnableBt()
+ done()
+ })
+ afterEach(function () {
+ console.info('afterEach called')
+ })
+ afterAll(async function (done) {
+ console.info('afterAll called')
+ await sleep(6000);
+ gattClient.close();
+ done()
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_MtuSize_0200
+ * @tc.name testSetBLEMtuSize
+ * @tc.desc Test api 401 - Invalid null parameters.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('SUB_COMMUNICATION_BLUETOOTH_BLE_MtuSize_0200', 0, function () {
+ try {
+ gattClient.setBLEMtuSize();
+ expect(true).assertFalse();
+ } catch(error) {
+ console.error('[bluetooth_js]error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_MtuSize_0300
+ * @tc.name testSetBLEMtuSize
+ * @tc.desc Test api 401 -error type.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_MtuSize_0300', 0, function () {
+ try {
+ gattClient.setBLEMtuSize(null);
+ expect(true).assertFalse();
+ } catch(error) {
+ console.error(`[bluetooth_js]setBLEMtuSize3 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0100
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - Invalid null parameters.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0100', 0, async function (done) {
+ try {
+ await gattClient.readCharacteristicValue().then((data) => {
+ if (object != null) {
+ expect(true).assertEqual(true);
+ } else {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue1 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0200
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - Invalid null parameters.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0200', 0, async function (done) {
+ try {
+ await gattClient.readCharacteristicValue(null).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue2 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0300
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - null serviceUuid.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0300', 0, async function (done) {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue3 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0400
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - if serviceUuid type is error.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0400', 0, async function (done) {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: 123,
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue4 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0500
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - null characteristicUuid.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0500', 0, async function (done) {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue5 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0600
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - if characteristicUuid is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0600', 0, async function (done) {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: null,
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue6 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0700
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - null characteristicValue.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0700', 0, async function (done) {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', descriptors:descriptors};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue7 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0800
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - if characteristicValue is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0800', 0, async function (done) {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: null, descriptors:descriptors};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue8 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0900
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - null descriptors.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0900', 0, async function (done) {
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue9 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1000
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - if descriptors type is error.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1000', 0, async function (done) {
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:123};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue10 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1100
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - if serviceUuid of descriptors is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1100', 0, async function (done) {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue11 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1200
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - if serviceUuid of descriptors is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1200', 0, async function (done) {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: 1111222,
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue12 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1300
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - if descriptorUuid of descriptors is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1300', 0, async function (done) {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue13 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1400
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - if descriptorUuid of descriptors is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1400', 0, async function (done) {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: 444555,
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue14 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done();
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1500
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - if descriptorValue of descriptors is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1500', 0, async function (done) {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB'};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done()
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue15 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1600
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - if descriptorValue of descriptors is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1600', 0, async function (done) {
+ let descriptors = [];
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: 4455};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ try {
+ await gattClient.readCharacteristicValue(characteristic).then((data) => {
+ console.info('[bluetooth_js] readCharacValue promise data:'
+ + JSON.stringify(data));
+ }).catch(err => {
+ console.error(`bluetooth readCharacteValue promise has error: ${err}`);
+ expect(true).assertFalse();
+ });
+ done()
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue16 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1700
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 -null api by callback.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1700', 0, async function(done) {
+ try {
+ gattClient.readCharacteristicValue();
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]readCharacteValue17 failed, error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1800
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 -null readCharacteristicValue by callback.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_1800', 0, async function(done) {
+ try {
+ function readCcc(code, BLECharacteristic) {
+ if (coderror.code != 0) {
+ return;
+ }
+ console.log('bluetooth characteristic uuid:'+ BLECharacteristic.characteristicUuid);
+ expect(true).assertEqual(data==null);
+ let value = new Uint8Array(BLECharacteristic.characteristicValue);
+ console.log('bluetooth characteristic value: '
+ + value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
+ }
+ gattClient.readCharacteristicValue(null,readCcc);
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue18 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0100
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - null descriptor.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0100', 0, async function (done) {
+ try {
+ await gattClient.readDescriptorValue().then((object) => {
+ if (object != null) {
+ console.error('readDescriptorValue promise object:'+JSON.stringify(object));
+ } else {
+ console.info('[bluetooth_js]readDescripValue null:' + JSON.stringify(object));
+ expect(true).assertFalse();
+ }
+ }).catch(err => {
+ console.error('[bluetooth_js]readDescrValue promise err:'+JSON.stringify(err));
+ expect(true).assertFalse();
+ })
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue1 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0200
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - descriptor is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0200', 0, async function (done) {
+ try {
+ await gattClient.readDescriptorValue(null).then((object) => {
+ if (object != null) {
+ console.error('readDescriptorValue promise object:'+JSON.stringify(object));
+
+ } else {
+ console.info('[bluetooth_js]readDescripValue null:' + JSON.stringify(object));
+ expect(true).assertFalse();
+ }
+ done();
+ }).catch(err => {
+ console.error('[bluetooth_js]readDescrValue promise err:'+JSON.stringify(err));
+ expect(true).assertFalse();
+ done();
+ })
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue2 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0300
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - serviceUuid of descriptor is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0300', 0, async function (done) {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {
+ characteristicUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ await gattClient.readDescriptorValue(descriptor).then((object) => {
+ if (object != null) {
+ console.error('readDescriptorValue promise object:'+JSON.stringify(object));
+
+ } else {
+ console.info('[bluetooth_js]readDescripValue null:' + JSON.stringify(object));
+ expect(true).assertFalse();
+ }
+ done();
+ }).catch(err => {
+ console.error('[bluetooth_js]readDescrValue promise err:'+JSON.stringify(err));
+ expect(true).assertFalse();
+ done();
+ })
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue3 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0400
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - serviceUuid of descriptor is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0400', 0, async function (done) {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = { serviceUuid: 1234,
+ characteristicUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ await gattClient.readDescriptorValue(descriptor).then((object) => {
+ if (object != null) {
+ console.error('readDescriptorValue promise object:'+JSON.stringify(object));
+
+ } else {
+ console.info('[bluetooth_js]readDescripValue null:' + JSON.stringify(object));
+ expect(true).assertFalse();
+ }
+ done();
+ }).catch(err => {
+ console.error('[bluetooth_js]readDescrValue promise err:'+JSON.stringify(err));
+ expect(true).assertFalse();
+ done();
+ })
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue4 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0500
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - characteristicUuid of descriptor is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0500', 0, async function (done) {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ await gattClient.readDescriptorValue(descriptor).then((object) => {
+ if (object != null) {
+ console.error('readDescriptorValue promise object:'+JSON.stringify(object));
+
+ } else {
+ console.info('[bluetooth_js]readDescripValue null:' + JSON.stringify(object));
+ expect(true).assertFalse();
+ }
+ done();
+ }).catch(err => {
+ console.error('[bluetooth_js]readDescrValue promise err:'+JSON.stringify(err));
+ expect(true).assertFalse();
+ done();
+ })
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue5 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0600
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - characteristicUuid of descriptor is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0600', 0, async function (done) {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: 1234,
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ await gattClient.readDescriptorValue(descriptor).then((object) => {
+ if (object != null) {
+ console.error('readDescriptorValue promise object:'+JSON.stringify(object));
+
+ } else {
+ console.info('[bluetooth_js]readDescripValue null:' + JSON.stringify(object));
+ expect(true).assertFalse();
+ }
+ done();
+ }).catch(err => {
+ console.error('[bluetooth_js]readDescrValue promise err:'+JSON.stringify(err));
+ expect(true).assertFalse();
+ done();
+ })
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue6 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0700
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - descriptorUuid of descriptor is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0700', 0, async function (done) {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ await gattClient.readDescriptorValue(descriptor).then((object) => {
+ if (object != null) {
+ console.error('readDescriptorValue promise object:'+JSON.stringify(object));
+
+ } else {
+ console.info('[bluetooth_js]readDescripValue null:' + JSON.stringify(object));
+ expect(true).assertFalse();
+ }
+ done();
+ }).catch(err => {
+ console.error('[bluetooth_js]readDescrValue promise err:'+JSON.stringify(err));
+ expect(true).assertFalse();
+ done();
+ })
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue7 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0800
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - descriptorUuid of descriptor is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0800', 0, async function (done) {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: 1234,
+ descriptorValue: arrayBuffer};
+ await gattClient.readDescriptorValue(descriptor).then((object) => {
+ if (object != null) {
+ console.error('readDescriptorValue promise object:'+JSON.stringify(object));
+
+ } else {
+ console.info('[bluetooth_js]readDescripValue null:' + JSON.stringify(object));
+ expect(true).assertFalse();
+ }
+ done();
+ }).catch(err => {
+ console.error('[bluetooth_js]readDescrValue promise err:'+JSON.stringify(err));
+ expect(true).assertFalse();
+ done();
+ })
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue8 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0900
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - descriptorValue of descriptor is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0900', 0, async function (done) {
+ try {
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB'};
+ await gattClient.readDescriptorValue(descriptor).then((object) => {
+ if (object != null) {
+ console.error('readDescriptorValue promise object:'+JSON.stringify(object));
+
+ } else {
+ console.info('[bluetooth_js]readDescripValue null:' + JSON.stringify(object));
+ expect(true).assertFalse();
+ }
+ done();
+ }).catch(err => {
+ console.error('[bluetooth_js]readDescrValue promise err:'+JSON.stringify(err));
+ expect(true).assertFalse();
+ done();
+ })
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue9 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_1000
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 - descriptorValue of descriptor is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_1000', 0, async function (done) {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: 1236454};
+ await gattClient.readDescriptorValue(descriptor).then((object) => {
+ if (object != null) {
+ console.error('readDescriptorValue promise object:'+JSON.stringify(object));
+
+ } else {
+ console.info('[bluetooth_js]readDescripValue null:' + JSON.stringify(object));
+ expect(true).assertFalse();
+ }
+ done();
+ }).catch(err => {
+ console.error('[bluetooth_js]readDescrValue promise err:'+JSON.stringify(err));
+ expect(true).assertFalse();
+ done();
+ })
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue10 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_1100
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 -null readDescriptorValue by callback.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_1100', 0, async function (done) {
+ try {
+ gattClient.readDescriptorValue();
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue11 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_1200
+ * @tc.name testReadDescriptorValue
+ * @tc.desc Test 401 -null readDescriptorValue by callback.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_1200', 0, async function (done) {
+ try {
+ function readDesc(code, BLEDescriptor) {
+ if (code.code != 0) {
+ console.info('[bluetooth_js] descriptor code: ' + BLEDescriptor.descriptorUuid);
+ expect(true).assertEqual(BLEDescriptor.descriptorUuid==null);
+ }
+ console.info('[bluetooth_js] descriptor uuid: ' + BLEDescriptor.descriptorUuid);
+ let value = new Uint8Array(BLEDescriptor.descriptorValue);
+ console.info('[bluetooth_js] descriptor value: '
+ + value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
+ }
+ gattClient.readDescriptorValue(null,readDesc);
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error(`[bluetooth_js]readDescrValue12 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0100
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 - api of null parameter.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0100', 0, function () {
+ try {
+ gattClient.writeCharacteristicValue();
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue1 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0200
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 - api of error parameter.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0200', 0, function () {
+ try {
+ gattClient.writeCharacteristicValue(null);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue2 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0300
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 -null serviceUuid.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0300', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue3 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0400
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 -serviceUuid is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0400', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: 123123,
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue4 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0500
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 - null characteristicUuid.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0500', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue5 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0600
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 - characteristicUuid is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0600', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: 123123,
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue6 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0700
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 - null characteristicValue.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0700', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue7 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0800
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 - characteristicValue is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0800', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: "string", descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue8 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0900
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 - null descriptors.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0900', 0, function () {
+ try {
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue9 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1000
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 -descriptors is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1000', 0, function () {
+ try {
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:'123ss'};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue10 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1100
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 -null serviceUuid of descriptors.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1100', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue11 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1200
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 -serviceUuid of descriptors is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1200', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid:123123,
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue12 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1300
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 -characteristicUuid of descriptors is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1300', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid:'00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue13 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1400
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 -characteristicUuid of descriptors is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1400', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid:'00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: 123123,
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue14 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1500
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 -descriptorUuid of descriptors is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1500', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid:'00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue15 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1600
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 -descriptorUuid of descriptors is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1600', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid:'00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: 123123, descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue16 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1700
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 -descriptorValue of descriptors is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1600', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid:'00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue17 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1800
+ * @tc.name testWriteCharacteristicValue
+ * @tc.desc Test 401 -descriptorValue of descriptors is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_1800', 0, function () {
+ try {
+ let descriptors = [];
+ let descriptor = {serviceUuid:'00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: "string"};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 32;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.writeCharacteristicValue(characteristic);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]readCharacteValue18 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0100
+ * @tc.name testWriteDescriptorValue
+ * @tc.desc Test 401 - api is null parameter.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0100', 0, function () {
+ try {
+ gattClient.writeDescriptorValue();
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]writeDescriptorValue1 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0200
+ * @tc.name testWriteDescriptorValue
+ * @tc.desc Test 401 - api is error parameter.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0200', 0, function () {
+ try {
+ gattClient.writeDescriptorValue(null);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]writeDescriptorValue2 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0300
+ * @tc.name testWriteDescriptorValue
+ * @tc.desc Test 401 - null serviceUuid.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0300', 0, function () {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ gattClient.writeDescriptorValue(descriptor);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]writeDescriptorValue3 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0400
+ * @tc.name testWriteDescriptorValue
+ * @tc.desc Test 401 - serviceUuid is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0400', 0, function () {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: 123123,
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ gattClient.writeDescriptorValue(descriptor);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]writeDescriptorValue4 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0500
+ * @tc.name testWriteDescriptorValue
+ * @tc.desc Test 401 - characteristicUuid is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0500', 0, function () {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ gattClient.writeDescriptorValue(descriptor);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]writeDescriptorValue5 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0600
+ * @tc.name testWriteDescriptorValue
+ * @tc.desc Test 401 - characteristicUuid is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0600', 0, function () {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: 123123,
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ gattClient.writeDescriptorValue(descriptor);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]writeDescriptorValue6 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0700
+ * @tc.name testWriteDescriptorValue
+ * @tc.desc Test 401 - descriptorUuid is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0700', 0, function () {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ gattClient.writeDescriptorValue(descriptor);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]writeDescriptorValue7 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0800
+ * @tc.name testWriteDescriptorValue
+ * @tc.desc Test 401 - descriptorUuid is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0800', 0, function () {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: 123123, descriptorValue: arrayBuffer};
+ gattClient.writeDescriptorValue(descriptor);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]writeDescriptorValue8 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0900
+ * @tc.name testWriteDescriptorValue
+ * @tc.desc Test 401 - descriptorValue is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0900', 0, function () {
+ try {
+ let descriptor = {serviceUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB'};
+ gattClient.writeDescriptorValue(descriptor);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]writeDescriptorValue9 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_1000
+ * @tc.name testWriteDescriptorValue
+ * @tc.desc Test 401 - descriptorValue is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_1000', 0, function () {
+ try {
+ let descriptor = {serviceUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: 'string'};
+ gattClient.writeDescriptorValue(descriptor);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]writeDescriptorValue10 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0100
+ * @tc.name testSetNotifyCharacteristicChanged
+ * @tc.desc Test 401 - parameter of api is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0100', 0, function () {
+ try {
+ gattClient.setNotifyCharacteristicChanged();
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged1 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0200
+ * @tc.name testSetNotifyCharacteristicChanged
+ * @tc.desc Test 401 - first parameter of api is error type .
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0200', 0, function () {
+ try {
+ gattClient.setNotifyCharacteristicChanged(null, true);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged2 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0300
+ * @tc.name testSetNotifyCharacteristicChanged
+ * @tc.desc Test 401 - second parameter of api is null .
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0300', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.setNotifyCharacteristicChanged(characteristic, 222);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged3 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0400
+ * @tc.name testSetNotifyCharacteristicChanged
+ * @tc.desc Test 401 - serviceUuid is null .
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0400', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 1;
+ let characteristic = {
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.setNotifyCharacteristicChanged(characteristic, true);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged4 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0500
+ * @tc.name testSetNotifyCharacteristicChanged
+ * @tc.desc Test 401 - serviceUuid is error type .
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0500', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 1;
+ let characteristic = {serviceUuid:123123,
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.setNotifyCharacteristicChanged(characteristic, true);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged5 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0600
+ * @tc.name testSetNotifyCharacteristicChanged
+ * @tc.desc Test 401 - characteristicUuid is null .
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0600', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 1;
+ let characteristic = {serviceUuid:'00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.setNotifyCharacteristicChanged(characteristic, true);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged6 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0700
+ * @tc.name testSetNotifyCharacteristicChanged
+ * @tc.desc Test 401 - characteristicUuid is error type .
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0700', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 1;
+ let characteristic = {serviceUuid:'00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: 123123,
+ characteristicValue: arrayBufferCCC, descriptors:descriptors};
+ gattClient.setNotifyCharacteristicChanged(characteristic, true);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged7 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0800
+ * @tc.name testSetNotifyCharacteristicChanged
+ * @tc.desc Test 401 - characteristicValue is null .
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0800', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 1;
+ let characteristic = {serviceUuid:'00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', descriptors:descriptors};
+ gattClient.setNotifyCharacteristicChanged(characteristic, true);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged8 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0900
+ * @tc.name testSetNotifyCharacteristicChanged
+ * @tc.desc Test 401 - characteristicValue is error type .
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0900', 0, function () {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let desValue = new Uint8Array(arrayBuffer);
+ desValue[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
+ descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristic = {serviceUuid:'00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: '123', descriptors:descriptors};
+ gattClient.setNotifyCharacteristicChanged(characteristic, true);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged9 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_1000
+ * @tc.name testSetNotifyCharacteristicChanged
+ * @tc.desc Test 401 - descriptors is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_1000', 0, function () {
+ try {
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 1;
+ let characteristic = {serviceUuid:'00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC};
+ gattClient.setNotifyCharacteristicChanged(characteristic, true);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged10 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_1100
+ * @tc.name testSetNotifyCharacteristicChanged
+ * @tc.desc Test 401 - descriptors is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_1100', 0, function () {
+ try {
+ let arrayBufferCCC = new ArrayBuffer(8);
+ let cccValue = new Uint8Array(arrayBufferCCC);
+ cccValue[0] = 1;
+ let characteristic = {serviceUuid:'00001820-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferCCC, descriptors:'123'};
+ gattClient.setNotifyCharacteristicChanged(characteristic, true);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]setNotifyCharacteristicChanged11 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_createGattClientDevice_0100
+ * @tc.name test createGattClientDevice
+ * @tc.desc Test createGattClientDevice 401.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_createGattClientDevice_0100', 0, async function (done) {
+ try {
+ let gattClient = bluetooth.BLE.createGattClientDevice();
+ gattClient.close();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]createGattClientDevice01 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_createGattClientDevice_0200
+ * @tc.name test createGattClientDevice
+ * @tc.desc Test createGattClientDevice 401.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_createGattClientDevice_0200', 0, async function (done) {
+ try {
+ let gattClient = bluetooth.BLE.createGattClientDevice(null);
+ gattClient.close();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]createGattClientDevice02 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+})
+}
+
+
diff --git a/communication/bluetooth_manager/src/main/js/test/BleScanResult.test.js b/communication/bluetooth_manager/src/main/js/test/BleScanResult.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..5093ede64819284677eead808e09ba53e3c292d8
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/js/test/BleScanResult.test.js
@@ -0,0 +1,797 @@
+/*
+ * Copyright (C) 2022 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 bluetooth from '@ohos.bluetoothManager';
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
+
+export default function bluetoothBLETest6() {
+describe('bluetoothBLETest6', function() {
+ function sleep(delay) {
+ return new Promise(resovle => setTimeout(resovle, delay))
+ }
+
+ async function tryToEnableBt() {
+ let sta = bluetooth.getState();
+ switch(sta){
+ case 0:
+ bluetooth.enableBluetooth();
+ await sleep(5000);
+ let sta1 = bluetooth.getState();
+ console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta1));
+ break;
+ case 1:
+ console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
+ await sleep(3000);
+ break;
+ case 2:
+ console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
+ break;
+ case 3:
+ bluetooth.enableBluetooth();
+ await sleep(3000);
+ let sta2 = bluetooth.getState();
+ console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta2));
+ break;
+ default:
+ console.info('[bluetooth_js] enable success');
+ }
+ }
+ beforeAll(function () {
+ console.info('beforeAll called')
+ })
+ beforeEach(async function(done) {
+ console.info('beforeEach called')
+ await tryToEnableBt()
+ done()
+ })
+ afterEach(function () {
+ console.info('afterEach called')
+ })
+ afterAll(function () {
+ console.info('afterAll called')
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_0100
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test startBLEScan 401 - Invalid parameter.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 0
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_0100', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLEscan device result1 '+JSON.stringify(data));
+ except(true).assertTrue(data.length>0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind",onReceiveEvent)
+ bluetooth.BLE.startBLEScan(null);
+ await sleep(1000);
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_0100 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_0200
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_0200', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLEscan device result2'+JSON.stringify(data));
+ except(true).assertTrue(data.length>0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan([{deviceId:"00:11:22:33:44:55"}]);
+ await sleep(1000);
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_0200 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_0300
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_0300', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLEscan device result3'+JSON.stringify(data));
+ except(true).assertTrue(data.length>0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan([{name:"blue_test"}]);
+ await sleep(1000);
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_0300 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_0400
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_0400', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLEscan device result4'+JSON.stringify(data));
+ except(true).assertTrue(data.length>0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan([{serviceUuid:"00001888-0000-1000-8000-00805f9b34fb"}]);
+ await sleep(1000);
+ console.info('[bluetooth_js] BLE scan off4');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_0400 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_0500
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_0500', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLEscan device result5'+JSON.stringify(data));
+ except(true).assertTrue(data.length>0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan(
+ [{}],
+ {
+ interval: 100,
+ dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
+ matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
+ }
+ );
+ await sleep(1000);
+ console.info('[bluetooth_js] BLE scan off5');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_0500 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_0600
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_0600', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLEscan device result6'+JSON.stringify(data));
+ except(true).assertTrue(data.length>0);
+ }
+ let ScanOptions= {
+ interval: 100,
+ dutyMode: bluetooth.ScanDuty.SCAN_MODE_BALANCED,
+ matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan([{}],ScanOptions);
+ await sleep(1000);
+ console.info('[bluetooth_js] BLE scan off6');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_0600 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_0700
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_0700', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLEscan device result7'+JSON.stringify(data));
+ except(true).assertTrue(data.length>0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan(
+ [{}],
+ {
+ interval: 100,
+ dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_LATENCY,
+ matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
+ }
+ );
+ await sleep(1000);
+ console.info('[bluetooth_js] BLE scan off7');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_0700 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_0800
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_0800', 0, async function (done) {
+ try {
+ bluetooth.disableBluetooth();
+ await sleep(3000);
+ let state = bluetooth.getState();
+ console.info('[bluetooth_js] bt turn off1:'+ JSON.stringify(state));
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLEscan device result8'+JSON.stringify(data));
+ except(true).assertTrue(data.length=0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan(
+ [{}],
+ {
+ interval: 100,
+ dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
+ matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
+ }
+ );
+ await sleep(1000);
+ expect(true).assertFalse();
+ console.info('[bluetooth_js] BLE scan off8');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_0800 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_0700
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_0900', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLEscan device result9'+JSON.stringify(data));
+ except(true).assertTrue(data.length>0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan(
+ [{}],
+ {
+ interval: 0,
+ dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_LATENCY,
+ matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
+ }
+ );
+ await sleep(1000);
+ console.info('[bluetooth_js] BLE scan off7');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_0900 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_1000
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_1000', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLEscan device result10'+JSON.stringify(data));
+ except(true).assertTrue(data.length>0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan(
+ [{}],
+ {
+ interval: 500,
+ dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
+ matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
+ }
+ );
+ await sleep(1000);
+ console.info('[bluetooth_js] BLE scan off10');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_1000 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_1100
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_1100', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLEscan device result11'+JSON.stringify(data));
+ except(true).assertTrue(data.length>0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan(
+ [{}],
+ {
+ interval: 500,
+ dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
+ matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
+ }
+ );
+ await sleep(1000);
+ console.info('[bluetooth_js] BLE scan off11');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_1100 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_1200
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_1200', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLEscan device result12'+JSON.stringify(data));
+ except(true).assertTrue(data.length>0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan(
+ [{}],
+ {
+ interval: 500,
+ dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_LATENCY,
+ matchMode: bluetooth.MatchMode.MATCH_MODE_STICKY,
+ }
+ );
+ await sleep(1000);
+ console.info('[bluetooth_js] BLE scan off12');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_1200 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_1300
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_1300', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLEscan device result13'+JSON.stringify(data));
+ except(true).assertTrue(data.length>0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan(
+ [{
+ deviceId:"11:22:33:44:55:66",
+ name:"test",
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb"
+ }],
+ {
+ interval: 500,
+ dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
+ matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
+ }
+ );
+ await sleep(1000);
+ console.info('[bluetooth_js] BLE scan off13');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_1300 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /* @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_1400
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 9
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_1400', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLE scan device find result14'+ JSON.stringify(data));
+ expect(true).assertTrue(data.length > 0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan([{
+ serviceUuid:"00001812-0000-1000-8000-00805F9B34FB",
+ serviceUuidMask:"0000FFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
+ }]);
+ await sleep(1000);
+ console.info('[bluetooth_js] BLE scan off14 ');
+ bluetooth.BLE.stopBLEScan();
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_1400 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_1500
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 9
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_1500', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLE scan device find result15'+ JSON.stringify(data));
+ expect(true).assertTrue(data.length > 0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ bluetooth.BLE.startBLEScan([{
+ serviceSolicitationUuid:"00000101-0000-1000-8000-00805F9B34FB",
+ serviceSolicitationUuidMask:"FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
+
+ }]);
+ await sleep(1000);
+ console.info('[bluetooth_js] BLE scan off15 ');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_1500 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_1600
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 9
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_1600', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLE scan device find result16'+ JSON.stringify(data));
+ expect(true).assertTrue(data.length > 0);
+ }
+ let ScanFilters= [];
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ const serviceDataArrayBuffer = new ArrayBuffer(1);
+ const serviceDataMaskArrayBuffer = new ArrayBuffer(1);
+ const serviceDataValue = new Uint8Array(serviceDataArrayBuffer);
+ const serviceDataMaskValue = new Uint8Array(serviceDataMaskArrayBuffer);
+ serviceDataValue[0] = '0xFF';
+ serviceDataMaskValue[0] = '0xFF';
+ let ScanFilter = {
+ serviceData:serviceDataArrayBuffer,
+ serviceDataMask:serviceDataMaskArrayBuffer,
+ }
+ ScanFilters[0]=ScanFilter;
+ bluetooth.BLE.startBLEScan(ScanFilters);
+ await sleep(1000);
+ console.info('[bluetooth_js] BLE scan off16');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_1600 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_1700
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test ClassicStartBLEScan api.
+ * @tc.size MEDIUM
+ * @ since 9
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_1700', 0, async function (done) {
+ try {
+ function onReceiveEvent(data)
+ {
+ console.info('[bluetooth_js] BLE scan device find result17'+ JSON.stringify(data));
+ expect(true).assertTrue(data.length > 0);
+ }
+ bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
+ const manufactureDataArrayBuffer = new ArrayBuffer(29);
+ const manufactureDataMaskArrayBuffer = new ArrayBuffer(29);
+ const manufactureDataValue = new Uint8Array(manufactureDataArrayBuffer);
+ const manufactureDataMaskValue = new Uint8Array(manufactureDataMaskArrayBuffer);
+ for (let i = 0; i < 29; i++) {
+ manufactureDataValue[i] = '0xFF';
+ }
+ for (let i = 0; i < 29; i++) {
+ manufactureDataMaskValue[i] = '0xFF';
+ }
+ bluetooth.BLE.startBLEScan([{
+ manufactureId:0x0006,
+ manufactureData:manufactureDataValue,
+ manufactureDataMask:manufactureDataMaskValue,
+ }]);
+ await sleep(1000);
+ expect(true).assertFalse();
+ console.info('[bluetooth_js] BLE scan off17 ');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_1700 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_1800
+ * @tc.name test gatt connect and disconnect
+ * @tc.desc Test connect and disconnect api .
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_1800', 0, async function (done) {
+ try {
+ async function onReceiveEvent(ScanResult)
+ {
+ console.info('[bluetooth_js] BLEscan device result12'+JSON.stringify(ScanResult)
+ +ScanResult.deviceId+ScanResult.rssi+ ScanResult.data);
+ except(true).assertTrue(ScanResult.length>0);
+ await sleep(1000);
+ let gattClient = bluetooth.BLE.createGattClientDevice(ScanResult[0].deviceId);
+ let ret = gattClient.connect();
+ await sleep(2000);
+ console.info('[bluetooth_js] gattClient connect' + ret)
+ expect(ret).assertTrue();
+ let disconnect = gattClient.disconnect();
+ console.info('[bluetooth_js] gatt disconnect:' + disconnect);
+ expect(disconnect).assertEqual(false);
+ }
+ await bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent);
+ bluetooth.BLE.startBLEScan(
+ [{}],
+ {
+ interval: 500,
+ dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_LATENCY,
+ matchMode: bluetooth.MatchMode.MATCH_MODE_STICKY,
+ }
+ );
+ console.info('[bluetooth_js] BLE scan offC');
+ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
+ bluetooth.BLE.stopBLEScan();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_1800 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_1900
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test startBLEScan 401 - Invalid parameter.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 0
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_1900', 0, async function (done) {
+ try {
+ bluetooth.BLE.startBLEScan(123);
+ expect(true).assertFalse();
+ bluetooth.BLE.stopBLEScan();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_1900 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_2000
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test startBLEScan 401 - Invalid parameter.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 0
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Scan_2000', 0, async function (done) {
+ try {
+ bluetooth.BLE.startBLEScan([{
+ serviceSolicitationUuid:"00000101-0000-1000-8000-00805F9B34FB",
+ serviceSolicitationUuidMask:"FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
+ }]);
+ bluetooth.BLE.stopBLEScan("test");
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]Scan_2000 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+})
+}
+
diff --git a/communication/bluetooth_manager/src/main/js/test/BleService.test.js b/communication/bluetooth_manager/src/main/js/test/BleService.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..42c8d5d41df0ce2b14319cb65d3ddfdce825d783
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/js/test/BleService.test.js
@@ -0,0 +1,1190 @@
+/*
+ * Copyright (C) 2022 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 bluetooth from '@ohos.bluetoothManager';
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
+
+export default function bluetoothBLETest1() {
+describe('bluetoothBLETest1', function() {
+
+ let gattServer = null;
+ let gattClient = null;
+ function sleep(delay) {
+ return new Promise(resovle => setTimeout(resovle, delay))
+ }
+
+ async function tryToEnableBt() {
+ let sta = bluetooth.getState();
+ switch(sta){
+ case 0:
+ console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
+ bluetooth.enableBluetooth();
+ await sleep(3000);
+ break;
+ case 1:
+ console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
+ await sleep(3000);
+ break;
+ case 2:
+ console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
+ break;
+ case 3:
+ console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
+ bluetooth.enableBluetooth();
+ await sleep(3000);
+ break;
+ default:
+ console.info('[bluetooth_js] enable success');
+ }
+ }
+ beforeAll(async function (done) {
+ console.info('beforeAll called')
+ await tryToEnableBt()
+ gattServer = bluetooth.BLE.createGattServer();
+ gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
+ done()
+ })
+ beforeEach(async function(done) {
+ console.info('beforeEach called')
+ await tryToEnableBt()
+ done()
+ })
+ afterEach(function () {
+ console.info('afterEach called')
+ })
+ afterAll(function () {
+ console.info('afterAll called')
+ gattServer.close();
+ })
+
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_Connect_0100
+ * @tc.name test Server connectStateChange
+ * @tc.desc Test on and off api .
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_Connect_0100', 0, async function (done) {
+ try {
+ function Connected(BLEConnectChangedState) {
+ let deviceId = BLEConnectChangedState.deviceId;
+ let status = BLEConnectChangedState.state;
+ console.info("[bluetooth_js] connectStateChange jsondata:"
+ +'deviceId:' + deviceId + 'status:' + status);
+ expect(true).assertEqual(BLEConnectChangedState !=null);
+ }
+ await gattServer.on("connectStateChange", Connected);
+ gattClient.connect();
+ await sleep(2000);
+ await gattServer.off("connectStateChange");
+ done()
+ } catch (error) {
+ console.error(`[bluetooth_js]Connect_0100 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_0100
+ * @tc.name testAddService
+ * @tc.desc Test api 401 - characteristics of service is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_0100', 0, async function (done) {
+ try {
+ let service = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ isPrimary: true, includeServices: []};
+ gattServer.addService(service);
+ await sleep(1000);
+ expect(true).assertFalse();
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]AddService1 failed, error.code:'+JSON.stringify(error.code)
+ +'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_0200
+ * @tc.name testAddService
+ * @tc.desc Test AddService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_0200', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]AddService2 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_0300
+ * @tc.name testAddService
+ * @tc.desc Test AddService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_0300', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ let characteristicN = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ characteristics[1] = characteristicN;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]AddService3 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_0400
+ * @tc.name testAddService
+ * @tc.desc Test AddService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_0400', 0, async function (done) {
+ try {
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ expect(true).assertFalse();
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]AddService4 failed, error.code:'+JSON.stringify(error.code)
+ +'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_0500
+ * @tc.name testAddService
+ * @tc.desc Test AddService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_0500', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]AddService5 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_0600
+ * @tc.name testAddService
+ * @tc.desc Test AddService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_0600', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+
+ let descriptor1 = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+
+ descriptors[0] = descriptor;
+ descriptors[1] = descriptor1;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]AddService6 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_0700
+ * @tc.name testAddService
+ * @tc.desc Test AddService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_0700', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]AddService7 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_0800
+ * @tc.name testAddService
+ * @tc.desc Test AddService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_0800', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: false,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]AddService8 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_0900
+ * @tc.name testAddService
+ * @tc.desc Test AddService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_0900', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'', isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ expect(true).assertFalse();
+ await sleep(1000);
+ gattServer.removeService('');
+ await sleep(1000);
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]AddService9 failed, error.code:'+JSON.stringify(error.code)
+ +'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_1000
+ * @tc.name testAddService
+ * @tc.desc Test AddService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_1000', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '123@ad',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '123@ad',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'123@ad', isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ expect(true).assertFalse();
+ gattServer.removeService('123@ad');
+ await sleep(1000);
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]AddService10 failed, error.code:'+JSON.stringify(error.code)
+ +'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_1100
+ * @tc.name testAddService
+ * @tc.desc Test AddService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_1100', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ expect(true).assertFalse();
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]AddService11 failed, error.code:'+JSON.stringify(error.code)
+ +'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_1200
+ * @tc.name testAddService
+ * @tc.desc Test AddService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_1200', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB'};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ expect(true).assertFalse();
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]AddService12 failed, error.code:'+JSON.stringify(error.code)
+ +'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_2000
+ * @tc.name testAddService
+ * @tc.desc Test api 401 - null gattService parameters.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_2000', 0, async function (done) {
+ try {
+ gattServer.addService();
+ expect(true).assertFalse();
+ await sleep(1000);
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]addService20 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_2100
+ * @tc.name testAddService
+ * @tc.desc Test api 401 - parameters is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_2100', 0, async function (done) {
+ try {
+ gattServer.addService(null);
+ expect(true).assertFalse();
+ await sleep(1000);
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]addService21 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_2200
+ * @tc.name testAddService
+ * @tc.desc Test api 401 - serviceUuid of gattService is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_2200', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]addService22 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_2300
+ * @tc.name testAddService
+ * @tc.desc Test api 401 - serviceUuid of gattService is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_2300', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:123123, isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]addService23 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_2400
+ * @tc.name testAddService
+ * @tc.desc Test api 401 - isPrimary of gattService is null.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_2400', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB',
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]addService24 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_2500
+ * @tc.name testAddService
+ * @tc.desc Test api 401 - isPrimary of gattService is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_2500', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: '123S123',
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]addService25 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_AddService_2600
+ * @tc.name testAddService
+ * @tc.desc Test api 401 - characteristics of gattService is error type.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_AddService_2600', 0, async function (done) {
+ try {
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
+ characteristics:"123sss",includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]addService26 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_RemoveService_0100
+ * @tc.name testRemoveService
+ * @tc.desc Test RemoveService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_RemoveService_0100', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB',
+ isPrimary: true,characteristics:characteristics,includeServices:[]};
+ let gattService1 = {serviceUuid:'00001888-0000-1000-8000-00805f9b34fb',
+ isPrimary: false,characteristics:characteristics,includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ gattServer.addService(gattService1);
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]removeService1 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(true).assertFalse();
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_RemoveService_0200
+ * @tc.name testRemoveService
+ * @tc.desc Test RemoveService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_RemoveService_0200', 0, async function (done) {
+ try {
+ gattServer.removeService('00001800-0000-1000-8000-00805f9b3442');
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]removeService2 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_RemoveService_0300
+ * @tc.name testRemoveService
+ * @tc.desc Test RemoveService api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_RemoveService_0300', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ await sleep(1000);
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]removeService3 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_RemoveService_0400
+ * @tc.name testRemoveService
+ * @tc.desc Test RemoveService 401-null parameter.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_RemoveService_0400', 0, async function (done) {
+ try {
+ gattServer.removeService();
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]removeService4 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_RemoveService_0500
+ * @tc.name testRemoveService
+ * @tc.desc Test RemoveService 401-error parameter.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_RemoveService_0500', 0, async function (done) {
+ try {
+ gattServer.removeService("sss");
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]removeService5 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0100
+ * @tc.name testNotifyCharacteristicChanged
+ * @tc.desc Test NotifyCharacteristicChanged api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0100', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: descV};
+ descriptors[0] = descriptor;
+ let arrayBufferC = new ArrayBuffer(8);
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue:
+ arrayBufferC, descriptors:descriptors};
+ let NotifyCharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue:
+ characteristic.characteristicValue, confirm: false};
+ gattServer.notifyCharacteristicChanged('00:11:22:33:44:55', NotifyCharacteristic);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]notifyCharacteristicChanged1 failed, code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0200
+ * @tc.name testNotifyCharacteristicChanged
+ * @tc.desc Test NotifyCharacteristicChanged api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0200', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: descV};
+ descriptors[0] = descriptor;
+ let arrayBufferC = new ArrayBuffer(8);
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue:
+ arrayBufferC, descriptors:descriptors};
+ let notifyCharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue:
+ characteristic.characteristicValue, confirm: false};
+ gattServer.notifyCharacteristicChanged('00:11:22:33:44:55', notifyCharacteristic);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]notifyCharacteristicChanged2 failed, code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0300
+ * @tc.name testNotifyCharacteristicChanged
+ * @tc.desc Test NotifyCharacteristicChanged api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0300', 0, async function (done) {
+ try {
+ console.info('[bluetooth_js] COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0200');
+ gattServer.notifyCharacteristicChanged('00:11:22:33:44:55', null);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]notifyCharacteristicChanged3 failed, code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_sendResponse_0100
+ * @tc.name testSendResponse success
+ * @tc.desc Test SendResponse api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_sendResponse_0100', 0, async function (done) {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let value = new Uint8Array(arrayBuffer);
+ value[0] = 1;
+ let ServerResponse = {deviceId: '00:11:22:33:44:55', transId: 1,
+ status: 0, offset: 0, value: arrayBuffer};
+ gattServer.sendResponse(ServerResponse);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]sendResponse1 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_sendResponse_0200
+ * @tc.name testSendResponse success
+ * @tc.desc Test SendResponse api.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_sendResponse_0200', 0, async function (done) {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let value = new Uint8Array(arrayBuffer);
+ value[0] = 1;
+ let ServerResponse = {deviceId: '00:11:22:33:44:55', transId: 1,
+ status: -1, offset: 0, value: arrayBuffer};
+ gattServer.sendResponse(ServerResponse);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]sendResponse2 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900099');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_sendResponse_0300
+ * @tc.name testSendResponse success
+ * @tc.desc Test SendResponse 401 -null parameter.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_sendResponse_0300', 0, async function (done) {
+ try {
+ gattServer.sendResponse();
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]sendResponse3 error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_BLE_sendResponse_0400
+ * @tc.name testSendResponse success
+ * @tc.desc Test SendResponse 401 -error parameter.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_BLE_sendResponse_0400', 0, async function (done) {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let value = new Uint8Array(arrayBuffer);
+ value[0] = 1;
+ let ServerResponse = {transId: 1,
+ status: -1, offset: 0, value: arrayBuffer};
+ gattServer.sendResponse(ServerResponse);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]sendResponse4 failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+
+ })
+
+
+})
+}
+
+
diff --git a/graphic/webGL/src/main/js/default/test/List.test.js b/communication/bluetooth_manager/src/main/js/test/List.test.js
similarity index 50%
rename from graphic/webGL/src/main/js/default/test/List.test.js
rename to communication/bluetooth_manager/src/main/js/test/List.test.js
index 9ab60addbb67ec28ae5cb11e76ec6966aeb14c38..ac47b6163eea3e49b3d570d4d53e6f1d741c52fa 100644
--- a/graphic/webGL/src/main/js/default/test/List.test.js
+++ b/communication/bluetooth_manager/src/main/js/test/List.test.js
@@ -13,18 +13,19 @@
* limitations under the License.
*/
-require('./WebGL.test01.js')
-require('./WebGL.test02.js')
-require('./WebGL.test03.js')
-require('./WebGL.test04.js')
-require('./WebGL.test05.js')
-require('./WebGL.test06.js')
-require('./WebGL.test07.js')
-require('./WebGL.test08.js')
-require('./WebGL.test09.js')
-require('./WebGL.test10.js')
-require('./WebGL.test11.js')
-require('./WebGL.test12.js')
-require('./WebGL.test13.js')
-require('./WebGL.test14.js')
-require('./WebGL.test15.js')
\ No newline at end of file
+import bluetoothBLETest from './BleGattManager.test.js'
+import bluetoothBLETest4 from './BleGattManager401.test.js'
+import bluetoothBLETest1 from './BleService.test.js'
+import bluetoothBLETest2 from './BleAdvertiser.test.js'
+import bluetoothBLETest5 from './BleAdvertiser401.test.js'
+import bluetoothBLETest3 from './SwitchOff003.test.js'
+import bluetoothBLETest6 from './BleScanResult.test.js'
+export default function testsuite() {
+bluetoothBLETest()
+bluetoothBLETest1()
+bluetoothBLETest2()
+bluetoothBLETest4()
+bluetoothBLETest5()
+bluetoothBLETest3()
+bluetoothBLETest6()
+}
diff --git a/communication/bluetooth_manager/src/main/js/test/SwitchOff003.test.js b/communication/bluetooth_manager/src/main/js/test/SwitchOff003.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..36950999acb1dd0cbf4a9653bd6593cb416a5eef
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/js/test/SwitchOff003.test.js
@@ -0,0 +1,1128 @@
+/*
+ * Copyright (C) 2022 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 bluetooth from '@ohos.bluetoothManager';
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
+
+export default function bluetoothBLETest3() {
+describe('bluetoothBLETest3', function() {
+ let gattServer = null;
+ let gattClient = null;
+ function sleep(delay) {
+ return new Promise(resovle => setTimeout(resovle, delay))
+ }
+
+ async function tryToDisableBt() {
+ let sta = bluetooth.getState();
+ switch(sta){
+ case 0:
+ console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
+ break;
+ case 1:
+ console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
+ await sleep(3000);
+ break;
+ case 2:
+ console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
+ bluetooth.disableBluetooth();
+ await sleep(3000);
+ break;
+ case 3:
+ console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
+ break;
+ default:
+ console.info('[bluetooth_js] enable success');
+ }
+ }
+ beforeAll(function () {
+ console.info('beforeAll called')
+ gattServer = bluetooth.BLE.createGattServer();
+ gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
+ })
+ beforeEach(async function(done) {
+ console.info('beforeEach called')
+ await tryToDisableBt()
+ done()
+ })
+ afterEach(function () {
+ console.info('afterEach called')
+ })
+ afterAll(async function (done) {
+ console.info('afterAll called')
+ await sleep(6000);
+ gattClient.close();
+ done()
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_0100
+ * @tc.name test bluetooth Profile ConnectionState
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_0100', 0, async function (done) {
+ await sleep(3000);
+ let sta = bluetooth.getState();
+ console.info('[bluetooth_js] bt getState:'+ JSON.stringify(sta));
+ try {
+ let connState = bluetooth.getBtConnectionState();
+ console.info('[bluetooth_js] get bt connection state result'
+ + JSON.stringify(connState));
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]getBtConnectionState error.code:'
+ +JSON.stringify(error.code)+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_0200
+ * @tc.name Test pairDevice api
+ * @tc.desc Test 2900003 - Bluetooth switch is off
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_0200', 0, async function (done) {
+ try {
+ bluetooth.pairDevice("11:22:55:66:33:44");
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]pairDevice error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_0300
+ * @tc.name test getRemoteDeviceName
+ * @tc.desc Test 2900003 - Bluetooth switch is off
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_0300', 0, async function (done) {
+ try {
+ let ret = bluetooth.getRemoteDeviceName("00:00:00:00:00:00");
+ console.info('[bluetooth_js] getRemoteDeviceName ret2:' + JSON.stringify(ret));
+ expect(ret.length).assertEqual(0);
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]getRemoteDeviceName error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_0400
+ * @tc.name test getRemoteDeviceClass
+ * @tc.desc Test 2900003 - Bluetooth switch is off
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_0400', 0, async function (done) {
+ try {
+ let DeviceClass = bluetooth.getRemoteDeviceClass("00:00:00:00:00:00");
+ console.info('[bluetooth_js] getRemoteDeviceClass ret2 :' + JSON.stringify(DeviceClass)
+ + 'majorClass:' +DeviceClass.majorClass + 'majorMinorClass:'+ DeviceClass.majorMinorClass
+ + 'classOfDevice:' + DeviceClass.classOfDevice);
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]getRemoteDeviceClass error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_0500
+ * @tc.name test get PairedDevices
+ * @tc.desc Test 2900003 - Bluetooth switch is off
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_0500', 0, async function (done) {
+ try {
+ let ret = bluetooth.getPairedDevices();
+ console.info('[bluetooth_js] getPairedDevices ret2:' + JSON.stringify(ret));
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]getPairedDevices error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_0600
+ * @tc.name test Get A2DP ConnectionState
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_0600', 0, async function (done) {
+ try {
+ let a2dpSrcConn = bluetooth.getProfileConnState(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
+ console.info('[bluetooth_js]get a2dp result:' + JSON.stringify(a2dpSrcConn));
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]getProfileConnState error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_0700
+ * @tc.name Test setDevicePairing
+ * @tc.desc Test 2900003 - Bluetooth switch is off
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_0700', 0, async function (done) {
+ try {
+ bluetooth.setDevicePairingConfirmation("11:22:55:66:33:44",false);
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]setDevicePairingConfirmation error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_0800
+ * @tc.name setLocalName
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_0800', 0, async function (done) {
+ try {
+ let newName = 'my bluetooth';
+ bluetooth.setLocalName(newName);
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]setLocalName error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_0900
+ * @tc.name TEST setBluetoothScanMode
+ * @tc.desc TEST 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_0900', 0, async function (done) {
+ try {
+ bluetooth.setBluetoothScanMode(bluetooth.ScanMode.SCAN_MODE_LIMITED_DISCOVERABLE,0);
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]setBluetoothScanMode error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_1000
+ * @tc.name TEST getBluetoothScanMode
+ * @tc.desc TEST 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_1000', 0, async function (done) {
+ try {
+ let oldScanMode = bluetooth.getBluetoothScanMode();
+ console.info('[bluetooth_js] getBluetoothScanMode = '+ JSON.stringify(oldScanMode));
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]getBluetoothScanMode error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_1100
+ * @tc.name TEST startBluetoothDiscovery
+ * @tc.desc TEST 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_1100', 0, async function (done) {
+ try {
+ bluetooth.startBluetoothDiscovery();
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]startBluetoothDiscovery error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_1200
+ * @tc.name TEST stopBluetoothDiscovery
+ * @tc.desc TEST 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_1200', 0, async function (done) {
+ try {
+ bluetooth.stopBluetoothDiscovery();
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]stopBluetoothDiscovery error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_1300
+ * @tc.name testSppListen
+ * @tc.desc Test 2900003 - Bluetooth switch is off
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_1300', 0, async function (done) {
+ try {
+ let SppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB',
+ secure: true, type: bluetooth.SppType.SPP_RFCOMM};
+ let serverNumber = -1;
+ function serverSocket(code, number) {
+ if (code) {
+ console.log('bluetooth error code01: ' + code);
+ }else{
+ console.log('bluetooth serverSocket Number:' + JSON.stringify(number));
+ serverNumber = number;
+ expect(true).assertEqual(number!=null);
+ }
+ }
+ bluetooth.sppListen('server1', SppOption, serverSocket);
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]sppListen error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_1400
+ * @tc.name testSppAccept
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_1400', 0, async function (done) {
+ try {
+ function acceptClientSocket(code, number) {
+
+ if (code) {
+ console.log('[bluetooth_js] error code05: ' + JSON.stringify(code));
+ }else{
+ console.log('[bluetooth_js] clientSocket Number:' + JSON.stringify(number));
+ expect(true).assertEqual(number!=null);
+ }
+ }
+ bluetooth.sppAccept(0, acceptClientSocket);
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]sppAccept error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_1500
+ * @tc.name testSppConnect
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_1500', 0, async function (done) {
+ try {
+ let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB',
+ secure: true, type: 0};
+ bluetooth.sppConnect('00:11:22:33:44:55', sppOption, function(code, number) {
+ if (code) {
+ console.info('[bluetooth_js] code is: ' + JSON.stringify(code));
+ } else {
+ console.log('[bluetooth_js]sppConnect Number:'
+ + JSON.stringify(number));
+ }
+ });
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]sppConnect error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_1600
+ * @tc.name test getDevice HFP State.
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_1600', 0, async function (done) {
+ try {
+ let hfpSrc = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
+ let retArray = hfpSrc.getConnectionDevices();
+ console.info('[bluetooth_js]hfp getConnectionDevices:' + JSON.stringify(retArray));
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]getConnectionDevices error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_1700
+ * @tc.name test getDeviceState.
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_1700', 0, async function (done) {
+ try {
+ let hfpSrc = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
+ let ret = hfpSrc.getDeviceState('11:22:33:44:55:66');
+ console.info('[bluetooth_js]hfp getDeviceState:' + JSON.stringify(ret));
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]getDeviceState error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_1800
+ * @tc.name test A2DP Connect
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_1800', 0, async function (done) {
+ try {
+ let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
+ a2dpSrc.connect('11:22:33:44:55:77');
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]A2DPconnect error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_1900
+ * @tc.name test A2DP disconnect
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_1900', 0, async function (done) {
+ try {
+ let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
+ a2dpSrc.disconnect('11:22:33:44:55:77');
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]A2DPdisconnect error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_2000
+ * @tc.name test get A2DP Playing State
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_2000', 0, async function (done) {
+ try {
+ let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
+ console.info('[bluetooth_js]a2dp get profile result:' + JSON.stringify(a2dpSrc));
+ let state = a2dpSrc.getPlayingState('11:22:33:44:55:66');
+ console.info('[bluetooth_js]a2dp getPlayingState result:' + JSON.stringify(state));
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]getPlayingState error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_2100
+ * @tc.name test HFP Connect
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_2100', 0, async function (done) {
+ try {
+ let hfpSrc =
+ bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
+ hfpSrc.connect('11:22:33:44:55:77');
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]HFPconnect error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_2200
+ * @tc.name test HFP disconnect
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_2200', 0, async function (done) {
+ try {
+ let hfpSrc =
+ bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
+ hfpSrc.disconnect('11:22:33:44:55:77');
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]HFPdisconnect error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_2300
+ * @tc.name test Hid Connect
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_2300', 0, async function (done) {
+ try {
+ let hidSrc =
+ bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HID_HOST);
+ hidSrc.connect('11:22:33:44:55:77');
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]Hidconnect error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_2400
+ * @tc.name test Hid disconnect
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_2400', 0, async function (done) {
+ try {
+ let hidSrc =
+ bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HID_HOST);
+ hidSrc.disconnect('11:22:33:44:55:77');
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]Hiddisconnect error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_2500
+ * @tc.name test PAN disconnect
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_2500', 0, async function (done) {
+ try {
+ let panSrc =
+ bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_PAN_NETWORK);
+ panSrc.disconnect('11:22:33:44:55:77');
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]Pandisconnect error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_2600
+ * @tc.name test PAN setTethering
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_2600', 0, async function (done) {
+ try {
+ let panSrc =
+ bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_PAN_NETWORK);
+ panSrc.setTethering(true);
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]PansetTethering error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_2700
+ * @tc.name test getConnectedBLEDevices
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_2700', 0, function () {
+ try {
+ let result = bluetooth.BLE.getConnectedBLEDevices();
+ console.info("[bluetooth_js] getConnDev:" + JSON.stringify(result)
+ + "length:" +result.length);
+ expect(true).assertFalse();
+ } catch (error) {
+ console.error(`[bluetooth_js]getConnDev failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900003');
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_2800
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_2800', 0, async function (done) {
+ try {
+ bluetooth.BLE.startBLEScan(
+ [{
+ deviceId:"11:22:33:44:55:66",
+ name:"test",
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb"
+ }],
+ {
+ interval: 500,
+ dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
+ matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
+ }
+ );
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]startBLEScan error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_2900
+ * @tc.name testClassicStartBLEScan
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_2900', 0, async function (done) {
+ try {
+ bluetooth.BLE.stopBLEScan();
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]startBLEScan error.code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_3000
+ * @tc.name testStartAdvertising
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 0
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_3000', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let setting={
+ interval:20,
+ txPower:-10,
+ connectable:true,
+ }
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.startAdvertising(setting,advData,advResponse);
+ expect(true).assertFalse();
+ }catch(error) {
+ console.error('[bluetooth_js]startAdvertising error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ }
+ await sleep(2000);
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_3100
+ * @tc.name teststopAdvertising
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 0
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_3100', 0, async function (done) {
+ let manufactureValueBuffer = new Uint8Array(4);
+ manufactureValueBuffer[0] = 1;
+ manufactureValueBuffer[1] = 2;
+ manufactureValueBuffer[2] = 3;
+ manufactureValueBuffer[3] = 4;
+ let serviceValueBuffer = new Uint8Array(4);
+ serviceValueBuffer[0] = 4;
+ serviceValueBuffer[1] = 6;
+ serviceValueBuffer[2] = 7;
+ serviceValueBuffer[3] = 8;
+ let advData={
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ let advResponse ={
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ }
+ try {
+ gattServer.stopAdvertising();
+ expect(true).assertFalse();
+ }catch(error) {
+ console.error('[bluetooth_js]stopAdvertising error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ }
+ done();
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_3200
+ * @tc.name testAddService
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_3200', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+ descriptors[0] = descriptor;
+ let characteristics = [];
+ let arrayBufferC = new ArrayBuffer(8);
+ let cccV = new Uint8Array(arrayBufferC);
+ cccV[0] = 1;
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: arrayBufferC, descriptors:descriptors};
+ characteristics[0] = characteristic;
+ let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
+ characteristics:characteristics, includeServices:[]};
+ gattServer.addService(gattService);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]AddService failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_3300
+ * @tc.name test removeService
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_3300', 0, async function (done) {
+ try {
+ gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]removeService failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('401');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_3400
+ * @tc.name test removeService
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_3400', 0, async function (done) {
+ try {
+ gattServer.close();
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]close failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_3500
+ * @tc.name testNotifyCharacteristicChanged
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_3500', 0, async function (done) {
+ try {
+ let descriptors = [];
+ let arrayBuffer = new ArrayBuffer(8);
+ let descV = new Uint8Array(arrayBuffer);
+ descV[0] = 11;
+ let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: descV};
+ descriptors[0] = descriptor;
+ let arrayBufferC = new ArrayBuffer(8);
+ let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue:
+ arrayBufferC, descriptors:descriptors};
+ let NotifyCharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue:
+ characteristic.characteristicValue, confirm: false};
+ gattServer.notifyCharacteristicChanged('00:11:22:33:44:55', NotifyCharacteristic);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error('[bluetooth_js]notifyCharacteristicChanged1 failed, code:'
+ +JSON.stringify(error.code)+'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_3600
+ * @tc.name testSendResponse success
+ * @tc.desc Test 2900003 - Bluetooth switch is off.
+ * @tc.size MEDIUM
+ * @tc.type Function
+ * @tc.level Level 1
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_3600', 0, async function (done) {
+ try {
+ let arrayBuffer = new ArrayBuffer(8);
+ let value = new Uint8Array(arrayBuffer);
+ value[0] = 1;
+ let ServerResponse = {deviceId: '00:11:22:33:44:55', transId: 1,
+ status: 0, offset: 0, value: arrayBuffer};
+ gattServer.sendResponse(ServerResponse);
+ expect(true).assertFalse();
+ done();
+ } catch (error) {
+ console.error(`[bluetooth_js]sendResponse failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_3700
+ * @tc.name test gatt connect
+ * @tc.desc Test 2900003 - Bluetooth switch is off
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_3700', 0, async function (done) {
+ try {
+ gattClient.connect();
+ await sleep(2000);
+ expect(true).assertFalse();
+ } catch(error) {
+ console.error(`[bluetooth_js]connect failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900003');
+ }
+ done()
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_3800
+ * @tc.name test gatt disconnect
+ * @tc.desc Test 2900003 - Bluetooth switch is off
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_3800', 0, async function (done) {
+ try {
+ gattClient.disconnect();
+ expect(true).assertFalse();
+ } catch(error) {
+ console.error(`[bluetooth_js]disconnect failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900003');
+ }
+ done()
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_3900
+ * @tc.name test gatt close
+ * @tc.desc Test 2900003 - Bluetooth switch is off
+ * @tc.size MEDIUM
+ * @ since 7
+ * @tc.type Function
+ * @tc.level Level 3
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_3900', 0, async function (done) {
+ try {
+ gattClient.close();
+ expect(true).assertFalse();
+ } catch(error) {
+ console.error(`[bluetooth_js]gattClient close failed, code is ${error.code},
+ message is ${error.message}`);
+ expect(error.code).assertEqual('2900003');
+ }
+ done()
+ })
+
+ /**
+ * @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_4000
+ * @tc.name Test cancelPairedDevice api
+ * @tc.desc Test 2900003 - Bluetooth switch is off
+ * @tc.size MEDIUM
+ * @ since 8
+ * @tc.type Function
+ * @tc.level Level 2
+ */
+ it('COMMUNICATION_BLUETOOTH_SwitchOff_4000', 0, async function (done) {
+
+ try {
+ bluetooth.cancelPairedDevice("11:22:55:66:33:44");
+ expect(true).assertFalse();
+ done()
+ } catch (error) {
+ console.error('[bluetooth_js]cancelPairedDevice error.code:'+JSON.stringify(error.code)+
+ 'error.message:'+JSON.stringify(error.message));
+ expect(error.code).assertEqual('2900003');
+ done()
+ }
+ })
+
+})
+}
+
+
diff --git a/communication/bluetooth_manager/src/main/resources/base/element/string.json b/communication/bluetooth_manager/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..d4b2a0a059d21198f9767cea679a5cc2bb8f6dad
--- /dev/null
+++ b/communication/bluetooth_manager/src/main/resources/base/element/string.json
@@ -0,0 +1,28 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "OsAccountTest"
+ },
+ {
+ "name": "mainability_description",
+ "value": "JS_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "MainAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "MainAbility_label",
+ "value": "label"
+ },
+ {
+ "name": "TestAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "TestAbility_label",
+ "value": "label"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/security/cryptoFramework/js_api_test_two/src/main/resources/base/media/icon.png b/communication/bluetooth_manager/src/main/resources/base/media/icon.png
similarity index 100%
rename from security/cryptoFramework/js_api_test_two/src/main/resources/base/media/icon.png
rename to communication/bluetooth_manager/src/main/resources/base/media/icon.png
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/FieldNodeJsTest.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/FieldNodeJsTest.js
index 50b432cdff56b4393a2b2c6e30749018723e56b8..3ca426cf3f5bd4f26d6eac5459a12d472e827ca5 100644
--- a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/FieldNodeJsTest.js
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/FieldNodeJsTest.js
@@ -179,11 +179,12 @@ describe('FieldNodeTest', function() {
it('SUB_DDM_DKV_FIELDNODE_TYPE_0100', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
- node.type = ddm.value.type.STRING;
- console.info('type = ' + node.type);
- expect(node.type === ddm.type.STRING).assertTrue()
+ node.type = ddm.ValueType.STRING;
+ console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0100 type = ' + node.type);
+ expect(node.type === ddm.ValueType.STRING).assertTrue();
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0100 fail on exception: " + e);
+ expect(null).assertFail();
}
done();
})
@@ -197,11 +198,12 @@ describe('FieldNodeTest', function() {
it('SUB_DDM_DKV_FIELDNODE_TYPE_0200', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
- node.type = ddm.type.INTEGER;
- console.info('type = ' + node.type);
- expect(node.type === ddm.type.INTEGER).assertTrue()
+ node.type = ddm.ValueType.INTEGER;
+ console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0200 type = ' + node.type);
+ expect(node.type === ddm.ValueType.INTEGER).assertTrue();
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0200 fail on exception: " + e);
+ expect(null).assertFail();
}
done();
})
@@ -215,11 +217,12 @@ describe('FieldNodeTest', function() {
it('SUB_DDM_DKV_FIELDNODE_TYPE_0300', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
- node.type = ddm.type.FLOAT;
- console.info('type = ' + node.type);
- expect(node.type === ddm.type.FLOAT).assertTrue()
+ node.type = ddm.ValueType.FLOAT;
+ console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0300 type = ' + node.type);
+ expect(node.type === ddm.ValueType.FLOAT).assertTrue();
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0300 fail on exception: " + e);
+ expect(null).assertFail();
}
done();
})
@@ -233,11 +236,12 @@ describe('FieldNodeTest', function() {
it('SUB_DDM_DKV_FIELDNODE_TYPE_0400', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
- node.type = ddm.type.BYTE_ARRAY;
- console.info('type = ' + node.type);
- expect(node.type === ddm.type.BYTE_ARRAY).assertTrue()
+ node.type = ddm.ValueType.BYTE_ARRAY;
+ console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0400 type = ' + node.type);
+ expect(node.type === ddm.ValueType.BYTE_ARRAY).assertTrue();
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0400 fail on exception: " + e);
+ expect(null).assertFail();
}
done();
})
@@ -251,11 +255,12 @@ describe('FieldNodeTest', function() {
it('SUB_DDM_DKV_FIELDNODE_TYPE_0500', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
- node.type = ddm.type.BOOLEAN;
- console.info('type = ' + node.type);
- expect(node.type === ddm.ValueType.BOOLEAN).assertTrue()
+ node.type = ddm.ValueType.BOOLEAN;
+ console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0500 type = ' + node.type);
+ expect(node.type === ddm.ValueType.BOOLEAN).assertTrue();
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0500 fail on exception: " + e);
+ expect(null).assertFail();
}
done();
})
@@ -269,11 +274,12 @@ describe('FieldNodeTest', function() {
it('SUB_DDM_DKV_FIELDNODE_TYPE_0600', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
- node.type = ddm.type.DOUBLE;
- console.info('type = ' + node.type);
- expect(node.type === ddm.type.DOUBLE).assertTrue()
+ node.type = ddm.ValueType.DOUBLE;
+ console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0600 type = ' + node.type);
+ expect(node.type === ddm.ValueType.DOUBLE).assertTrue();
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0600 fail on exception: " + e);
+ expect(null).assertFail();
}
done();
})
diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/SingleKvStoreKVCallbackJsTest.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/SingleKvStoreKVCallbackJsTest.js
index debd83af170d038b356334df9031b6ff9657c882..3028c44fc127f2bf73ee00dd9a1209ac5831e551 100644
--- a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/SingleKvStoreKVCallbackJsTest.js
+++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/SingleKvStoreKVCallbackJsTest.js
@@ -177,9 +177,10 @@ describe('SingleKvStoreCallbackTest', function () {
await kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) {
if (err == undefined) {
console.info('SingleKvStoreGetStringCallbackTest001 get success');
- expect(true).assertTrue();
+ expect(null).assertFail();
} else {
- console.info('SingleKvStoreGetStringCallbackTest001 get fail');
+ console.error('SingleKvStoreGetStringCallbackTest001 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(err.code == 15100004).assertTrue();
}
done();
});
@@ -355,9 +356,10 @@ describe('SingleKvStoreCallbackTest', function () {
await kvStore.get(KEY_TEST_INT_ELEMENT, function (err,data) {
if (err == undefined) {
console.info('SingleKvStoreGetIntCallbackTest002 get success');
- expect(true).assertTrue();
+ expect(null).assertFail();
} else {
- console.info('SingleKvStoreGetIntCallbackTest002 get fail');
+ console.error('SingleKvStoreGetIntCallbackTest002 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(err.code == 15100004).assertTrue();
}
done();
})
@@ -401,9 +403,10 @@ describe('SingleKvStoreCallbackTest', function () {
await kvStore.get(KEY_TEST_BOOLEAN_ELEMENT, function (err,data) {
if (err == undefined) {
console.info('SingleKvStoreGetBoolCallbackTest001 get success');
- expect(true).assertTrue();
+ expect(null).assertFail();
} else {
console.error('SingleKvStoreGetBoolCallbackTest001 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(err.code == 15100004).assertTrue();
}
done();
});
@@ -553,9 +556,10 @@ describe('SingleKvStoreCallbackTest', function () {
await kvStore.get(KEY_TEST_FLOAT_ELEMENT, function (err,data) {
if (err == undefined) {
console.info('SingleKvStoreGetFloatCallbackTest001 get success');
- expect(true).assertTrue();
+ expect(null).assertFail();
} else {
console.error('SingleKvStoreGetFloatCallbackTest001 get fail' + `, error code is ${err.code}, message is ${err.message}`);
+ expect(err.code == 15100004).assertTrue();
}
done();
});
diff --git a/distributeddatamgr/kvStoretest/kvStorejstest/hap/src/main/js/test/FieldNodeJsunit.test.js b/distributeddatamgr/kvStoretest/kvStorejstest/hap/src/main/js/test/FieldNodeJsunit.test.js
index 8eaf9bf4524fcbea49c91b6d1f224f0dd9f9e368..713d6613e9c4a4884955ceacb8c3209027f6a1e3 100644
--- a/distributeddatamgr/kvStoretest/kvStorejstest/hap/src/main/js/test/FieldNodeJsunit.test.js
+++ b/distributeddatamgr/kvStoretest/kvStorejstest/hap/src/main/js/test/FieldNodeJsunit.test.js
@@ -170,11 +170,12 @@ describe('fieldNodeTest', function() {
it('testtype001', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
- node.type = ddm.value.type.STRING;
- console.info('type = ' + node.type);
- expect(node.type === ddm.type.STRING).assertTrue()
+ node.type = ddm.ValueType.STRING;
+ console.info('testtype001 type = ' + node.type);
+ expect(node.type === ddm.ValueType.STRING).assertTrue();
} catch (e) {
console.info("testtype001 fail on exception: " + e);
+ expect(null).assertFail();
}
done();
})
@@ -187,11 +188,12 @@ describe('fieldNodeTest', function() {
it('testtype002', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
- node.type = ddm.type.INTEGER;
- console.info('type = ' + node.type);
- expect(node.type === ddm.type.INTEGER).assertTrue()
+ node.type = ddm.ValueType.INTEGER;
+ console.info('testtype002 type = ' + node.type);
+ expect(node.type === ddm.ValueType.INTEGER).assertTrue();
} catch (e) {
console.info("testtype002 fail on exception: " + e);
+ expect(null).assertFail();
}
done();
})
@@ -204,11 +206,12 @@ describe('fieldNodeTest', function() {
it('testtype003', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
- node.type = ddm.type.FLOAT;
- console.info('type = ' + node.type);
- expect(node.type === ddm.type.FLOAT).assertTrue()
+ node.type = ddm.ValueType.FLOAT;
+ console.info('testtype003 type = ' + node.type);
+ expect(node.type === ddm.ValueType.FLOAT).assertTrue();
} catch (e) {
console.info("testtype003 fail on exception: " + e);
+ expect(null).assertFail();
}
done();
})
@@ -221,11 +224,12 @@ describe('fieldNodeTest', function() {
it('testtype004', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
- node.type = ddm.type.BYTE_ARRAY;
- console.info('type = ' + node.type);
- expect(node.type === ddm.type.BYTE_ARRAY).assertTrue()
+ node.type = ddm.ValueType.BYTE_ARRAY;
+ console.info('testtype004 type = ' + node.type);
+ expect(node.type === ddm.ValueType.BYTE_ARRAY).assertTrue();
} catch (e) {
console.info("testtype004 fail on exception: " + e);
+ expect(null).assertFail();
}
done();
})
@@ -238,11 +242,13 @@ describe('fieldNodeTest', function() {
it('testtype005', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
- node.type = ddm.type.BOOLEAN;
- console.info('type = ' + node.type);
- expect(node.type === ddm.ValueType.BOOLEAN).assertTrue()
+ node.type = ddm.ValueType.BOOLEAN;
+ console.info('testtype005 type = ' + node.type);
+ expect(node.type === ddm.ValueType.BOOLEAN).assertTrue();
} catch (e) {
console.info("testtype005 fail on exception: " + e);
+ expect(null).assertFail();
+
}
done();
})
@@ -255,11 +261,12 @@ describe('fieldNodeTest', function() {
it('testtype006', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
- node.type = ddm.type.DOUBLE;
- console.info('type = ' + node.type);
- expect(node.type === ddm.type.DOUBLE).assertTrue()
+ node.type = ddm.ValueType.DOUBLE;
+ console.info('testtype006 type = ' + node.type);
+ expect(node.type === ddm.ValueType.DOUBLE).assertTrue();
} catch (e) {
console.info("testtype006 fail on exception: " + e);
+ expect(null).assertFail();
}
done();
})
diff --git a/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbStoreResultSetJsunit.test.js b/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbStoreResultSetJsunit.test.js
index 906aea8f42e3c909d1136fe0aabeaae7049a1cf6..7d7f7a4540a085a34dd37595ec7df4bc18fb3b6c 100644
--- a/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbStoreResultSetJsunit.test.js
+++ b/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbStoreResultSetJsunit.test.js
@@ -1649,22 +1649,17 @@ describe('rdbResultSetTest', function () {
* @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0203
* @tc.desc resultSet getColumnIndex test
*/
- it('testGetColumnIndex0004', 0, async function (done) {
+ it('testGetColumnIndex0004', 0, async function (done) {
console.info(TAG + '************* testGetColumnIndex0004 start *************');
- let errInfo = undefined;
- let predicates = await new dataRdb.RdbPredicates('test')
- let resultSet = await rdbStore.query(predicates)
- try{
- let resultSetresult = resultSet.getColumnIndex('')
- expect(-1).assertEqual(resultSetresult)
- }catch(err){
- errInfo = err
- }
- expect(errInfo.code).assertEqual("401")
- resultSet = null;
- done();
- console.info(TAG + '************* testGetColumnIndex0004 end *************');
-
+ {
+ let predicates = await new dataRdb.RdbPredicates('test')
+ let resultSet = await rdbStore.query(predicates)
+ expect(-1).assertEqual(resultSet.getColumnIndex(''))
+
+ resultSet = null;
+ done();
+ console.info(TAG + '************* testGetColumnIndex0004 end *************');
+ }
})
/**
diff --git a/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreJsunit.test.js b/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreJsunit.test.js
index f908b475bafbe3d0a84b004f1dd1de61f89ccce2..9952154883de2ff99b567f6e89aa7b61e349679f 100644
--- a/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreJsunit.test.js
+++ b/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreJsunit.test.js
@@ -249,232 +249,68 @@ describe('relationalStoreTest', function () {
})
/**
- * @tc.number SUB_DDM_RelationalStore_OpenStatus_0010
- * @tc.name Get relational store status test
- * @tc.desc relational OpenStatus
+ * @tc.number SUB_DDM_RelationalStore_Version_0010
+ * @tc.name Get relational store version test
+ * @tc.desc relational version
*/
- it('SUB_DDM_RelationalStore_OpenStatus_0010', 0, async function (done) {
- console.info(TAG + "************* SUB_DDM_RelationalStore_OpenStatus_0010 start *************");
- data_Rdb.getRdbStore(context, STORE_CONFIG, async (err, store) => {
- if (err) {
- expect(null).assertFail();
- }
- expect(store.openStatus == data_Rdb.OpenStatus.ON_CREATE).assertTrue();
- data_Rdb.getRdbStore(context, STORE_CONFIG, async (err, store) => {
- if (err) {
- expect(null).assertFail();
- }
- expect(store.openStatus == data_Rdb.OpenStatus.ON_OPEN).assertTrue();
- await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name);
- done();
- })
- })
- console.info(TAG + "************* SUB_DDM_RelationalStore_OpenStatus_0010 end *************");
- })
+ it('SUB_DDM_RelationalStore_Version_0010', 0, async function (done) {
+ console.info(TAG + "************* SUB_DDM_RelationalStore_Version_0010 start *************");
+ let store = await data_Rdb.getRdbStore(context, STORE_CONFIG);
- /**
- * @tc.number SUB_DDM_RelationalStore_OpenStatus_0020
- * @tc.name Get relational store status test
- * @tc.desc relational OpenStatus
- */
- it('SUB_DDM_RelationalStore_OpenStatus_0020', 0, async function (done) {
- console.info(TAG + "************* SUB_DDM_RelationalStore_OpenStatus_0020 start *************");
try {
- let rdbStore = await data_Rdb.getRdbStore(context, STORE_CONFIG);
- expect(rdbStore.openStatus == data_Rdb.OpenStatus.ON_CREATE).assertTrue();
- await rdbStore.executeSql(CREATE_TABLE_TEST);
- rdbStore = await data_Rdb.getRdbStore(context, STORE_CONFIG);
- expect(rdbStore.openStatus == data_Rdb.OpenStatus.ON_OPEN).assertTrue();
- await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name);
- done();
- } catch(e) {
- console.log("catch err: failed, err: code=" + e.code + " message=" + e.message);
+ store.version = 5
+ expect(5).assertEqual(store.version);
+ } catch (err) {
+ console.info("SUB_DDM_RelationalStore_Version_0010 failed: err: code=" + err.code + " message=" + err.message);
+ expect(null).assertFail();
+ }
+
+ try {
+ store.version = 2147483647
+ expect(2147483647).assertEqual(store.version);
+ } catch (err) {
+ console.info(" SUB_DDM_RelationalStore_Version_0010 failed: err: code=" + err.code + " message=" + err.message);
expect(null).assertFail();
- done();
- console.info(TAG + "************* SUB_DDM_RelationalStore_OpenStatus_0020 end *************");
}
-
- })
- /**
- * @tc.number SUB_DDM_RelationalStore_OpenStatus_0030
- * @tc.name Get relational store status test
- * @tc.desc relational OpenStatus
- */
- it('SUB_DDM_RelationalStore_OpenStatus_0030', 0, async function(done){
- console.info(TAG + "************* SUB_DDM_RelationalStore_OpenStatus_0030 start *************");
- await data_Rdb.getRdbStore(contextApplication, STORE_CONFIG, async function(err,rdbStore){
- try {
- if (err) {
- console.info("Get SUB_DDM_RelationalStore_OpenStatus_0030 failed, err: " + err);
- expect().assertFail();
- return;
- }
- expect(rdbStore.openStatus == data_Rdb.OpenStatus.ON_CREATE).assertTrue();
- } catch (err) {
- console.log("SUB_DDM_RelationalStore_OpenStatus_0030 status is " + rdbStore.OpenStatus);
- }
- console.log("Get SUB_DDM_RelationalStore_OpenStatus_0030 successfully.");
- })
await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name);
done();
- console.log("Get SUB_DDM_RelationalStore_OpenStatus_0030 successfully end.");
- await sleep(1000);
+ console.info(TAG + "************* SUB_DDM_RelationalStore_Version_0010 end *************");
})
-
+
/**
- * @tc.number SUB_DDM_RelationalStore_OpenStatus_0040
- * @tc.name Get relational store status test
- * @tc.desc relational OpenStatus
- */
- it('SUB_DDM_RelationalStore_OpenStatus_0040', 0, async function(done){
- console.info(TAG + "************* SUB_DDM_RelationalStore_OpenStatus_0040 start *************");
- await data_Rdb.getRdbStore(contextApplication, STORE_CONFIG, async function(err,rdbStore){
- try {
- if (err) {
- console.info("Get SUB_DDM_RelationalStore_OpenStatus_0040 failed, err: " + err);
- return;
- }
- expect(rdbStore.openStatus ==data_Rdb.OpenStatus.ON_CREATE).assertTrue();
- } catch (err) {
- console.log("SUB_DDM_RelationalStore_OpenStatus_0040 status1 is "+ rdbStore.OpenStatus);
- }
- });
- await sleep(1000);
- await data_Rdb.getRdbStore(contextApplication, STORE_CONFIG, async function(err,rdbStore){
- try {
- if (err) {
- console.info("Get SUB_DDM_RelationalStore_OpenStatus_0040 failed, err: " + err);
- expect().assertFail();
- return;
- }
- expect(rdbStore.openStatus ==data_Rdb.OpenStatus.ON_OPEN).assertTrue();
- } catch (err) {
- console.log("SUB_DDM_RelationalStore_OpenStatus_0040 status is "+ rdbStore.OpenStatus);
- }
- });
- await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name);
- done();
- console.log("Get SUB_DDM_RelationalStore_OpenStatus_0040 successfully end.");
- })
+ * @tc.number SUB_DDM_RelationalStore_Version_0020
+ * @tc.name Get relational store version test
+ * @tc.desc relational version
+ */
+ it('SUB_DDM_RelationalStore_Version_0020', 0, async function (done) {
+ console.info(TAG + "************* SUB_DDM_RelationalStore_Version_0020 start *************");
+ let store = await data_Rdb.getRdbStore(context, STORE_CONFIG);
- /**
- * @tc.number SUB_DDM_RelationalStore_OpenStatus_0050
- * @tc.name Get relational store status test
- * @tc.desc relational OpenStatus
- */
- it('SUB_DDM_RelationalStore_OpenStatus_0050', 0, async function(done){
- console.info(TAG + "************* SUB_DDM_RelationalStore_OpenStatus_0050 start *************");
try {
- let promise = null;
- promise = await data_Rdb.getRdbStore(context, STORE_CONFIG);
- promise =null;
- promise = await data_Rdb.getRdbStore(context, STORE_CONFIG);
- console.info("Get SUB_DDM_RelationalStore_OpenStatus_0050 promise.openStatus: " + promise.openStatus);
- console.info("Get SUB_DDM_RelationalStore_OpenStatus_0050 data_Rdb.OpenStatus.ON_OPEN: " + data_Rdb.OpenStatus.ON_OPEN);
- expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_OPEN);
- await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name);
+ store.version = -2147483648;
} catch (err) {
- console.info(TAG + "Get rdbstore fail catch err: " + err);
- expect(null).assertFail();
+ console.info("SUB_DDM_RelationalStore_Version_0020 failed1: err: code=" + err.code + " message=" + err.message);
+ expect("401").assertEqual(err.code);
}
- done();
- console.log("Get SUB_DDM_RelationalStore_OpenStatus_0050 successfully end.");
- })
- /**
- * @tc.number SUB_DDM_RelationalStore_OpenStatus_0060
- * @tc.name Get relational store status test
- * @tc.desc relational OpenStatus
- */
- it('SUB_DDM_RelationalStore_OpenStatus_0060', 0, async function(done){
- console.info(TAG + "************* SUB_DDM_RelationalStore_OpenStatus_0060 start *************");
- let STORE_CONFIG1 = {
- name: "rdbnumber.db",
- securityLevel: data_Rdb.SecurityLevel.S1
- };
try {
- let promise = null;
- promise = await data_Rdb.getRdbStore(context, STORE_CONFIG);
- console.info("Get SUB_DDM_RelationalStore_OpenStatus_0060 STORE_CONFIG promise.openStatus: " + promise.openStatus);
- expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_CREATE);
- promise = await data_Rdb.getRdbStore(context, STORE_CONFIG1);
- console.info("Get SUB_DDM_RelationalStore_OpenStatus_0060 STORE_CONFIG1 promise.openStatus: " + promise.openStatus);
- expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_CREATE);
+ store.version = 2147483647000;
} catch (err) {
- console.info(TAG + "Get SUB_DDM_RelationalStore_OpenStatus_0060 fail catch err: " + err);
- expect(null).assertFail();
+ console.info("SUB_DDM_RelationalStore_Version_0020 failed2: err: code=" + err.code + " message=" + err.message);
+ expect("401").assertEqual(err.code);
}
- await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name);
- await data_Rdb.deleteRdbStore(context, STORE_CONFIG1.name);
- done();
- console.log("Get SUB_DDM_RelationalStore_OpenStatus_0060 successfully end.");
- })
-
- /**
- * @tc.number SUB_DDM_RelationalStore_OpenStatus_0070
- * @tc.name Get relational store status test
- * @tc.desc relational OpenStatus
- */
- it('SUB_DDM_RelationalStore_OpenStatus_0070', 0, async function(done){
- console.info(TAG + "************* SUB_DDM_RelationalStore_OpenStatus_0070 start *************");
- let STORE_CONFIG1 = {
- name: "rdbnumber.db",
- securityLevel: data_Rdb.SecurityLevel.S1
- };
- try {
- let promise = null;
- promise = await data_Rdb.getRdbStore(context, STORE_CONFIG);
- console.info("Get SUB_DDM_RelationalStore_OpenStatus_0070 STORE_CONFIG promise.openStatus: " + promise.openStatus);
- expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_CREATE);
- let rdbResult = await data_Rdb.getRdbStore(context, STORE_CONFIG1);
- console.info("Get SUB_DDM_RelationalStore_OpenStatus_0070 STORE_CONFIG1 rdbResult.openStatus: " + rdbResult.openStatus);
- expect(rdbResult.openStatus).assertEqual(data_Rdb.OpenStatus.ON_CREATE);
- } catch (err) {
- console.info(TAG + "Get SUB_DDM_RelationalStore_OpenStatus_0070 fail catch err: " + err);
- expect(null).assertFail();
- }
- await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name);
- await data_Rdb.deleteRdbStore(context, STORE_CONFIG1.name);
- done();
- console.log("Get SUB_DDM_RelationalStore_OpenStatus_0070 successfully end.");
- })
- /**
- * @tc.number SUB_DDM_RelationalStore_OpenStatus_0080
- * @tc.name Get relational store status test
- * @tc.desc relational OpenStatus
- */
- it('SUB_DDM_RelationalStore_OpenStatus_0080', 0, async function(done){
- console.info(TAG + "************* SUB_DDM_RelationalStore_OpenStatus_0050 start *************");
- let STORE_CONFIG1 = {
- name: "rdbnumber.db",
- securityLevel: data_Rdb.SecurityLevel.S1
- };
try {
- let promise = null;
- promise = await data_Rdb.getRdbStore(context, STORE_CONFIG);
- console.info("Get SUB_DDM_RelationalStore_OpenStatus_0080 STORE_CONFIG promise.openStatus: " + promise.openStatus);
- expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_CREATE);
- let rdbResult = await data_Rdb.getRdbStore(context, STORE_CONFIG1);
- console.info("Get SUB_DDM_RelationalStore_OpenStatus_0080 STORE_CONFIG1 rdbResult.openStatus: " + rdbResult.openStatus);
- expect(rdbResult.openStatus).assertEqual(data_Rdb.OpenStatus.ON_CREATE);
- promise = null;
- promise = await data_Rdb.getRdbStore(context, STORE_CONFIG);
- console.info("Get SUB_DDM_RelationalStore_OpenStatus_0080 STORE_CONFIG promise.openStatus: " + promise.openStatus);
- expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_OPEN);
- rdbResult = null;
- rdbResult = await data_Rdb.getRdbStore(context, STORE_CONFIG1);
- console.info("Get SUB_DDM_RelationalStore_OpenStatus_0080 STORE_CONFIG1 rdbResult.openStatus: " + rdbResult.openStatus);
- expect(rdbResult.openStatus).assertEqual(data_Rdb.OpenStatus.ON_OPEN);
+ store.version = 0;
} catch (err) {
- console.info(TAG + "Get SUB_DDM_RelationalStore_OpenStatus_0080 fail catch err: " + err);
- expect(null).assertFail();
+ console.info("SUB_DDM_RelationalStore_Version_0020 failed3: err: code=" + err.code + " message=" + err.message);
+ expect("401").assertEqual(err.code);
}
+
await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name);
- await data_Rdb.deleteRdbStore(context, STORE_CONFIG1.name);
done();
- console.log("Get SUB_DDM_RelationalStore_OpenStatus_0080 successfully end.");
+ console.info(TAG + "************* SUB_DDM_RelationalStore_Version_0020 end *************");
})
console.info(TAG + "*************Unit Test End*************");
diff --git a/distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/module.json b/distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/module.json
index eed3943f3deffc8b1315a848b2c8ed66e0f8474a..8ff8ddf62ede3b6a85ce3e90b2471261cb23ece7 100644
--- a/distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/module.json
+++ b/distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/module.json
@@ -16,6 +16,12 @@
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [
{
"name": "ohos.acts.RelationalStoreStage.MainAbility",
diff --git a/graphic/effectKit/entry/src/main/module.json b/graphic/effectKit/entry/src/main/module.json
index 50fb31c61b7f56bb5825b3afc17aa7146ef01ec9..c641103d2db2841afdf6a002b9afe40e0544a331 100644
--- a/graphic/effectKit/entry/src/main/module.json
+++ b/graphic/effectKit/entry/src/main/module.json
@@ -14,6 +14,12 @@
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [{
"name": "com.example.ActsEffectKitTest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
diff --git a/graphic/graphicColorSpace/entry/src/main/module.json b/graphic/graphicColorSpace/entry/src/main/module.json
index 9d6bfbf19d42c5ebf55b3e7d775ae79d8ff86fcf..e2a9f9c0e215c944fa5fbe94ad5a4f7491d25063 100644
--- a/graphic/graphicColorSpace/entry/src/main/module.json
+++ b/graphic/graphicColorSpace/entry/src/main/module.json
@@ -14,6 +14,12 @@
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
+ "metadata": [
+ {
+ "name": "ArkTSPartialUpdate",
+ "value": "false"
+ }
+ ],
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
diff --git a/graphic/webGL/BUILD.gn b/graphic/webGL/BUILD.gn
index e94d45a869899ec8babf3638cc442ba9d424fd97..4be546a1a46320e4a8e3cffdf2a227f9befcf7d2 100644
--- a/graphic/webGL/BUILD.gn
+++ b/graphic/webGL/BUILD.gn
@@ -1,4 +1,4 @@
-# Copyright (C) 2021 Huawei Device Co., Ltd.
+# Copyright (C) 2022 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
@@ -16,16 +16,18 @@ import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("webGL_hap_test") {
hap_profile = "./src/main/config.json"
deps = [
- ":window_js_assets",
- ":window_resources",
+ ":webGL_js_assets",
+ ":webGL_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsWebGLHapTest"
}
-ohos_js_assets("window_js_assets") {
- source_dir = "./src/main/js/default"
+ohos_js_assets("webGL_js_assets") {
+ js2abc = true
+ hap_profile = "./src/main/config.json"
+ source_dir = "./src/main/js"
}
-ohos_resources("window_resources") {
+ohos_resources("webGL_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
diff --git a/graphic/webGL/Test.json b/graphic/webGL/Test.json
index 2495f81fb0f1f9dfe4954bd7fcd9c9af7c6612ed..0b16200512f1e89ecb806ae6d88da39921618b18 100644
--- a/graphic/webGL/Test.json
+++ b/graphic/webGL/Test.json
@@ -1,10 +1,12 @@
{
"description": "Configuration for hjunit demo Tests",
"driver": {
- "type": "JSUnitTest",
+ "type": "OHJSUnitTest",
"test-timeout": "1200000",
- "package": "com.test.webGL",
- "shell-timeout": "60000"
+ "shell-timeout": "800000",
+ "bundle-name": "com.test.webGL",
+ "package-name": "com.test.webGL",
+ "testcase-timeout": "300000"
},
"kits": [
{
@@ -17,7 +19,8 @@
{
"type": "ShellKit",
"run-command": [
- "hilog -Q pidoff"
+ "power-shell wakeup",
+ "power-shell setmode 602"
]
}
]
diff --git a/graphic/webGL/src/main/config.json b/graphic/webGL/src/main/config.json
index 892807e25e53a4aac0425b038cbe23afc5594ae1..b5a4cbc59ad748eafce90a4a07f585dcdf840a12 100644
--- a/graphic/webGL/src/main/config.json
+++ b/graphic/webGL/src/main/config.json
@@ -26,38 +26,70 @@
"moduleType": "entry"
},
"abilities": [
- {
- "visible": true,
- "skills": [
- {
- "entities": [
- "entity.system.home"
- ],
- "actions": [
- "action.system.home"
- ]
- }
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "formsEnabled": false,
+ "name": "com.test.webGL.MainAbility",
+ "srcLanguage": "js",
+ "srcPath": "MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:MainAbility_desc",
+ "label": "$string:MainAbility_label",
+ "type": "page",
+ "visible": true,
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "formsEnabled": false,
+ "name": ".TestAbility",
+ "srcLanguage": "js",
+ "srcPath": "TestAbility",
+ "icon": "$media:icon",
+ "description": "$string:TestAbility_desc",
+ "label": "$string:TestAbility_label",
+ "type": "page",
+ "visible": true,
+ "launchType": "standard"
+ }
],
- "name": "com.test.webGL.MainAbility",
- "icon": "$media:icon",
- "description": "$string:mainability_description",
- "label": "$string:app_name",
- "type": "page",
- "launchType": "standard",
- "isVisible": "true"
- }
- ],
- "js": [
- {
- "pages": [
- "pages/index/index"
+ "js": [
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": "default",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": false
+ }
+ },
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": ".TestAbility",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": false
+ }
+ }
],
- "name": "default",
- "window": {
- "designWidth": 720,
- "autoDesignWidth": false
- }
- }
- ]
+ "testRunner": {
+ "name": "OpenHarmonyTestRunner",
+ "srcPath": "TestRunner"
+ },
+ "mainAbility": ".MainAbility",
+ "srcPath": ""
}
}
diff --git a/graphic/webGL/src/main/js/MainAbility/app.js b/graphic/webGL/src/main/js/MainAbility/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..bc635539608de340468c90d7cd66dfb5a6affba2
--- /dev/null
+++ b/graphic/webGL/src/main/js/MainAbility/app.js
@@ -0,0 +1,23 @@
+/*
+ * 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('AceApplication onCreate');
+
+ },
+ onDestroy() {
+ console.info('AceApplication onDestroy');
+ }
+};
diff --git a/graphic/webGL/src/main/js/default/i18n/en-US.json b/graphic/webGL/src/main/js/MainAbility/i18n/en-US.json
similarity index 100%
rename from graphic/webGL/src/main/js/default/i18n/en-US.json
rename to graphic/webGL/src/main/js/MainAbility/i18n/en-US.json
diff --git a/graphic/webGL/src/main/js/default/i18n/zh-CN.json b/graphic/webGL/src/main/js/MainAbility/i18n/zh-CN.json
similarity index 100%
rename from graphic/webGL/src/main/js/default/i18n/zh-CN.json
rename to graphic/webGL/src/main/js/MainAbility/i18n/zh-CN.json
diff --git a/graphic/webGL/src/main/js/default/pages/index/index.css b/graphic/webGL/src/main/js/MainAbility/pages/index/index.css
similarity index 100%
rename from graphic/webGL/src/main/js/default/pages/index/index.css
rename to graphic/webGL/src/main/js/MainAbility/pages/index/index.css
diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/MainAbility/pages/index/index.hml b/graphic/webGL/src/main/js/MainAbility/pages/index/index.hml
similarity index 100%
rename from security/cryptoFramework/js_api_test_two/src/main/js/MainAbility/pages/index/index.hml
rename to graphic/webGL/src/main/js/MainAbility/pages/index/index.hml
diff --git a/graphic/webGL/src/main/js/MainAbility/pages/index/index.js b/graphic/webGL/src/main/js/MainAbility/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..1ced937cf25654b5e91be9753e6b60f21d82569c
--- /dev/null
+++ b/graphic/webGL/src/main/js/MainAbility/pages/index/index.js
@@ -0,0 +1,23 @@
+/*
+ * 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 {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ }
+}
diff --git a/graphic/webGL/src/main/js/TestAbility/app.js b/graphic/webGL/src/main/js/TestAbility/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..bc7aee0a9767637c83bafdf28e4605c504263996
--- /dev/null
+++ b/graphic/webGL/src/main/js/TestAbility/app.js
@@ -0,0 +1,24 @@
+/*
+ * 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');
+ }
+};
diff --git a/graphic/webGL/src/main/js/TestAbility/i18n/en-US.json b/graphic/webGL/src/main/js/TestAbility/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..25af508b55c6f7eb289f5adbfa3fcd899693d092
--- /dev/null
+++ b/graphic/webGL/src/main/js/TestAbility/i18n/en-US.json
@@ -0,0 +1,7 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ },
+ "Files":{}
+}
\ No newline at end of file
diff --git a/graphic/webGL/src/main/js/TestAbility/i18n/zh-CN.json b/graphic/webGL/src/main/js/TestAbility/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..c74f8594ce7999792ef0ce67414b1eae9cf01907
--- /dev/null
+++ b/graphic/webGL/src/main/js/TestAbility/i18n/zh-CN.json
@@ -0,0 +1,7 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ },
+ "Files":{}
+}
\ No newline at end of file
diff --git a/graphic/webGL/src/main/js/TestAbility/pages/index/index.css b/graphic/webGL/src/main/js/TestAbility/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..b21c92c6290ea747bd891e2ab673721afc5521ed
--- /dev/null
+++ b/graphic/webGL/src/main/js/TestAbility/pages/index/index.css
@@ -0,0 +1,30 @@
+.container {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ left: 0px;
+ top: 0px;
+ width: 100%;
+ height: 100%;
+}
+
+.title {
+ font-size: 60px;
+ text-align: center;
+ width: 100%;
+ height: 40%;
+ margin: 10px;
+}
+
+@media screen and (device-type: phone) and (orientation: landscape) {
+ .title {
+ font-size: 60px;
+ }
+}
+
+@media screen and (device-type: tablet) and (orientation: landscape) {
+ .title {
+ font-size: 100px;
+ }
+}
\ No newline at end of file
diff --git a/graphic/webGL/src/main/js/TestAbility/pages/index/index.hml b/graphic/webGL/src/main/js/TestAbility/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..d84ef493b1aec0e40e3901957d593416830e2705
--- /dev/null
+++ b/graphic/webGL/src/main/js/TestAbility/pages/index/index.hml
@@ -0,0 +1,8 @@
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
+
+
+
diff --git a/graphic/webGL/src/main/js/TestAbility/pages/index/index.js b/graphic/webGL/src/main/js/TestAbility/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..5a8af71d5a48ea4951cb87454b73a48570422123
--- /dev/null
+++ b/graphic/webGL/src/main/js/TestAbility/pages/index/index.js
@@ -0,0 +1,35 @@
+/*
+ * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
+import { Hypium } from '@ohos/hypium'
+import testsuite from '../../../test/List.test'
+
+export default {
+ data:{
+ title:""
+ },
+ onInit(){
+ this.title = this.$t('strings.world');
+ },
+ onShow(){
+ global.el = this.$refs.canvas1;
+ global.el2 = this.$refs.canvas2;
+ var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+ var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ console.info('start run testcase!!!')
+ Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
+ }
+}
diff --git a/graphic/webGL/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/graphic/webGL/src/main/js/TestRunner/OpenHarmonyTestRunner.js
new file mode 100644
index 0000000000000000000000000000000000000000..b9e78ce7cf73f1ade6ba52a408a44e33f5430f0d
--- /dev/null
+++ b/graphic/webGL/src/main/js/TestRunner/OpenHarmonyTestRunner.js
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
+
+function translateParamsToString(parameters) {
+ const keySet = new Set([
+ '-s class', '-s notClass', '-s suite', '-s itName',
+ '-s level', '-s testType', '-s size', '-s timeout',
+ '-s package', '-s dryRun'
+ ])
+ let targetParams = '';
+ for (const key in parameters) {
+ if (keySet.has(key)) {
+ targetParams += ' ' + key + ' ' + parameters[key]
+ }
+ }
+ return targetParams.trim()
+}
+
+ export default {
+ onPrepare() {
+ console.info('OpenHarmonyTestRunner OnPrepare')
+ },
+ onRun() {
+ console.log('OpenHarmonyTestRunner onRun run')
+ var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+
+ var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
+
+ var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
+ cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
+ var debug = abilityDelegatorArguments.parameters["-D"]
+ console.info('debug value : '+debug)
+ if (debug == 'true')
+ {
+ cmd += ' -D'
+ }
+ console.info('cmd : '+cmd)
+ abilityDelegator.executeShellCommand(cmd, (err, data) => {
+ console.info('executeShellCommand : err : ' + JSON.stringify(err));
+ console.info('executeShellCommand : data : ' + data.stdResult);
+ console.info('executeShellCommand : data : ' + data.exitCode);
+ })
+ }
+};
diff --git a/graphic/webGL/src/main/js/default/pages/index/index.hml b/graphic/webGL/src/main/js/default/pages/index/index.hml
deleted file mode 100644
index 4616360cc1594be7edbdaca39ef4670e0f68be2a..0000000000000000000000000000000000000000
--- a/graphic/webGL/src/main/js/default/pages/index/index.hml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- {{ $t('strings.hello') }} {{ title }}
-
-
-
-
diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test01.js b/graphic/webGL/src/main/js/default/test/WebGL.test01.js
deleted file mode 100644
index 7d1c78f8c5f98f6b363bd44ebe34f56a498008a2..0000000000000000000000000000000000000000
--- a/graphic/webGL/src/main/js/default/test/WebGL.test01.js
+++ /dev/null
@@ -1,2496 +0,0 @@
-/*
- * 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 app from '@system.app'
-
-import {
- describe,
- beforeAll,
- beforeEach,
- afterEach,
- afterAll,
- it,
- expect
-} from 'deccjsunit/index'
-
-describe('webgl1Test_webgl1', function() {
- console.info('webgltest start');
- var gl;
- var gl2;
-
- var indices = new Uint16Array([0, 1, 2, 1, 3, 4]);
- var vertices = new Uint16Array([
- -0.5, 0.5, 0.0,
- 0.0, 0.5, 0.0,
- -0.25, 0.25, 0.0,
- 0.5, 0.5, 0.0,
- 0.25, 0.25, 0.0,
- ])
-
- //顶点着色器程序
- var VSHADER_SOURCE =
- "attribute vec4 a_Position;" +
- "void main() {" +
- //设置坐标
- "gl_Position = a_Position; " +
- // "gl_PointSize = 10.0;" +
- "} ";
-
- //片元着色器
- var FSHADER_SOURCE =
- "void main() {" +
- //设置颜色
- "gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);" +
- "}";
-
- function globalFunction() {
- const vertexShader = gl.createShader(gl.VERTEX_SHADER);
- gl.shaderSource(vertexShader, VSHADER_SOURCE);
- gl.compileShader(vertexShader);
- const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
- gl.shaderSource(fragmentShader, FSHADER_SOURCE);
- gl.compileShader(fragmentShader);
- const programObj = gl.createProgram();
- console.info("testUseProgram has failed for " + programObj)
- const useProgramError1 = gl.getError();
- console.info("useProgramError: " + useProgramError1);
- const renderBufferValue1 = gl.getParameter(gl.CURRENT_PROGRAM);
- console.info("testUseProgram has failed for " + renderBufferValue1)
- gl.attachShader(programObj, vertexShader);
- gl.attachShader(programObj, fragmentShader);
- gl.linkProgram(programObj);
- gl.useProgram(programObj);
- return programObj;
- }
-
-
- function createProgram(gl) {
- //顶点着色器程序
- var VSHADER_SOURCE =
- 'attribute vec4 a_Position;\n' +
- 'void main() {\n' +
- ' gl_Position = a_Position;\n' +
- '}\n';
-
- // 片元着色器程序
- var FSHADER_SOURCE =
- 'precision mediump float;\n' +
- 'uniform vec4 u_FragColor;\n' +
- 'void main() {\n' +
- ' gl_FragColor = u_FragColor;\n' +
- '}\n';
- var vertexShader = gl.createShader(gl.VERTEX_SHADER);
- gl.shaderSource(vertexShader, VSHADER_SOURCE);
- gl.compileShader(vertexShader);
- var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
- gl.shaderSource(fragmentShader, FSHADER_SOURCE);
- gl.compileShader(fragmentShader);
- const programObj = gl.createProgram();
- console.log("testUseProgram has failed for " + programObj)
- const useProgramError1 = gl.getError();
- console.info("useProgramError: " + useProgramError1);
- const renderBufferValue1 = gl.getParameter(gl.CURRENT_PROGRAM);
- console.log("testUseProgram has failed for " + renderBufferValue1)
- gl.attachShader(programObj, vertexShader);
- gl.attachShader(programObj, fragmentShader);
- gl.linkProgram(programObj);
- gl.useProgram(programObj);
- return programObj;
- }
-
- function initShaders(gl, vshader, fshader) {
- var program = createProgramExternal(gl, vshader, fshader);
- console.log("======createProgram program: " + JSON.stringify(program));
-
- if (!program) {
- console.log('Failed to create program');
- return false;
- }
-
- gl.useProgram(program);
- gl.program = program;
-
- return true;
- }
-
- function createProgramExternal(gl, vshader, fshader) {
- // Create shader object
- var vertexShader = loadShader(gl, gl.VERTEX_SHADER, vshader);
- console.log("======vertexShader: " + vertexShader);
- var fragmentShader = loadShader(gl, gl.FRAGMENT_SHADER, fshader);
- if (!vertexShader || !fragmentShader) {
- return null;
- }
-
- // Create a program object
- var program = gl.createProgram();
- console.log("======createProgram program: " + JSON.stringify(program));
-
- if (!program) {
- return null;
- }
-
- // Attach the shader objects
- gl.attachShader(program, vertexShader);
- gl.attachShader(program, fragmentShader);
-
- // Link the program object
- gl.linkProgram(program);
-
- // Check the result of linking
- var linked = gl.getProgramParameter(program, 0x8B82);
- console.log("======getProgramParameter linked: " + linked);
-
- const getUniformLocationValue = gl.getUniformLocation(program, "a_Position");
- console.log("======getUniformLocation: " + JSON.stringify(getUniformLocationValue));
-
-
- if (!linked) {
- var error = gl.getProgramInfoLog(program);
- console.log('Failed to link program: ' + error);
- gl.deleteProgram(program);
- gl.deleteShader(fragmentShader);
- gl.deleteShader(vertexShader);
- return null;
- }
-
- return program;
- }
-
- function loadShader(gl, type, source) {
- console.log("======into loadShader====");
- // Create shader object
- var shader = gl.createShader(type);
- if (shader == null) {
- console.log('unable to create shader');
- return null;
- }
-
- const isShaderValue = gl.isShader(shader);
- console.log('isShader: ' + isShaderValue);
-
- // Set the shader program
- gl.shaderSource(shader, source);
-
- // Compile the shader
- gl.compileShader(shader);
-
- // Check the result of compilation
- var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
- if (!compiled) {
- var error = gl.getShaderInfoLog(shader);
- console.log('Failed to compile shader: ' + error);
- gl.deleteShader(shader);
- return null;
- }
-
- var vertex = gl.getShaderParameter(shader, gl.VERTEX_SHADER);
- console.log('getShaderParameter VERTEX_SHADER: ' + vertex);
-
-
- return shader;
- }
-
- function initVertexBuffers(gl) {
- var vertices = new Float32Array([
- 0.0, -1.0, -0.5, 0, 0.5, 0
- ]);
-
- var n = 3; // 点的个数
-
- // 创建缓冲区对象
- var vertexBuffer = gl.createBuffer();
- if (!vertexBuffer) {
- console.log('Failed to create the buffer object');
- return -1;
- }
-
- // 将缓冲区对象绑定到目标
- gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
- // 向缓冲区对象写入数据
- gl.bufferData(gl.ARRAY_BUFFER, vertices.buffer, gl.STATIC_DRAW);
-
- var aPosition = gl.getAttribLocation(gl.program, 'a_Position');
- console.info("webgl# getAttribLocation getAttribLocation success:" + JSON.stringify(gl.program));
- console.info("webgl# getAttribLocation getAttribLocation success:" + aPosition);
- if (aPosition < 0) {
- console.log('Failed to get the storage location of a_Position');
- return -1;
- }
- // 将缓冲区对象分配给a_Position变量
- gl.vertexAttribPointer(aPosition, 2, gl.FLOAT, false, 0, 0);
-
- // 连接a_Position变量与分配给它的缓冲区对象
- gl.enableVertexAttribArray(aPosition);
-
- return n;
- }
-
-
- var float1 = new Float32Array([1.1, 1.2, 1.3, 1.4]);
- var int1 = new Int8Array([1, 1, 1, 1]);
- var uint1 = new Uint8Array([1, 1, 1, 1]);
- var float2 = [1.1, 1.2, 1.3, 1.4];
- var int2 = [1, 1, 1, 1];
- var uint2 = [1, 1, 1, 1];
-
- function initContext() {
- console.info('initContext start');
- // 获取canvas元素
- const canvas = global.el;
- const canvas2 = global.el2;
- // 获取webgl上下文
- gl = canvas.getContext('webgl');
- if (!gl) {
- console.log('webgltest Failed to get the rendering context for WebGL');
- }
- gl2 = canvas2.getContext('webgl2');
- if (!gl) {
- console.log('webgltest Failed to get the rendering context for WebGL2');
- }
- console.info('webgltest initContext finish');
- }
-
- function deleteContext() {
- if (gl != null) {
- gl = null;
- console.info("webgltest gl has null");
- }
- if (gl2 != null) {
- console.info("webgltest gl2 has null");
- gl2 = null;
- }
- }
-
- /**
- * run before testClass
- */
- beforeAll(async function(done) {
- console.info('webgltest beforeAll called');
- initContext();
- done();
- });
-
- /**
- * run after testClass
- */
- afterAll(async function(done) {
- console.info('webgltest afterEach called');
- deleteContext();
- done();
- })
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0001
- * @tc.name webgl_test_getContextAttributes
- * @tc.desc Test getContextAttributes.
- */
- it('webgl_test_getContextAttributes', 0, async function(done) {
- console.info("webgltest into getContextAttributes");
- const getContextAttributesValue = gl.getContextAttributes();
- const alphaValue = getContextAttributesValue.alpha;
- console.info("webgltest getContextAttributes: " + getContextAttributesValue);
- expect(typeof(getContextAttributesValue)).assertEqual("object" || null);
- done();
- })
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0002
- * @tc.name webgl_test_isContextLost
- * @tc.desc Test isContextLost.
- */
- it('webgl_test_isContextLost', 0, async function(done) {
- console.info("webgltest into isContextLost");
- const isContextLostValue = gl.isContextLost();
- console.info("webgltest isContextLost: " + isContextLostValue);
- expect(isContextLostValue).assertEqual(false);
- done();
- })
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0003
- * @tc.name webgl_test_getSupportedExtensions
- * @tc.desc Test getSupportedExtensions.
- */
- it('webgl_test_getSupportedExtensions', 0, async function(done) {
- //initContext();
- console.info("webgltest into getSupportedExtensions");
- const getSupportedExtensionsValue = gl.getSupportedExtensions();
- console.info("webgltest getSupportedExtensions: " + getSupportedExtensionsValue);
- expect(typeof(getSupportedExtensionsValue)).assertEqual('object');
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0005
- * @tc.name webgl_test_getExtension
- * @tc.desc Test getExtension.
- */
- it('webgl_test_getExtension', 0, async function(done) {
- //initContext();
- console.info("webgltest into getExtension");
- const getExtensionValue = gl.getExtension();
- console.info("webgltest getExtension: " + getExtensionValue);
- expect(getExtensionValue).assertEqual(undefined);
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0006
- * @tc.name webgl_test_activeTexture
- * @tc.desc Test activeTexture.
- */
- it('webgl_test_activeTexture', 0, async function(done) {
- //initContext();
- console.info("webgltest into activeTexture");
- gl.activeTexture(gl.TEXTURE0);
- const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE);
- console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter);
- expect(activeTextureParameter).assertEqual(33984);
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0007
- * @tc.name webgl_test_activeTexture_1
- * @tc.desc Test activeTexture.
- */
- it('webgl_test_activeTexture_1', 0, async function(done) {
- //initContext();
- console.info("webgltest into activeTexture");
- gl.activeTexture(gl.TEXTURE1);
- const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE);
- console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter);
- expect(activeTextureParameter).assertEqual(33985);
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0008
- * @tc.name webgl_test_attachShader
- * @tc.desc Test attachShader.
- */
- it('webgl_test_attachShader', 0, async function(done) {
- //initContext();
- console.info("webgltest into attachShader");
-
- //顶点着色器程序
- var VSHADER_SOURCE =
- 'attribute vec4 a_Position;\n' +
- 'void main() {\n' +
- ' gl_Position = a_Position;\n' +
- '}\n';
-
- // 片元着色器程序
- var FSHADER_SOURCE =
- 'precision mediump float;\n' +
- 'uniform vec4 u_FragColor;\n' +
- 'void main() {\n' +
- ' gl_FragColor = u_FragColor;\n' +
- '}\n';
- var vertexShader = gl.createShader(gl.VERTEX_SHADER);
- gl.shaderSource(vertexShader, VSHADER_SOURCE);
- gl.compileShader(vertexShader);
- var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
- gl.shaderSource(fragmentShader, FSHADER_SOURCE);
- gl.compileShader(fragmentShader);
- const programObj = gl.createProgram();
- console.log("testUseProgram has failed for " + programObj)
- const useProgramError1 = gl.getError();
- console.info("useProgramError: " + useProgramError1);
- const renderBufferValue1 = gl.getParameter(gl.CURRENT_PROGRAM);
- console.log("testUseProgram has failed for " + renderBufferValue1)
- gl.attachShader(programObj, vertexShader);
- gl.attachShader(programObj, fragmentShader);
- gl.linkProgram(programObj);
- gl.useProgram(programObj);
-
- let errorCode = gl.getError();
- console.info("webgltest attachShader getError: " + errorCode);
- expect(errorCode).assertEqual(gl.NO_ERROR);
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0009
- * @tc.name webgl_test_bindAttribLocation
- * @tc.desc Test bindAttribLocation.
- */
- it('webgl_test_bindAttribLocation', 0, async function(done) {
- //initContext();
- console.info("webgltest into bindAttribLocation");
-
- //顶点着色器程序
- var VSHADER_SOURCE =
- 'attribute vec4 a_Position;\n' +
- 'void main() {\n' +
- ' gl_Position = a_Position;\n' +
- '}\n';
-
- // 片元着色器程序
- var FSHADER_SOURCE =
- 'precision mediump float;\n' +
- 'uniform vec4 u_FragColor;\n' +
- 'void main() {\n' +
- ' gl_FragColor = u_FragColor;\n' +
- '}\n';
- var vertexShader = gl.createShader(gl.VERTEX_SHADER);
- gl.shaderSource(vertexShader, VSHADER_SOURCE);
- gl.compileShader(vertexShader);
- var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
- gl.shaderSource(fragmentShader, FSHADER_SOURCE);
- gl.compileShader(fragmentShader);
- const programObj = gl.createProgram();
- console.log("testUseProgram has failed for " + programObj)
- const useProgramError1 = gl.getError();
- console.info("useProgramError: " + useProgramError1);
- const renderBufferValue1 = gl.getParameter(gl.CURRENT_PROGRAM);
- console.log("testUseProgram has failed for " + renderBufferValue1)
- gl.attachShader(programObj, vertexShader);
- gl.attachShader(programObj, fragmentShader);
- gl.linkProgram(programObj);
- gl.useProgram(programObj);
-
- gl.bindAttribLocation(programObj, 1, 'a_Position');
-
- let errorCode = gl.getError();
- console.info("webgltest bindAttribLocation getError: " + errorCode);
- expect(errorCode).assertEqual(gl.NO_ERROR);
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0010
- * @tc.name webgl_test_bindBuffer
- * @tc.desc Test bindBuffer.
- */
- it('webgl_test_bindBuffer', 0, async function(done) {
- //initContext();
- console.info("webgltest into bindBuffer");
-
- var buffer = gl.createBuffer();
-
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
-
- //bind后isBuffer为true
- const isBufferValue = gl.isBuffer(buffer);
- console.info("isBufferValue: " + isBufferValue);
- expect(isBufferValue).assertEqual(true);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0011
- * @tc.name webgl_test_bindBuffer_1
- * @tc.desc Test bindBuffer.
- */
- it('webgl_test_bindBuffer_1', 0, async function(done) {
- //initContext();
- console.info("webgltest into bindBuffer");
-
- var buffer = gl.createBuffer();
-
- // bind前isBuffer为false
- const isBufferValue0 = gl.isBuffer(buffer);
- console.info("webgltest isBufferValue0: " + isBufferValue0);
- expect(isBufferValue0).assertEqual(false);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
-
- //bind后isBuffer为true
- const isBufferValue = gl.isBuffer(buffer);
- console.info("isBufferValue: " + isBufferValue);
- expect(isBufferValue).assertEqual(true);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0012
- * @tc.name webgl_test_bindFramebuffer
- * @tc.desc Test bindFramebuffer.
- */
- it('webgl_test_bindFramebuffer', 0, async function(done) {
- //initContext();
- console.info("webgltest into bindFramebuffer");
-
- var framebuffer = gl.createFramebuffer();
-
- const isFramebuffer1 = gl.isFramebuffer(framebuffer);
- console.info("createFramebuffer --> isFramebuffer1: " + isFramebuffer1);
- expect(isFramebuffer1).assertEqual(false);
-
- // bind
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
-
- const isFrameBuffer2 = gl.isFramebuffer(framebuffer);
- console.info("createFramebuffer --> bindFramebuffer --> isFrameBuffer2: " +
- isFrameBuffer2);
- expect(isFrameBuffer2).assertEqual(true);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0013
- * @tc.name webgl_test_bindRenderbuffer
- * @tc.desc Test bindRenderbuffer.
- */
- it('webgl_test_bindRenderbuffer', 0, async function(done) {
- //initContext();
- console.info("webgltest into bindRenderbuffer");
-
- var renderbuffer = gl.createRenderbuffer();
-
- //不 bindRenderbuffer, 那么下面会返回 false
- const isRenderBuffer0 = gl.isRenderbuffer(renderbuffer);
- console.info("createRenderbuffer --> isRenderbuffer0: " + isRenderBuffer0);
- expect(isRenderBuffer0).assertEqual(false);
-
- gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
-
- // bindRenderbuffer后, isRenderbuffer返回true
- const isRenderBuffer1 = gl.isRenderbuffer(renderbuffer);
- console.info("createRenderbuffer --> bindRenderbuffer --> isRenderbuffer: " +
- isRenderBuffer1);
- expect(isRenderBuffer1).assertEqual(true);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0014
- * @tc.name webgl_test_bindTexture
- * @tc.desc Test bindTexture.
- */
- it('webgl_test_bindTexture', 0, async function(done) {
- //initContext();
- console.info("webgltest into bindTexture");
-
- var texture = gl.createTexture();
-
- const isTexture0 = gl.isTexture(texture);
- console.info("createTexture --> isTexture: " + isTexture0);
- expect(isTexture0).assertEqual(false);
-
- gl.bindTexture(gl.TEXTURE_2D, texture);
-
- const isTexture1 = gl.isTexture(texture);
- console.info("createTexture --> bindTexture --> isTexture: " + isTexture1);
- expect(isTexture1).assertEqual(true);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0015
- * @tc.name webgl_test_blendColor
- * @tc.desc Test blendColor.
- */
- it('webgl_test_blendColor', 0, async function(done) {
- //initContext();
- console.info("webgltest into blendColor");
-
- gl.blendColor(0, 0.5, 1, 1);
- const blendColorValue = gl.getParameter(gl.BLEND_COLOR);
- console.info("blendColor --> getParameter: " + blendColorValue);
-
- var blendColorArr = new Float32Array([0, 0.5, 1, 1]);
-
- // expect(blendColorValue).assertEqual(blendColorArr);
-
- // 判断数据类型是否正确
- expect(blendColorValue.constructor).assertEqual(blendColorArr.constructor);
- // 判断数据值是否正确
- expect(blendColorValue.toString()).assertEqual(blendColorArr.toString());
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0016
- * @tc.name webgl_test_blendColor_1
- * @tc.desc Test blendColor.
- */
- it('webgl_test_blendColor_1', 0, async function(done) {
- //initContext();
- console.info("webgltest into blendColor");
-
- gl.blendColor(1, 1, 1, 1);
- const blendColorValue = gl.getParameter(gl.BLEND_COLOR);
- console.info("blendColor --> getParameter: " + blendColorValue);
-
- var blendColorArr = new Float32Array([1, 1, 1, 1]);
-
- // expect(blendColorValue).assertEqual(blendColorArr);
-
- // 判断数据类型是否正确
- expect(blendColorValue.constructor).assertEqual(blendColorArr.constructor);
- // 判断数据值是否正确
- expect(blendColorValue.toString()).assertEqual(blendColorArr.toString());
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0017
- * @tc.name webgl_test_blendEquation
- * @tc.desc Test blendEquation.
- */
- it('webgl_test_blendEquation', 0, async function(done) {
- //initContext();
- console.info("webgltest into blendEquation");
-
- gl.blendEquation(gl.FUNC_ADD);
-
- const blendEquationValue = gl.getParameter(gl.BLEND_EQUATION_RGB);
- console.info("blendEquation --> getParameter: " + blendEquationValue);
- expect(blendEquationValue).assertEqual(gl.FUNC_ADD);
-
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0018
- * @tc.name webgl_test_blendEquation_1
- * @tc.desc Test blendEquation.
- */
- it('webgl_test_blendEquation_1', 0, async function(done) {
- //initContext();
- console.info("webgltest into blendEquation");
-
- gl.blendEquation(gl.FUNC_ADD);
-
- const blendEquationValue2 = gl.getParameter(gl.BLEND_EQUATION_ALPHA);
- console.info("blendEquation --> getParameter: " + blendEquationValue2);
- expect(blendEquationValue2).assertEqual(32774);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0019
- * @tc.name webgl_test_blendEquationSeparate
- * @tc.desc Test blendEquationSeparate.
- */
- it('webgl_test_blendEquationSeparate', 0, async function(done) {
- //initContext();
- console.info("webgltest into blendEquationSeparate");
- gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_SUBTRACT);
-
- const blendEquationSeparateValue = gl.getParameter(gl.BLEND_EQUATION_RGB);
- console.info("blendEquation --> getParameter: " + blendEquationSeparateValue);
- expect(blendEquationSeparateValue).assertEqual(gl.FUNC_ADD);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0020
- * @tc.name webgl_test_blendFunc
- * @tc.desc Test blendFunc.
- */
- it('webgl_test_blendFunc', 0, async function(done) {
- //initContext();
- console.info("webgltest into blendFunc");
-
- gl.enable(gl.BLEND);
-
- gl.blendFunc(gl.SRC_COLOR, gl.DST_COLOR);
-
- const blendFuncValue = gl.getParameter(gl.BLEND_SRC_RGB);
- console.info("blendFunc --> getParameter: " + blendFuncValue);
- expect(blendFuncValue).assertEqual(gl.SRC_COLOR);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0021
- * @tc.name webgl_test_blendFuncSeparate
- * @tc.desc Test blendFuncSeparate.
- */
- it('webgl_test_blendFuncSeparate', 0, async function(done) {
- //initContext();
- console.info("webgltest into blendFuncSeparate");
-
- gl.enable(gl.BLEND);
-
- gl.blendFuncSeparate(gl.SRC_COLOR, gl.DST_COLOR, gl.ONE, gl.ZERO);
-
- const blendFuncSeparateParameter = gl.getParameter(gl.BLEND_SRC_RGB)
- console.info("blendFuncSeparate --> getParameter: " + blendFuncSeparateParameter);
- expect(blendFuncSeparateParameter).assertEqual(gl.SRC_COLOR);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0022
- * @tc.name webgl_test_checkFramebufferStatus2
- * @tc.desc Test checkFramebufferStatus.
- */
- it('webgl_test_checkFramebufferStatus2', 0, async function(done) {
- //initContext();
- console.info("webgltest into checkFramebufferStatus");
-
- var framebuffer = gl.createFramebuffer();
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
-
- const checkFramebufferStatus = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
- console.info("createFramebuffer --> bindFramebuffer --> checkFramebufferStatus: " +
- checkFramebufferStatus);
- expect(checkFramebufferStatus).assertEqual(gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0023
- * @tc.name webgl_test_checkFramebufferStatus_1
- * @tc.desc Test checkFramebufferStatus.
- */
- it('webgl_test_checkFramebufferStatus_1', 0, async function(done) {
- //initContext();
- console.info("webgltest into checkFramebufferStatus");
-
- var framebuffer = gl.createFramebuffer();
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
-
- gl.deleteFramebuffer(framebuffer);
-
- const checkFrameBufferStatus2 = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
- console.info(
- "createFramebuffer --> bindFramebuffer --> deleteFramebuffer --> checkFrameBufferStatus2: " +
- checkFrameBufferStatus2);
- expect(checkFrameBufferStatus2).assertEqual(gl.FRAMEBUFFER_COMPLETE);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0024
- * @tc.name webgl_test_clear
- * @tc.desc Test clear.
- */
- it('webgl_test_clear', 0, async function(done) {
- //initContext();
- console.info("webgltest into clear");
- gl.clear(gl.COLOR_BUFFER_BIT);
- var float32Array = new Float32Array([0, 0, 0, 0]);
- const clearParameter = gl.getParameter(gl.COLOR_CLEAR_VALUE);
- console.info("webgltest clear getParameter: " + clearParameter);
- expect(typeof(clearParameter)).assertEqual(typeof(float32Array));
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0025
- * @tc.name webgl_test_clearColor
- * @tc.desc Test clearColor.
- */
- it('webgl_test_clearColor', 0, async function(done) {
- //initContext();
- console.info("webgltest into clearColor");
- gl.clearColor(1, 0.5, 0.5, 3);
-
- const clearColorParameter = gl.getParameter(gl.COLOR_CLEAR_VALUE);
-
- var float32ArrayValue = new Float32Array([1, 0.5, 0.5, 3]);
-
- console.info("webgltest clearColor: " + clearColorParameter);
- expect(clearColorParameter.toString()).assertEqual(float32ArrayValue.toString());
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0026
- * @tc.name webgl_test_clearDepth
- * @tc.desc Test clearDepth.
- */
- it('webgl_test_clearDepth', 0, async function(done) {
- //initContext();
- console.info("webgltest into clearDepth");
-
- //用于设置深度缓冲区的深度清除值。
- gl.clearDepth(0.5);
- //若要获取当前深度清除值,查询DEPTH_CLEAR_VALUE 常量。
- const clearDepthValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE);
- // 0.5
- console.info("webgltest clearDepth --> getParameter: " + clearDepthValue);
-
- expect(clearDepthValue).assertEqual(0.5);
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0027
- * @tc.name webgl_test_clearDepth_2
- * @tc.desc Test clearDepth.
- */
- it('webgl_test_clearDepth_2', 0, async function(done) {
- //initContext();
- console.info("webgltest into clearDepth");
-
- //用于设置深度缓冲区的深度清除值。
- gl.clearDepth(8);
- //若要获取当前深度清除值,查询DEPTH_CLEAR_VALUE 常量。
- const clearDepthValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE);
- // 0.5
- console.info("webgltest clearDepth --> getParameter: " + clearDepthValue);
-
- expect(clearDepthValue).assertEqual(1);
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0028
- * @tc.name webgl_test_clearStencil
- * @tc.desc Test clearStencil.
- */
- it('webgl_test_clearStencil', 0, async function(done) {
- //initContext();
- console.info("webgltest into clearStencil");
-
- gl.clearStencil(1);
- //要获取当前模板清除值,请查询STENCIL_CLEAR_VALUE 常量。
- const clearStencilValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE);
- console.info("webgltest clearStencil --> getParameter: " + clearStencilValue);
- expect(clearStencilValue).assertEqual(1);
-
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0029
- * @tc.name webgl_test_clearStencil_1
- * @tc.desc Test clearStencil.
- */
- it('webgl_test_clearStencil_1', 0, async function(done) {
- //initContext();
- console.info("webgltest into clearStencil");
-
- gl.clearStencil(20);
- //要获取当前模板清除值,请查询STENCIL_CLEAR_VALUE 常量。
- const clearStencilValue = gl.getParameter(gl.STENCIL_CLEAR_VALUE);
- console.info("webgltest clearStencil --> getParameter: " + clearStencilValue);
- expect(clearStencilValue).assertEqual(20);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0030
- * @tc.name webgl_test_colorMask
- * @tc.desc Test colorMask.
- */
- it('webgl_test_colorMask', 0, async function(done) {
- //initContext();
- console.info("webgltest into colorMask");
-
- gl.colorMask(true, true, true, false);
- // 要获取当前的颜色掩码,请查询COLOR_WRITEMASK返回Array.
- const colorMaskValue = gl.getParameter(gl.COLOR_WRITEMASK);
- // [true, true, true, false]
- console.info("webgltest colorMask --> getParameter: " + colorMaskValue);
-
- expect(colorMaskValue.toString()).assertEqual('true,true,true,false');
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0031
- * @tc.name webgl_test_colorMask_1
- * @tc.desc Test colorMask.
- */
- it('webgl_test_colorMask_1', 0, async function(done) {
- //initContext();
- console.info("webgltest into colorMask");
-
- gl.colorMask(false, false, false, false);
- // 要获取当前的颜色掩码,请查询COLOR_WRITEMASK返回Array.
- const colorMaskValue = gl.getParameter(gl.COLOR_WRITEMASK);
- // [true, true, true, false]
- console.info("webgltest colorMask --> getParameter: " + colorMaskValue);
-
- expect(colorMaskValue.toString()).assertEqual('false,false,false,false');
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0032
- * @tc.name webgl_test_compileShader
- * @tc.desc Test compileShader.
- */
- it('webgl_test_compileShader', 0, async function(done) {
- //initContext();
- console.info("webgltest into compileShader");
-
- var shader = gl.createShader(gl.VERTEX_SHADER);
- gl.shaderSource(shader, VSHADER_SOURCE);
- gl.compileShader(shader);
-
- let errorCode = gl.getError();
- console.info("webgltest compileShader getError: " + errorCode);
- expect(errorCode).assertEqual(gl.NO_ERROR);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0033
- * @tc.name webgl_test_copyTexImage2D
- * @tc.desc Test copyTexImage2D.
- */
- it('webgl_test_copyTexImage2D', 0, async function(done) {
- //initContext();
- console.info("webgltest into copyTexImage2D");
- gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 512, 512, 0);
- let errorCode = gl.getError();
- console.info("webgltest copyTexImage2D getError: " + errorCode);
- expect(errorCode).assertEqual(gl.NO_ERROR);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0034
- * @tc.name webgl_test_copyTexImage2D
- * @tc.desc Test copyTexImage2D.
- */
- it('webgl_test_copyTexImage2D', 0, async function(done) {
- //initContext();
- console.info("webgltest into copyTexImage2D");
- gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, '512', 512, 0);
- let errorCode = gl.getError();
- console.info("webgltest copyTexImage2D getError: " + errorCode);
- expect(errorCode).assertEqual(gl.NO_ERROR);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0035
- * @tc.name webgl_test_copyTexSubImage2D
- * @tc.desc Test copyTexSubImage2D.
- */
- it('webgl_test_copyTexSubImage2D', 0, async function(done) {
- //initContext();
- console.info("webgltest into copyTexSubImage2D");
-
- gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 16, 16);
- let errorCode = gl.getError();
- console.info("webgltest copyTexSubImage2D getError: " + errorCode);
- expect(errorCode).assertEqual(gl.NO_ERROR);
-
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0036
- * @tc.name webgl_test_copyTexSubImage2D_1
- * @tc.desc Test copyTexSubImage2D.
- */
- it('webgl_test_copyTexSubImage2D_1', 0, async function(done) {
- //initContext();
- console.info("webgltest into copyTexSubImage2D");
-
- gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, false, 16);
- let errorCode = gl.getError();
- console.info("webgltest copyTexSubImage2D getError: " + errorCode);
- expect(errorCode).assertEqual(gl.NO_ERROR);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0037
- * @tc.name webgl_test_createBuffer
- * @tc.desc Test createBuffer.
- */
- it('webgl_test_createBuffer', 0, async function(done) {
- //initContext();
- console.info("webgltest into createBuffer");
-
- const buffer = gl.createBuffer();
-
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
- const isBufferValue = gl.isBuffer(buffer);
- console.info("isBufferValue: " + isBufferValue);
-
- console.info("webgltest createBuffer bindBuffer isBuffer: " + isBufferValue);
- expect(isBufferValue).assertEqual(true);
-
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0038
- * @tc.name webgl_test_createBuffer_1
- * @tc.desc Test createBuffer.
- */
- it('webgl_test_createBuffer_1', 0, async function(done) {
- //initContext();
- console.info("webgltest into createBuffer");
-
- const buffer = gl.createBuffer();
-
- const isBufferValue = gl.isBuffer(buffer);
- console.info("isBufferValue: " + isBufferValue);
-
- console.info("webgltest createBuffer bindBuffer isBuffer: " + isBufferValue);
- expect(isBufferValue).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0039
- * @tc.name webgl_test_createFramebuffer
- * @tc.desc Test createFramebuffer.
- */
- it('webgl_test_createFramebuffer', 0, async function(done) {
- //initContext();
- console.info("webgltest into createFramebuffer");
-
- const framebuffer = gl.createFramebuffer();
-
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
- const isFramebuffer = gl.isFramebuffer(framebuffer);
- console.info("webgltest createFramebuffer --> bindFramebuffer --> isFramebuffer: " +
- isFramebuffer);
- expect(isFramebuffer).assertEqual(true);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0040
- * @tc.name webgl_test_createFramebuffer_1
- * @tc.desc Test createFramebuffer.
- */
- it('webgl_test_createFramebuffer_1', 0, async function(done) {
- //initContext();
- console.info("webgltest into createFramebuffer");
-
- const framebuffer = gl.createFramebuffer();
-
- const isFramebuffer = gl.isFramebuffer(framebuffer);
- console.info("webgltest createFramebuffer --> bindFramebuffer --> isFramebuffer: " +
- isFramebuffer);
- expect(isFramebuffer).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0041
- * @tc.name webgl_test_createProgram
- * @tc.desc Test createProgram.
- */
- it('webgl_test_createProgram', 0, async function(done) {
- //initContext();
- console.info("webgltest into createProgram");
- const program = gl.createProgram();
- const isProgram = gl.isProgram(program);
- console.info("webgltest createProgram isProgram: " + isProgram);
- expect(isProgram).assertEqual(true);
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0042
- * @tc.name webgl_test_createRenderbuffer
- * @tc.desc Test createRenderbuffer.
- */
- it('webgl_test_createRenderbuffer', 0, async function(done) {
- //initContext();
- console.info("webgltest into createRenderbuffer");
-
- const renderbuffer = gl.createRenderbuffer();
- gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
- const isRenderBuffer = gl.isRenderbuffer(renderbuffer);
- console.info(
- "createRenderbuffer --> bindRenderbuffer --> getParameter --> isRenderbuffer: " +
- isRenderBuffer);
- expect(isRenderBuffer).assertEqual(true);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0043
- * @tc.name webgl_test_createRenderbuffer_1
- * @tc.desc Test createRenderbuffer.
- */
- it('webgl_test_createRenderbuffer_1', 0, async function(done) {
- //initContext();
- console.info("webgltest into createRenderbuffer");
-
- const renderbuffer = gl.createRenderbuffer();
- const isRenderBuffer = gl.isRenderbuffer(renderbuffer);
- console.info(
- "createRenderbuffer --> bindRenderbuffer --> getParameter --> isRenderbuffer: " +
- isRenderBuffer);
- expect(isRenderBuffer).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0044
- * @tc.name webgl_test_createShader
- * @tc.desc Test createShader.
- */
- it('webgl_test_createShader', 0, async function(done) {
- //initContext();
- console.info("webgltest into createShader");
-
- const shader = gl.createShader(gl.VERTEX_SHADER);
- const isShader = gl.isShader(shader);
- console.info("webgltest createShader isShader: " + isShader);
- expect(isShader).assertEqual(true);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0045
- * @tc.name webgl_test_createTexture
- * @tc.desc Test createTexture.
- */
- it('webgl_test_createTexture', 0, async function(done) {
- //initContext();
- console.info("webgltest into createTexture");
-
- const texture = gl.createTexture();
- gl.bindTexture(gl.TEXTURE_2D, texture);
- const isTexture = gl.isTexture(texture);
- console.info("webgltest createTexture isTexture: " + isTexture);
- expect(isTexture).assertEqual(true);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0046
- * @tc.name webgl_test_createTexture_1
- * @tc.desc Test createTexture.
- */
- it('webgl_test_createTexture_1', 0, async function(done) {
- //initContext();
- console.info("webgltest into createTexture");
-
- const texture = gl.createTexture();
- const isTexture = gl.isTexture(texture);
- console.info("webgltest createTexture isTexture: " + isTexture);
- expect(isTexture).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0047
- * @tc.name webgl_test_cullFace
- * @tc.desc Test cullFace.
- */
- it('webgl_test_cullFace', 0, async function(done) {
- //initContext();
- console.info("webgltest into cullFace");
-
- gl.enable(gl.CULL_FACE);
- gl.cullFace(gl.FRONT_AND_BACK);
- // 需要 CULL_FACE_MODE 常量来检查当前多边形剔除模式。
- const cullFaceparameter = gl.getParameter(gl.CULL_FACE_MODE)
- console.info("cullFace --> getParameter: " + cullFaceparameter);
- expect(cullFaceparameter).assertEqual(gl.FRONT_AND_BACK);
-
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0048
- * @tc.name webgl_test_cullFace_2
- * @tc.desc Test cullFace.
- */
- it('webgl_test_cullFace_2', 0, async function(done) {
- //initContext();
- console.info("webgltest into cullFace");
-
- gl.enable(gl.CULL_FACE);
- gl.cullFace(gl.FRONT);
- // 需要 CULL_FACE_MODE 常量来检查当前多边形剔除模式。
- const cullFaceparameter = gl.getParameter(gl.CULL_FACE_MODE)
- console.info("cullFace --> getParameter: " + cullFaceparameter);
- expect(cullFaceparameter).assertEqual(gl.FRONT);
-
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0049
- * @tc.name webgl_test_cullFace_3
- * @tc.desc Test cullFace.
- */
- it('webgl_test_cullFace_3', 0, async function(done) {
- //initContext();
- console.info("webgltest into cullFace");
-
- gl.enable(gl.CULL_FACE);
- gl.cullFace(gl.BACK);
- // 需要 CULL_FACE_MODE 常量来检查当前多边形剔除模式。
- const cullFaceparameter = gl.getParameter(gl.CULL_FACE_MODE)
- console.info("cullFace --> getParameter: " + cullFaceparameter);
- expect(cullFaceparameter).assertEqual(gl.BACK);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0050
- * @tc.name webgl_test_deleteBuffer
- * @tc.desc Test deleteBuffer.
- */
- it('webgl_test_deleteBuffer', 0, async function(done) {
- //initContext();
- console.info("webgltest into deleteBuffer");
-
- var buffer = gl.createBuffer();
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
- const isBuffer1 = gl.isBuffer(buffer);
- console.info("webgltest createBuffer bindBuffer isBuffer1: " + isBuffer1);
- expect(isBuffer1).assertEqual(true);
-
- gl.deleteBuffer(buffer);
- const isBuffer2 = gl.isBuffer(buffer);
- console.info("webgltest createBuffer bindBuffer deleteBuffer isBuffer2: " + isBuffer2);
- expect(isBuffer2).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0051
- * @tc.name webgl_test_deleteBuffer_2
- * @tc.desc Test deleteBuffer.
- */
- it('webgl_test_deleteBuffer_2', 0, async function(done) {
- //initContext();
- console.info("webgltest into deleteBuffer");
-
- var buffer = gl.createBuffer();
-
- const isBuffer1 = gl.isBuffer(buffer);
- console.info("webgltest createBuffer bindBuffer isBuffer1: " + isBuffer1);
- expect(isBuffer1).assertEqual(false);
-
- gl.deleteBuffer(buffer);
- const isBuffer2 = gl.isBuffer(buffer);
- console.info("webgltest createBuffer bindBuffer deleteBuffer isBuffer2: " + isBuffer2);
- expect(isBuffer2).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0052
- * @tc.name webgl_test_deleteFramebuffer
- * @tc.desc Test deleteFramebuffer.
- */
- it('webgl_test_deleteFramebuffer', 0, async function(done) {
- //initContext();
- console.info("webgltest into deleteFramebuffer");
-
- var framebuffer = gl.createFramebuffer();
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
-
- const isFramebuffer1 = gl.isFramebuffer(framebuffer);
- console.info("webgltest createFramebuffer bindFramebuffer isFramebuffer1: " +
- isFramebuffer1);
- expect(isFramebuffer1).assertEqual(true);
-
- gl.deleteFramebuffer(framebuffer);
-
- const isFramebuffer2 = gl.isFramebuffer(framebuffer);
- console.info("webgltest createFramebuffer bindFramebuffer isFramebuffer2: " +
- isFramebuffer2);
- expect(isFramebuffer2).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0053
- * @tc.name webgl_test_deleteProgram
- * @tc.desc Test deleteProgram.
- */
- it('webgl_test_deleteProgram', 0, async function(done) {
- //initContext();
- console.info("webgltest into deleteProgram");
-
- const program = gl.createProgram();
- const isProgram1 = gl.isProgram(program);
- console.info("webgltest createProgram isProgram1: " + isProgram1);
- expect(isProgram1).assertEqual(true);
-
- gl.deleteProgram(program);
- const isProgram2 = gl.isProgram(program);
- console.info("webgltest getExtension: " + isProgram2);
- expect(isProgram2).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0054
- * @tc.name webgl_test_deleteProgram_2
- * @tc.desc Test deleteProgram.
- */
- it('webgl_test_deleteProgram_2', 0, async function(done) {
- //initContext();
- console.info("webgltest into deleteProgram");
-
- const program = gl.createProgram();
-
- gl.deleteProgram(program);
- const isProgram2 = gl.isProgram(program);
- console.info("webgltest getExtension: " + isProgram2);
- expect(isProgram2).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0055
- * @tc.name webgl_test_deleteRenderbuffer
- * @tc.desc Test deleteRenderbuffer.
- */
- it('webgl_test_deleteRenderbuffer', 0, async function(done) {
- //initContext();
- console.info("webgltest into deleteRenderbuffer");
-
- const renderbuffer = gl.createRenderbuffer();
- gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
- const isRenderbuffer1 = gl.isRenderbuffer(renderbuffer);
- console.info("webgltest createRenderbuffer bindRenderbuffer isRenderbuffer1: " +
- isRenderbuffer1);
- expect(isRenderbuffer1).assertEqual(true);
-
- gl.deleteRenderbuffer(renderbuffer);
-
- const isRenderbuffer2 = gl.isRenderbuffer(renderbuffer);
- console.info(
- "webgltest createRenderbuffer bindRenderbuffer deleteRenderbuffer isRenderbuffer2: " +
- isRenderbuffer2);
- expect(isRenderbuffer2).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0056
- * @tc.name webgl_test_deleteShader
- * @tc.desc Test deleteShader.
- */
- it('webgl_test_deleteShader', 0, async function(done) {
- //initContext();
- console.info("webgltest into deleteShader");
-
- var shader = gl.createShader(gl.VERTEX_SHADER);
- const isShader1 = gl.isShader(shader);
- console.info("webgltest createShader isShader: " + isShader1);
- expect(isShader1).assertEqual(true);
-
- gl.deleteShader(shader);
-
- const isShader2 = gl.isShader(shader);
- console.info("webgltest createShader deleteShader isShader2: " + isShader2);
- expect(isShader2).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0057
- * @tc.name webgl_test_deleteShader_2
- * @tc.desc Test deleteShader.
- */
- it('webgl_test_deleteShader_2', 0, async function(done) {
- //initContext();
- console.info("webgltest into deleteShader");
-
- var shader = gl.createShader(gl.VERTEX_SHADER);
-
- gl.deleteShader(shader);
-
- const isShader2 = gl.isShader(shader);
- console.info("webgltest createShader deleteShader isShader2: " + isShader2);
- expect(isShader2).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0058
- * @tc.name webgl_test_deleteTexture
- * @tc.desc Test deleteTexture.
- */
- it('webgl_test_deleteTexture', 0, async function(done) {
- //initContext();
- console.info("webgltest into deleteTexture");
-
- var texture = gl.createTexture();
- gl.bindTexture(gl.TEXTURE_2D, texture);
- const isTexture1 = gl.isTexture(texture);
- console.info("webgltest createTexture isTexture: " + isTexture1);
- expect(isTexture1).assertEqual(true);
-
- gl.deleteTexture(texture);
-
- const isTexture2 = gl.isTexture(texture);
- console.info("webgltest createTexture deleteTexture isTexture2: " + isTexture2);
- expect(isTexture2).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0059
- * @tc.name webgl_test_deleteTexture_2
- * @tc.desc Test deleteTexture.
- */
- it('webgl_test_deleteTexture_2', 0, async function(done) {
- //initContext();
- console.info("webgltest into deleteTexture");
-
- var texture = gl.createTexture();
-
- const isTexture1 = gl.isTexture(texture);
- console.info("webgltest createTexture isTexture: " + isTexture1);
- expect(isTexture1).assertEqual(false);
-
- gl.deleteTexture(texture);
-
- const isTexture2 = gl.isTexture(texture);
- console.info("webgltest createTexture deleteTexture isTexture2: " + isTexture2);
- expect(isTexture2).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0060
- * @tc.name webgl_test_depthFunc
- * @tc.desc Test depthFunc.
- */
- it('webgl_test_depthFunc', 0, async function(done) {
- //initContext();
- console.info("webgltest into depthFunc");
-
- gl.enable(gl.DEPTH_TEST);
- gl.depthFunc(gl.NEVER);
- // 要检查当前深度函数,请查询DEPTH_FUNC常量。
- const depthParameter = gl.getParameter(gl.DEPTH_FUNC);
- console.info("depthFunc --> getParameter: " + depthParameter);
- expect(depthParameter).assertEqual(gl.NEVER);
-
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0061
- * @tc.name webgl_test_depthFunc_2
- * @tc.desc Test depthFunc.
- */
- it('webgl_test_depthFunc_2', 0, async function(done) {
- //initContext();
- console.info("webgltest into depthFunc");
-
- gl.enable(gl.DEPTH_TEST);
- gl.depthFunc(gl.LESS);
- // 要检查当前深度函数,请查询DEPTH_FUNC常量。
- const depthParameter = gl.getParameter(gl.DEPTH_FUNC);
- console.info("depthFunc --> getParameter: " + depthParameter);
- expect(depthParameter).assertEqual(gl.LESS);
-
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0062
- * @tc.name webgl_test_depthFunc_3
- * @tc.desc Test depthFunc.
- */
- it('webgl_test_depthFunc_3', 0, async function(done) {
- //initContext();
- console.info("webgltest into depthFunc");
-
- gl.enable(gl.DEPTH_TEST);
- gl.depthFunc(gl.EQUAL);
- // 要检查当前深度函数,请查询DEPTH_FUNC常量。
- const depthParameter = gl.getParameter(gl.DEPTH_FUNC);
- console.info("depthFunc --> getParameter: " + depthParameter);
- expect(depthParameter).assertEqual(gl.EQUAL);
-
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0063
- * @tc.name webgl_test_depthFunc_4
- * @tc.desc Test depthFunc.
- */
- it('webgl_test_depthFunc_4', 0, async function(done) {
- //initContext();
- console.info("webgltest into depthFunc");
-
- gl.enable(gl.DEPTH_TEST);
- gl.depthFunc(gl.LEQUAL);
- // 要检查当前深度函数,请查询DEPTH_FUNC常量。
- const depthParameter = gl.getParameter(gl.DEPTH_FUNC);
- console.info("depthFunc --> getParameter: " + depthParameter);
- expect(depthParameter).assertEqual(gl.LEQUAL);
-
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0064
- * @tc.name webgl_test_depthFunc_5
- * @tc.desc Test depthFunc.
- */
- it('webgl_test_depthFunc_5', 0, async function(done) {
- //initContext();
- console.info("webgltest into depthFunc");
-
- gl.enable(gl.DEPTH_TEST);
- gl.depthFunc(gl.GREATER);
- // 要检查当前深度函数,请查询DEPTH_FUNC常量。
- const depthParameter = gl.getParameter(gl.DEPTH_FUNC);
- console.info("depthFunc --> getParameter: " + depthParameter);
- expect(depthParameter).assertEqual(gl.GREATER);
-
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0065
- * @tc.name webgl_test_depthFunc_6
- * @tc.desc Test depthFunc.
- */
- it('webgl_test_depthFunc_6', 0, async function(done) {
- //initContext();
- console.info("webgltest into depthFunc");
-
- gl.enable(gl.DEPTH_TEST);
- gl.depthFunc(gl.NOTEQUAL);
- // 要检查当前深度函数,请查询DEPTH_FUNC常量。
- const depthParameter = gl.getParameter(gl.DEPTH_FUNC);
- console.info("depthFunc --> getParameter: " + depthParameter);
- expect(depthParameter).assertEqual(gl.NOTEQUAL);
-
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0066
- * @tc.name webgl_test_depthFunc_7
- * @tc.desc Test depthFunc.
- */
- it('webgl_test_depthFunc_7', 0, async function(done) {
- //initContext();
- console.info("webgltest into depthFunc");
-
- gl.enable(gl.DEPTH_TEST);
- gl.depthFunc(gl.GEQUAL);
- // 要检查当前深度函数,请查询DEPTH_FUNC常量。
- const depthParameter = gl.getParameter(gl.DEPTH_FUNC);
- console.info("depthFunc --> getParameter: " + depthParameter);
- expect(depthParameter).assertEqual(gl.GEQUAL);
-
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0067
- * @tc.name webgl_test_depthFunc_8
- * @tc.desc Test depthFunc.
- */
- it('webgl_test_depthFunc_8', 0, async function(done) {
- //initContext();
- console.info("webgltest into depthFunc");
-
- gl.enable(gl.DEPTH_TEST);
- gl.depthFunc(gl.ALWAYS);
- // 要检查当前深度函数,请查询DEPTH_FUNC常量。
- const depthParameter = gl.getParameter(gl.DEPTH_FUNC);
- console.info("depthFunc --> getParameter: " + depthParameter);
- expect(depthParameter).assertEqual(gl.ALWAYS);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0068
- * @tc.name webgl_test_depthMask
- * @tc.desc Test depthMask.
- */
- it('webgl_test_depthMask', 0, async function(done) {
- //initContext();
- console.info("webgltest into depthMask");
-
- gl.depthMask(false);
- // 要获得当前的深度遮罩值,传入 DEPTH_WRITEMASK 常量,返回 Boolean.
- const depthMaskValue = gl.getParameter(gl.DEPTH_WRITEMASK);
- // false
- console.info("webgltest depthMaskValue: " + depthMaskValue);
- expect(depthMaskValue).assertEqual(false);
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0069
- * @tc.name webgl_test_depthMask_2
- * @tc.desc Test depthMask.
- */
- it('webgl_test_depthMask_2', 0, async function(done) {
- //initContext();
- console.info("webgltest into depthMask");
-
- gl.depthMask(true);
- // 要获得当前的深度遮罩值,传入 DEPTH_WRITEMASK 常量,返回 Boolean.
- const depthMaskValue = gl.getParameter(gl.DEPTH_WRITEMASK);
- // false
- console.info("webgltest depthMaskValue: " + depthMaskValue);
- expect(depthMaskValue).assertEqual(true);
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0070
- * @tc.name webgl_test_depthRange
- * @tc.desc Test depthRange.
- */
- it('webgl_test_depthRange', 0, async function(done) {
- //initContext();
- console.info("webgltest into depthRange");
-
- gl.depthRange(0.2, 0.6);
- // 要检查当前深度范围,请查询DEPTH_RANGE返回一个的常量Float32Array
- const depthRangeValue = gl.getParameter(gl.DEPTH_RANGE);
- // Float32Array[0.2, 0.6]
- const float32ArrayValue = new Float32Array([0.2, 0.6]);
- console.info("webgltest depthRange: " + depthRangeValue);
- expect(depthRangeValue.toString()).assertEqual(float32ArrayValue.toString());
- //deleteContext();
- done();
- });
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0071
- * @tc.name webgl_test_depthRange_2
- * @tc.desc Test depthRange.
- */
- it('webgl_test_depthRange_2', 0, async function(done) {
- //initContext();
- console.info("webgltest into depthRange");
-
- gl.depthRange(0.8, 1.0);
- // 要检查当前深度范围,请查询DEPTH_RANGE返回一个的常量Float32Array
- const depthRangeValue = gl.getParameter(gl.DEPTH_RANGE);
- // Float32Array[0.2, 0.6]
- const float32ArrayValue = new Float32Array([0.8, 1.0]);
- console.info("webgltest depthRange: " + depthRangeValue);
- expect(depthRangeValue.toString()).assertEqual(float32ArrayValue.toString());
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0072
- * @tc.name webgl_test_detachShader
- * @tc.desc Test detachShader.
- */
- it('webgl_test_detachShader', 0, async function(done) {
- //initContext();
- console.info("webgltest into detachShader");
-
- //顶点着色器
- var vertexShader = gl.createShader(gl.VERTEX_SHADER);
- gl.shaderSource(vertexShader, VSHADER_SOURCE);
- gl.compileShader(vertexShader);
- //片元着色器
- var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); //创建 WebGLShader。
- gl.shaderSource(fragmentShader, FSHADER_SOURCE); //fragmentSrc设置一个 WebGLShader 的源码。
- gl.compileShader(fragmentShader);
-
- //WebGLProgram
- var program = gl.createProgram(); //创建 WebGLProgram
- gl.attachShader(program, vertexShader); //往 WebGLProgram 添加一个片段或者顶点着色器。
- gl.attachShader(program, fragmentShader);
- gl.linkProgram(program); //链接给入的 WebGLProgram 对象
- gl.detachShader(program, vertexShader); //从一个WebGLProgram中分离一个先前附加的片段或者顶点着色器;
- gl.detachShader(program, fragmentShader);
- gl.deleteShader(vertexShader);
- gl.deleteShader(fragmentShader);
-
- let errorCode = gl.getError();
- console.info("webgltest uniform3uiv getError: " + errorCode);
- expect(errorCode).assertEqual(gl.NO_ERROR);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0073
- * @tc.name webgl_test_disable
- * @tc.desc Test disable.
- */
- it('webgl_test_disable', 0, async function(done) {
- //initContext();
- console.info("webgltest into disable");
-
- gl.disable(gl.DITHER);
- // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法:
- const isEnabled = gl.isEnabled(gl.DITHER);
- // false
- console.info("webgltest disable isEnabled: " + isEnabled);
- expect(isEnabled).assertEqual(false);
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0074
- * @tc.name webgl_test_disable_2
- * @tc.desc Test disable.
- */
- it('webgl_test_disable_2', 0, async function(done) {
- //initContext();
- console.info("webgltest into disable");
- gl.enable(gl.DITHER);
- const isEnabled2 = gl.isEnabled(gl.DITHER);
- // true
- console.info("webgltest disable isEnabled2: " + isEnabled2);
- expect(isEnabled2).assertEqual(true);
-
- gl.disable(gl.DITHER);
- // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法:
- const isEnabled = gl.isEnabled(gl.DITHER);
- // false
- console.info("webgltest disable isEnabled: " + isEnabled);
- expect(isEnabled).assertEqual(false);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0075
- * @tc.name webgl_test_disableVertexAttribArray
- * @tc.desc Test disableVertexAttribArray.
- */
- it('webgl_test_disableVertexAttribArray', 0, async function(done) {
- //initContext();
- console.info("webgltest into disableVertexAttribArray");
- gl.disableVertexAttribArray(0);
- let errorCode = gl.getError();
- console.info("webgltest disableVertexAttribArray getError: " + errorCode);
- expect(errorCode).assertEqual(gl.NO_ERROR);
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0076
- * @tc.name webgl_test_drawArrays
- * @tc.desc Test drawArrays.
- */
- it('webgl_test_drawArrays', 0, async function(done) {
- //initContext();
- console.info("webgltest into drawArrays");
-
- gl.drawArrays(gl.POINTS, 0, 8);
- let errorCode = gl.getError();
- console.info("webgltest drawArrays getError: " + errorCode);
- expect(errorCode).assertEqual(gl.NO_ERROR);
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0077
- * @tc.name webgl_test_drawArrays_2
- * @tc.desc Test drawArrays.
- */
- it('webgl_test_drawArrays_2', 0, async function(done) {
- //initContext();
- console.info("webgltest into drawArrays");
-
- gl.drawArrays(gl.POINTS, 0, -8);
- let errorCode = gl.getError();
- console.info("webgltest drawArrays getError: " + errorCode);
- expect(errorCode).assertEqual(1281);
-
- //deleteContext();
- done();
- });
-
-
- /**
- * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0078
- * @tc.name webgl_test_drawElements
- * @tc.desc Test drawElements.
- */
- it('webgl_test_drawElements', 0, async function(done) {
- //initContext();
- console.info("webgltest into drawElements");
-
-
- // 初始化着色器
- if (!initShaders(gl, VSHADER_SOURCE, FSHADER_SOURCE)) {
- console.log('Failed to intialize shaders.');
- return;
- }
-
- // 设置顶点位置
- var n = initVertexBuffers(gl);
- if (n < 0) {
- console.log('Failed to set the positions of the vertices');
- return;
- }
-
- var maxViewPortDimsParameter = gl.getParameter(gl.MAX_VIEWPORT_DIMS);
- console.log('maxViewPortDimsParameter: ' + maxViewPortDimsParameter);
- var viewPortParameter = gl.getParameter(gl.VIEWPORT);
- console.log('viewPortParameter: ' + viewPortParameter);
- var boolParameter = gl.getParameter(gl.BOOL);
- console.log('boolParameter: ' + boolParameter);
- var SamplerCubeParameter = gl.getParameter(gl.SAMPLER_CUBE);
- console.log('SamplerCubeParameter: ' + SamplerCubeParameter);
-
- const isContextLostValue = gl.isContextLost();
- console.info("isContextLostValue: " + isContextLostValue);
-
- // 指定清空