diff --git a/OAT.xml b/OAT.xml index 671a4af15f4ef170b7d994cbafa1774fafb9f645..aea1722eef1fcd7940edda809bcb2991c0531096 100755 --- a/OAT.xml +++ b/OAT.xml @@ -57,6 +57,7 @@ Note:If the text contains special characters, please escape them according to th + diff --git a/ability/ability_runtime/aacommand/AACommand07/entry/src/main/module.json b/ability/ability_runtime/aacommand/AACommand07/entry/src/main/module.json index cc7238d29b20ea84bb5de27abed4fea6c92793cf..1ec4a4fe2f52a231148c339ffb364a2e79eb7951 100644 --- a/ability/ability_runtime/aacommand/AACommand07/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommand07/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/aacommand/AACommand08/entry/src/main/module.json b/ability/ability_runtime/aacommand/AACommand08/entry/src/main/module.json index cc7238d29b20ea84bb5de27abed4fea6c92793cf..1ec4a4fe2f52a231148c339ffb364a2e79eb7951 100644 --- a/ability/ability_runtime/aacommand/AACommand08/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommand08/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/module.json b/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/module.json index 7ac0abaddf4e2cfa0be1396c8b80a5c4f022174b..7c4559e5b69ae48fedccc3c1bd9814e0a86d0137 100644 --- a/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommandPrintOneTest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", @@ -33,6 +39,12 @@ } ] } + ], + "requestPermissions": [ + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } ] } } \ No newline at end of file diff --git a/ability/ability_runtime/aacommand/AACommandPrintOneTest/signature/openharmony_sx.p7b b/ability/ability_runtime/aacommand/AACommandPrintOneTest/signature/openharmony_sx.p7b index f60167a1bb6d93f4b3d751080729cfbb9f15a6c2..c101676c7342587316cf95c54f7821010813cf53 100644 Binary files a/ability/ability_runtime/aacommand/AACommandPrintOneTest/signature/openharmony_sx.p7b and b/ability/ability_runtime/aacommand/AACommandPrintOneTest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/module.json b/ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/module.json index 67d8175e38f1479169f73561c6b23f7f0e51c18a..0c4a8969c06d1981a69898b276e588c6e39c4ba3 100644 --- a/ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommandPrintSync/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/module.json b/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/module.json index 34441664894c5461c8ca036386e21a240b10711b..ffe8dbfaf560fb4ec9d7620f8e28159afa5957ab 100644 --- a/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommandPrintSyncTest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", @@ -33,6 +39,12 @@ } ] } + ], + "requestPermissions": [ + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } ] } } \ No newline at end of file diff --git a/ability/ability_runtime/aacommand/AACommandPrintSyncTest/signature/openharmony_sx.p7b b/ability/ability_runtime/aacommand/AACommandPrintSyncTest/signature/openharmony_sx.p7b index fc9ce82d092c3bdfa915a3983015cdda2d8f5a19..5ee7a823c71113fc4bf7cab109b3dd95938f1a6b 100644 Binary files a/ability/ability_runtime/aacommand/AACommandPrintSyncTest/signature/openharmony_sx.p7b and b/ability/ability_runtime/aacommand/AACommandPrintSyncTest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/module.json b/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/module.json index 67d8175e38f1479169f73561c6b23f7f0e51c18a..0c4a8969c06d1981a69898b276e588c6e39c4ba3 100644 --- a/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommandRelyHap/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/aacommand/AACommandpackage/entry/src/main/module.json b/ability/ability_runtime/aacommand/AACommandpackage/entry/src/main/module.json index 67d8175e38f1479169f73561c6b23f7f0e51c18a..0c4a8969c06d1981a69898b276e588c6e39c4ba3 100644 --- a/ability/ability_runtime/aacommand/AACommandpackage/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommandpackage/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/module.json b/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/module.json index 34441664894c5461c8ca036386e21a240b10711b..ffe8dbfaf560fb4ec9d7620f8e28159afa5957ab 100644 --- a/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/module.json +++ b/ability/ability_runtime/aacommand/AACommandtest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", @@ -33,6 +39,12 @@ } ] } + ], + "requestPermissions": [ + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } ] } } \ No newline at end of file diff --git a/ability/ability_runtime/aacommand/AACommandtest/signature/openharmony_sx.p7b b/ability/ability_runtime/aacommand/AACommandtest/signature/openharmony_sx.p7b index 536e69b7dffe31356ca7d67355d6d04fda5a017b..2aedc5788dc5cc8713ddc14825c3cfc1c2dcd10c 100644 Binary files a/ability/ability_runtime/aacommand/AACommandtest/signature/openharmony_sx.p7b and b/ability/ability_runtime/aacommand/AACommandtest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/abilitymontior/entry/src/main/module.json b/ability/ability_runtime/abilitymontior/entry/src/main/module.json index f6d605fcb9bc64a46f0efcf7ebc0281a09b92151..894080ab94fb3af4388b49495480392bdf285259 100644 --- a/ability/ability_runtime/abilitymontior/entry/src/main/module.json +++ b/ability/ability_runtime/abilitymontior/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", @@ -59,6 +65,12 @@ "visible": true, "launchType": "singleton" } + ], + "requestPermissions": [ + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } ] } } \ No newline at end of file diff --git a/ability/ability_runtime/abilitymontior/signature/openharmony_sx.p7b b/ability/ability_runtime/abilitymontior/signature/openharmony_sx.p7b index 134b5126c169e00da3d46076b70582bd3304e74b..1aef4da53ecc5a2919ecea9d1662cfb43253bba1 100644 Binary files a/ability/ability_runtime/abilitymontior/signature/openharmony_sx.p7b and b/ability/ability_runtime/abilitymontior/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/AppScope/app.json b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/AppScope/app.json index 6eeb4089825ed9a4142e37807015e693d983aa7c..0886fe44f7a27b290173f3f20180c3c00a3097a1 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/AppScope/app.json +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/AppScope/app.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.example.amsabilitymultiinstanceappa", + "bundleName": "com.acts.abilitymultiinstancea", "vendor": "huawei", "versionCode": 1000000, "versionName": "1.0.0", diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/MainAbility/MainAbility.ts index c37109ee5a17a92a787c1fea8b85ca77d370f7ed..c871366df6dc8fcbd26a9cc3dd2a495e7935b94c 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/MainAbility/MainAbility.ts @@ -22,8 +22,8 @@ function publishCallBack() { } async function startAbilityProcess(abilityContext, parameters) { - let bundleName = "com.example.amsabilitymultiinstanceappa"; - let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + let bundleName = "com.acts.abilitymultiinstancea"; + let abilityName = "com.acts.abilitymultiinstancea.MainAbility"; let idx = parameters.nextStep; switch (parameters.step[idx]) { @@ -34,34 +34,34 @@ async function startAbilityProcess(abilityContext, parameters) { parameters.startId = 2; break; case "StartB": - bundleName = "com.example.amsabilitymultiinstanceappb"; - abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + bundleName = "com.acts.abilitymultiinstanceb"; + abilityName = "com.acts.abilitymultiinstanceb.MainAbility"; break; case "StartC": - bundleName = "com.example.amsabilitymultiinstanceappc"; - abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + bundleName = "com.acts.abilitymultiinstancec"; + abilityName = "com.acts.abilitymultiinstancec.MainAbility"; break; case "StartDMain1": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 1; break; case "StartDMain2": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 2; break; case "StartDSec": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.SecondAbility"; break; case "StartDThd": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.ThirdAbility"; break; case "StartE": - bundleName = "com.example.amsabilitymultiinstanceappe"; - abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + bundleName = "com.acts.abilitymultiinstancee"; + abilityName = "com.acts.abilitymultiinstancee.MainAbility"; break; default: diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/module.json b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/module.json index ea41f009b2cf081cb2fde99b14678b7815b042d7..9219ce99940e85ee4e00764ca3c7c8c66d3cdc31 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/module.json +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/module.json @@ -1,6 +1,6 @@ { "module": { - "name": "com.example.amsabilitymultiinstanceappa", + "name": "com.acts.abilitymultiinstancea", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", "description": "$string:phone_entry_dsc", @@ -13,9 +13,15 @@ "installationFree": false, "uiSyntax": "ets", "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { - "name": "com.example.amsabilitymultiinstanceappa.MainAbility", + "name": "com.acts.abilitymultiinstancea.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", "description": "$string:phone_entry_main", "icon": "$media:icon", diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/signature/openharmony_sx.p7b b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/signature/openharmony_sx.p7b index ce94d93344b8bde0a11457141b4c26119e966628..f41ac3e5a35d863c972e18fff5e9edee668d404a 100644 Binary files a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/signature/openharmony_sx.p7b and b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappa/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/AppScope/app.json b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/AppScope/app.json index 3b4690d4ee538be78e37f2992724d1faf383e67b..349f31375aff6ee7f16b54aca014ef8299c81882 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/AppScope/app.json +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/AppScope/app.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.example.amsabilitymultiinstanceappb", + "bundleName": "com.acts.abilitymultiinstanceb", "vendor": "huawei", "versionCode": 1000000, "versionName": "1.0.0", diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/MainAbility/MainAbility.ts index 7d0aec329bcff69411e36a3faab36014fb760422..3a1e87be35d38d0dcb3020508dae5afbd0e7a355 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/MainAbility/MainAbility.ts @@ -22,8 +22,8 @@ function publishCallBack() { } async function startAbilityProcess(abilityContext, parameters) { - let bundleName = "com.example.amsabilitymultiinstanceappa"; - let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + let bundleName = "com.acts.abilitymultiinstancea"; + let abilityName = "com.acts.abilitymultiinstancea.MainAbility"; let idx = parameters.nextStep; switch (parameters.step[idx]) { @@ -34,34 +34,34 @@ async function startAbilityProcess(abilityContext, parameters) { parameters.startId = 2; break; case "StartB": - bundleName = "com.example.amsabilitymultiinstanceappb"; - abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + bundleName = "com.acts.abilitymultiinstanceb"; + abilityName = "com.acts.abilitymultiinstanceb.MainAbility"; break; case "StartC": - bundleName = "com.example.amsabilitymultiinstanceappc"; - abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + bundleName = "com.acts.abilitymultiinstancec"; + abilityName = "com.acts.abilitymultiinstancec.MainAbility"; break; case "StartDMain1": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 1; break; case "StartDMain2": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 2; break; case "StartDSec": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.SecondAbility"; break; case "StartDThd": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.ThirdAbility"; break; case "StartE": - bundleName = "com.example.amsabilitymultiinstanceappe"; - abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + bundleName = "com.acts.abilitymultiinstancee"; + abilityName = "com.acts.abilitymultiinstancee.MainAbility"; break; default: diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/module.json b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/module.json index 63945acf31e11fd61a6ec3929a8039fbfd7702f0..4ea270ed2cefaeddc1c371793401323aa3416ead 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/module.json +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/module.json @@ -1,6 +1,6 @@ { "module": { - "name": "com.example.amsabilitymultiinstanceappb", + "name": "com.acts.abilitymultiinstanceb", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", "description": "$string:phone_entry_dsc", @@ -13,9 +13,15 @@ "installationFree": false, "uiSyntax": "ets", "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { - "name": "com.example.amsabilitymultiinstanceappb.MainAbility", + "name": "com.acts.abilitymultiinstanceb.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", "description": "$string:phone_entry_main", "icon": "$media:icon", diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/signature/openharmony_sx.p7b b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/signature/openharmony_sx.p7b index 84cee5f0d7c46dd4184133a41ff82f5381e137d1..fe75d73d2613689bcc5d313224b59446e7f3cf2f 100644 Binary files a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/signature/openharmony_sx.p7b and b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappb/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/AppScope/app.json b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/AppScope/app.json index 4a929dae8502d95cc6d63e1833cda12c58996441..64a832e1f77ae0682e525af12a240c1bd64d84de 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/AppScope/app.json +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/AppScope/app.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.example.amsabilitymultiinstanceappc", + "bundleName": "com.acts.abilitymultiinstancec", "vendor": "huawei", "versionCode": 1000000, "versionName": "1.0.0", diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/MainAbility/MainAbility.ts index 64b71689d5bc2dc3583136732b3682d1a2cb3157..b7de8637605055d6ef02c4d85034072160399ef0 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/MainAbility/MainAbility.ts @@ -41,8 +41,8 @@ async function onShowProcess() { } async function startAbilityProcess(abilityContext, parameters) { - let bundleName = "com.example.amsabilitymultiinstanceappa"; - let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + let bundleName = "com.acts.abilitymultiinstancea"; + let abilityName = "com.acts.abilitymultiinstancea.MainAbility"; let idx = parameters.nextStep; switch (parameters.step[idx]) { @@ -53,34 +53,34 @@ async function startAbilityProcess(abilityContext, parameters) { parameters.startId = 2; break; case "StartB": - bundleName = "com.example.amsabilitymultiinstanceappb"; - abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + bundleName = "com.acts.abilitymultiinstanceb"; + abilityName = "com.acts.abilitymultiinstanceb.MainAbility"; break; case "StartC": - bundleName = "com.example.amsabilitymultiinstanceappc"; - abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + bundleName = "com.acts.abilitymultiinstancec"; + abilityName = "com.acts.abilitymultiinstancec.MainAbility"; break; case "StartDMain1": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 1; break; case "StartDMain2": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 2; break; case "StartDSec": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.SecondAbility"; break; case "StartDThd": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.ThirdAbility"; break; case "StartE": - bundleName = "com.example.amsabilitymultiinstanceappe"; - abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + bundleName = "com.acts.abilitymultiinstancee"; + abilityName = "com.acts.abilitymultiinstancee.MainAbility"; break; default: diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/module.json b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/module.json index 2acfc5d45e7b66cf8a03d65dd6562c8f3224f081..2fc6b88408fd0c58197b8b298eebd10bace29f11 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/module.json +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/module.json @@ -1,6 +1,6 @@ { "module": { - "name": "com.example.amsabilitymultiinstanceappc", + "name": "com.acts.abilitymultiinstancec", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", "description": "$string:phone_entry_dsc", @@ -13,9 +13,15 @@ "installationFree": false, "uiSyntax": "ets", "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { - "name": "com.example.amsabilitymultiinstanceappc.MainAbility", + "name": "com.acts.abilitymultiinstancec.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", "description": "$string:phone_entry_main", "icon": "$media:icon", diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/signature/openharmony_sx.p7b b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/signature/openharmony_sx.p7b index 54bebe9e9cf73a04d81628241725bf5cd04b8ae9..f1257f0bb406d863844e45ffa8cc4411c8e02bb8 100644 Binary files a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/signature/openharmony_sx.p7b and b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappc/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/AppScope/app.json b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/AppScope/app.json index 44433c774917da52f33d7d1ec568df27dda320e5..71c91d1e4635b53330a5e8f2f549ac8a285506d4 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/AppScope/app.json +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/AppScope/app.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.example.amsabilitymultiinstanceappd", + "bundleName": "com.acts.abilitymultiinstanced", "vendor": "huawei", "versionCode": 1000000, "versionName": "1.0.0", diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/MainAbility/MainAbility.ts index 9b93f421e473c7a27d8d5b12b6a48801c01ee32d..8ddf4919ff5e1777fdaa4b81de1e3a3ce701ded1 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/MainAbility/MainAbility.ts @@ -42,8 +42,8 @@ async function onShowProcess() { } async function startAbilityProcess(abilityContext, parameters) { - let bundleName = "com.example.amsabilitymultiinstanceappa"; - let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + let bundleName = "com.acts.abilitymultiinstancea"; + let abilityName = "com.acts.abilitymultiinstancea.MainAbility"; let idx = parameters.nextStep; switch (parameters.step[idx]) { @@ -54,34 +54,34 @@ async function startAbilityProcess(abilityContext, parameters) { parameters.startId = 2; break; case "StartB": - bundleName = "com.example.amsabilitymultiinstanceappb"; - abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + bundleName = "com.acts.abilitymultiinstanceb"; + abilityName = "com.acts.abilitymultiinstanceb.MainAbility"; break; case "StartC": - bundleName = "com.example.amsabilitymultiinstanceappc"; - abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + bundleName = "com.acts.abilitymultiinstancec"; + abilityName = "com.acts.abilitymultiinstancec.MainAbility"; break; case "StartDMain1": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 1; break; case "StartDMain2": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 2; break; case "StartDSec": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.SecondAbility"; break; case "StartDThd": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.ThirdAbility"; break; case "StartE": - bundleName = "com.example.amsabilitymultiinstanceappe"; - abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + bundleName = "com.acts.abilitymultiinstancee"; + abilityName = "com.acts.abilitymultiinstancee.MainAbility"; break; default: diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/SecondAbility/SecondAbility.ts b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/SecondAbility/SecondAbility.ts index 015a64945899c1f4f44a5e490276eed2ffd54306..c30a16bd6fc323330ec89bf62832888ba778c53f 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/SecondAbility/SecondAbility.ts +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/SecondAbility/SecondAbility.ts @@ -42,8 +42,8 @@ async function onShowProcess() { } async function startAbilityProcess(abilityContext, parameters) { - let bundleName = "com.example.amsabilitymultiinstanceappa"; - let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + let bundleName = "com.acts.abilitymultiinstancea"; + let abilityName = "com.acts.abilitymultiinstancea.MainAbility"; let idx = parameters.nextStep; switch (parameters.step[idx]) { @@ -54,34 +54,34 @@ async function startAbilityProcess(abilityContext, parameters) { parameters.startId = 2; break; case "StartB": - bundleName = "com.example.amsabilitymultiinstanceappb"; - abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + bundleName = "com.acts.abilitymultiinstanceb"; + abilityName = "com.acts.abilitymultiinstanceb.MainAbility"; break; case "StartC": - bundleName = "com.example.amsabilitymultiinstanceappc"; - abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + bundleName = "com.acts.abilitymultiinstancec"; + abilityName = "com.acts.abilitymultiinstancec.MainAbility"; break; case "StartDMain1": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 1; break; case "StartDMain2": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 2; break; case "StartDSec": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.SecondAbility"; break; case "StartDThd": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.ThirdAbility"; break; case "StartE": - bundleName = "com.example.amsabilitymultiinstanceappe"; - abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + bundleName = "com.acts.abilitymultiinstancee"; + abilityName = "com.acts.abilitymultiinstancee.MainAbility"; break; default: diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/ThirdAbility/ThirdAbility.ts b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/ThirdAbility/ThirdAbility.ts index fcea4946e6d3a259c87d2d3ec0fe3b570eb52f25..1e8f8c7e3d948d792de2ae2f21ed559bbecf9a02 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/ThirdAbility/ThirdAbility.ts +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/ThirdAbility/ThirdAbility.ts @@ -42,8 +42,8 @@ async function onShowProcess() { } async function startAbilityProcess(abilityContext, parameters) { - let bundleName = "com.example.amsabilitymultiinstanceappa"; - let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + let bundleName = "com.acts.abilitymultiinstancea"; + let abilityName = "com.acts.abilitymultiinstancea.MainAbility"; let idx = parameters.nextStep; switch (parameters.step[idx]) { @@ -54,30 +54,30 @@ async function startAbilityProcess(abilityContext, parameters) { parameters.startId = 2; break; case "StartB": - bundleName = "com.example.amsabilitymultiinstanceappb"; - abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + bundleName = "com.acts.abilitymultiinstanceb"; + abilityName = "com.acts.abilitymultiinstanceb.MainAbility"; break; case "StartC": - bundleName = "com.example.amsabilitymultiinstanceappc"; - abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + bundleName = "com.acts.abilitymultiinstancec"; + abilityName = "com.acts.abilitymultiinstancec.MainAbility"; break; case "StartDMain1": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 1; break; case "StartDMain2": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 2; break; case "StartDSec": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.SecondAbility"; break; case "StartDThd": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.ThirdAbility"; break; default: diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/module.json b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/module.json index fddc1a2e76c591a4b6317bdb68e039b9ac9f8b3a..3d3c78e233c8c0e5ac410e6854f57422f39ea62e 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/module.json +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/module.json @@ -1,6 +1,6 @@ { "module": { - "name": "com.example.amsabilitymultiinstanceappd", + "name": "com.acts.abilitymultiinstanced", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", "description": "$string:phone_entry_dsc", @@ -13,9 +13,15 @@ "installationFree": false, "uiSyntax": "ets", "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { - "name": "com.example.amsabilitymultiinstanceappd.MainAbility", + "name": "com.acts.abilitymultiinstanced.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", "description": "$string:phone_entry_main", "icon": "$media:icon", @@ -35,7 +41,7 @@ ] }, { - "name": "com.example.amsabilitymultiinstanceappd.SecondAbility", + "name": "com.acts.abilitymultiinstanced.SecondAbility", "srcEntrance": "./ets/SecondAbility/SecondAbility.ts", "description": "$string:phone_entry_main", "icon": "$media:icon", @@ -55,7 +61,7 @@ ] }, { - "name": "com.example.amsabilitymultiinstanceappd.ThirdAbility", + "name": "com.acts.abilitymultiinstanced.ThirdAbility", "srcEntrance": "./ets/ThirdAbility/ThirdAbility.ts", "description": "$string:phone_entry_main", "icon": "$media:icon", diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/signature/openharmony_sx.p7b b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/signature/openharmony_sx.p7b index 66fb51025f164d1d50c5490d1e4ef959376d98fb..81eb8845f2beb7d50221a4a53bb5b882a49d8733 100644 Binary files a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/signature/openharmony_sx.p7b and b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappd/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappe/signature/openharmony_sx.p7b b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappe/signature/openharmony_sx.p7b index fcff8c60d675b52d9a0e333dfc3942662b43122d..fdb95a4e4bcf56cb050226d6a7b4a29a200770e8 100755 Binary files a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappe/signature/openharmony_sx.p7b and b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappe/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/config.json b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/config.json index 9614e4e2eee309ec7db6868797243b704e31373e..aca8b8e97518c674925da0d368eddb665e08e5a4 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/config.json +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/config.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.example.amsabilitymultiinstanceappe", + "bundleName": "com.acts.abilitymultiinstancee", "vendor": "example", "version": { "code": 1, @@ -14,11 +14,11 @@ }, "deviceConfig": { "default": { - "process": "com.example.amsabilitymultiinstanceappe" + "process": "com.acts.abilitymultiinstancee" } }, "module": { - "package": "com.example.amsabilitymultiinstanceappe", + "package": "com.acts.abilitymultiinstancee", "name": ".MyApplication", "deviceType": [ "default", @@ -41,7 +41,7 @@ ] } ], - "name": "com.example.amsabilitymultiinstanceappe.MainAbility", + "name": "com.acts.abilitymultiinstancee.MainAbility", "visible": true, "icon": "$media:icon", "description": "$string:mainability_description", diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/pages/index/index.js b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/pages/index/index.js index 6a7a379d295ebf9a2bed52b5eb8db721a900a039..c064061d30a734067c31f1d67bc898d7cc9b7136 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/pages/index/index.js +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/pages/index/index.js @@ -24,8 +24,8 @@ function publishCallBack() { } async function startAbilityProcess(parameters) { - let bundleName = "com.example.amsabilitymultiinstanceappa"; - let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + let bundleName = "com.acts.abilitymultiinstancea"; + let abilityName = "com.acts.abilitymultiinstancea.MainAbility"; let idx = parameters.nextStep; switch (parameters.step[idx]) { @@ -36,34 +36,34 @@ async function startAbilityProcess(parameters) { parameters.startId = 2; break; case "StartB": - bundleName = "com.example.amsabilitymultiinstanceappb"; - abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + bundleName = "com.acts.abilitymultiinstanceb"; + abilityName = "com.acts.abilitymultiinstanceb.MainAbility"; break; case "StartC": - bundleName = "com.example.amsabilitymultiinstanceappc"; - abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + bundleName = "com.acts.abilitymultiinstancec"; + abilityName = "com.acts.abilitymultiinstancec.MainAbility"; break; case "StartDMain1": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 1; break; case "StartDMain2": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 2; break; case "StartDSec": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.SecondAbility"; break; case "StartDThd": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.ThirdAbility"; break; case "StartE": - bundleName = "com.example.amsabilitymultiinstanceappe"; - abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + bundleName = "com.acts.abilitymultiinstancee"; + abilityName = "com.acts.abilitymultiinstancee.MainAbility"; break; default: diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets index c2816b1b06996508bf29d654d6526123f8359204..db278c5463b4d22dc6e1bca8b2ff56cc550136c7 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets @@ -24,8 +24,8 @@ const ONACCEPTWANT_KEY_UNDEFINED_ID = -2; const UNSUBSCRIBE_TIMEOUT = 5000; async function startAbilityProcess(abilityContext, parameters) { - let bundleName = "com.example.amsabilitymultiinstanceappa"; - let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + let bundleName = "com.acts.abilitymultiinstancea"; + let abilityName = "com.acts.abilitymultiinstancea.MainAbility"; let idx = parameters.nextStep; switch (parameters.step[idx]) { @@ -45,34 +45,34 @@ async function startAbilityProcess(abilityContext, parameters) { parameters.startId = ONACCEPTWANT_KEY_UNDEFINED_ID; break; case "StartB": - bundleName = "com.example.amsabilitymultiinstanceappb"; - abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + bundleName = "com.acts.abilitymultiinstanceb"; + abilityName = "com.acts.abilitymultiinstanceb.MainAbility"; break; case "StartC": - bundleName = "com.example.amsabilitymultiinstanceappc"; - abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + bundleName = "com.acts.abilitymultiinstancec"; + abilityName = "com.acts.abilitymultiinstancec.MainAbility"; break; case "StartDMain1": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 1; break; case "StartDMain2": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.MainAbility"; parameters.startId = 2; break; case "StartDSec": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.SecondAbility"; break; case "StartDThd": - bundleName = "com.example.amsabilitymultiinstanceappd"; - abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + bundleName = "com.acts.abilitymultiinstanced"; + abilityName = "com.acts.abilitymultiinstanced.ThirdAbility"; break; case "StartE": - bundleName = "com.example.amsabilitymultiinstanceappe"; - abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + bundleName = "com.acts.abilitymultiinstancee"; + abilityName = "com.acts.abilitymultiinstancee.MainAbility"; break; default: diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/module.json b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/module.json index 361091f9695839e2bfd5acb208f011de68c5201d..34059a90be709f74e34def7bb22158927f05c1b1 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/module.json +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/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.example.abilitymultiinstance.MainAbility", @@ -34,6 +40,12 @@ } ] } + ], + "requestPermissions": [ + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } ] } } diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/signature/openharmony_sx.p7b b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/signature/openharmony_sx.p7b index 60bab1e1e047a5cf06673de1aa7a28719fdad880..276a42d96f01d1626236f10e0ec1e267a8ad1791 100644 Binary files a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/signature/openharmony_sx.p7b and b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassista/entry/src/main/module.json b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassista/entry/src/main/module.json index b3b145d06377ea8c4f89a69ee42e7817a8e37b26..db2eece2d77e280b2e69de8825f4c2808763627f 100644 --- a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassista/entry/src/main/module.json +++ b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassista/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistc/entry/src/main/module.json b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistc/entry/src/main/module.json index 327e861b6691e5d1b3faebe53a49e9bae2610720..baf49d0917fa66c3ab3d8194da0ea348ea596a86 100644 --- a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistc/entry/src/main/module.json +++ b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistc/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility2", diff --git a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistd/entry/src/main/module.json b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistd/entry/src/main/module.json index 6acc12f62dcf81121df92d959c75260ad0c0b95f..8f40a169d079f250f409087e04df7e3f283fe4ca 100644 --- a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistd/entry/src/main/module.json +++ b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistd/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility3", diff --git a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassiste/entry/src/main/module.json b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassiste/entry/src/main/module.json index 01fd1934ee1683874889c1e8658d5eb632b62666..f9e72d246142296781ed9406c7ff979b2c7e0b09 100644 --- a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassiste/entry/src/main/module.json +++ b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassiste/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility4", diff --git a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistf/entry/src/main/module.json b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistf/entry/src/main/module.json index cd1b2ecabd06bc88f8073a7f76ff1bf1abae3cc6..d153699ac0efccf5c66970b39a5ef4538106f9e8 100644 --- a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistf/entry/src/main/module.json +++ b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistf/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbilityf5", diff --git a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistg/entry/src/main/module.json b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistg/entry/src/main/module.json index 67edae7e7a2d273c2b47835810b0cf8b0d5fbca3..c4a0edabc3df4174fc02bcb02c72da30e509dfe5 100644 --- a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistg/entry/src/main/module.json +++ b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassistg/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility6", diff --git a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassisth/entry/src/main/module.json b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassisth/entry/src/main/module.json index ce69e78940991db0b7a99cb4b64be274d153275c..bc19bc5a4ea3dce4c68317dac28b369ff0a77889 100644 --- a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassisth/entry/src/main/module.json +++ b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitorassisth/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility7", diff --git a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitortest/entry/src/main/module.json b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitortest/entry/src/main/module.json index 04d2ae8ed563ad88b2e385c38df60ce00127503b..4657077047afbb8e29c2f885a974a44523c6f8cc 100644 --- a/ability/ability_runtime/abilitystagemonitor/abilitystagemonitortest/entry/src/main/module.json +++ b/ability/ability_runtime/abilitystagemonitor/abilitystagemonitortest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "TestAbility", diff --git a/ability/ability_runtime/actsabilityusertest/entry/src/main/module.json b/ability/ability_runtime/actsabilityusertest/entry/src/main/module.json index 8f318e5236019cf55c466ba0799390021823b159..d89426368d6607aadf50a5bc1dbdd67c0feae835 100644 --- a/ability/ability_runtime/actsabilityusertest/entry/src/main/module.json +++ b/ability/ability_runtime/actsabilityusertest/entry/src/main/module.json @@ -12,6 +12,12 @@ "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "uiSyntax": "ets", "abilities": [ { diff --git a/ability/ability_runtime/actscalltest/systemappcalleea/entry/src/main/module.json b/ability/ability_runtime/actscalltest/systemappcalleea/entry/src/main/module.json index a654cf85b6f062af9223a84ad3aed626a4704c9c..e30b79c4c8a2d48c9971116a78800373ccd5e6ff 100644 --- a/ability/ability_runtime/actscalltest/systemappcalleea/entry/src/main/module.json +++ b/ability/ability_runtime/actscalltest/systemappcalleea/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.example.systemappcalleea.MainAbility", diff --git a/ability/ability_runtime/actscalltest/systemappcallera/entry/src/main/module.json b/ability/ability_runtime/actscalltest/systemappcallera/entry/src/main/module.json index 976752cdbf5b413bdec69796bb6fa1566718dfb0..7b36a22814c3fd7de7e4b5d466983cc20aff9aaa 100644 --- a/ability/ability_runtime/actscalltest/systemappcallera/entry/src/main/module.json +++ b/ability/ability_runtime/actscalltest/systemappcallera/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.example.systemappcallera.MainAbility", diff --git a/ability/ability_runtime/actscalltest/systemappcallerb/entry/src/main/module.json b/ability/ability_runtime/actscalltest/systemappcallerb/entry/src/main/module.json index ee469e489d056f7ae8be90cbb81d5c7963e54564..3250f3921928cf5e06f65d04468a2c346b7c9b86 100644 --- a/ability/ability_runtime/actscalltest/systemappcallerb/entry/src/main/module.json +++ b/ability/ability_runtime/actscalltest/systemappcallerb/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.example.systemappcallerb.MainAbility", diff --git a/ability/ability_runtime/actscalltest/systemappcallerc/entry/src/main/module.json b/ability/ability_runtime/actscalltest/systemappcallerc/entry/src/main/module.json index 80e641e5b536009a7b664d0b8ecab43a6c59838f..e5a2c71863b12b68bf2ccb118f03a9d058d6838e 100644 --- a/ability/ability_runtime/actscalltest/systemappcallerc/entry/src/main/module.json +++ b/ability/ability_runtime/actscalltest/systemappcallerc/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.example.systemappcallerc.MainAbility", diff --git a/ability/ability_runtime/actscalltest/systemcallentrytest/entry/src/main/module.json b/ability/ability_runtime/actscalltest/systemcallentrytest/entry/src/main/module.json index f623720cb3eb630df8a0675b5ea5716fe6b724cb..222cc142a3a9203c8eca996d286840b701dd0cf7 100644 --- a/ability/ability_runtime/actscalltest/systemcallentrytest/entry/src/main/module.json +++ b/ability/ability_runtime/actscalltest/systemcallentrytest/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.example.systemcalltest.MainAbility", diff --git a/ability/ability_runtime/actscalltest/systemcallfeature/entry/src/main/module.json b/ability/ability_runtime/actscalltest/systemcallfeature/entry/src/main/module.json index 36482e3bf3c9a4c3f58f9bb64b904fc847a95c13..aa649f485c5662e9153d9a14dae7f7aeea1bc63d 100644 --- a/ability/ability_runtime/actscalltest/systemcallfeature/entry/src/main/module.json +++ b/ability/ability_runtime/actscalltest/systemcallfeature/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.second.MainAbility", diff --git a/ability/ability_runtime/actscalltest/thirdappa/entry/src/main/module.json b/ability/ability_runtime/actscalltest/thirdappa/entry/src/main/module.json index 5505f6ca87f0dfb2a0d641a465a438c7cc0160ea..fc239beb1fb211bca490e6a4dbcd187900262d77 100644 --- a/ability/ability_runtime/actscalltest/thirdappa/entry/src/main/module.json +++ b/ability/ability_runtime/actscalltest/thirdappa/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.example.thirdappa.MainAbility", diff --git a/ability/ability_runtime/actscalltest/thirdcalltest/entry/src/main/module.json b/ability/ability_runtime/actscalltest/thirdcalltest/entry/src/main/module.json index b2306f445a32948c3d550e0c1b3cd788a872fd33..dbdfb56a75128a1658dbd96b3c01497bfca44c4f 100644 --- a/ability/ability_runtime/actscalltest/thirdcalltest/entry/src/main/module.json +++ b/ability/ability_runtime/actscalltest/thirdcalltest/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.example.thirdcalltest.MainAbility", diff --git a/ability/ability_runtime/actsdataabilityaccessdatasharetest/actsdataabilityaccessdatasharetest/src/main/config.json b/ability/ability_runtime/actsdataabilityaccessdatasharetest/actsdataabilityaccessdatasharetest/src/main/config.json index a93d6cea7b3668ec9f63d27fc52007d0c994fe0a..66919f5f8cc0307ada1bdd5ab6f59fd801e0d333 100644 --- a/ability/ability_runtime/actsdataabilityaccessdatasharetest/actsdataabilityaccessdatasharetest/src/main/config.json +++ b/ability/ability_runtime/actsdataabilityaccessdatasharetest/actsdataabilityaccessdatasharetest/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 5, "releaseType": "Beta1" } diff --git a/ability/ability_runtime/actsdataabilityaccessdatasharetest/datashareserverhap/entry/src/main/module.json b/ability/ability_runtime/actsdataabilityaccessdatasharetest/datashareserverhap/entry/src/main/module.json index 465ba09da3eccecf8fa98f74631226acc7aa8a43..00fc37036c6f0335b718b0f2f10f488c29a3fa44 100644 --- a/ability/ability_runtime/actsdataabilityaccessdatasharetest/datashareserverhap/entry/src/main/module.json +++ b/ability/ability_runtime/actsdataabilityaccessdatasharetest/datashareserverhap/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/actsfwkdataaccessortest/actsdataabilityrelyhap/entry/src/main/config.json b/ability/ability_runtime/actsfwkdataaccessortest/actsdataabilityrelyhap/entry/src/main/config.json index 69d3afcf941128ee13047da5270e804bb657944c..8f1b25436e317a7ac83d210ef9cb8781d3b7e4ba 100644 --- a/ability/ability_runtime/actsfwkdataaccessortest/actsdataabilityrelyhap/entry/src/main/config.json +++ b/ability/ability_runtime/actsfwkdataaccessortest/actsdataabilityrelyhap/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.1.1" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 9 } }, diff --git a/ability/ability_runtime/actsqueryfunctiontest/actsgetabilitystatestagetest/entry/src/main/module.json b/ability/ability_runtime/actsqueryfunctiontest/actsgetabilitystatestagetest/entry/src/main/module.json index 69a80af0ca698cae287a179ba741fdfd2e2e0fe2..ed12a311cf868537511f3431980b36cbeb36903f 100644 --- a/ability/ability_runtime/actsqueryfunctiontest/actsgetabilitystatestagetest/entry/src/main/module.json +++ b/ability/ability_runtime/actsqueryfunctiontest/actsgetabilitystatestagetest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", @@ -53,6 +59,12 @@ "icon": "$media:icon", "label": "$string:MainAbility4_label" } + ], + "requestPermissions": [ + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } ] } } \ No newline at end of file diff --git a/ability/ability_runtime/actsqueryfunctiontest/actsgetabilitystatestagetest/signature/openharmony_sx.p7b b/ability/ability_runtime/actsqueryfunctiontest/actsgetabilitystatestagetest/signature/openharmony_sx.p7b index 1a13677f2bba213b735e7187d638114530b030ed..a7837634b279ecb039de4d58e8fc58b87a71354e 100644 Binary files a/ability/ability_runtime/actsqueryfunctiontest/actsgetabilitystatestagetest/signature/openharmony_sx.p7b and b/ability/ability_runtime/actsqueryfunctiontest/actsgetabilitystatestagetest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actsqueryfunctiontest/actsgetappcontextstageatest/entry/src/main/module.json b/ability/ability_runtime/actsqueryfunctiontest/actsgetappcontextstageatest/entry/src/main/module.json index 41ecb73effa4f4cb1ce8f2fd9c6884559c7d1866..fb330aeaeb4937eda8bbe0ae8d01a72a50d0cd14 100644 --- a/ability/ability_runtime/actsqueryfunctiontest/actsgetappcontextstageatest/entry/src/main/module.json +++ b/ability/ability_runtime/actsqueryfunctiontest/actsgetappcontextstageatest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/actsqueryfunctiontest/actsgetappcontextstagebtest/entry/src/main/module.json b/ability/ability_runtime/actsqueryfunctiontest/actsgetappcontextstagebtest/entry/src/main/module.json index 41ecb73effa4f4cb1ce8f2fd9c6884559c7d1866..fb330aeaeb4937eda8bbe0ae8d01a72a50d0cd14 100644 --- a/ability/ability_runtime/actsqueryfunctiontest/actsgetappcontextstagebtest/entry/src/main/module.json +++ b/ability/ability_runtime/actsqueryfunctiontest/actsgetappcontextstagebtest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/actsqueryfunctiontest/actsgetappcontexttest/entry/src/main/module.json b/ability/ability_runtime/actsqueryfunctiontest/actsgetappcontexttest/entry/src/main/module.json index 41ecb73effa4f4cb1ce8f2fd9c6884559c7d1866..fb330aeaeb4937eda8bbe0ae8d01a72a50d0cd14 100644 --- a/ability/ability_runtime/actsqueryfunctiontest/actsgetappcontexttest/entry/src/main/module.json +++ b/ability/ability_runtime/actsqueryfunctiontest/actsgetappcontexttest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystageatest/entry/src/main/module.json b/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystageatest/entry/src/main/module.json index 09fdb067a2aa9fe01a1c2498ac415aec5c1d85cf..c388bdd9fc94fb7cb28cba9f2e4c550ac7ef5267 100644 --- a/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystageatest/entry/src/main/module.json +++ b/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystageatest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystagebtest/entry/src/main/module.json b/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystagebtest/entry/src/main/module.json index 09fdb067a2aa9fe01a1c2498ac415aec5c1d85cf..c388bdd9fc94fb7cb28cba9f2e4c550ac7ef5267 100644 --- a/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystagebtest/entry/src/main/module.json +++ b/ability/ability_runtime/actsqueryfunctiontest/actsgetcurrenttopabilitystagebtest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/actsserviceabilityclienttest/actsserviceabilityserverrelyhap/entry/src/main/config.json b/ability/ability_runtime/actsserviceabilityclienttest/actsserviceabilityserverrelyhap/entry/src/main/config.json index b8a5fb7663de75edb2ecc69205507d6da51a0f77..f2165dcfeea4bb587153290ad1236cd825decfb5 100644 --- a/ability/ability_runtime/actsserviceabilityclienttest/actsserviceabilityserverrelyhap/entry/src/main/config.json +++ b/ability/ability_runtime/actsserviceabilityclienttest/actsserviceabilityserverrelyhap/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.1.1" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 9 } }, diff --git a/ability/ability_runtime/actsserviceabilityclienttest/actsserviceabilityserversecondrelyhap/entry/src/main/config.json b/ability/ability_runtime/actsserviceabilityclienttest/actsserviceabilityserversecondrelyhap/entry/src/main/config.json index fbb42748129d4da7804b6ef1d1530d3f918924a5..40040bf90d38f2660940d5901c8fdb51d064ca77 100644 --- a/ability/ability_runtime/actsserviceabilityclienttest/actsserviceabilityserversecondrelyhap/entry/src/main/config.json +++ b/ability/ability_runtime/actsserviceabilityclienttest/actsserviceabilityserversecondrelyhap/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.1.1" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 9 } }, diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActsExecuteShellCommandTest/entry/src/main/module.json b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActsExecuteShellCommandTest/entry/src/main/module.json index db4ff937144c965b54e6f0bdc87af9d3ab04a4cf..88cdaa0fb49d32b4a97737c6dde6303a3684fc84 100755 --- a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActsExecuteShellCommandTest/entry/src/main/module.json +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActsExecuteShellCommandTest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActsKillProcessWithAccountCloseRelyHap/entry/src/main/module.json b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActsKillProcessWithAccountCloseRelyHap/entry/src/main/module.json index db4ff937144c965b54e6f0bdc87af9d3ab04a4cf..88cdaa0fb49d32b4a97737c6dde6303a3684fc84 100755 --- a/ability/ability_runtime/actsshellcommandfunctionalitytest/ActsKillProcessWithAccountCloseRelyHap/entry/src/main/module.json +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/ActsKillProcessWithAccountCloseRelyHap/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/actsshellcommandfunctionalitytest/actsshellcommandcontroltest/entry/src/main/module.json b/ability/ability_runtime/actsshellcommandfunctionalitytest/actsshellcommandcontroltest/entry/src/main/module.json index f737641a3b1559e7c64a66f1efb68309f23df16a..4bb7fcdcb96b29347476c4edd9a85308673bafc4 100644 --- a/ability/ability_runtime/actsshellcommandfunctionalitytest/actsshellcommandcontroltest/entry/src/main/module.json +++ b/ability/ability_runtime/actsshellcommandfunctionalitytest/actsshellcommandcontroltest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/actsstartrunnertest/entry/src/main/module.json b/ability/ability_runtime/actsstartrunnertest/entry/src/main/module.json index a6e6fea2aa1875fdd25a78da9cd7eee283ef5ee3..d142e69baf395468fb21dc7cc4f024c188ab1f24 100644 --- a/ability/ability_runtime/actsstartrunnertest/entry/src/main/module.json +++ b/ability/ability_runtime/actsstartrunnertest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/module.json b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/module.json index 015dfcf1027046899d5780f2b1843f38871d2474..0b82e31ff35baa87365dff04081a9ddbd922d164 100644 --- a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/module.json +++ b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", @@ -35,6 +41,12 @@ } ] } + ], + "requestPermissions": [ + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } ] } } \ No newline at end of file diff --git a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/signature/openharmony_sx.p7b b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/signature/openharmony_sx.p7b index b901cc81c08614c4745ed72142857e7fc712baf7..481c85b926c1e973aa81151ddcfeac57a188c038 100644 Binary files a/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/signature/openharmony_sx.p7b and b/ability/ability_runtime/actssupportfunction/actsonandoffscreentest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/module.json b/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/module.json index 015dfcf1027046899d5780f2b1843f38871d2474..0b82e31ff35baa87365dff04081a9ddbd922d164 100644 --- a/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/module.json +++ b/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", @@ -35,6 +41,12 @@ } ] } + ], + "requestPermissions": [ + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } ] } } \ No newline at end of file diff --git a/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/signature/openharmony_sx.p7b b/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/signature/openharmony_sx.p7b index fbe4df030061b3b936c14cda433ffb2501870e98..0bbaa2e713c1cac3ad9d3242d8715788bfc1aa42 100644 Binary files a/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/signature/openharmony_sx.p7b and b/ability/ability_runtime/actssupportfunction/actssupportfunctiontest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actssupportfunction/faonandoffscreen/entry/src/main/config.json b/ability/ability_runtime/actssupportfunction/faonandoffscreen/entry/src/main/config.json index 114424569204ab79c82ce3576edca775164ed54f..ae5560ad585a2189e072b79dc72cb1b0c961c626 100644 --- a/ability/ability_runtime/actssupportfunction/faonandoffscreen/entry/src/main/config.json +++ b/ability/ability_runtime/actssupportfunction/faonandoffscreen/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 9 } }, diff --git a/ability/ability_runtime/actssupportfunction/fasupportfunction/entry/src/main/config.json b/ability/ability_runtime/actssupportfunction/fasupportfunction/entry/src/main/config.json index 8b42adfe97c9b911fb2205c6680f0ef18dbcf05b..20c6b00f98cefbeb149afaaf22194f5173ef80f4 100644 --- a/ability/ability_runtime/actssupportfunction/fasupportfunction/entry/src/main/config.json +++ b/ability/ability_runtime/actssupportfunction/fasupportfunction/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 9 } }, diff --git a/ability/ability_runtime/actssupportfunction/fasupportfunction/fasupportfunctiontwo/src/main/config.json b/ability/ability_runtime/actssupportfunction/fasupportfunction/fasupportfunctiontwo/src/main/config.json index 1255034f8d4675af43931e9cdd411c9abbb81522..68a0bd25664cd17a551180b1ebeb2bafd5f2f915 100644 --- a/ability/ability_runtime/actssupportfunction/fasupportfunction/fasupportfunctiontwo/src/main/config.json +++ b/ability/ability_runtime/actssupportfunction/fasupportfunction/fasupportfunctiontwo/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 9 } }, diff --git a/ability/ability_runtime/actssupportfunction/fasupportfunctionthree/entry/src/main/config.json b/ability/ability_runtime/actssupportfunction/fasupportfunctionthree/entry/src/main/config.json index 4dfc0697f6e8fe56e0779a43359fcf273d133f02..53751d4e7531129526a043eb5aaafd3e13f17d8e 100644 --- a/ability/ability_runtime/actssupportfunction/fasupportfunctionthree/entry/src/main/config.json +++ b/ability/ability_runtime/actssupportfunction/fasupportfunctionthree/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 9 } }, diff --git a/ability/ability_runtime/actssupportfunction/stageonandoffscreen/entry/src/main/module.json b/ability/ability_runtime/actssupportfunction/stageonandoffscreen/entry/src/main/module.json index beea295e0f48bebbea24fc6335d3ddcf8809d5b4..29364789c7bb09a6b0a0ae895000d1a7ca81a126 100644 --- a/ability/ability_runtime/actssupportfunction/stageonandoffscreen/entry/src/main/module.json +++ b/ability/ability_runtime/actssupportfunction/stageonandoffscreen/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/actssupportfunction/stagesupportfunction/entry/src/main/module.json b/ability/ability_runtime/actssupportfunction/stagesupportfunction/entry/src/main/module.json index fd3799416ce086806f54dae11a522f3c0170b9e0..46e186a731875aa67405243b3af36661798f388f 100644 --- a/ability/ability_runtime/actssupportfunction/stagesupportfunction/entry/src/main/module.json +++ b/ability/ability_runtime/actssupportfunction/stagesupportfunction/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "skills": [ diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/FormHost.test.ets b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/FormHost.test.ets index 85f21a189c18e65c773f9aa2ed417bf81f1f6818..185b1b541d562fcdefb293365bfca7f94ed1d020 100644 --- a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/FormHost.test.ets +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/FormHost.test.ets @@ -905,7 +905,8 @@ export default function formHostTest() { let TAG = 'System_API_Test_Form_Host_3500'; try { let formId = "1337079774"; - formHost.shareForm(formId, null, (error, data) => { + let deviceId = "12400633174999288"; + formHost.shareForm(formId, deviceId, (error, data) => { if (error) { console.log(TAG + ' formHost shareForm, error:' + JSON.stringify(error)); expect(error.code).assertEqual(ERROR_CODE); @@ -929,8 +930,9 @@ export default function formHostTest() { */ it('System_API_Test_Form_Host_3600',0, async function (done) { let TAG = 'System_API_Test_Form_Host_3600'; - let formId = "12400633174999288"; - formHost.shareForm(formId, null) + let formId = "1337079774"; + let deviceId = "12400633174999288"; + formHost.shareForm(formId, deviceId) .then(() => { expect().assertFail(); done(); diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/module.json b/ability/ability_runtime/actssystemapitest/entry/src/main/module.json index f737641a3b1559e7c64a66f1efb68309f23df16a..4bb7fcdcb96b29347476c4edd9a85308673bafc4 100644 --- a/ability/ability_runtime/actssystemapitest/entry/src/main/module.json +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersApi7AppA/entry/src/main/config.json b/ability/ability_runtime/actsusers/ActsAmsUsersApi7AppA/entry/src/main/config.json index 4967aad915912c8765ab05f293ce689c7f6a0ea8..e81dff987f3739c781a5fdd6551d11f2c773ad8f 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersApi7AppA/entry/src/main/config.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersApi7AppA/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.1.1" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 9 } }, diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/module.json b/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/module.json index 9379d6be57731bdf237090b39f3214471960eefe..291e725ae2ea792dad3da578a7519bcbc23f6a2d 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/module.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppA/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.killprocesshap.MainAbility", diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/module.json b/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/module.json index 4c0f769d9cce9fc77350d241db82b7deb03cb443..700cb43c9e2283e50f98bb4acb7fb866a6494869 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/module.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppB/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.killprocessthirdhap.MainAbility", diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/module.json b/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/module.json index 3e3ea6c85d34d6a2730d4749617138e0f48f679b..7129daf9b03c1a7fcbdb601c140478746b07cf8a 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/module.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppC/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.killprocessthirdhap2.MainAbility", diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets index f430fd1b6e86921bc66a233cdc64164b1c51c54d..40f48bf026eea0b1d19909cbfa28790de7a50f49 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets @@ -388,111 +388,6 @@ export default function abilityTest() { }) - /* - * @tc.number : ACTS_startAbility_3000 - * @tc.name : start new ability - * @tc.desc : Start an ability with the parameter startability with options succeeded.(promise) - */ - it('ACTS_startAbility_3000', 0, async function (done) { - let TAG = 'ACTS_startAbility_3000' - let Subscriber - var flag = true - var startresult = false - function SubscribeCallBack (err, data) { - expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); - console.debug(TAG + "====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ - startresult = true - } - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); - } - commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { - console.debug(TAG + "====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ - console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); - Subscriber = data; - commonEvent.subscribe(Subscriber, SubscribeCallBack); - console.debug(TAG + "====>start startAbility====>"); - await globalThis.abilityContext.startAbility( - { - bundleName: 'com.example.userservicesystemapi7', - abilityName: 'com.example.userservicesystemapi7.ServiceAbility' - }).then(()=>{ - console.debug(TAG + "====>startAbility end====>"); - }) - }) - }) - - function UnSubscribeCallback() { - console.debug(TAG + "====>UnSubscribeCallback====>"); - flag = false - expect(startresult).assertEqual(true); - done(); - } - - function timeout() { - if(flag == true) { - expect().assertFail(); - console.debug(TAG + 'ACTS_startAbility_3000 - timeout'); - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) - } - } - - setTimeout(timeout, START_ABILITY_TIMEOUT); - }) - /* - * @tc.number : ACTS_startAbility_3100 - * @tc.name : start new ability - * @tc.desc : Start an ability with the parameter startability with options succeeded.(promise) - */ - it('ACTS_startAbility_3100', 0, async function (done) { - let TAG = 'ACTS_startAbility_3100' - let Subscriber - var flag = true - var startresult = false - function SubscribeCallBack (err, data) { - expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); - console.debug(TAG + "====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ - startresult = true - } - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); - } - commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { - console.debug(TAG + "====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ - console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); - Subscriber = data; - commonEvent.subscribe(Subscriber, SubscribeCallBack); - console.debug(TAG + "====>start startAbility====>"); - await globalThis.abilityContext.startAbility( - { - bundleName: 'com.example.userservicesystemapi7', - abilityName: 'com.example.userservicesystemapi7.ServiceAbility' - },()=>{ - console.debug(TAG + "====>startAbility end====>"); - }) - }) - }) - - function UnSubscribeCallback() { - console.debug(TAG + "====>UnSubscribeCallback====>"); - flag = false - expect(startresult).assertEqual(true); - done(); - } - - function timeout() { - if(flag == true) { - expect().assertFail(); - console.debug(TAG + 'ACTS_startAbility_3100 - timeout'); - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) - } - } - - setTimeout(timeout, START_ABILITY_TIMEOUT); - }) - /* * @tc.number : ACTS_StartAbilityForResult_0100 * @tc.name : start new ability for result diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/module.json b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/module.json index a2aab205623dcfced0e7474f2413c8ac436e14f1..29178e0d6fdf714981fcfc31533806c5474f0a70 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/module.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/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.actsinterfacemultiuserstest.MainAbility", @@ -80,6 +86,10 @@ { "name": "ohos.permission.GET_RUNNING_INFO", "reason": "need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ] } diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/signature/openharmony_sx.p7b b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/signature/openharmony_sx.p7b index b181c98738527ac0d1676a50ebfb0e318f024c3d..7e2d2e9f7262ec2cf9cb091689ab4b64c460a250 100644 Binary files a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/signature/openharmony_sx.p7b and b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/BUILD.gn b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/BUILD.gn index b4e59886110a0ff53f131570cd6873c7d897f2fd..1d16f55bb73223cd15f8ea3b2c08afd6a4987437 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/BUILD.gn +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/BUILD.gn @@ -21,7 +21,7 @@ ohos_js_hap_suite("ActsAmsUsersThirdTest") { ":actsamsusersthirdtest_resources", ] ets2abc = true - certificate_profile = "signature/openharmony_sx_thirdparty.p7b" + certificate_profile = "signature/openharmony_sx.p7b" hap_name = "ActsAmsUsersThirdTest" subsystem_name = "ability" part_name = "ability_runtime" diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/module.json b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/module.json index a738bf267f4b49a242293a6c88aa77eba71684ca..aeb94d6db7d17625092525df95ffc03e03eec14a 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/module.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/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.actsinterfacemultiusersthirdtest.MainAbility", @@ -51,6 +57,12 @@ "visible": true, "orientation": "portrait" } + ], + "requestPermissions": [ + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" + } ] } } diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/signature/openharmony_sx.p7b b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..b8c098e1bc65a06a34e961501d5147ba51965cde Binary files /dev/null and b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/AppScope/app.json b/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/AppScope/app.json index 7504f565bdea43a23f545c402bf38a742eaaa505..74eef94bde981683b7f6e1480327ced80699f269 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/AppScope/app.json +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/AppScope/app.json @@ -1,6 +1,6 @@ { "app":{ - "bundleName":"com.example.staticabilitystagecontext", + "bundleName":"com.acts.stabilitystagecontext", "vendor":"huawei", "versionCode":1000000, "versionName":"1.0.0", diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/Test.json b/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/Test.json index 09fbd946a224a5675b834cadf2727b3c1ea2fa87..11e8d930b789e892f498d9cfc8d71fc9bc7d0216 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/Test.json +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/Test.json @@ -3,8 +3,8 @@ "driver": { "type": "OHJSUnitTest", "test-timeout": "180000", - "bundle-name": "com.example.staticabilitystagecontext", - "module-name": "com.example.staticabilitystagecontext", + "bundle-name": "com.acts.stabilitystagecontext", + "module-name": "com.acts.stabilitystagecontext", "shell-timeout": "600000", "testcase-timeout": 70000 }, diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts index 43765bb9327697af0d211120aaaf7bbc6dd24b04..863fc0ea8381b92aaf50114ea25bbb664d4b7120 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -59,7 +59,7 @@ export default class OpenHarmonyTestRunner implements TestRunner { onAbilityCreate: onAbilityCreateCallback, }; abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) - var cmd = 'aa start -d 0 -a com.example.staticabilitystagecontext.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + var cmd = 'aa start -d 0 -a com.acts.stabilitystagecontext.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) var debug = abilityDelegatorArguments.parameters["-D"] if (debug == 'true') diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/test/Ability.test.ets index ab37bc1fca14008f0ed803d5d50f70a2d16c7923..ef2f70f4c6459c805be1173a8753cdd3b1c80a0d 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/test/Ability.test.ets @@ -91,7 +91,7 @@ export default function abilityTest() { expect(typeof (data.removable)).assertEqual("boolean"); console.log("checkApplicationInfo_expect_typeof_end") - expect(data.name).assertEqual("com.example.staticabilitystagecontext"); + expect(data.name).assertEqual("com.acts.stabilitystagecontext"); expect(data.description).assertEqual("$string:description_application"); expect(data.descriptionId).assertLarger(0); expect(data.systemApp).assertEqual(true); @@ -100,12 +100,12 @@ export default function abilityTest() { expect(data.labelId.length).assertLarger(0); expect(data.icon).assertEqual("$media:icon"); expect(data.iconId.length).assertLarger(0); - expect(data.process).assertEqual("com.example.staticabilitystagecontext"); + expect(data.process).assertEqual("com.acts.stabilitystagecontext"); expect(data.supportedModes).assertEqual(0); expect(data.moduleInfos.length).assertEqual(1); - expect(data.moduleInfos[0].moduleName).assertEqual("com.example.staticabilitystagecontext"); + expect(data.moduleInfos[0].moduleName).assertEqual("com.acts.stabilitystagecontext"); expect(data.codePath).assertEqual("/data/app/el1/bundle/public/" + - "com.example.staticabilitystagecontext"); + "com.acts.stabilitystagecontext"); expect(data.removable).assertEqual(true); console.log("checkApplicationInfo end " + data); } @@ -145,7 +145,7 @@ export default function abilityTest() { expect(typeof (data.moduleName)).assertEqual("string"); expect(typeof (data.mainAbilityName)).assertEqual("string"); console.log("checkHapModuleInfo_expect_typeof_end") - expect(data.name).assertEqual("com.example.staticabilitystagecontext"); + expect(data.name).assertEqual("com.acts.stabilitystagecontext"); expect(data.description).assertEqual("$string:phone_entry_dsc"); expect(data.descriptionId).assertEqual(16777221); expect(data.icon).assertEqual("$media:icon"); @@ -157,10 +157,10 @@ export default function abilityTest() { expect(data.reqCapabilities.length).assertEqual(0); expect(data.deviceTypes.length).assertEqual(2); expect(data.deviceTypes[0]).assertEqual("default"); - expect(data.moduleName).assertEqual("com.example.staticabilitystagecontext") - expect(data.mainAbilityName).assertEqual("com.example.staticabilitystagecontext.MainAbility"); + expect(data.moduleName).assertEqual("com.acts.stabilitystagecontext") + expect(data.mainAbilityName).assertEqual("com.acts.stabilitystagecontext.MainAbility"); expect(data.installationFree).assertEqual(false); - expect(data.mainElementName).assertEqual('com.example.staticabilitystagecontext.MainAbility'); + expect(data.mainElementName).assertEqual('com.acts.stabilitystagecontext.MainAbility'); expect(data.hashValue).assertEqual(''); console.log("checkHapModuleInfo end " + data); } diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/module.json b/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/module.json index d07906ec98f383d5371708cf07860f67ec237167..33a5adb80b52d00cf6ed5b1592bc5014d6f1b17c 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/module.json +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/module.json @@ -1,10 +1,10 @@ { "module": { - "name": "com.example.staticabilitystagecontext", + "name": "com.acts.stabilitystagecontext", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", "description": "$string:phone_entry_dsc", - "mainElement": "com.example.staticabilitystagecontext.MainAbility", + "mainElement": "com.acts.stabilitystagecontext.MainAbility", "deviceTypes": [ "default", "tablet" @@ -13,9 +13,15 @@ "installationFree": false, "uiSyntax": "ets", "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { - "name": "com.example.staticabilitystagecontext.MainAbility", + "name": "com.acts.stabilitystagecontext.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", "description": "$string:phone_entry_main", "icon": "$media:icon", diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/signature/openharmony_sx.p7b b/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/signature/openharmony_sx.p7b index 129159f1bc10760100629e656549cd64c008e54c..6d1436e4b1f202b81231b087f3c628aedb408a0e 100644 Binary files a/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/signature/openharmony_sx.p7b and b/ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/AppScope/app.json b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/AppScope/app.json index eaefec3d4bbe202c7991216cb6f4c4a19f55d8a7..bb130accff84ea3af8aea3d832283ff7e722e876 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/AppScope/app.json +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/AppScope/app.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.example.staticinformationmultihappackage", + "bundleName": "com.acts.stinformationmulapp", "vendor": "huawei", "versionCode": 1000000, "versionName": "1.0.0", diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/MainAbility/MainAbility.ts index 53a58cda859a860c09acbf6df8202fea84709979..0fd3611820e2ebd479ab55ca126948ad892071c6 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/MainAbility/MainAbility.ts @@ -44,7 +44,7 @@ export default class MainAbility extends Ability { console.log("ACTS_getAbilityInfo_0400 MainAbility onForeground") if (globalThis.abilityWant.action == 'startHapA') { globalThis.abilityContext.startAbility({ - bundleName: "com.example.staticinformationmultihappackage", + bundleName: "com.acts.stinformationmulapp", abilityName: "com.example.feature.MainAbility", action: "startHapB" }, (error, data) => { diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/entry/src/main/module.json b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/entry/src/main/module.json index abb7c71e70896b375f829b1ce2da38b8ae818b06..39bc1f167a1343406e20f7b9e9a934dc6d499682 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/entry/src/main/module.json +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/entry/src/main/module.json @@ -1,6 +1,6 @@ { "module": { - "name": "com.example.staticinformationmultihappackage", + "name": "com.acts.stinformationmulapp", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", "description": "$string:phone_entry_dsc", @@ -13,9 +13,15 @@ "installationFree": false, "uiSyntax": "ets", "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { - "name": "com.example.staticinformationmultihappackage.MainAbility", + "name": "com.acts.stinformationmulapp.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", "description": "$string:phone_entry_main", "icon": "$media:icon", diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/signature/openharmony_sx.p7b b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/signature/openharmony_sx.p7b index b7bac195276833f75df9e88f11526507e6b813af..0e59575f124446c7fb0c73f12a73caf88d6e1b8c 100644 Binary files a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/signature/openharmony_sx.p7b and b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapa/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapb/AppScope/app.json b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapb/AppScope/app.json index eaefec3d4bbe202c7991216cb6f4c4a19f55d8a7..bb130accff84ea3af8aea3d832283ff7e722e876 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapb/AppScope/app.json +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapb/AppScope/app.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.example.staticinformationmultihappackage", + "bundleName": "com.acts.stinformationmulapp", "vendor": "huawei", "versionCode": 1000000, "versionName": "1.0.0", diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapb/entry/src/main/module.json b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapb/entry/src/main/module.json index 17e5e428d35f3ec2c1f797888bb87b40ea799371..fbf1caacd31339563d97c2f3fda52c3a389079b6 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapb/entry/src/main/module.json +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapb/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.example.feature.MainAbility", diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapb/signature/openharmony_sx.p7b b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapb/signature/openharmony_sx.p7b index b7bac195276833f75df9e88f11526507e6b813af..0e59575f124446c7fb0c73f12a73caf88d6e1b8c 100644 Binary files a/ability/ability_runtime/amscontextualinforquery/actsamsstatichapb/signature/openharmony_sx.p7b and b/ability/ability_runtime/amscontextualinforquery/actsamsstatichapb/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/AppScope/app.json b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/AppScope/app.json index 2c629769e8ba2edb6a25e494a46a8a2f9245e20c..6ce7d4f9655f23c6928ba58e5d8a10331909cc58 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/AppScope/app.json +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/AppScope/app.json @@ -1,6 +1,6 @@ { "app":{ - "bundleName":"com.example.staticinfomationquery", + "bundleName":"com.acts.staticinfomationquery", "vendor":"huawei", "versionCode":1000000, "versionName":"1.0.0", diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/Test.json b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/Test.json index 5847669645bbd40456caa14bd870b969aeced378..ff225b0321b689a0c2b8711f193a7c561109e9e6 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/Test.json +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/Test.json @@ -3,8 +3,8 @@ "driver": { "type": "OHJSUnitTest", "test-timeout": "300000", - "bundle-name": "com.example.staticinfomationquery", - "module-name": "com.example.staticinfomationquery", + "bundle-name": "com.acts.staticinfomationquery", + "module-name": "com.acts.staticinfomationquery", "shell-timeout": "600000", "testcase-timeout": 70000 }, diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts index fe265c085ef0098936b09e12b83fde1f48eb48c1..e3191851685c2b27eca6a349ab51a3cdd30abd8a 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -59,7 +59,7 @@ export default class OpenHarmonyTestRunner implements TestRunner { onAbilityCreate: onAbilityCreateCallback, }; abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) - var cmd = 'aa start -d 0 -a com.example.staticinfomationquery.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + var cmd = 'aa start -d 0 -a com.acts.staticinfomationquery.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) var debug = abilityDelegatorArguments.parameters["-D"] if (debug == 'true') diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/test/Ability.test.ets index f8f8ce49b07299e15fd5ef16d6d13cf1dee43da8..6321f5698f401d9156ffd9b36fe375f5df525f91 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/test/Ability.test.ets @@ -193,15 +193,15 @@ export default function abilityTest() { expect(typeof (data.defaultFormWidth)).assertEqual("number"); expect(typeof (data.uri)).assertEqual("string"); - expect(data.bundleName).assertEqual("com.example.staticinfomationquery"); - expect(data.name).assertEqual("com.example.staticinfomationquery.MainAbility"); + expect(data.bundleName).assertEqual("com.acts.staticinfomationquery"); + expect(data.name).assertEqual("com.acts.staticinfomationquery.MainAbility"); expect(data.label).assertEqual("$string:entry_label"); expect(data.description).assertEqual("$string:phone_entry_main"); expect(data.icon).assertEqual("$media:icon"); expect(data.labelId).assertLarger(0); expect(data.descriptionId).assertLarger(0); expect(data.iconId).assertLarger(0); - expect(data.moduleName).assertEqual("com.example.staticinfomationquery"); + expect(data.moduleName).assertEqual("com.acts.staticinfomationquery"); expect(data.process).assertEqual(""); expect(data.targetAbility).assertEqual(""); expect(data.backgroundModes).assertEqual(0); @@ -275,7 +275,7 @@ export default function abilityTest() { expect(typeof (data.codePath)).assertEqual("string"); expect(typeof (data.removable)).assertEqual("boolean"); console.log("checkApplicationInfo_expect_typeof_end") - expect(data.name).assertEqual("com.example.staticinfomationquery"); + expect(data.name).assertEqual("com.acts.staticinfomationquery"); expect(data.description).assertEqual("$string:description_application"); expect(data.descriptionId).assertLarger(0); expect(data.systemApp).assertEqual(true); @@ -284,11 +284,11 @@ export default function abilityTest() { expect(data.labelId.length).assertLarger(0); expect(data.icon).assertEqual("$media:icon"); expect(data.iconId.length).assertLarger(0); - expect(data.process).assertEqual("com.example.staticinfomationquery"); + expect(data.process).assertEqual("com.acts.staticinfomationquery"); expect(data.supportedModes).assertEqual(0); expect(data.moduleInfos.length).assertEqual(1); - expect(data.moduleInfos[0].moduleName).assertEqual("com.example.staticinfomationquery"); - expect(data.codePath).assertEqual("/data/app/el1/bundle/public/com.example.staticinfomationquery") + expect(data.moduleInfos[0].moduleName).assertEqual("com.acts.staticinfomationquery"); + expect(data.codePath).assertEqual("/data/app/el1/bundle/public/com.acts.staticinfomationquery") expect(data.removable).assertEqual(true); console.log("checkApplicationInfo end " + data); } @@ -329,7 +329,7 @@ export default function abilityTest() { expect(typeof (data.moduleName)).assertEqual("string"); expect(typeof (data.mainAbilityName)).assertEqual("string"); console.log("checkHapModuleInfo_expect_typeof_end") - expect(data.name).assertEqual("com.example.staticinfomationquery"); + expect(data.name).assertEqual("com.acts.staticinfomationquery"); expect(data.description).assertEqual("$string:phone_entry_dsc"); expect(data.descriptionId).assertEqual(16777221); expect(data.icon).assertEqual("$media:icon"); @@ -341,10 +341,10 @@ export default function abilityTest() { expect(data.reqCapabilities.length).assertEqual(0); expect(data.deviceTypes.length).assertEqual(2); expect(data.deviceTypes[0]).assertEqual("default"); - expect(data.moduleName).assertEqual("com.example.staticinfomationquery") - expect(data.mainAbilityName).assertEqual("com.example.staticinfomationquery.MainAbility"); + expect(data.moduleName).assertEqual("com.acts.staticinfomationquery") + expect(data.mainAbilityName).assertEqual("com.acts.staticinfomationquery.MainAbility"); expect(data.installationFree).assertEqual(false); - expect(data.mainElementName).assertEqual('com.example.staticinfomationquery.MainAbility'); + expect(data.mainElementName).assertEqual('com.acts.staticinfomationquery.MainAbility'); expect(data.hashValue).assertEqual(''); console.log("checkHapModuleInfo end " + data); } diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/module.json b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/module.json index 9f169ffcfa46a6ae4d82de7771a984a3f0688ef4..960b71f7b411943967a1af807a87e80c23a2bb0f 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/module.json +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/module.json @@ -1,10 +1,10 @@ { "module": { - "name": "com.example.staticinfomationquery", + "name": "com.acts.staticinfomationquery", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", "description": "$string:phone_entry_dsc", - "mainElement": "com.example.staticinfomationquery.MainAbility", + "mainElement": "com.acts.staticinfomationquery.MainAbility", "deviceTypes": [ "default", "tablet" @@ -13,9 +13,15 @@ "installationFree": false, "uiSyntax": "ets", "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { - "name": "com.example.staticinfomationquery.MainAbility", + "name": "com.acts.staticinfomationquery.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", "description": "$string:phone_entry_main", "icon": "$media:icon", diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/signature/openharmony_sx.p7b b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/signature/openharmony_sx.p7b index 1a5303991111ebd68235f9230dcfac6f5f46da82..31f212d10eefd8ba9a5eaa1019a23b84f84d58a6 100644 Binary files a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/signature/openharmony_sx.p7b and b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/test/Ability.test.ets index a0f82d4c5152aeb361da4518dc14398716056ff9..40aaa78800b4dd5057bb579157fbd4e75045ce4e 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/test/Ability.test.ets @@ -76,9 +76,9 @@ export default function abilityTest() { console.log("ACTS_getAbilityInfo_0500_feature_abilityInfo" + abilityInfo1.name) console.log("ACTS_getAbilityInfo_0500_feature_applicationInfo" + applicationInfo1.name) console.log("ACTS_getAbilityInfo_0500_feature_hapModuleInfo" + hapModuleInfo1.name) - expect(abilityInfo1.name).assertEqual("com.example.staticinformationmultihappackage.MainAbility"); - expect(applicationInfo1.name).assertEqual("com.example.staticinformationmultihappackage"); - expect(hapModuleInfo1.name).assertEqual("com.example.staticinformationmultihappackage"); + expect(abilityInfo1.name).assertEqual("com.acts.stinformationmulapp.MainAbility"); + expect(applicationInfo1.name).assertEqual("com.acts.stinformationmulapp"); + expect(hapModuleInfo1.name).assertEqual("com.acts.stinformationmulapp"); } if(EntryHap && FeatureHap){ commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/module.json b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/module.json index e03d892786f2efb92a808af8626f88d03d689fb0..de80c0ed548b99c055d78f027709db10c29c30c3 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/module.json +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/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.example.staticinformationmultiple.MainAbility", diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/test/Ability.test.ets index 96b50083a3f025abcbde389eda30c5d66c336e0b..2be9424b37ff2697ff2879ae1b12415837972e6b 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/test/Ability.test.ets @@ -36,8 +36,8 @@ export default function abilityTest() { var FeatureHap = false; globalThis.abilityContext.startAbility({ - bundleName: "com.example.staticinformationmultihappackage", - abilityName: "com.example.staticinformationmultihappackage.MainAbility", + bundleName: "com.acts.stinformationmulapp", + abilityName: "com.acts.stinformationmulapp.MainAbility", action:"startHapA" }, (error, data) => { console.log('ACTS_getAbilityInfo_0400 - startAbility start HapA: ' @@ -64,9 +64,9 @@ export default function abilityTest() { console.log("ACTS_getAbilityInfo_0400_entry_abilityInfo" + abilityInfo.name) console.log("ACTS_getAbilityInfo_0400_entry_applicationInfo" + applicationInfo.name) console.log("ACTS_getAbilityInfo_0400_entry_hapModuleInfo" + hapModuleInfo.name) - expect(abilityInfo.name).assertEqual("com.example.staticinformationmultihappackage.MainAbility"); - expect(applicationInfo.name).assertEqual("com.example.staticinformationmultihappackage"); - expect(hapModuleInfo.name).assertEqual("com.example.staticinformationmultihappackage"); + expect(abilityInfo.name).assertEqual("com.acts.stinformationmulapp.MainAbility"); + expect(applicationInfo.name).assertEqual("com.acts.stinformationmulapp"); + expect(hapModuleInfo.name).assertEqual("com.acts.stinformationmulapp"); } else if (data.event == 'MainAbility_Start_CommonEvent_multi_hap_feature'){ FeatureHap = true; console.log("ACTS_getAbilityInfo_0400====> MainAbility_Start_CommonEvent_multi_hap_feature") @@ -77,7 +77,7 @@ export default function abilityTest() { console.log("ACTS_getAbilityInfo_0400_feature_applicationInfo" + applicationInfo1.name) console.log("ACTS_getAbilityInfo_0400_feature_hapModuleInfo" + hapModuleInfo1.name) expect(abilityInfo1.name).assertEqual("com.example.feature.MainAbility"); - expect(applicationInfo1.name).assertEqual("com.example.staticinformationmultihappackage"); + expect(applicationInfo1.name).assertEqual("com.acts.stinformationmulapp"); expect(hapModuleInfo1.name).assertEqual("com.example.feature"); } if(EntryHap && FeatureHap){ diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/module.json b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/module.json index 840408536e6f7fcdf998599ad221a27a35fe358b..8145d8615c987c47ae322ad968820de8446e7c50 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/module.json +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/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.example.staticinformationmultihap.MainAbility", diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/MainAbility/MainAbility.ts index 243e393b9badad912b99fc0e9578033f158a5cf9..898a16855bcf98eef9790937a617ec2f2e20e904 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -67,8 +67,8 @@ export default class MainAbility extends Ability { if (globalThis.abilityWant.action == 'startmultiple') { globalThis.abilityContext.startAbility({ - bundleName: "com.example.staticinformationmultihappackage", - abilityName: "com.example.staticinformationmultihappackage.MainAbility", + bundleName: "com.acts.stinformationmulapp", + abilityName: "com.acts.stinformationmulapp.MainAbility", action: "multiple" }, (err, data) => { console.log('ACTS_getAbilityInfo_0500 MainAbility onForeground - startAbility restart singleton: ' diff --git a/ability/ability_runtime/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/module.json b/ability/ability_runtime/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/module.json index 80d69ecc80140ce1a781ba43e2b62b76e7f0f9ac..b20a52fe57227b7709d723240219e7277cb4ab31 100644 --- a/ability/ability_runtime/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/module.json +++ b/ability/ability_runtime/amscontextualinforquery/actsamsstaticquerytesttwohap/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.example.staticquerytesttwo.MainAbility", diff --git a/ability/ability_runtime/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/module.json b/ability/ability_runtime/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/module.json index e8e58308f17b4095b1cd060275e9f2ba8d34e665..e3dce422af667919476ac7af18e3078012a5429d 100644 --- a/ability/ability_runtime/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/module.json +++ b/ability/ability_runtime/amsdisplayIdtest/actsamsspecifytesthap/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.example.actsspecifytesthap.MainAbility", diff --git a/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/module.json b/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/module.json index 7032b6d078bd1158a3f2436ccd77b8bd64d71161..6b6db55e5a77d896e9d95fe3c777da546eac29d4 100644 --- a/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/module.json +++ b/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilityforresulttest/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.example.startabilityforresult.MainAbility", diff --git a/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/module.json b/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/module.json index 737b07832099ca394c53710c82194390e3d6c138..b3ed5d46a76328c9870fb1bc457e5863e5fa2963 100644 --- a/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/module.json +++ b/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/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.example.actsgetdisplayidtest.MainAbility", @@ -48,8 +54,8 @@ "reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" }, { - "name": "ohos.permission.MANAGE_MISSIONS", - "reason": "need use ohos.permission.MANAGE_MISSIONS" + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ] } diff --git a/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/signature/openharmony_sx.p7b b/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/signature/openharmony_sx.p7b index 4628524a22dfbba03b4eb4dfc1c882448ad44fcc..c134de23a78697b218d181a0f98396e732db324b 100644 Binary files a/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/signature/openharmony_sx.p7b and b/ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ApiCoverAbility.test.ets b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ApiCoverAbility.test.ets index 7d29e62bbc00c52a2247280c27832b1cd642210e..ab40853cc34740e1d4d5a80b56911f41dac0b783 100644 --- a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ApiCoverAbility.test.ets +++ b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/ets/test/ApiCoverAbility.test.ets @@ -27,6 +27,7 @@ import commonEvent from '@ohos.commonEvent'; import ability from '@ohos.ability.ability'; import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; import common from '@ohos.app.ability.common'; +import contextConstant from "@ohos.app.ability.contextConstant" var EXTENSION_INFO_ERR = 16000001 var INNER_ERROR = 16000050 @@ -313,22 +314,19 @@ export default function ApiCoverTest() { */ it('SUB_AA_ABILITY_Extension_API_012', 0, async function (done) { try { - let info: appManagerNew.ProcessRunningInfo; + let info: appManagerNew.ProcessInformation; let stageContext: common.AbilityStageContext = globalThis.stageContext; let abilityContext: common.UIAbilityContext = globalThis.abilityContext; let appContext: common.ApplicationContext = abilityContext.getApplicationContext(); let baseContext: common.BaseContext = stageContext; let context: common.Context = stageContext; - let el1 = common.AreaMode.EL1; - let el2 = common.AreaMode.EL2; + let el1 = contextConstant.AreaMode.EL1; + let el2 = contextConstant.AreaMode.EL2; let eventHub: common.EventHub = context.eventHub; let abilityResult: common.AbilityResult; let connectOptions: common.ConnectOptions; - appContext.killProcessesBySelf(); - appContext.killProcessesBySelf((err, data) => { - console.log(`killProcessesBySelf, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`); - }) + console.log("killAllProcesses:" + JSON.stringify(appContext.killAllProcesses)); let abilityDelegator: abilityDelegatorRegistry.AbilityDelegator; abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); let abilityDelegatorArgs: abilityDelegatorRegistry.AbilityDelegatorArgs; diff --git a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/module.json b/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/module.json index 5b17c8d11d83cde54e1e815265542092b6d5e33d..3578f778572265687168b87387f1587cd430c20e 100644 --- a/ability/ability_runtime/apicover/apicoverhaptest/entry/src/main/module.json +++ b/ability/ability_runtime/apicover/apicoverhaptest/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.apicoverhaptest.MainAbility", @@ -100,6 +106,10 @@ { "name": "ohos.permission.GET_RUNNING_INFO", "reason": "need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ] } diff --git a/ability/ability_runtime/apicover/apicoverhaptest/signature/openharmony_sx.p7b b/ability/ability_runtime/apicover/apicoverhaptest/signature/openharmony_sx.p7b index b177620035b2636cd30b5d4b88e06f0938dd177d..d45e639b97f6645a0ce7c3dbe07b85c086596a59 100644 Binary files a/ability/ability_runtime/apicover/apicoverhaptest/signature/openharmony_sx.p7b and b/ability/ability_runtime/apicover/apicoverhaptest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/apicover/fasupplement/entry/src/main/config.json b/ability/ability_runtime/apicover/fasupplement/entry/src/main/config.json index 74c27a58f83bac2da564c172d738293be1e2f109..075c74bb414ce7a40583a88e2199bdbed1b33322 100644 --- a/ability/ability_runtime/apicover/fasupplement/entry/src/main/config.json +++ b/ability/ability_runtime/apicover/fasupplement/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 9 } }, diff --git a/ability/ability_runtime/apicover/formmodule/entry/src/main/module.json b/ability/ability_runtime/apicover/formmodule/entry/src/main/module.json index fa1ed60eb7b1d0277c786da60e5aad75d4654459..c0ec9831ae4bc69bb7d8271c20ad88bdc0ffeb2b 100644 --- a/ability/ability_runtime/apicover/formmodule/entry/src/main/module.json +++ b/ability/ability_runtime/apicover/formmodule/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "ModuleAbility", diff --git a/ability/ability_runtime/apicover/stagesupplement/entry/src/main/module.json b/ability/ability_runtime/apicover/stagesupplement/entry/src/main/module.json index cc933bdfa5efb7e675870772ca94edd03627ff63..ee81691167bff995c7ee9dffff1ec5f1a6bf2f5e 100644 --- a/ability/ability_runtime/apicover/stagesupplement/entry/src/main/module.json +++ b/ability/ability_runtime/apicover/stagesupplement/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/apitest/entry/src/main/module.json b/ability/ability_runtime/apitest/entry/src/main/module.json index f8424d2ab518bdc9d411de3d3e354a1bcbd0bd9d..39b741016f48616254a2429389dd9f39ad74b403 100644 --- a/ability/ability_runtime/apitest/entry/src/main/module.json +++ b/ability/ability_runtime/apitest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/context/actscreatemodulecontextassist/entry/src/main/module.json b/ability/ability_runtime/context/actscreatemodulecontextassist/entry/src/main/module.json index 061b933246f5f7860797eeab386cec878436c174..9f57a16b1280f0060651cdb66d680da4cc37375f 100644 --- a/ability/ability_runtime/context/actscreatemodulecontextassist/entry/src/main/module.json +++ b/ability/ability_runtime/context/actscreatemodulecontextassist/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/context/actscreatemodulecontextassistone/entry/src/main/module.json b/ability/ability_runtime/context/actscreatemodulecontextassistone/entry/src/main/module.json index e5642d1eff72e9f29357d10f88497e49e77ee87f..1b962e5099c0b1a434b1fa31232be96e838dee0f 100644 --- a/ability/ability_runtime/context/actscreatemodulecontextassistone/entry/src/main/module.json +++ b/ability/ability_runtime/context/actscreatemodulecontextassistone/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/context/actscreatemodulecontexttest/entry/src/main/module.json b/ability/ability_runtime/context/actscreatemodulecontexttest/entry/src/main/module.json index 38120a8e141951a133e6cc5dc1ce02d2c65decd1..d69baa7b4156a880844dc7cffa2e0677c59218ce 100644 --- a/ability/ability_runtime/context/actscreatemodulecontexttest/entry/src/main/module.json +++ b/ability/ability_runtime/context/actscreatemodulecontexttest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/context/actsfacontexttest/entry/src/main/config.json b/ability/ability_runtime/context/actsfacontexttest/entry/src/main/config.json index 4b0c516cb4db28c751e816091bc2f0a475cd5759..1dfdeeddaf213153021f67a3989c3217332dcc3a 100644 --- a/ability/ability_runtime/context/actsfacontexttest/entry/src/main/config.json +++ b/ability/ability_runtime/context/actsfacontexttest/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "releaseType": "Release", "target": 9 } diff --git a/ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/module.json b/ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/module.json index 41a606908ab4c7e176a3b21d3b39692954578f89..e64d729fdf0bf03cc56850c2e56d698f3d1e1fcd 100644 --- a/ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/module.json +++ b/ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/context/actsstagecontext/actsstagecontextassistone/entry/src/main/module.json b/ability/ability_runtime/context/actsstagecontext/actsstagecontextassistone/entry/src/main/module.json index a6dae9dd13012243198601202fa5f1d05d0e7628..c509a45fa21dda93da494ed50bd05941ee1d21b7 100644 --- a/ability/ability_runtime/context/actsstagecontext/actsstagecontextassistone/entry/src/main/module.json +++ b/ability/ability_runtime/context/actsstagecontext/actsstagecontextassistone/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility3", diff --git a/ability/ability_runtime/context/actsstagecontext/actsstagecontextassisttwo/entry/src/main/module.json b/ability/ability_runtime/context/actsstagecontext/actsstagecontextassisttwo/entry/src/main/module.json index 6bacd2189ba6826efab70ce28cadae7f35cdb9d6..d21640721e69c2ea97bc24c6e4ee5b924e0ee439 100644 --- a/ability/ability_runtime/context/actsstagecontext/actsstagecontextassisttwo/entry/src/main/module.json +++ b/ability/ability_runtime/context/actsstagecontext/actsstagecontextassisttwo/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility4", diff --git a/ability/ability_runtime/context/actsstagecontext/actsstagecontextpropertiestest/entry/src/main/module.json b/ability/ability_runtime/context/actsstagecontext/actsstagecontextpropertiestest/entry/src/main/module.json index 18930cb5410f86e71e80171ec54afb5b1b2a88cd..36ce688b6dba454f4f0f07947ee90df47d7c802a 100644 --- a/ability/ability_runtime/context/actsstagecontext/actsstagecontextpropertiestest/entry/src/main/module.json +++ b/ability/ability_runtime/context/actsstagecontext/actsstagecontextpropertiestest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/context/actsstagecontexttest/entry/src/main/ets/test/ActsStageContextTest.test.ets b/ability/ability_runtime/context/actsstagecontexttest/entry/src/main/ets/test/ActsStageContextTest.test.ets index 2f859b6124bae665f6f2a923763620b31c6ef559..0abdfbd6d7e52fb8ac682e3337d43225c45a5ad3 100644 --- a/ability/ability_runtime/context/actsstagecontexttest/entry/src/main/ets/test/ActsStageContextTest.test.ets +++ b/ability/ability_runtime/context/actsstagecontexttest/entry/src/main/ets/test/ActsStageContextTest.test.ets @@ -149,43 +149,5 @@ export default function actsStageContextTest() { done() }) }) - - /* - * @tc.number : ACTS_StageContext_1500 - * @tc.name : get resource by Resource in applicationInfo from context(API8) - * @tc.desc : get resource by Resource in applicationInfo from context(API8) - */ - it('ACTS_StageContext_1500',0, async function (done) { - await bundleManager.getApplicationInfo("com.example.fa8_app", 0).then(appInfo => { - return globalThis.abilityContext.resourceManager.getString(appInfo.labelResource) - }).then(str => { - console.info("ACTS_StageContext_1500 labelId: " + str) - expect(str).assertEqual("fa8_app") - done() - }).catch(e => { - console.info("ACTS_StageContext_1500 error: " + e) - expect().assertFail() - done() - }) - }) - - /* - * @tc.number : ACTS_StageContext_2200 - * @tc.name : get resource by Resource in applicationInfo from context - * @tc.desc : get resource by Resource in applicationInfo from context - */ - it('ACTS_StageContext_2200',0, async function (done) { - await bundleManager.getApplicationInfo("com.example.contextapp", 0).then(appInfo => { - return globalThis.abilityContext.resourceManager.getString(appInfo.labelResource) - }).then(str => { - console.info("ACTS_StageContext_2200 labelId: " + str) - expect(str).assertEqual("ContextApp") - done() - }).catch(e => { - console.info("ACTS_StageContext_2200 error: " + e) - expect().assertFail() - done() - }) - }) }) } \ No newline at end of file diff --git a/ability/ability_runtime/context/actsstagecontexttest/entry/src/main/module.json b/ability/ability_runtime/context/actsstagecontexttest/entry/src/main/module.json index d5c701fff2d82010b07d4e68b25297d89458ec3e..9cd0332e2a5d983f2db78524aefd84686224f70b 100644 --- a/ability/ability_runtime/context/actsstagecontexttest/entry/src/main/module.json +++ b/ability/ability_runtime/context/actsstagecontexttest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/context/actsstagecontexttest/module1/src/main/module.json b/ability/ability_runtime/context/actsstagecontexttest/module1/src/main/module.json index c4ea19162fd395f4cfdb3ac20a6bc55de4c2619b..c6bf2ef23ebac89b68ea2b020d616858b470b20c 100644 --- a/ability/ability_runtime/context/actsstagecontexttest/module1/src/main/module.json +++ b/ability/ability_runtime/context/actsstagecontexttest/module1/src/main/module.json @@ -12,6 +12,12 @@ "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/context/scene/contextapp/entry/src/main/module.json b/ability/ability_runtime/context/scene/contextapp/entry/src/main/module.json index fea5678b5adf579a4d7af87cd6beac10e9f329a6..30ecf74d79ee441685f803418c262d715af66353 100644 --- a/ability/ability_runtime/context/scene/contextapp/entry/src/main/module.json +++ b/ability/ability_runtime/context/scene/contextapp/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/config.json b/ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/config.json index 3942892c9f9b3b3d35797d01261176f335736184..d8a03b1c63a5726a451d94529074e4874b0b46b4 100644 --- a/ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/config.json +++ b/ability/ability_runtime/faapicover/faapicoverhaptest/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 9 } }, diff --git a/ability/ability_runtime/faapicover/faauxiliary/entry/src/main/config.json b/ability/ability_runtime/faapicover/faauxiliary/entry/src/main/config.json index ee0129cff641bbfdcefeb1a24b80061bfc421311..e2baafcf214e6d522d00d52895752d3ded255630 100644 --- a/ability/ability_runtime/faapicover/faauxiliary/entry/src/main/config.json +++ b/ability/ability_runtime/faapicover/faauxiliary/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 9 } }, diff --git a/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/config.json b/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/config.json index 9b43e045bdefaa765fa78015596beaf3443e7c34..7e38f3a6294f79859a9681c47617b01045a60f2a 100644 --- a/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/config.json +++ b/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/config.json @@ -99,6 +99,10 @@ }, { "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ], "js": [ diff --git a/ability/ability_runtime/featureability/actsfeatureabilitytest/signature/openharmony_sx.p7b b/ability/ability_runtime/featureability/actsfeatureabilitytest/signature/openharmony_sx.p7b index 88852f74445028c3308fe52c59f0ac16b3b9f11c..adcaa07d7443a7a30a8a201fc5096b056126644d 100644 Binary files a/ability/ability_runtime/featureability/actsfeatureabilitytest/signature/openharmony_sx.p7b and b/ability/ability_runtime/featureability/actsfeatureabilitytest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationA/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationA/entry/src/main/config.json index 69885d738e957085e9d4adf536fef5871691a0ad..bd239c5307e9a2cda7a2cc825478390c27f86c70 100644 --- a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationA/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationA/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "releaseType": "Release", "target": 9 } diff --git a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationB/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationB/entry/src/main/config.json index 9032a309e7d2f6f7fadce75dacffaefa7e3a7ee6..f96b0701ea79899c0dafc7fd18e18100b3535c1b 100644 --- a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationB/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationB/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "releaseType": "Release", "target": 9 } diff --git a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationC/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationC/entry/src/main/config.json index 7bf45b785c06293eb8e5712add77f88d493fd404..fb8554bfd68208e2821f2b72a232a95ea60c817f 100644 --- a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationC/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationC/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "releaseType": "Release", "target": 9 } diff --git a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationD/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationD/entry/src/main/config.json index 06ebc4ce21e9b02c3243e4f306d0b9b3a0bcb8ba..ea410ede57007baec76febe9f3aa5bd91abba0c0 100644 --- a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationD/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationD/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "releaseType": "Release", "target": 9 } diff --git a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationE/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationE/entry/src/main/config.json index b1cb15545119c0b687f6b70010553686327b25a0..958e5ed3eadcc4bb0de61f04e6554ad233a569ea 100644 --- a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationE/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationE/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "releaseType": "Release", "target": 9 } diff --git a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationF/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationF/entry/src/main/config.json index 51e08615864fe1eacd74d1ff60fa9a40bf626f1d..9fee2ad4f6c4a688c913db547526243be56849e6 100644 --- a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationF/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationF/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "releaseType": "Release", "target": 9 } diff --git a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationG/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationG/entry/src/main/config.json index 98aa63406490681a9976853e354ffb4332da2469..07413320931860e09135b7cf813b96d4656db8d3 100644 --- a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationG/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationG/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "releaseType": "Release", "target": 9 } diff --git a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationH/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationH/entry/src/main/config.json index a0ab6decd0de8cd9a1886d31f2f0116bbe6587ab..c455132c5042d11e4ce489719c0a617fcdf1082b 100644 --- a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationH/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationH/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "releaseType": "Release", "target": 9 } diff --git a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/config.json index 7a5c96d008f32d9cf7f6c601eeaf327b6f545d9d..0205a204cd87ebace020903e0c6247926f524d63 100644 --- a/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formproviderst_ets/formsupplyapplicationNotSysApp/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "releaseType": "Release", "target": 9 } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/config.json index 7867a7fafa5080db314f160d7b4a3d30d5961f23..e2a9011cb8f0b666d6fddbe94aa2067499b86016 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/entry/src/main/config.json @@ -118,6 +118,10 @@ { "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ], "js": [ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/signature/openharmony_sx.p7b b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/signature/openharmony_sx.p7b index be524e3fc21d1a06eb9cae826617176ffaf91fed..54c0439dbbc9a5abd676733739e7e0f181c9fdf5 100644 Binary files a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/signature/openharmony_sx.p7b and b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/config.json index 0482f7248173dbac04bc1ee803e722c7d435ed13..755b2bcf5f6c37e2c2840359a131e149dd69feb3 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/entry/src/main/config.json @@ -118,6 +118,10 @@ { "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ], "js": [ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/signature/openharmony_sx.p7b b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/signature/openharmony_sx.p7b index 2ec8367d22862ff39e434b3bc37530465b9cee15..8b9089b1d8832b0bba57185626e070d387a04190 100644 Binary files a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/signature/openharmony_sx.p7b and b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formacquiretest2/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/config.json index 7c5b8623ce04b2e0fe25c4e6e40a1f880f8951e8..fb1cf985fa78bec754775d5f60dae763366ad181 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/entry/src/main/config.json @@ -136,6 +136,10 @@ { "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ], "js": [ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/signature/openharmony_sx.p7b b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/signature/openharmony_sx.p7b index 2019a0fac22fdc7caf6bad99dd5ffd0b10279f48..dc9c933dab99cb66b131c474f0fcef599ad53da1 100644 Binary files a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/signature/openharmony_sx.p7b and b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdeletetest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/config.json index 1bebae8113cdcf342e2ffa1264b00aadee8bbe16..7b8ada74a1d9798df8c2eddd10ac511bd88c1cfa 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/entry/src/main/config.json @@ -117,6 +117,10 @@ { "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ], "js": [ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/signature/openharmony_sx.p7b b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/signature/openharmony_sx.p7b index 9cdfa1437599eb92aa45ce33692591848d83440f..787c4134ba5d5bcd7962df41fb7dd5162da55daf 100644 Binary files a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/signature/openharmony_sx.p7b and b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formdynamicrefreshtest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/config.json index 4c22e2f1c2790ef4ac59e543966be5ed50f56f6b..8508ae97cb5d5a9a2dd9b9f2bcc6276895a07d37 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formfuzztest/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "releaseType": "Release", "target": 9 } diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/config.json index 30add8ca7cec1aa314b407b71e9fb283f7b0d353..a27bd1b3364829e7e3cdc9bb8dfe375127cded15 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/entry/src/main/config.json @@ -125,6 +125,10 @@ { "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ], "js": [ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/signature/openharmony_sx.p7b b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/signature/openharmony_sx.p7b index bd0b2bbf78f222383db4a9e1391f30b0168d58a1..e0f6d7352af38054d98e1c4c32e1760eb07a8158 100644 Binary files a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/signature/openharmony_sx.p7b and b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formreleasetest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/config.json index 22d8f9f55ac23617e988cf479e378dc51aba985e..dae1470e88d59e57c31204d0ae5556518eb04c29 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/entry/src/main/config.json @@ -127,6 +127,10 @@ { "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ], "js": [ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/signature/openharmony_sx.p7b b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/signature/openharmony_sx.p7b index ad15c6e8c8bf9f77a759ddc020240a02b60c37c8..8674932ebb4741d16905b341b10350ff4a5ebd8d 100644 Binary files a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/signature/openharmony_sx.p7b and b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_disable/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/config.json index 49c25833e5168d4e1197c094d21eb17f119019fb..2116fcfe512bdb9341c1a46bc2e6d8b6da7ef0bc 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/entry/src/main/config.json @@ -127,6 +127,10 @@ { "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ], "js": [ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/signature/openharmony_sx.p7b b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/signature/openharmony_sx.p7b index 2d47e203742c271666e7af3752683c02fcaec12f..96766868f93f9e2e57ab30993ccf412ef669eb9e 100644 Binary files a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/signature/openharmony_sx.p7b and b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_enable/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/config.json index 34f54b514ac7e56c2d63b5440f0e565d4251e6e2..7e7034a640915736756384ea81438db438d7d2e1 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/entry/src/main/config.json @@ -127,6 +127,10 @@ { "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ], "js": [ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/signature/openharmony_sx.p7b b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/signature/openharmony_sx.p7b index ebb175905c4480ad095e8d7802a1bb6461dc9dba..f321f0258de0e083f14d2e282cea81359a123ec7 100644 Binary files a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/signature/openharmony_sx.p7b and b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/config.json index dc5d8a84a98480d80c5a5e83a6ccd1841751d378..f365fd21709d6cd7b2d46afd1c80ce4cd3e7105e 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/entry/src/main/config.json @@ -127,6 +127,10 @@ { "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ], "js": [ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/signature/openharmony_sx.p7b b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/signature/openharmony_sx.p7b index 672dea806962c0cffa11225732242811da56e227..4264d251a4569db755f34658338795c94c2eb4a6 100644 Binary files a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/signature/openharmony_sx.p7b and b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyinvisible2/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/config.json index 2c9ddc9e2c35c41c4728a2b7ab77e19db7cea65e..e572741973df50bdfb70546cf56e729c9482b14b 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/entry/src/main/config.json @@ -127,6 +127,10 @@ { "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ], "js": [ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/signature/openharmony_sx.p7b b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/signature/openharmony_sx.p7b index 16e1483da119503576af5729e8ed48e80f043073..f1300562ac01eeb15908df13ac6ef919020e14b9 100644 Binary files a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/signature/openharmony_sx.p7b and b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstatetest_notifyvisible/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/config.json index 962e1f872edbf63e05eb5a40a6618e7242c2f5e3..16dc812a70473470be0023d492376012513455d4 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/config.json @@ -143,6 +143,10 @@ { "name": "ohos.permission.CLEAN_BACKGROUND_PROCESSES", "reason": "need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ], "js": [ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/test/FmsStress.test.ets b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/test/FmsStress.test.ets index 371a116803bf0aad3401409221e6da622d44d7d4..77be808017e53d4253c9a7642577d7d3e5c95103 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/test/FmsStress.test.ets +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/entry/src/main/ets/test/FmsStress.test.ets @@ -35,7 +35,6 @@ const unsubscribeCallback = (tcNumber) => { const unsubscribeOnDeletedCallback = (tcNumber, done) => { console.info(`${tcNumber} unsubscribeOnDeleted Callback`); - done(); } const unsubscribeOnAcquiredCallback = (tcNumber) => { console.info(`${tcNumber} unsubscribeOnAcquired Callback`); diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/signature/openharmony_sx.p7b b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/signature/openharmony_sx.p7b index 9819ab531ce4d217796676c74f48da9d899dca65..022445e93ab8b411293daa019604acb245f11d89 100644 Binary files a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/signature/openharmony_sx.p7b and b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formstresstest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/config.json b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/config.json index bc6b952fbff43c8e7f23d686ac3e701501d146de..976e19bd194e6cc5a35ea2677fb6ca6537c747fc 100644 --- a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/config.json +++ b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/entry/src/main/config.json @@ -136,6 +136,10 @@ { "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ], "js": [ diff --git a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/signature/openharmony_sx.p7b b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/signature/openharmony_sx.p7b index b047dcf7afc0990d6a6f41542360ab9284bcaa1d..23f82c8ed07ab6b4567bd5a8643aa0f7cab51590 100644 Binary files a/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/signature/openharmony_sx.p7b and b/ability/ability_runtime/formmanager/fa/formsystemtest_ets/formupdatefreshtest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/test/GetFormsInfoTest.test.ets b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/test/GetFormsInfoTest.test.ets index 965669dc47f4055eff11750d40ce5a9d02b4c73e..907207a028fdcf69ff8ee5b8f25e586a2ecd7de5 100644 --- a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/test/GetFormsInfoTest.test.ets +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/ets/test/GetFormsInfoTest.test.ets @@ -29,7 +29,6 @@ let module1FormInfo: formInfo.FormInfo = { isDefault: true, updateEnabled: true, formVisibleNotify: true, - relatedBundleName : "com.example.getformsinfotest", scheduledUpdateTime: "10:30", formConfigAbility: "ability://xxxxx", updateDuration: 1, @@ -50,7 +49,6 @@ let module2FormInfo: formInfo.FormInfo = { isDefault: true, updateEnabled: true, formVisibleNotify: true, - relatedBundleName : "com.example.getformsinfotest", scheduledUpdateTime: "10:30", formConfigAbility: "ability://xxxxx", updateDuration: 1, @@ -396,8 +394,6 @@ export default function abilityTest() { expect(expectInfo.isDefault).assertEqual(result.isDefault); console.info("formProvider::GetFormsInfoTest: formVisibleNotify expect " + expectInfo.formVisibleNotify); expect(expectInfo.formVisibleNotify).assertEqual(result.formVisibleNotify); - console.info("formProvider::GetFormsInfoTest: relatedBundleName expect " + expectInfo.relatedBundleName); - expect(expectInfo.relatedBundleName).assertEqual(result.relatedBundleName); console.info("formProvider::GetFormsInfoTest: scheduledUpdateTime expect " + expectInfo.scheduledUpdateTime); expect(expectInfo.scheduledUpdateTime).assertEqual(result.scheduledUpdateTime); console.info("formProvider::GetFormsInfoTest: formConfigAbility expect " + expectInfo.formConfigAbility); diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/module.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/module.json index 3be9582522234c01c2c91f3e439defc726360091..3dcdd14e0c675cda1473ef14f4f7039822a4c7e3 100644 --- a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/entry/src/main/module.json +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/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.getformsinfotest.MainAbility", diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/module.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/module.json index ac065dbf50e15df3f3c26f3820dd05abaab0798d..00aa98619d053026afd8e218502b67840bf52e24 100644 --- a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/module.json +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module1/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/module.json b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/module.json index 5cf7620fb80dd3f6b3d0ab9abc4d9033ac07464e..de61086c9b3e4e858055e6971160e1930854a018 100644 --- a/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/module.json +++ b/ability/ability_runtime/formmanager/stage/actsformprovidergetformsinfo/module2/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/module.json index cb9cf615b3f499507b209252d76bcb766325ee65..a7bab22a990398bd54aec2e0abc4ec3f5bc84466 100644 --- a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": true, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/module.json index 1c6a22e79e2a4d13f97d3c30e9201dea411867e0..7f2b7574867f0225f73ad5e76705a2e94fe0e5a6 100644 --- a/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/module.json @@ -14,6 +14,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/module.json index 1c6a22e79e2a4d13f97d3c30e9201dea411867e0..7f2b7574867f0225f73ad5e76705a2e94fe0e5a6 100644 --- a/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/module.json @@ -14,6 +14,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/actsfreeinstallstartabilityforresultstagetest/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/actsfreeinstallstartabilityforresultstagetest/entry/src/main/module.json index 6180dbba72246deffaafb5d2586edf9f0f3024ca..6dee86a7e365004e9ff2d937c78da179c4c7682e 100644 --- a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/actsfreeinstallstartabilityforresultstagetest/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/actsfreeinstallstartabilityforresultstagetest/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.startAbilityForResult.hmservice.MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/actsstartabilityforresultnotargetbundleliststagetest/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/actsstartabilityforresultnotargetbundleliststagetest/entry/src/main/module.json index 4f0eb835069cfdbc7cdb65d39417086876bc9cfd..f33f6635296b63e6383b1cffa6c736ff8cd53b83 100644 --- a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/actsstartabilityforresultnotargetbundleliststagetest/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/actsstartabilityforresultnotargetbundleliststagetest/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.startAbilityForResult.hmservice.MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/module.json index 91476a305a95c733df2381d2f97004f25a000361..21884298d098b2ec57f1b2f5f2d82656d69d60e4 100644 --- a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": true, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "com.example.qianyiyingyong.MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/module.json index 75cca782494ff3c689b337e963cfc4667759a1d2..f54df7327ac99f3b8a432575db118dd16b392ec9 100644 --- a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": true, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "com.example.hm2.MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/module.json index b7ab4cd759d0ad1f0994338260931a14a405a78f..a22e3cbe850bc5a05c03158a3204a07eba02bbf3 100644 --- a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": true, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "com.example.qianyiyingyong.MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/module.json index 20f9f942e37df49bcb3ff0e41d41222803818daf..6a3d703d56c4d948133d72c0d02471fea54b7b4b 100644 --- a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": true, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility1", diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/actsfreeinstallstartabilitystagetest/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/actsfreeinstallstartabilitystagetest/entry/src/main/module.json index 4b48fee0b5c28edbd7613a24c6a5f4cb010fc427..afd635a1e0ba00f69d50d60b24d938edbd514ac1 100644 --- a/ability/ability_runtime/freeinstalltest/startabilitystagetest/actsfreeinstallstartabilitystagetest/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/actsfreeinstallstartabilitystagetest/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.open.harmony.packagemag.MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/actsstartabilitynotargetbundleliststagetest/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/actsstartabilitynotargetbundleliststagetest/entry/src/main/module.json index 56ad2c95b627be7d959f50769ff4765e9b6cd3ad..e7c07db362c04ec8ced89fa39b8026ee131ff58a 100644 --- a/ability/ability_runtime/freeinstalltest/startabilitystagetest/actsstartabilitynotargetbundleliststagetest/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/actsstartabilitynotargetbundleliststagetest/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.open.harmony.packagemag.hmservice.MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/module.json index dd22b61cbeab684cbaa9278e837cdade5d3292c9..a9f5808bc00d33fcb99509dcf7acc164471ff9b8 100644 --- a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": true, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "com.example.qianyiyingyong.MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/module.json index 76b8db711fc8ffc00d409b4eb9f21502f7aa81a5..d2c1586ae3af5a6a4495f359f6b318f911fbb832 100644 --- a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/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.hm2.MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/module.json index dbbcce16c62d5d5bcf28b3f23cfbe364e3f214c4..d26b46e9da921f86038a994fe8d497705e621638 100644 --- a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/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.hm2.MainAbility", diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/module.json index 581880d0fcf6dc86a577ab08c1297b57a4e1d2fe..cff982d9f74fee429a69bbd1da951605c06dcd6a 100644 --- a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/module.json +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": true, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/newwant/actsnewwantarelyhap/entry/src/main/module.json b/ability/ability_runtime/newwant/actsnewwantarelyhap/entry/src/main/module.json index 849da36abd721b4c83ec3376ff7f41423a61547f..f536b73b7db6948db89d17de1456d12cba433496 100644 --- a/ability/ability_runtime/newwant/actsnewwantarelyhap/entry/src/main/module.json +++ b/ability/ability_runtime/newwant/actsnewwantarelyhap/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.example.newwanthapc.MainAbility", diff --git a/ability/ability_runtime/newwant/actsnewwantbrelyhap/entry/src/main/module.json b/ability/ability_runtime/newwant/actsnewwantbrelyhap/entry/src/main/module.json index ff46a35ecd219644022ae4c31dbfe09468066f1e..4f8e15091739cdc787ccc1f408df9125ad3e4eb1 100644 --- a/ability/ability_runtime/newwant/actsnewwantbrelyhap/entry/src/main/module.json +++ b/ability/ability_runtime/newwant/actsnewwantbrelyhap/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.example.newwanthapb.MainAbility", diff --git a/ability/ability_runtime/newwant/actsnewwantrelyhap/entry/src/main/module.json b/ability/ability_runtime/newwant/actsnewwantrelyhap/entry/src/main/module.json index 2b356a796093007e7a684fbb22a2e82aa0dcbcb7..a1f6eb71cc9ace660b0d587be2ece01356551362 100644 --- a/ability/ability_runtime/newwant/actsnewwantrelyhap/entry/src/main/module.json +++ b/ability/ability_runtime/newwant/actsnewwantrelyhap/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.example.newwanthapa.MainAbility", diff --git a/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/module.json b/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/module.json index f8213cbeb779cdfa36b4c9fb06217a20f27f0e71..289fe8696b7c964f242a1cf5430ac9f831f8b577 100644 --- a/ability/ability_runtime/newwant/actsnewwanttest/entry/src/main/module.json +++ b/ability/ability_runtime/newwant/actsnewwanttest/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.example.newwanttest.MainAbility", @@ -43,6 +49,10 @@ { "name": "ohos.permission.GET_BUNDLE_INFO", "reason": "need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND" } ] } diff --git a/ability/ability_runtime/newwant/actsnewwanttest/signature/openharmony_sx.p7b b/ability/ability_runtime/newwant/actsnewwanttest/signature/openharmony_sx.p7b index 3cbbdb3a812eef551228a66359af0309f9039ec3..33d6722eaef28e48dd0b80570db6af23ccee6db3 100644 Binary files a/ability/ability_runtime/newwant/actsnewwanttest/signature/openharmony_sx.p7b and b/ability/ability_runtime/newwant/actsnewwanttest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/non_concurrent/acts_systemappa_test/AppScope/app.json b/ability/ability_runtime/non_concurrent/acts_systemappa_test/AppScope/app.json index cf576dc15f5dd16fe89b1e496d5569ba70d2f753..696423b19864104bbf18473713e2e9306c3dbaf3 100644 --- a/ability/ability_runtime/non_concurrent/acts_systemappa_test/AppScope/app.json +++ b/ability/ability_runtime/non_concurrent/acts_systemappa_test/AppScope/app.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.example.actsabilitypermissiontest", + "bundleName": "com.acts.abilitypermissiontest", "vendor": "huawei", "versionCode": 1000000, "versionName": "1.0.0", diff --git a/ability/ability_runtime/non_concurrent/acts_systemappa_test/Test.json b/ability/ability_runtime/non_concurrent/acts_systemappa_test/Test.json index 8e028c73e122376aa58c6b04a0252be93817813d..6a07c444b1f66a43eed90132ec9d31999a6671e7 100644 --- a/ability/ability_runtime/non_concurrent/acts_systemappa_test/Test.json +++ b/ability/ability_runtime/non_concurrent/acts_systemappa_test/Test.json @@ -3,8 +3,8 @@ "driver": { "type": "OHJSUnitTest", "test-timeout": "300000", - "bundle-name": "com.example.actsabilitypermissiontest", - "module-name": "com.example.actsabilitypermissiontest", + "bundle-name": "com.acts.abilitypermissiontest", + "module-name": "com.acts.abilitypermissiontest", "shell-timeout": "600000", "testcase-timeout": 70000 }, diff --git a/ability/ability_runtime/non_concurrent/acts_systemappa_test/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/non_concurrent/acts_systemappa_test/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts index 5a6f38020383883bce44298f8add80762f263adc..81ceac5bbd1d2e064765c786ecabd3be168200f2 100644 --- a/ability/ability_runtime/non_concurrent/acts_systemappa_test/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts +++ b/ability/ability_runtime/non_concurrent/acts_systemappa_test/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -59,7 +59,7 @@ export default class OpenHarmonyTestRunner implements TestRunner { onAbilityCreate: onAbilityCreateCallback, }; abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) - var cmd = 'aa start -d 0 -a com.example.actsabilitypermissiontest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + var cmd = 'aa start -d 0 -a com.acts.abilitypermissiontest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) var debug = abilityDelegatorArguments.parameters["-D"] if (debug == 'true') diff --git a/ability/ability_runtime/non_concurrent/acts_systemappa_test/entry/src/main/ets/test/AbilityPermission.test.ets b/ability/ability_runtime/non_concurrent/acts_systemappa_test/entry/src/main/ets/test/AbilityPermission.test.ets index 69f48355c9fcf7d53665c4ac8fb7333dc06741b2..b5d185a49395f70817e617a8601d56d786d5b68e 100644 --- a/ability/ability_runtime/non_concurrent/acts_systemappa_test/entry/src/main/ets/test/AbilityPermission.test.ets +++ b/ability/ability_runtime/non_concurrent/acts_systemappa_test/entry/src/main/ets/test/AbilityPermission.test.ets @@ -71,8 +71,8 @@ export default function abilityPermissionTest() { console.debug("====>start startAbility_100====>"); await globalThis.abilityContext.startAbilityWithAccount( { - bundleName: 'com.example.actsabilitypermissiontest', - abilityName: 'com.example.actsabilitypermissiontest.MainAbility2' + bundleName: 'com.acts.abilitypermissiontest', + abilityName: 'com.acts.abilitypermissiontest.MainAbility2' }, userA, () => { console.debug("====>startAbility end_100====>"); }) @@ -117,8 +117,8 @@ export default function abilityPermissionTest() { console.debug("====>start startAbility_0300====>"); await globalThis.abilityContext.startAbilityWithAccount( { - bundleName: 'com.example.actssystemappuonehundredonerelytest', - abilityName: 'com.example.actssystemappuonehundredonerelytest.MainAbility' + bundleName: 'com.acts.systemapponerely', + abilityName: 'com.acts.systemapponerely.MainAbility' }, userA ).then().catch((err) => { console.debug("ACTS_AbilityPermission_0300====>" + err) @@ -176,8 +176,8 @@ export default function abilityPermissionTest() { console.debug("====>0600start connectAbility====>"); connId = await globalThis.abilityContext.connectAbilityWithAccount( { - bundleName: 'com.example.actssystemappuonehundredonerelytest', - abilityName: 'com.example.actssystemappuonehundredonerelytest.ServiceAbility', + bundleName: 'com.acts.systemapponerely', + abilityName: 'com.acts.systemapponerely.ServiceAbility', action: "StartAbilityPromise" }, userA, { onConnect: onConnectCallbackC, diff --git a/ability/ability_runtime/non_concurrent/acts_systemappa_test/entry/src/main/module.json b/ability/ability_runtime/non_concurrent/acts_systemappa_test/entry/src/main/module.json index 82a0380edc07096c6e467fe6d9877bd414b1a2c7..f5f23f86a547eb4e5fc80b51ba21aa2ebbb17527 100644 --- a/ability/ability_runtime/non_concurrent/acts_systemappa_test/entry/src/main/module.json +++ b/ability/ability_runtime/non_concurrent/acts_systemappa_test/entry/src/main/module.json @@ -1,6 +1,6 @@ { "module": { - "name": "com.example.actsabilitypermissiontest", + "name": "com.acts.abilitypermissiontest", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", "description": "$string:phone_entry_dsc", @@ -13,9 +13,15 @@ "installationFree": false, "uiSyntax": "ets", "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { - "name": "com.example.actsabilitypermissiontest.MainAbility", + "name": "com.acts.abilitypermissiontest.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", "description": "$string:phone_entry_main", "icon": "$media:icon", @@ -34,7 +40,7 @@ ] }, { - "name": "com.example.actsabilitypermissiontest.MainAbility2", + "name": "com.acts.abilitypermissiontest.MainAbility2", "srcEntrance": "./ets/MainAbility2/MainAbility2.ts", "description": "$string:phone_entry_main", "icon": "$media:icon", diff --git a/ability/ability_runtime/non_concurrent/acts_systemappa_test/signature/openharmony_sx.p7b b/ability/ability_runtime/non_concurrent/acts_systemappa_test/signature/openharmony_sx.p7b index 8301816f15114e3514d24a5e04fee1f354d835ce..27bfebd1cc7288ea20efaf96c9e51a127a540878 100755 Binary files a/ability/ability_runtime/non_concurrent/acts_systemappa_test/signature/openharmony_sx.p7b and b/ability/ability_runtime/non_concurrent/acts_systemappa_test/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/non_concurrent/acts_systemappone_rely_test/entry/src/main/module.json b/ability/ability_runtime/non_concurrent/acts_systemappone_rely_test/entry/src/main/module.json index 7d216453ecbb068459e156ae39950f39ec663f54..7b2e7321cec4eafcfd616510aa86fafeaa1d2cdf 100644 --- a/ability/ability_runtime/non_concurrent/acts_systemappone_rely_test/entry/src/main/module.json +++ b/ability/ability_runtime/non_concurrent/acts_systemappone_rely_test/entry/src/main/module.json @@ -1,6 +1,6 @@ { "module": { - "name": "com.example.actssystemappuonehundredonerelytest", + "name": "com.acts.systemapponerely", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", "description": "$string:phone_entry_dsc", @@ -13,9 +13,15 @@ "installationFree": false, "uiSyntax": "ets", "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { - "name": "com.example.actssystemappuonehundredonerelytest.MainAbility", + "name": "com.acts.systemapponerely.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", "description": "$string:phone_entry_main", "icon": "$media:icon", diff --git a/ability/ability_runtime/non_concurrent/actsthirdappatest/entry/src/main/module.json b/ability/ability_runtime/non_concurrent/actsthirdappatest/entry/src/main/module.json index 88cdbb44ad85e1104fce4301a0c805b2b97b6be1..cc21d8f40e4da254d8052325cfd87bc4ac42343c 100755 --- a/ability/ability_runtime/non_concurrent/actsthirdappatest/entry/src/main/module.json +++ b/ability/ability_runtime/non_concurrent/actsthirdappatest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "TestAbility", diff --git a/ability/ability_runtime/non_concurrent/actsthirdapponerelytest/entry/src/main/module.json b/ability/ability_runtime/non_concurrent/actsthirdapponerelytest/entry/src/main/module.json index d60d0b2098bc014f53359a2f39c6273547b4db98..1c418141ce162490c369aa4f6edb6f2d0f3a75ba 100755 --- a/ability/ability_runtime/non_concurrent/actsthirdapponerelytest/entry/src/main/module.json +++ b/ability/ability_runtime/non_concurrent/actsthirdapponerelytest/entry/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "uiSyntax": "ets", "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/ability/ability_runtime/stage/actslifecyclemultihap2/entry/src/main/module.json b/ability/ability_runtime/stage/actslifecyclemultihap2/entry/src/main/module.json index 2c54a1714b89458038d233530c5d96b87aaee0a8..89d4ef8883a0194ab9509e414af9742b1e0d5381 100644 --- a/ability/ability_runtime/stage/actslifecyclemultihap2/entry/src/main/module.json +++ b/ability/ability_runtime/stage/actslifecyclemultihap2/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.example.lifecycletest.Hap2MainAbility1", diff --git a/ability/ability_runtime/stage/actslifecyclemultihap3/entry/src/main/module.json b/ability/ability_runtime/stage/actslifecyclemultihap3/entry/src/main/module.json index 9e3445cb704b21fd04fa89fe4c1b5c1c83644460..8f5ec08d9498bc42d180073df8ddc13ea68dc0c2 100644 --- a/ability/ability_runtime/stage/actslifecyclemultihap3/entry/src/main/module.json +++ b/ability/ability_runtime/stage/actslifecyclemultihap3/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.example.lifecycletest.Hap3MainAbility1", diff --git a/ability/ability_runtime/stage/actslifecyclemultihaptest/entry/src/main/module.json b/ability/ability_runtime/stage/actslifecyclemultihaptest/entry/src/main/module.json index c252247132da7d567ecc898b2126ede9c8707ea0..85a35f9d1e15c78d0fa25ace8e563f78211aea92 100644 --- a/ability/ability_runtime/stage/actslifecyclemultihaptest/entry/src/main/module.json +++ b/ability/ability_runtime/stage/actslifecyclemultihaptest/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.example.lifecycletest.MainAbility", diff --git a/ability/ability_runtime/stage/actslifecyclemultihaptest/hap4/src/main/module.json b/ability/ability_runtime/stage/actslifecyclemultihaptest/hap4/src/main/module.json index 596d713cd69ec4c5f39820b551ddd186ff085bd2..ba063a5d45b71630526234357739616fe290e335 100644 --- a/ability/ability_runtime/stage/actslifecyclemultihaptest/hap4/src/main/module.json +++ b/ability/ability_runtime/stage/actslifecyclemultihaptest/hap4/src/main/module.json @@ -14,6 +14,12 @@ "uiSyntax": "ets", "process": "hap4mainability", "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "com.example.lifecycletest.hap4mainability", diff --git a/ability/ability_runtime/stage/actslifecyclesinglehaptest/entry/src/main/module.json b/ability/ability_runtime/stage/actslifecyclesinglehaptest/entry/src/main/module.json index 00594cbbfbaf0f5d4a5021514f15816e3f523e17..219ae0f400c751764fde32c179d8eac6d59fdaf7 100644 --- a/ability/ability_runtime/stage/actslifecyclesinglehaptest/entry/src/main/module.json +++ b/ability/ability_runtime/stage/actslifecyclesinglehaptest/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.example.lifecycle_xts.MainAbility", diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/module.json b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/module.json index c252247132da7d567ecc898b2126ede9c8707ea0..85a35f9d1e15c78d0fa25ace8e563f78211aea92 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/module.json +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/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.example.lifecycletest.MainAbility", diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/hap4/src/main/module.json b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/hap4/src/main/module.json index 596d713cd69ec4c5f39820b551ddd186ff085bd2..ba063a5d45b71630526234357739616fe290e335 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/hap4/src/main/module.json +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/hap4/src/main/module.json @@ -14,6 +14,12 @@ "uiSyntax": "ets", "process": "hap4mainability", "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "com.example.lifecycletest.hap4mainability", diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/module.json b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/module.json index 33173a72c91660664b05a17afbe70c09b95997b5..53661e02c9e607cf884ab30952d605cc99aab2b2 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/module.json +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/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.example.windowstagelifecycle_xts.MainAbility", diff --git a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/module.json b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/module.json index 3de96a784b47f56d45a0914130dd0c856cf8c0c2..7d63d53c2eaa6d6b852c7273cb75f755154b0322 100644 --- a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/module.json +++ b/ability/ability_runtime/workercontextcover/workercontexttest/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.workercontexttest.MainAbility", diff --git a/account/appaccount/actsaccounttstest/entry/src/main/module.json b/account/appaccount/actsaccounttstest/entry/src/main/module.json index 48fcafb33a76c5b1098b2b76f4b36e59081aa5ca..b02bf699a7e2ecb57e55a67871233eaaa2a9c694 100644 --- a/account/appaccount/actsaccounttstest/entry/src/main/module.json +++ b/account/appaccount/actsaccounttstest/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.accounttstest.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", diff --git a/ai/mindspore/BUILD.gn b/ai/mindspore/BUILD.gn index 5849705710379a1b8eff24ea15d69b08d581466e..46403f16e90a26718475c9715c8b3b402f5c8e70 100644 --- a/ai/mindspore/BUILD.gn +++ b/ai/mindspore/BUILD.gn @@ -28,6 +28,7 @@ ohos_moduletest_suite("ActsMindSporeTest") { configs = [ ":mindspore_config" ] + external_deps = [ "c_utils:utils" ] deps = [ "//third_party/googletest:gmock", "//third_party/googletest:gtest", diff --git a/ai/mindspore/src/ohos_c_api_test_mslite.cpp b/ai/mindspore/src/ohos_c_api_test_mslite.cpp index 49573fe347dbff721d4915c7d22a173f7e25d1b9..d86cd2869b8de493a1046b94bf5e65101e7d4c34 100644 --- a/ai/mindspore/src/ohos_c_api_test_mslite.cpp +++ b/ai/mindspore/src/ohos_c_api_test_mslite.cpp @@ -15,6 +15,7 @@ #include #include +#include #include "ohos_common.h" #include "gtest/gtest.h" #include "include/c_api/context_c.h" @@ -90,9 +91,9 @@ void FillInputsData(OH_AI_TensorHandleArray inputs, string model_name, bool is_t const int64_t *shape = OH_AI_TensorGetShape(tensor, &shape_num); auto imageBuf_nhwc = new char[size1]; PackNCHWToNHWCFp32(imageBuf, imageBuf_nhwc, shape[0], shape[1] * shape[2], shape[3]); - memcpy(input_data, imageBuf_nhwc, size1); + memcpy_s(input_data, size1, imageBuf_nhwc, size1); } else { - memcpy(input_data, imageBuf, size1); + memcpy_s(input_data, size1, imageBuf, size1); } printf("input data after filling is: "); for (int j = 0; j < element_num && j <= 20; ++j) { @@ -958,7 +959,7 @@ HWTEST(MSLiteTest, OHOS_Model_GetInputByTensorName_0001, Function | MediumTest | const int64_t *shape = OH_AI_TensorGetShape(tensor, &shape_num); auto imageBuf_nhwc = new char[size1]; PackNCHWToNHWCFp32(imageBuf, imageBuf_nhwc, shape[0], shape[1] * shape[2], shape[3]); - memcpy(input_data, imageBuf_nhwc, size1); + memcpy_s(input_data, size1, imageBuf_nhwc, size1); printf("input data is:"); for (int j = 0; j < element_num && j <= 20; ++j) { printf("%f ", input_data[j]); @@ -1479,7 +1480,7 @@ HWTEST(MSLiteTest, OHOS_Input_0003, Function | MediumTest | Level1) { printf("Tensor name: %s, elements num: %" PRId64 ".\n", OH_AI_TensorGetName(tensor), element_num); void *input_data = OH_AI_TensorGetMutableData(inputs.handle_list[i]); ASSERT_NE(input_data, nullptr); - memcpy(input_data, imageBuf, size1); + memcpy_s(input_data, size1, imageBuf, size1); } printf("==========Model Predict==========\n"); OH_AI_TensorHandleArray outputs; diff --git a/arkui/BUILD.gn b/arkui/BUILD.gn index 5e2d17548604412058a6404c15a570c6cfd65fd0..a8648882009d02f2e982ab0b962eadd642c19dfe 100644 --- a/arkui/BUILD.gn +++ b/arkui/BUILD.gn @@ -21,6 +21,7 @@ group("arkui") { "ace_ets_component_four:ActsAceEtsComponentFourTest", "ace_ets_component_three:ActsAceEtsComponentThreeTest", "ace_ets_component_two:ActsAceEtsComponentTwoTest", + "ace_ets_component_ui:ActsAceEtsComponentUITest", "ace_ets_dev:ActsAceDevTest", "ace_ets_standard:ActsAceEtsStTest", "ace_ets_test:ActsAceEtsTest", diff --git a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/list.ets b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/list.ets index 32ac65e2fa39fcbd358fc809e6c8f229ed925a51..93928f3de584680222844189efe04b4c939b38dc 100644 --- a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/list.ets +++ b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/list.ets @@ -98,13 +98,13 @@ struct ListLanes { .alignListItem(ListItemAlign.Start) .border({ width: 3, color: Color.Red }) .lanes({ minLength: 40, maxLength: 60 }) - .onScrollBegin((dx: number, dy: number) => { - if ((this.listPosition == 0 && dy >= 0) || (this.listPosition == 2 && dy <= 0)) { - this.scroller.scrollBy(0, -dy) - return { dxRemain: dx, dyRemain: 0 } + .onScrollFrameBegin((offset: number, state: ScrollState) => { + if ((this.listPosition == 0 && offset >= 0) || (this.listPosition == 2 && offset <= 0)) { + this.scroller.scrollBy(0, -offset) + return { offsetRemain: 0 } } this.listPosition = 1; - return { dxRemain: dx, dyRemain: dy } + return { offsetRemain: offset } try { var backData = { diff --git a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/pluginComponent.ets b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/pluginComponent.ets index e1310d6f783df35ccad68be0204f2764013ac9d6..9552dee9a93d08fbd9a573690b7c4ec45888265b 100644 --- a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/pluginComponent.ets +++ b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/pluginComponent.ets @@ -19,9 +19,9 @@ import plugin from "../common/plugin_component.js" @Component struct PluginUserExample { @StorageLink("plugincount") plugincount: Object[] = [ - { source: 'plugincomponent1', ability: 'com.example.plugin' }, - { source: 'plugintemplate', ability: 'com.example.myapplication' }, - { source: 'plugintemplate', ability: 'com.example.myapplication' }] + { source: 'plugincomponent1', bundleName: 'com.example.plugin' }, + { source: 'plugintemplate', bundleName: 'com.example.myapplication' }, + { source: 'plugintemplate', bundleName: 'com.example.myapplication' }] build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { @@ -48,7 +48,7 @@ struct PluginUserExample { }) ForEach(this.plugincount, item => { PluginComponent({ - template: { source: 'plugincomponent1', ability: 'com.example.plugin' }, + template: { source: 'plugincomponent1', bundleName: 'com.example.plugin' }, data: { 'countDownStartValue': 'new countDownStartValue' } }).size({ width: 500, height: 100 }) .onComplete(() => { diff --git a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/scroll.ets b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/scroll.ets index 01f8c565be0584154a7ceab1fad46c4a1554089d..bbecbe823fc6a9b87af8c03ea9db6aba69453818 100644 --- a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/scroll.ets +++ b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/scroll.ets @@ -61,9 +61,9 @@ struct ScrollOnScrollBegin { }.width('100%') } .scrollable(ScrollDirection.Vertical) - .onScrollBegin((dx: number, dy: number) => { - console.info('dx=' + dx + ",dy=" + dy) - return { dxRemain: dx, dyRemain: dy } + .onScrollFrameBegin((offset: number, state: ScrollState) => { + console.info('offset=' + offset) + return { offsetRemain: offset } }) .scrollBar(BarState.On) .scrollBarColor(Color.Gray) diff --git a/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/pluginComponent.ets b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/pluginComponent.ets index e1310d6f783df35ccad68be0204f2764013ac9d6..9552dee9a93d08fbd9a573690b7c4ec45888265b 100644 --- a/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/pluginComponent.ets +++ b/arkui/ace_ets_component_attrlack/entry/src/main/ets/MainAbility/pages/pluginComponent.ets @@ -19,9 +19,9 @@ import plugin from "../common/plugin_component.js" @Component struct PluginUserExample { @StorageLink("plugincount") plugincount: Object[] = [ - { source: 'plugincomponent1', ability: 'com.example.plugin' }, - { source: 'plugintemplate', ability: 'com.example.myapplication' }, - { source: 'plugintemplate', ability: 'com.example.myapplication' }] + { source: 'plugincomponent1', bundleName: 'com.example.plugin' }, + { source: 'plugintemplate', bundleName: 'com.example.myapplication' }, + { source: 'plugintemplate', bundleName: 'com.example.myapplication' }] build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { @@ -48,7 +48,7 @@ struct PluginUserExample { }) ForEach(this.plugincount, item => { PluginComponent({ - template: { source: 'plugincomponent1', ability: 'com.example.plugin' }, + template: { source: 'plugincomponent1', bundleName: 'com.example.plugin' }, data: { 'countDownStartValue': 'new countDownStartValue' } }).size({ width: 500, height: 100 }) .onComplete(() => { diff --git a/arkui/ace_ets_component_ui/AppScope/app.json b/arkui/ace_ets_component_ui/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..ac723a39e366c401bb0cdc83e38c1239729f6266 --- /dev/null +++ b/arkui/ace_ets_component_ui/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.myapplication", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 10, + "targetAPIVersion": 10, + "car": { + "apiCompatibleVersion": 10, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/AppScope/resources/base/element/string.json b/arkui/ace_ets_component_ui/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/arkui/ace_ets_component_ui/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/AppScope/resources/base/media/app_icon.png b/arkui/ace_ets_component_ui/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/arkui/ace_ets_component_ui/AppScope/resources/base/media/app_icon.png differ diff --git a/arkui/ace_ets_component_ui/BUILD.gn b/arkui/ace_ets_component_ui/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..26344b9c337be26c47997339b47bd643b8b5f4f5 --- /dev/null +++ b/arkui/ace_ets_component_ui/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAceEtsComponentUITest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":ace_ets_component_ui_js_assets", + ":ace_ets_component_ui_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAceEtsComponentUITest" +} + +ohos_app_scope("ace_ets_component_ui_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("ace_ets_component_ui_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("ace_ets_component_ui_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":ace_ets_component_ui_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/arkui/ace_ets_component_ui/Test.json b/arkui/ace_ets_component_ui/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..e268e4e7e4c5022676bc7ce534ad650b84d71cca --- /dev/null +++ b/arkui/ace_ets_component_ui/Test.json @@ -0,0 +1,36 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "com.example.myapplication", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": "180000" + }, + "kits": [{ + "test-file-name": [ + "ActsAceEtsComponentUITest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, { + "type": "ShellKit", + "run-command": [ + "param set persist.ace.testmode.enabled 1", + "param set persist.sys.suspend_manager_enabled 0", + "reboot", + "power-shell wakeup", + "hilog -Q pidoff", + "hilog -b DEBUG", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" + ], + "teardown-command": [ + "param set persist.sys.suspend_manager_enabled 1", + "reboot" + ] + + + }] +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/Application/AbilityStage.ts b/arkui/ace_ets_component_ui/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0e0206ea9fb5ce94ef140d69510b6280969dd8e --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,9 @@ +import AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/MainAbility.ts b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..4d66065e88c907379883364a43ec02989cfd626b --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,37 @@ +import Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + onCreate(want,launchParam){ + // Ability is creating, initialize resources for this ability + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage) + globalThis.windowStage = windowStage + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/DatelPanel.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/DatelPanel.ets new file mode 100644 index 0000000000000000000000000000000000000000..f6fae167d20ad0e2d737fd73e25471ff4b927594 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/DatelPanel.ets @@ -0,0 +1,91 @@ + +/** + * 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 {MessageManager,Callback} from '../utils/MessageManager'; +@Entry +@Component +struct DataPanelExample { + public valueArr: number[] = [10, 10, 10, 10, 10, 10, 10, 10, 10] + messageManager:MessageManager = new MessageManager() + + @State maxValue:number = 0 + @State dataPanelType:DataPanelType = 0 + @State values:number[] = [25,1]; + + + onPageShow() { + console.info('Checkbox onPageShow') + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value) + if (message.name == 'maxValue') { + this.maxValue = message.value + } + if (message.name == 'dataPanelType') { + this.dataPanelType = message.value + } + if (message.name == 'values') { + this.values = message.value + } + + } + this.messageManager.registerCallback(callback) + + } + + + build() { + Column({ space: 5 }) { + Row() { + Stack() { + DataPanel({ values: this.values, max: this.maxValue, type: this.dataPanelType }).width(168).height(168).key('dp1') + + DataPanel({ values: this.values}).width(168).height(168).key('dp2') + + Column() { + Text('30').fontSize(35).fontColor('#182431') + Text('1.0.0').fontSize(9.33).lineHeight(12.83).fontWeight(500).opacity(0.6) + } + + Text('%') + .fontSize(9.33) + .lineHeight(12.83) + .fontWeight(500) + .opacity(0.6) + .position({ x: 104.42, y: 78.17 }) + }.margin({ right: 44 }) + + Stack() { + DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Circle }).width(168).height(168).key('dp2') + Column() { + Text('75').fontSize(35).fontColor('#182431') + Text('已使用98GB/128GB').fontSize(8.17).lineHeight(11.08).fontWeight(500).opacity(0.6) + } + + Text('%') + .fontSize(9.33) + .lineHeight(12.83) + .fontWeight(500) + .opacity(0.6) + .position({ x: 104.42, y: 78.17 }) + } + }.margin({ bottom: 59 }) + + DataPanel({ values: this.valueArr, max: 100, type: DataPanelType.Line }).width(300).height(10).key('dp3') + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/blankParentWidth.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/blankParentWidth.ets new file mode 100644 index 0000000000000000000000000000000000000000..669cfa9c376deadafbd66d9bc973069f67ae4541 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/blankParentWidth.ets @@ -0,0 +1,67 @@ +/** + * 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 {MessageManager,Callback} from '../utils/MessageManager'; + +@Entry +@Component +struct BlankParentWidth { + @State colorString : string = "#fc7fae53" + @State minWith: string = '120' + messageManager:MessageManager = new MessageManager() + + onPageShow() { + console.info('blankParentWidth onPageShow') + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value) + if (message.name == 'blankColor') { + this.colorString = message.value + } + if (message.name == 'minWith') { + this.minWith = message.value + } + + } + this.messageManager.registerCallback(callback) + + } + + build() { + Column() { + Row() { + Text('Bluetooth').fontSize(18).key('text') + Blank().key('blank') + Toggle({ type: ToggleType.Switch }).key('toggle') + }.width('100%').backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 }).id('row') + + Row() { + Text('Bluetooth01').fontSize(18).key('text1') + Blank().color(Color.Yellow).key('bl1') + Toggle({ type: ToggleType.Switch }).key('toggle1') + }.backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 }).margin({top:60}) + + Row() { + Text('Bluetooth02').fontSize(18) + // 设置最小宽度为160 + Blank(this.minWith).color(this.colorString).key('bl2') + Toggle({ type: ToggleType.Switch }) + }.backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 }).margin({top:60}) + + }.backgroundColor(0xEFEFEF).padding(20) + + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/buttonExample.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/buttonExample.ets new file mode 100644 index 0000000000000000000000000000000000000000..210b772d41a4141902d1d988de3dd5ac719646b3 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/buttonExample.ets @@ -0,0 +1,112 @@ + +/** + * 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 {MessageManager,Callback} from '../utils/MessageManager'; +@Entry +@Component +struct ButtonExample { + @State bttype:ButtonType = ButtonType.Normal + @State stateEffect:boolean = true + @State str:string = "Disable1" + messageManager:MessageManager = new MessageManager() + + + @State fontColor:Color = Color.Red + @State fontFamily:string = "123" + @State fontStyle:FontStyle = FontStyle.Italic + @State fontWeight:FontWeight = FontWeight.Lighter + @State fontSize: string = '12' + + onPageShow() { + console.info('ButtonExample onPageShow') + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value) + if (message.name == 'bttype') { + this.bttype = message.value + } + if (message.name == 'stateEffect') { + this.stateEffect = message.value + } + + if (message.name == 'fontSize') { + this.fontSize = message.value + } + if (message.name == 'fontColor') { + this.fontColor = message.value + } + if (message.name == 'fontFamily') { + this.fontFamily = message.value + } + if (message.name == 'fontStyle') { + this.fontStyle = message.value + } + if (message.name == 'fontWeight') { + this.fontWeight = message.value + } + + } + this.messageManager.registerCallback(callback) + + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { + Text('Normal button').fontSize(9).fontColor(0xCCCCCC) + Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Button('OK', { type: this.bttype, stateEffect: this.stateEffect}).borderRadius(8).backgroundColor(0x317aff).width(90).fontSize(this.fontSize).key('btok') + .fontColor(this.fontColor).fontFamily(this.fontFamily).fontStyle(this.fontStyle).fontWeight(this.fontWeight) + Button({ type: ButtonType.Normal, stateEffect: true }) { + Row() { + LoadingProgress().width(20).height(20).margin({ left: 12 }).color(0xFFFFFF) + Text('loading').fontSize(12).fontColor(0xffffff).margin({ left: 5, right: 12 }) + }.alignItems(VerticalAlign.Center) + }.borderRadius(8).backgroundColor(0x317aff).width(90).height(40) + + Button('Disable', { type: ButtonType.Normal, stateEffect: false }).opacity(0.4) + .borderRadius(8).backgroundColor(0x317aff).width(90).key('btdisable') + } + + Text('Capsule button').fontSize(9).fontColor(0xCCCCCC) + Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Button('OK1', { type: ButtonType.Capsule, stateEffect: true }).backgroundColor(0x317aff).width(90) + Button({ type: ButtonType.Capsule, stateEffect: true }) { + Row() { + LoadingProgress().width(20).height(20).margin({ left: 12 }).color(0xFFFFFF) + Text('loading1').fontSize(12).fontColor(0xffffff).margin({ left: 5, right: 12 }) + }.alignItems(VerticalAlign.Center).width(90).height(40) + }.backgroundColor(0x317aff) + + Button(this.str, { type: ButtonType.Capsule, stateEffect: true }).opacity(0.4) + .backgroundColor(0x317aff).width(90).key('btdisable1').onClick(() => { + this.str = "click" + }) + } + + Text('Circle button').fontSize(9).fontColor(0xCCCCCC) + Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.Wrap }) { + Button({ type: ButtonType.Circle, stateEffect: true }) { + LoadingProgress().width(20).height(20).color(0xFFFFFF) + }.width(55).height(55).backgroundColor(0x317aff) + + Button({ type: ButtonType.Circle, stateEffect: true }) { + LoadingProgress().width(20).height(20).color(0xFFFFFF) + }.width(55).height(55).margin({ left: 20 }).backgroundColor(0xF55A42) + } + }.height(400).padding({ left: 35, right: 35, top: 35 }) + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/checkBoxExample.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/checkBoxExample.ets new file mode 100644 index 0000000000000000000000000000000000000000..986e1909cb794e5e760fb7ace35d44dbfc1be822 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/checkBoxExample.ets @@ -0,0 +1,62 @@ +/** + * 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 {MessageManager,Callback} from '../utils/MessageManager'; +@Entry +@Component +struct CheckboxExample { + @State select:boolean = true; + @State selectedColor:string = "#ed6f21" + messageManager:MessageManager = new MessageManager() + + onPageShow() { + console.info('Checkbox onPageShow') + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value) + if (message.name == 'select') { + this.select = message.value + } + if (message.name == 'selectedColor') { + this.selectedColor = message.value + } + + } + this.messageManager.registerCallback(callback) + + } + + build() { + Row() { + Checkbox({name: 'checkbox1', group: 'checkboxGroup'}) + .select(this.select) + .selectedColor(this.selectedColor) + .onChange((value: boolean) => { + if (value) { + this.selectedColor = "#ffff21" + } else { + this.selectedColor = "#000000" + } + }).key("check1").id('chek1') + Checkbox({name: 'checkbox2', group: 'checkboxGroup'}) + .select(false) + .selectedColor(0x39a2db) + .onChange((value: boolean) => { + console.info('Checkbox2 change is'+ value) + }).key("check2") + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/checkBoxGroupUI.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/checkBoxGroupUI.ets new file mode 100644 index 0000000000000000000000000000000000000000..af1dbbbad79aa12a26cbeb686451840b1fb18c58 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/checkBoxGroupUI.ets @@ -0,0 +1,100 @@ +/** + * 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 {MessageManager,Callback} from '../utils/MessageManager'; + +@Entry +@Component +struct CheckboxExample { + @State selectAll:boolean = true; + @State selectedColor:string = "#007DFF"; + @State message:string = "testclick"; + @State message2:string = "testclick2"; + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('Checkbox onPageShow') + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value) + if (message.name == 'selectAll') { + this.selectAll = message.value + } + if (message.name == 'selectedColor') { + this.selectedColor = message.value + } + + } + this.messageManager.registerCallback(callback) + + } + + + build() { + Scroll() { + Column() { + // 全选按钮 + + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + CheckboxGroup({ group: 'checkboxGroup' }) + .selectedColor(this.selectedColor) + .selectAll(this.selectAll) + .onChange((itemName: CheckboxGroupResult) => { + console.info("checkbox group content" + JSON.stringify(itemName)) + console.info("checkbox group content" + JSON.stringify(itemName.status)) + console.info("checkbox group content" + JSON.stringify(itemName.name)) + this.message = JSON.stringify(itemName.name); + this.message2 = JSON.stringify(itemName.status); + }).key("allck") + Text('Select All').fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500) + } + // 选项1 + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) + .selectedColor('#007DEF') + .select(false) + .onChange((value: boolean) => { + console.info('Checkbox1 change is' + value) + }).key('cb1') + Text('Checkbox1').fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500) + }.margin({ left: 36 }) + + // 选项2 + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Checkbox({ name: 'checkbox2', group: 'checkboxGroup' }) + .selectedColor('#007DFF') + .onChange((value: boolean) => { + console.info('Checkbox2 change is' + value) + }).key('cb2') + Text('Checkbox2').fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500) + }.margin({ left: 36 }) + + // 选项3 + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Checkbox({ name: 'checkbox3', group: 'checkboxGroup' }) + .selectedColor('#007DFF') + .onChange((value: boolean) => { + console.info('Checkbox3 change is' + value) + }) + Text('Checkbox3').fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500) + }.margin({ left: 36 }) + + Text(this.message).fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500).margin({left:20,top:20}).key('text1') + Text(this.message2).fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500).margin({left:20,top:20}).key('text2') + + } + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/dataPicker.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/dataPicker.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f0f62628de113814200e63232c4e303b1126bf7 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/dataPicker.ets @@ -0,0 +1,65 @@ +/** + * 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 {MessageManager,Callback} from '../utils/MessageManager'; +@Entry +@Component +struct DatePickerExample { + @State isLunar: boolean = false + @State message: string = 'touch' + private selectedDate: Date = new Date('2021-08-08') + @State options:DatePickerOptions = { + start: new Date('1970-1-1'), + end: new Date('2100-1-1'), + selected: this.selectedDate + } + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('Checkbox onPageShow') + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value) + if (message.name == 'isLunar') { + this.isLunar = message.value + } + if (message.name == 'options') { + this.options = message.value + } + + } + this.messageManager.registerCallback(callback) + + } + + build() { + Column() { + Button('切换公历农历') + .margin({ top: 30 }) + .onClick(() => { + this.isLunar = !this.isLunar + }) + Text(this.message).fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500).margin({top:20}).key('dptouch') + DatePicker(this.options) + .lunar(this.isLunar) + .onChange((value: DatePickerResult) => { + this.selectedDate.setFullYear(value.year, value.month, value.day) + console.info('select current date is: ' + JSON.stringify(value)) + this.message = JSON.stringify(value.year) + }).key('dataPicker') + + }.width('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/divider.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/divider.ets new file mode 100644 index 0000000000000000000000000000000000000000..ddc0bfb6750d071712dea244996fc80184419074 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/divider.ets @@ -0,0 +1,110 @@ +/** + * 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 {MessageManager,Callback} from '../utils/MessageManager'; +@Entry +@Component +struct DividerExample { + @State vertical:boolean = false + @State color:string = '#acbdef' + @State strokeWidth:number = 20 + @State lineCapStyle:LineCapStyle = LineCapStyle.Butt + @State widthK:number = 0 + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('divider onPageShow') + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value) + if (message.name == 'vertical') { + this.vertical = message.value + } + if (message.name == 'color') { + this.color = message.value + } + if (message.name == 'strokeWidth') { + this.strokeWidth = message.value + } + if (message.name == 'lineCapStyle') { + this.lineCapStyle = message.value + } + if (message.name == 'widthK') { + this.widthK = message.value + + } + } + this.messageManager.registerCallback(callback) + + } + + build() { + Column() { + // 使用横向分割线场景 + Text('Horizontal divider').fontSize(9).fontColor(0xCCCCCC) + List() { + ForEach([1, 2, 3], (item) => { + ListItem() { + Text('list' + item).width('100%').fontSize(14).fontColor('#182431').textAlign(TextAlign.Start) + }.width(244).height(48) + }, item => item.toString()) + }.padding({ left: 24, bottom: 8 }) + + Divider().strokeWidth(8).color('#F1F3F5') + List() { + ForEach([4, 5], (item) => { + ListItem() { + Text('list' + item).width('100%').fontSize(14).fontColor('#182431').textAlign(TextAlign.Start) + }.width(244).height(48) + }, item => item.toString()) + }.padding({ left: 24, top: 8 }) + + // 使用纵向分割线场景 + Text('Vertical divider').fontSize(9).fontColor(0xCCCCCC) + Column() { + Column() { + Row().width(288).height(64).backgroundColor('#30C9F0').opacity(0.3) + Row() { + Button('Button') + .width(136) + .height(22) + .fontSize(16) + .fontColor('#007DFF') + .fontWeight(500) + .backgroundColor(Color.Transparent) + Divider().vertical(this.vertical).height(22).color(this.color).width(this.widthK).margin({ left: 8, right: 8 }).strokeWidth(this.strokeWidth).lineCap(this.lineCapStyle).key("divider") + Button('Button') + .width(136) + .height(22) + .fontSize(16) + .fontColor('#007DFF') + .fontWeight(500) + .backgroundColor(Color.Transparent) + }.margin({ top: 17 }) + } + .width(336) + .height(152) + .backgroundColor('#FFFFFF') + .borderRadius(24) + .padding(24) + } + .width('100%') + .height(168) + .backgroundColor('#F1F3F5') + .justifyContent(FlexAlign.Center) + .margin({ top: 8 }) + }.width('100%').padding({ top: 24 }) + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/guage.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/guage.ets new file mode 100644 index 0000000000000000000000000000000000000000..dca276bf518736ada4b5b99d058aa21c83fddaeb --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/guage.ets @@ -0,0 +1,91 @@ + +/** + * 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 {MessageManager,Callback} from '../utils/MessageManager'; + +@Entry +@Component +struct GaugeExample { + @State startAngle:number = 0; + @State endAngle:number = 0; + @State colors:Array<[number,number]> = [[0x317AF7, 0.1], [0x5BA854, 0.2], [0xE08C3A, 0.3], [0x9C554B, 0.4]] + @State strokeWidth:number = 0; + @State value:number = 30; + @State min:number = 0; + @State max:number = 100; + @State wth:number = 100; + + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('Gauge onPageShow') + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value) + if (message.name == 'startAngle') { + this.startAngle = message.value + } + if (message.name == 'endAngle') { + this.endAngle = message.value + } + if (message.name == 'colors') { + this.colors = message.value + } + if (message.name == 'strokeWidth') { + this.strokeWidth = message.value + } + if (message.name == 'value') { + this.value = message.value + } + if (message.name == 'min') { + this.min = message.value + } + if (message.name == 'max') { + this.max = message.value + } + if (message.name == 'wth') { + this.wth = message.value + } + } + this.messageManager.registerCallback(callback) + + } + + build() { + Column({ space: 20 }) { + // 使用默认的min和max为0-100,角度范围默认0-360,value值设置 + // 参数中设置当前值为75 + Gauge({ value: 75 }) + .width(200).height(200) + .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1]]) + + // 参数设置当前值为75,属性设置值为25,属性设置优先级高 + Gauge({ value: 75 }) + .value(25) // 属性和参数都设置时以参数为准 + .width(200).height(200) + .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1]]) + + // 210--150度环形图表 + Gauge({ value: this.value, min: this.min, max: this.max }) + .startAngle(this.startAngle) + .endAngle(this.endAngle) + .colors(this.colors) + .strokeWidth(this.strokeWidth) + .width(this.wth) + .height(200).key('guage') + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/index/index.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..97504e2440a9a6110fd5c9c02985914ef8d9e655 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,56 @@ +/* + * 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 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_component_ui/entry/src/main/ets/MainAbility/pages/loadingprogress.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/loadingprogress.ets new file mode 100644 index 0000000000000000000000000000000000000000..e6965412b75f713326b4838d09514fe4811b5475 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/loadingprogress.ets @@ -0,0 +1,44 @@ +/** + * 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 {MessageManager,Callback} from '../utils/MessageManager'; + +@Entry +@Component +struct LoadingProgressExample { + @State color:Color = Color.Blue + messageManager:MessageManager = new MessageManager() + onPageShow() { + console.info('Gauge onPageShow') + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value) + if (message.name == 'color') { + this.color = message.value + } + + } + this.messageManager.registerCallback(callback) + + } + build() { + Column({ space: 5 }) { + Text('Orbital LoadingProgress ').fontSize(9).fontColor(0xCCCCCC).width('90%') + LoadingProgress() + .color(this.color).key('loadingProgress') + }.width('100%').margin({ top: 5 }) + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/marquee.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/marquee.ets new file mode 100644 index 0000000000000000000000000000000000000000..de3db117a7b9b169811aa093c012ab6603e80f26 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/marquee.ets @@ -0,0 +1,109 @@ +/** + * 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 {MessageManager,Callback} from '../utils/MessageManager'; + + +@Entry +@Component +struct MarqueeExample { + @State start:boolean = false + @State fromStart:boolean = true + @State step:number = 50 + @State loop:number = 2 + @State src:string = "Running Marquee starts rolling" + @State message1:string = "message1" + @State message2:string = "message2" + @State message3:string = "message3" + @State allowScale:boolean = false + messageManager:MessageManager = new MessageManager() + + onPageShow() { + console.info('Gauge onPageShow') + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.error('message = ' + message.name + "--" + message.value) + if (message.name == 'step') { + this.step = message.value + } + if (message.name == 'loop') { + this.loop = message.value + } + if (message.name == 'src') { + this.src = message.value + } + if (message.name == 'allowScale') { + this.allowScale = message.value + } + if (message.name == 'fromStart') { + this.fromStart = message.value + } + if (message.name == 'start') { + this.start = message.value + } + + } + this.messageManager.registerCallback(callback) + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Marquee({ + start:this.start, + step:this.step, + loop:this.loop, + fromStart:this.fromStart, + src:this.src + }) + .width(360) + .height(80) + .fontColor('#FFFFFF') + .fontSize(48) + .allowScale(this.allowScale) + .fontWeight(700) + .backgroundColor('#182431') + .margin({ bottom: 40 }) + .key('marquee') + .onStart(() => { + console.info('Marquee animation complete onStart') + this.message1 = "onStart" + }) + .onBounce(() => { + console.info('Marquee animation complete onBounce') + this.message2 = "onBounce" + }) + .onFinish(() => { + console.info('Marquee animation complete onFinish') + this.message3 = "onFinish" + }) + Button('Start') + .onClick(() => { + this.start = true + }) + .width(120) + .height(40) + .fontSize(16) + .fontWeight(500) + .backgroundColor('#007DFF').key('btstart').key('start') + + Text(this.message1).fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500).key('text1') + Text(this.message2).fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500).key('text2') + Text(this.message3).fontSize(14).lineHeight(20).fontColor('#182431').fontWeight(500).key('text3') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/second/second.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..1c1c727ff11ecc97909f482c35268db87ae23bb4 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/second/second.ets @@ -0,0 +1,43 @@ +/* + * 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 router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/utils/Common.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/utils/Common.ets new file mode 100644 index 0000000000000000000000000000000000000000..16d5ad46f0dad844df185b479830df5ae52618e3 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/utils/Common.ets @@ -0,0 +1,51 @@ +/** + * 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 class CommonFunc { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + + static sleep(time){ + return new Promise((resolve,reject)=>{ + setTimeout(()=>{ + resolve("ok") + },time) + }).then(()=>{ + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } +} + + + + diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/utils/MessageManager.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/utils/MessageManager.ets new file mode 100644 index 0000000000000000000000000000000000000000..70d716b6d61af8e8ba54a5a0affe80413221b168 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/utils/MessageManager.ets @@ -0,0 +1,54 @@ +/** + * 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 interface Callback { + (message:any):void +} + +export class MessageManager { + callback:Callback + callbacks:Map = 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_component_ui/entry/src/main/ets/TestAbility/TestAbility.ts b/arkui/ace_ets_component_ui/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8028a70f8af44690b95a08bd177bca6b09f24687 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * 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 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_component_ui/entry/src/main/ets/TestAbility/pages/index.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * 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 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_component_ui/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/arkui/ace_ets_component_ui/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ee2f1652b3d04ce83ece64ef70f8dfa62a2dc8 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 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.example.myapplication.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_component_ui/entry/src/main/ets/test/BlankJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/BlankJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..de80f778d8e19e8fd6b52020d244ab9b5d85d0d1 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/BlankJsunit.test.ets @@ -0,0 +1,172 @@ +/** + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" +import router from '@system.router'; +import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest'; +import CommonFunc from '../MainAbility/utils/Common'; +import {MessageManager,Callback} from '../MainAbility/utils/MessageManager'; + +export default function blankJsunit() { + describe('blankJsunit', function () { + beforeEach(async function (done) { + console.info("blankJsunit beforeEach start"); + let options = { + uri: 'MainAbility/pages/blankParentWidth', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get blankJsunit state pages:" + JSON.stringify(pages)); + if (!("blankParentWidth" == pages.name)) { + console.info("get blankJsunit state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push blankJsunit success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push blankJsunit page error:" + err); + expect().assertFail(); + } + done(); + }); + + /** + * @tc.number SUB_ARKUI_BLANK_JSAPI_001 + * @tc.name Test blankJsunit_0100 + * @tc.desc Test blank attribute + */ + it('blankJsunit_0100', 0, async function (done) { + console.info('blankJsunitUITest_0100 START'); + await CommonFunc.sleep(1000); + globalThis.value.message.notify({name:'blankColor',value:'#FCAE5394'}) + await CommonFunc.sleep(2000); + let strJson = getInspectorByKey('bl2'); + let obj = JSON.parse(strJson); + console.info("[blankJsunit_0100'] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.color).assertEqual('#FCAE5394'); + done(); + }); + + /** + * @tc.number SUB_ARKUI_BLANK_JSAPI_002 + * @tc.name Test blankJsunit_0100 + * @tc.desc Test blank attribute + */ + it('blankJsunit_0200', 0, async function (done) { + console.info('blankJsunitUITest_0200 START'); + await CommonFunc.sleep(1000); + // 动态修改Blank组件的minwidth + globalThis.value.message.notify({name:'minWith',value:'80'}) + await CommonFunc.sleep(2000); + // 获取动态修改后的组件的minwidth + let strJson = getInspectorByKey('bl2'); + let obj = JSON.parse(strJson); + console.info("[blankJsunit_0200'] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.min).assertEqual('80.00vp'); + done(); + }); + + it('blankJsunit_0300', 0, async function (done) { + console.info('blankJsunitUITest_0300 START'); + await CommonFunc.sleep(1000); + // 动态非法修改Blank组件的minwidth + globalThis.value.message.notify({name:'minWith',value:'-30'}) + await CommonFunc.sleep(2000); + // 获取默认的minWidth值 + let strJson = getInspectorByKey('bl2'); + let obj = JSON.parse(strJson); + console.info("[blankJsunit_0300'] component obj is: " + obj.$attrs.min); + // return not the default value to confirm ? + expect(obj.$attrs.min).assertEqual('0.00px'); + done(); + }); + + it('blankJsunit_0400', 0, async function (done) { + console.info('blankJsunitUITest_0400 START'); + await CommonFunc.sleep(1000); + // 动态非法修改Blank组件的颜色 + globalThis.value.message.notify({name:'blankColor',value:'#AE53'}) + await CommonFunc.sleep(3000); + // 获取非法动态修改后默认组件的颜色 + let strJson = getInspectorByKey('bl2'); + console.info("[blankJsunit_0400'] component obj is: " + strJson); + let obj = JSON.parse(strJson); + // add enum color test case and confirm the the color ? + expect(obj.$attrs.color).assertEqual('#AAEE5533'); + done(); + }); + + it('blankJsunit_0500', 0, async function (done) { + console.info('blankJsunitUITest_0500 START'); + await CommonFunc.sleep(1000); + // 验证父组件不设置宽度,blank失效 + let text1_rect = CommonFunc.getComponentRect('text1'); + let toggle1_rect = CommonFunc.getComponentRect('toggle1'); + let bl1_rect = CommonFunc.getComponentRect('bl1'); + console.info("[blankJsunit_0500'] text1_rect is " + JSON.stringify(text1_rect) + "toggle1_rect is " + JSON.stringify(toggle1_rect) + "bl1.rect is " + JSON.stringify(bl1_rect)); + // 判断blank不显示 + expect(bl1_rect.left - bl1_rect.right).assertEqual(0) + let strJson = getInspectorByKey('blank'); + let obj = JSON.parse(strJson); + console.info("[blankJsunit_0500'] component obj is: " + strJson); + expect(obj.$attrs.min).assertEqual('0.00px'); + done(); + }); + + it('blankJsunit_0600', 0, async function (done) { + console.info('blankJsunitUITest_0600 START'); + await CommonFunc.sleep(1000); + // 验证父组件为row/coloumn 且宽度有,blank平分 + let strJson = getInspectorByKey('blank'); + let obj = JSON.parse(strJson); + console.info("[blankJsunit_0600'] component obj is: " + JSON.stringify(obj)); + let text_rect = CommonFunc.getComponentRect('text'); + let toggle_rect = CommonFunc.getComponentRect('toggle'); + console.info("[blankJsunit_0600'] text_rect is " + JSON.stringify(text_rect) + "toggle_rect is " + JSON.stringify(toggle_rect)); + // 判断blank平分显示 + let gaps = toggle_rect.left - text_rect.right; + expect(gaps > 0).assertTrue(); + expect(obj.$attrs.min).assertEqual('0.00px'); + done(); + }); + + it('blankJsunit_0700', 0, async function (done) { + console.info('blankJsunitUITest_0700 START'); + await CommonFunc.sleep(1000); + // 直接判断组件的属性 + let strJson = getInspectorByKey('blank'); + let obj = JSON.parse(strJson); + console.info("[blankJsunit_0700'] component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Blank'); + expect(obj.$attrs.color).assertEqual('#FFFFFFFF'); + expect(obj.$attrs.min).assertEqual('0.00px'); + done(); + }); + + it('blankJsunit_0800', 0, async function (done) { + console.info('blankJsunitUITest_0700 START'); + await CommonFunc.sleep(1000); + globalThis.value.message.notify({name:'minWith',value:'rr'}) + await CommonFunc.sleep(200); + let strJson2 = getInspectorByKey('bl2'); + let obj2 = JSON.parse(strJson2); + console.info("[blankJsunit_0300'] component obj2 is: " + JSON.stringify(obj2)); + expect(obj2.$attrs.min).assertEqual('0.00px'); + done(); + + }); + + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/ButtonJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/ButtonJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..623f59cb4b9884a493ab97aea5d90d9982f9e2f4 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/ButtonJsunit.test.ets @@ -0,0 +1,179 @@ +/** + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" +import router from '@system.router'; +import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest'; +import CommonFunc from '../MainAbility/utils/Common'; +import {MessageManager,Callback} from '../MainAbility/utils/MessageManager'; +const waitUiReadyMs = 1000; + +export default function buttonJsunit() { + describe('buttonJsunit', function () { + beforeEach(async function (done) { + console.info("buttonJsunit beforeEach start"); + let options = { + uri: 'MainAbility/pages/buttonExample', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get buttonJsunit state pages:" + JSON.stringify(pages)); + if (!("buttonExample" == pages.name)) { + console.info("get buttonJsunit state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push buttonJsunit success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push buttonJsunit page error:" + err); + expect().assertFail(); + } + done(); + }); + + it('buttonJsunit_0100', 0, async function (done) { + console.info('buttonJsunitUITest_0100 START'); + await CommonFunc.sleep(1000); + // 获取button组件的信息 + let strJson = getInspectorByKey('btok'); + let obj = JSON.parse(strJson); + console.info("[buttonJsunit_0100'] component obj is: " + obj); + expect(obj.$type).assertEqual('Button'); + expect(obj.$attrs.type).assertEqual('ButtonType.Normal'); + expect(obj.$attrs.stateEffect).assertEqual('true'); + expect(obj.$attrs.fontSize).assertEqual('12.00fp'); + expect(obj.$attrs.fontColor).assertEqual('#FFFF0000'); + expect(obj.$attrs.fontFamily).assertEqual('123'); + expect(obj.$attrs.fontStyle).assertEqual('FontStyle.Italic'); + expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Lighter'); + done(); + }); + + it('buttonJsunit_0200', 0, async function (done) { + console.info('buttonJsunitUITest_0200 START'); + await CommonFunc.sleep(1000); + globalThis.value.message.notify({name:'stateEffect', value:false}); + await CommonFunc.sleep(200); + let strJson2 = getInspectorByKey('btok'); + let obj2 = JSON.parse(strJson2); + console.info("[buttonJsunit_0200'] component2 obj is: " + obj2.$attrs.stateEffect); + expect(obj2.$attrs.stateEffect).assertEqual('false'); + done(); + }); + + it('buttonJsunit_0300', 0, async function (done) { + console.info('buttonJsunitUITest_0300 START'); + await CommonFunc.sleep(1000); + // 动态修改Button组件的属性,设置为非法值 + globalThis.value.message.notify({name:'bttype', value:'5'}); + await CommonFunc.sleep(500); + let strJson = getInspectorByKey('btok'); + let obj = JSON.parse(strJson); + console.info("[buttonJsunit_0300'] component obj is: " + obj.$attrs.type); + expect(obj.$attrs.type).assertEqual('ButtonType.Capsule'); + done(); + }); + + it('buttonJsunit_0400', 0, async function (done) { + console.info('buttonJsunitUITest_0400 START'); + // check the button is click + let driver = Driver.create(); + await driver.delayMs(waitUiReadyMs); + let btn = await driver.findComponent(ON.id('btdisable')); + await driver.delayMs(waitUiReadyMs); + let isClick = await btn.isClickable(); + expect(isClick).assertFalse(); + done(); + }); + + it('buttonJsunit_0500', 0, async function (done) { + console.info('buttonJsunitUITest_0500 START'); + // 判断按钮的点击事件,通过按钮的文本可以判断 + let driver = Driver.create(); + await driver.delayMs(waitUiReadyMs); + let btn = await driver.findComponent(ON.id('btdisable1')); + await driver.delayMs(waitUiReadyMs); + await btn.click(); + await driver.delayMs(2000); + let tt = await btn.getText(); + console.info("[buttonJsunit_0500'] component obj is: " + tt); + expect(tt == 'click').assertTrue(); + done(); + }); + + it('buttonJsunit_0600', 0, async function (done) { + // buton 通用字体属性判断 + console.info('buttonJsunitUITest_0600 START'); + await CommonFunc.sleep(1000); + globalThis.value.message.notify({name:'fontSize',value:'13'}); + await CommonFunc.sleep(200); + globalThis.value.message.notify({name:'fontColor',value:Color.Green}); + await CommonFunc.sleep(200); + globalThis.value.message.notify({name:'fontFamily',value:'HarmonyOS Sans'}); + await CommonFunc.sleep(200); + globalThis.value.message.notify({name:'fontStyle',value:'FontStyle.Normal'}); + await CommonFunc.sleep(200); + globalThis.value.message.notify({name:'fontWeight',value:FontWeight.Bold}); + await CommonFunc.sleep(200); + let strJson = getInspectorByKey('btok'); + let obj = JSON.parse(strJson); + console.info("[buttonJsunit_0600'] component obj is: " + obj); + expect(obj.$attrs.fontSize).assertEqual('13.00fp'); + expect(obj.$attrs.fontColor).assertEqual('#FF008000'); + expect(obj.$attrs.fontFamily).assertEqual('HarmonyOS Sans'); + expect(obj.$attrs.fontStyle).assertEqual('FontStyle.Normal'); + expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Bold'); + done(); + }); + + it('buttonJsunit_0700', 0, async function (done) { + // buton 通用字体非法属性判断 + console.info('buttonJsunitUITest_0700 START'); + await CommonFunc.sleep(1000); + globalThis.value.message.notify({name:'fontSize',value:'-200'}); + await CommonFunc.sleep(200); + globalThis.value.message.notify({name:'fontColor',value:"#ff"}); + await CommonFunc.sleep(200); + globalThis.value.message.notify({name:'fontFamily',value:'233'}); + await CommonFunc.sleep(200); + globalThis.value.message.notify({name:'fontStyle',value:'4444'}); + await CommonFunc.sleep(200); + globalThis.value.message.notify({name:'fontWeight',value:'-20'}); + await CommonFunc.sleep(200); + let strJson = getInspectorByKey('btok'); + let obj = JSON.parse(strJson); + console.info("[buttonJsunit_0700'] component obj is: " + obj.$attrs.fontSize + obj.$attrs.fontColor + obj.$attrs.fontFamily + obj.$attrs.fontStyle + obj.$attrs.fontWeight); + expect(obj.$attrs.fontSize).assertEqual('-200.00fp'); + expect(obj.$attrs.fontColor).assertEqual('#FFFFFFFF'); + expect(obj.$attrs.fontFamily).assertEqual('233'); + expect(obj.$attrs.fontStyle).assertEqual('FontStyle.Normal'); + expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Normal'); + done(); + }); + + it('buttonJsunit_0800', 0, async function (done) { + console.info('buttonJsunitUITest_0800 START'); + await CommonFunc.sleep(1000); + // 动态修改Button组件的属性 + globalThis.value.message.notify({name:'bttype',value:ButtonType.Capsule}); + await CommonFunc.sleep(500); + let strJson = getInspectorByKey('btok'); + let obj = JSON.parse(strJson); + console.info("[buttonJsunit_0800'] component obj is: " + obj.$attrs.type); + expect(obj.$attrs.type).assertEqual('ButtonType.Capsule'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/CheckBoxJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/CheckBoxJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..550f2ed6bc77da2e75486a19b00861985ad5a919 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/CheckBoxJsunit.test.ets @@ -0,0 +1,168 @@ +/** + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" +import router from '@system.router'; +import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest'; +import CommonFunc from '../MainAbility/utils/Common'; +import {MessageManager,Callback} from '../MainAbility/utils/MessageManager'; +const waitUiReadyMs = 1000; + +export default function checkBoxJsunit() { + describe('CheckBoxJsunit', function () { + beforeEach(async function (done) { + console.info("checkBoxJsunit beforeEach start"); + let options = { + uri: 'MainAbility/pages/checkBoxExample', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get checkBoxJsunit state pages:" + JSON.stringify(pages)); + if (!("checkBoxExample" == pages.name)) { + console.info("get checkBoxJsunit state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push checkBoxJsunit success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push checkBoxJsunit page error:" + err); + expect().assertFail(); + } + done(); + }); + + it('checkBoxJsunit_0100', 0, async function (done) { + console.info('checkBoxJsunit_0100 START'); + await CommonFunc.sleep(3000); + // get the checkbox component and test attribute + let strJson = getInspectorByKey('chek1'); + let obj = JSON.parse(strJson); + console.info("[checkBoxJsunit_0100'] component obj is: " + JSON.stringify(obj.$attrs.select)); + expect(obj.$attrs.selectedColor).assertEqual('#FFED6F21'); + let driver = Driver.create(); + await driver.delayMs(waitUiReadyMs); + let checkBox = await driver.findComponent(ON.id('chek1')); + let isChecked = await checkBox.isChecked(); + // to confirm + console.info("[checkBoxJsunit_0100'] component obj isChecked: " + isChecked); + expect(isChecked).assertFalse(); + done(); + }); + + it('checkBoxJsunit_0200', 0, async function (done) { + console.info('checkBoxJsunit_0200 START'); + await CommonFunc.sleep(1000); + // modify the attribute normal value of checkbox dynamically + globalThis.value.message.notify({name:'select',value:'false'}) + await CommonFunc.sleep(2000); + let driver = Driver.create(); + await driver.delayMs(waitUiReadyMs); + let checkBox = await driver.findComponent(ON.id('chek1')); + let isChecked = await checkBox.isChecked(); + expect(isChecked).assertFalse(); + globalThis.value.message.notify({name:'selectedColor',value:'#ecaaff'}) + await CommonFunc.sleep(4000); + // check the value of changed attribute + let strJson2 = getInspectorByKey('chek1'); + let obj2 = JSON.parse(strJson2); + console.info("[blankJsunit_0200'] component obj2 is: " + JSON.stringify(obj2.$attrs.selectedColor)); + expect(obj2.$attrs.selectedColor).assertEqual('#FFECAAFF'); + done(); + }); + + it('checkBoxJsunit_0300', 0, async function (done) { + console.info('checkBoxJsunit_0300 START'); + await CommonFunc.sleep(2000); + // modify the attribute illegal value of checkbox dynamically + globalThis.value.message.notify({name:'selectedColor',value:'#ecaf'}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('chek1'); + let obj = JSON.parse(strJson); + console.info("[blankJsunit_0300'] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.selectedColor).assertEqual('#EECCAAFF'); + done(); + }); + + it('checkBoxJsunit_0400', 0, async function (done) { + console.info('checkBoxJsunit_0400 START'); + await CommonFunc.sleep(1000); + // test the clicking event of checkbox + let driver = Driver.create(); + await driver.delayMs(waitUiReadyMs); + let checkbox1 = await driver.findComponent(ON.id('chek1')); + expect(checkbox1 != null).assertTrue(); + await checkbox1.click(); + await driver.delayMs(waitUiReadyMs); + // check the click event by selectedColor + let strJson = getInspectorByKey('chek1'); + let obj = JSON.parse(strJson); + console.info("[blankJsunit_0400'] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.selectedColor).assertEqual('#FF000000'); + done(); + }); + + it('checkBoxJsunit_0500', 0, async function (done) { + console.info('checkBoxJsunit_0300 START'); + await CommonFunc.sleep(2000); + // verify the enum color + globalThis.value.message.notify({name:'selectedColor',value:Color.Green}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('chek1'); + let obj = JSON.parse(strJson); + console.info("[blankJsunit_0500'] component obj is: " + JSON.stringify(obj.$attrs.selectedColor)); + expect(obj.$attrs.selectedColor).assertEqual('#FF008000'); + done(); + }); + + it('checkBoxJsunit_0600', 0, async function (done) { + console.info('checkBoxJsunit_0600 START'); + await CommonFunc.sleep(2000); + // verify the enum color of rgb + globalThis.value.message.notify({name:'selectedColor',value:'rgb(238, 130, 238)'}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('chek1'); + let obj = JSON.parse(strJson); + console.info("[blankJsunit_0600'] component obj is: " + JSON.stringify(obj.$attrs.selectedColor)); + expect(obj.$attrs.selectedColor).assertEqual('#FFEE82EE'); + done(); + }); + + it('checkBoxJsunit_0700', 0, async function (done) { + console.info('checkBoxJsunit_0700 START'); + await CommonFunc.sleep(1000); + // more click + let driver = Driver.create(); + await driver.delayMs(waitUiReadyMs); + let checkbox1 = await driver.findComponent(ON.id('chek1')); + expect(checkbox1 != null).assertTrue(); + await checkbox1.click(); + await driver.delayMs(waitUiReadyMs); + await checkbox1.click(); + await driver.delayMs(waitUiReadyMs); + await checkbox1.click(); + await driver.delayMs(waitUiReadyMs); + // check the click event by selectedColor + let strJson = getInspectorByKey('chek1'); + let obj = JSON.parse(strJson); + console.info("[blankJsunit_0700'] component obj is: " + JSON.stringify(obj.$attrs.selectedColor)); + expect(obj.$attrs.selectedColor).assertEqual('#FFFFFF21'); + done(); + }); + + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/List.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6230fdfd23183c29467cdc071dd36da8dc6a4fc6 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,38 @@ +/** + * 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 blankJsunit from './BlankJsunit.test.ets'; +import buttonJsunit from './ButtonJsunit.test.ets'; +import checkBoxGroupUIJsunit from './checkBoxGroupUIJsunit.test.ets'; +import CheckBoxJsunit from './CheckBoxJsunit.test.ets'; +import datelPanelJsunit from './datelPanelJsunit.test.ets'; +import dataPickerJsunit from './dataPickerJsunit.test.ets'; +import dividerJsunit from './dividerJsunit.test.ets'; +import gaugeJsunit from './gaugeJsunit.test.ets'; +import loadingProgressJsunit from './loadingProgressJsunit.test.ets'; +import marqueeJsunit from './marqueeJsunit.test.ets'; + +export default function testsuite() { + blankJsunit(); + buttonJsunit(); + checkBoxGroupUIJsunit(); + CheckBoxJsunit(); + dataPickerJsunit(); + datelPanelJsunit(); + dividerJsunit(); + gaugeJsunit(); + loadingProgressJsunit(); + marqueeJsunit(); +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/checkBoxGroupUIJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/checkBoxGroupUIJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..822cb05336ec7031db15b91ae28ecac6643fdd63 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/checkBoxGroupUIJsunit.test.ets @@ -0,0 +1,172 @@ +/** + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" +import router from '@system.router'; +import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest'; +import CommonFunc from '../MainAbility/utils/Common'; +import {MessageManager,Callback} from '../MainAbility/utils/MessageManager'; +const waitUiReadyMs = 1000; + +export default function checkBoxGroupUIJsunit() { + describe('checkBoxGroupUIJsunit', function () { + beforeEach(async function (done) { + console.info("checkBoxJsunit beforeEach start"); + let options = { + uri: 'MainAbility/pages/checkBoxGroupUI', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get checkBoxGroupUIJsunit pages:" + JSON.stringify(pages)); + if (!("checkBoxGroupUI" == pages.name)) { + console.info("get checkBoxGroupUIJsunit state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push checkBoxGroupUIJsunit success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push checkBoxGroupUI page error:" + err); + expect().assertFail(); + } + done(); + }); + + + it('checkBoxGroupUIJsunit_0100', 0, async function (done) { + console.info('checkBoxGroupUIJsunit_0100 START'); + await CommonFunc.sleep(1000); + // get the checkboxGroup component and test attribute + let strJson = getInspectorByKey('allck'); + console.info("checkBoxGroupUIJsunit_0100 strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("checkBoxGroupUIJsunit_0100 component obj is: " + JSON.stringify(obj.$attrs.selectedColor)); + expect(obj.$attrs.selectedColor).assertEqual('#FF007DFF'); + // add assert single checkbox selectedColor + let strJson2 = getInspectorByKey('cb1'); + console.info("checkBoxGroupUIJsunit_cb1_0100 strJson:" + strJson2); + let obj2 = JSON.parse(strJson2); + console.info("checkBoxGroupUIJsunit_cb1_0100 component obj2 is: " + JSON.stringify(obj2.$attrs.selectedColor)); + expect(obj2.$attrs.selectedColor).assertEqual('#FF007DEF'); + done(); + }); + + it('checkBoxGroupUIJsunit_0200', 0, async function (done) { + console.info('checkBoxGroupUIJsunit_0200 START'); + await CommonFunc.sleep(1000); + // modify the attribute normal value of checkbox dynamically + await CommonFunc.sleep(2000); + globalThis.value.message.notify({name:'selectedColor',value:'#EEAAFF'}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('allck'); + let obj = JSON.parse(strJson); + console.info("[checkBoxGroupUIJsunit_0200'] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.selectedColor).assertEqual('#FFEEAAFF'); + // add assert single checkbox selectedColor + let strJson2 = getInspectorByKey('cb1'); + let obj2 = JSON.parse(strJson2); + console.info("checkBoxGroupUIJsunit_cb1_0200 component obj2 is: " + JSON.stringify(obj2.$attrs.selectedColor)); + expect(obj2.$attrs.selectedColor).assertEqual('#FF007DEF'); + done(); + }); + + it('checkBoxGroupUIJsunit_0300', 0, async function (done) { + console.info('checkBoxGroupUIJsunit_0300 START'); + await CommonFunc.sleep(1000); + // modify the attribute illegal value of checkbox dynamically + globalThis.value.message.notify({name:'selectedColor',value:'#eaf'}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('allck'); + let obj = JSON.parse(strJson); + console.info("[checkBoxGroupUIJsunit_0300 '] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.selectedColor).assertEqual('#FFEEAAFF'); + done(); + }); + + it('checkBoxGroupUIJsunit_0400', 0, async function (done) { + console.info('checkBoxGroupUIJsunit_0400 START'); + await CommonFunc.sleep(1000); + // modify the selectedColor + globalThis.value.message.notify({name:'selectedColor',value:'rgb(238, 130, 238)'}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('allck'); + let obj = JSON.parse(strJson); + console.info("[checkBoxGroupUIJsunit_0400 '] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.selectedColor).assertEqual('#FFEE82EE'); + done(); + }); + + it('checkBoxGroupUIJsunit_0500', 0, async function (done) { + console.info('checkBoxGroupUIJsunit_0500 START'); + await CommonFunc.sleep(1000); + // modify the selectedColor + globalThis.value.message.notify({name:'selectedColor',value:Color.Green}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('allck'); + let obj = JSON.parse(strJson); + console.info("[checkBoxGroupUIJsunit_0500 '] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.selectedColor).assertEqual('#FF008000'); + done(); + }); + + it('checkBoxGroupUIJsunit_0600', 0, async function (done) { + console.info('checkBoxGroupUIJsunit_0600 START'); + await CommonFunc.sleep(1000); + // test the clicking event of checkboxGroup + let driver = Driver.create(); + await driver.delayMs(waitUiReadyMs); + let checkGoup = await driver.findComponent(ON.id('allck')); + await checkGoup.click(); + await driver.delayMs(waitUiReadyMs); + await checkGoup.click(); + await driver.delayMs(waitUiReadyMs); + // check the isSelect and name + let ttx = await driver.findComponent(ON.id('text1')); + let txt = await ttx.getText(); + console.info("[checkBoxGroupUIJsunit_0600'] component obj is: " + txt); + expect(txt).assertEqual('["checkbox1","checkbox2","checkbox3"]'); + let ttxx = await driver.findComponent(ON.id('text2')); + let txtt = await ttxx.getText(); + console.info("[checkBoxGroupUIJsunit_0600'] component obj2 is: " + txtt); + expect(txtt).assertEqual('0'); + await checkGoup.click(); + await driver.delayMs(waitUiReadyMs); + done(); + }); + + it('checkBoxGroupUIJsunit_0700', 0, async function (done) { + console.info('checkBoxGroupUIJsunit_0700 START'); + await CommonFunc.sleep(1000); + let driver = Driver.create(); + await driver.delayMs(waitUiReadyMs); + let checkGoup = await driver.findComponent(ON.id('cb2')); + await checkGoup.click(); + await driver.delayMs(waitUiReadyMs); + // check the isSelect and name + let ttx = await driver.findComponent(ON.id('text1')); + let txt = await ttx.getText(); + console.info("[checkBoxGroupUIJsunit_0700'] component obj is: " + txt); + expect(txt).assertEqual('["checkbox2"]'); + let ttxx = await driver.findComponent(ON.id('text2')); + let txtt = await ttxx.getText(); + console.info("[checkBoxGroupUIJsunit_0700'] component obj2 is: " + txtt); + expect(txtt).assertEqual('1'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/dataPickerJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/dataPickerJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..05b9f7d6a040947d37d58549d20f821731d14537 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/dataPickerJsunit.test.ets @@ -0,0 +1,78 @@ +/** + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" +import router from '@system.router'; +import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest'; +import CommonFunc from '../MainAbility/utils/Common'; +import {MessageManager,Callback} from '../MainAbility/utils/MessageManager'; +const waitUiReadyMs = 1000; + +export default function dataPickerJsunit() { + describe('dataPickerJsunit', function () { + beforeEach(async function (done) { + console.info("dataPickerJsunit beforeEach start"); + let options = { + uri: 'MainAbility/pages/dataPicker', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get dataPickerJsunit state pages:" + JSON.stringify(pages)); + if (!("dataPicker" == pages.name)) { + console.info("get dataPickerJsunit state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push dataPickerJsunit success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push dataPickerJsunit page error:" + err); + expect().assertFail(); + } + done(); + }); + + it('dataPickerJsunit_0100', 0, async function (done) { + console.info('dataPickerJsunit_0100 START'); + await CommonFunc.sleep(1000); + // get the dataPicker component and test attribute to confirm + let strJson = getInspectorByKey('dataPicker'); + let obj = JSON.parse(strJson); + console.info("obj is: " + JSON.stringify(obj)); + console.info("dataPickerJsunit_0100'] component obj is: " + obj.$attrs.options + "---" + obj.$attrs.startDate); + console.info("dataPickerJsunit_0100'] component obj is: " + obj.$attrs.start + "--" + obj.$attrs.end + "--" + obj.$attrs.selected); + expect(obj.$attrs.lunar).assertEqual('false'); + done(); + }); + + it('dataPickerJsunit_0200', 0, async function (done) { + console.info('dataPickerJsunit_0200 START'); + // modify the type attribute normal value of dataPicker dynamically + globalThis.value.message.notify({name:'isLunar',value:true}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('dataPicker'); + let obj = JSON.parse(strJson); + console.info("[dataPicker'] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.lunar).assertEqual('true'); + globalThis.value.message.notify({name:'isLunar',value:false}) + await CommonFunc.sleep(2000); + let strJson2 = getInspectorByKey('dataPicker'); + let obj2 = JSON.parse(strJson2); + console.info("[dataPicker'] component obj2 is: " + JSON.stringify(obj2)); + expect(obj2.$attrs.lunar).assertEqual('false'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/datelPanelJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/datelPanelJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5cb7b20d9a31e5e60e45c2e3a138e8ba665da42c --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/datelPanelJsunit.test.ets @@ -0,0 +1,170 @@ +/** + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" +import router from '@system.router'; +import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest'; +import CommonFunc from '../MainAbility/utils/Common'; +import {MessageManager,Callback} from '../MainAbility/utils/MessageManager'; +const waitUiReadyMs = 1000; + +export default function datelPanelJsunit() { + describe('datelPanelJsunit', function () { + beforeEach(async function (done) { + console.info("datelPanelJsunit beforeEach start"); + let options = { + uri: 'MainAbility/pages/DatelPanel', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get datelPanelJsunit state pages:" + JSON.stringify(pages)); + if (!("DatelPanel" == pages.name)) { + console.info("get datelPanelJsunit state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push datelPanelJsunit success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push datelPanelJsunit page error:" + err); + expect().assertFail(); + } + done(); + }); + + it('datelPanelJsunit_0100', 0, async function (done) { + console.info('datelPanelJsunit_0100 START'); + await CommonFunc.sleep(1000); + // get the datelPanel component and test attribute + let strJson = getInspectorByKey('dp1'); + let obj = JSON.parse(strJson); + console.info("datelPanelJsunit_0100'] component obj is: " + JSON.stringify(obj.$attrs.values)); + let valus = obj.$attrs.values; + let expectV:string = [25,1].toString(); + expect(valus == expectV).assertTrue(); + expect(obj.$attrs.max).assertEqual('26.000000'); + expect(obj.$attrs.type).assertEqual('DataPanelType.Line'); + done(); + }); + + it('datelPanelJsunit_0200', 0, async function (done) { + console.info('datelPanelJsunit_0200 START'); + await CommonFunc.sleep(1000); + // modify the type attribute normal value of DataPanel dynamically + globalThis.value.message.notify({name:'dataPanelType',value:DataPanelType.Line}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('dp1'); + let obj = JSON.parse(strJson); + console.info("[datelPanelJsunit_0200'] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.type).assertEqual('DataPanelType.Line'); + done(); + }); + + it('datelPanelJsunit_0300', 0, async function (done) { + console.info('datelPanelJsunit_0300 START'); + await CommonFunc.sleep(1000); + // modify the attribute illegal value of DataPanel dynamically + globalThis.value.message.notify({name:'dataPanelType',value:3}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('dp1'); + let obj = JSON.parse(strJson); + console.info("[datelPanelJsunit_0300'] component obj is: " + JSON.stringify(obj)); + // check the default value + expect(obj.$attrs.type).assertEqual('DataPanelType.Circle'); + done(); + }); + + it('datelPanelJsunit_0400', 0, async function (done) { + console.info('datelPanelJsunit_0400 START'); + await CommonFunc.sleep(1000); + // modify the values attribute normal value of DataPanel dynamically + globalThis.value.message.notify({name:'values',value:[10,10,10,10,10,10,10,10,10]}) + await CommonFunc.sleep(200); + // check the value of changed attribute + let strJson = getInspectorByKey('dp1'); + let obj = JSON.parse(strJson); + console.info("[datelPanelJsunit_0400'] component obj is: " + JSON.stringify(obj.$attrs.values)); + let valus = obj.$attrs.values; + let expectV:string = [10,10,10,10,10,10,10,10,10].toString(); + expect(valus == expectV).assertTrue(); + done(); + }); + + it('datelPanelJsunit_0500', 0, async function (done) { + console.info('datelPanelJsunit_0500 START'); + await CommonFunc.sleep(1000); + // modify the values ten attribute value of DataPanel dynamically + globalThis.value.message.notify({name:'values',value:[-50,33,1,22,33,33,333,21,31,10]}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('dp1'); + let obj = JSON.parse(strJson); + console.info("[datelPanelJsunit_0500'] component obj is: " + JSON.stringify(obj.$attrs.values)); + let valus = obj.$attrs.values; + let expectV:string = [0,33,1,22,33,33,333,21,31].toString(); + expect(valus == expectV).assertTrue(); + expect(obj.$attrs.max).assertEqual('507.000000'); + done(); + }); + + it('datelPanelJsunit_0600', 0, async function (done) { + console.info('datelPanelJsunit_0600 START'); + await CommonFunc.sleep(1000); + // modify the max attribute value of DataPanel dynamically + globalThis.value.message.notify({name:'maxValue',value:27}) + await CommonFunc.sleep(2000); + // check the max value of changed attribute + let strJson = getInspectorByKey('dp1'); + let obj = JSON.parse(strJson); + console.info("[datelPanelJsunit_0600'] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.max).assertEqual('27.000000'); + done(); + }); + + it('datelPanelJsunit_0700', 0, async function (done) { + console.info('datelPanelJsunit_0700 START'); + await CommonFunc.sleep(1000); + // fix value num + globalThis.value.message.notify({name:'values',value:[-3,10,10,10,10,10,10,10,10,90]}) + await CommonFunc.sleep(2000); + // modify the max attribute value of DataPanel dynamically + globalThis.value.message.notify({name:'maxValue',value:-30}) + await CommonFunc.sleep(2000); + // check the max value of changed attribute + let strJson = getInspectorByKey('dp1'); + let obj = JSON.parse(strJson); + console.info("[datelPanelJsunit_0700'] component obj is: " + JSON.stringify(obj.$attrs.options)); + expect(obj.$attrs.max).assertEqual('80.000000'); + done(); + }); + + it('datelPanelJsunit_0800', 0, async function (done) { + console.info('datelPanelJsunit_0800 START'); + await CommonFunc.sleep(1000); + // fix value num + globalThis.value.message.notify({name:'values',value:[10,10,10,10,10,10,10,10,10]}) + await CommonFunc.sleep(2000); + // modify the max attribute value of DataPanel dynamically + globalThis.value.message.notify({name:'maxValue',value:0}) + await CommonFunc.sleep(2000); + // check the max value of changed attribute + let strJson = getInspectorByKey('dp1'); + let obj = JSON.parse(strJson); + console.info("[datelPanelJsunit_0800'] component obj is: " + JSON.stringify(obj.$attrs.max)); + expect(obj.$attrs.max).assertEqual('90.000000'); + done(); + }); + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/dividerJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/dividerJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..887471d4da4ff85462b285c1fdf451c663fc29bc --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/dividerJsunit.test.ets @@ -0,0 +1,145 @@ +/** + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" +import router from '@system.router'; +import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest'; +import CommonFunc from '../MainAbility/utils/Common'; +import {MessageManager,Callback} from '../MainAbility/utils/MessageManager'; +const waitUiReadyMs = 1000; + +export default function dividerJsunit() { + describe('dividerJsunit', function () { + beforeEach(async function (done) { + console.info("dividerJsunit beforeEach start"); + let options = { + uri: 'MainAbility/pages/divider', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get dividerJsunit state pages:" + JSON.stringify(pages)); + if (!("divider" == pages.name)) { + console.info("get dividerJsunit state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push dividerJsunit success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push dividerJsunit page error:" + err); + expect().assertFail(); + } + done(); + }); + + it('dividerJsunit_0100', 0, async function (done) { + console.info('dividerJsunit_0100 START'); + await CommonFunc.sleep(1000); + // get the dividerJsunit_0100 component and test attribute + let strJson = getInspectorByKey('divider'); + let obj = JSON.parse(strJson); + console.info("dividerJsunit_0100'] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.vertical).assertEqual('false'); + expect(obj.$attrs.strokeWidth).assertEqual('20.000000'); + // to confirm + //expect(obj.$attrs.lineCap).assertEqual('LineCapStyle.Butt'); + expect(obj.$attrs.lineCap).assertEqual('BUTT'); + expect(obj.$attrs.color).assertEqual('#FFACBDEF'); + done(); + }); + + it('dividerJsunit_0200', 0, async function (done) { + console.info('dividerJsunit_0200 START'); + await CommonFunc.sleep(1000); + // modify the type attribute normal value of divider dynamically + globalThis.value.message.notify({name:'strokeWidth',value:'30'}) + await CommonFunc.sleep(200); + globalThis.value.message.notify({name:'lineCapStyle',value:LineCapStyle.Round}) + await CommonFunc.sleep(200); + globalThis.value.message.notify({name:'color',value:'#FFFFFF'}) + await CommonFunc.sleep(200); + // check the value of changed attribute + let strJson = getInspectorByKey('divider'); + let obj = JSON.parse(strJson); + console.info("[dividerJsunit_0200'] component obj is: " + JSON.stringify(obj.$attrs.lineCap)); + expect(obj.$attrs.strokeWidth).assertEqual('30.000000'); + expect(obj.$attrs.lineCap).assertEqual('ROUND'); + expect(obj.$attrs.color).assertEqual('#FFFFFFFF'); + done(); + }); + + it('dividerJsunit_0300', 0, async function (done) { + console.info('dividerJsunit_0300 START'); + await CommonFunc.sleep(1000); + // modify the lineCapStyle attribute normal value of divider dynamically + globalThis.value.message.notify({name:'lineCapStyle',value:LineCapStyle.Square}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('divider'); + let obj = JSON.parse(strJson); + console.info("[dividerJsunit_0300'] component obj is: " + obj.$attrs.lineCap); + expect(obj.$attrs.lineCap).assertEqual('SQUARE'); + done(); + }); + + it('dividerJsunit_0400', 0, async function (done) { + console.info('datelPanelJsunit_0400 START'); + await CommonFunc.sleep(1000); + // modify the values attribute illegal value of divider dynamically + globalThis.value.message.notify({name:'strokeWidth',value:'-30'}) + await CommonFunc.sleep(200); + globalThis.value.message.notify({name:'lineCapStyle',value:'4'}) + await CommonFunc.sleep(200); + globalThis.value.message.notify({name:'color',value:'#FF'}) + await CommonFunc.sleep(200); + // check the value of changed attribute + let strJson = getInspectorByKey('divider'); + let obj = JSON.parse(strJson); + expect(obj.$attrs.strokeWidth).assertEqual('-30.000000'); + expect(obj.$attrs.lineCap).assertEqual('BUTT'); + // to confirm + expect(obj.$attrs.color).assertEqual('#33182431'); + done(); + }); + + it('dividerJsunit_0500', 0, async function (done) { + console.info('dividerJsunit_0500 START'); + await CommonFunc.sleep(1000); + // test the common attribute + globalThis.value.message.notify({name:'widthK',value:'1.0'}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('divider'); + let obj = JSON.parse(strJson); + console.info("[dividerJsunit_0500'] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.width).assertEqual('1.00vp') + done(); + }); + + + it('dividerJsunit_0600', 0, async function (done) { + console.info('dividerJsunit_0500 START'); + await CommonFunc.sleep(1000); + // modify the type attribute normal value of divider dynamically + globalThis.value.message.notify({name:'vertical',value:true}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('divider'); + let obj = JSON.parse(strJson); + console.info("[dividerJsunit_0600'] component obj is: " + JSON.stringify(obj.$attrs.vertical)); + expect(obj.$attrs.vertical).assertEqual('true'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/gaugeJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/gaugeJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bce248f5df61363047605d52634f677ef0c87376 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/gaugeJsunit.test.ets @@ -0,0 +1,186 @@ +/** + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" +import router from '@system.router'; +import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest'; +import CommonFunc from '../MainAbility/utils/Common'; +import {MessageManager,Callback} from '../MainAbility/utils/MessageManager'; +const waitUiReadyMs = 1000; + +export default function gaugeJsunit() { + describe('gaugeJsunit', function () { + beforeEach(async function (done) { + console.info("gaugeJsunit beforeEach start"); + let options = { + uri: 'MainAbility/pages/guage', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get gaugeJsunit state pages:" + JSON.stringify(pages)); + if (!("guage" == pages.name)) { + console.info("get gaugeJsunit state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push gaugeJsunit success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push gaugeJsunit page error:" + err); + expect().assertFail(); + } + done(); + }); + + it('gaugeJsunit_0100', 0, async function (done) { + console.info('gaugeJsunit_0100 START'); + await CommonFunc.sleep(1000); + // get the gauge component and test attribute + let strJson = getInspectorByKey('guage'); + let obj = JSON.parse(strJson); + console.info('gaugeJsunit_0100 component obj is:' + JSON.stringify(obj)); + console.info('gaugeJsunit_0100 component obj startAngle is:' + obj.$attrs.startAngle); + console.info('gaugeJsunit_0100 component obj startAngle is:' + obj.$attrs.endAngle); + console.info('gaugeJsunit_0100 component obj startAngle is:' + obj.$attrs.strokeWidth); + console.info('gaugeJsunit_0100 component obj startAngle is:' + obj.$attrs.colors); + expect(obj.$attrs.startAngle).assertEqual('0.00'); + expect(obj.$attrs.endAngle).assertEqual('0.00'); + expect(obj.$attrs.strokeWidth).assertEqual('0.00vp'); + expect(obj.$attrs.value).assertEqual('30.00'); + expect(obj.$attrs.min).assertEqual('0.00'); + expect(obj.$attrs.max).assertEqual('100.00'); + let colors = obj.$attrs.colors; + console.info('gaugeJsunit_0100 component obj is: ' + colors); + expect(colors).assertEqual('[["#FF317AF7",0.10000000149011612],["#FF5BA854",0.20000000298023224],["#FFE08C3A",0.300000011920929],["#FF9C554B",0.40000000596046448]]'); + done(); + }); + + it('gaugeJsunit_0200', 0, async function (done) { + console.info('gaugeJsunit_0200 START'); + await CommonFunc.sleep(1000); + // modify the type attribute normal value of guage dynamically + globalThis.value.message.notify({name:'startAngle',value:20}) + await CommonFunc.sleep(2000); + globalThis.value.message.notify({name:'strokeWidth',value:30}) + await CommonFunc.sleep(2000); + globalThis.value.message.notify({name:'endAngle',value:270}) + await CommonFunc.sleep(2000); + globalThis.value.message.notify({name:'colors',value:[[0x317AF6, 0.3], [0x5BA854, 0.3], [0xE08C3A, 0.4], [0x9A554B, 0.4]]}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('guage'); + let obj = JSON.parse(strJson); + console.info('gaugeJsunit_0200 component obj is: ' + JSON.stringify(obj)); + expect(obj.$attrs.startAngle).assertEqual('20.00'); + expect(obj.$attrs.endAngle).assertEqual('270.00'); + expect(obj.$attrs.strokeWidth).assertEqual('30.00vp'); + let colors = obj.$attrs.colors; + console.info('gaugeJsunit_0200 component obj is: ' + colors); + expect(colors).assertEqual('[["#FF317AF6",0.300000011920929],["#FF5BA854",0.300000011920929],["#FFE08C3A",0.40000000596046448],["#FF9A554B",0.40000000596046448]]'); + done(); + }); + + it('gaugeJsunit_0300', 0, async function (done) { + console.info('gaugeJsunit_0200 START'); + await CommonFunc.sleep(1000); + // modify the parameter value of guage dynamically + globalThis.value.message.notify({name:'value',value:'40'}) + await CommonFunc.sleep(2000); + globalThis.value.message.notify({name:'min',value:'20'}) + await CommonFunc.sleep(2000); + globalThis.value.message.notify({name:'max',value:'90'}) + await CommonFunc.sleep(2000); + // check the value of changed parameter + let strJson = getInspectorByKey('guage'); + let obj = JSON.parse(strJson); + expect(obj.$attrs.value).assertEqual('0.00'); + expect(obj.$attrs.min).assertEqual('0.00'); + expect(obj.$attrs.max).assertEqual('100.00'); + done(); + }); + + + it('gaugeJsunit_0400', 0, async function (done) { + console.info('gaugeJsunit_0400 START'); + await CommonFunc.sleep(1000); + // modify the values attribute illegal value of divider dynamically + globalThis.value.message.notify({name:'startAngle',value:'-30'}) + await CommonFunc.sleep(2000); + globalThis.value.message.notify({name:'strokeWidth',value:'-30'}) + await CommonFunc.sleep(2000); + globalThis.value.message.notify({name:'endAngle',value:'450'}) + await CommonFunc.sleep(2000); + globalThis.value.message.notify({name:'colors',value:'[[0x317AF6, 2], [0x5BA, 0.3], [0xE08C3A, 0.4], [0x9A554B, 0.4]]'}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('guage'); + let obj = JSON.parse(strJson); + console.info('gaugeJsunit_0400 component obj is: ' + JSON.stringify(obj)); + expect(obj.$attrs.startAngle).assertEqual('-30.00'); + expect(obj.$attrs.endAngle).assertEqual('450.00'); + expect(obj.$attrs.strokeWidth).assertEqual('-30.00vp'); + let colors = obj.$attrs.colors; + console.info('gaugeJsunit_0400 component obj is: ' + colors); + expect(colors).assertEqual('[["#FF317AF6",0.300000011920929],["#FF5BA854",0.300000011920929],["#FFE08C3A",0.40000000596046448],["#FF9A554B",0.40000000596046448]]'); + done(); + }); + + it('gaugeJsunit_0500', 0, async function (done) { + console.info('gaugeJsunit_0500 START'); + await CommonFunc.sleep(1000); + // test the illegal parameter + globalThis.value.message.notify({name:'value',value:'-40'}) + await CommonFunc.sleep(2000); + globalThis.value.message.notify({name:'min',value:'-6'}) + await CommonFunc.sleep(2000); + globalThis.value.message.notify({name:'max',value:'-7'}) + await CommonFunc.sleep(2000); + // check the value of changed parameter + let strJson = getInspectorByKey('guage'); + let obj = JSON.parse(strJson); + expect(obj.$attrs.value).assertEqual('0.00'); + expect(obj.$attrs.min).assertEqual('0.00'); + expect(obj.$attrs.max).assertEqual('100.00'); + done(); + }); + + it('gaugeJsunit_0600', 0, async function (done) { + console.info('gaugeJsunit_0600 START'); + await CommonFunc.sleep(1000); + // test the support common attribute + globalThis.value.message.notify({name:'wth',value:'20'}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('guage'); + let obj = JSON.parse(strJson); + console.info('gaugeJsunit_0600 component obj is: ' + JSON.stringify(obj)); + expect(obj.$attrs.width).assertEqual('20.00vp') + done(); + }); + + it('gaugeJsunit_0700', 0, async function (done) { + console.info('gaugeJsunit_0700 START'); + await CommonFunc.sleep(1000); + // test the support common attribute + globalThis.value.message.notify({name:'wth',value:'-60'}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('guage'); + let obj = JSON.parse(strJson); + console.info('gaugeJsunit_0700 component obj is: ' + JSON.stringify(obj)); + expect(obj.$attrs.width).assertEqual('0.00vp') + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/loadingProgressJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/loadingProgressJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1cf9c897d6d2f7c967aa0655082cfc27697242bc --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/loadingProgressJsunit.test.ets @@ -0,0 +1,84 @@ +/** + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" +import router from '@system.router'; +import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest'; +import CommonFunc from '../MainAbility/utils/Common'; +import {MessageManager,Callback} from '../MainAbility/utils/MessageManager'; +const waitUiReadyMs = 1000; + +export default function loadingProgressJsunit() { + describe('loadingProgressJsunit', function () { + beforeEach(async function (done) { + console.info("loadingProgressJsunit beforeEach start"); + let options = { + uri: 'MainAbility/pages/loadingprogress', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get loadingProgressJsunit state pages:" + JSON.stringify(pages)); + if (!("loadingprogress" == pages.name)) { + console.info("get loadingProgressJsunit state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push loadingProgressJsunit success" + JSON.stringify(result)); + } + } catch (err) { + console.error("push loadingProgressJsunit page error:" + err); + expect().assertFail(); + } + done(); + }); + + it('loadingProgressJsunit_0100', 0, async function (done) { + console.info('loadingProgressJsunit_0100 START'); + await CommonFunc.sleep(1000); + // get the gauge component and test attribute + let strJson = getInspectorByKey('loadingProgress'); + let obj = JSON.parse(strJson); + console.info('loadingProgressJsunit_0100 component obj is:' + JSON.stringify(obj)); + expect(obj.$attrs.color).assertEqual('#FF0000FF'); + done(); + }); + + it('loadingProgressJsunit_0200', 0, async function (done) { + console.info('loadingProgressJsunit_0200 START'); + await CommonFunc.sleep(1000); + // modify the color attribute normal value of loadingProgress dynamically + globalThis.value.message.notify({name:'color',value:Color.Green}) + await CommonFunc.sleep(2000); + // check the value of changed attribute + let strJson = getInspectorByKey('loadingProgress'); + let obj = JSON.parse(strJson); + console.info('loadingProgressJsunit_0200 component obj is: ' + JSON.stringify(obj)); + expect(obj.$attrs.color).assertEqual('#FF008000'); + done(); + }); + + it('loadingProgressJsunit_0300', 0, async function (done) { + console.info('loadingProgressJsunit_0300 START'); + await CommonFunc.sleep(1000); + // modify the values attribute illegal value of loadingProgress dynamically + globalThis.value.message.notify({name:'color',value:'-20'}) + await CommonFunc.sleep(2000); + let strJson = getInspectorByKey('loadingProgress'); + let obj = JSON.parse(strJson); + console.info('loadingProgressJsunit_0300 component obj is: ' + JSON.stringify(obj)); + expect(obj.$attrs.color).assertEqual('#FF008000'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/marqueeJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/marqueeJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..67a5c08e9796a42139b33c2d2878b1712e79f30c --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/marqueeJsunit.test.ets @@ -0,0 +1,160 @@ +/** + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" +import router from '@system.router'; +import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.uitest'; +import CommonFunc from '../MainAbility/utils/Common'; +import {MessageManager,Callback} from '../MainAbility/utils/MessageManager'; +const waitUiReadyMs = 1000; + +export default function marqueeJsunit() { + describe('marqueeJsunit', function () { + beforeEach(async function (done) { + console.info("marqueeJsunit beforeEach start"); + let options = { + uri: 'MainAbility/pages/marquee', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get marqueeJsunit state pages:" + JSON.stringify(pages)); + if (!("marguee" == pages.name)) { + console.info("get marqueeJsunit state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push marqueeJsunit success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push marqueeJsunit page error:" + err); + expect().assertFail(); + } + done(); + }); + + it('marqueeJsunit_0100', 0, async function (done) { + console.info('marqueeJsunit_0100 START'); + await CommonFunc.sleep(1000); + // get the marquee component and test attribute + let strJson = getInspectorByKey('marquee'); + console.info('marqueeJsunit_0100 hhe'); + let obj = JSON.parse(strJson); + // to confirm allowScale + console.info('marqueeJsunit_0100 component obj is: ' + obj.$attrs.allowScale); + expect(obj.$attrs.start).assertEqual('false'); + expect(obj.$attrs.step).assertEqual('50.000000'); + expect(obj.$attrs.loop).assertEqual('2'); + expect(obj.$attrs.fromStart).assertEqual('true'); + expect(obj.$attrs.src).assertEqual('Running Marquee starts rolling'); + done(); + }); + + it('marqueeJsunit_0200', 0, async function (done) { + console.info('marqueeJsunit_0200 START'); + // modify the type attribute normal value of marquee dynamically + globalThis.value.message.notify({name:'fromStart',value:false}) + await CommonFunc.sleep(200); + // check the value of changed parameter + let strJson = getInspectorByKey('marquee'); + let obj = JSON.parse(strJson); + expect(obj.$attrs.fromStart).assertEqual('false'); + done(); + }); + + it('marqueeJsunit_0300', 0, async function (done) { + console.info('marqueeJsunit_0300 START'); + await CommonFunc.sleep(1000); + // modify the values partly attribute illegal value of marguee dynamically + globalThis.value.message.notify({name:'loop',value:-30}) + await CommonFunc.sleep(1000); + // check the value of changed attribute + let strJson = getInspectorByKey('marquee'); + let obj = JSON.parse(strJson); + expect(obj.$attrs.loop).assertEqual('2'); + done(); + }); + + it('marqueeJsunit_0400', 0, async function (done) { + console.info('marqueeJsunit_0400 START'); + // modify the type attribute normal value of marquee dynamically + globalThis.value.message.notify({name:'step',value:20}) + await CommonFunc.sleep(2000); + // check the value of changed parameter + let strJson = getInspectorByKey('marquee'); + let obj = JSON.parse(strJson); + expect(obj.$attrs.step).assertEqual('20.000000'); + done(); + }); + + it('marqueeJsunit_0500', 0, async function (done) { + console.info('marqueeJsunit_0400 START'); + await CommonFunc.sleep(1000); + // test event + let driver = Driver.create(); + await driver.delayMs(waitUiReadyMs); + let btn = await driver.findComponent(ON.id('start')); + await driver.delayMs(waitUiReadyMs); + await btn.click(); + await driver.delayMs(5000); + // check the test event + let ttx = await driver.findComponent(ON.id('text1')); + let txt = await ttx.getText(); + console.info("[marqueeJsunit_0500'] component obj is: " + txt); + expect(txt == 'onStart').assertTrue(); + let ttxx = await driver.findComponent(ON.id('text2')); + let txtt = await ttxx.getText(); + console.info("[marqueeJsunit_0500'] component obj2 is: " + txtt); + expect(txtt == 'onBounce').assertTrue(); + let ttxxx = await driver.findComponent(ON.id('text3')); + let txttt = await ttxxx.getText(); + console.info("[marqueeJsunit_0500'] component obj3 is: " + txttt); + expect(txttt == 'onFinish').assertTrue(); + done(); + }); + + it('marqueeJsunit_0600', 0, async function (done) { + console.info('marqueeJsunit_0600 START'); + // modify the values partly attribute illegal value of marguee dynamically + globalThis.value.message.notify({name:'step',value:-30}) + await CommonFunc.sleep(1000); + let strJson = getInspectorByKey('marquee'); + let obj = JSON.parse(strJson); + // to confirm + expect(obj.$attrs.step).assertEqual('-30.000000'); + done(); + }); + + it('marqueeJsunit_0700', 0, async function (done) { + console.info('marqueeJsunit_0700 START'); + // modify the type attribute normal value of marquee dynamically + globalThis.value.message.notify({name:'loop',value:1}) + await CommonFunc.sleep(1000); + let strJson = getInspectorByKey('marquee'); + let obj = JSON.parse(strJson); + expect(obj.$attrs.loop).assertEqual('1'); + done(); + }); + + it('marqueeJsunit_0800', 0, async function (done) { + console.info('marqueeJsunit_0800 START'); + // modify the type attribute normal value of marquee dynamically + globalThis.value.message.notify({name:'src',value:'starts rolling'}) + await CommonFunc.sleep(2000); + let strJson = getInspectorByKey('marquee'); + let obj = JSON.parse(strJson); + expect(obj.$attrs.src).assertEqual('starts rolling'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/module.json b/arkui/ace_ets_component_ui/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..9a7fb2986c74e9bc810340c78650fc19af4509a8 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/module.json @@ -0,0 +1,41 @@ +{ + "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", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "true" + } + ], + "abilities": [{ + "name": "com.example.myapplication.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" + ] + }] + }] + } +} \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/resources/base/element/string.json b/arkui/ace_ets_component_ui/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/arkui/ace_ets_component_ui/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_component_ui/entry/src/main/resources/base/media/icon.png b/arkui/ace_ets_component_ui/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/arkui/ace_ets_component_ui/entry/src/main/resources/base/media/icon.png differ diff --git a/arkui/ace_ets_component_ui/entry/src/main/resources/base/profile/main_pages.json b/arkui/ace_ets_component_ui/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..8ab0bfb745003bcefa0aa4b076b231376b8c6f46 --- /dev/null +++ b/arkui/ace_ets_component_ui/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,16 @@ +{ + "src": [ + "MainAbility/pages/index/index", + "MainAbility/pages/second/second", + "MainAbility/pages/blankParentWidth", + "MainAbility/pages/buttonExample", + "MainAbility/pages/checkBoxExample", + "MainAbility/pages/checkBoxGroupUI", + "MainAbility/pages/DatelPanel", + "MainAbility/pages/dataPicker", + "MainAbility/pages/divider", + "MainAbility/pages/loadingprogress", + "MainAbility/pages/guage", + "MainAbility/pages/marquee" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/signature/openharmony_sx_thirdparty.p7b b/arkui/ace_ets_component_ui/signature/openharmony_sx.p7b similarity index 81% rename from ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/signature/openharmony_sx_thirdparty.p7b rename to arkui/ace_ets_component_ui/signature/openharmony_sx.p7b index 7f7133cc6530e75d25ea3c10651c2acec9fbe99f..de77b14599538e5185cbddf4c765ef9c905d2c34 100644 Binary files a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/signature/openharmony_sx_thirdparty.p7b and b/arkui/ace_ets_component_ui/signature/openharmony_sx.p7b differ diff --git a/arkui/ace_ets_layout_test/AppScope/app.json b/arkui/ace_ets_layout_test/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..364bedf081a097b5f7ea17e9fabc06b998a09841 --- /dev/null +++ b/arkui/ace_ets_layout_test/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.acts.arkui.layout.test", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/AppScope/resources/base/element/string.json b/arkui/ace_ets_layout_test/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/arkui/ace_ets_layout_test/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/AppScope/resources/base/media/app_icon.png b/arkui/ace_ets_layout_test/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/arkui/ace_ets_layout_test/AppScope/resources/base/media/app_icon.png differ diff --git a/arkui/ace_ets_layout_test/BUILD.gn b/arkui/ace_ets_layout_test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..bd920044c554e84ba74ed50b9273b002fe36a5d3 --- /dev/null +++ b/arkui/ace_ets_layout_test/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ArkUIActsLayoutTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":ace_ets_component_flex_js_assets", + ":ace_ets_component_flex_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ArkUIActsLayoutTest" +} + +ohos_app_scope("ace_ets_component_flex_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("ace_ets_component_flex_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("ace_ets_component_flex_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":ace_ets_component_flex_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/arkui/ace_ets_layout_test/Test.json b/arkui/ace_ets_layout_test/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..128c2d7cb37b9a72f3956cd0ed8c6151f47ea414 --- /dev/null +++ b/arkui/ace_ets_layout_test/Test.json @@ -0,0 +1,24 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "com.acts.arkui.layout.test", + "module-name": "phone", + "shell-timeout": "600000" + }, + "kits": [{ + "test-file-name": [ + "ArkUIActsLayoutTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, { + "type": "ShellKit", + "run-command": [ + "power-shell wakeup", + "power-shell setmode 602" + ] + + }] +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/Application/AbilityStage.ts b/arkui/ace_ets_layout_test/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0e0206ea9fb5ce94ef140d69510b6280969dd8e --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,9 @@ +import AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/MainAbility.ts b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..4d66065e88c907379883364a43ec02989cfd626b --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,37 @@ +import Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + onCreate(want,launchParam){ + // Ability is creating, initialize resources for this ability + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage) + globalThis.windowStage = windowStage + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/common/Common.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/common/Common.ets new file mode 100644 index 0000000000000000000000000000000000000000..3ce9a67897c9de2e08b3e866f3f05d26a7591744 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/common/Common.ets @@ -0,0 +1,117 @@ +/** + * 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. + */ + +export default class CommonFunc { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + var xStep; + var yStep; + var swipeSteps; + var ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + var downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (var i = 1;i <= swipeSteps; i++) { + var movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + var upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } +} + + + + diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/common/MessageManager.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/common/MessageManager.ets new file mode 100644 index 0000000000000000000000000000000000000000..87184961b82a78bc3eda763d3d8620b2bdf6634c --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/common/MessageManager.ets @@ -0,0 +1,54 @@ +/** + * 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. + */ +export interface Callback { + (message:any):void +} + +export class MessageManager { + callback:Callback + callbacks:Map = 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); - - // 指定清空的颜色 - gl.clearColor(0.0, 0.0, 0.0, 1.0); - - // 清空 - // COLOR_BUFFER_BIT 0x00004000 - gl.clear(gl.COLOR_BUFFER_BIT); - - console.info("indices.length: " + indices.length) - gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_SHORT, 0); - - let errorCode = gl.getError(); - console.info("webgltest drawArrays getError: " + errorCode); - expect(errorCode).assertEqual(1280); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0079 - * @tc.name webgl_test_drawElements_2 - * @tc.desc Test drawElements. - */ - it('webgl_test_drawElements_2', 0, async function(done) { - //initContext(); - console.info("webgltest into drawElements"); - - gl.drawElements(1, 2, 3, 4); - - let errorCode = gl.getError(); - console.info("webgltest drawElements getError: " + errorCode); - expect(errorCode).assertEqual(0x0500); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0080 - * @tc.name webgl_test_enable - * @tc.desc Test enable. - */ - it('webgl_test_enable', 0, async function(done) { - //initContext(); - console.info("webgltest into enable"); - - gl.enable(gl.DITHER); - - const isEnabled = gl.isEnabled(gl.DITHER); - // true - console.info("webgltest enable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(true); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0081 - * @tc.name webgl_test_enable_2 - * @tc.desc Test enable. - */ - it('webgl_test_enable_2', 0, async function(done) { - //initContext(); - console.info("webgltest into enable"); - - gl.enable(gl.DITHER); - - const isEnabled = gl.isEnabled(gl.DITHER); - // true - console.info("webgltest enable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(true); - - gl.disable(gl.DITHER); - // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: - const isEnabled2 = gl.isEnabled(gl.DITHER); - // false - console.info("webgltest disable isEnabled2: " + isEnabled2); - expect(isEnabled2).assertEqual(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0082 - * @tc.name webgl_test_enableVertexAttribArray - * @tc.desc Test enableVertexAttribArray. - */ - it('webgl_test_enableVertexAttribArray', 0, async function(done) { - //initContext(); - console.info("webgltest into enableVertexAttribArray"); - //顶点着色器程序 - 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); - - const aVertexPosition = gl.getAttribLocation(programObj, "a_Position"); - - gl.enableVertexAttribArray(aVertexPosition); - gl.vertexAttribPointer(aVertexPosition, 4, gl.FLOAT, false, 0, 0); - gl.drawArrays(gl.TRIANGLES, 0, 3); - - let errorCode = gl.getError(); - console.info("webgltest enableVertexAttribArray getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0083 - * @tc.name webgl_test_finish - * @tc.desc Test finish. - */ - it('webgl_test_finish', 0, async function(done) { - //initContext(); - console.info("webgltest into finish"); - gl.finish(); - let errorCode = gl.getError(); - console.info("webgltest finish getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0084 - * @tc.name webgl_test_flush - * @tc.desc Test flush. - */ - it('webgl_test_flush', 0, async function(done) { - //initContext(); - console.info("webgltest into flush"); - gl.flush(); - let errorCode = gl.getError(); - console.info("webgltest flush getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0085 - * @tc.name webgl_test_framebufferRenderbuffer - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0086 - * @tc.name webgl_test_framebufferRenderbuffer_2 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer_2', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, "11", gl.RENDERBUFFER, renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0087 - * @tc.name webgl_test_framebufferTexture2D - * @tc.desc Test framebufferTexture2D. - */ - it('webgl_test_framebufferTexture2D', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferTexture2D"); - const texture = gl.createTexture(); - gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, - 0); - - let errorCode = gl.getError(); - console.info("webgltest framebufferTexture2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0088 - * @tc.name webgl_test_framebufferTexture2D_1 - * @tc.desc Test framebufferTexture2D. - */ - it('webgl_test_framebufferTexture2D_1', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferTexture2D"); - const texture = gl.createTexture(); - gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, - "123"); - - let errorCode = gl.getError(); - console.info("webgltest framebufferTexture2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - - //deleteContext(); - done(); - }); - - - //********************************************* webgl2 ****************************************************** - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0089 - * @tc.name webgl_test_drawBuffers - * @tc.desc Test drawBuffers. - */ - it('webgl_test_drawBuffers', 0, async function(done) { - //initContext(); - console.info("webgltest into drawBuffers"); - - gl2.drawBuffers([gl2.NONE, gl2.COLOR_ATTACHMENT1]); - - let errorCode = gl.getError(); - console.info("webgltest drawBuffers getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0090 - * @tc.name webgl_test_drawBuffers_2 - * @tc.desc Test drawBuffers. - */ - it('webgl_test_drawBuffers_2', 0, async function(done) { - //initContext(); - console.info("webgltest into drawBuffers"); - gl2.drawBuffers(["gl2.NONE", "gl2.COLOR_ATTACHMENT1"]); - let errorCode = gl.getError(); - console.info("webgltest drawBuffers getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_091 - * @tc.name webgl_test_clearBufferfv - * @tc.desc Test clearBufferfv. - */ - it('webgl_test_clearBufferfv', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferfv"); - - gl2.clearBufferfv(gl.COLOR, 0, [0.0, 0.0, 0.0, 0.0]); - - let errorCode = gl.getError(); - console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0092 - * @tc.name webgl_test_clearBufferfv_2 - * @tc.desc Test clearBufferfv. - */ - it('webgl_test_clearBufferfv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferfv"); - - gl2.clearBufferfv(gl.COLOR, "0", [0.0, 0.0, 0.0, 0.0]); - - let errorCode = gl.getError(); - console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0093 - * @tc.name webgl_test_clearBufferiv - * @tc.desc Test clearBufferiv. - */ - it('webgl_test_clearBufferiv', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferiv"); - - gl2.clearBufferiv(gl.COLOR, 0, new Int32Array([0, 1, 0, 0.5])); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0094 - * @tc.name webgl_test_clearBufferiv_2 - * @tc.desc Test clearBufferiv. - */ - it('webgl_test_clearBufferiv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferiv"); - - gl2.clearBufferiv(gl.COLOR, "0", new Int32Array([0, 1, 0, 0.5])); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0095 - * @tc.name webgl_test_clearBufferuiv - * @tc.desc Test clearBufferuiv. - */ - it('webgl_test_clearBufferuiv', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferuiv"); - - gl2.clearBufferuiv(gl.COLOR, 0, new Uint32Array([0, 1, 0, 0])); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferuiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0096 - * @tc.name webgl_test_clearBufferuiv_2 - * @tc.desc Test clearBufferuiv. - */ - it('webgl_test_clearBufferuiv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferuiv"); - - gl2.clearBufferuiv(gl.COLOR, "0", new Uint32Array([0, 1, 0, 0])); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferuiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0097 - * @tc.name webgl_test_clearBufferfi - * @tc.desc Test clearBufferfi. - */ - it('webgl_test_clearBufferfi', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferfi"); - - gl2.clearBufferfi(gl.DEPTH_STENCIL, 0, 1.0, 0); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferfi getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0098 - * @tc.name webgl_test_clearBufferfi_2 - * @tc.desc Test clearBufferfi. - */ - it('webgl_test_clearBufferfi_2', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferfi"); - - gl2.clearBufferfi(gl.DEPTH_STENCIL, "0", 1.0, 0); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferfi getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0099 - * @tc.name webgl_test_createQuery - * @tc.desc Test createQuery. - */ - it('webgl_test_createQuery', 0, async function(done) { - //initContext(); - console.info("webgltest into createQuery"); - - const query = gl2.createQuery(); - gl2.beginQuery(0x8C2F, query); - - const currentQuery = gl2.getQuery(gl2.ANY_SAMPLES_PASSED, 0x8865); - const isQuery = gl2.isQuery(currentQuery); - - console.info("webgltest createQuery isQuery: " + isQuery); - expect(isQuery).assertEqual(true); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0100 - * @tc.name webgl_test_beginQuery - * @tc.desc Test beginQuery. - */ - it('webgl_test_beginQuery', 0, async function(done) { - //initContext(); - console.info("webgltest into beginQuery"); - - var query = gl2.createQuery(); - gl2.beginQuery(0x8C2F, query); - - const currentQuery = gl2.getQuery(0x8C2F, 0x8865); - const isQuery1 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery isQuery1: " + isQuery1); - expect(isQuery1).assertEqual(true); - //deleteContext(); - done(); - }); -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test02.js b/graphic/webGL/src/main/js/default/test/WebGL.test02.js deleted file mode 100644 index 06b339d4a2bfb838e88ce52905eabe08d1cdc6f7..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test02.js +++ /dev/null @@ -1,2820 +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_webgl2', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_0101 - * @tc.name webgl_test_getQuery - * @tc.desc Test getQuery. - */ - it('webgl_test_getQuery', 0, async function(done) { - //initContext(); - console.info("webgltest into getQuery"); - - var query = gl2.createQuery(); - gl2.beginQuery(0x8C2F, query); - - var currentQuery = gl2.getQuery(0x8C2F, 0x8865); - const isQuery1 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery isQuery1: " + isQuery1); - expect(isQuery1).assertEqual(true); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0102 - * @tc.name webgl_test_isQuery - * @tc.desc Test isQuery. - */ - it('webgl_test_isQuery', 0, async function(done) { - //initContext(); - console.info("webgltest into isQuery"); - const query = gl2.createQuery(); - gl2.beginQuery(0x8C2F, query); - - const currentQuery = gl2.getQuery(0x8C2F, 0x8865); - const isQuery1 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery isQuery1: " + isQuery1); - expect(isQuery1).assertEqual(true); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0103 - * @tc.name webgl_test_isQuery_2 - * @tc.desc Test isQuery. - */ - it('webgl_test_isQuery_2', 0, async function(done) { - //initContext(); - console.info("webgltest into isQuery"); - const query = gl2.createQuery(); - - const isQuery1 = gl2.isQuery(query); - console.info("webgltest createQuery isQuery1: " + isQuery1); - expect(isQuery1).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0104 - * @tc.name webgl_test_endQuery - * @tc.desc Test endQuery. - */ - it('webgl_test_endQuery', 0, async function(done) { - //initContext(); - console.info("webgltest into endQuery"); - - var query = gl2.createQuery(); - gl2.beginQuery(0x8C2F, query); - - const currentQuery = gl2.getQuery(0x8C2F, 0x8865); - const isQuery1 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery isQuery1: " + isQuery1); - expect(isQuery1).assertEqual(true); - - gl2.endQuery(0x8C2F); - - const isQuery2 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery isQuery2: " + isQuery2); - expect(isQuery2).assertEqual(true); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0105 - * @tc.name webgl_test_getQueryParameter - * @tc.desc Test getQueryParameter. - */ - it('webgl_test_getQueryParameter', 0, async function(done) { - //initContext(); - console.info("webgltest into getQueryParameter"); - var query = gl2.createQuery(); - gl2.beginQuery(0x8C2F, query); - - var currentQuery = gl2.getQuery(0x8C2F, 0x8865); - const isQuery1 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery isQuery1: " + isQuery1); - expect(isQuery1).assertEqual(true); - - // 返回一个GLboolean 指示查询结果是否可用。 - var result = gl2.getQueryParameter(currentQuery, gl2.QUERY_RESULT_AVAILABLE); - - console.info("webgltest createQuery beginQuery getQueryParameter: " + result); - expect(typeof(result)).assertEqual("boolean"); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0106 - * @tc.name webgl_test_getQueryParameter2 - * @tc.desc Test getQueryParameter. - */ - it('webgl_test_getQueryParameter2', 0, async function(done) { - //initContext(); - console.info("webgltest into getQueryParameter"); - var query = gl2.createQuery(); - gl2.beginQuery(0x8C2F, query); - - var currentQuery = gl2.getQuery(0x8C2F, gl2.CURRENT_QUERY); - const isQuery1 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery isQuery1: " + isQuery1); - expect(isQuery1).assertEqual(true); - - // 返回一个GLboolean 指示查询结果是否可用。 - var result = gl2.getQueryParameter(currentQuery, gl2.QUERY_RESULT); - - console.info("webgltest createQuery beginQuery getQueryParameter: " + result); - expect(typeof(result)).assertEqual("number"); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0107 - * @tc.name webgl_test_deleteQuery - * @tc.desc Test deleteQuery. - */ - it('webgl_test_deleteQuery', 0, async function(done) { - //initContext(); - console.info("webgltest into deleteQuery"); - - var query = gl2.createQuery(); - gl2.beginQuery(0x8C2F, query); - - const currentQuery = gl2.getQuery(0x8C2F, 0x8865); - const isQuery1 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery isQuery1: " + isQuery1); - expect(isQuery1).assertEqual(true); - - gl2.deleteQuery(currentQuery); - - const isQuery2 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery deleteQuery isQuery2: " + isQuery2); - - expect(isQuery2).assertEqual(false); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0108 - * @tc.name webgl_test_createSampler - * @tc.desc Test createSampler. - */ - it('webgl_test_createSampler', 0, async function(done) { - //initContext(); - console.info("webgltest into createSampler"); - const sampler = gl2.createSampler(); - const isSampler1 = gl2.isSampler(sampler); - console.info("webgltest createSampler isSampler1: " + isSampler1); - expect(isSampler1).assertEqual(true); - - gl2.bindSampler(0, sampler); - const isSampler2 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); - expect(isSampler2).assertEqual(true); - - gl2.deleteSampler(sampler); - const isSampler3 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); - expect(isSampler3).assertEqual(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0109 - * @tc.name webgl_test_samplerParameterf - * @tc.desc Test samplerParameterf. - */ - it('webgl_test_samplerParameterf', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameterf"); - - let sampler = gl2.createSampler(); - // gl2.bindSampler(0, sampler); - gl2.samplerParameterf(sampler, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameterf getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0110 - * @tc.name webgl_test_samplerParameteri - * @tc.desc Test samplerParameteri. - */ - it('webgl_test_samplerParameteri', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameteri"); - let sampler = gl2.createSampler(); - // gl2.bindSampler(0, sampler); - // gl2.samplerParameteri(sampler, 0x884D, 0x2600); - gl2.samplerParameteri(sampler, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameteri getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0111 - * @tc.name webgl_test_deleteSampler - * @tc.desc Test deleteSampler. - */ - it('webgl_test_deleteSampler', 0, async function(done) { - //initContext(); - console.info("webgltest into deleteSampler"); - const sampler = gl2.createSampler(); - const isSampler1 = gl2.isSampler(sampler); - console.info("webgltest createSampler isSampler1: " + isSampler1); - expect(isSampler1).assertEqual(true); - - gl2.bindSampler(0, sampler); - const isSampler2 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); - expect(isSampler2).assertEqual(true); - - gl2.deleteSampler(sampler); - const isSampler3 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); - expect(isSampler3).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0112 - * @tc.name webgl_test_isSampler - * @tc.desc Test isSampler. - */ - it('webgl_test_isSampler', 0, async function(done) { - //initContext(); - console.info("webgltest into isSampler"); - const sampler = gl2.createSampler(); - const isSampler1 = gl2.isSampler(sampler); - console.info("webgltest createSampler isSampler1: " + isSampler1); - expect(isSampler1).assertEqual(true); - - gl2.bindSampler(0, sampler); - const isSampler2 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); - expect(isSampler2).assertEqual(true); - - gl2.deleteSampler(sampler); - const isSampler3 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); - expect(isSampler3).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0113 - * @tc.name webgl_test_isSampler_2 - * @tc.desc Test isSampler. - */ - it('webgl_test_isSampler_2', 0, async function(done) { - //initContext(); - console.info("webgltest into isSampler"); - const sampler = gl2.createSampler(); - - gl2.bindSampler(0, sampler); - const isSampler2 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); - expect(isSampler2).assertEqual(true); - - gl2.deleteSampler(sampler); - const isSampler3 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); - expect(isSampler3).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0114 - * @tc.name webgl_test_bindSampler - * @tc.desc Test bindSampler. - */ - it('webgl_test_bindSampler', 0, async function(done) { - //initContext(); - console.info("webgltest into bindSampler"); - const sampler = gl2.createSampler(); - const isSampler1 = gl2.isSampler(sampler); - console.info("webgltest createSampler isSampler1: " + isSampler1); - expect(isSampler1).assertEqual(true); - - gl2.bindSampler(0, sampler); - const isSampler2 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); - expect(isSampler2).assertEqual(true); - - gl2.deleteSampler(sampler); - const isSampler3 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); - expect(isSampler3).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0115 - * @tc.name webgl_test_getSamplerParameter_1 - * @tc.desc Test getSamplerParameter. - */ - it('webgl_test_getSamplerParameter_1', 0, async function(done) { - //initContext(); - console.info("webgltest into getSamplerParameter"); - - let sampler = gl2.createSampler(); - // const samplerParameter = gl2.getSamplerParameter(sampler, gl.TEXTURE_COMPARE_FUNC); - - const samplerParameter = gl2.getSamplerParameter(sampler, 0x884D); - - console.info("webgltest createSampler getSamplerParameter_1: " + samplerParameter); - expect(typeof(samplerParameter)).assertEqual("number"); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0116 - * @tc.name webgl_test_getSamplerParameter_2 - * @tc.desc Test getSamplerParameter. - */ - it('webgl_test_getSamplerParameter_2', 0, async function(done) { - //initContext(); - console.info("webgltest into getSamplerParameter"); - - let sampler = gl2.createSampler(); - const samplerParameter = gl2.getSamplerParameter(sampler, 0x884C); - - console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); - expect(typeof(samplerParameter)).assertEqual("number"); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0117 - * @tc.name webgl_test_getSamplerParameter_3 - * @tc.desc Test getSamplerParameter. - */ - it('webgl_test_getSamplerParameter_3', 0, async function(done) { - //initContext(); - console.info("webgltest into getSamplerParameter"); - - let sampler = gl2.createSampler(); - const samplerParameter = gl2.getSamplerParameter(sampler, gl.TEXTURE_MAG_FILTER); - - console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); - expect(typeof(samplerParameter)).assertEqual("number"); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0118 - * @tc.name webgl_test_getSamplerParameter_4 - * @tc.desc Test getSamplerParameter. - */ - it('webgl_test_getSamplerParameter_4', 0, async function(done) { - //initContext(); - console.info("webgltest into getSamplerParameter"); - - let sampler = gl2.createSampler(); - const samplerParameter = gl2.getSamplerParameter(sampler, 0x813B); - - console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); - expect(typeof(samplerParameter)).assertEqual("number"); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0119 - * @tc.name webgl_test_getSamplerParameter_5 - * @tc.desc Test getSamplerParameter. - */ - it('webgl_test_getSamplerParameter_5', 0, async function(done) { - //initContext(); - console.info("webgltest into getSamplerParameter"); - - let sampler = gl2.createSampler(); - const samplerParameter = gl2.getSamplerParameter(sampler, gl.TEXTURE_MIN_FILTER); - - console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); - expect(typeof(samplerParameter)).assertEqual("number"); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0120 - * @tc.name webgl_test_getSamplerParameter_6 - * @tc.desc Test getSamplerParameter. - */ - it('webgl_test_getSamplerParameter_6', 0, async function(done) { - //initContext(); - console.info("webgltest into getSamplerParameter"); - - let sampler = gl2.createSampler(); - const samplerParameter = gl2.getSamplerParameter(sampler, 0x813A); - - console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); - expect(typeof(samplerParameter)).assertEqual("number"); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0121 - * @tc.name webgl_test_getSamplerParameter_7 - * @tc.desc Test getSamplerParameter. - */ - it('webgl_test_getSamplerParameter_7', 0, async function(done) { - //initContext(); - console.info("webgltest into getSamplerParameter"); - - let sampler = gl2.createSampler(); - const samplerParameter = gl2.getSamplerParameter(sampler, 0x8072); - - console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); - expect(typeof(samplerParameter)).assertEqual("number"); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0122 - * @tc.name webgl_test_getSamplerParameter_8 - * @tc.desc Test getSamplerParameter. - */ - it('webgl_test_getSamplerParameter_8', 0, async function(done) { - //initContext(); - console.info("webgltest into getSamplerParameter"); - - let sampler = gl2.createSampler(); - const samplerParameter = gl2.getSamplerParameter(sampler, gl.TEXTURE_WRAP_S); - - console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); - expect(typeof(samplerParameter)).assertEqual("number"); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0123 - * @tc.name webgl_test_fenceSync - * @tc.desc Test fenceSync. - */ - it('webgl_test_fenceSync', 0, async function(done) { - //initContext(); - console.info("webgltest into fenceSync"); - - let sync = gl2.fenceSync(0x9117, 0); - let status = gl2.clientWaitSync(sync, 0, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(true); - - gl2.deleteSync(sync); - - const isSync2 = gl2.isSync(sync); - console.info("webgltest fenceSync deleteSync isSync2: " + isSync2); - expect(isSync2).assertEqual(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0124 - * @tc.name webgl_test_clientWaitSync - * @tc.desc Test clientWaitSync. - */ - it('webgl_test_clientWaitSync', 0, async function(done) { - //initContext(); - console.info("webgltest into clientWaitSync"); - let sync = gl2.fenceSync(0x9117, 0); - let status = gl2.clientWaitSync(sync, 0, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(true); - - console.info("webgltest fenceSync clientWaitSync: " + status); - - expect(status).assertEqual(gl2.ALREADY_SIGNALED || gl2.TIMEOUT_EXPIRED || gl - .CONDITION_SATISFIED || - gl.WAIT_FAILED); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0125 - * @tc.name webgl_test_waitSync - * @tc.desc Test waitSync. - */ - it('webgl_test_waitSync', 0, async function(done) { - //initContext(); - console.info("webgltest into waitSync"); - - let sync = gl2.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0); - gl2.waitSync(sync, 0, gl.TIMEOUT_IGNORED); - - let errorCode = gl.getError(); - console.info("webgltest framebufferTexture2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0126 - * @tc.name webgl_test_isSync - * @tc.desc Test isSync. - */ - it('webgl_test_isSync', 0, async function(done) { - //initContext(); - console.info("webgltest into isSync"); - let sync = gl2.fenceSync(0x9117, 0); - let status = gl2.clientWaitSync(sync, 0, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(true); - - gl2.deleteSync(sync); - - const isSync2 = gl2.isSync(sync); - console.info("webgltest fenceSync deleteSync isSync2: " + isSync2); - expect(isSync2).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0127 - * @tc.name webgl_test_getSyncParameter - * @tc.desc Test getSyncParameter. - */ - it('webgl_test_getSyncParameter', 0, async function(done) { - //initContext(); - console.info("webgltest into getSyncParameter"); - - console.info("webgltest into isSync"); - let sync = gl2.fenceSync(0x9117, 0); - let status = gl2.clientWaitSync(sync, 0, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(true); - const syncParameter = gl2.getSyncParameter(sync, 0x9112); - - console.info("webgltest fenceSync getSyncParameter: " + syncParameter); - expect(syncParameter).assertEqual(0x9116); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0128 - * @tc.name webgl_test_getSyncParameter2 - * @tc.desc Test getSyncParameter. - */ - it('webgl_test_getSyncParameter2', 0, async function(done) { - //initContext(); - console.info("webgltest into getSyncParameter"); - - console.info("webgltest into isSync"); - let sync = gl2.fenceSync(0x9117, 0); - let status = gl2.clientWaitSync(sync, 0, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(true); - - const syncParameter = gl2.getSyncParameter(sync, 0x9114); - - console.info("webgltest fenceSync getSyncParameter: " + syncParameter); - let syncParameterFlag = false; - - if (syncParameter == gl2.SIGNALED || syncParameter == gl2.UNSIGNALED) { - syncParameterFlag = true; - } - expect(syncParameterFlag).assertEqual(true); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0129 - * @tc.name webgl_test_getSyncParameter3 - * @tc.desc Test getSyncParameter. - */ - it('webgl_test_getSyncParameter3', 0, async function(done) { - //initContext(); - console.info("webgltest into getSyncParameter"); - - let sync = gl2.fenceSync(0x9117, 0); - let status = gl2.clientWaitSync(sync, 0, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(true); - const syncParameter = gl2.getSyncParameter(sync, 0x9113); - - console.info("webgltest fenceSync getSyncParameter: " + syncParameter); - expect(syncParameter).assertEqual(0x9117); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0130 - * @tc.name webgl_test_getSyncParameter4 - * @tc.desc Test getSyncParameter. - */ - it('webgl_test_getSyncParameter4', 0, async function(done) { - //initContext(); - console.info("webgltest into getSyncParameter"); - - let sync = gl2.fenceSync(0x9117, 0); - let status = gl2.clientWaitSync(sync, 0, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(true); - const syncParameter = gl2.getSyncParameter(sync, 0x9115); - - console.info("webgltest fenceSync getSyncParameter: " + syncParameter); - expect(syncParameter).assertEqual(0); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0131 - * @tc.name webgl_test_deleteSync - * @tc.desc Test deleteSync. - */ - it('webgl_test_deleteSync', 0, async function(done) { - //initContext(); - console.info("webgltest into deleteSync"); - let sync = gl2.fenceSync(0x9117, 0); - let status = gl2.clientWaitSync(sync, 0, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(true); - - gl2.deleteSync(sync); - - const isSync2 = gl2.isSync(sync); - console.info("webgltest fenceSync deleteSync isSync2: " + isSync2); - expect(isSync2).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0132 - * @tc.name webgl_test_createTransformFeedback - * @tc.desc Test createTransformFeedback. - */ - it('webgl_test_createTransformFeedback', 0, async function(done) { - //initContext(); - console.info("webgltest into createTransformFeedback"); - - const transformFeedback = gl2.createTransformFeedback(); - - - console.info("webgltest into createTransformFeedback: " + transformFeedback) - - gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); - - gl2.beginTransformFeedback(gl2.TRIANGLES); - - const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); - - console.info("BindTransformFeedback : " + isTransformFeedback2); - expect(isTransformFeedback2).assertEqual(true); - - gl2.deleteTransformFeedback(transformFeedback); - const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); - console.info("webgltest createTransformFeedback bindTransformFeedback " + - "deleteTransformFeedback isTransformFeedback3: " + isTransformFeedback3); - expect(isTransformFeedback3).assertEqual(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0133 - * @tc.name webgl_test_isTransformFeedback - * @tc.desc Test isTransformFeedback. - */ - it('webgl_test_isTransformFeedback', 0, async function(done) { - //initContext(); - console.info("webgltest into isTransformFeedback"); - let transformFeedback = gl2.createTransformFeedback(); - const isTransformFeedback1 = gl2.isTransformFeedback(transformFeedback); - console.info("webgltest createTransformFeedback isTransformFeedback1: " + - isTransformFeedback1); - expect(isTransformFeedback1).assertEqual(false); - - gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); - - const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); - console.info( - "webgltest createTransformFeedback bindTransformFeedback isTransformFeedback2: " + - isTransformFeedback2); - expect(isTransformFeedback2).assertEqual(true); - - gl2.deleteTransformFeedback(transformFeedback); - const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); - console.info("webgltest createTransformFeedback bindTransformFeedback " + - "deleteTransformFeedback isTransformFeedback3: " + isTransformFeedback3); - expect(isTransformFeedback3).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0134 - * @tc.name webgl_test_bindTransformFeedback - * @tc.desc Test bindTransformFeedback. - */ - it('webgl_test_bindTransformFeedback', 0, async function(done) { - //initContext(); - console.info("webgltest into bindTransformFeedback"); - let transformFeedback = gl2.createTransformFeedback(); - const isTransformFeedback1 = gl2.isTransformFeedback(transformFeedback); - console.info("webgltest createTransformFeedback isTransformFeedback1: " + - isTransformFeedback1); - expect(isTransformFeedback1).assertEqual(false); - - gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); - - const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); - console.info( - "webgltest createTransformFeedback bindTransformFeedback isTransformFeedback2: " + - isTransformFeedback2); - expect(isTransformFeedback2).assertEqual(true); - - gl2.deleteTransformFeedback(transformFeedback); - const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); - console.info( - "webgltest createTransformFeedback bindTransformFeedback deleteTransformFeedback " + - "isTransformFeedback3: " + isTransformFeedback3); - expect(isTransformFeedback3).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0135 - * @tc.name webgl_test_beginTransformFeedback - * @tc.desc Test beginTransformFeedback. - */ - it('webgl_test_beginTransformFeedback', 0, async function(done) { - //initContext(); - console.info("webgltest into beginTransformFeedback"); - - let transformFeedback = gl2.createTransformFeedback(); - // gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); - gl2.beginTransformFeedback(gl2.TRIANGLES); - - - let errorCode = gl.getError(); - console.info("webgltest framebufferTexture2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0137 - * @tc.name webgl_test_deleteTransformFeedback - * @tc.desc Test deleteTransformFeedback. - */ - it('webgl_test_deleteTransformFeedback', 0, async function(done) { - //initContext(); - console.info("webgltest into deleteTransformFeedback"); - const transformFeedback = gl2.createTransformFeedback(); - - gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); - - const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); - console.info( - "webgltest createTransformFeedback bindTransformFeedback isTransformFeedback2: " + - isTransformFeedback2); - expect(isTransformFeedback2).assertEqual(true); - - gl2.deleteTransformFeedback(transformFeedback); - const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); - console.info( - "webgltest createTransformFeedback bindTransformFeedback deleteTransformFeedback " + - "isTransformFeedback3: " + isTransformFeedback3); - expect(isTransformFeedback3).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0138 - * @tc.name webgl_test_getFragDataLocation - * @tc.desc Test getFragDataLocation. - */ - it('webgl_test_getFragDataLocation', 0, async function(done) { - //initContext(); - console.info("webgltest into getFragDataLocation"); - - //顶点着色器程序 - 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); - - gl2.getFragDataLocation(programObj, 'a_Position'); - - let errorCode = gl.getError(); - console.info("webgltest getFragDataLocation getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0139 - * @tc.name webgl_test_uniform1ui - * @tc.desc Test uniform1ui. - */ - it('webgl_test_uniform1ui', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform1ui"); - - //顶点着色器程序 - 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); - - const location = gl.getUniformLocation(programObj, "a_Position"); - gl2.uniform1ui(location, 1.8); - - let errorCode = gl.getError(); - console.info("webgltest uniform1ui getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0140 - * @tc.name webgl_test_uniform1ui_2 - * @tc.desc Test uniform1ui. - */ - it('webgl_test_uniform1ui_2', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform1ui"); - - const programObj = gl.createProgram(); - console.log("testUseProgram has failed for " + programObj) - - const location = gl.getUniformLocation(programObj, "v_color"); - gl2.uniform1ui(location, 1.8); - - let errorCode = gl.getError(); - console.info("webgltest uniform1ui getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0141 - * @tc.name webgl_test_uniform2ui - * @tc.desc Test uniform2ui. - */ - it('webgl_test_uniform2ui', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform2ui"); - - //顶点着色器程序 - 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); - - const location = gl.getUniformLocation(programObj, "a_Position"); - const a = gl2.uniform2ui(location, 2.8, 2.8); - - let errorCode = gl.getError(); - console.info("webgltest uniform2ui getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0142 - * @tc.name webgl_test_uniform2ui_2 - * @tc.desc Test uniform2ui. - */ - it('webgl_test_uniform2ui_2', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform2ui"); - - const programObj = gl.createProgram(); - console.log("testUseProgram has failed for " + programObj) - - const location = gl.getUniformLocation(programObj, "v_color"); - const a = gl2.uniform2ui(location, 2.8, 2.8); - - let errorCode = gl.getError(); - console.info("webgltest uniform2ui getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0143 - * @tc.name webgl_test_uniform3ui - * @tc.desc Test uniform3ui. - */ - it('webgl_test_uniform3ui', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform3ui"); - - //顶点着色器程序 - 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); - - const location = gl.getUniformLocation(programObj, "a_Position"); - const a = gl2.uniform3ui(location, 3.8, 3.8, 3.8); - - let errorCode = gl.getError(); - console.info("webgltest uniform3ui getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0144 - * @tc.name webgl_test_uniform3ui_2 - * @tc.desc Test uniform3ui. - */ - it('webgl_test_uniform3ui_2', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform3ui"); - - const programObj = gl.createProgram(); - console.log("testUseProgram has failed for " + programObj) - - const location = gl.getUniformLocation(programObj, "v_color"); - const a = gl2.uniform3ui(location, 3.8, 3.8, 3.8); - - let errorCode = gl.getError(); - console.info("webgltest uniform3ui getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0145 - * @tc.name webgl_test_uniform4ui - * @tc.desc Test uniform4ui. - */ - it('webgl_test_uniform4ui', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform4ui"); - - //顶点着色器程序 - 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); - - const location = gl.getUniformLocation(programObj, "a_Position"); - const a = gl2.uniform4ui(location, 4.8, 4.8, 4.8, 4.8); - - let errorCode = gl.getError(); - console.info("webgltest uniform4ui getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0146 - * @tc.name webgl_test_uniform4ui_2 - * @tc.desc Test uniform4ui. - */ - it('webgl_test_uniform4ui_2', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform4ui"); - - const programObj = gl.createProgram(); - console.log("testUseProgram has failed for " + programObj) - - const location = gl.getUniformLocation(programObj, "v_color"); - const a = gl2.uniform4ui(location, 4.8, 4.8, 4.8, 4.8); - - let errorCode = gl.getError(); - console.info("webgltest uniform4ui getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0147 - * @tc.name webgl_test_uniform1uiv - * @tc.desc Test uniform1uiv. - */ - it('webgl_test_uniform1uiv', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform1uiv"); - - //顶点着色器程序 - 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); - const location = gl.getUniformLocation(programObj, "a_Position"); - const a = gl2.uniform1uiv(location, float1, 1, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniform1uiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0148 - * @tc.name webgl_test_uniform1uiv_2 - * @tc.desc Test uniform1uiv. - */ - it('webgl_test_uniform1uiv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform1uiv"); - - const programObj = gl.createProgram(); - - const location = gl.getUniformLocation(programObj, "v_Color"); - const a = gl2.uniform1uiv(location, float1, 1, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniform1uiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0149 - * @tc.name webgl_test_uniform2uiv - * @tc.desc Test uniform2uiv. - */ - it('webgl_test_uniform2uiv', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform2uiv"); - - //顶点着色器程序 - 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); - - const location = gl.getUniformLocation(programObj, "a_Position"); - const a = gl2.uniform2uiv(location, float1, 2, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniform2uiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0150 - * @tc.name webgl_test_uniform2uiv_2 - * @tc.desc Test uniform2uiv. - */ - it('webgl_test_uniform2uiv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform2uiv"); - - - const programObj = gl.createProgram(); - - - const location = gl.getUniformLocation(programObj, "v_Color"); - const a = gl2.uniform2uiv(location, float2, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniform2uiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0151 - * @tc.name webgl_test_uniform3uiv - * @tc.desc Test uniform3uiv. - */ - it('webgl_test_uniform3uiv', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform3uiv"); - - //顶点着色器程序 - 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); - - const location = gl.getUniformLocation(programObj, "a_Position"); - const a = gl2.uniform3uiv(location, float1, 3, 255); - - 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_0152 - * @tc.name webgl_test_uniform3uiv_3 - * @tc.desc Test uniform3uiv. - */ - it('webgl_test_uniform3uiv_3', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform3uiv"); - - - const programObj = gl.createProgram(); - - - const location = gl.getUniformLocation(programObj, "v_Color"); - const a = gl2.uniform3uiv(location, float2, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniform3uiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0153 - * @tc.name webgl_test_uniform4uiv - * @tc.desc Test uniform4uiv. - */ - it('webgl_test_uniform4uiv', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform4uiv"); - - //顶点着色器程序 - 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); - - const location = gl.getUniformLocation(programObj, "a_Position"); - const a = gl2.uniform4uiv(location, float1, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniform4uiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0154 - * @tc.name webgl_test_uniform4uiv_2 - * @tc.desc Test uniform4uiv. - */ - it('webgl_test_uniform4uiv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into uniform4uiv"); - - - const programObj = gl.createProgram(); - - const location = gl.getUniformLocation(programObj, "v_Color"); - const a = gl2.uniform4uiv(location, float2, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniform4uiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0155 - * @tc.name webgl_test_uniformMatrix3x2fv - * @tc.desc Test uniformMatrix3x2fv. - */ - it('webgl_test_uniformMatrix3x2fv', 0, async function(done) { - //initContext(); - console.info("webgltest into uniformMatrix3x2fv"); - - //顶点着色器程序 - 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); - - const location = gl.getUniformLocation(programObj, "a_Position"); - const a = gl2.uniformMatrix3x2fv(location, false, float1, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniformMatrix3x2fv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0156 - * @tc.name webgl_test_uniformMatrix3x2fv_2 - * @tc.desc Test uniformMatrix3x2fv. - */ - it('webgl_test_uniformMatrix3x2fv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into uniformMatrix3x2fv"); - - - const programObj = gl.createProgram(); - - - const location = gl.getUniformLocation(programObj, "v_Color"); - const a = gl2.uniformMatrix3x2fv(location, false, float2, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniformMatrix3x2fv getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0157 - * @tc.name webgl_test_uniformMatrix4x2fv - * @tc.desc Test uniformMatrix4x2fv. - */ - it('webgl_test_uniformMatrix4x2fv', 0, async function(done) { - //initContext(); - console.info("webgltest into uniformMatrix4x2fv"); - - //顶点着色器程序 - 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); - const location = gl.getUniformLocation(programObj, "a_Position"); - const a = gl2.uniformMatrix4x2fv(location, false, float1, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniformMatrix4x2fv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0158 - * @tc.name webgl_test_uniformMatrix4x2fv_2 - * @tc.desc Test uniformMatrix4x2fv. - */ - it('webgl_test_uniformMatrix4x2fv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into uniformMatrix4x2fv"); - - - const programObj = gl.createProgram(); - - const location = gl.getUniformLocation(programObj, "v_Color"); - const a = gl2.uniformMatrix4x2fv(location, false, float2, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniformMatrix4x2fv getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0159 - * @tc.name webgl_test_uniformMatrix2x3fv - * @tc.desc Test uniformMatrix2x3fv. - */ - it('webgl_test_uniformMatrix2x3fv', 0, async function(done) { - //initContext(); - console.info("webgltest into uniformMatrix2x3fv"); - - //顶点着色器程序 - 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); - const location = gl.getUniformLocation(programObj, "a_Position"); - const a = gl2.uniformMatrix2x3fv(location, false, float1, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniformMatrix2x3fv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0160 - * @tc.name webgl_test_uniformMatrix2x3fv_2 - * @tc.desc Test uniformMatrix2x3fv. - */ - it('webgl_test_uniformMatrix2x3fv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into uniformMatrix2x3fv"); - - const programObj = gl.createProgram(); - - const location = gl.getUniformLocation(programObj, "v_Color"); - const a = gl2.uniformMatrix2x3fv(location, false, float2, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniformMatrix2x3fv getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0161 - * @tc.name webgl_test_uniformMatrix4x3fv - * @tc.desc Test uniformMatrix4x3fv. - */ - it('webgl_test_uniformMatrix4x3fv', 0, async function(done) { - //initContext(); - console.info("webgltest into uniformMatrix4x3fv"); - - //顶点着色器程序 - 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); - const location = gl.getUniformLocation(programObj, "a_Position"); - const a = gl2.uniformMatrix4x3fv(location, false, float1, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniformMatrix4x3fv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0162 - * @tc.name webgl_test_uniformMatrix4x3fv_2 - * @tc.desc Test uniformMatrix4x3fv. - */ - it('webgl_test_uniformMatrix4x3fv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into uniformMatrix4x3fv"); - - - const programObj = gl.createProgram(); - - const location = gl.getUniformLocation(programObj, "v_Color"); - const a = gl2.uniformMatrix4x3fv(location, false, float2, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniformMatrix4x3fv getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0163 - * @tc.name webgl_test_uniformMatrix2x4fv - * @tc.desc Test uniformMatrix2x4fv. - */ - it('webgl_test_uniformMatrix2x4fv', 0, async function(done) { - //initContext(); - console.info("webgltest into uniformMatrix2x4fv"); - - //顶点着色器程序 - 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); - const location = gl.getUniformLocation(programObj, "a_Position"); - const a = gl2.uniformMatrix2x4fv(location, false, float1, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniformMatrix2x4fv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0164 - * @tc.name webgl_test_uniformMatrix2x4fv_2 - * @tc.desc Test uniformMatrix2x4fv. - */ - it('webgl_test_uniformMatrix2x4fv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into uniformMatrix2x4fv"); - - - const programObj = gl.createProgram(); - - const location = gl.getUniformLocation(programObj, "v_Color"); - const a = gl2.uniformMatrix2x4fv(location, false, float2, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniformMatrix2x4fv getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0165 - * @tc.name webgl_test_uniformMatrix3x4fv - * @tc.desc Test uniformMatrix3x4fv. - */ - it('webgl_test_uniformMatrix3x4fv', 0, async function(done) { - //initContext(); - console.info("webgltest into uniformMatrix3x4fv"); - - //顶点着色器程序 - 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); - const location = gl.getUniformLocation(programObj, "a_Position"); - const a = gl2.uniformMatrix3x4fv(location, false, float1, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniformMatrix3x4fv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0166 - * @tc.name webgl_test_uniformMatrix3x4fv_2 - * @tc.desc Test uniformMatrix3x4fv. - */ - it('webgl_test_uniformMatrix3x4fv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into uniformMatrix3x4fv"); - - - const programObj = gl.createProgram(); - - const location = gl.getUniformLocation(programObj, "v_Color"); - const a = gl2.uniformMatrix3x4fv(location, false, float2, 0, 255); - - let errorCode = gl.getError(); - console.info("webgltest uniformMatrix3x4fv getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0167 - * @tc.name webgl_test_vertexAttribI4i - * @tc.desc Test vertexAttribI4i. - */ - it('webgl_test_vertexAttribI4i', 0, async function(done) { - //initContext(); - console.info("webgltest into vertexAttribI4i"); - - const a = gl2.vertexAttribI4i(1, 10, 11, 12, 13); - - let errorCode = gl.getError(); - console.info("webgltest vertexAttribI4i getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0168 - * @tc.name webgl_test_vertexAttribI4iv - * @tc.desc Test vertexAttribI4iv. - */ - it('webgl_test_vertexAttribI4iv', 0, async function(done) { - //initContext(); - console.info("webgltest into vertexAttribI4iv"); - - const a = gl2.vertexAttribI4iv(1, int1); - - let errorCode = gl.getError(); - console.info("webgltest vertexAttribI4iv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0169 - * @tc.name webgl_test_vertexAttribI4iv_2 - * @tc.desc Test vertexAttribI4iv. - */ - it('webgl_test_vertexAttribI4iv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into vertexAttribI4iv"); - - const a = gl2.vertexAttribI4iv(1, int2); - - let errorCode = gl.getError(); - console.info("webgltest vertexAttribI4iv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0170 - * @tc.name webgl_test_vertexAttribI4ui - * @tc.desc Test vertexAttribI4ui. - */ - it('webgl_test_vertexAttribI4ui', 0, async function(done) { - //initContext(); - console.info("webgltest into vertexAttribI4ui"); - - const a = gl2.vertexAttribI4ui(1, 10, 11, 12, 13); - - let errorCode = gl.getError(); - console.info("webgltest vertexAttribI4ui getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0171 - * @tc.name webgl_test_vertexAttribI4uiv - * @tc.desc Test vertexAttribI4uiv. - */ - it('webgl_test_vertexAttribI4uiv', 0, async function(done) { - //initContext(); - console.info("webgltest into vertexAttribI4uiv"); - - const a = gl2.vertexAttribI4uiv(1, uint1); - - let errorCode = gl.getError(); - console.info("webgltest vertexAttribI4uiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0172 - * @tc.name webgl_test_vertexAttribI4uiv_2 - * @tc.desc Test vertexAttribI4uiv. - */ - it('webgl_test_vertexAttribI4uiv_2', 0, async function(done) { - //initContext(); - console.info("webgltest into vertexAttribI4uiv"); - - const a = gl2.vertexAttribI4uiv(1, uint2); - - let errorCode = gl.getError(); - console.info("webgltest vertexAttribI4uiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0173 - * @tc.name webgl_test_vertexAttribIPointer - * @tc.desc Test vertexAttribIPointer. - */ - it('webgl_test_vertexAttribIPointer', 0, async function(done) { - //initContext(); - console.info("webgltest into vertexAttribIPointer"); - - const a = gl2.vertexAttribIPointer(2, 4, gl.UNSIGNED_BYTE, 20, 16); - - let errorCode = gl.getError(); - console.info("webgltest vertexAttribIPointer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0174 - * @tc.name webgl_test_vertexAttribDivisor - * @tc.desc Test vertexAttribDivisor. - */ - it('webgl_test_vertexAttribDivisor', 0, async function(done) { - //initContext(); - console.info("webgltest into vertexAttribDivisor"); - - const a = gl2.vertexAttribDivisor(0, 2); - - let errorCode = gl.getError(); - console.info("webgltest vertexAttribDivisor getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0175 - * @tc.name webgl_test_vertexAttribDivisor_2 - * @tc.desc Test vertexAttribDivisor. - */ - it('webgl_test_vertexAttribDivisor_2', 0, async function(done) { - //initContext(); - console.info("webgltest into vertexAttribDivisor"); - - const a = gl2.vertexAttribDivisor(0, "2"); - - let errorCode = gl.getError(); - console.info("webgltest vertexAttribDivisor getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0176 - * @tc.name webgl_test_drawArraysInstanced - * @tc.desc Test drawArraysInstanced. - */ - it('webgl_test_drawArraysInstanced', 0, async function(done) { - //initContext(); - console.info("webgltest into drawArraysInstanced"); - - const a = gl2.drawArraysInstanced(gl.POINTS, 0, 8, 4); - - let errorCode = gl.getError(); - console.info("webgltest drawArraysInstanced getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0177 - * @tc.name webgl_test_drawElementsInstanced - * @tc.desc Test drawElementsInstanced. - */ - it('webgl_test_drawElementsInstanced', 0, async function(done) { - //initContext(); - console.info("webgltest into drawElementsInstanced"); - - const a = gl2.drawElementsInstanced(gl.POINTS, 2, gl.UNSIGNED_SHORT, 0, 4); - - let errorCode = gl.getError(); - console.info("webgltest drawElementsInstanced getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_VALUE); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0178 - * @tc.name webgl_test_drawRangeElements - * @tc.desc Test drawRangeElements. - */ - it('webgl_test_drawRangeElements', 0, async function(done) { - //initContext(); - console.info("webgltest into drawRangeElements"); - - const a = gl2.drawRangeElements(gl.POINTS, 0, 7, 8, gl.UNSIGNED_BYTE, 0); - - let errorCode = gl.getError(); - console.info("webgltest drawRangeElements getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_VALUE); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0179 - * @tc.name testFrontFaceFirst - * @tc.desc Test frontFace. - */ - it('testFrontFaceFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL frontFace test start ...' + JSON.stringify(gl)); - gl.enable(gl.CULL_FACE); - gl.cullFace(gl.FRONT_AND_BACK); - gl.frontFace(gl.CW); - const frontFaceParameter = gl.getParameter(gl.CULL_FACE_MODE); - console.info('frontFace -> frontFaceParameter' + frontFaceParameter); - gl.disable(gl.CULL_FACE); - expect(frontFaceParameter).assertEqual(gl.FRONT_AND_BACK); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0180 - * @tc.name testFrontFace_Third - * @tc.desc Test frontFace. - */ - it('testFrontFace_Third', 0, async function(done) { - //initContext(); - console.info('jsWebGL frontFace test start ...' + JSON.stringify(gl)); - gl.enable(gl.CULL_FACE); - gl.cullFace(gl.BACK); - gl.frontFace(gl.CW); - const frontFaceParameter = gl.getParameter(gl.CULL_FACE_MODE); - console.info('frontFace -> frontFaceParameter' + frontFaceParameter); - gl.disable(gl.CULL_FACE); - expect(frontFaceParameter).assertEqual(gl.BACK); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0181 - * @tc.name testFrontFaceError - * @tc.desc Test frontFace. - */ - it('testFrontFaceError', 0, async function(done) { - //initContext(); - console.info('jsWebGL frontFace test start ...' + JSON.stringify(gl)); - gl.cullFace(gl.BACK); - gl.frontFace(gl.CW); - const frontFaceParameter = gl.getParameter(gl.CULL_FACE_MODE); - console.info('frontFace -> frontFaceParameter' + frontFaceParameter); - gl.disable(gl.CULL_FACE); - expect(frontFaceParameter).assertEqual(gl.BACK); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0182 - * @tc.name testGenerateMipmap - * @tc.desc Test generateMipmap. - */ - it('testGenerateMipmap', 0, async function(done) { - //initContext(); - console.info('jsWebGL generateMipmap test start ...' + JSON.stringify(gl)); - gl.generateMipmap(gl2.TEXTURE_2D); - const error = gl.getError(); - console.info('generateMipmap error ' + error); - expect(error).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0183 - * @tc.name testGenerateMipmapError - * @tc.desc Test generateMipmap. - */ - it('testGenerateMipmapError', 0, async function(done) { - //initContext(); - console.info('jsWebGL generateMipmap test start ...' + JSON.stringify(gl)); - gl.generateMipmap(gl.TEXTURE_2D); - const error = gl.getError(); - console.info('generateMipmap error ' + error); - expect(error).assertEqual(1282); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0184 - * @tc.name testGetActiveAttrib - * @tc.desc Test getActiveAttrib. - */ - it('testGetActiveAttrib', 0, async function(done) { - //initContext(); - console.info('jsWebGL getActiveAttrib test start ...' + JSON.stringify(gl)); - const programObj = globalFunction(); - gl.bindAttribLocation(programObj, 0, 'a_Position'); - // const numAttribs = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES); - const info = gl.getActiveAttrib(programObj, 0); - const error = gl.getError(); - expect(error).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0185 - * @tc.name testGetActiveUniform - * @tc.desc Test getActiveUniform. - */ - it('testGetActiveUniform', 0, async function(done) { - //initContext(); - console.info('jsWebGL getActiveUniform test start ...' + JSON.stringify(gl)); - const programObj = globalFunction(); - const info = gl.getActiveUniform(programObj, 0); - const error = gl.getError(); - expect(error).assertEqual(1281); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0186 - * @tc.name testGetAttachedShaders - * @tc.desc Test getAttachedShaders. - */ - it('testGetAttachedShaders', 0, async function(done) { - //initContext(); - console.info('jsWebGL getAttachedShaders test start ...' + JSON.stringify(gl)); - const programObj = globalFunction(); - const shaderArray = gl.getAttachedShaders(programObj); - const type = ((typeof shaderArray) === "object") - console.info('getAttachedShaders shaderArray' + shaderArray); - expect(type).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0187 - * @tc.name testGetAttribLocationError - * @tc.desc Test getAttribLocation. - */ - it('testGetAttribLocationError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getAttribLocation test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - const index = gl.getAttribLocation(program, 'webgl_Color'); - console.info('getAttribLocation index' + index); - expect(index).assertEqual(-1); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0188 - * @tc.name testGetAttribLocationFirst - * @tc.desc Test getAttribLocation. - */ - it('testGetAttribLocationFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL getAttribLocation test start ...' + JSON.stringify(gl)); - 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.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); - - const aVertexPosition = gl.getAttribLocation(programObj, "a_Position"); - expect(aVertexPosition).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0189 - * @tc.name testGetBufferParameterFirst - * @tc.desc Test getBufferParameter. - */ - it('testGetBufferParameterFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL getBufferParameter test start ...' + JSON.stringify(gl)); - const buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - const bufferSize = gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE); - console.info('bufferSize' + bufferSize); - expect(bufferSize).assertEqual(1024); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0190 - * @tc.name testGetBufferParameterSecond - * @tc.desc Test getBufferParameter. - */ - it('testGetBufferParameterSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL getBufferParameter test start ...' + JSON.stringify(gl)); - const buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - const bufferUsage = gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_USAGE); - console.info('bufferUsage' + bufferUsage); - expect(bufferUsage).assertEqual(gl.STATIC_DRAW); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0191 - * @tc.name testGetErrorFirst - * @tc.desc Test getError. - */ - it('testGetErrorFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL getError test start ...' + JSON.stringify(gl)); - // turn on scissor test - gl.enable(gl.SCISSOR_TEST); - // set the scissor rectangle - gl.scissor(0, 0, -200, 200); - // 如果宽度或高度为负值, gl.INVALID_VALUE(DEC:1281)则会引发错误 - const scissorErrorCode = gl.getError(); - console.info("scissorErrorCode: " + scissorErrorCode); - expect(scissorErrorCode).assertEqual(1281); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0192 - * @tc.name testGetErrorSecond - * @tc.desc Test getError. - */ - it('testGetErrorSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL getError test start ...' + JSON.stringify(gl)); - gl.getError(); // 0 (0) - gl.enable(gl.DITHER); - const errorCode = gl.getError(); // gl.INVALID_ENUM; - console.info('getError 2 errorCode' + errorCode); - expect(errorCode).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0193 - * @tc.name testGetFramebufferAttachmentParameter - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .COLOR_ATTACHMENT0, - gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0197 - * @tc.name testGetProgramParameterFourth - * @tc.desc Test getProgramParameter. - */ - it('testGetProgramParameterFourth', 0, async function(done) { - //initContext(); - console.info('jsWebGL getProgramParameter test start ...' + JSON.stringify(gl)); - const program = globalFunction(); - const attachedShaders = gl.getProgramParameter(program, gl.ATTACHED_SHADERS); - console.info('attachedShaders' + attachedShaders); - expect(attachedShaders).assertEqual(2); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0198 - * @tc.name testGetProgramParameterError - * @tc.desc Test getProgramParameter. - */ - it('testGetProgramParameterError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getProgramParameter test start ...' + JSON.stringify(gl)); - const vertexShader = gl.createShader(gl.VERTEX_SHADER); - gl.shaderSource(vertexShader, VSHADER_SOURCE); - gl.compileShader(vertexShader); - - const programObj = gl.createProgram(); - // gl.attachShader(programObj, vertexShader); - const attachedShaders = gl.getProgramParameter(programObj, gl.ATTACHED_SHADERS); - console.info('attachedShaders' + attachedShaders); - const type = (attachedShaders === 1); - expect(type).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0199 - * @tc.name testGetProgramInfoLog - * @tc.desc Test getProgramInfoLog. - */ - it('testGetProgramInfoLog', 0, async function(done) { - //initContext(); - console.info('jsWebGL getProgramInfoLog test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - // Attach pre-existing shaders - gl.attachShader(program, VSHADER_SOURCE); - gl.attachShader(program, FSHADER_SOURCE); - gl.linkProgram(program); - gl.validateProgram(program); - const info = gl.getProgramInfoLog(program); - gl.useProgram(program); - expect(info).assertEqual('The program object is incomplete.'); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0200 - * @tc.name testGetRenderbufferParameterFirst - * @tc.desc Test getRenderbufferParameter. - */ - it('testGetRenderbufferParameterFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); - - const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH); - expect(width).assertEqual(256); - done(); - }); -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test03.js b/graphic/webGL/src/main/js/default/test/WebGL.test03.js deleted file mode 100644 index 152a90172868bf183109bdea03f9b3e8bd8b7045..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test03.js +++ /dev/null @@ -1,2010 +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_webgl3', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_0201 - * @tc.name testGetRenderbufferParameterSecond - * @tc.desc Test getRenderbufferParameter. - */ - it('testGetRenderbufferParameterSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); - - const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT); - expect(width).assertEqual(gl.RGBA4); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0202 - * @tc.name testGetRenderbufferParameterThird - * @tc.desc Test getRenderbufferParameter. - */ - it('testGetRenderbufferParameterThird', 0, async function(done) { - //initContext(); - console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); - const internalFormat = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl - .RENDERBUFFER_INTERNAL_FORMAT); - expect(internalFormat).assertEqual(gl.RGBA4); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0203 - * @tc.name testGetRenderbufferParameterFourth - * @tc.desc Test getRenderbufferParameter. - */ - it('testGetRenderbufferParameterFourth', 0, async function(done) { - //initContext(); - console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); - const greenSize = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_GREEN_SIZE); - expect(greenSize).assertEqual(4); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0204 - * @tc.name testGetRenderbufferParameterError - * @tc.desc Test getRenderbufferParameter. - */ - it('testGetRenderbufferParameterError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - // gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); - const greenSize = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_GREEN_SIZE); - expect(greenSize).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0206 - * @tc.name testGetShaderParameterSecond - * @tc.desc Test getShaderParameter. - */ - it('testGetShaderParameterSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderParameter test start ...' + JSON.stringify(gl)); - const vertexShader = gl.createShader(gl.VERTEX_SHADER); - // const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); - // gl.deleteShader(vertexShader); - const deleteStatus = gl.getShaderParameter(vertexShader, gl.DELETE_STATUS); - console.info('deleteStatus' + deleteStatus); - expect(deleteStatus).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0207 - * @tc.name testGetShaderParameterThird - * @tc.desc Test getShaderParameter. - */ - it('testGetShaderParameterThird', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderParameter test start ...' + JSON.stringify(gl)); - const vertexShader = gl.createShader(gl.VERTEX_SHADER); - gl.shaderSource(vertexShader, VSHADER_SOURCE); - gl.compileShader(vertexShader); - const compileStatus = gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS); - console.info('compileStatus' + compileStatus); - expect(compileStatus).assertEqual(true); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0208 - * @tc.name testGetShaderParameterFourth - * @tc.desc Test getShaderParameter. - */ - it('testGetShaderParameterFourth', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderParameter test start ...' + JSON.stringify(gl)); - var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); - gl.shaderSource(fragmentShader, FSHADER_SOURCE); - gl.compileShader(fragmentShader); - const compileStatus = gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS); - console.info('compileStatus' + compileStatus); - expect(compileStatus).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0209 - * @tc.name testGetShaderParameterError - * @tc.desc Test getShaderParameter. - */ - it('testGetShaderParameterError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderParameter test start ...' + JSON.stringify(gl)); - var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); - // gl.shaderSource(fragmentShader, FSHADER_SOURCE); - // gl.compileShader(fragmentShader); - const compileStatus = gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS); - console.info('compileStatus' + compileStatus); - const type = (compileStatus === true) - expect(type).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0210 - * @tc.name testGetShaderPrecisionFormat - * @tc.desc Test getShaderPrecisionFormat. - */ - it('testGetShaderPrecisionFormat', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); - const shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl - .MEDIUM_FLOAT); - console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); - const type = ((typeof shaderPrecisionFormat) === "object") - expect(type).assertEqual(true); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0211 - * @tc.name testGetTexParameterError - * @tc.desc Test getTexParameter. - */ - it('testGetTexParameterError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER); - console.info('texParameterfValue' + texParameterValue); - const type = (texParameterValue === gl.LINEAR_MIPMAP_NEAREST); - expect(type).assertEqual(false); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0212 - * @tc.name testGetTexParameterFirst - * @tc.desc Test getTexParameter. - */ - it('testGetTexParameterFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(gl.LINEAR_MIPMAP_NEAREST); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0213 - * @tc.name testGetTexParameterSecond - * @tc.desc Test getTexParameter. - */ - it('testGetTexParameterSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); - gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(gl.LINEAR); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0214 - * @tc.name testGetUniform - * @tc.desc Test getUniform. - */ - it('testGetUniform', 0, async function(done) { - //initContext(); - console.info('jsWebGL getUniform test start ...' + JSON.stringify(gl)); - // const programObj = globalFunction(); - // - // const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - // const uniform = gl.getUniform(programObj, uniformLocation); - // console.info('getUniformLocation uniform' + uniform); - // expect(uniform.toString()).assertEqual([0,0,0,0].toString()); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0215 - * @tc.name testGetUniformError - * @tc.desc Test getUniform. - */ - it('testGetUniformError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getUniform test start ...' + JSON.stringify(gl)); - const programObj = gl.createProgram(); - - - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - const uniform = gl.getUniform(programObj, uniformLocation); - console.info('getUniformLocation uniform' + uniform); - expect(uniform).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0216 - * @tc.name testGetUniformLocation - * @tc.desc Test getUniformLocation. - */ - it('testGetUniformLocation', 0, async function(done) { - //initContext(); - console.info('jsWebGL getUniformLocation test start ...' + JSON.stringify(gl)); - // let programObj = globalFunction(); - // const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - // const uniform = gl.getUniform(programObj, uniformLocation); - // console.info('getUniformLocation uniform' + uniform); - // expect(uniform.toString()).assertEqual([0,0,0,0].toString()); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0217 - * @tc.name testGetUniformLocationError - * @tc.desc Test getUniformLocation. - */ - it('testGetUniformLocationError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getUniformLocation test start ...' + JSON.stringify(gl)); - const programObj = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - const uniform = gl.getUniform(programObj, uniformLocation); - console.info('getUniformLocation uniform' + uniform); - expect(uniform).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0218 - * @tc.name testGetParameter1 - * @tc.desc Test getParameter. - */ - it('testGetParameter1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - expect(textureParameter).assertEqual(33984); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0219 - * @tc.name testGetParameter2 - * @tc.desc Test getParameter. - */ - it('testGetParameter2', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - - //设置线宽: - gl.lineWidth(5); - // 获取线宽: - const lineWidthValue = gl.getParameter(gl.LINE_WIDTH); - console.info("lineWidthValue: " + lineWidthValue); - // 获取可用宽度的范围。返回一个Float32Array. - const lineWidthArray = gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE); - console.info("lineWidthArray: " + lineWidthArray); - expect(lineWidthValue).assertEqual(5); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0221 - * @tc.name testGetParameter4 - * @tc.desc Test getParameter. - */ - it('testGetParameter4', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - var framebuffer = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - - const framebufferParameter = gl.getParameter(gl.FRAMEBUFFER_BINDING); - console.info("framebufferParameter: " + framebufferParameter); - const isFramebuffer = gl.isFramebuffer(framebufferParameter); - console.info("isFramebuffer: " + isFramebuffer); - expect(isFramebuffer).assertEqual(true); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0222 - * @tc.name testGetParameter5 - * @tc.desc Test getParameter. - */ - it('testGetParameter5', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - const renderbuffer = gl.getParameter(gl.RENDERBUFFER_BINDING); - console.info("renderbuffer: " + renderbuffer); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer); - const isRenderbuffer = gl.isRenderbuffer(renderbuffer); - console.info("isRenderbuffer: " + isRenderbuffer); - expect(isRenderbuffer).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0223 - * @tc.name testGetParameter6 - * @tc.desc Test getParameter. - */ - it('testGetParameter6', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - const textureParameter = gl.getParameter(gl.TEXTURE_BINDING_2D); - console.info("texture: " + texture); - - const isTexture = gl.isTexture(textureParameter); - console.info("isTexture: " + isTexture); - expect(isTexture).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0224 - * @tc.name testGetParameter7 - * @tc.desc Test getParameter. - */ - it('testGetParameter7', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.blendColor(0, 0.5, 1, 1); - const blendColorValue = gl.getParameter(gl.BLEND_COLOR); - // Float32Array[0, 0.5, 1, 1] - console.info("blendColor --> getParameter: " + blendColorValue); - var blendColorArr = new Float32Array([0, 0.5, 1, 1]); - - const equalsblendColorType = (blendColorValue.constructor === blendColorArr.constructor); - console.info("blendColorequalsType: " + equalsblendColorType); - - const equalsblendColorValue = (blendColorValue.toString() === blendColorArr.toString()); - console.info("equalsblendColorValue: " + equalsblendColorValue); - expect(equalsblendColorType).assertEqual(true); - expect(equalsblendColorValue).assertEqual(true); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0225 - * @tc.name testGetParameter8 - * @tc.desc Test getParameter. - */ - it('testGetParameter8', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.depthMask(false); - // 要获得当前的深度遮罩值,传入 DEPTH_WRITEMASK 常量,返回 Boolean. - const depthMaskValue = gl.getParameter(gl.DEPTH_WRITEMASK); - // false - console.info("depthMaskValue: " + depthMaskValue); - expect(depthMaskValue).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0226 - * @tc.name testGetParameter9 - * @tc.desc Test getParameter. - */ - it('testGetParameter9', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.colorMask(true, true, true, false); - // 要获取当前的颜色掩码,请查询COLOR_WRITEMASK返回Array. - const colorMaskValue = gl.getParameter(gl.COLOR_WRITEMASK); - // [true, true, true, false] - console.info("colorMask --> getParameter: " + colorMaskValue); - expect(colorMaskValue.toString()).assertEqual([true, true, true, false].toString()); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0227 - * @tc.name testGetParameter10 - * @tc.desc Test getParameter. - */ - it('testGetParameter10', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - //用于设置深度缓冲区的深度清除值。 - gl.clearDepth(0.5); - //若要获取当前深度清除值,查询DEPTH_CLEAR_VALUE 常量。 - const clearDepthValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); - // 0.5 - console.info("clearDepth --> getParameter: " + clearDepthValue); - expect(clearDepthValue).assertEqual(0.5); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0228 - * @tc.name testGetParameter11 - * @tc.desc Test getParameter. - */ - it('testGetParameter11', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - const tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.pixelStorei(gl.PACK_ALIGNMENT, 2); - gl.pixelStorei(gl.UNPACK_ALIGNMENT, 8); - //要检查像素数据的打包和解包值,可以使用 查询相同的像素存储参数WebGLRenderingContext.getParameter()。 - const packValue = gl.getParameter(gl.PACK_ALIGNMENT); - const unpackValue = gl.getParameter(gl.UNPACK_ALIGNMENT); - console.info("packValue: " + packValue); - console.info("unpackValue: " + unpackValue); - expect(packValue).assertEqual(2); - expect(unpackValue).assertEqual(8); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0229 - * @tc.name testGetParameter12 - * @tc.desc Test getParameter. - */ - it('testGetParameter12', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - const str = gl.getParameter(gl.SHADING_LANGUAGE_VERSION); - console.info("getParameter str: " + str); - // const strType = ((typeof str) === "object"); - const str1 = str.join(" "); - console.info("strType: " + str1); - expect(str1).assertEqual('OpenGL ES GLSL ES 3.20'); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0230 - * @tc.name testGetParameter13 - * @tc.desc Test getParameter. - */ - it('testGetParameter13', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.enable(gl.SAMPLE_COVERAGE); - gl.sampleCoverage(0.5, false); - // To check the sample coverage values, query the SAMPLE_COVERAGE_VALUE and SAMPLE_COVERAGE_INVERT constants. - const sampleCoverageValue = gl.getParameter(gl.SAMPLE_COVERAGE_VALUE); // 0.5 - const sampleCoverageInvert = gl.getParameter(gl.SAMPLE_COVERAGE_INVERT); // false - console.info("sampleCoverageValue: " + sampleCoverageValue); - console.info("sampleCoverageInvert: " + sampleCoverageInvert); - expect(sampleCoverageValue).assertEqual(0.5); - expect(sampleCoverageInvert).assertEqual(false); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0232 - * @tc.name testGetVertexAttrib - * @tc.desc Test getVertexAttrib. - */ - it('testGetVertexAttrib', 0, async function(done) { - //initContext(); - console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const bufferVertexAttrib = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING); - const isBuffer = gl.isBuffer(bufferVertexAttrib); - console.info("getVertexAttrib: bufferVertexAttrib" + bufferVertexAttrib); - expect(isBuffer).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0234 - * @tc.name testUniform1f - * @tc.desc Test uniform1f. - */ - it('testUniform1f', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform1f test start ...' + JSON.stringify(gl)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl.uniform1f(uniformLocation, 0.8); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(0); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0235 - * @tc.name testUniform1fError - * @tc.desc Test uniform1f. - */ - it('testUniform1fError', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform1f test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - - gl.uniform1f(uniformLocation, 0.8, 0.8); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0236 - * @tc.name testUniform2f - * @tc.desc Test uniform2f. - */ - it('testUniform2f', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform2f test start ...' + JSON.stringify(gl)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl.uniform2f(uniformLocation, 0.8, 0.8); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0237 - * @tc.name testUniform2fError - * @tc.desc Test uniform2f. - */ - it('testUniform2fError', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform2f test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - - gl.uniform2f(uniformLocation, 0.8); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0238 - * @tc.name testUniform3f - * @tc.desc Test uniform3f. - */ - it('testUniform3f', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform3f test start ...' + JSON.stringify(gl)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl.uniform3f(uniformLocation, 0.8, 0.8, 0.8); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(0); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0239 - * @tc.name testUniform3fError - * @tc.desc Test frontFace. - */ - it('testUniform3fError', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform3f test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - - gl.uniform3f(uniformLocation, 0.8, 0.8); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0240 - * @tc.name testUniform4f - * @tc.desc Test uniform4f. - */ - it('testUniform4f', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform4f test start ...' + JSON.stringify(gl)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl.uniform4f(uniformLocation, 0.8, 0.8, 0.8, 0.8); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0241 - * @tc.name testUniform4fError - * @tc.desc Test uniform4f. - */ - it('testUniform4fError', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform4f test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - - gl.uniform4f(uniformLocation, 0.8, 0.8); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0242 - * @tc.name testUniform1i - * @tc.desc Test uniform1i. - */ - it('testUniform1i', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform1i test start ...' + JSON.stringify(gl)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl.uniform1i(uniformLocation, 2); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(0); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0243 - * @tc.name testUniform1iError - * @tc.desc Test uniform1i. - */ - it('testUniform1iError', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform1i test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - - gl.uniform1i(uniformLocation, 0.8, 0.8); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0244 - * @tc.name testUniform2i - * @tc.desc Test uniform2i. - */ - it('testUniform2i', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform2i test start ...' + JSON.stringify(gl)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl.uniform2i(uniformLocation, 2, 2); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0245 - * @tc.name testUniform2iError - * @tc.desc Test uniform2i. - */ - it('testUniform2iError', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform2i test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - - gl.uniform2i(uniformLocation, 0.8, 0.8); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0246 - * @tc.name testUniform3i - * @tc.desc Test uniform3i. - */ - it('testUniform3i', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform3i test start ...' + JSON.stringify(gl)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl.uniform3i(uniformLocation, 2, 2, 2); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0247 - * @tc.name testUniform3iError - * @tc.desc Test uniform3i. - */ - it('testUniform3iError', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform3i test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - - gl.uniform3i(uniformLocation, 0.8, 0.8); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0248 - * @tc.name testUniform4i - * @tc.desc Test uniform4i. - */ - it('testUniform4i', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform4i test start ...' + JSON.stringify(gl)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl.uniform4i(uniformLocation, 2, 2, 2, 2); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0249 - * @tc.name testUniform4iError - * @tc.desc Test uniform4i. - */ - it('testUniform4iError', 0, async function(done) { - //initContext(); - console.info('jsWebGL uniform4i test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - - gl.uniform4i(uniformLocation, 0.8, 0.8); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0250 - * @tc.name testTexParameterf - * @tc.desc Test texParameterf. - */ - it('testTexParameterf', 0, async function(done) { - //initContext(); - console.info('jsWebGL texParameterf test start ...' + JSON.stringify(gl)); - gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(gl.LINEAR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0251 - * @tc.name testTexParameteri - * @tc.desc Test texParameteri. - */ - it('testTexParameteri', 0, async function(done) { - //initContext(); - console.info('jsWebGL texParameteri test start ...' + JSON.stringify(gl)); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(gl.LINEAR_MIPMAP_NEAREST); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0252 - * @tc.name testHint - * @tc.desc Test hint. - */ - it('testHint', 0, async function(done) { - //initContext(); - console.info('jsWebGL hint test start ...' + JSON.stringify(gl)); - gl.hint(gl.GENERATE_MIPMAP_HINT, gl.FASTEST); - gl.generateMipmap(gl2.TEXTURE_2D); - const error = gl.getError(); - console.info('error' + error); - expect(error).assertEqual(0); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0253 - * @tc.name testHintError - * @tc.desc Test hint. - */ - it('testHintError', 0, async function(done) { - //initContext(); - console.info('jsWebGL hint test start ...' + JSON.stringify(gl)); - gl.hint(gl.GENERATE_MIPMAP_HINT, gl.FASTEST); - gl.generateMipmap(gl.TEXTURE_2D); - const error = gl.getError(); - console.info('hintError' + error); - expect(error).assertEqual(1282); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0254 - * @tc.name testIsBuffer - * @tc.desc Test isBuffer. - */ - it('testIsBuffer', 0, async function(done) { - //initContext(); - console.info('jsWebGL isBuffer test start ...' + JSON.stringify(gl)); - const buffer = gl.createBuffer(); - - const isBuffer1 = gl.isBuffer(buffer); - console.info('isBuffer1' + isBuffer1); - expect(isBuffer1).assertEqual(false); - - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - - const isBuffer = gl.isBuffer(buffer); - console.info('isBuffer' + isBuffer); - expect(isBuffer).assertEqual(true); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0255 - * @tc.name testIsEnabled - * @tc.desc Test isEnabled. - */ - it('testIsEnabled', 0, async function(done) { - //initContext(); - console.info('jsWebGL isEnabled test start ...' + JSON.stringify(gl)); - - gl.enable(gl.STENCIL_TEST); - const isEnabledValue1 = gl.isEnabled(gl.STENCIL_TEST); - console.info("isEnabledValue1: " + isEnabledValue1); - expect(isEnabledValue1).assertEqual(true); - - // false - // 启用或说明给定的能力项,使用WebGLRenderingContext.enable()方法和WebGLRenderingContext.disable()方法: - gl.disable(gl.STENCIL_TEST); - const isEnabledValue2 = gl.isEnabled(gl.STENCIL_TEST); - console.info("isEnabledValue2: " + isEnabledValue2); - expect(isEnabledValue2).assertEqual(false); - - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0256 - * @tc.name testSampleCoverageFirst - * @tc.desc Test sampleCoverage. - */ - it('testSampleCoverageFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL sampleCoverage test start ...' + JSON.stringify(gl)); - gl.enable(gl.SAMPLE_COVERAGE); - gl.sampleCoverage(0.5, false); - // To check the sample coverage values, query the SAMPLE_COVERAGE_VALUE and SAMPLE_COVERAGE_INVERT constants. - const sampleCoverageInvert = gl.getParameter(gl.SAMPLE_COVERAGE_INVERT); // false - console.info("sampleCoverageInvert: " + sampleCoverageInvert); - - expect(sampleCoverageInvert).assertEqual(false); - - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0257 - * @tc.name testSampleCoverageSecond - * @tc.desc Test sampleCoverage. - */ - it('testSampleCoverageSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL sampleCoverage test start ...' + JSON.stringify(gl)); - gl.enable(gl.SAMPLE_COVERAGE); - gl.sampleCoverage(0.5, false); - // To check the sample coverage values, query the SAMPLE_COVERAGE_VALUE and SAMPLE_COVERAGE_INVERT constants. - const sampleCoverageValue = gl.getParameter(gl.SAMPLE_COVERAGE_VALUE); // 0.5 - console.info("sampleCoverageValue: " + sampleCoverageValue); - expect(sampleCoverageValue).assertEqual(0.5); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0258 - * @tc.name testScissor - * @tc.desc Test scissor. - */ - it('testScissor', 0, async function(done) { - //initContext(); - console.info('jsWebGL scissor test start ...' + JSON.stringify(gl)); - - // turn on scissor test - gl.enable(gl.SCISSOR_TEST); - // set the scissor rectangle - gl.scissor(0, 0, -200, 200); - // 如果宽度或高度为负值, gl.INVALID_VALUE(DEC:1281)则会引发错误 - const scissorErrorCode = gl.getError(); - console.info("scissorErrorCode: " + scissorErrorCode); - expect(scissorErrorCode).assertEqual(1281); - - gl.scissor(0, 0, 200, 200); - const scissorValue = gl.getParameter(gl.SCISSOR_BOX); - console.info("scissorValue: " + scissorValue); - // Int32Array[0, 0, 200, 200] - var testInt32Array = new Int32Array([0, 0, 200, 200]); - - // 判断数据类型 - const equalsScissorType = (scissorValue.constructor === testInt32Array.constructor); - // 判断数据值 - const equalsScissorValue = (scissorValue.toString() === testInt32Array.toString()); - - expect(equalsScissorType).assertEqual(true); - expect(equalsScissorValue).assertEqual(true); - - // execute drawing commands in the scissor box (e.g. clear) - // turn off scissor test again - gl.disable(gl.SCISSOR_TEST); - - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0259 - * @tc.name testRenderbufferStorage - * @tc.desc Test renderbufferStorage. - */ - it('testRenderbufferStorage', 0, async function(done) { - //initContext(); - console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); - const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH); - console.info("getRenderbufferParameter width: " + width); - expect(width).assertEqual(256); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0260 - * @tc.name testStencilFunc - * @tc.desc Test stencilFunc. - */ - it('testStencilFunc', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilFunc test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - gl.stencilFunc(gl.LESS, 0, 0b1110011); - const stencilFuncParameter = gl.getParameter(gl.STENCIL_FUNC); - console.info("stencilFunc stencilFuncParameter: " + stencilFuncParameter); - expect(stencilFuncParameter).assertEqual(gl.LESS); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0261 - * @tc.name testStencilFuncSeparate - * @tc.desc Test stencilFuncSeparate. - */ - it('testStencilFuncSeparate', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilFuncSeparate test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - gl.stencilFuncSeparate(gl.FRONT, gl.LESS, 0.2, 1110011); - const stencilFuncSeparateParameter = gl.getParameter(gl.STENCIL_FUNC); - console.info("stencilFuncSeparate stencilFuncSeparateParameter: " + - stencilFuncSeparateParameter); - expect(stencilFuncSeparateParameter).assertEqual(gl.LESS); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0262 - * @tc.name testStencilMask - * @tc.desc Test stencilMask. - */ - it('testStencilMask', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilMask test start ...' + JSON.stringify(gl)); - gl.stencilMask(110101); - const stencilMaskParameter = gl.getParameter(gl.STENCIL_WRITEMASK); - console.info("stencilMask stencilMaskParameter: " + stencilMaskParameter); - expect(stencilMaskParameter).assertEqual(110101); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0263 - * @tc.name testStencilMaskSeparate - * @tc.desc Test stencilMaskSeparate. - */ - it('testStencilMaskSeparate', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilMaskSeparate test start ...' + JSON.stringify(gl)); - gl.stencilMaskSeparate(gl.FRONT, 110101); - const stencilMaskSeparateParameter = gl.getParameter(gl.STENCIL_WRITEMASK); - console.info("stencilMaskSeparate stencilMaskSeparateParameter: " + - stencilMaskSeparateParameter); - expect(stencilMaskSeparateParameter).assertEqual(110101); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0264 - * @tc.name testStencilOp - * @tc.desc Test stencilOp. - */ - it('testStencilOp', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilOp test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - gl.stencilOp(gl.INCR, gl.DECR, gl.INVERT); - const stencilOpParameter = gl.getParameter(gl.STENCIL_FAIL); - console.info("stencilOp stencilOpParameter: " + stencilOpParameter); - expect(stencilOpParameter).assertEqual(gl.INCR); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0265 - * @tc.name testStencilOpSeparate - * @tc.desc Test stencilOpSeparate. - */ - it('testStencilOpSeparate', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilOpSeparate test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - gl.stencilOpSeparate(gl.FRONT, gl.INCR, gl.DECR, gl.INVERT); - const stencilOpSeparateParameter = gl.getParameter(gl.STENCIL_FAIL); - console.info("stencilOpSeparate stencilOpSeparateParameter: " + stencilOpSeparateParameter); - expect(stencilOpSeparateParameter).assertEqual(gl.INCR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0266 - * @tc.name testShaderSource - * @tc.desc Test shaderSource. - */ - it('testShaderSource', 0, async function(done) { - //initContext(); - console.info('jsWebGL shaderSource test start ...' + JSON.stringify(gl)); - var shader = gl.createShader(gl.VERTEX_SHADER); - gl.shaderSource(shader, 'originalSource'); - - var source = gl.getShaderSource(shader); - console.info("shaderSource source: " + source); - expect(source).assertEqual('originalSource'); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0267 - * @tc.name testGetShaderSource - * @tc.desc Test getShaderSource. - */ - it('testGetShaderSource', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderSource test start ...' + JSON.stringify(gl)); - var shader = gl.createShader(gl.VERTEX_SHADER); - gl.shaderSource(shader, 'originalSource'); - - var source = gl.getShaderSource(shader); - console.info("getShaderSource source: " + source); - expect(source).assertEqual('originalSource'); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0269 - * @tc.name testGetShaderInfoLog - * @tc.desc Test getShaderInfoLog. - */ - it('testGetShaderInfoLog', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderInfoLog test start ...' + JSON.stringify(gl)); - var shader = gl.createShader(gl.VERTEX_SHADER); - gl.shaderSource(shader, "shaderCode"); - - /* compile shader source code. */ - gl.compileShader(shader); - const message = gl.getShaderInfoLog(shader); - console.info("getShaderInfoLog message: " + message); - expect(message).assertContain("0:1: L0001: Typename expected, found 'shaderCode'"); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0270 - * @tc.name testFrontFaceSecond - * @tc.desc Test frontFace. - */ - it('testFrontFaceSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL frontFace test start ...' + JSON.stringify(gl)); - gl.enable(gl.CULL_FACE); - gl.cullFace(gl.FRONT); - gl.frontFace(gl.CW); - const frontFaceParameter = gl.getParameter(gl.CULL_FACE_MODE); - console.info('frontFace -> frontFaceParameter' + frontFaceParameter); - gl.disable(gl.CULL_FACE); - expect(frontFaceParameter).assertEqual(gl.FRONT); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0271 - * @tc.name testGetUniformBlockIndex - * @tc.desc Test getUniformBlockIndex. - */ - it('testGetUniformBlockIndex', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 getUniformBlockIndex test start ...' + JSON.stringify(gl2)); - const program = gl.createProgram(); - const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); - gl2.uniformBlockBinding(program, blockIndex, 1); - console.info("uniformBlockBinding blockIndex: " + blockIndex); - expect(blockIndex).assertEqual(4294967295); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0272 - * @tc.name testGetActiveUniformBlockParameter - * @tc.desc Test getActiveUniformBlockParameter. - */ - it('testGetActiveUniformBlockParameter', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( - gl2)); - const program = globalFunction(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - const int32Array = new Int32Array([1, 2]); - gl2.uniform1iv(uniformLocation, int32Array); - const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); - gl2.uniformBlockBinding(program, blockIndex, 1); - const blockSize = gl2.getActiveUniformBlockParameter(program, blockIndex, gl - .UNIFORM_BLOCK_DATA_SIZE); - console.info("getActiveUniformBlockParameter blockSize" + blockSize); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_VALUE); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0275 - * @tc.name testCreateVertexArray - * @tc.desc Test createVertexArray. - */ - it('testCreateVertexArray', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 createVertexArray test start ...' + JSON.stringify(gl2)); - const vao = gl2.createVertexArray(); - const isVertexArray1 = gl2.isVertexArray(vao); - console.info("isVertexArray1" + isVertexArray1); - gl2.bindVertexArray(vao); - const isVertexArray = gl2.isVertexArray(vao); - console.info("isVertexArray" + isVertexArray); - expect(isVertexArray).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0276 - * @tc.name testBindVertexArray - * @tc.desc Test bindVertexArray. - */ - it('testBindVertexArray', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bindVertexArray test start ...' + JSON.stringify(gl2)); - const vao = gl2.createVertexArray(); - const isVertexArray1 = gl2.isVertexArray(vao); - console.info("isVertexArray1" + isVertexArray1); - gl2.bindVertexArray(vao); - const isVertexArray = gl2.isVertexArray(vao); - console.info("isVertexArray" + isVertexArray); - expect(isVertexArray).assertEqual(true); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0277 - * @tc.name testDeleteVertexArray - * @tc.desc Test deleteVertexArray. - */ - it('testDeleteVertexArray', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 deleteVertexArray test start ...' + JSON.stringify(gl2)); - const vao = gl2.createVertexArray(); - gl2.bindVertexArray(vao); - const isVertexArray1 = gl2.isVertexArray(vao); - console.info("isVertexArray1" + isVertexArray1); - gl2.deleteVertexArray(vao); - const isVertexArray = gl2.isVertexArray(vao); - console.info("isVertexArray" + isVertexArray); - expect(isVertexArray).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0278 - * @tc.name testUniform1fvFirst - * @tc.desc Test uniform1fv. - */ - it('testUniform1fvFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform1fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const flaot32list = new Float32Array([1.2, 2.2]); - gl2.uniform1fv(uniformLocation, flaot32list); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0279 - * @tc.name testUniform1fvSecond - * @tc.desc Test uniform1fv. - */ - it('testUniform1fvSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform1fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const flaot32list = new Float32Array([1.2, 2.2]); - gl2.uniform1fv(uniformLocation, flaot32list, 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0280 - * @tc.name testUniform1fvError - * @tc.desc Test uniform1fv. - */ - it('testUniform1fvError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform1fv test start ...' + JSON.stringify(gl2)); - const programObj = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const flaot32list = new Float32Array([1.2, 2.2]); - gl2.uniform1fv(uniformLocation, flaot32list); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0281 - * @tc.name testUniform1fvThird - * @tc.desc Test uniform1fv. - */ - it('testUniform1fvThird', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform1fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform1fv(uniformLocation, [1.2, 2.2]); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0282 - * @tc.name testUniform1fv4 - * @tc.desc Test uniform1fv. - */ - it('testUniform1fv4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform1fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform1fv(uniformLocation, [1.2, 2.2], 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0283 - * @tc.name testUniform2fvFirst - * @tc.desc Test uniform2fv. - */ - it('testUniform2fvFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform2fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const flaot32list = new Float32Array([1.2, 2.2]); - gl2.uniform2fv(uniformLocation, flaot32list); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0284 - * @tc.name testUniform2fvSecond - * @tc.desc Test uniform2fv. - */ - it('testUniform2fvSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform2fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const flaot32list = new Float32Array([1.2, 2.2], 0, 0); - gl2.uniform2fv(uniformLocation, flaot32list); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0285 - * @tc.name testUniform2fvError - * @tc.desc Test uniform2fv. - */ - it('testUniform2fvError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform2fv test start ...' + JSON.stringify(gl2)); - const programObj = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const flaot32list = new Float32Array([1.2, 2.2]); - gl2.uniform2fv(uniformLocation, flaot32list); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0286 - * @tc.name testUniform2fv3 - * @tc.desc Test uniform2fv. - */ - it('testUniform2fv3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform2fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform2fv(uniformLocation, [1.2, 2.2]); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0287 - * @tc.name testUniform2fv4 - * @tc.desc Test uniform2fv. - */ - it('testUniform2fv4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform2fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform2fv(uniformLocation, [1.2, 2.2], 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0288 - * @tc.name testUniform3fvFirst - * @tc.desc Test frontFace. - */ - it('testUniform3fvFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform3fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const flaot32list = new Float32Array([1.2, 2.2]); - gl2.uniform3fv(uniformLocation, flaot32list); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0289 - * @tc.name testUniform3fvSecond - * @tc.desc Test uniform3fv. - */ - it('testUniform3fvSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform3fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const flaot32list = new Float32Array([1.2, 2.2]); - gl2.uniform3fv(uniformLocation, flaot32list, 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0290 - * @tc.name testUniform3fvError - * @tc.desc Test uniform3fv. - */ - it('testUniform3fvError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform3fv test start ...' + JSON.stringify(gl2)); - const programObj = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const flaot32list = new Float32Array([1.2, 2.2]); - gl2.uniform3fv(uniformLocation, flaot32list); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0291 - * @tc.name testUniform3fv3 - * @tc.desc Test uniform3fv. - */ - it('testUniform3fv3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform3fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform3fv(uniformLocation, [1.2, 2.2]); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0292 - * @tc.name testUniform3fv4 - * @tc.desc Test uniform3fv. - */ - it('testUniform3fv4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform3fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform3fv(uniformLocation, [1.2, 2.2], 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0293 - * @tc.name testUniform4fvFirst - * @tc.desc Test uniform4fv. - */ - it('testUniform4fvFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform4fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const flaot32list = new Float32Array([1.2, 2.2]); - gl2.uniform4fv(uniformLocation, flaot32list); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0294 - * @tc.name testUniform4fvSecond - * @tc.desc Test uniform4fv. - */ - it('testUniform4fvSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform4fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const flaot32list = new Float32Array([1.2, 2.2]); - gl2.uniform4fv(uniformLocation, flaot32list, 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0295 - * @tc.name testUniform4fvError - * @tc.desc Test uniform4fv. - */ - it('testUniform4fvError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform4fv test start ...' + JSON.stringify(gl2)); - const programObj = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const flaot32list = new Float32Array([1.2, 2.2]); - gl2.uniform4fv(uniformLocation, flaot32list); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0296 - * @tc.name testUniform4fv3 - * @tc.desc Test uniform4fv. - */ - it('testUniform4fv3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform4fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform4fv(uniformLocation, [1.2, 2.2]); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0297 - * @tc.name testUniform4fvThird - * @tc.desc Test uniform4fv. - */ - it('testUniform4fvThird', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform4fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform4fv(uniformLocation, [1.2, 2.2], 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0298 - * @tc.name testUniform1ivFirst - * @tc.desc Test uniform1iv. - */ - it('testUniform1ivFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform1iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const int32Array = new Int32Array([1, 2]); - gl2.uniform1iv(uniformLocation, int32Array); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0299 - * @tc.name testUniform1ivSecond - * @tc.desc Test uniform1iv. - */ - it('testUniform1ivSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform1iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const int32Array = new Int32Array([1, 2]); - gl2.uniform1iv(uniformLocation, int32Array, 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0300 - * @tc.name testUniform1ivError - * @tc.desc Test uniform1iv. - */ - it('testUniform1ivError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform1iv test start ...' + JSON.stringify(gl2)); - const programObj = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const int32Array = new Int32Array([1, 2]); - gl2.uniform1iv(uniformLocation, int32Array); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test04.js b/graphic/webGL/src/main/js/default/test/WebGL.test04.js deleted file mode 100644 index 4759c7554b31603ccf9248bb12621ecb964feeb6..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test04.js +++ /dev/null @@ -1,1929 +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_webgl4', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_0301 - * @tc.name testUniform1iv3 - * @tc.desc Test uniform1iv. - */ - it('testUniform1iv3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform1iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform1iv(uniformLocation, [1, 2]); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0302 - * @tc.name testUniform1iv4 - * @tc.desc Test uniform1iv. - */ - it('testUniform1iv4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform1iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform1iv(uniformLocation, [1, 2], 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0303 - * @tc.name testUniform2ivFirst - * @tc.desc Test uniform2iv. - */ - it('testUniform2ivFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform2iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const int32Array = new Int32Array([1, 2]); - gl2.uniform2iv(uniformLocation, int32Array); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0304 - * @tc.name testUniform2ivSecond - * @tc.desc Test uniform2iv. - */ - it('testUniform2ivSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform2iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const int32Array = new Int32Array([1, 2]); - gl2.uniform2iv(uniformLocation, int32Array, 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0305 - * @tc.name testUniform2ivError - * @tc.desc Test uniform2iv. - */ - it('testUniform2ivError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform2iv test start ...' + JSON.stringify(gl2)); - const programObj = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const int32Array = new Int32Array([1, 2]); - gl2.uniform2iv(uniformLocation, int32Array); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0306 - * @tc.name testUniform2iv3 - * @tc.desc Test uniform2iv. - */ - it('testUniform2iv3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform2iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform2iv(uniformLocation, [1, 2]); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0307 - * @tc.name testUniform2iv4 - * @tc.desc Test uniform2iv. - */ - it('testUniform2iv4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform2iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform2iv(uniformLocation, [1, 2], 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0308 - * @tc.name testUniform3ivFirst - * @tc.desc Test uniform3iv. - */ - it('testUniform3ivFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform3iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const int32Array = new Int32Array([1, 2]); - gl2.uniform3iv(uniformLocation, int32Array); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0309 - * @tc.name testUniform3ivSecond - * @tc.desc Test uniform3iv. - */ - it('testUniform3ivSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform3iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const int32Array = new Int32Array([1, 2]); - gl2.uniform3iv(uniformLocation, int32Array, 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0310 - * @tc.name testUniform3ivError - * @tc.desc Test uniform3iv. - */ - it('testUniform3ivError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform3iv test start ...' + JSON.stringify(gl2)); - const programObj = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const int32Array = new Int32Array([1, 2]); - gl2.uniform3iv(uniformLocation, int32Array); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0311 - * @tc.name testUniform3iv3 - * @tc.desc Test uniform3iv. - */ - it('testUniform3iv3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform3iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform3iv(uniformLocation, [1, 2]); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0312 - * @tc.name testUniform3iv4 - * @tc.desc Test uniform3iv. - */ - it('testUniform3iv4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform3iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform3iv(uniformLocation, [1, 2], 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0313 - * @tc.name testUniform4ivFirst - * @tc.desc Test uniform4iv. - */ - it('testUniform4ivFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform4iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const int32Array = new Int32Array([1, 2]); - gl2.uniform4iv(uniformLocation, int32Array); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0314 - * @tc.name testUniform4ivSecond - * @tc.desc Test uniform4iv. - */ - it('testUniform4ivSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform4iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const int32Array = new Int32Array([1, 2]); - gl2.uniform4iv(uniformLocation, int32Array, 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0315 - * @tc.name testUniform4ivError - * @tc.desc Test uniform4iv. - */ - it('testUniform4ivError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform4iv test start ...' + JSON.stringify(gl2)); - const programObj = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - const int32Array = new Int32Array([1, 2]); - gl2.uniform4iv(uniformLocation, int32Array); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0316 - * @tc.name testUniform4iv3 - * @tc.desc Test uniform4iv. - */ - it('testUniform4iv3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform4iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform4iv(uniformLocation, [1, 2]); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0317 - * @tc.name testUniform4iv4 - * @tc.desc Test uniform4iv. - */ - it('testUniform4iv4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniform4iv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniform4iv(uniformLocation, [1, 2], 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0318 - * @tc.name testUniformMatrix4fvFirst - * @tc.desc Test uniformMatrix4fv. - */ - it('testUniformMatrix4fvFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix4fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - var flaot32list = new Float32Array([1, 2]); - gl2.uniformMatrix4fv(uniformLocation, true, flaot32list); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0319 - * @tc.name testUniformMatrix4fv2 - * @tc.desc Test uniformMatrix4fv. - */ - it('testUniformMatrix4fv2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix4fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - var flaot32list = new Float32Array([1, 2]); - gl2.uniformMatrix4fv(uniformLocation, true, flaot32list, 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0320 - * @tc.name testUniformMatrix4fvError - * @tc.desc Test uniformMatrix4fv. - */ - it('testUniformMatrix4fvError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix4fv test start ...' + JSON.stringify(gl2)); - const programObj = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - var flaot32list = new Float32Array([1, 2]); - gl2.uniformMatrix4fv(uniformLocation, true, flaot32list); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0321 - * @tc.name testUniformMatrix4fv3 - * @tc.desc Test uniformMatrix4fv. - */ - it('testUniformMatrix4fv3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix4fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniformMatrix4fv(uniformLocation, true, [1, 2]); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0322 - * @tc.name testUniformMatrix4fv4 - * @tc.desc Test uniformMatrix4fv. - */ - it('testUniformMatrix4fv4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix4fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniformMatrix4fv(uniformLocation, true, [1, 2], 0, 0); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0323 - * @tc.name testUniformMatrix3fvFirst - * @tc.desc Test uniformMatrix3fv. - */ - it('testUniformMatrix3fvFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix3fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - var flaot32list = new Float32Array([1, 2]); - gl2.uniformMatrix3fv(uniformLocation, true, flaot32list); - - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0324 - * @tc.name testUniformMatrix3fv2 - * @tc.desc Test uniformMatrix3fv. - */ - it('testUniformMatrix3fv2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix3fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - var flaot32list = new Float32Array([1, 2]); - gl2.uniformMatrix3fv(uniformLocation, true, flaot32list, 0, 0); - - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0325 - * @tc.name testUniformMatrix3fvError - * @tc.desc Test uniformMatrix3fv. - */ - it('testUniformMatrix3fvError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix3fv test start ...' + JSON.stringify(gl2)); - const programObj = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - var flaot32list = new Float32Array([1, 2]); - gl2.uniformMatrix3fv(uniformLocation, true, flaot32list); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0326 - * @tc.name testUniformMatrix3fv3 - * @tc.desc Test uniformMatrix3fv. - */ - it('testUniformMatrix3fv3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix3fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniformMatrix3fv(uniformLocation, true, [1, 2]); - - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0327 - * @tc.name testUniformMatrix3fv4 - * @tc.desc Test uniformMatrix3fv. - */ - it('testUniformMatrix3fv4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix3fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniformMatrix3fv(uniformLocation, true, [1, 2], 0, 0); - - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0328 - * @tc.name testUniformMatrix2fv1 - * @tc.desc Test uniformMatrix2fv. - */ - it('testUniformMatrix2fv1', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix2fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - var flaot32list = new Float32Array([1, 2]); - gl2.uniformMatrix2fv(uniformLocation, true, flaot32list); - - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0329 - * @tc.name testUniformMatrix2fv2 - * @tc.desc Test uniformMatrix2fv. - */ - it('testUniformMatrix2fv2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix2fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - var flaot32list = new Float32Array([1, 2]); - gl2.uniformMatrix2fv(uniformLocation, true, flaot32list, 0, 0); - - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0330 - * @tc.name testUniformMatrix2fvError - * @tc.desc Test uniformMatrix2fv. - */ - it('testUniformMatrix2fvError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix2fv test start ...' + JSON.stringify(gl2)); - const programObj = gl.createProgram(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - var flaot32list = new Float32Array([1, 2]); - gl2.uniformMatrix2fv(uniformLocation, true, flaot32list); - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(1282); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0331 - * @tc.name testUniformMatrix2fv3 - * @tc.desc Test uniformMatrix2fv. - */ - it('testUniformMatrix2fv3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix2fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniformMatrix2fv(uniformLocation, true, [1, 2]); - - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0332 - * @tc.name testUniformMatrix2fv4 - * @tc.desc Test uniformMatrix2fv. - */ - it('testUniformMatrix2fv4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformMatrix2fv test start ...' + JSON.stringify(gl2)); - const programObj = globalFunction(); - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - - gl2.uniformMatrix2fv(uniformLocation, true, [1, 2], 0, 0); - - const error = gl.getError(); - console.info("error: " + error); - expect(error).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0333 - * @tc.name testBufferData1 - * @tc.desc Test bufferData. - */ - it('testBufferData1', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - const buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl2.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - const bufferSize = gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE); - console.info('bufferSize' + bufferSize); - expect(bufferSize).assertEqual(1024); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0334 - * @tc.name testBufferData2 - * @tc.desc Test bufferData. - */ - it('testBufferData2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - const buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl2.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - const bufferUsage = gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_USAGE); - console.info('bufferUsage' + bufferUsage); - expect(bufferUsage).assertEqual(gl.STATIC_DRAW); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0335 - * @tc.name testBufferData3 - * @tc.desc Test bufferData. - */ - it('testBufferData3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - gl2.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.DYNAMIC_READ); - const errorCode = gl.getError(); - console.info("webgltest bufferData getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0336 - * @tc.name testBufferData4 - * @tc.desc Test bufferData. - */ - it('testBufferData4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - gl2.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.DYNAMIC_READ, 0, 0); - const errorCode = gl.getError(); - console.info("webgl2test bufferData getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0337 - * @tc.name testBufferDataError - * @tc.desc Test bufferData. - */ - it('testBufferDataError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - gl2.bufferData(1024, gl.STATIC_DRAW); - const bufferSize = gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE); - console.info('bufferSize' + bufferSize); - const type = (bufferSize === 1024) - expect(type).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0338 - * @tc.name testBufferSubData - * @tc.desc Test bufferData. - */ - it('testBufferSubData', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - gl2.bufferSubData(gl.COPY_READ_BUFFER, 512, new ArrayBuffer(8)); - const errorCode = gl.getError(); - console.info("webgl2test bufferSubData getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0339 - * @tc.name testBufferSubData2 - * @tc.desc Test bufferData. - */ - it('testBufferSubData2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - gl2.bufferSubData(gl.COPY_READ_BUFFER, 512, new ArrayBuffer(8), 0, 0); - const errorCode = gl.getError(); - console.info("webgl2test bufferSubData getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0340 - * @tc.name testTexImage2D - * @tc.desc Test texImage2D. - */ - it('testTexImage2D', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texImage2D(gl2.TEXTURE_2D, 0, 32, 512, 512, 0, 32, 32, view); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0341 - * @tc.name testTexImage2D2 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - gl2.texImage2D(gl2.TEXTURE_2D, 0, gl.RGB8, 512, 512, 0, gl.RGB, gl.UNSIGNED_BYTE, 0); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0342 - * @tc.name testTexImage2D3 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texImage2D(gl2.TEXTURE_2D, 0, gl.R16F, 512, 512, 0, gl.RED, gl.FLOAT, view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0343 - * @tc.name testTexImage2D4 - * @tc.desc Test frontFace. - */ - it('testTexImage2D4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texImage2D(gl2.TEXTURE_2D, 0, gl.R16F, 512, 512, 0, gl.RED, gl.FLOAT, view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0344 - * @tc.name testTexSubImage2D5 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D5', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl.RED, gl.FLOAT, view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0345 - * @tc.name testTexSubImage2D6 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D6', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); - gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl.RED, gl.FLOAT, 0); - const errorCode = gl.getError(); - console.info("webgl2test texSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0346 - * @tc.name testTexSubImage2D7 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D7', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl.RGBA, gl.UNSIGNED_BYTE, view); - const errorCode = gl.getError(); - console.info("webgl2test texSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0347 - * @tc.name testTexSubImage2D8 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D8', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl.RGBA, gl.UNSIGNED_BYTE, view); - const errorCode = gl.getError(); - console.info("webgl2test texSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0348 - * @tc.name testCompressedTexImage2D9 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D9', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 compressedTexImage2D test start ...' + JSON.stringify(gl2)); - gl2.compressedTexImage2D(gl2.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, gl.PIXEL_UNPACK_BUFFER, 0); - const errorCode = gl.getError(); - console.info("webgl2test compressedTexImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0349 - * @tc.name testCompressedTexImage2D11 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D11', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 compressedTexImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.compressedTexImage2D(gl2.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, view, 0, 0); - const errorCode = gl.getError(); - console.info("webgl2test compressedTexImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0350 - * @tc.name testCompressedTexSubImage2D12 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D12', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 compressedTexSubImage2D test start ...' + JSON.stringify(gl2)); - gl2.compressedTexSubImage2D(gl2.TEXTURE_2D, 0, 256, 256, 512, 512, 0x83F3, gl - .PIXEL_UNPACK_BUFFER, 0); - const errorCode = gl.getError(); - console.info("webgl2test compressedTexSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0351 - * @tc.name testCompressedTexSubImage2D13 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D13', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 compressedTexSubImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.compressedTexSubImage2D(gl2.TEXTURE_2D, 0, 256, 256, 512, 512, 0x83F3, view, 0, 0); - const errorCode = gl.getError(); - console.info("webgl2test compressedTexSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0352 - * @tc.name testReadPixelsFirst - * @tc.desc Test readPixels. - */ - it('testReadPixelsFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_BYTE, view); - const errorCode = gl.getError(); - console.info("webgl2test readPixels getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0353 - * @tc.name testReadPixelsSecond - * @tc.desc Test readPixels. - */ - it('testReadPixelsSecond', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); - gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_BYTE, 0); - const errorCode = gl.getError(); - console.info("webgl2test readPixels getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0354 - * @tc.name testReadPixelsThird - * @tc.desc Test readPixels. - */ - it('testReadPixelsThird', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_BYTE, view, 0); - const errorCode = gl.getError(); - console.info("webgl2test readPixels getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0355 - * @tc.name testReadPixelsError - * @tc.desc Test readPixels. - */ - it('testReadPixelsError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - const returnVale = gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_BYTE, view, 0); - const errorCode = gl.getError(); - console.info("webgl2test readPixels getError: " + errorCode); - const type = - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - -/* - * ***************************************** GT ************************************************ - */ - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0356 - * @tc.name testIsFramebuffer - * @tc.desc Test isFramebuffer. - */ - it('testIsFramebuffer', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testIsFramebuffer test start ...66'); - var framebuffer = gl.createFramebuffer(); - const isFramebuffer = gl.isFramebuffer(framebuffer); - console.info("createFramebuffer --> isFramebuffer: " + isFramebuffer); - expect(isFramebuffer).assertEqual(false); - //deleteContext(); - done(); - } catch (e) { - console.log("testIsFramebuffer has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0357 - * @tc.name testIsFramebuffer_01 - * @tc.desc Test isFramebuffer. - */ - it('testIsFramebuffer_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testIsFramebuffer_01 test start ...66'); - var framebuffer = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - const isFramebuffer = gl.isFramebuffer(framebuffer); - console.info("createFramebuffer --> bindFramebuffer --> isFramebuffer: " + - isFramebuffer); - expect(isFramebuffer).assertEqual(true); - //deleteContext(); - done(); - } catch (e) { - console.log("testIsFramebuffer_01 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0358 - * @tc.name testIsFramebuffer_02 - * @tc.desc Test isFramebuffer. - */ - it('testIsFramebuffer_02', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testIsFramebuffer_02 test start ...66'); - var programobject = gl.createProgram(); - const isFramebuffer = gl.isFramebuffer(programobject); - console.info("createFramebuffer --> isFramebuffer: " + isFramebuffer); - expect(isFramebuffer).assertEqual(false); - //deleteContext(); - done(); - } catch (e) { - console.log("testIsFramebuffer_02 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0359 - * @tc.name testIsFramebuffer_03 - * @tc.desc Test isFramebuffer. - */ - it('testIsFramebuffer_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsFramebuffer_03 test start ...66'); - var shader = gl.createShader(gl.VERTEX_SHADER) - const isFramebuffer = gl.isFramebuffer(shader); - console.info("createFramebuffer --> isFramebuffer: " + isFramebuffer); - expect(isFramebuffer).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0360 - * @tc.name testIsFramebuffer_04 - * @tc.desc Test isFramebuffer. - */ - it('testIsFramebuffer_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsFramebuffer_04 test start ...66'); - var renderbufferObject = gl.createRenderbuffer(); - const isFramebuffer = gl.isFramebuffer(renderbufferObject); - console.info("createFramebuffer --> isFramebuffer: " + isFramebuffer); - expect(isFramebuffer).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0361 - * @tc.name testIsProgram - * @tc.desc Test isProgram. - */ - it('testIsProgram', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsProgram test start ...66'); - var program = gl.createProgram(); - const isProgram = gl.isProgram(program); - console.info("createProgram --> isProgram: " + isProgram); - expect(isProgram).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0362 - * @tc.name testIsProgram_01 - * @tc.desc Test isProgram. - */ - it('testIsProgram_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsProgram_01 test start ...66'); - var framebuffer = gl.createFramebuffer(); - const programError = gl.getError(); - console.info("createProgram --> programError: " + programError); - const isProgram = gl.isProgram(framebuffer); - console.info("createProgram --> isProgram: " + isProgram); - expect(isProgram).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0363 - * @tc.name testIsProgram_02 - * @tc.desc Test isProgram. - */ - it('testIsProgram_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsProgram_02 test start ...66'); - var renderbuffer = gl.createRenderbuffer(); - const programError = gl.getError(); - console.info("createProgram --> programError: " + programError); - const isProgram = gl.isProgram(renderbuffer); - console.info("createProgram --> isProgram: " + isProgram); - expect(isProgram).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0364 - * @tc.name testIsProgram_03 - * @tc.desc Test isProgram. - */ - it('testIsProgram_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsProgram_03 test start ...66'); - var shader = gl.createShader(gl.VERTEX_SHADER); - const programError = gl.getError(); - console.info("createProgram --> programError: " + programError); - const isProgram = gl.isProgram(shader); - console.info("createProgram --> isProgram: " + isProgram); - expect(isProgram).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0366 - * @tc.name testIsRenderbuffer - * @tc.desc Test isRenderbuffer. - */ - it('testIsRenderbuffer', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsRenderbuffer test start ...66'); - var renderbuffer = gl.createRenderbuffer(); - const isrenderbuffer = gl.isRenderbuffer(renderbuffer); - console.info("createRenderbuffer --> isRenderbuffer: " + isrenderbuffer); - expect(isrenderbuffer).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0367 - * @tc.name testIsRenderbuffer_01 - * @tc.desc Test isRenderbuffer. - */ - it('testIsRenderbuffer_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsRenderbuffer_01 test start ...66'); - var renderbuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer); - const isrenderbuffer = gl.isRenderbuffer(renderbuffer); - console.info("createRenderbuffer --> isRenderbuffer: " + isrenderbuffer); - expect(isrenderbuffer).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0368 - * @tc.name testIsRenderbuffer_02 - * @tc.desc Test isRenderbuffer. - */ - it('testIsRenderbuffer_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsRenderbuffer_02 test start ...66'); - var framebuffer = gl.createFramebuffer(); - const isrenderbuffer = gl.isRenderbuffer(framebuffer); - console.info("createRenderbuffer --> isRenderbuffer: " + isrenderbuffer); - expect(isrenderbuffer).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0369 - * @tc.name testIsRenderbuffer_03 - * @tc.desc Test isRenderbuffer. - */ - it('testIsRenderbuffer_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsRenderbuffer_03 test start ...66'); - var programobject = gl.createProgram(); - const isrenderbuffer = gl.isRenderbuffer(programobject); - console.info("createRenderbuffer --> isRenderbuffer: " + isrenderbuffer); - expect(isrenderbuffer).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0371 - * @tc.name testIsShader - * @tc.desc Test isShader. - */ - it('testIsShader', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsShader test start ...66'); - var shader = gl.createShader(gl.VERTEX_SHADER) - const isShader = gl.isShader(shader); - console.info("createShader --> isShader: " + isShader); - expect(isShader).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0372 - * @tc.name testIsShader_01 - * @tc.desc Test isShader. - */ - it('testIsShader_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsShader_01 test start ...66'); - var shader = gl.createShader(gl.FRAGMENT_SHADER) - const isShader = gl.isShader(shader); - console.info("createShader --> isShader: " + isShader); - expect(isShader).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0373 - * @tc.name testIsShader_02 - * @tc.desc Test isShader. - */ - it('testIsShader_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsShader_02 test start ...66'); - var renderbuffer = gl.createRenderbuffer(); - const isShader = gl.isShader(renderbuffer); - console.info("createShader --> isShader: " + isShader); - expect(isShader).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0374 - * @tc.name testIsShader_03 - * @tc.desc Test isShader. - */ - it('testIsShader_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsShader_03 test start ...66'); - var framebuffer = gl.createFramebuffer(); - const isShader = gl.isShader(framebuffer); - console.info("createShader --> isShader: " + isShader); - expect(isShader).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0375 - * @tc.name testIsShader_04 - * @tc.desc Test isShader. - */ - it('testIsShader_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsShader_04 test start ...66'); - var programobject = gl.createProgram(); - const isShader = gl.isShader(programobject); - console.info("createShader --> isShader: " + isShader); - expect(isShader).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0376 - * @tc.name testIsTexture - * @tc.desc Test isTexture. - */ - it('testIsTexture', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsTexture test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - const isTexture = gl.isTexture(texture); - console.info("createShader --> isTexture: " + isTexture); - expect(isTexture).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0377 - * @tc.name testIsTexture_01 - * @tc.desc Test isTexture. - */ - it('testIsTexture_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsTexture_01 test start ...66'); - var texture = gl.createTexture(); - const isTexture = gl.isTexture(texture); - console.info("createShader --> isTexture: " + isTexture); - expect(isTexture).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0378 - * @tc.name testIsTexture_02 - * @tc.desc Test isTexture. - */ - it('testIsTexture_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsTexture_02 test start ...66'); - var programobject = gl.createProgram(); - const isTexture = gl.isTexture(programobject); - console.info("createShader --> isTexture: " + isTexture); - expect(isTexture).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0379 - * @tc.name testIsTexture_03 - * @tc.desc Test isTexture. - */ - it('testIsTexture_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsTexture_03 test start ...66'); - var renderbuffer = gl.createRenderbuffer(); - const isTexture = gl.isTexture(renderbuffer); - console.info("createShader --> isTexture: " + isTexture); - expect(isTexture).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0380 - * @tc.name testIsTexture_04 - * @tc.desc Test isTexture. - */ - it('testIsTexture_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsTexture_04 test start ...66'); - var framebuffer = gl.createFramebuffer(); - const isTexture = gl.isTexture(framebuffer); - console.info("createShader --> isTexture: " + isTexture); - expect(isTexture).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0383 - * @tc.name testLineWidth_01 - * @tc.desc Test lineWidth. - */ - it('testLineWidth_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testLineWidth_01 test start ...66'); - gl.lineWidth(-1); - const windtherror = gl.getError(); - console.info("windtherror: " + windtherror); - expect(windtherror).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0384 - * @tc.name testLineWidth_02 - * @tc.desc Test lineWidth. - */ - it('testLineWidth_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testLineWidth_02 test start ...66'); - gl.lineWidth(0); - const windtherror = gl.getError(); - console.info("windtherror: " + windtherror); - expect(windtherror).assertEqual(gl.INVALID_VALUE); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0385 - * @tc.name testLinkProgram - * @tc.desc Test linkProgram. - */ - it('testLinkProgram', 0, async function(done) { - //initContext(); - console.info('jsWebGL testLinkProgram test start ...66'); - console.info('jsWebGL testLinkProgram test start ...' + JSON.stringify(gl)); - var shaderProg = gl.createProgram(); - gl.linkProgram(shaderProg); - const linkProgramError = gl.getError(); - console.info("linkProgramError: " + linkProgramError); - expect(linkProgramError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0388 - * @tc.name testLinkProgram_03 - * @tc.desc Test linkProgram. - */ - it('testLinkProgram_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testLinkProgram_03 test start ...66'); - var shader = gl.createShader(gl.VERTEX_SHADER); - gl.linkProgram(shader); - const linkProgramError = gl.getError(); - console.info("linkProgramError: " + linkProgramError); - expect(linkProgramError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0389 - * @tc.name testLinkProgram_04 - * @tc.desc Test linkProgram. - */ - it('testLinkProgram_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testLinkProgram_04 test start ...66'); - gl.linkProgram("-123"); - const linkProgramError = gl.getError(); - console.info("linkProgramError: " + linkProgramError); - expect(linkProgramError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0390 - * @tc.name testPixelStorei - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei test start ...66'); - var tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.pixelStorei(gl.PACK_ALIGNMENT, 4); - gl.pixelStorei(gl.UNPACK_ALIGNMENT, 8); - const packValue = gl.getParameter(gl.PACK_ALIGNMENT); - const unpackValue = gl.getParameter(gl.UNPACK_ALIGNMENT); - console.info("packValue: " + packValue); - console.info("unpackValue: " + unpackValue); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0391 - * @tc.name testPixelStorei_01 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_01 test start ...66'); - var tex = gl.createTexture(); - gl.pixelStorei(gl.UNPACK_ALIGNMENT, 8); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0392 - * @tc.name testPixelStorei_02 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_02 test start ...66'); - var tex = gl.createTexture(); - gl.pixelStorei(gl.LINE_LOOP, 8); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0393 - * @tc.name testPixelStorei_03 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_03 test start ...66'); - var tex = gl.createTexture(); - gl.pixelStorei(gl.ONE_MINUS_SRC_COLOR, 8); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0394 - * @tc.name testPixelStorei_04 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_04 test start ...66'); - var tex = gl.createTexture(); - gl.pixelStorei(gl.ONE_MINUS_SRC_COLOR, -1); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0395 - * @tc.name testPolygonOffset - * @tc.desc Test polygonOffset. - */ - it('testPolygonOffset', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPolygonOffset test start ...66'); - gl.enable(gl.POLYGON_OFFSET_FILL); - gl.polygonOffset(2, 3); - const polygonOffsetError = gl.getError(); - console.info("polygonOffsetError: " + polygonOffsetError); - expect(polygonOffsetError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0396 - * @tc.name testPolygonOffset_01 - * @tc.desc Test polygonOffset. - */ - it('testPolygonOffset_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPolygonOffset_01 test start ...66'); - gl.enable(gl.TRIANGLE_STRIP); - gl.polygonOffset(-2, 3); - const polygonOffsetError = gl.getError(); - console.info("polygonOffsetError: " + polygonOffsetError); - expect(polygonOffsetError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0397 - * @tc.name testPolygonOffset_02 - * @tc.desc Test polygonOffset. - */ - it('testPolygonOffset_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPolygonOffset_02 test start ...66'); - gl.enable(gl.TRIANGLES); - gl.polygonOffset(-2, -3); - const polygonOffsetError = gl.getError(); - console.info("polygonOffsetError: " + polygonOffsetError); - expect(polygonOffsetError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0398 - * @tc.name testPolygonOffset_03 - * @tc.desc Test polygonOffset. - */ - it('testPolygonOffset_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPolygonOffset_03 test start ...66'); - gl.enable(gl.LINES); - gl.polygonOffset(0, 0); - const polygonOffsetError = gl.getError(); - console.info("polygonOffsetError: " + polygonOffsetError); - expect(polygonOffsetError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0399 - * @tc.name testPolygonOffset_04 - * @tc.desc Test polygonOffset. - */ - it('testPolygonOffset_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPolygonOffset_04 test start ...66'); - gl.enable(gl.LINE_STRIP); - gl.polygonOffset(0, 0); - const polygonOffsetError = gl.getError(); - console.info("polygonOffsetError: " + polygonOffsetError); - expect(polygonOffsetError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0400 - * @tc.name testBufferData - * @tc.desc Test bufferData. - */ - it('testBufferData', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData test start ...66'); - console.info('jsWebGL testBufferData test start ...' + JSON.stringify(gl)); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test05.js b/graphic/webGL/src/main/js/default/test/WebGL.test05.js deleted file mode 100644 index 8e533afaeeccd40b5dfadf10f9494441263b5a3c..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test05.js +++ /dev/null @@ -1,1837 +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_webgl5', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_0401 - * @tc.name testBufferData_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.INVALID_ENUM); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0402 - * @tc.name testBufferData_02 - * @tc.desc Test bufferData. - */ - it('testBufferData_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_02 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.SRC_COLOR); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0403 - * @tc.name testBufferData_03 - * @tc.desc Test bufferData. - */ - it('testBufferData_03', 0, async function(done) { - console.info('jsWebGL testBufferData_03 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.SRC_ALPHA); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0404 - * @tc.name testBufferData_04 - * @tc.desc Test bufferData. - */ - it('testBufferData_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_04 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.SRC_ALPHA); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0405 - * @tc.name testBufferData_1 - * @tc.desc Test bufferData. - */ - it('testBufferData_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_1 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0406 - * @tc.name testBufferData_1_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_1_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0407 - * @tc.name testBufferData_1_02 - * @tc.desc Test bufferData. - */ - it('testBufferData_1_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_1_02 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.ONE_MINUS_SRC_ALPHA); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0408 - * @tc.name testBufferData_1_03 - * @tc.desc Test bufferData. - */ - it('testBufferData_1_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_1_03 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.ONE_MINUS_DST_ALPHA); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0409 - * @tc.name testBufferData_1_04 - * @tc.desc Test bufferData. - */ - it('testBufferData_1_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_1_03 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, -1, gl.INVALID_VALUE); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0410 - * @tc.name testBufferSubData - * @tc.desc Test bufferSubData. - */ - it('testBufferSubData', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferSubData test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - gl.bufferSubData(gl.COPY_READ_BUFFER, 512, new ArrayBuffer(8)); - const bufferSubDataError = gl.getError(); - console.info("bufferSubDataError: " + bufferSubDataError); - expect(bufferSubDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0411 - * @tc.name testBufferSubData_1 - * @tc.desc Test bufferData. - */ - it('testBufferSubData_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferSubData_1 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.TRIANGLE_FAN); - gl.bufferSubData(gl.TRIANGLE_FAN, 512, new ArrayBuffer(8)); - const bufferSubDataError = gl.getError(); - console.info("bufferSubDataError: " + bufferSubDataError); - expect(bufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0412 - * @tc.name testBufferSubData_2 - * @tc.desc Test bufferSubData. - */ - it('testBufferSubData_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferSubData_2 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - gl.bufferSubData(gl.COPY_READ_BUFFER, 512, new ArrayBuffer(8)); - const bufferSubDataError = gl.getError(); - console.info("bufferSubDataError: " + bufferSubDataError); - expect(bufferSubDataError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0413 - * @tc.name testBufferSubData_3 - * @tc.desc Test bufferSubData. - */ - it('testBufferSubData_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferSubData_3 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.TRIANGLE_STRIP); - gl.bufferSubData(gl.COPY_READ_BUFFER, 512, new ArrayBuffer(8)); - const bufferSubDataError = gl.getError(); - console.info("bufferSubDataError: " + bufferSubDataError); - expect(bufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0414 - * @tc.name testBufferSubData_4 - * @tc.desc Test bufferSubData. - */ - it('testBufferSubData_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferSubData_4 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.TRIANGLE_STRIP); - gl.bufferSubData(gl.COPY_READ_BUFFER, 512, new ArrayBuffer(8)); - const bufferSubDataError = gl.getError(); - console.info("bufferSubDataError: " + bufferSubDataError); - expect(bufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0415 - * @tc.name testCompressedTexImage2D - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexImage2D test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); - const compressedTexImage2DError = gl.getError(); - console.info("compressedTexImage2DError: " + compressedTexImage2DError); - expect(compressedTexImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0416 - * @tc.name testCompressedTexImage2D_01 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexImage2D_01 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_3D, texture); - gl.compressedTexImage2D(gl.TEXTURE_3D, [0, 0], 0x83F3, 512, 512, -1, 0); - const compressedTexImage2DError = gl.getError(); - console.info("compressedTexImage2DError: " + compressedTexImage2DError); - expect(compressedTexImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0417 - * @tc.name testCompressedTexImage2D_02 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexImage2D_02 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_3D, texture); - gl.compressedTexImage2D(gl.SRC_COLOR, -1, 0x83F3, -1, [-1, -1], 0, 0); - const compressedTexImage2DError = gl.getError(); - console.info("compressedTexImage2DError: " + compressedTexImage2DError); - expect(compressedTexImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0418 - * @tc.name testCompressedTexImage2D_03 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexImage2D_03 test start ...66'); - var program = gl.createProgram(); - gl.bindTexture(gl.TEXTURE_3D, program); - gl.compressedTexImage2D(gl.TEXTURE_3D, 0, [0x83F3, 0x83F3], 512, 512, 0, 0); - const compressedTexImage2DError = gl.getError(); - console.info("compressedTexImage2DError: " + compressedTexImage2DError); - expect(compressedTexImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0419 - * @tc.name testCompressedTexImage2D_04 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexImage2D_04 test start ...66'); - var framebuffer = gl.createFramebuffer(); - gl.bindTexture(gl.TEXTURE_3D, framebuffer); - gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x0307, 512, 512, 0, "abc"); - const compressedTexImage2DError = gl.getError(); - console.info("compressedTexImage2DError: " + compressedTexImage2DError); - expect(compressedTexImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0420 - * @tc.name testCompressedTexSubImage2D_1 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexSubImage2D_1 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); - gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 256, 256, 512, 512, 0x83F3, gl - .PIXEL_UNPACK_BUFFER, 0); - const compressedTexSubImage2DError = gl.getError(); - console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); - expect(compressedTexSubImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0421 - * @tc.name testReadPixels - * @tc.desc Test readPixels. - */ - it('testReadPixels', 0, async function(done) { - //initContext(); - console.info('jsWebGL testReadPixels test start ...66'); - var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); - gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl - .UNSIGNED_BYTE, pixels); - const readPixelsError = gl.getError(); - console.info("readPixelsError: " + readPixelsError); - expect(readPixelsError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0422 - * @tc.name testReadPixels_01 - * @tc.desc Test readPixels. - */ - it('testReadPixels_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testReadPixels_01 test start ...66'); - var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); - gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.DST_COLOR, - pixels); - const readPixelsError = gl.getError(); - console.info("readPixelsError: " + readPixelsError); - expect(readPixelsError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0423 - * @tc.name testReadPixels_02 - * @tc.desc Test readPixels. - */ - it('testReadPixels_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testReadPixels_02 test start ...66'); - var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); - gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.DST_COLOR, - 0); - const readPixelsError = gl.getError(); - console.info("readPixelsError: " + readPixelsError); - expect(readPixelsError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0424 - * @tc.name testReadPixels_03 - * @tc.desc Test readPixels. - */ - it('testReadPixels_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testReadPixels_03 test start ...66'); - var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); - gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, -1, gl.DST_COLOR, -2); - const readPixelsError = gl.getError(); - console.info("readPixelsError: " + readPixelsError); - expect(readPixelsError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0425 - * @tc.name testReadPixels_04 - * @tc.desc Test readPixels. - */ - it('testReadPixels_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testReadPixels_04 test start ...66'); - var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); - gl.readPixels(-1, -1, gl.drawingBufferWidth, gl.drawingBufferHeight, -1, gl.CONSTANT_COLOR, - 0); - const readPixelsError = gl.getError(); - console.info("readPixelsError: " + readPixelsError); - expect(readPixelsError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0426 - * @tc.name testTexImage2D - * @tc.desc Test texImage2D. - */ - it('testTexImage2D', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0427 - * @tc.name testTexImage2D_01 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D_01 test start ...66'); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB8, 512, 512, [0, 0], gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0428 - * @tc.name testTexImage2D_02 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D_02 test start ...66'); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl.CONSTANT_ALPHA, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0429 - * @tc.name testTexImage2D_03 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D_03 test start ...66'); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl.FUNC_SUBTRACT, -1); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0430 - * @tc.name testTexImage2D_04 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D_04 test start ...66'); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.DST_COLOR, 512, 512, 0, gl.RGB8, gl.CONSTANT_ALPHA, -1); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0431 - * @tc.name testTexSubImage2D - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexSubImage2D test start ...66'); - console.info('jsWebGL testTexSubImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(16); - const z = new Float32Array(buffer, 0, 4); - gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 512, 512, gl.RED, gl.FLOAT, z, 0); - const ttexSubImage2DError = gl.getError(); - console.info("ttexSubImage2DError: " + ttexSubImage2DError); - expect(ttexSubImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0432 - * @tc.name testUniform1fv - * @tc.desc Test uniform1fv. - */ - it('testUniform1fv', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform1fv test start ...66'); - const programObj = createProgram(gl); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniform1fv(uniformlocationObj, flaot32list); - const uniform1fvError = gl.getError(); - console.info("uniform1fvError: " + uniform1fvError); - const errorCode = gl.getError(); - expect(uniform1fvError).assertEqual(0); - - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0433 - * @tc.name testUniform1fv_1 - * @tc.desc Test uniform1fv. - */ - it('testUniform1fv_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform1fv_1 test start ...66'); - const shader = gl.createShader(gl.VERTEX_SHADER); - const uniformlocationObj = gl.getUniformLocation(shader, "a_Position1"); - const flaot32list = new Float32Array([1, 2]); - gl.uniform1fv(uniformlocationObj, flaot32list); - const uniform1fvError = gl.getError(); - console.info("uniform1fvError: " + uniform1fvError); - expect(uniform1fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0435 - * @tc.name testUniform1fv_3 - * @tc.desc Test uniform1fv. - */ - it('testUniform1fv_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform1fv_3 test start ...66'); - const programobject = gl.createProgram(); - const uniformlocationObj = gl.getUniformLocation(programobject, "a_Position1"); - const flaot32list = new Float32Array([-1, -2]); - gl.uniform1fv(uniformlocationObj, flaot32list); - const uniform1fvError = gl.getError(); - console.info("uniform1fvError: " + uniform1fvError); - const errorCode = gl.getError(); - expect(uniform1fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0437 - * @tc.name testUniform2fv - * @tc.desc Test uniform2fv. - */ - it('testUniform2fv', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform2fv test start ...66'); - const programObj = createProgram(gl); - const uniformlocationObj = gl.getUniformLocation(programObj, "123"); - const flaot32list = new Float32Array([1, 2]); - gl.uniform2fv(uniformlocationObj, flaot32list); - const uniform2fvError = gl.getError(); - console.info("uniform2fvError: " + uniform2fvError); - expect(uniform2fvError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0439 - * @tc.name testUniform2fv_2 - * @tc.desc Test uniform2fv. - */ - it('testUniform2fv_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform2fv_2 test start ...66'); - const programObj = gl.createProgram(); - const uniformlocationObj = gl.getUniformLocation(programObj, "123"); - const flaot32list = new Float32Array([1, 2]); - gl.uniform2fv(uniformlocationObj, flaot32list); - const uniform2fvError = gl.getError(); - console.info("uniform2fvError: " + uniform2fvError); - expect(uniform2fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0441 - * @tc.name testUniform2fv_4 - * @tc.desc Test uniform2fv. - */ - it('testUniform2fv_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform2fv_4 test start ...66'); - const shader = gl.createShader(gl.VERTEX_SHADER); - const uniformlocationObj = gl.getUniformLocation(shader, "a_Position1"); - const flaot32list = new Float32Array([1, 2]); - gl.uniform2fv(uniformlocationObj, flaot32list); - const uniform2fvError = gl.getError(); - console.info("uniform2fvError1: " + uniform2fvError); - expect(uniform2fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0442 - * @tc.name testUniform3fv - * @tc.desc Test uniform3fv. - */ - it('testUniform3fv', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform3fv test start ...66'); - const programObj = createProgram(gl); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniform3fv(uniformlocationObj, flaot32list); - const uniform3fvError = gl.getError(); - console.info("uniform3fvError: " + uniform3fvError); - expect(uniform3fvError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0443 - * @tc.name testUniform3fv_1 - * @tc.desc Test uniform3fv. - */ - it('testUniform3fv_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform3fv_1 test start ...66'); - const programObj = gl.createProgram(); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniform3fv(uniformlocationObj, flaot32list); - const uniform3fvError = gl.getError(); - console.info("uniform3fvError: " + uniform3fvError); - expect(uniform3fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0446 - * @tc.name testUniform3fv_4 - * @tc.desc Test uniform3fv. - */ - it('testUniform3fv_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform3fv_4 test start ...66'); - const shader = gl.createShader(gl.VERTEX_SHADER); - const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniform3fv(uniformlocationObj, flaot32list); - const uniform3fvError = gl.getError(); - console.info("uniform3fvError: " + uniform3fvError); - expect(uniform3fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0447 - * @tc.name testUniform4fv - * @tc.desc Test uniform4fv. - */ - it('testUniform4fv', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform4fv test start ...66'); - const programObj = createProgram(gl); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniform4fv(uniformlocationObj, flaot32list); - const uniform4fvError = gl.getError(); - console.info("uniform4fvError: " + uniform4fvError); - expect(uniform4fvError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0448 - * @tc.name testUniform4fv_01 - * @tc.desc Test uniform4fv. - */ - it('testUniform4fv_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform4fv_01 test start ...66'); - const programObj = gl.createProgram(); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniform4fv(uniformlocationObj, flaot32list); - const uniform4fvError = gl.getError(); - console.info("uniform4fvError: " + uniform4fvError); - expect(uniform4fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0451 - * @tc.name testUniform4fv_04 - * @tc.desc Test uniform4fv. - */ - it('testUniform4fv_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform4fv_04 test start ...66'); - const shader = gl.createShader(gl.VERTEX_SHADER); - const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniform4fv(uniformlocationObj, flaot32list); - const uniform4fvError = gl.getError(); - console.info("uniform4fvError: " + uniform4fvError); - expect(uniform4fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0452 - * @tc.name testUniform1iv - * @tc.desc Test uniform1iv. - */ - it('testUniform1iv', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform1iv test start ...66'); - const programObj = createProgram(gl); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const int32list = new Int32Array([1, 2]); - gl.uniform1iv(uniformlocationObj, int32list); - const uniform1ivError = gl.getError(); - console.info("uniform1ivError: " + uniform1ivError); - expect(uniform1ivError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0453 - * @tc.name testUniform1iv_01 - * @tc.desc Test uniform1iv. - */ - it('testUniform1iv_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform1iv_01 test start ...66'); - const programObj = gl.createProgram(); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const int32list = new Int32Array([1, 2]); - gl.uniform1iv(uniformlocationObj, int32list); - const uniform1ivError = gl.getError(); - console.info("uniform1ivError: " + uniform1ivError); - expect(uniform1ivError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0457 - * @tc.name testUniform2iv - * @tc.desc Test uniform2iv. - */ - it('testUniform2iv', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform2iv test start ...66'); - const programObj = createProgram(gl); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const int32list = new Int32Array([1, 2]); - gl.uniform2iv(uniformlocationObj, int32list); - const uniform2ivError = gl.getError(); - console.info("testUniform2ivError: " + uniform2ivError); - expect(uniform2ivError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0458 - * @tc.name testUniform2iv_01 - * @tc.desc Test uniform2iv. - */ - it('testUniform2iv_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform2iv_01 test start ...66'); - const programObj = gl.createProgram(); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const int32list = new Int32Array([1, 2]); - gl.uniform2iv(uniformlocationObj, int32list); - const uniform2ivError = gl.getError(); - console.info("testUniform2ivError: " + uniform2ivError); - expect(uniform2ivError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0461 - * @tc.name testUniform2iv_04 - * @tc.desc Test uniform2iv. - */ - it('testUniform2iv_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform2iv_04 test start ...66'); - const shader = gl.createShader(gl.VERTEX_SHADER); - const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); - const int32list = new Int32Array([1, 2]); - gl.uniform2iv(uniformlocationObj, int32list); - const uniform2ivError = gl.getError(); - console.info("testUniform2ivError: " + uniform2ivError); - expect(uniform2ivError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0462 - * @tc.name testUniform3iv - * @tc.desc Test uniform3iv. - */ - it('testUniform3iv', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform3iv test start ...66'); - const programObj = createProgram(gl); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const int32list = new Int32Array([1, 2]); - gl.uniform3iv(uniformlocationObj, int32list); - const uniform3ivError = gl.getError(); - console.info("testUniform3ivError: " + uniform3ivError); - expect(uniform3ivError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0463 - * @tc.name testUniform3iv_01 - * @tc.desc Test uniform3iv. - */ - it('testUniform3iv_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform3iv_01 test start ...66'); - const programObj = gl.createProgram(); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const int32list = new Int32Array([1, 2]); - gl.uniform3iv(uniformlocationObj, int32list); - const uniform3ivError = gl.getError(); - console.info("testUniform3ivError: " + uniform3ivError); - expect(uniform3ivError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0466 - * @tc.name testUniform3iv_04 - * @tc.desc Test uniform3iv. - */ - it('testUniform3iv_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform3iv_04 test start ...66'); - const shader = gl.createShader(gl.VERTEX_SHADER); - const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); - const int32list = new Int32Array([1, 2]); - gl.uniform3iv(uniformlocationObj, int32list); - const uniform3ivError = gl.getError(); - console.info("testUniform3ivError: " + uniform3ivError); - expect(uniform3ivError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0467 - * @tc.name testUniform4iv - * @tc.desc Test uniform4iv. - */ - it('testUniform4iv', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform4iv test start ...66'); - const programObj = createProgram(gl); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const int32list = new Int32Array([1, 2]); - gl.uniform4iv(uniformlocationObj, int32list); - const uniform4ivError = gl.getError(); - console.info("testUniform4ivError: " + uniform4ivError); - expect(uniform4ivError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0468 - * @tc.name testUniform4iv_01 - * @tc.desc Test uniform4iv. - */ - it('testUniform4iv_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform4iv_01 test start ...66'); - const programObj = gl.createProgram(); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const int32list = new Int32Array([1, 2]); - gl.uniform4iv(uniformlocationObj, int32list); - const uniform4ivError = gl.getError(); - console.info("testUniform4ivError: " + uniform4ivError); - expect(uniform4ivError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0469 - * @tc.name testUniform4iv_02 - * @tc.desc Test uniform4iv. - */ - it('testUniform4iv_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform4iv_02 test start ...66'); - const buffer = gl.createBuffer(); - const uniformlocationObj = gl.getUniformLocation(buffer, "a_Position"); - const int32list = new Int32Array([1, 2]); - gl.uniform4iv(uniformlocationObj, int32list); - const uniform4ivError = gl.getError(); - console.info("testUniform4ivError: " + uniform4ivError); - expect(uniform4ivError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0470 - * @tc.name testUniform4iv_03 - * @tc.desc Test uniform4iv. - */ - it('testUniform4iv_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform4iv_03 test start ...66'); - const buffer = gl.createBuffer(); - const uniformlocationObj = gl.getUniformLocation(buffer, "a_Position"); - const int32list = new Int32Array([1, 2]); - gl.uniform4iv(uniformlocationObj, int32list); - const uniform4ivError = gl.getError(); - console.info("testUniform4ivError: " + uniform4ivError); - expect(uniform4ivError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0471 - * @tc.name testUniform4iv_04 - * @tc.desc Test Uniform4uiv. - */ - it('testUniform4iv_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniform4iv_03 test start ...66'); - const shader = gl.createShader(gl.VERTEX_SHADER); - const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); - const int32list = new Int32Array([1, 2]); - gl.uniform4iv(uniformlocationObj, int32list); - const uniform4ivError = gl.getError(); - console.info("testUniform4ivError: " + uniform4ivError); - expect(uniform4ivError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0472 - * @tc.name testUniformMatrix2fv - * @tc.desc Test uniformMatrix2fv. - */ - it('testUniformMatrix2fv', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix2fv test start ...66'); - const programObj = createProgram(gl); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniformMatrix2fv(uniformlocationObj, true, flaot32list); - const uniformMatrix2fvError = gl.getError(); - console.info("uniformMatrix2fvError: " + uniformMatrix2fvError); - expect(uniformMatrix2fvError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0473 - * @tc.name testUniformMatrix2fv_01 - * @tc.desc Test uniformMatrix2fv. - */ - it('testUniformMatrix2fv_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix2fv_01 test start ...66'); - const programObj = gl.createProgram(); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniformMatrix2fv(uniformlocationObj, true, flaot32list); - const uniformMatrix2fvError = gl.getError(); - console.info("uniformMatrix2fvError: " + uniformMatrix2fvError); - expect(uniformMatrix2fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0475 - * @tc.name testUniformMatrix2fv_03 - * @tc.desc Test uniformMatrix2fv. - */ - it('testUniformMatrix2fv_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix2fv_03 test start ...66'); - const buffer = gl.createBuffer(); - const uniformlocationObj = gl.getUniformLocation(buffer, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniformMatrix2fv(uniformlocationObj, true, flaot32list); - const uniformMatrix2fvError = gl.getError(); - console.info("uniformMatrix2fvError: " + uniformMatrix2fvError); - expect(uniformMatrix2fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0476 - * @tc.name testUniformMatrix2fv_04 - * @tc.desc Test uniformMatrix2fv. - */ - it('testUniformMatrix2fv_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix2fv_04 test start ...66'); - const shader = gl.createShader(gl.VERTEX_SHADER); - const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniformMatrix2fv(uniformlocationObj, true, flaot32list); - const uniformMatrix2fvError = gl.getError(); - console.info("uniformMatrix2fvError: " + uniformMatrix2fvError); - expect(uniformMatrix2fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0477 - * @tc.name testUniformMatrix3fv - * @tc.desc Test uniformMatrix3fv. - */ - it('testUniformMatrix3fv', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix3fv test start ...66'); - const programObj = createProgram(gl); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniformMatrix3fv(uniformlocationObj, true, flaot32list); - const uniformMatrix3fvError = gl.getError(); - console.info("uniformMatrix3fvError: " + uniformMatrix3fvError); - expect(uniformMatrix3fvError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0478 - * @tc.name testUniformMatrix3fv_01 - * @tc.desc Test uniformMatrix3fv. - */ - it('testUniformMatrix3fv_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix3fv_01 test start ...66'); - const programObj = gl.createProgram(); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniformMatrix3fv(uniformlocationObj, true, flaot32list); - const uniformMatrix3fvError = gl.getError(); - console.info("uniformMatrix3fvError: " + uniformMatrix3fvError); - expect(uniformMatrix3fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0479 - * @tc.name testUniformMatrix3fv_02 - * @tc.desc Test uniformMatrix3fv. - */ - it('testUniformMatrix3fv_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix3fv_02 test start ...66'); - const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); - const uniformlocationObj = gl.getUniformLocation(fragmentShader, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniformMatrix3fv(uniformlocationObj, true, flaot32list); - const uniformMatrix3fvError = gl.getError(); - console.info("uniformMatrix3fvError: " + uniformMatrix3fvError); - expect(uniformMatrix3fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0480 - * @tc.name testUniformMatrix3fv_03 - * @tc.desc Test uniformMatrix3fv. - */ - it('testUniformMatrix3fv_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix3fv_03 test start ...66'); - const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); - const uniformlocationObj = gl.getUniformLocation(fragmentShader, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniformMatrix3fv(uniformlocationObj, true, flaot32list); - const uniformMatrix3fvError = gl.getError(); - console.info("uniformMatrix3fvError: " + uniformMatrix3fvError); - expect(uniformMatrix3fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0481 - * @tc.name testUniformMatrix3fv_04 - * @tc.desc Test uniformMatrix3fv. - */ - it('testUniformMatrix3fv_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix3fv_04 test start ...66'); - var shader = gl.createShader(gl.VERTEX_SHADER); - const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - gl.uniformMatrix3fv(uniformlocationObj, true, flaot32list); - const uniformMatrix3fvError = gl.getError(); - console.info("uniformMatrix3fvError: " + uniformMatrix3fvError); - expect(uniformMatrix3fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0482 - * @tc.name testUniformMatrix4fv - * @tc.desc Test uniformMatrix4fv. - */ - it('testUniformMatrix4fv', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix4fv test start ...66'); - const programObj = createProgram(gl); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - const a = gl.uniformMatrix4fv(uniformlocationObj, true, flaot32list); - console.info("a: " + a); - const uniformMatrix4fvError = gl.getError(); - console.info("uniformMatrix4fvError: " + uniformMatrix4fvError); - expect(uniformMatrix4fvError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0483 - * @tc.name testUniformMatrix4fv_01 - * @tc.desc Test uniformMatrix4fv. - */ - it('testUniformMatrix4fv_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix4fv_01 test start ...66'); - const programObj = gl.createProgram(); - const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - const a = gl.uniformMatrix4fv(uniformlocationObj, true, flaot32list); - console.info("a: " + a); - const uniformMatrix4fvError = gl.getError(); - console.info("uniformMatrix4fvError: " + uniformMatrix4fvError); - expect(uniformMatrix4fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0484 - * @tc.name testUniformMatrix4fv_02 - * @tc.desc Test uniformMatrix4fv. - */ - it('testUniformMatrix4fv_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix4fv_02 test start ...66'); - const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); - const uniformlocationObj = gl.getUniformLocation(fragmentShader, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - const a = gl.uniformMatrix4fv(uniformlocationObj, true, flaot32list); - console.info("a: " + a); - const uniformMatrix4fvError = gl.getError(); - console.info("uniformMatrix4fvError: " + uniformMatrix4fvError); - expect(uniformMatrix4fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0485 - * @tc.name testUniformMatrix4fv_03 - * @tc.desc Test uniformMatrix4fv. - */ - it('testUniformMatrix4fv_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix4fv_03 test start ...66'); - var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); - const uniformlocationObj = gl.getUniformLocation(fragmentShader, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - const a = gl.uniformMatrix4fv(uniformlocationObj, true, flaot32list); - console.info("a: " + a); - const uniformMatrix4fvError = gl.getError(); - console.info("uniformMatrix4fvError: " + uniformMatrix4fvError); - expect(uniformMatrix4fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0486 - * @tc.name testUniformMatrix4fv_04 - * @tc.desc Test uniformMatrix4fv. - */ - it('testUniformMatrix4fv_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testUniformMatrix4fv_04 test start ...66'); - const shader = gl.createShader(gl.VERTEX_SHADER); - const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); - const flaot32list = new Float32Array([1, 2]); - const a = gl.uniformMatrix4fv(uniformlocationObj, true, flaot32list); - console.info("a: " + a); - const uniformMatrix4fvError = gl.getError(); - console.info("uniformMatrix4fvError: " + uniformMatrix4fvError); - expect(uniformMatrix4fvError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0487 - * @tc.name testCopyBufferSubData - * @tc.desc Test copyBufferSubData. - */ - it('testCopyBufferSubData', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCopyBufferSubData test start ...66'); - console.info('jsWebGL testCopyBufferSubData test start ...' + JSON.stringify(gl)); - const srcBuffer = gl.createBuffer(); - const dstBuffer = gl.createBuffer(); - const vertices = [1, 2]; - const data = new Float32Array(vertices); - const length = vertices.length * 4; - gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); - gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); - gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); - gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); - gl2.copyBufferSubData(gl.COPY_READ_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); - const copyBufferSubDataError = gl.getError(); - console.info("copyBufferSubDataError: " + copyBufferSubDataError); - expect(copyBufferSubDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0488 - * @tc.name testCopyBufferSubData_01 - * @tc.desc Test copyBufferSubData. - */ - it('testCopyBufferSubData_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCopyBufferSubData_01 test start ...66'); - const srcBuffer = gl.createBuffer(); - const dstBuffer = gl.createBuffer(); - const vertices = [1, 2]; - const data = new Float32Array(vertices); - const length = vertices.length * 4; - gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); - gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); - - gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); - gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); - gl2.copyBufferSubData(gl.ONE_MINUS_CONSTANT_ALPHA, gl.ONE_MINUS_CONSTANT_ALPHA, 0, 0, 0); - const copyBufferSubDataError = gl.getError(); - console.info("copyBufferSubDataError: " + copyBufferSubDataError); - expect(copyBufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0489 - * @tc.name testCopyBufferSubData_02 - * @tc.desc Test copyBufferSubData. - */ - it('testCopyBufferSubData_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCopyBufferSubData_02 test start ...66'); - const srcBuffer = gl.createBuffer(); - const dstBuffer = gl.createBuffer(); - const vertices = [1, 2]; - const data = new Float32Array(vertices); - const length = vertices.length * 4; - gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); - gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); - - gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); - gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); - gl2.copyBufferSubData(gl.SRC_ALPHA_SATURATE, gl.SRC_ALPHA_SATURATE, 0, 0, 0); - const copyBufferSubDataError = gl.getError(); - console.info("copyBufferSubDataError: " + copyBufferSubDataError); - expect(copyBufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0490 - * @tc.name testCopyBufferSubData_03 - * @tc.desc Test copyBufferSubData. - */ - it('testCopyBufferSubData_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCopyBufferSubData_03 test start ...66'); - const srcBuffer = gl.createBuffer(); - const dstBuffer = gl.createBuffer(); - const vertices = [1, 2]; - const data = new Float32Array(vertices); - const length = vertices.length * 4; - gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); - gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); - gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); - gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); - gl2.copyBufferSubData(gl.SRC_ALPHA_SATURATE, gl.SRC_ALPHA_SATURATE, 0, 0, length); - const copyBufferSubDataError = gl.getError(); - console.info("copyBufferSubDataError: " + copyBufferSubDataError); - expect(copyBufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0491 - * @tc.name testCopyBufferSubData_04 - * @tc.desc Test copyBufferSubData. - */ - it('testCopyBufferSubData_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCopyBufferSubData_04 test start ...66'); - const srcBuffer = gl.createBuffer(); - const dstBuffer = gl.createBuffer(); - const vertices = [1, 2]; - const data = new Float32Array(vertices); - const length = vertices.length * 4; - gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); - gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); - gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); - gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); - gl2.copyBufferSubData(gl.SRC_ALPHA_SATURATE, gl.SRC_ALPHA_SATURATE, 0, 0, gl - .ONE_MINUS_CONSTANT_COLOR); - const copyBufferSubDataError = gl.getError(); - console.info("copyBufferSubDataError: " + copyBufferSubDataError); - expect(copyBufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0492 - * @tc.name testGetBufferSubData - * @tc.desc Test getBufferSubData. - */ - it('testGetBufferSubData', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetBufferSubData test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const vertices = [1, 2]; - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); - var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); - gl2.getBufferSubData(gl.ARRAY_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); - const getBufferSubDataError = gl.getError(); - console.info("getBufferSubDataError: " + getBufferSubDataError); - expect(getBufferSubDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0493 - * @tc.name testGetBufferSubData_01 - * @tc.desc Test getBufferSubData. - */ - it('testGetBufferSubData_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetBufferSubData_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const vertices = [1, 2]; - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); - var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); - gl2.getBufferSubData(gl.SRC_ALPHA_SATURATE, 0, new Float32Array(arrBuffer), 0, 0); - const getBufferSubDataError = gl.getError(); - console.info("getBufferSubDataError: " + getBufferSubDataError); - expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0494 - * @tc.name testGetBufferSubData_02 - * @tc.desc Test getBufferSubData. - */ - it('testGetBufferSubData_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetBufferSubData_02 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const vertices = [1, 2]; - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); - var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); - gl2.getBufferSubData(gl.FUNC_SUBTRACT, 0, new Float32Array(arrBuffer), 0, 0); - const getBufferSubDataError = gl.getError(); - console.info("getBufferSubDataError: " + getBufferSubDataError); - expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0495 - * @tc.name testGetBufferSubData_03 - * @tc.desc Test getBufferSubData. - */ - it('testGetBufferSubData_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetBufferSubData_03 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const vertices = [1, 2]; - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); - var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); - gl2.getBufferSubData(gl.BLEND_DST_RGB, 0, new Int32Array(arrBuffer), 0, 0); - const getBufferSubDataError = gl.getError(); - console.info("getBufferSubDataError: " + getBufferSubDataError); - expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0496 - * @tc.name testGetBufferSubData_04 - * @tc.desc Test getBufferSubData. - */ - it('testGetBufferSubData_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetBufferSubData_04 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const vertices = [1, 2]; - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.BLEND_SRC_ALPHA); - var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); - gl2.getBufferSubData(gl.ARRAY_BUFFER, 0, new Int32Array(arrBuffer), 0, 0); - const getBufferSubDataError = gl.getError(); - console.info("getBufferSubDataError: " + getBufferSubDataError); - expect(getBufferSubDataError).assertEqual(gl.NO_ERROR); - for(let err; (err = gl.getError()) != gl.NO_ERROR;) {} - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0497 - * @tc.name testBlitFramebuffer - * @tc.desc Test blitFramebuffer. - */ - it('testBlitFramebuffer', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBlitFramebuffer test start ...66'); - console.info('jsWebGL testBlitFramebuffer test start ...' + JSON.stringify(gl)); - gl2.blitFramebuffer(0, 0, 400, 1080, 0, 0, 400, 1080, gl2.COLOR_BUFFER_BIT, gl2.NEAREST); - const blitFramebufferError = gl.getError(); - console.info("blitFramebufferError: " + blitFramebufferError); - expect(blitFramebufferError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0498 - * @tc.name testFramebufferTextureLayer - * @tc.desc Test framebufferTextureLayer. - */ - it('testFramebufferTextureLayer', 0, async function(done) { - //initContext(); - console.info('jsWebGL testFramebufferTextureLayer test start ...66'); - console.info('jsWebGL testFramebufferTextureLayer test start ...' + JSON.stringify(gl)); - var texture = gl.createTexture(); - gl2.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, - texture, 0, 8) - const framebufferTextureLayerError = gl.getError(); - console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); - expect(framebufferTextureLayerError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0499 - * @tc.name testInvalidateFramebuffer - * @tc.desc Test invalidateFramebuffer. - */ - it('testInvalidateFramebuffer', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateFramebuffer test start ...66'); - console.info('jsWebGL testInvalidateFramebuffer test start ...' + JSON.stringify(gl)); - gl2.invalidateFramebuffer(gl.READ_FRAMEBUFFER, - [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1]); - const invalidateFramebufferError = gl.getError(); - console.info("invalidateFramebufferError: " + invalidateFramebufferError); - expect(invalidateFramebufferError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0500 - * @tc.name testInvalidateSubFramebuffer - * @tc.desc Test invalidateSubFramebuffer. - */ - it('testInvalidateSubFramebuffer', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateSubFramebuffer test start ...66'); - console.info('jsWebGL testInvalidateSubFramebuffer test start ...' + JSON.stringify(gl)); - gl2.invalidateSubFramebuffer(gl.READ_FRAMEBUFFER, - [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1], - 0, 0, 256, 256); - const invalidateSubFramebufferError = gl.getError(); - console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); - expect(invalidateSubFramebufferError).assertEqual(0); - done(); - }) -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test06.js b/graphic/webGL/src/main/js/default/test/WebGL.test06.js deleted file mode 100644 index 609b41d835f964fa4325c90d5eff74a77334be69..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test06.js +++ /dev/null @@ -1,2443 +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_webgl6', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_0502 - * @tc.name testGetInternalformatParameter - * @tc.desc Test getInternalformatParameter. - */ - it('testGetInternalformatParameter', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetInternalformatParameter test start ...66'); - var samples = gl2.getInternalformatParameter(gl.RENDERBUFFER, gl2.RGBA8, gl.SAMPLES); - console.info("samples: " + samples); - const int32list = [-1, -1, -1]; - expect(samples.toString() != int32list.toString()).assertEqual(true); - //判断数据类型是否正确 - // expect(samples.constructor).assertEqual(int32list.constructor); - //判断数据值是否正确 - // expect(samples.toString()).assertEqual(int32list.toString()); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0503 - * @tc.name testGetInternalformatParameter_01 - * @tc.desc Test getInternalformatParameter. - */ - it('testGetInternalformatParameter_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetInternalformatParameter_01 test start ...66'); - var samples = gl2.getInternalformatParameter(gl.RENDERBUFFER, gl2.RGBA8, gl.SAMPLES); - console.info("samples: " + samples); - const int32list = new Int32Array([-1, -1, -1]); - expect(samples.constructor).assertEqual(int32list.constructor); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0504 - * @tc.name testRenderbufferStorageMultisample - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); - gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.RBGA4, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0505 - * @tc.name testTexStorage2D - * @tc.desc Test texStorage2D. - */ - it('testTexStorage2D', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexStorage2D test start ...66'); - console.info('jsWebGL testTexStorage2D test start ...' + JSON.stringify(gl)); - gl2.texStorage2D(gl.TEXTURE_2D, 1, gl.RGB8, 256, 256); - const texStorage2DError = gl.getError(); - console.info("texStorage2DError: " + texStorage2DError); - expect(texStorage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0506 - * @tc.name testTransformFeedbackVaryings - * @tc.desc Test transformFeedbackVaryings. - */ - it('testTransformFeedbackVaryings', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTransformFeedbackVaryings test start ...66'); - console.info('jsWebGL testTransformFeedbackVaryings test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - var transformFeedbackOutputs = ['gl_Position', 'anotherOutput']; - gl2.transformFeedbackVaryings(program, transformFeedbackOutputs, gl.INTERLEAVED_ATTRIBS); - const transformFeedbackVaryingsError = gl.getError(); - console.info("transformFeedbackVaryingsError: " + transformFeedbackVaryingsError); - expect(transformFeedbackVaryingsError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0508 - * @tc.name testPauseTransformFeedback - * @tc.desc Test pauseTransformFeedback. - */ - it('testPauseTransformFeedback', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testPauseTransformFeedback test start ...66'); - console.info('jsWebGL testPauseTransformFeedback test start ...' + JSON.stringify(gl)); - const transformFeedback = gl2.createTransformFeedback(); - gl2.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, transformFeedback); - gl2.beginTransformFeedback(gl2.TRIANGLES); - gl2.pauseTransformFeedback(); - const pauseTransformFeedbackError = gl.getError(); - console.info("pauseTransformFeedbackError: " + pauseTransformFeedbackError); - expect(pauseTransformFeedbackError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testPauseTransformFeedback has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0509 - * @tc.name testResumeTransformFeedback - * @tc.desc Test resumeTransformFeedback. - */ - it('testResumeTransformFeedback', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testPauseTransformFeedback test start ...66'); - console.info('jsWebGL testPauseTransformFeedback test start ...' + JSON.stringify(gl)); - gl2.resumeTransformFeedback(); - const resumeTransformFeedbackError = gl.getError(); - console.info("resumeTransformFeedbackError: " + resumeTransformFeedbackError); - expect(resumeTransformFeedbackError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("resumeTransformFeedbackError has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0510 - * @tc.name testBindBufferBase - * @tc.desc Test bindBufferBase. - */ - it('testBindBufferBase', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testBindBufferBase test start ...66'); - console.info('jsWebGL testBindBufferBase test start ...' + JSON.stringify(gl)); - let buffer = gl.createBuffer(); - gl2.bindBufferBase(gl.TRANSFORM_FEEDBACK_BUFFER, 0, buffer); - const bindBufferBaseError = gl.getError(); - console.info("bindBufferBaseError: " + bindBufferBaseError); - expect(bindBufferBaseError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("bindBufferBaseError has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0511 - * @tc.name testGetIndexedParameter - * @tc.desc Test getIndexedParameter. - */ - it('testGetIndexedParameter', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetIndexedParameter test start ...66'); - console.info('jsWebGL testGetIndexedParameter test start ...' + JSON.stringify(gl)); - const WebGLBufferobject = gl2.getIndexedParameter(gl.TRANSFORM_FEEDBACK_BUFFER_BINDING, - 0); - const isBuffer = gl.isBuffer(WebGLBufferobject); - expect(isBuffer).assertEqual(false); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetIndexedParameter has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0512 - * @tc.name testGetIndexedParameter_01 - * @tc.desc Test getIndexedParameter. - */ - it('testGetIndexedParameter_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetIndexedParameter_01 test start ...66'); - console.info('jsWebGL testGetIndexedParameter_01 test start ...' + JSON.stringify(gl)); - const reurGLsizeiptr = gl2.getIndexedParameter(gl.TRANSFORM_FEEDBACK_BUFFER_SIZE, 0); - const typeGLsizeiptr = typeof(reurGLsizeiptr); - expect(typeGLsizeiptr).assertInstanceOf('String'); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetIndexedParameter_01 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0513 - * @tc.name testGetIndexedParameter_02 - * @tc.desc Test getIndexedParameter. - */ - it('testGetIndexedParameter_02', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetIndexedParameter_02 test start ...66'); - console.info('jsWebGL testGetIndexedParameter_02 test start ...' + JSON.stringify(gl)); - const retuGLintptr = gl2.getIndexedParameter(gl.TRANSFORM_FEEDBACK_BUFFER_START, 0); - const typeGLintptr = typeof(retuGLintptr); - expect(typeGLintptr).assertInstanceOf('String'); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetIndexedParameter_02 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0514 - * @tc.name testGetIndexedParameter_03 - * @tc.desc Test getIndexedParameter. - */ - it('testGetIndexedParameter_03', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetIndexedParameter_03 test start ...66'); - console.info('jsWebGL testGetIndexedParameter_03 test start ...' + JSON.stringify(gl)); - const WebGLBufferobject = gl2.getIndexedParameter(gl.UNIFORM_BUFFER_BINDING, 0); - const isBuffer = gl.isBuffer(WebGLBufferobject); - expect(isBuffer).assertEqual(false); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetIndexedParameter_03 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0515 - * @tc.name testGetIndexedParameter_04 - * @tc.desc Test getIndexedParameter. - */ - it('testGetIndexedParameter_04', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetIndexedParameter_04 test start ...66'); - console.info('jsWebGL testGetIndexedParameter_04 test start ...' + JSON.stringify(gl)); - const reurGLsizeiptr = gl2.getIndexedParameter(gl.UNIFORM_BUFFER_SIZE, 0); - const typeGLsizeiptr = typeof(reurGLsizeiptr); - expect(typeGLsizeiptr).assertInstanceOf('String'); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetIndexedParameter_04 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0516 - * @tc.name testGetIndexedParameter_05 - * @tc.desc Test getIndexedParameter. - */ - it('testGetIndexedParameter_05', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetIndexedParameter_05 test start ...66'); - console.info('jsWebGL testGetIndexedParameter_05 test start ...' + JSON.stringify(gl)); - const retuGLintptr = gl2.getIndexedParameter(gl.UNIFORM_BUFFER_START, 0); - const typeGLintptr = typeof(retuGLintptr); - expect(typeGLintptr).assertInstanceOf('String'); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetIndexedParameter_05 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0517 - * @tc.name testGetUniformIndices - * @tc.desc Test getUniformIndices. - */ - it('testGetUniformIndices', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetUniformIndices test start ...66'); - console.info('jsWebGL testGetUniformIndices test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - const retuGLintptr = gl2.getUniformIndices(program, ['UBORed', 'UBOGreen', 'UBOBlue']); - console.log("testGetUniformIndices has failed for " + retuGLintptr) - const int32list = [-1, -1, -1]; - console.log("testGetUniformIndices has failed for " + int32list) - //判断数据类型是否正确 - expect(retuGLintptr.constructor).assertEqual(int32list.constructor); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetUniformIndices has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0518 - * @tc.name testGetUniformIndices_01 - * @tc.desc Test getUniformIndices. - */ - it('testGetUniformIndices_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetUniformIndices_01 test start ...66'); - const program = gl.createProgram(); - const retuGLintptr = gl2.getUniformIndices(program, ['UBORed', 'UBOGreen', 'UBOBlue']); - console.log("testGetUniformIndices has failed for " + retuGLintptr) - const int32list = [-1, -1, -1]; - console.log("testGetUniformIndices_01 has failed for " + int32list) - //判断数据值是否正确 - expect(retuGLintptr.toString() != int32list.toString()).assertEqual(true); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetUniformIndices has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0519 - * @tc.name testGetActiveUniforms - * @tc.desc Test getActiveUniforms. - */ - it('testGetActiveUniforms', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetActiveUniforms test start ...66'); - console.info('jsWebGL testGetActiveUniforms test start ...' + JSON.stringify(gl)); - // const programObj = 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); - - - - const uniformIndices = [1, 2, 3]; - const uniformType = gl2.getActiveUniforms(programObj, uniformIndices, gl2.UNIFORM_TYPE) - const glenumList = [-1, -1, -1]; - expect(uniformType.toString() != glenumList.toString()).assertEqual(true); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetActiveUniforms has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0520 - * @tc.name testGetActiveUniforms_01 - * @tc.desc Test getActiveUniforms. - */ - it('testGetActiveUniforms_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetActiveUniforms_01 test start ...66'); - //顶点着色器程序 - 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); - - const uniformIndices = [1, 2, 3]; - const uniformType = gl2.getActiveUniforms(programObj, uniformIndices, gl2.UNIFORM_TYPE) - const glenumList = [-1, -1, -1]; - expect(uniformType.constructor).assertEqual(glenumList.constructor); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetActiveUniforms has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0521 - * @tc.name testGetActiveUniforms_02 - * @tc.desc Test getActiveUniforms. - */ - it('testGetActiveUniforms_02', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetActiveUniforms_02 test start ...66'); - //顶点着色器程序 - 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); - - const uniformIndices = [4, 5, 6]; - const uniformSize = gl2.getActiveUniforms(programObj, uniformIndices, gl2.UNIFORM_SIZE) - const gluintList = [-1, 0, 0]; - expect(uniformSize.toString() != gluintList.toString()).assertEqual(true); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetActiveUniforms_02 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0522 - * @tc.name testGetActiveUniforms_03 - * @tc.desc Test getActiveUniforms. - */ - it('testGetActiveUniforms_03', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetActiveUniforms_03 test start ...66'); - //顶点着色器程序 - 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); - const uniformIndices = [7, 8, 9]; - const uniformBlockIndex = gl2.getActiveUniforms(programObj, uniformIndices, gl2 - .UNIFORM_BLOCK_INDEX) - const glintlist = [-1, 0, 0]; - expect(uniformBlockIndex.toString() != glintlist.toString()).assertEqual(true); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetActiveUniforms_03 has failed for " + e) - expect(null).assertFail() - } - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0523 - * @tc.name testGetActiveUniforms_04 - * @tc.desc Test getActiveUniforms. - */ - it('testGetActiveUniforms_04', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetActiveUniforms_04 test start ...66'); - //顶点着色器程序 - 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); - const uniformIndices = [1, 2, 3]; - const uniformOffset = gl2.getActiveUniforms(programObj, uniformIndices, gl2 - .UNIFORM_OFFSET) - const glintlist = [-1, 0, 0]; - expect(uniformOffset.toString() != glintlist.toString()).assertEqual(true); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetActiveUniforms_04 has failed for " + e) - expect(null).assertFail() - } - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0524 - * @tc.name testGetActiveUniforms_05 - * @tc.desc Test getActiveUniforms. - */ - it('testGetActiveUniforms_05', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetActiveUniforms_05 test start ...66'); - //顶点着色器程序 - 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); - const uniformIndices = [1, 2, 3]; - const uniformStride = gl2.getActiveUniforms(programObj, uniformIndices, gl2 - .UNIFORM_ARRAY_STRIDE) - const glintlist = [-1, 0, 0]; - expect(uniformStride.toString() != glintlist.toString()).assertEqual(true); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetActiveUniforms_05 has failed for " + e) - expect(null).assertFail() - } - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0525 - * @tc.name testGetActiveUniforms_06 - * @tc.desc Test getActiveUniforms. - */ - it('testGetActiveUniforms_06', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetActiveUniforms_06 test start ...66'); - //顶点着色器程序 - 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); - const uniformIndices = [1, 2, 3]; - const uniformMatrixStride = gl2.getActiveUniforms(programObj, uniformIndices, gl2 - .UNIFORM_MATRIX_STRIDE) - const glbooleanlist = [-1, 0, 0]; - expect(uniformMatrixStride.toString() != glbooleanlist.toString()).assertEqual(true); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetActiveUniforms_06 has failed for " + e) - expect(null).assertFail() - } - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0527 - * @tc.name testUseProgram - * @tc.desc Test useProgram. - */ - it('testUseProgram', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testUseProgram test start ...66'); - console.info('jsWebGL testUseProgram test start ...' + JSON.stringify(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 program = gl.createProgram(); - console.log("testUseProgram has failed for " + program) - const useProgramError1 = gl.getError(); - console.info("useProgramError: " + useProgramError1); - const renderBufferValue1 = gl.getParameter(gl.CURRENT_PROGRAM); - console.log("testUseProgram has failed for " + program) - gl.attachShader(program, vertexShader); - gl.attachShader(program, fragmentShader); - gl.linkProgram(program); - gl.useProgram(program); - const useProgramError = gl.getError(); - console.info("useProgramError: " + useProgramError); - expect(useProgramError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testUseProgram has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0528 - * @tc.name testValidateProgram - * @tc.desc Test validateProgram. - */ - it('testValidateProgram', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testValidateProgram test start ...66'); - console.info('jsWebGL testValidateProgram test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - gl.validateProgram(program); - const validateProgramError = gl.getError(); - console.info("validateProgramError: " + validateProgramError); - expect(validateProgramError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testValidateProgram has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0529 - * @tc.name testVertexAttrib1f - * @tc.desc Test vertexAttrib1f. - */ - it('testVertexAttrib1f', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib1f test start ...66'); - console.info('jsWebGL testVertexAttrib1f test start ...' + JSON.stringify(gl)); - gl.vertexAttrib1f(1, 10.0); - const vertexAttrib1fError = gl.getError(); - console.info("vertexAttrib1fError: " + vertexAttrib1fError); - expect(vertexAttrib1fError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib1f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0530 - * @tc.name testVertexAttrib2f - * @tc.desc Test vertexAttrib2f. - */ - it('testVertexAttrib2f', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib2f test start ...66'); - gl.vertexAttrib2f(1, 10.0); - const vertexAttrib2fError = gl.getError(); - console.info("vertexAttrib2fError: " + vertexAttrib2fError); - expect(vertexAttrib2fError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib2f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0531 - * @tc.name testVertexAttrib3f - * @tc.desc Test vertexAttrib3f. - */ - it('testVertexAttrib3f', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testvertexAttrib3f test start ...66'); - console.info('jsWebGL testvertexAttrib3f test start ...' + JSON.stringify(gl)); - gl.vertexAttrib3f(1, 10.0); - const vertexAttrib3fError = gl.getError(); - console.info("vertexAttrib3fError: " + vertexAttrib3fError); - expect(vertexAttrib3fError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib3f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0532 - * @tc.name testVertexAttrib4f - * @tc.desc Test vertexAttrib4f. - */ - it('testVertexAttrib4f', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib4f test start ...66'); - console.info('jsWebGL testVertexAttrib4f test start ...' + JSON.stringify(gl)); - gl.vertexAttrib4f(1, 10.0); - const vertexAttrib4fError = gl.getError(); - console.info("vertexAttrib4fError: " + vertexAttrib4fError); - expect(vertexAttrib4fError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testvertexAttrib4f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0533 - * @tc.name testVertexAttrib1fv - * @tc.desc Test vertexAttrib1fv. - */ - it('testVertexAttrib1fv', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib1fv test start ...66'); - console.info('jsWebGL testVertexAttrib1fv test start ...' + JSON.stringify(gl)); - const floatArray = new Float32Array([10.0, 5.0, 2.0]); - gl.vertexAttrib1fv(1, floatArray); - const vertexAttrib1fvError = gl.getError(); - console.info("vertexAttrib1fvError: " + vertexAttrib1fvError); - expect(vertexAttrib1fvError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib1fv has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0534 - * @tc.name testVertexAttrib2fv - * @tc.desc Test vertexAttrib2fv. - */ - it('testVertexAttrib2fv', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib2fv test start ...66'); - console.info('jsWebGL testVertexAttrib2fv test start ...' + JSON.stringify(gl)); - const floatArray = new Float32Array([10.0, 5.0, 2.0]); - gl.vertexAttrib2fv(1, floatArray); - const vertexAttrib2fvError = gl.getError(); - console.info("vertexAttrib2fvError: " + vertexAttrib2fvError); - expect(vertexAttrib2fvError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib2fv has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0535 - * @tc.name testVertexAttrib3fv - * @tc.desc Test vertexAttrib3fv. - */ - it('testVertexAttrib3fv', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib3fv test start ...66'); - console.info('jsWebGL testVertexAttrib3fv test start ...' + JSON.stringify(gl)); - const floatArray = new Float32Array([10.0, 5.0, 2.0]); - gl.vertexAttrib3fv(1, floatArray); - const vertexAttrib3fvError = gl.getError(); - console.info("vertexAttrib3fvError: " + vertexAttrib3fvError); - expect(vertexAttrib3fvError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib3fv has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0536 - * @tc.name testVertexAttrib4fv - * @tc.desc Test vertexAttrib4fv. - */ - it('testVertexAttrib4fv', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib4fv test start ...66'); - console.info('jsWebGL testVertexAttrib4fv test start ...' + JSON.stringify(gl)); - const floatArray = new Float32Array([10.0, 5.0, 2.0]); - gl.vertexAttrib4fv(1, floatArray); - const vertexAttrib4fvError = gl.getError(); - console.info("vertexAttrib4fvError: " + vertexAttrib4fvError); - expect(vertexAttrib4fvError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib4fv has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0537 - * @tc.name testVertexAttribPointer - * @tc.desc Test vertexAttribPointer. - */ - it('testVertexAttribPointer', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttribPointer test start ...66'); - console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); - gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 20, 0); - const vertexAttribPointerError = gl.getError(); - console.info("vertexAttribPointerError: " + vertexAttribPointerError); - expect(vertexAttribPointerError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttribPointer has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0538 - * @tc.name testViewport - * @tc.desc Test viewport. - */ - it('testViewport', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testViewport test start ...66'); - console.info('jsWebGL testViewport test start ...' + JSON.stringify(gl)); - gl.viewport(1, 2, 3, 4); - const viewportError = gl.getError(); - console.info("viewportError: " + viewportError); - expect(viewportError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testViewport has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0539 - * @tc.name testTexStorage3D - * @tc.desc Test texStorage3D. - */ - it('testTexStorage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexStorage3D test start ...66'); - console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); - gl2.texStorage3D(gl.TEXTURE_3D, 1, gl.RGB8, 256, 256, 256); - const texStorage3DError = gl.getError(); - console.info("texStorage3DError: " + texStorage3DError); - expect(texStorage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexStorage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0540 - * @tc.name testTexImage3D - * @tc.desc Test texImage3D. - */ - it('testTexImage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D test start ...66'); - console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); - gl2.texImage3D(gl2.TEXTURE_3D, 0, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0541 - * @tc.name testTexImage3D_01 - * @tc.desc Test texImage3D. - */ - it('testTexImage3D_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D_01 test start ...66'); - console.info('jsWebGL testTexImage3D_01 test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - gl2.texImage3D(gl2.TEXTURE_3D, 0, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, - buffer); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D_01 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0542 - * @tc.name testTexImage3D_02 - * @tc.desc Test texImage3D. - */ - it('testTexImage3D_02', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D_02 test start ...66'); - console.info('jsWebGL testTexImage3D_02 test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - gl2.texImage3D(gl2.TEXTURE_3D, 0, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, - buffer, 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D_02 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0543 - * @tc.name testTexSubImage3D - * @tc.desc Test texSubImage3D. - */ - it('testTexSubImage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexSubImage3D test start ...66'); - console.info('jsWebGL testTexSubImage3D test start ...' + JSON.stringify(gl)); - gl2.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 200, 200, 1, gl.RGBA, gl.UNSIGNED_BYTE, 1); - const texSubImage3DError = gl.getError(); - console.info("texSubImage3DError: " + texSubImage3DError); - expect(texSubImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexSubImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0544 - * @tc.name testTexSubImage3D_01 - * @tc.desc Test texSubImage3D. - */ - it('testTexSubImage3D_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexSubImage3D_01 test start ...66'); - console.info('jsWebGL testTexSubImage3D_01 test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(16); - const view = new DataView(buffer, 12, 4); - gl2.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 200, 200, 1, gl.RGBA, gl.UNSIGNED_BYTE, - buffer, 0); - const texSubImage3DError = gl.getError(); - console.info("texSubImage3DError: " + texSubImage3DError); - expect(texSubImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexSubImage3D_01 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0545 - * @tc.name testCopyTexSubImage3D - * @tc.desc Test copyTexSubImage3D. - */ - it('testCopyTexSubImage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCopyTexSubImage3D test start ...66'); - console.info('jsWebGL testCopyTexSubImage3D test start ...' + JSON.stringify(gl)); - gl2.copyTexSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 0, 0, 16, 16); - const copyTexSubImage3DError = gl.getError(); - console.info("copyTexSubImage3DError: " + copyTexSubImage3DError); - expect(copyTexSubImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCopyTexSubImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0546 - * @tc.name testCompressedTexImage3D_01 - * @tc.desc Test compressedTexImage3D. - */ - it('testCompressedTexImage3D_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexImage3D_01 test start ...66'); - console.info('jsWebGL testCompressedTexImage3D_01 test start ...' + JSON.stringify(gl)); - gl2.compressedTexImage3D(gl.TEXTURE_3D, 0, 0x83F0, 512, 512, 512, 0, gl2 - .PIXEL_UNPACK_BUFFER, 0); - const compressedTexImage3DError = gl.getError(); - console.info("compressedTexImage3DError: " + compressedTexImage3DError); - expect(compressedTexImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexImage3D_01 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0547 - * @tc.name testCompressedTexImage3D_02 - * @tc.desc Test compressedTexImage3D. - */ - it('testCompressedTexImage3D_02', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexImage3D_02 test start ...66'); - console.info('jsWebGL testCompressedTexImage3D_02 test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - gl2.compressedTexImage3D(gl.TEXTURE_3D, 0, 0x83F0, 512, 512, 512, 0, buffer, 0, 0); - const compressedTexImage3DError = gl.getError(); - console.info("compressedTexImage3DError: " + compressedTexImage3DError); - expect(compressedTexImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexImage3D_02 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0548 - * @tc.name testCompressedTexSubImage3D - * @tc.desc Test compressedTexSubImage3D. - */ - it('testCompressedTexSubImage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexSubImage3D test start ...66'); - console.info('jsWebGL testCompressedTexSubImage3D test start ...' + JSON.stringify(gl)); - gl2.compressedTexSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 512, 512, 512, gl2 - .COMPRESSED_R11_EAC, - gl2.PIXEL_UNPACK_BUFFER, 0); - const compressedTexSubImage3DError = gl.getError(); - console.info("compressedTexSubImage3DError: " + compressedTexSubImage3DError); - expect(compressedTexSubImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexSubImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0549 - * @tc.name testCompressedTexSubImage3D_01 - * @tc.desc Test compressedTexSubImage3D. - */ - it('testCompressedTexSubImage3D_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexSubImage3D test start ...66'); - console.info('jsWebGL testCompressedTexSubImage3D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - gl2.compressedTexSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 512, 512, 512, gl2 - .COMPRESSED_R11_EAC, buffer, 0, 256); - const compressedTexSubImage3DError = gl.getError(); - console.info("compressedTexSubImage3DError: " + compressedTexSubImage3DError); - expect(compressedTexSubImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexSubImage3D_01 has failed for " + e) - expect(null).assertFail() - } - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0550 - * @tc.name testGetActiveAttribError - * @tc.desc Test getActiveAttrib. - */ - it('testGetActiveAttribError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getActiveAttrib test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - const info = gl.getActiveAttrib(); - expect(info).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0551 - * @tc.name testGetActiveUniformError - * @tc.desc Test getActiveUniform. - */ - it('testGetActiveUniformError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getActiveUniform test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - const info = gl.getActiveUniform(program); - expect(info).assertEqual(undefined); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0552 - * @tc.name testGetAttachedShadersError - * @tc.desc Test getAttachedShaders. - */ - it('testGetAttachedShadersError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getAttachedShaders test start ...' + JSON.stringify(gl)); - const shaderArray = gl.getAttachedShaders(); - console.info('getAttachedShaders shaderArray' + shaderArray); - expect(shaderArray).assertEqual(undefined); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0553 - * @tc.name testGetBufferParameterError - * @tc.desc Test getBufferParameter. - */ - it('testGetBufferParameterError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getBufferParameter test start ...' + JSON.stringify(gl)); - const buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - const bufferSize = gl.getBufferParameter(gl.ARRAY_BUFFER); - expect(bufferSize).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0554 - * @tc.name testGetParameterError - * @tc.desc Test getParameter. - */ - it('testGetParameterError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - var textureParameter = gl.getParameter(); - console.info("activeTexture --> getParameter: " + textureParameter); - expect(textureParameter).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0555 - * @tc.name testGetError_error - * @tc.desc Test getParameter. - */ - it('testGetError_error', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.enable(gl.SCISSOR_TEST); - const scissorErrorCode = gl.scissor(0); - console.info("scissorErrorCode: " + scissorErrorCode); - expect(scissorErrorCode).assertEqual(undefined); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0556 - * @tc.name testGetFramebufferAttachmentParameterError - * @tc.desc Test frontFace. - */ - it('testGetFramebufferAttachmentParameterError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const framebuffer = gl.getFramebufferAttachmentParameter(gl - .FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); - console.info('Framebuffer' + framebuffer); - expect(framebuffer).assertEqual(undefined); - done(); - }); - - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0557 - * @tc.name testGetProgramInfoLog - * @tc.desc Test getProgramInfoLog. - */ - it('testGetProgramInfoLog', 0, async function(done) { - //initContext(); - console.info('jsWebGL getProgramInfoLog test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - // Attach pre-existing shaders - gl.attachShader(program, VSHADER_SOURCE); - gl.attachShader(program, FSHADER_SOURCE); - gl.linkProgram(program); - gl.validateProgram(program); - const info = gl.getProgramInfoLog(); - gl.useProgram(program); - expect(info).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0558 - * @tc.name testGetShaderPrecisionFormatError - * @tc.desc Test getShaderPrecisionFormat. - */ - it('testGetShaderPrecisionFormatError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); - const shaderPrecisionFormat = gl.getShaderPrecisionFormat(); - console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); - expect(shaderPrecisionFormat).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0559 - * @tc.name testGetShaderInfoLogError - * @tc.desc Test getShaderInfoLog. - */ - it('testGetShaderInfoLogError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderInfoLog test start ...' + JSON.stringify(gl)); - var shader = gl.createShader(gl.VERTEX_SHADER); - gl.shaderSource(shader, "shaderCode"); - - /* compile shader source code. */ - gl.compileShader(shader); - const message = gl.getShaderInfoLog(); - console.info("getShaderInfoLog message: " + message); - const type = (message === null); - expect(type).assertEqual(true); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0560 - * @tc.name testGetShaderSource - * @tc.desc Test getShaderSource. - */ - it('testGetShaderSourceError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderSource test start ...' + JSON.stringify(gl)); - var shader = gl.createShader(gl.VERTEX_SHADER); - gl.shaderSource(shader, 'originalSource'); - - var source = gl.getShaderSource(); - console.info("getShaderSource source: " + source); - expect(source).assertEqual(undefined); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0561 - * @tc.name testGetVertexAttribFirst - * @tc.desc Test getVertexAttrib. - */ - it('testGetVertexAttribFirstError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); - const type = gl.getVertexAttrib(0); - console.info("getVertexAttrib: type" + type); - expect(type).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0562 - * @tc.name testGetVertexAttribOffset - * @tc.desc Test getVertexAttribOffset. - */ - it('testGetVertexAttribOffsetError', 0, async function(done) { - //initContext(); - console.info('jsWebGL getVertexAttribOffset test start ...' + JSON.stringify(gl)); - const index = gl.getVertexAttribOffset(); - console.info("getVertexAttribOffset: index" + index); - expect(index).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0563 - * @tc.name testIsBufferError - * @tc.desc Test isBuffer. - */ - it('testIsBufferError', 0, async function(done) { - //initContext(); - console.info('jsWebGL isBuffer test start ...' + JSON.stringify(gl)); - const buffer = gl.createBuffer(); - const isBuffer1 = gl.isBuffer(buffer); - console.info('isBuffer1' + isBuffer1); - expect(isBuffer1).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0564 - * @tc.name testIsEnabledError - * @tc.desc Test isEnabled. - */ - it('testIsEnabledError', 0, async function(done) { - //initContext(); - console.info('jsWebGL isEnabled test start ...' + JSON.stringify(gl)); - gl.disable(gl.STENCIL_TEST); - const isEnabledValue2 = gl.isEnabled(gl.STENCIL_TEST); - console.info("isEnabledValue2: " + isEnabledValue2); - expect(isEnabledValue2).assertEqual(false); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0565 - * @tc.name testRenderbufferStorageError - * @tc.desc Test renderbufferStorage. - */ - it('testRenderbufferStorageError', 0, async function(done) { - //initContext(); - console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); - const returnValue = gl.renderbufferStorage(256, 256); - console.info("getRenderbufferParameter returnValue: " + returnValue); - expect(returnValue).assertEqual(undefined); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0566 - * @tc.name testSampleCoverageError - * @tc.desc Test sampleCoverage. - */ - it('testSampleCoverageError', 0, async function(done) { - //initContext(); - console.info('jsWebGL sampleCoverage test start ...' + JSON.stringify(gl)); - //initContext(); - console.info('jsWebGL sampleCoverage test start ...' + JSON.stringify(gl)); - - const sampleCoverageInvert = gl.sampleCoverage(); - - console.info("sampleCoverageInvert: " + sampleCoverageInvert); - - expect(sampleCoverageInvert).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0567 - * @tc.name testScissorError - * @tc.desc Test scissor. - */ - it('testScissorError', 0, async function(done) { - //initContext(); - console.info('jsWebGL scissor test start ...' + JSON.stringify(gl)); - const scissorValue = gl.scissor(200); - console.info("scissorValue: " + scissorValue); - expect(scissorValue).assertEqual(undefined); - - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0568 - * @tc.name testShaderSourceError - * @tc.desc Test shaderSource. - */ - it('testShaderSourceError', 0, async function(done) { - //initContext(); - console.info('jsWebGL shaderSource test start ...' + JSON.stringify(gl)); - var shader = gl.createShader(gl.VERTEX_SHADER); - var source = gl.shaderSource(shader); - console.info("shaderSource source: " + source); - expect(source).assertEqual(undefined); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0569 - * @tc.name testStencilFuncError - * @tc.desc Test stencilFunc. - */ - it('testStencilFuncError', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilFunc test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - const stencilFuncParameter = gl.stencilFunc(gl.LESS); - console.info("stencilFunc stencilFuncParameter: " + stencilFuncParameter); - expect(stencilFuncParameter).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0570 - * @tc.name testStencilFuncSeparateError - * @tc.desc Test stencilFuncSeparate. - */ - it('testStencilFuncSeparateError', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilFuncSeparate test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - const stencilFuncSeparateParameter = gl.stencilFuncSeparate(gl.FRONT); - console.info("stencilFuncSeparate stencilFuncSeparateParameter: " + - stencilFuncSeparateParameter); - expect(stencilFuncSeparateParameter).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0571 - * @tc.name testStencilMaskError - * @tc.desc Test stencilMask. - */ - it('testStencilMaskError', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilMask test start ...' + JSON.stringify(gl)); - const stencilMaskParameter = gl.stencilMask(); - console.info("stencilMask stencilMaskParameter: " + stencilMaskParameter); - expect(stencilMaskParameter).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0572 - * @tc.name testStencilMaskSeparateError - * @tc.desc Test stencilMaskSeparate. - */ - it('testStencilMaskSeparateError', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilMaskSeparate test start ...' + JSON.stringify(gl)); - const stencilMaskSeparateParameter = gl.stencilMaskSeparate(gl.FRONT); - console.info("stencilMaskSeparate stencilMaskSeparateParameter: " + - stencilMaskSeparateParameter); - expect(stencilMaskSeparateParameter).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0573 - * @tc.name testStencilOpError - * @tc.desc Test stencilOp. - */ - it('testStencilOpError', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilOp test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - const stencilOpParameter = gl.stencilOp(); - console.info("stencilOp stencilOpParameter: " + stencilOpParameter); - expect(stencilOpParameter).assertEqual(undefined); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0574 - * @tc.name testStencilOpSeparate - * @tc.desc Test stencilOpSeparate. - */ - it('testStencilOpSeparateError', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilOpSeparate test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - const stencilOpSeparateParameter = gl.stencilOpSeparate(gl.FRONT, gl.INCR, gl.DECR, gl - .INVERT); - console.info("stencilOpSeparate stencilOpSeparateParameter: " + stencilOpSeparateParameter); - expect(stencilOpSeparateParameter).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0575 - * @tc.name testTexParameterfError - * @tc.desc Test texParameterf. - */ - it('testTexParameterfError', 0, async function(done) { - //initContext(); - console.info('jsWebGL texParameterf test start ...' + JSON.stringify(gl)); - const texParameterValue = gl.texParameterf(); - console.info('texParameterValue' + texParameterValue); - expect(texParameterValue).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0576 - * @tc.name testTexParameteriError - * @tc.desc Test texParameteri. - */ - it('testTexParameteriError', 0, async function(done) { - //initContext(); - console.info('jsWebGL texParameteri test start ...' + JSON.stringify(gl)); - const texParameterValue = gl.texParameteri(); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(undefined); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0577 - * @tc.name testGetUniformBlockIndexError - * @tc.desc Test getUniformBlockIndex. - */ - it('testGetUniformBlockIndexError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 getUniformBlockIndex test start ...' + JSON.stringify(gl2)); - const program = gl.createProgram(); - const blockIndex = gl2.getUniformBlockIndex(program); - gl2.uniformBlockBinding(program, blockIndex, 1); - console.info("uniformBlockBinding blockIndex: " + blockIndex); - expect(blockIndex).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0578 - * @tc.name testGetActiveUniformBlockParameterError - * @tc.desc Test getActiveUniformBlockParameter. - */ - it('testGetActiveUniformBlockParameterError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( - gl2)); - const program = globalFunction(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - const int32Array = new Int32Array([1, 2]); - gl2.uniform1iv(uniformLocation, int32Array); - const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); - gl2.uniformBlockBinding(program, blockIndex, 1); - const blockSize = gl2.getActiveUniformBlockParameter(); - console.info("getActiveUniformBlockParameter blockSize" + blockSize); - expect(blockSize).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0579 - * @tc.name testGetActiveUniformBlockNameError - * @tc.desc Test getActiveUniformBlockName. - */ - it('testGetActiveUniformBlockNameError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 getActiveUniformBlockName test start ...' + JSON.stringify(gl2)); - const program = gl.createProgram(); - const blockIndex = gl2.getUniformBlockIndex(program, 'UBOData'); - console.info("getActiveUniformBlockName blockIndex" + blockIndex); - - gl2.uniformBlockBinding(program, blockIndex, 1); - const blockName = gl2.getActiveUniformBlockName(program); - console.info("blockName" + blockName); - expect(blockName).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0580 - * @tc.name testUniformBlockBindingError - * @tc.desc Test uniformBlockBinding. - */ - it('testUniformBlockBindingError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 uniformBlockBinding test start ...' + JSON.stringify(gl2)); - const program = gl.createProgram(); - const blockIndex = gl2.getUniformBlockIndex(program); - gl2.uniformBlockBinding(program, blockIndex, 1); - const blockName = gl2.getActiveUniformBlockName(program); - console.info("blockName" + blockName); - - expect(blockName).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0581 - * @tc.name testCreateVertexArrayError - * @tc.desc Test createVertexArray. - */ - it('testCreateVertexArrayError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 createVertexArray test start ...' + JSON.stringify(gl2)); - const vao = gl2.createVertexArray(); - const isVertexArray1 = gl2.isVertexArray(vao); - console.info("isVertexArray1" + isVertexArray1); - const isVertexArray = gl2.isVertexArray(vao); - console.info("isVertexArray" + isVertexArray); - expect(isVertexArray).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0582 - * @tc.name testBindVertexArray - * @tc.desc Test bindVertexArray. - */ - it('testBindVertexArrayError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bindVertexArray test start ...' + JSON.stringify(gl2)); - const vao = gl2.createVertexArray(); - const isVertexArray1 = gl2.isVertexArray(vao); - console.info("isVertexArray1" + isVertexArray1); - gl2.bindVertexArray(); - const isVertexArray = gl2.isVertexArray(vao); - console.info("isVertexArray" + isVertexArray); - expect(isVertexArray).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0583 - * @tc.name testDeleteVertexArray - * @tc.desc Test deleteVertexArray. - */ - it('testDeleteVertexArrayError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 deleteVertexArray test start ...' + JSON.stringify(gl2)); - const vao = gl2.createVertexArray(); - gl2.bindVertexArray(vao); - const isVertexArray1 = gl2.isVertexArray(vao); - console.info("isVertexArray1" + isVertexArray1); - gl2.deleteVertexArray(vao); - const isVertexArray = gl2.isVertexArray(vao); - console.info("isVertexArray" + isVertexArray); - expect(isVertexArray).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0584 - * @tc.name testIsVertexArrayError - * @tc.desc Test bindVertexArray. - */ - it('testIsVertexArray', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 isVertexArray test start ...' + JSON.stringify(gl2)); - const vao = gl2.createVertexArray(); - const isVertexArray1 = gl2.isVertexArray(vao); - console.info("isVertexArray1" + isVertexArray1); - gl2.bindVertexArray(vao); - const isVertexArray = gl2.isVertexArray(vao); - console.info("isVertexArray" + isVertexArray); - expect(isVertexArray).assertEqual(true); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0585 - * @tc.name testIsVertexArrayError - * @tc.desc Test bindVertexArray. - */ - it('testIsVertexArrayError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 isVertexArray test start ...' + JSON.stringify(gl2)); - const vao = gl2.createVertexArray(); - const isVertexArray1 = gl2.isVertexArray(vao); - console.info("isVertexArray1" + isVertexArray1); - gl2.bindVertexArray(); - const isVertexArray = gl2.isVertexArray(); - console.info("isVertexArray" + isVertexArray); - expect(isVertexArray).assertEqual(false); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0586 - * @tc.name testTexImage2DError - * @tc.desc Test texImage2D. - */ - it('testTexImage2DError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - gl2.texImage2D(-gl.TEXTURE_2D, -0, -32, -512, -512, -0, -32, -32, -new ArrayBuffer(8)); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(1281); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0587 - * @tc.name testTexSubImage2DError - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2DError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); - gl2.texSubImage2D(-gl.TEXTURE_2D, -0, -0, -0, -512, -512, -gl.RED, gl.FLOAT, - - new ArrayBuffer(16), -0); - const errorCode = gl.getError(); - console.info("webgl2test texSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(1280); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0588 - * @tc.name testCompressedTexImage2DError - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2DError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 compressedTexImage2D test start ...' + JSON.stringify(gl2)); - gl2.compressedTexImage2D(-gl.TEXTURE_2D, -0, -0x83F3, -512, -512, -0, -gl - .PIXEL_UNPACK_BUFFER, -0); - const errorCode = gl.getError(); - console.info("webgl2test compressedTexImage2D getError: " + errorCode); - expect(errorCode).assertEqual(1280); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0589 - * @tc.name testCompressedTexSubImage2DError - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2DError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 compressedTexSubImage2D test start ...' + JSON.stringify(gl2)); - gl2.compressedTexSubImage2D(-gl.TEXTURE_2D, -0, -256, -256, -512, -512, -0x83F3, -gl - .PIXEL_UNPACK_BUFFER, 0); - const errorCode = gl.getError(); - console.info("webgl2test compressedTexSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(1281); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0590 - * @tc.name testBufferSubDataError - * @tc.desc Test bufferData. - */ - it('testBufferSubDataError', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - gl2.bufferSubData(-gl.COPY_READ_BUFFER, -512, -new ArrayBuffer(8)); - const errorCode = gl.getError(); - console.info("webgl2test bufferSubData getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0591 - * @tc.name webgl_test_getContextAttributes2 - * @tc.desc Test getContextAttributes. - */ - it('webgl_test_getContextAttributes2', 0, async function(done) { - //initContext(); - console.info("webgltest into getContextAttributes"); - const getContextAttributesValue = gl.getContextAttributes("error"); - console.info("webgltest getContextAttributes: " + getContextAttributesValue); - expect(getContextAttributesValue).assertEqual(null); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0592 - * @tc.name webgl_test_isContextLost2 - * @tc.desc Test isContextLost. - */ - it('webgl_test_isContextLost2', 0, async function(done) { - //initContext(); - console.info("webgltest into isContextLost"); - const isContextLostValue = gl.isContextLost("error"); - console.info("webgltest isContextLost: " + isContextLostValue); - expect(isContextLostValue).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0593 - * @tc.name webgl_test_getSupportedExtensions2 - * @tc.desc Test getSupportedExtensions. - */ - it('webgl_test_getSupportedExtensions2', 0, async function(done) { - //initContext(); - console.info("webgltest into getSupportedExtensions"); - const getSupportedExtensionsValue = gl.getSupportedExtensions("error"); - console.info("webgltest getSupportedExtensions: " + getSupportedExtensionsValue); - expect(typeof(getSupportedExtensionsValue)).assertEqual('object'); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0595 - * @tc.name webgl_test_getExtension2 - * @tc.desc Test getExtension. - */ - it('webgl_test_getExtension2', 0, async function(done) { - //initContext(); - console.info("webgltest into getExtension"); - const getExtensionValue = gl.getExtension("error"); - console.info("webgltest getExtension: " + getExtensionValue); - expect(getExtensionValue).assertEqual(undefined); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0596 - * @tc.name webgl_test_activeTexture2 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture2', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE8B4C); - 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_0597 - * @tc.name webgl_test_activeTexture_12 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture_12', 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_0598 - * @tc.name webgl_test_attachShader2 - * @tc.desc Test attachShader. - */ - it('webgl_test_attachShader2', 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.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0599 - * @tc.name webgl_test_bindAttribLocation2 - * @tc.desc Test bindAttribLocation. - */ - it('webgl_test_bindAttribLocation2', 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, 'V_color'); - - 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_0600 - * @tc.name webgl_test_bindBuffer2 - * @tc.desc Test bindBuffer. - */ - it('webgl_test_bindBuffer2', 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(); - }); -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test07.js b/graphic/webGL/src/main/js/default/test/WebGL.test07.js deleted file mode 100644 index 43084077f9550069b4b06d20f9743605444a19c4..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test07.js +++ /dev/null @@ -1,2160 +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_webgl7', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_0601 - * @tc.name webgl_test_bindBuffer_12 - * @tc.desc Test bindBuffer. - */ - it('webgl_test_bindBuffer_12', 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(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0602 - * @tc.name webgl_test_bindFramebuffer2 - * @tc.desc Test bindFramebuffer. - */ - it('webgl_test_bindFramebuffer2', 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 --> isFramebuffer_2: " + - isFrameBuffer2); - expect(isFrameBuffer2).assertEqual(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0603 - * @tc.name webgl_test_bindRenderbuffer2 - * @tc.desc Test bindRenderbuffer. - */ - it('webgl_test_bindRenderbuffer2', 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(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0604 - * @tc.name webgl_test_bindTexture2 - * @tc.desc Test bindTexture. - */ - it('webgl_test_bindTexture2', 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(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0605 - * @tc.name webgl_test_blendColor2 - * @tc.desc Test blendColor. - */ - it('webgl_test_blendColor2', 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_0606 - * @tc.name webgl_test_blendColor_12 - * @tc.desc Test blendColor. - */ - it('webgl_test_blendColor_12', 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_0607 - * @tc.name webgl_test_blendEquation2 - * @tc.desc Test blendEquation. - */ - it('webgl_test_blendEquation2', 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_0608 - * @tc.name webgl_test_blendEquation_12 - * @tc.desc Test blendEquation. - */ - it('webgl_test_blendEquation_12', 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(gl.FUNC_ADD); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0609 - * @tc.name webgl_test_blendEquationSeparate2 - * @tc.desc Test blendEquationSeparate. - */ - it('webgl_test_blendEquationSeparate2', 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_0613 - * @tc.name webgl_test_clear2 - * @tc.desc Test clear. - */ - it('webgl_test_clear2', 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_0614 - * @tc.name webgl_test_clearColor2 - * @tc.desc Test clearColor. - */ - it('webgl_test_clearColor2', 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_0615 - * @tc.name webgl_test_clearDepth2 - * @tc.desc Test clearDepth. - */ - it('webgl_test_clearDepth2', 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); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0616 - * @tc.name webgl_test_clearDepth_22 - * @tc.desc Test clearDepth. - */ - it('webgl_test_clearDepth_22', 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(0); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0617 - * @tc.name webgl_test_clearStencil2 - * @tc.desc Test clearStencil. - */ - it('webgl_test_clearStencil2', 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_0618 - * @tc.name webgl_test_clearStencil_12 - * @tc.desc Test clearStencil. - */ - it('webgl_test_clearStencil_12', 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_0620 - * @tc.name webgl_test_colorMask_12 - * @tc.desc Test colorMask. - */ - it('webgl_test_colorMask_12', 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_0622 - * @tc.name webgl_test_createProgram2 - * @tc.desc Test createProgram. - */ - it('webgl_test_createProgram2', 0, async function(done) { - //initContext(); - console.info("webgltest into createProgram"); - const program = gl.createProgram("error"); - const isProgram = gl.isProgram(program); - console.info("webgltest createProgram isProgram: " + isProgram); - expect(isProgram).assertEqual(true); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0623 - * @tc.name webgl_test_createShader2 - * @tc.desc Test createShader. - */ - it('webgl_test_createShader2', 0, async function(done) { - //initContext(); - console.info("webgltest into createShader"); - - const shader = gl.createShader('VERTEX_SHADER'); - const isShader = gl.isShader(shader); - console.info("webgltest createShader isShader: " + isShader); - expect(isShader).assertEqual(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0624 - * @tc.name webgl_test_deleteFramebuffer2 - * @tc.desc Test deleteFramebuffer. - */ - it('webgl_test_deleteFramebuffer2', 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(); - - const isFramebuffer2 = gl.isFramebuffer(framebuffer); - console.info("webgltest createFramebuffer bindFramebuffer isFramebuffer2: " + - isFramebuffer2); - expect(isFramebuffer2).assertEqual(true); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0625 - * @tc.name webgl_test_deleteRenderbuffer2 - * @tc.desc Test deleteRenderbuffer. - */ - it('webgl_test_deleteRenderbuffer2', 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(); - - const isRenderbuffer2 = gl.isRenderbuffer(renderbuffer); - console.info( - "webgltest createRenderbuffer bindRenderbuffer deleteRenderbuffer isRenderbuffer2: " + - isRenderbuffer2); - expect(isRenderbuffer2).assertEqual(true); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0628 - * @tc.name webgl_test_enableVertexAttribArray2 - * @tc.desc Test enableVertexAttribArray. - */ - it('webgl_test_enableVertexAttribArray2', 0, async function(done) { - //initContext(); - console.info("webgltest into enableVertexAttribArray"); - //顶点着色器程序 - 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); - - const aVertexPosition = gl.getAttribLocation(programObj, "a_Position"); - - gl.enableVertexAttribArray(aVertexPosition); - gl.vertexAttribPointer(aVertexPosition, 4, gl.FLOAT, false, 0, 0); - - gl.drawArrays(gl.TRIANGLES, 0, 3); - - - let errorCode = gl.getError(); - console.info("webgltest enableVertexAttribArray getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0629 - * @tc.name webgl_test_finish2 - * @tc.desc Test finish. - */ - it('webgl_test_finish2', 0, async function(done) { - //initContext(); - console.info("webgltest into finish"); - gl.finish(); - let errorCode = gl.getError(); - console.info("webgltest finish getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0630 - * @tc.name webgl_test_flush2 - * @tc.desc Test flush. - */ - it('webgl_test_flush2', 0, async function(done) { - //initContext(); - console.info("webgltest into flush"); - gl.flush("error"); - let errorCode = gl.getError(); - console.info("webgltest flush getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0637 - * @tc.name webgl_test_createSampler2 - * @tc.desc Test createSampler. - */ - it('webgl_test_createSampler2', 0, async function(done) { - //initContext(); - console.info("webgltest into createSampler"); - const sampler = gl2.createSampler('error'); - const isSampler1 = gl2.isSampler(sampler); - console.info("webgltest createSampler isSampler1: " + isSampler1); - expect(isSampler1).assertEqual(true); - - gl2.bindSampler(0, sampler); - const isSampler2 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); - expect(isSampler2).assertEqual(true); - - gl2.deleteSampler(sampler); - const isSampler3 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); - expect(isSampler3).assertEqual(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0638 - * @tc.name webgl_test_deleteSampler2 - * @tc.desc Test deleteSampler. - */ - it('webgl_test_deleteSampler2', 0, async function(done) { - //initContext(); - console.info("webgltest into deleteSampler"); - const sampler = gl2.createSampler(); - const isSampler1 = gl2.isSampler(sampler); - console.info("webgltest createSampler isSampler1: " + isSampler1); - expect(isSampler1).assertEqual(true); - - gl2.bindSampler(0, sampler); - const isSampler2 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); - expect(isSampler2).assertEqual(true); - - gl2.deleteSampler('sampler'); - const isSampler3 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); - expect(isSampler3).assertEqual(true); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0639 - * @tc.name webgl_test_bindSampler2 - * @tc.desc Test bindSampler. - */ - it('webgl_test_bindSampler2', 0, async function(done) { - //initContext(); - console.info("webgltest into bindSampler"); - const sampler = gl2.createSampler(); - const isSampler1 = gl2.isSampler(sampler); - console.info("webgltest createSampler isSampler1: " + isSampler1); - expect(isSampler1).assertEqual(true); - - gl2.bindSampler(0, 'sampler'); - const isSampler2 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); - expect(isSampler2).assertEqual(true); - - gl2.deleteSampler(sampler); - const isSampler3 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); - expect(isSampler3).assertEqual(false); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0641 - * @tc.name webgl_test_samplerParameterf2 - * @tc.desc Test samplerParameterf. - */ - it('webgl_test_samplerParameterf2', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameterf"); - - let sampler = gl2.createSampler(); - // gl2.bindSampler(0, sampler); - gl2.samplerParameterf(sampler, gl.TEXTURE_MAG_FILTER); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameterf getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0642 - * @tc.name webgl_test_getSamplerParameter_12 - * @tc.desc Test getSamplerParameter. - */ - it('webgl_test_getSamplerParameter_12', 0, async function(done) { - //initContext(); - console.info("webgltest into getSamplerParameter"); - - let sampler = gl2.createSampler(); - - const samplerParameter = gl2.getSamplerParameter(sampler, '0x884D'); - - console.info("webgltest createSampler getSamplerParameter_1: " + samplerParameter); - expect(samplerParameter).assertEqual(undefined); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0643 - * @tc.name webgl_test_fenceSync2 - * @tc.desc Test fenceSync. - */ - it('webgl_test_fenceSync2', 0, async function(done) { - //initContext(); - console.info("webgltest into fenceSync"); - - let sync = gl2.fenceSync('0x9117', 0); - let status = gl2.clientWaitSync(sync, 0, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(false); - - gl2.deleteSync(sync); - - const isSync2 = gl2.isSync(sync); - console.info("webgltest fenceSync deleteSync isSync2: " + isSync2); - expect(isSync2).assertEqual(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0644 - * @tc.name webgl_test_isSync2 - * @tc.desc Test isSync. - */ - it('webgl_test_isSync2', 0, async function(done) { - //initContext(); - console.info("webgltest into isSync"); - let sync = gl2.fenceSync(0x9117, 0); - let status = gl2.clientWaitSync(sync, 0, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(true); - - gl2.deleteSync(sync); - - const isSync2 = gl2.isSync('sync'); - console.info("webgltest fenceSync deleteSync isSync2: " + isSync2); - expect(isSync2).assertEqual(false); - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0645 - * @tc.name webgl_test_deleteSync2 - * @tc.desc Test deleteSync. - */ - it('webgl_test_deleteSync2', 0, async function(done) { - //initContext(); - console.info("webgltest into deleteSync"); - let sync = gl2.fenceSync(0x9117, 0); - let status = gl2.clientWaitSync(sync, 0, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(true); - - gl2.deleteSync('sync'); - - const isSync2 = gl2.isSync(sync); - console.info("webgltest fenceSync deleteSync isSync2: " + isSync2); - expect(isSync2).assertEqual(true); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0646 - * @tc.name webgl_test_clientWaitSync2 - * @tc.desc Test clientWaitSync. - */ - it('webgl_test_clientWaitSync2', 0, async function(done) { - //initContext(); - console.info("webgltest into clientWaitSync"); - let sync = gl2.fenceSync(0x9117, 0); - let status = gl2.clientWaitSync('sync', 0, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(true); - - console.info("webgltest fenceSync clientWaitSync: " + status); - - expect(status).assertEqual(0); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0647 - * @tc.name webgl_test_waitSync2 - * @tc.desc Test waitSync. - */ - it('webgl_test_waitSync2', 0, async function(done) { - //initContext(); - console.info("webgltest into waitSync"); - - let sync = gl2.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0); - gl2.waitSync('sync', 0, gl.TIMEOUT_IGNORED); - - let errorCode = gl.getError(); - console.info("webgltest framebufferTexture2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0648 - * @tc.name webgl_test_createTransformFeedback2 - * @tc.desc Test createTransformFeedback. - */ - it('webgl_test_createTransformFeedback2', 0, async function(done) { - //initContext(); - console.info("webgltest into createTransformFeedback"); - - const transformFeedback = gl2.createTransformFeedback(); - - - console.info("webgltest into createTransformFeedback: " + transformFeedback) - - gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); - - gl2.beginTransformFeedback(gl2.TRIANGLES); - - const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); - - console.info("BindTransformFeedback : " + isTransformFeedback2); - expect(isTransformFeedback2).assertEqual(true); - - gl2.deleteTransformFeedback(transformFeedback); - const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); - console.info("webgltest createTransformFeedback bindTransformFeedback " + - "deleteTransformFeedback isTransformFeedback3: " + isTransformFeedback3); - expect(isTransformFeedback3).assertEqual(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0649 - * @tc.name webgl_test_isTransformFeedback2 - * @tc.desc Test isTransformFeedback. - */ - it('webgl_test_isTransformFeedback2', 0, async function(done) { - //initContext(); - console.info("webgltest into isTransformFeedback"); - let transformFeedback = gl2.createTransformFeedback(); - const isTransformFeedback1 = gl2.isTransformFeedback(transformFeedback); - console.info("webgltest createTransformFeedback isTransformFeedback1: " + - isTransformFeedback1); - expect(isTransformFeedback1).assertEqual(false); - - gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); - - const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); - console.info( - "webgltest createTransformFeedback bindTransformFeedback isTransformFeedback2: " + - isTransformFeedback2); - expect(isTransformFeedback2).assertEqual(true); - - gl2.deleteTransformFeedback(transformFeedback); - const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); - console.info("webgltest createTransformFeedback bindTransformFeedback " + - "deleteTransformFeedback isTransformFeedback3: " + isTransformFeedback3); - expect(isTransformFeedback3).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0650 - * @tc.name webgl_test_bindTransformFeedback2 - * @tc.desc Test bindTransformFeedback. - */ - it('webgl_test_bindTransformFeedback2', 0, async function(done) { - //initContext(); - console.info("webgltest into bindTransformFeedback"); - let transformFeedback = gl2.createTransformFeedback(); - const isTransformFeedback1 = gl2.isTransformFeedback(transformFeedback); - console.info("webgltest createTransformFeedback isTransformFeedback1: " + - isTransformFeedback1); - expect(isTransformFeedback1).assertEqual(false); - - gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); - - const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); - console.info("webgltest createTransformFeedback bindTransformFeedback " + - "isTransformFeedback2: " + isTransformFeedback2); - expect(isTransformFeedback2).assertEqual(true); - - gl2.deleteTransformFeedback(transformFeedback); - const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); - console.info("webgltest createTransformFeedback bindTransformFeedback " + - "deleteTransformFeedback isTransformFeedback3: " + isTransformFeedback3); - expect(isTransformFeedback3).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0651 - * @tc.name webgl_test_beginTransformFeedback2 - * @tc.desc Test beginTransformFeedback. - */ - it('webgl_test_beginTransformFeedback2', 0, async function(done) { - //initContext(); - console.info("webgltest into beginTransformFeedback"); - - let transformFeedback = gl2.createTransformFeedback(); - - gl2.beginTransformFeedback('TRIANGLES'); - - let errorCode = gl.getError(); - console.info("webgltest framebufferTexture2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0653 - * @tc.name webgl_test_deleteTransformFeedback2 - * @tc.desc Test deleteTransformFeedback. - */ - it('webgl_test_deleteTransformFeedback2', 0, async function(done) { - //initContext(); - console.info("webgltest into deleteTransformFeedback"); - const transformFeedback = gl2.createTransformFeedback(); - - gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); - - const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); - console.info("webgltest createTransformFeedback bindTransformFeedback " + - "isTransformFeedback2: " + isTransformFeedback2); - expect(isTransformFeedback2).assertEqual(true); - - gl2.deleteTransformFeedback('transformFeedback'); - const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); - console.info( - "webgltest createTransformFeedback bindTransformFeedback deleteTransformFeedback " + - "isTransformFeedback3: " + isTransformFeedback3); - expect(isTransformFeedback3).assertEqual(true); - //deleteContext(); - done(); - }); - - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0654 - * @tc.name testUseProgramError - * @tc.desc Test useProgram. - */ - it('testUseProgramError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testUseProgram test start ...66'); - console.info('jsWebGL testUseProgram test start ...' + JSON.stringify(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 program = gl.createProgram(); - console.log("testUseProgram has failed for " + program) - const useProgramError1 = gl.getError(); - console.info("useProgramError: " + useProgramError1); - const renderBufferValue1 = gl.getParameter(gl.CURRENT_PROGRAM); - console.log("testUseProgram has failed for " + program) - gl.attachShader(program, vertexShader); - gl.attachShader(program, fragmentShader); - gl.linkProgram(program); - gl.useProgram(false); - const useProgramError = gl.getError(); - console.info("useProgramError: " + useProgramError); - expect(useProgramError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testUseProgram has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0655 - * @tc.name testValidateProgramError - * @tc.desc Test validateProgram. - */ - it('testValidateProgramError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testValidateProgram test start ...66'); - console.info('jsWebGL testValidateProgram test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - gl.validateProgram(false); - const validateProgramError = gl.getError(); - console.info("validateProgramError: " + validateProgramError); - expect(validateProgramError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testValidateProgram has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0656 - * @tc.name testVertexAttrib1fError - * @tc.desc Test vertexAttrib1f. - */ - it('testVertexAttrib1fError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib1f test start ...66'); - console.info('jsWebGL testVertexAttrib1f test start ...' + JSON.stringify(gl)); - gl.vertexAttrib1f(false, 10.0); - const vertexAttrib1fError = gl.getError(); - console.info("vertexAttrib1fError: " + vertexAttrib1fError); - expect(vertexAttrib1fError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib1f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0657 - * @tc.name testVertexAttrib2fError - * @tc.desc Test vertexAttrib2f. - */ - it('testVertexAttrib2fError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib2f test start ...66'); - gl.vertexAttrib2f(false, 10.0); - const vertexAttrib2fError = gl.getError(); - console.info("vertexAttrib2fError: " + vertexAttrib2fError); - expect(vertexAttrib2fError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib2f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0658 - * @tc.name testVertexAttrib3fError - * @tc.desc Test vertexAttrib3f. - */ - it('testVertexAttrib3fError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testvertexAttrib3f test start ...66'); - console.info('jsWebGL testvertexAttrib3f test start ...' + JSON.stringify(gl)); - gl.vertexAttrib3f(false, 10.0); - const vertexAttrib3fError = gl.getError(); - console.info("vertexAttrib3fError: " + vertexAttrib3fError); - expect(vertexAttrib3fError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib3f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0659 - * @tc.name testVertexAttrib4fError - * @tc.desc Test vertexAttrib4f. - */ - it('testVertexAttrib4fError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib4f test start ...66'); - console.info('jsWebGL testVertexAttrib4f test start ...' + JSON.stringify(gl)); - gl.vertexAttrib4f(false, 10.0); - const vertexAttrib4fError = gl.getError(); - console.info("vertexAttrib4fError: " + vertexAttrib4fError); - expect(vertexAttrib4fError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testvertexAttrib4f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0660 - * @tc.name testVertexAttrib1fvError - * @tc.desc Test vertexAttrib1fv. - */ - it('testVertexAttrib1fvError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib1fv test start ...66'); - console.info('jsWebGL testVertexAttrib1fv test start ...' + JSON.stringify(gl)); - const floatArray = new Float32Array([10.0, 5.0, 2.0]); - gl.vertexAttrib1fv(false, floatArray); - const vertexAttrib1fvError = gl.getError(); - console.info("vertexAttrib1fvError: " + vertexAttrib1fvError); - expect(vertexAttrib1fvError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib1fv has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0661 - * @tc.name testVertexAttrib2fvError - * @tc.desc Test vertexAttrib2fv. - */ - it('testVertexAttrib2fvError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib2fv test start ...66'); - console.info('jsWebGL testVertexAttrib2fv test start ...' + JSON.stringify(gl)); - const floatArray = new Float32Array([10.0, 5.0, 2.0]); - gl.vertexAttrib2fv(false, floatArray); - const vertexAttrib2fvError = gl.getError(); - console.info("vertexAttrib2fvError: " + vertexAttrib2fvError); - expect(vertexAttrib2fvError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib2fv has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0662 - * @tc.name testVertexAttrib3fvError - * @tc.desc Test vertexAttrib3fv. - */ - it('testVertexAttrib3fvError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib3fv test start ...66'); - console.info('jsWebGL testVertexAttrib3fv test start ...' + JSON.stringify(gl)); - const floatArray = new Float32Array([10.0, 5.0, 2.0]); - gl.vertexAttrib3fv(false, floatArray); - const vertexAttrib3fvError = gl.getError(); - console.info("vertexAttrib3fvError: " + vertexAttrib3fvError); - expect(vertexAttrib3fvError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib3fv has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0663 - * @tc.name testVertexAttrib4fvError - * @tc.desc Test vertexAttrib4fv. - */ - it('testVertexAttrib4fvError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib4fv test start ...66'); - console.info('jsWebGL testVertexAttrib4fv test start ...' + JSON.stringify(gl)); - const floatArray = new Float32Array([10.0, 5.0, 2.0]); - gl.vertexAttrib4fv(false, floatArray); - const vertexAttrib4fvError = gl.getError(); - console.info("vertexAttrib4fvError: " + vertexAttrib4fvError); - expect(vertexAttrib4fvError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib4fv has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0664 - * @tc.name testVertexAttribPointerError - * @tc.desc Test vertexAttribPointer. - */ - it('testVertexAttribPointerError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttribPointer test start ...66'); - console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); - gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 20, 0); - const vertexAttribPointerError = gl.getError(); - console.info("vertexAttribPointerError: " + vertexAttribPointerError); - expect(vertexAttribPointerError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttribPointer has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0665 - * @tc.name testViewportError - * @tc.desc Test viewport. - */ - it('testViewportError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testViewport test start ...66'); - console.info('jsWebGL testViewport test start ...' + JSON.stringify(gl)); - gl.viewport(false, 2, 3, 4); - const viewportError = gl.getError(); - console.info("viewportError: " + viewportError); - expect(viewportError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testViewport has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0666 - * @tc.name testTexStorage3DError - * @tc.desc Test texStorage3D. - */ - it('testTexStorage3DError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexStorage3D test start ...66'); - console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); - gl2.texStorage3D(gl.TEXTURE_3D, false, gl.RGB8, 256, 256, 256); - const texStorage3DError = gl.getError(); - console.info("texStorage3DError: " + texStorage3DError); - expect(texStorage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexStorage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0667 - * @tc.name testTexImage3DError - * @tc.desc Test texImage3D. - */ - it('testTexImage3DError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D test start ...66'); - console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); - gl2.texImage3D(gl2.TEXTURE_3D, false, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, - 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0668 - * @tc.name testTexImage3D_01Error - * @tc.desc Test texImage3D. - */ - it('testTexImage3D_01Error', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D_01Error test start ...66'); - console.info('jsWebGL testTexImage3D_01Error test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - gl2.texImage3D(gl2.TEXTURE_3D, false, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, - buffer); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D_01 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0669 - * @tc.name testTexImage3D_02Error - * @tc.desc Test texImage3D. - */ - it('testTexImage3D_02Error', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D_02Error test start ...66'); - console.info('jsWebGL testTexImage3D_02Error test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - gl2.texImage3D(gl2.TEXTURE_3D, false, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, - buffer, 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D_02 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0670 - * @tc.name testTexSubImage3D_01Error - * @tc.desc Test texSubImage3D. - */ - it('testTexSubImage3D_01Error', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexSubImage3D_01Error test start ...66'); - console.info('jsWebGL testTexSubImage3D_01Error test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(16); - const view = new DataView(buffer, 12, 4); - gl2.texSubImage3D(gl.TEXTURE_3D, false, 0, 0, 0, 200, 200, 1, gl.RGBA, gl.UNSIGNED_BYTE, - buffer, 0); - const texSubImage3DError = gl.getError(); - console.info("texSubImage3DError: " + texSubImage3DError); - expect(texSubImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexSubImage3D_01 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0671 - * @tc.name testTexSubImage3DError - * @tc.desc Test texSubImage3D. - */ - it('testTexSubImage3DError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexSubImage3DError test start ...66'); - console.info('jsWebGL testTexSubImage3DError test start ...' + JSON.stringify(gl)); - gl2.texSubImage3D(gl.TEXTURE_3D, false, 0, 0, 0, 200, 200, 1, gl.RGBA, gl.UNSIGNED_BYTE, - 1); - const texSubImage3DError = gl.getError(); - console.info("texSubImage3DError: " + texSubImage3DError); - expect(texSubImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexSubImage3DError has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0672 - * @tc.name testCopyTexSubImage3DError - * @tc.desc Test copyTexSubImage3D. - */ - it('testCopyTexSubImage3DError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCopyTexSubImage3DError test start ...66'); - console.info('jsWebGL testCopyTexSubImage3DError test start ...' + JSON.stringify(gl)); - gl2.copyTexSubImage3D(gl.TEXTURE_3D, false, 0, 0, 0, 0, 0, 16, 16); - const copyTexSubImage3DError = gl.getError(); - console.info("copyTexSubImage3DError: " + copyTexSubImage3DError); - expect(copyTexSubImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCopyTexSubImage3DError has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0673 - * @tc.name testCompressedTexImage3D_01Error - * @tc.desc Test compressedTexImage3D. - */ - it('testCompressedTexImage3D_01Error', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexImage3D_01Error test start ...66'); - console.info('jsWebGL testCompressedTexImage3D_01Error test start ...' + JSON.stringify( - gl)); - gl2.compressedTexImage3D(gl.TEXTURE_3D, false, 0x83F0, 512, 512, 512, 0, gl2 - .PIXEL_UNPACK_BUFFER, 0); - const compressedTexImage3DError = gl.getError(); - console.info("compressedTexImage3DError: " + compressedTexImage3DError); - expect(compressedTexImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexImage3D_01Error has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0674 - * @tc.name testCompressedTexImage3D_02Error - * @tc.desc Test compressedTexImage3D. - */ - it('testCompressedTexImage3D_02Error', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexImage3D_02Error test start ...66'); - console.info('jsWebGL testCompressedTexImage3D_02Error test start ...' + JSON.stringify( - gl)); - const buffer = new ArrayBuffer(8); - gl2.compressedTexImage3D(gl.TEXTURE_3D, false, 0x83F0, 512, 512, 512, 0, buffer, 0, 0); - const compressedTexImage3DError = gl.getError(); - console.info("compressedTexImage3DError: " + compressedTexImage3DError); - expect(compressedTexImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexImage3D_02Error has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0675 - * @tc.name testCompressedTexSubImage3DError - * @tc.desc Test compressedTexSubImage3D. - */ - it('testCompressedTexSubImage3DError', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexSubImage3DError test start ...66'); - console.info('jsWebGL testCompressedTexSubImage3DError test start ...' + JSON.stringify( - gl)); - gl2.compressedTexSubImage3D(gl.TEXTURE_3D, false, 0, 0, 0, 512, 512, 512, gl2 - .COMPRESSED_R11_EAC, - gl2.PIXEL_UNPACK_BUFFER, 0); - const compressedTexSubImage3DError = gl.getError(); - console.info("compressedTexSubImage3DError: " + compressedTexSubImage3DError); - expect(compressedTexSubImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexSubImage3DError has failed for " + e) - expect(null).assertFail() - } - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0676 - * @tc.name testCompressedTexSubImage3D_01Error - * @tc.desc Test compressedTexSubImage3D. - */ - it('testCompressedTexSubImage3D_01Error', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexSubImage3D_01Error test start ...66'); - console.info('jsWebGL testCompressedTexSubImage3D_01Error test start ...' + JSON - .stringify(gl)); - const buffer = new ArrayBuffer(8); - gl2.compressedTexSubImage3D(gl.TEXTURE_3D, false, 0, 0, 0, 512, 512, 512, gl2 - .COMPRESSED_R11_EAC, - buffer, 0, 256); - const compressedTexSubImage3DError = gl.getError(); - console.info("testCompressedTexSubImage3D_01Error: " + compressedTexSubImage3DError); - expect(compressedTexSubImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexSubImage3D_01Error has failed for " + e) - expect(null).assertFail() - } - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0677 - * @tc.name webgl_test_getFragDataLocationError - * @tc.desc Test getFragDataLocation. - */ - it('webgl_test_getFragDataLocationError', 0, async function(done) { - //initContext(); - console.info("webgltest into getFragDataLocation"); - - //顶点着色器程序 - 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); - - gl2.getFragDataLocation(programObj, false); - - let errorCode = gl.getError(); - console.info("webgltest webgl_test_getFragDataLocationError getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0678 - * @tc.name webgl_test_vertexAttribI4uiError - * @tc.desc Test vertexAttribI4ui. - */ - it('webgl_test_vertexAttribI4uiError', 0, async function(done) { - //initContext(); - console.info("webgltest into vertexAttribI4ui"); - - const a = gl2.vertexAttribI4ui(false, 10, 11, 12, 13); - - let errorCode = gl.getError(); - console.info("webgltest vertexAttribI4ui getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0679 - * @tc.name webgl_test_vertexAttribIPointerError - * @tc.desc Test vertexAttribIPointer. - */ - it('webgl_test_vertexAttribIPointerError', 0, async function(done) { - //initContext(); - console.info("webgltest into vertexAttribIPointer"); - - const a = gl2.vertexAttribIPointer(false, 4, gl.UNSIGNED_BYTE, 20, 16); - - let errorCode = gl.getError(); - console.info("webgltest vertexAttribIPointer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0680 - * @tc.name webgl_test_drawArraysInstancedError - * @tc.desc Test drawArraysInstanced. - */ - it('webgl_test_drawArraysInstancedError', 0, async function(done) { - //initContext(); - console.info("webgltest into drawArraysInstanced"); - - const a = gl2.drawArraysInstanced(gl.POINTS, false, 8, 4); - - let errorCode = gl.getError(); - console.info("webgltest drawArraysInstanced getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0681 - * @tc.name webgl_test_drawElementsInstancedError - * @tc.desc Test drawElementsInstanced. - */ - it('webgl_test_drawElementsInstancedError', 0, async function(done) { - //initContext(); - console.info("webgltest into drawElementsInstanced"); - - const a = gl2.drawElementsInstanced(gl.POINTS, false, gl.UNSIGNED_SHORT, 0, 4); - - let errorCode = gl.getError(); - console.info("webgltest drawElementsInstanced getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0682 - * @tc.name webgl_test_drawRangeElementsError - * @tc.desc Test drawRangeElements. - */ - it('webgl_test_drawRangeElementsError', 0, async function(done) { - //initContext(); - console.info("webgltest into drawRangeElements"); - - const a = gl2.drawRangeElements(gl.POINTS, false, 7, 8, gl.UNSIGNED_BYTE, 0); - - let errorCode = gl.getError(); - console.info("webgltest drawRangeElements getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0683 - * @tc.name testCompressedTexImage2D_0415 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D_0415', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexImage2D_0415 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - var texture = gl.createTexture(); - gl.bindTexture(texture, texture); - gl.compressedTexImage2D(-texture, -8, -"abc", -8, -512, -8, view); - const compressedTexImage2DError = gl.getError(); - console.info("compressedTexImage2DError: " + compressedTexImage2DError); - expect(compressedTexImage2DError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0684 - * @tc.name testCompressedTexImage2D_0416 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D_0416', 0, async function(done) { - //initContext(); - console.info('jsWebGL GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0415_02 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - var texture = gl.createTexture(); - gl.bindTexture(texture, texture); - gl.compressedTexImage2D(-texture, -8, -texture, -8, -512, -8, view); - const compressedTexImage2DError = gl.getError(); - console.info("compressedTexImage2DError: " + compressedTexImage2DError); - expect(compressedTexImage2DError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0685 - * @tc.name testCompressedTexSubImage2D_0420 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D_0420', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexSubImage2D_0420 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, -0); - gl.compressedTexSubImage2D(-texture, -0, -256, -texture, -512, -0x83F3, -gl - .PIXEL_UNPACK_BUFFER, view); - const compressedTexSubImage2DError = gl.getError(); - console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); - expect(compressedTexSubImage2DError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0686 - * @tc.name testCompressedTexSubImage2D_0421 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D_0421', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexSubImage2D_0421 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, -0); - gl.compressedTexSubImage2D(-texture, -8, -256, -256, -512, -0x83F3, -gl.PIXEL_UNPACK_BUFFER, - view); - const compressedTexSubImage2DError = gl.getError(); - console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); - expect(compressedTexSubImage2DError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_687 - * @tc.name testReadPixels_422 - * @tc.desc Test readPixels. - */ - it('testReadPixels_422', 0, async function(done) { - //initContext(); - console.info('jsWebGL testReadPixels_422 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); - gl.readPixels(-0, 0, -1, -1, -1, gl.ONE_MINUS_SRC_ALPHA, view); - const readPixelsError = gl.getError(); - console.info("readPixelsError: " + readPixelsError); - expect(readPixelsError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0688 - * @tc.name testReadPixels_423 - * @tc.desc Test readPixels. - */ - it('testReadPixels_423', 0, async function(done) { - //initContext(); - console.info('jsWebGL testReadPixels_423 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); - gl.readPixels(0, 0, -1, -1, -1, gl.ONE_MINUS_SRC_ALPHA, view); - const readPixelsError = gl.getError(); - console.info("readPixelsError: " + readPixelsError); - expect(readPixelsError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0689 - * @tc.name testTexImage2D_0426 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_0426', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D_0426 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - gl.texImage2D(-gl.TEXTURE_2D, -0, -gl.RGB8, -512, -512, -0, -gl.RGB8, gl.UNSIGNED_BYTE, - view); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0690 - * @tc.name testTexImage2D_0427 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_0427', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D_0427 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - gl.texImage2D(-gl.TEXTURE_2D, -0, -gl.RGB8, -512, -512, -0, -gl.RGB8, gl.UNSIGNED_BYTE, - view); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0694 - * @tc.name testTexSubImage2D_01 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexSubImage2D test start ...66'); - console.info('jsWebGL testTexSubImage2D test start ...' + JSON.stringify(gl)); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, view); - const ttexSubImage2DError = gl.getError(); - console.info("ttexSubImage2DError: " + ttexSubImage2DError); - expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0695 - * @tc.name testTexSubImage2D_02 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexSubImage2D_02 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - gl.texSubImage2D(-gl.TEXTURE_2D, -gl.RED, 0, 0, -0, 512, -gl.RED, -gl.FLOAT, view); - const ttexSubImage2DError = gl.getError(); - console.info("ttexSubImage2DError: " + ttexSubImage2DError); - expect(ttexSubImage2DError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0699 - * @tc.name testBlitFramebuffer_01 - * @tc.desc Test blitFramebuffer. - */ - it('testBlitFramebuffer_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBlitFramebuffer_01 test start ...66'); - gl2.blitFramebuffer(-0, -0, -400, 1080, 0, -0, 400, 1080, -gl2.COLOR_BUFFER_BIT, -gl2 - .NEAREST); - const blitFramebufferError = gl.getError(); - console.info("blitFramebufferError: " + blitFramebufferError); - expect(blitFramebufferError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0700 - * @tc.name testBlitFramebuffer_02 - * @tc.desc Test blitFramebuffer. - */ - it('testBlitFramebuffer_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBlitFramebuffer_02 test start ...66'); - gl2.blitFramebuffer(-gl2.NEAREST, -0, -400, -gl2.NEAREST, -0, -0, 400, 1080, - -gl2.COLOR_BUFFER_BIT, -gl2.NEAREST); - const blitFramebufferError = gl.getError(); - console.info("blitFramebufferError: " + blitFramebufferError); - expect(blitFramebufferError).assertEqual(gl.INVALID_ENUM); - done(); - }) -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test08.js b/graphic/webGL/src/main/js/default/test/WebGL.test08.js deleted file mode 100644 index b6075162073328d91ef3dfdc2f413750c825bf08..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test08.js +++ /dev/null @@ -1,2413 +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_webgl8', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_0701 - * @tc.name testFramebufferTextureLayer_01 - * @tc.desc Test framebufferTextureLayer. - */ - it('testFramebufferTextureLayer_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testFramebufferTextureLayer_01 test start ...66'); - const shader = gl.createShader(gl.VERTEX_SHADER); - gl2.framebufferTextureLayer(-gl.FRAMEBUFFER, -gl.COLOR_ATTACHMENT0, shader, -0, -8) - const framebufferTextureLayerError = gl.getError(); - console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); - expect(framebufferTextureLayerError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0702 - * @tc.name testFramebufferTextureLayer_02 - * @tc.desc Test framebufferTextureLayer. - */ - it('testFramebufferTextureLayer_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testFramebufferTextureLayer_02 test start ...66'); - const texture = gl.createTexture(); - gl.bindTexture(gl2.TEXTURE_2D_ARRAY, texture); - gl2.texStorage3D(gl2.TEXTURE_2D_ARRAY, 1, gl2.RGBA8, 256, 256, 8); - gl.texParameteri(gl2.TEXTURE_CUBE_MAP, gl2.TEXTURE_MAG_FILTER, gl2.NEAREST); - const framebuffer = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - gl2.framebufferTextureLayer(gl.FRAMEBUFFER, gl2.COLOR_ATTACHMENT0, texture, 0, 8) - const framebufferTextureLayerError = gl.getError(); - console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); - expect(framebufferTextureLayerError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0703 - * @tc.name testInvalidateFramebuffer_01 - * @tc.desc Test invalidateFramebuffer. - */ - it('testInvalidateFramebuffer_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateFramebuffer_01 test start ...66'); - gl2.invalidateFramebuffer(-0, - [-0, -gl.COLOR_ATTACHMENT1]); - const invalidateFramebufferError = gl.getError(); - console.info("invalidateFramebufferError: " + invalidateFramebufferError); - expect(invalidateFramebufferError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0704 - * @tc.name testInvalidateFramebuffer_02 - * @tc.desc Test invalidateFramebuffer. - */ - it('testInvalidateFramebuffer_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateFramebuffer_02 test start ...66'); - gl2.invalidateFramebuffer(-gl.READ_FRAMEBUFFER, - [gl.COLOR_ATTACHMENT0, -gl.COLOR_ATTACHMENT1]); - const invalidateFramebufferError = gl.getError(); - console.info("invalidateFramebufferError: " + invalidateFramebufferError); - expect(invalidateFramebufferError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0705 - * @tc.name testInvalidateSubFramebuffer_01 - * @tc.desc Test invalidateSubFramebuffer. - */ - it('testInvalidateSubFramebuffer_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateSubFramebuffer_01 test start ...66'); - console.info('jsWebGL testInvalidateSubFramebuffer test start ...' + JSON.stringify(gl)); - gl2.invalidateSubFramebuffer(-gl.READ_FRAMEBUFFER, - [gl.COLOR_ATTACHMENT0, -gl.COLOR_ATTACHMENT1], - 0, 0, 256, 256); - const invalidateSubFramebufferError = gl.getError(); - console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); - expect(invalidateSubFramebufferError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0706 - * @tc.name testInvalidateSubFramebuffer_01 - * @tc.desc Test invalidateSubFramebuffer. - */ - it('testInvalidateSubFramebuffer_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateSubFramebuffer_02 test start ...66'); - console.info('jsWebGL testInvalidateSubFramebuffer test start ...' + JSON.stringify(gl)); - gl2.invalidateSubFramebuffer(-gl.READ_FRAMEBUFFER, - [-0, -gl.COLOR_ATTACHMENT1], - 0, -0, 256, -256); - const invalidateSubFramebufferError = gl.getError(); - console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); - expect(invalidateSubFramebufferError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0707 - * @tc.name testReadBuffer_01 - * @tc.desc Test readBuffer. - */ - it('testReadBuffer_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testReadBuffer_01 test start ...66'); - gl2.readBuffer(-gl.COLOR_ATTACHMENT0); - const readBufferError = gl.getError(); - console.info("readBufferError: " + readBufferError); - expect(readBufferError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0708 - * @tc.name testReadBuffer_02 - * @tc.desc Test readBuffer. - */ - it('testReadBuffer_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testReadBuffer_02 test start ...66'); - gl2.readBuffer(gl.INVALID_ENUM); - const readBufferError = gl.getError(); - console.info("readBufferError: " + readBufferError); - expect(readBufferError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0709 - * @tc.name testGetInternalformatParameter_02 - * @tc.desc Test getInternalformatParameter. - */ - it('testGetInternalformatParameter_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetInternalformatParameter_02 test start ...66'); - var samples = gl2.getInternalformatParameter(gl.RENDERBUFFER, gl2.RGBA8, gl.SAMPLES); - console.info("samples: " + samples); - const int32list = [-1, -1, -1]; - expect(samples.constructor == int32list.constructor).assertEqual(false); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0710 - * @tc.name testRenderbufferStorageMultisample_01 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); - gl2.renderbufferStorageMultisample(-gl.RENDERBUFFER, -4, -gl.RBGA4, -256, -256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0711 - * @tc.name testRenderbufferStorageMultisample_02 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); - gl2.renderbufferStorageMultisample(gl.ONE_MINUS_DST_COLOR, -0, -0, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0712 - * @tc.name testTexStorage2D_01 - * @tc.desc Test texStorage2D. - */ - it('testTexStorage2D_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexStorage2D_01 test start ...66'); - gl2.texStorage2D(-gl.TEXTURE_2D, -1, -gl.RGB8, -256, -256); - const texStorage2DError = gl.getError(); - console.info("texStorage2DError: " + texStorage2DError); - expect(texStorage2DError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0713 - * @tc.name testTexStorage2D_02 - * @tc.desc Test texStorage2D. - */ - it('testTexStorage2D_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexStorage2D_02 test start ...66'); - gl2.texStorage2D(-gl.SRC_ALPHA_SATURATE, -0, -gl.RGB8, 256, -256); - const texStorage2DError = gl.getError(); - console.info("texStorage2DError: " + texStorage2DError); - expect(texStorage2DError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0714 - * @tc.name testTransformFeedbackVaryings_01 - * @tc.desc Test transformFeedbackVaryings. - */ - it('testTransformFeedbackVaryings_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTransformFeedbackVaryings_01 test start ...66'); - const program = gl.createProgram(); - var transformFeedbackOutputs = ['-gl_Position', 'anotherOutput']; - gl2.transformFeedbackVaryings(program, transformFeedbackOutputs, -gl.INTERLEAVED_ATTRIBS); - const transformFeedbackVaryingsError = gl.getError(); - console.info("transformFeedbackVaryingsError: " + transformFeedbackVaryingsError); - expect(transformFeedbackVaryingsError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0715 - * @tc.name testTransformFeedbackVaryings_02 - * @tc.desc Test transformFeedbackVaryings. - */ - it('testTransformFeedbackVaryings_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTransformFeedbackVaryings_02 test start ...66'); - const program = gl.createProgram(); - var transformFeedbackOutputs = [-'gl_Position', -'anotherOutput']; - gl2.transformFeedbackVaryings(program, transformFeedbackOutputs, gl.ONE_MINUS_DST_COLOR); - const transformFeedbackVaryingsError = gl.getError(); - console.info("transformFeedbackVaryingsError: " + transformFeedbackVaryingsError); - expect(transformFeedbackVaryingsError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0716 - * @tc.name testGetTransformFeedbackVarying_01 - * @tc.desc Test getTransformFeedbackVarying. - */ - it('testGetTransformFeedbackVarying_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetTransformFeedbackVarying_01 test start ...66'); - const programObj = createProgram(gl); - var getTransformFeedbackVaryingobject = gl2.getTransformFeedbackVarying(-programObj, - - 0); - console.info("getTransformFeedbackVaryingobject: " + getTransformFeedbackVaryingobject); - const getTransformFeedbackVaryingError = gl.getError(); - console.info("getTransformFeedbackVaryingError: " + getTransformFeedbackVaryingError); - expect(getTransformFeedbackVaryingError).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetTransformFeedbackVarying has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0717 - * @tc.name testBindBufferBase_01 - * @tc.desc Test bindBufferBase. - */ - it('testBindBufferBase_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testBindBufferBase_01 test start ...66'); - let buffer = gl.createBuffer(); - gl2.bindBufferBase(-gl.TRANSFORM_FEEDBACK_BUFFER, -0, buffer); - const bindBufferBaseError = gl.getError(); - console.info("bindBufferBaseError: " + bindBufferBaseError); - expect(bindBufferBaseError).assertEqual(gl.INVALID_ENUM); - //deleteContext(); - done(); - } catch (e) { - console.log("bindBufferBaseError has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0718 - * @tc.name testBindBufferBase_02 - * @tc.desc Test bindBufferBase. - */ - it('testBindBufferBase_02', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testBindBufferBase_02 test start ...66'); - var programobject = gl.createProgram(); - gl2.bindBufferBase(-gl.SRC_ALPHA_SATURATE, -0, programobject); - const bindBufferBaseError = gl.getError(); - console.info("bindBufferBaseError: " + bindBufferBaseError); - expect(bindBufferBaseError).assertEqual(gl.INVALID_ENUM); - //deleteContext(); - done(); - } catch (e) { - console.log("bindBufferBaseError has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0719 - * @tc.name testGetTransformFeedbackVarying_02 - * @tc.desc Test getTransformFeedbackVarying. - */ - it('testGetTransformFeedbackVarying_02', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetTransformFeedbackVarying_02 test start ...66'); - const programObj = gl.createProgram(); - var getTransformFeedbackVaryingobject = gl2.getTransformFeedbackVarying(programObj, 0); - console.info("getTransformFeedbackVaryingobject: " + getTransformFeedbackVaryingobject); - const getTransformFeedbackVaryingError = gl.getError(); - console.info("getTransformFeedbackVaryingError: " + getTransformFeedbackVaryingError); - expect(getTransformFeedbackVaryingError).assertEqual(gl.INVALID_VALUE); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetTransformFeedbackVarying has failed for " + e) - expect(null).assertFail() - } - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0720 - * @tc.name bindBufferRange - * @tc.desc Test bindBufferRange. - */ - it('bindBufferRange', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL bindBufferRange test start ...66'); - const buffer = gl.createBuffer(); - gl2.bindBufferRange(gl.TRANSFORM_FEEDBACK_BUFFER, 1, buffer, 0, 4); - const bindBufferRangeError = gl.getError(); - console.info("bindBufferRangeError: " + bindBufferRangeError); - expect(bindBufferRangeError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("bindBufferRange has failed for " + e) - expect(null).assertFail() - } - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0721 - * @tc.name bindBufferRange_01 - * @tc.desc Test bindBufferRange. - */ - it('bindBufferRange_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL bindBufferRange_01 test start ...66'); - const buffer = gl.createBuffer(); - gl2.bindBufferRange(-gl.TRANSFORM_FEEDBACK_BUFFER, -0, buffer, -0, -4); - const bindBufferRangeError = gl.getError(); - console.info("bindBufferRangeError: " + bindBufferRangeError); - expect(bindBufferRangeError).assertEqual(gl.INVALID_VALUE); - //deleteContext(); - done(); - } catch (e) { - console.log("bindBufferRange has failed for " + e) - expect(null).assertFail() - } - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0722 - * @tc.name bindBufferRange_02 - * @tc.desc Test bindBufferRange. - */ - it('bindBufferRange_02', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL bindBufferRange_01 test start ...66'); - const buffer = gl.createBuffer(); - gl2.bindBufferRange(-gl.TRANSFORM_FEEDBACK_BUFFER, -1, buffer, -0, 4); - const bindBufferRangeError = gl.getError(); - console.info("bindBufferRangeError: " + bindBufferRangeError); - expect(bindBufferRangeError).assertEqual(gl.INVALID_ENUM); - //deleteContext(); - done(); - } catch (e) { - console.log("bindBufferRange has failed for " + e) - expect(null).assertFail() - } - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0723 - * @tc.name testIsShader_05 - * @tc.desc Test isShader. - */ - it('testIsShader_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsShader_05 test start ...66'); - var programobject = gl.createProgram(); - const isShader = gl.isShader(-0); - console.info("createShader --> isShader: " + isShader); - expect(isShader).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0724 - * @tc.name testLinkProgram_05 - * @tc.desc Test linkProgram. - */ - it('testLinkProgram_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testLinkProgram_05 test start ...66'); - const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); - gl.linkProgram(fragmentShader); - const linkProgramError = gl.getError(); - console.info("linkProgramError: " + linkProgramError); - expect(linkProgramError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0725 - * @tc.name testPauseTransformFeedback_01 - * @tc.desc Test pauseTransformFeedback. - */ - it('testPauseTransformFeedback_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testPauseTransformFeedback_01 test start ...66'); - const transformFeedback = gl2.createTransformFeedback(); - gl2.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, transformFeedback); - gl2.beginTransformFeedback(gl2.TRIANGLES); - gl2.pauseTransformFeedback(); - const pauseTransformFeedbackError = gl.getError(); - console.info("pauseTransformFeedbackError: " + pauseTransformFeedbackError); - expect(pauseTransformFeedbackError == gl.INVALID_OPERATION).assertEqual(true); - //deleteContext(); - done(); - } catch (e) { - console.log("testPauseTransformFeedback_01 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0726 - * @tc.name testResumeTransformFeedback_01 - * @tc.desc Test resumeTransformFeedback. - */ - it('testResumeTransformFeedback_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testResumeTransformFeedback_01 test start ...66'); - gl2.resumeTransformFeedback(); - const resumeTransformFeedbackError = gl.getError(); - console.info("resumeTransformFeedbackError: " + resumeTransformFeedbackError); - expect(resumeTransformFeedbackError == gl.INVALID_OPERATION).assertEqual(true); - //deleteContext(); - done(); - } catch (e) { - console.log("testResumeTransformFeedback_01 has failed for " + e) - expect(null).assertFail() - } - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0727 - * @tc.name webgl_test_blendEquation2 - * @tc.desc Test blendEquation. - */ - it('webgl_test_blendEquation2', 0, async function(done) { - //initContext(); - console.info("webgltest into blendEquation"); - - gl.blendEquation(gl.FUNC_REVERSE_SUBTRACT); - - const blendEquationValue = gl.getParameter(gl.BLEND_EQUATION_RGB); - console.info("blendEquation --> getParameter: " + blendEquationValue); - expect(blendEquationValue).assertEqual(gl.FUNC_REVERSE_SUBTRACT); - - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0728 - * @tc.name webgl_test_activeTexture_2 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE2); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33986); - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0729 - * @tc.name webgl_test_activeTexture_3 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE3); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33987); - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0730 - * @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.INVALID_VALUE); - //deleteContext(); - done(); - }); - - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0731 - * @tc.name webgl_test_bindBuffer_2 - * @tc.desc Test bindBuffer. - */ - it('webgl_test_bindBuffer_2', 0, async function(done) { - //initContext(); - console.info("webgltest into bindBuffer"); - - var buffer = gl.createBuffer(); - - gl.bindBuffer(gl.ELEMENT_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_0732 - * @tc.name webgl_test_bindTexture_2 - * @tc.desc Test bindTexture. - */ - it('webgl_test_bindTexture_2', 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_CUBE_MAP, 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_0733 - * @tc.name webgl_test_blendEquation__2 - * @tc.desc Test blendEquation. - */ - it('webgl_test_blendEquation__2', 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(32774); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0734 - * @tc.name webgl_test_blendEquation_3 - * @tc.desc Test blendEquation. - */ - it('webgl_test_blendEquation_3', 0, async function(done) { - //initContext(); - console.info("webgltest into blendEquation"); - - gl.blendEquation(gl.FUNC_SUBTRACT); - - const blendEquationValue = gl.getParameter(gl.BLEND_EQUATION_RGB); - console.info("blendEquation --> getParameter: " + blendEquationValue); - expect(blendEquationValue).assertEqual(gl.FUNC_SUBTRACT); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0735 - * @tc.name webgl_test_blendEquationSeparate_2 - * @tc.desc Test blendEquationSeparate. - */ - it('webgl_test_blendEquationSeparate_2', 0, async function(done) { - //initContext(); - console.info("webgltest into blendEquationSeparate"); - gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_REVERSE_SUBTRACT); - - const blendEquationSeparateValue = gl.getParameter(gl.BLEND_EQUATION_RGB); - console.info("blendEquationSeparate --> getParameter: " + blendEquationSeparateValue); - expect(blendEquationSeparateValue).assertEqual(gl.FUNC_ADD); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0736 - * @tc.name webgl_test_blendEquationSeparate_3 - * @tc.desc Test blendEquationSeparate. - */ - it('webgl_test_blendEquationSeparate_3', 0, async function(done) { - //initContext(); - console.info("webgltest into blendEquationSeparate"); - gl.blendEquationSeparate(gl.FUNC_SUBTRACT, gl.FUNC_REVERSE_SUBTRACT); - - const blendEquationSeparateValue = gl.getParameter(gl.BLEND_EQUATION_RGB); - console.info("blendEquationSeparate --> getParameter: " + blendEquationSeparateValue); - expect(blendEquationSeparateValue).assertEqual(gl.FUNC_SUBTRACT); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0737 - * @tc.name webgl_test_blendFunc_2 - * @tc.desc Test blendFunc. - */ - it('webgl_test_blendFunc_2', 0, async function(done) { - //initContext(); - console.info("webgltest into blendFunc"); - - gl.enable(gl.BLEND); - - gl.blendFunc(gl.ZERO, gl.ONE); - - const blendFuncValue = gl.getParameter(gl.BLEND_SRC_RGB); - console.info("blendFunc --> getParameter: " + blendFuncValue); - expect(blendFuncValue).assertEqual(gl.ZERO); - - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0738 - * @tc.name webgl_test_blendFunc_3 - * @tc.desc Test blendFunc. - */ - it('webgl_test_blendFunc_3', 0, async function(done) { - //initContext(); - console.info("webgltest into blendFunc"); - - gl.enable(gl.BLEND); - - gl.blendFunc(gl.SRC_ALPHA, gl.DST_ALPHA); - - const blendFuncValue = gl.getParameter(gl.BLEND_SRC_RGB); - console.info("blendFunc --> getParameter: " + blendFuncValue); - expect(blendFuncValue).assertEqual(gl.SRC_ALPHA); - - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0739 - * @tc.name webgl_test_blendFuncSeparate_2 - * @tc.desc Test blendFuncSeparate. - */ - it('webgl_test_blendFuncSeparate_2', 0, async function(done) { - //initContext(); - console.info("webgltest into blendFuncSeparate"); - - gl.enable(gl.BLEND); - - gl.blendFuncSeparate(gl.DST_ALPHA, gl.CONSTANT_COLOR, gl.CONSTANT_ALPHA, gl - .ONE_MINUS_CONSTANT_ALPHA); - - const blendFuncSeparateParameter = gl.getParameter(gl.BLEND_SRC_RGB) - console.info("blendFuncSeparate --> getParameter: " + blendFuncSeparateParameter); - expect(blendFuncSeparateParameter).assertEqual(gl.DST_ALPHA); - - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0740 - * @tc.name webgl_test_blendFuncSeparate_3 - * @tc.desc Test blendFuncSeparate. - */ - it('webgl_test_blendFuncSeparate_3', 0, async function(done) { - //initContext(); - console.info("webgltest into blendFuncSeparate"); - - gl.enable(gl.BLEND); - - gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.DST_ALPHA, gl - .ONE_MINUS_DST_ALPHA); - - const blendFuncSeparateParameter = gl.getParameter(gl.BLEND_SRC_RGB) - console.info("blendFuncSeparate --> getParameter: " + blendFuncSeparateParameter); - expect(blendFuncSeparateParameter).assertEqual(gl.SRC_ALPHA); - - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0741 - * @tc.name webgl_test_checkFramebufferStatus22 - * @tc.desc Test checkFramebufferStatus. - */ - it('webgl_test_checkFramebufferStatus22', 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_0742 - * @tc.name webgl_test_clear_2 - * @tc.desc Test clear. - */ - it('webgl_test_clear_2', 0, async function(done) { - //initContext(); - console.info("webgltest into clear"); - gl.clear(gl.DEPTH_BUFFER_BIT); - var float32Array = new Float32Array([0, 0, 0, 0]); - const clearParameter = gl.getParameter(gl.DEPTH_CLEAR_VALUE); - console.info("webgltest clear getParameter: " + clearParameter); - expect(typeof(clearParameter)).assertEqual('number'); - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0743 - * @tc.name webgl_test_clear_3 - * @tc.desc Test clear. - */ - it('webgl_test_clear_3', 0, async function(done) { - //initContext(); - console.info("webgltest into clear"); - gl.clear(gl.STENCIL_BUFFER_BIT); - var float32Array = new Float32Array([0, 0, 0, 0]); - const clearParameter = gl.getParameter(gl.STENCIL_CLEAR_VALUE); - console.info("webgltest clear getParameter: " + clearParameter); - expect(typeof(clearParameter)).assertEqual('number'); - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0744 - * @tc.name webgl_test_clearColor_2 - * @tc.desc Test clearColor. - */ - it('webgl_test_clearColor_2', 0, async function(done) { - //initContext(); - console.info("webgltest into clearColor"); - gl.clearColor(1, 3, 0.5, 3); - - const clearColorParameter = gl.getParameter(gl.COLOR_CLEAR_VALUE); - - var float32ArrayValue = new Float32Array([1, 3, 0.5, 3]); - - console.info("webgltest clearColor: " + clearColorParameter); - expect(clearColorParameter.toString()).assertEqual(float32ArrayValue.toString()); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0745 - * @tc.name webgl_test_copyTexImage2D_2 - * @tc.desc Test copyTexImage2D. - */ - it('webgl_test_copyTexImage2D_2', 0, async function(done) { - //initContext(); - console.info("webgltest into copyTexImage2D"); - gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.ALPHA, 0, 0, 512, 512, 0); - let errorCode = gl.getError(); - console.info("webgltest copyTexImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0746 - * @tc.name webgl_test_copyTexImage2D_3 - * @tc.desc Test copyTexImage2D. - */ - it('webgl_test_copyTexImage2D_3', 0, async function(done) { - //initContext(); - console.info("webgltest into copyTexImage2D"); - gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.LUMINANCE, 0, 0, 512, 512, 0); - let errorCode = gl.getError(); - console.info("webgltest copyTexImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0747 - * @tc.name webgl_test_copyTexSubImage2D_2 - * @tc.desc Test copyTexSubImage2D. - */ - it('webgl_test_copyTexSubImage2D_2', 0, async function(done) { - //initContext(); - console.info("webgltest into copyTexSubImage2D"); - - gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 16, 16); - let errorCode = gl.getError(); - console.info("webgltest copyTexSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0748 - * @tc.name webgl_test_copyTexSubImage2D_3 - * @tc.desc Test copyTexSubImage2D. - */ - it('webgl_test_copyTexSubImage2D_3', 0, async function(done) { - //initContext(); - console.info("webgltest into copyTexSubImage2D"); - - gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 16, 16); - let errorCode = gl.getError(); - console.info("webgltest copyTexSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0749 - * @tc.name webgl_test_copyTexSubImage2D_4 - * @tc.desc Test copyTexSubImage2D. - */ - it('webgl_test_copyTexSubImage2D_4', 0, async function(done) { - //initContext(); - console.info("webgltest into copyTexSubImage2D"); - - gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 16, 16); - let errorCode = gl.getError(); - console.info("webgltest copyTexSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0750 - * @tc.name webgl_test_createShader_2 - * @tc.desc Test createShader. - */ - it('webgl_test_createShader_2', 0, async function(done) { - //initContext(); - console.info("webgltest into createShader"); - - const shader = gl.createShader(gl.FRAGMENT_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_0751 - * @tc.name webgl_test_disable_22 - * @tc.desc Test disable. - */ - it('webgl_test_disable_22', 0, async function(done) { - //initContext(); - console.info("webgltest into disable"); - gl.enable(gl.BLEND); - const isEnabled2 = gl.isEnabled(gl.BLEND); - // true - console.info("webgltest disable isEnabled2: " + isEnabled2); - expect(isEnabled2).assertEqual(true); - - gl.disable(gl.BLEND); - // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: - const isEnabled = gl.isEnabled(gl.BLEND); - // false - console.info("webgltest disable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0752 - * @tc.name webgl_test_disable_23 - * @tc.desc Test disable. - */ - it('webgl_test_disable_23', 0, async function(done) { - //initContext(); - console.info("webgltest into disable"); - gl.enable(gl.BLEND); - const isEnabled2 = gl.isEnabled(gl.BLEND); - // true - console.info("webgltest disable isEnabled2: " + isEnabled2); - expect(isEnabled2).assertEqual(true); - - gl.disable(gl.BLEND); - // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: - const isEnabled = gl.isEnabled(gl.BLEND); - // false - console.info("webgltest disable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0753 - * @tc.name webgl_test_disable_24 - * @tc.desc Test disable. - */ - it('webgl_test_disable_24', 0, async function(done) { - //initContext(); - console.info("webgltest into disable"); - gl.enable(gl.DEPTH_TEST); - const isEnabled2 = gl.isEnabled(gl.DEPTH_TEST); - // true - console.info("webgltest disable isEnabled2: " + isEnabled2); - expect(isEnabled2).assertEqual(true); - - gl.disable(gl.DEPTH_TEST); - // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: - const isEnabled = gl.isEnabled(gl.DEPTH_TEST); - // false - console.info("webgltest disable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0754 - * @tc.name webgl_test_disable_25 - * @tc.desc Test disable. - */ - it('webgl_test_disable_25', 0, async function(done) { - //initContext(); - console.info("webgltest into disable"); - gl.enable(gl.POLYGON_OFFSET_FILL); - const isEnabled2 = gl.isEnabled(gl.POLYGON_OFFSET_FILL); - // true - console.info("webgltest disable isEnabled2: " + isEnabled2); - expect(isEnabled2).assertEqual(true); - - gl.disable(gl.POLYGON_OFFSET_FILL); - // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: - const isEnabled = gl.isEnabled(gl.POLYGON_OFFSET_FILL); - // false - console.info("webgltest disable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(false); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0755 - * @tc.name webgl_test_disable_26 - * @tc.desc Test disable. - */ - it('webgl_test_disable_26', 0, async function(done) { - //initContext(); - console.info("webgltest into disable"); - gl.enable(gl.SCISSOR_TEST); - const isEnabled2 = gl.isEnabled(gl.SCISSOR_TEST); - // true - console.info("webgltest disable isEnabled2: " + isEnabled2); - expect(isEnabled2).assertEqual(true); - - gl.disable(gl.SCISSOR_TEST); - // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: - const isEnabled = gl.isEnabled(gl.SCISSOR_TEST); - // false - console.info("webgltest disable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(false); - - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0756 - * @tc.name webgl_test_disableVertexAttribArray_2 - * @tc.desc Test disableVertexAttribArray. - */ - it('webgl_test_disableVertexAttribArray_2', 0, async function(done) { - //initContext(); - console.info("webgltest into disableVertexAttribArray"); - gl.disableVertexAttribArray(-1); - let errorCode = gl.getError(); - console.info("webgltest disableVertexAttribArray getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_VALUE); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0757 - * @tc.name webgl_test_drawArrays2 - * @tc.desc Test drawArrays. - */ - it('webgl_test_drawArrays2', 0, async function(done) { - //initContext(); - console.info("webgltest into drawArrays"); - - gl.drawArrays(gl.LINE_STRIP, 0, 8); - let errorCode = gl.getError(); - console.info("webgltest drawArrays getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0758 - * @tc.name webgl_test_drawArrays3 - * @tc.desc Test drawArrays. - */ - it('webgl_test_drawArrays3', 0, async function(done) { - //initContext(); - console.info("webgltest into drawArrays"); - - gl.drawArrays(gl.LINE_LOOP, 0, 8); - let errorCode = gl.getError(); - console.info("webgltest drawArrays getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0759 - * @tc.name webgl_test_drawArrays4 - * @tc.desc Test drawArrays. - */ - it('webgl_test_drawArrays4', 0, async function(done) { - //initContext(); - console.info("webgltest into drawArrays"); - - gl.drawArrays(gl.LINES, 0, 8); - let errorCode = gl.getError(); - console.info("webgltest drawArrays getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0760 - * @tc.name webgl_test_drawArrays5 - * @tc.desc Test drawArrays. - */ - it('webgl_test_drawArrays5', 0, async function(done) { - //initContext(); - console.info("webgltest into drawArrays"); - - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 8); - let errorCode = gl.getError(); - console.info("webgltest drawArrays getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0761 - * @tc.name webgl_test_drawArrays6 - * @tc.desc Test drawArrays. - */ - it('webgl_test_drawArrays6', 0, async function(done) { - //initContext(); - console.info("webgltest into drawArrays"); - - gl.drawArrays(gl.TRIANGLE_FAN, 0, 8); - let errorCode = gl.getError(); - console.info("webgltest drawArrays getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0762 - * @tc.name webgl_test_drawArrays7 - * @tc.desc Test drawArrays. - */ - it('webgl_test_drawArrays7', 0, async function(done) { - //initContext(); - console.info("webgltest into drawArrays"); - - gl.drawArrays(gl.TRIANGLES, 0, 8); - let errorCode = gl.getError(); - console.info("webgltest drawArrays getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0763 - * @tc.name webgl_test_drawElements22 - * @tc.desc Test drawElements. - */ - it('webgl_test_drawElements22', 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 viewPortParameter = gl.getParameter(gl.MAX_VIEWPORT_DIMS); - console.log('viewPortParameter: ' + viewPortParameter); - - const isContextLostValue = gl.isContextLost(); - console.info("isContextLostValue: " + isContextLostValue); - - // 指定清空的颜色 - gl.clearColor(0.0, 0.0, 0.0, 1.0); - - // 清空 - // COLOR_BUFFER_BIT 0x00004000 - gl.clear(gl.COLOR_BUFFER_BIT); - - console.info("indices.length: " + indices.length) - gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_SHORT, 0); - - let errorCode = gl.getError(); - console.info("webgltest drawArrays getError: " + errorCode); - expect(errorCode).assertEqual(1280); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0764 - * @tc.name webgl_test_drawElements23 - * @tc.desc Test drawElements. - */ - it('webgl_test_drawElements23', 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 viewPortParameter = gl.getParameter(gl.MAX_VIEWPORT_DIMS); - console.log('viewPortParameter: ' + viewPortParameter); - - const isContextLostValue = gl.isContextLost(); - console.info("isContextLostValue: " + isContextLostValue); - - // 指定清空的颜色 - gl.clearColor(0.0, 0.0, 0.0, 1.0); - - // 清空 - // COLOR_BUFFER_BIT 0x00004000 - gl.clear(gl.COLOR_BUFFER_BIT); - - console.info("indices.length: " + indices.length) - gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_SHORT, 0); - - let errorCode = gl.getError(); - console.info("webgltest drawArrays getError: " + errorCode); - expect(errorCode).assertEqual(1280); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0765 - * @tc.name webgl_test_drawElements24 - * @tc.desc Test drawElements. - */ - it('webgl_test_drawElements24', 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 viewPortParameter = gl.getParameter(gl.MAX_VIEWPORT_DIMS); - console.log('viewPortParameter: ' + viewPortParameter); - - const isContextLostValue = gl.isContextLost(); - console.info("isContextLostValue: " + isContextLostValue); - - // 指定清空的颜色 - gl.clearColor(0.0, 0.0, 0.0, 1.0); - - // 清空 - // COLOR_BUFFER_BIT 0x00004000 - gl.clear(gl.COLOR_BUFFER_BIT); - - console.info("indices.length: " + indices.length) - gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_SHORT, 0); - - let errorCode = gl.getError(); - console.info("webgltest drawArrays getError: " + errorCode); - expect(errorCode).assertEqual(1280); - //deleteContext(); - done(); - }); - - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0766 - * @tc.name webgl_test_enable - * @tc.desc Test enable. - */ - it('webgl_test_enable', 0, async function(done) { - //initContext(); - console.info("webgltest into enable"); - - gl.enable(gl.BLEND); - - const isEnabled = gl.isEnabled(gl.BLEND); - // true - console.info("webgltest enable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(true); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0767 - * @tc.name webgl_test_enable22 - * @tc.desc Test enable. - */ - it('webgl_test_enable22', 0, async function(done) { - //initContext(); - console.info("webgltest into enable"); - - gl.enable(gl.CULL_FACE); - - const isEnabled = gl.isEnabled(gl.CULL_FACE); - // true - console.info("webgltest enable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(true); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0768 - * @tc.name webgl_test_enable23 - * @tc.desc Test enable. - */ - it('webgl_test_enable23', 0, async function(done) { - //initContext(); - console.info("webgltest into enable"); - - gl.enable(gl.DEPTH_TEST); - - const isEnabled = gl.isEnabled(gl.DEPTH_TEST); - // true - console.info("webgltest enable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(true); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0769 - * @tc.name webgl_test_enable24 - * @tc.desc Test enable. - */ - it('webgl_test_enable24', 0, async function(done) { - //initContext(); - console.info("webgltest into enable"); - - gl.enable(gl.DITHER); - - const isEnabled = gl.isEnabled(gl.DITHER); - // true - console.info("webgltest enable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(true); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0770 - * @tc.name webgl_test_enable25 - * @tc.desc Test enable. - */ - it('webgl_test_enable25', 0, async function(done) { - //initContext(); - console.info("webgltest into enable"); - - gl.enable(gl.POLYGON_OFFSET_FILL); - - const isEnabled = gl.isEnabled(gl.POLYGON_OFFSET_FILL); - // true - console.info("webgltest enable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(true); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0771 - * @tc.name webgl_test_enable26 - * @tc.desc Test enable. - */ - it('webgl_test_enable26', 0, async function(done) { - //initContext(); - console.info("webgltest into enable"); - - gl.enable(gl.SAMPLE_ALPHA_TO_COVERAGE); - - const isEnabled = gl.isEnabled(gl.SAMPLE_ALPHA_TO_COVERAGE); - // true - console.info("webgltest enable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(true); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0772 - * @tc.name webgl_test_enable27 - * @tc.desc Test enable. - */ - it('webgl_test_enable27', 0, async function(done) { - //initContext(); - console.info("webgltest into enable"); - - gl.enable(gl.SAMPLE_COVERAGE); - - const isEnabled = gl.isEnabled(gl.SAMPLE_COVERAGE); - // true - console.info("webgltest enable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(true); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0773 - * @tc.name webgl_test_enable28 - * @tc.desc Test enable. - */ - it('webgl_test_enable28', 0, async function(done) { - //initContext(); - console.info("webgltest into enable"); - - gl.enable(gl.SCISSOR_TEST); - - const isEnabled = gl.isEnabled(gl.SCISSOR_TEST); - // true - console.info("webgltest enable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(true); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0774 - * @tc.name webgl_test_enable29 - * @tc.desc Test enable. - */ - it('webgl_test_enable29', 0, async function(done) { - //initContext(); - console.info("webgltest into enable"); - - gl.enable(gl.STENCIL_TEST); - - const isEnabled = gl.isEnabled(gl.STENCIL_TEST); - // true - console.info("webgltest enable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(true); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0775 - * @tc.name webgl_test_framebufferRenderbuffer22 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer22', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0776 - * @tc.name webgl_test_framebufferRenderbuffer23 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer23', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0777 - * @tc.name webgl_test_framebufferRenderbuffer24 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer24', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl - .RENDERBUFFER, renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0778 - * @tc.name webgl_test_framebufferRenderbuffer25 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer25', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0779 - * @tc.name webgl_test_framebufferTexture2D22 - * @tc.desc Test framebufferTexture2D. - */ - it('webgl_test_framebufferTexture2D22', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferTexture2D"); - const texture = gl.createTexture(); - gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, texture, - 0); - - let errorCode = gl.getError(); - console.info("webgltest framebufferTexture2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0780 - * @tc.name webgl_test_framebufferTexture2D23 - * @tc.desc Test framebufferTexture2D. - */ - it('webgl_test_framebufferTexture2D23', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferTexture2D"); - const texture = gl.createTexture(); - gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.TEXTURE_2D, texture, - 0); - - let errorCode = gl.getError(); - console.info("webgltest framebufferTexture2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0781 - * @tc.name webgl_test_framebufferTexture2D24 - * @tc.desc Test framebufferTexture2D. - */ - it('webgl_test_framebufferTexture2D24', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferTexture2D"); - const texture = gl.createTexture(); - gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl - .TEXTURE_CUBE_MAP_POSITIVE_X, texture, 0); - - let errorCode = gl.getError(); - console.info("webgltest framebufferTexture2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0782 - * @tc.name webgl_test_framebufferTexture2D25 - * @tc.desc Test framebufferTexture2D. - */ - it('webgl_test_framebufferTexture2D25', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferTexture2D"); - const texture = gl.createTexture(); - gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl - .TEXTURE_CUBE_MAP_POSITIVE_Y, texture, 0); - - let errorCode = gl.getError(); - console.info("webgltest framebufferTexture2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0783 - * @tc.name webgl_test_framebufferTexture2D26 - * @tc.desc Test framebufferTexture2D. - */ - it('webgl_test_framebufferTexture2D26', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferTexture2D"); - const texture = gl.createTexture(); - gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl - .TEXTURE_CUBE_MAP_POSITIVE_Z, texture, 0); - - let errorCode = gl.getError(); - console.info("webgltest framebufferTexture2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0784 - * @tc.name webgl_test_framebufferTexture2D25 - * @tc.desc Test framebufferTexture2D. - */ - it('webgl_test_framebufferTexture2D25', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferTexture2D"); - const texture = gl.createTexture(); - gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, - 0); - - let errorCode = gl.getError(); - console.info("webgltest framebufferTexture2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0785 - * @tc.name webgl_test_drawBuffers22 - * @tc.desc Test drawBuffers. - */ - it('webgl_test_drawBuffers22', 0, async function(done) { - //initContext(); - console.info("webgltest into drawBuffers"); - - gl2.drawBuffers([gl2.BACK, gl2.COLOR_ATTACHMENT2]); - - let errorCode = gl.getError(); - console.info("webgltest drawBuffers getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0786 - * @tc.name webgl_test_drawBuffers23 - * @tc.desc Test drawBuffers. - */ - it('webgl_test_drawBuffers23', 0, async function(done) { - //initContext(); - console.info("webgltest into drawBuffers"); - - gl2.drawBuffers([gl2.NONE, gl2.COLOR_ATTACHMENT3]); - - let errorCode = gl.getError(); - console.info("webgltest drawBuffers getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0787 - * @tc.name webgl_test_drawBuffers24 - * @tc.desc Test drawBuffers. - */ - it('webgl_test_drawBuffers24', 0, async function(done) { - //initContext(); - console.info("webgltest into drawBuffers"); - - gl2.drawBuffers([gl2.BACK, gl2.COLOR_ATTACHMENT4]); - - let errorCode = gl.getError(); - console.info("webgltest drawBuffers getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0788 - * @tc.name webgl_test_drawBuffers25 - * @tc.desc Test drawBuffers. - */ - it('webgl_test_drawBuffers25', 0, async function(done) { - //initContext(); - console.info("webgltest into drawBuffers"); - - gl2.drawBuffers([gl2.NONE, gl2.COLOR_ATTACHMENT5]); - - let errorCode = gl.getError(); - console.info("webgltest drawBuffers getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0789 - * @tc.name webgl_test_drawBuffers26 - * @tc.desc Test drawBuffers. - */ - it('webgl_test_drawBuffers26', 0, async function(done) { - //initContext(); - console.info("webgltest into drawBuffers"); - - gl2.drawBuffers([gl2.BACK, gl2.COLOR_ATTACHMENT6]); - - let errorCode = gl.getError(); - console.info("webgltest drawBuffers getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0790 - * @tc.name webgl_test_clearBufferfv22 - * @tc.desc Test clearBufferfv. - */ - it('webgl_test_clearBufferfv22', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferfv"); - - gl2.clearBufferfv(gl.DEPTH, 0, [0.0, 0.0, 0.0, 0.0]); - - let errorCode = gl.getError(); - console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0791 - * @tc.name webgl_test_clearBufferfv_22 - * @tc.desc Test clearBufferfv. - */ - it('webgl_test_clearBufferfv_22', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferfv"); - - gl2.clearBufferfv(gl.STENCIL, 0, [0.0, 0.0, 0.0, 0.0]); - - let errorCode = gl.getError(); - console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0792 - * @tc.name webgl_test_clearBufferfv23 - * @tc.desc Test clearBufferfv. - */ - it('webgl_test_clearBufferfv23', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferfv"); - - gl2.clearBufferfv(gl.DEPTH_STENCIL, 0, [0.0, 0.0, 0.0, 0.0]); - - let errorCode = gl.getError(); - console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_ENUM); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0793 - * @tc.name webgl_test_clearBufferiv22 - * @tc.desc Test clearBufferiv. - */ - it('webgl_test_clearBufferiv22', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferiv"); - - gl2.clearBufferiv(gl.DEPTH, 0, new Int32Array([0, 1, 0, 0.5])); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0794 - * @tc.name webgl_test_clearBufferiv23 - * @tc.desc Test clearBufferiv. - */ - it('webgl_test_clearBufferiv23', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferiv"); - - gl2.clearBufferiv(gl.STENCIL, 0, new Int32Array([0, 1, 0, 0.5])); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0795 - * @tc.name webgl_test_clearBufferiv24 - * @tc.desc Test clearBufferiv. - */ - it('webgl_test_clearBufferiv24', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferiv"); - - gl2.clearBufferiv(gl.DEPTH_STENCIL, 0, new Int32Array([0, 1, 0, 0.5])); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0796 - * @tc.name webgl_test_clearBufferuiv23 - * @tc.desc Test clearBufferuiv. - */ - it('webgl_test_clearBufferuiv23', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferuiv"); - - gl2.clearBufferuiv(gl.DEPTH, 0, new Uint32Array([0, 1, 0, 0])); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferuiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0797 - * @tc.name webgl_test_clearBufferuiv24 - * @tc.desc Test clearBufferuiv. - */ - it('webgl_test_clearBufferuiv24', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferuiv"); - - gl2.clearBufferuiv(gl.STENCIL, 0, new Uint32Array([0, 1, 0, 0])); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferuiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0798 - * @tc.name webgl_test_clearBufferuiv25 - * @tc.desc Test clearBufferuiv. - */ - it('webgl_test_clearBufferuiv25', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferuiv"); - - gl2.clearBufferuiv(gl.DEPTH_STENCIL, 0, new Uint32Array([0, 1, 0, 0])); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferuiv getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0799 - * @tc.name webgl_test_clearBufferfi22 - * @tc.desc Test clearBufferfi. - */ - it('webgl_test_clearBufferfi22', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferfi"); - - gl2.clearBufferfi(gl.DEPTH, 0, 1.0, 0); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferfi getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0800 - * @tc.name webgl_test_clearBufferfi23 - * @tc.desc Test clearBufferfi. - */ - it('webgl_test_clearBufferfi23', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferfi"); - - gl2.clearBufferfi(gl.STENCIL, 0, 1.0, 0); - - let errorCode = gl.getError(); - console.info("webgltest clearBufferfi getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test09.js b/graphic/webGL/src/main/js/default/test/WebGL.test09.js deleted file mode 100644 index ebaf1241478a46307f5e1210bc5806e33b87e99c..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test09.js +++ /dev/null @@ -1,2064 +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_webgl9', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_0802 - * @tc.name webgl_test_beginQuery22 - * @tc.desc Test beginQuery. - */ - it('webgl_test_beginQuery22', 0, async function(done) { - //initContext(); - console.info("webgltest into beginQuery"); - - var query = gl2.createQuery(); - gl2.beginQuery(gl2.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, query); - - const currentQuery = gl2.getQuery(gl2.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl2 - .CURRENT_QUERY); - const isQuery1 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery isQuery1: " + isQuery1); - expect(isQuery1).assertEqual(true); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0805 - * @tc.name webgl_test_endQuery24 - * @tc.desc Test endQuery. - */ - it('webgl_test_endQuery24', 0, async function(done) { - //initContext(); - console.info("webgltest into endQuery"); - - var query = gl2.createQuery(); - gl2.beginQuery(gl2.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, query); - - const currentQuery = gl2.getQuery(gl2.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl2 - .CURRENT_QUERY); - const isQuery1 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery isQuery1: " + isQuery1); - expect(isQuery1).assertEqual(true); - - gl2.endQuery(0x8C2F); - - const isQuery2 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery isQuery2: " + isQuery2); - expect(isQuery2).assertEqual(true); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0807 - * @tc.name webgl_test_getQuery24 - * @tc.desc Test endQuery. - */ - it('webgl_test_getQuery24', 0, async function(done) { - //initContext(); - console.info("webgltest into endQuery"); - - var query = gl2.createQuery(); - gl2.beginQuery(gl2.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, query); - - const currentQuery = gl2.getQuery(gl2.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl2 - .CURRENT_QUERY); - const isQuery1 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery isQuery1: " + isQuery1); - expect(isQuery1).assertEqual(true); - - gl2.endQuery(0x8C2F); - - const isQuery2 = gl2.isQuery(currentQuery); - console.info("webgltest createQuery isQuery2: " + isQuery2); - expect(isQuery2).assertEqual(true); - - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0808 - * @tc.name webgl_test_bindSampler23 - * @tc.desc Test bindSampler. - */ - it('webgl_test_bindSampler23', 0, async function(done) { - //initContext(); - console.info("webgltest into bindSampler"); - const sampler = gl2.createSampler(); - const isSampler1 = gl2.isSampler(sampler); - console.info("webgltest createSampler isSampler1: " + isSampler1); - expect(isSampler1).assertEqual(true); - - gl2.bindSampler(-1, sampler); - const isSampler2 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); - expect(isSampler2).assertEqual(true); - - gl2.deleteSampler(sampler); - const isSampler3 = gl2.isSampler(sampler); - console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); - expect(isSampler3).assertEqual(false); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0809 - * @tc.name webgl_test_samplerParameterf24 - * @tc.desc Test samplerParameterf. - */ - it('webgl_test_samplerParameterf24', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameterf"); - - let sampler = gl2.createSampler(); - // gl2.bindSampler(0, sampler); - gl2.samplerParameterf(sampler, gl.TEXTURE_COMPARE_FUNC, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameterf getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0810 - * @tc.name webgl_test_samplerParameterf25 - * @tc.desc Test samplerParameterf. - */ - it('webgl_test_samplerParameterf25', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameterf"); - - let sampler = gl2.createSampler(); - // gl2.bindSampler(0, sampler); - gl2.samplerParameterf(sampler, gl.TEXTURE_COMPARE_MODE, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameterf getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0811 - * @tc.name webgl_test_samplerParameterf26 - * @tc.desc Test samplerParameterf. - */ - it('webgl_test_samplerParameterf26', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameterf"); - - let sampler = gl2.createSampler(); - // gl2.bindSampler(0, sampler); - gl2.samplerParameterf(sampler, gl.TEXTURE_MAX_LOD, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameterf getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0812 - * @tc.name webgl_test_samplerParameterf27 - * @tc.desc Test samplerParameterf. - */ - it('webgl_test_samplerParameterf27', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameterf"); - - let sampler = gl2.createSampler(); - // gl2.bindSampler(0, sampler); - gl2.samplerParameterf(sampler, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameterf getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0813 - * @tc.name webgl_test_samplerParameterf28 - * @tc.desc Test samplerParameterf. - */ - it('webgl_test_samplerParameterf28', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameterf"); - - let sampler = gl2.createSampler(); - // gl2.bindSampler(0, sampler); - gl2.samplerParameterf(sampler, gl.TEXTURE_MIN_LOD, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameterf getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0814 - * @tc.name webgl_test_samplerParameterf29 - * @tc.desc Test samplerParameterf. - */ - it('webgl_test_samplerParameterf29', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameterf"); - - let sampler = gl2.createSampler(); - // gl2.bindSampler(0, sampler); - gl2.samplerParameterf(sampler, gl.TEXTURE_WRAP_R, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameterf getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0815 - * @tc.name webgl_test_samplerParameterf30 - * @tc.desc Test samplerParameterf. - */ - it('webgl_test_samplerParameterf30', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameterf"); - - let sampler = gl2.createSampler(); - // gl2.bindSampler(0, sampler); - gl2.samplerParameterf(sampler, gl.TEXTURE_WRAP_S, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameterf getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_ENUM); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0816 - * @tc.name webgl_test_samplerParameterf31 - * @tc.desc Test samplerParameterf. - */ - it('webgl_test_samplerParameterf31', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameterf"); - - let sampler = gl2.createSampler(); - // gl2.bindSampler(0, sampler); - gl2.samplerParameterf(sampler, gl.TEXTURE_WRAP_T, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameterf getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_ENUM); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0817 - * @tc.name webgl_test_samplerParameteri24 - * @tc.desc Test samplerParameteri. - */ - it('webgl_test_samplerParameteri24', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameteri"); - let sampler = gl2.createSampler(); - gl2.samplerParameteri(sampler, gl.TEXTURE_COMPARE_FUNC, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameteri getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0818 - * @tc.name webgl_test_samplerParameteri25 - * @tc.desc Test samplerParameteri. - */ - it('webgl_test_samplerParameteri25', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameteri"); - let sampler = gl2.createSampler(); - gl2.samplerParameteri(sampler, gl.TEXTURE_COMPARE_MODE, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameteri getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0819 - * @tc.name webgl_test_samplerParameteri26 - * @tc.desc Test samplerParameteri. - */ - it('webgl_test_samplerParameteri26', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameteri"); - let sampler = gl2.createSampler(); - gl2.samplerParameteri(sampler, gl.TEXTURE_MAX_LOD, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameteri getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0820 - * @tc.name webgl_test_samplerParameteri27 - * @tc.desc Test samplerParameteri. - */ - it('webgl_test_samplerParameteri27', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameteri"); - let sampler = gl2.createSampler(); - gl2.samplerParameteri(sampler, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameteri getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0821 - * @tc.name webgl_test_samplerParameteri28 - * @tc.desc Test samplerParameteri. - */ - it('webgl_test_samplerParameteri28', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameteri"); - let sampler = gl2.createSampler(); - gl2.samplerParameteri(sampler, gl.TEXTURE_MIN_LOD, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameteri getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0822 - * @tc.name webgl_test_samplerParameteri29 - * @tc.desc Test samplerParameteri. - */ - it('webgl_test_samplerParameteri29', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameteri"); - let sampler = gl2.createSampler(); - gl2.samplerParameteri(sampler, gl.TEXTURE_WRAP_R, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameteri getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0823 - * @tc.name webgl_test_samplerParameteri211 - * @tc.desc Test samplerParameteri. - */ - it('webgl_test_samplerParameteri211', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameteri"); - let sampler = gl2.createSampler(); - gl2.samplerParameteri(sampler, gl.TEXTURE_WRAP_S, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameteri getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_ENUM); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0824 - * @tc.name webgl_test_samplerParameteri212 - * @tc.desc Test samplerParameteri. - */ - it('webgl_test_samplerParameteri212', 0, async function(done) { - //initContext(); - console.info("webgltest into samplerParameteri"); - let sampler = gl2.createSampler(); - gl2.samplerParameteri(sampler, gl.TEXTURE_WRAP_T, gl.NEAREST); - - let errorCode = gl.getError(); - console.info("webgltest samplerParameteri getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_ENUM); - gl2.deleteSampler(sampler); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0825 - * @tc.name testGetShaderPrecisionFormat - * @tc.desc Test getShaderPrecisionFormat. - */ - it('testGetShaderPrecisionFormat', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); - const shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_INT); - console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); - const type = ((typeof shaderPrecisionFormat) === "object") - expect(type).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0826 - * @tc.name testGetActiveUniformBlockParameter_1 - * @tc.desc Test getActiveUniformBlockParameter. - */ - it('testGetActiveUniformBlockParameter_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( - gl2)); - const program = globalFunction(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - const int32Array = new Int32Array([1, 2]); - gl2.uniform1iv(uniformLocation, int32Array); - const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); - gl2.uniformBlockBinding(program, blockIndex, 1); - const blockSize = gl2.getActiveUniformBlockParameter(program, blockIndex, gl2 - .UNIFORM_BLOCK_BINDING); - console.info("getActiveUniformBlockParameter blockSize" + blockSize); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_VALUE); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0827 - * @tc.name testGetActiveUniformBlockParameter_2 - * @tc.desc Test getActiveUniformBlockParameter. - */ - it('testGetActiveUniformBlockParameter_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( - gl2)); - const program = globalFunction(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - const int32Array = new Int32Array([1, 2]); - gl2.uniform1iv(uniformLocation, int32Array); - const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); - gl2.uniformBlockBinding(program, blockIndex, 1); - const blockSize = gl2.getActiveUniformBlockParameter(program, blockIndex, gl2 - .UNIFORM_BLOCK_ACTIVE_UNIFORMS); - console.info("getActiveUniformBlockParameter blockSize" + blockSize); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_VALUE); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0828 - * @tc.name testGetActiveUniformBlockParameter_3 - * @tc.desc Test getActiveUniformBlockParameter. - */ - it('testGetActiveUniformBlockParameter_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( - gl2)); - const program = globalFunction(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - const int32Array = new Int32Array([1, 2]); - gl2.uniform1iv(uniformLocation, int32Array); - const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); - gl2.uniformBlockBinding(program, blockIndex, 1); - const blockSize = gl2.getActiveUniformBlockParameter(program, blockIndex, - gl2.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES); - console.info("getActiveUniformBlockParameter blockSize" + blockSize); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_VALUE); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0829 - * @tc.name testGetActiveUniformBlockParameter_4 - * @tc.desc Test getActiveUniformBlockParameter. - */ - it('testGetActiveUniformBlockParameter_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( - gl2)); - const program = globalFunction(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - const int32Array = new Int32Array([1, 2]); - gl2.uniform1iv(uniformLocation, int32Array); - const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); - gl2.uniformBlockBinding(program, blockIndex, 1); - const blockSize = gl2.getActiveUniformBlockParameter(program, blockIndex, - gl2.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER); - console.info("getActiveUniformBlockParameter blockSize" + blockSize); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_VALUE); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0830 - * @tc.name testGetIndexedParameter_01_01 - * @tc.desc Test getIndexedParameter. - */ - it('testGetIndexedParameter_01_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetIndexedParameter_01_01 test start ...66'); - console.info('jsWebGL testGetIndexedParameter_01 test start ...' + JSON.stringify(gl)); - const reurGLsizeiptr = gl2.getIndexedParameter(-gl.TRANSFORM_FEEDBACK_BUFFER_SIZE, -0); - const typeGLsizeiptr = typeof(reurGLsizeiptr); - expect(typeGLsizeiptr == 'String').assertEqual(false); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetIndexedParameter_01 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0831 - * @tc.name testGetIndexedParameter_02_01 - * @tc.desc Test getIndexedParameter. - */ - it('testGetIndexedParameter_02_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetIndexedParameter_02_01 test start ...66'); - console.info('jsWebGL testGetIndexedParameter_02 test start ...' + JSON.stringify(gl)); - const retuGLintptr = gl2.getIndexedParameter(-gl.TRANSFORM_FEEDBACK_BUFFER_START, -1); - const typeGLintptr = typeof(retuGLintptr); - expect(typeGLintptr == 'String').assertEqual(false); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetIndexedParameter_02 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0832 - * @tc.name testGetIndexedParameter_03 - * @tc.desc Test getIndexedParameter. - */ - it('testGetIndexedParameter_03_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetIndexedParameter_03_01 test start ...66'); - console.info('jsWebGL testGetIndexedParameter_03 test start ...' + JSON.stringify(gl)); - const WebGLBufferobject = gl2.getIndexedParameter(gl.UNIFORM_BUFFER_BINDING, -0); - const isBuffer = gl.isBuffer(WebGLBufferobject); - expect(isBuffer).assertEqual(false); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetIndexedParameter_03 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0833 - * @tc.name testGetIndexedParameter_04 - * @tc.desc Test getIndexedParameter. - */ - it('testGetIndexedParameter_04_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetIndexedParameter_04_01 test start ...66'); - console.info('jsWebGL testGetIndexedParameter_04 test start ...' + JSON.stringify(gl)); - const reurGLsizeiptr = gl2.getIndexedParameter(-gl.UNIFORM_BUFFER_SIZE, null); - const typeGLsizeiptr = typeof(reurGLsizeiptr); - expect(typeGLsizeiptr == 'String').assertEqual(false); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetIndexedParameter_04 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0834 - * @tc.name testGetIndexedParameter_05_01 - * @tc.desc Test getIndexedParameter. - */ - it('testGetIndexedParameter_05_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testGetIndexedParameter_05 test start ...66'); - console.info('jsWebGL testGetIndexedParameter_05 test start ...' + JSON.stringify(gl)); - const retuGLintptr = gl2.getIndexedParameter(-gl.UNIFORM_BUFFER_START, -0); - const typeGLintptr = typeof(retuGLintptr); - expect(typeGLintptr == 'String').assertEqual(false); - //deleteContext(); - done(); - } catch (e) { - console.log("testGetIndexedParameter_05 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0838 - * @tc.name testPixelStorei_1_02 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_1_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_1_02 test start ...66'); - var tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 4); - const unpackValue = gl.getParameter(gl.UNPACK_FLIP_Y_WEBGL); - console.info("unpackValue: " + unpackValue); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0839 - * @tc.name testPixelStorei_1_03 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_1_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_1_03 test start ...66'); - var tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 4); - const unpackValue = gl.getParameter(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL); - console.info("unpackValue: " + unpackValue); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0840 - * @tc.name testPixelStorei_1_04 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_1_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_1_04 test start ...66'); - var tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 4); - const unpackValue = gl.getParameter(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL); - console.info("unpackValue: " + unpackValue); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0841 - * @tc.name testPixelStorei_1_05 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_1_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_1_05 test start ...66'); - var tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.pixelStorei(gl2.PACK_ROW_LENGTH, 4); - const unpackValue = gl.getParameter(gl2.PACK_ROW_LENGTH); - console.info("unpackValue: " + unpackValue); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0842 - * @tc.name testPixelStorei_1_06 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_1_06', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_1_06 test start ...66'); - var tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.pixelStorei(gl2.PACK_SKIP_PIXELS, 4); - const unpackValue = gl.getParameter(gl2.PACK_SKIP_PIXELS); - console.info("unpackValue: " + unpackValue); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0843 - * @tc.name testPixelStorei_1_07 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_1_07', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_1_07 test start ...66'); - var tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.pixelStorei(gl2.PACK_SKIP_ROWS, 4); - const unpackValue = gl.getParameter(gl2.PACK_SKIP_ROWS); - console.info("unpackValue: " + unpackValue); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0844 - * @tc.name testPixelStorei_1_08 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_1_08', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_1_08 test start ...66'); - var tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.pixelStorei(gl2.UNPACK_ROW_LENGTH, 4); - const unpackValue = gl.getParameter(gl2.UNPACK_ROW_LENGTH); - console.info("unpackValue: " + unpackValue); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0845 - * @tc.name testPixelStorei_1_09 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_1_09', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_1_09 test start ...66'); - var tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.pixelStorei(gl2.UNPACK_IMAGE_HEIGHT, 4); - const unpackValue = gl.getParameter(gl2.UNPACK_IMAGE_HEIGHT); - console.info("unpackValue: " + unpackValue); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0846 - * @tc.name testPixelStorei_1_10 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_1_10', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_1_10 test start ...66'); - var tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.pixelStorei(gl2.UNPACK_SKIP_PIXELS, 4); - const unpackValue = gl.getParameter(gl2.UNPACK_SKIP_PIXELS); - console.info("unpackValue: " + unpackValue); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0847 - * @tc.name testPixelStorei_1_11 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_1_11', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_1_11 test start ...66'); - var tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.pixelStorei(gl2.UNPACK_SKIP_ROWS, 4); - const unpackValue = gl.getParameter(gl2.UNPACK_SKIP_ROWS); - console.info("unpackValue: " + unpackValue); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0848 - * @tc.name testPixelStorei_1_12 - * @tc.desc Test pixelStorei. - */ - it('testPixelStorei_1_12', 0, async function(done) { - //initContext(); - console.info('jsWebGL testPixelStorei_1_12 test start ...66'); - var tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.pixelStorei(gl2.UNPACK_SKIP_IMAGES, 4); - const unpackValue = gl.getParameter(gl2.UNPACK_SKIP_IMAGES); - console.info("unpackValue: " + unpackValue); - const pixelStoreiError = gl.getError(); - console.info("pixelStoreiError: " + pixelStoreiError); - expect(pixelStoreiError).assertEqual(0); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0849 - * @tc.name testBufferData_80 - * @tc.desc Test bufferData. - */ - it('testBufferData_80', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_80 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0850 - * @tc.name testBufferData_81 - * @tc.desc Test bufferData. - */ - it('testBufferData_81', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_81 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.COPY_READ_BUFFER, buffer); - gl.bufferData(gl2.COPY_READ_BUFFER, 1024, gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0851 - * @tc.name testBufferData_82 - * @tc.desc Test bufferData. - */ - it('testBufferData_82', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_82 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.COPY_WRITE_BUFFER, buffer); - gl.bufferData(gl2.COPY_WRITE_BUFFER, 1024, gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0852 - * @tc.name testBufferData_83 - * @tc.desc Test bufferData. - */ - it('testBufferData_83', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_83 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.TRANSFORM_FEEDBACK_BUFFER, buffer); - gl.bufferData(gl2.TRANSFORM_FEEDBACK_BUFFER, 1024, gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0853 - * @tc.name testBufferData_84 - * @tc.desc Test bufferData. - */ - it('testBufferData_84', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_84 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.UNIFORM_BUFFER, buffer); - gl.bufferData(gl2.UNIFORM_BUFFER, 1024, gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0854 - * @tc.name testBufferData_85 - * @tc.desc Test bufferData. - */ - it('testBufferData_85', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_85 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.PIXEL_PACK_BUFFER, buffer); - gl.bufferData(gl2.PIXEL_PACK_BUFFER, 1024, gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0855 - * @tc.name testBufferData_86 - * @tc.desc Test bufferData. - */ - it('testBufferData_86', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_86 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.PIXEL_UNPACK_BUFFER, buffer); - gl.bufferData(gl2.PIXEL_UNPACK_BUFFER, 1024, gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0856 - * @tc.name testBufferData_80_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_80_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_80_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.DYNAMIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0857 - * @tc.name testBufferData_81_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_81_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_81_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.COPY_READ_BUFFER, buffer); - gl.bufferData(gl2.COPY_READ_BUFFER, 1024, gl.STREAM_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0858 - * @tc.name testBufferData_82_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_82_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_82_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.COPY_WRITE_BUFFER, buffer); - gl.bufferData(gl2.COPY_WRITE_BUFFER, 1024, gl2.STATIC_READ); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0859 - * @tc.name testBufferData_83_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_83_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_83_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.TRANSFORM_FEEDBACK_BUFFER, buffer); - gl.bufferData(gl2.TRANSFORM_FEEDBACK_BUFFER, 1024, gl2.DYNAMIC_READ); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0860 - * @tc.name testBufferData_84_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_84_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_84_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.UNIFORM_BUFFER, buffer); - gl.bufferData(gl2.UNIFORM_BUFFER, 1024, gl2.STREAM_READ); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0861 - * @tc.name testBufferData_85_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_85_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_85_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.PIXEL_PACK_BUFFER, buffer); - gl.bufferData(gl2.PIXEL_PACK_BUFFER, 1024, gl2.STATIC_COPY); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0862 - * @tc.name testBufferData_86_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_86_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_86_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.PIXEL_UNPACK_BUFFER, buffer); - gl.bufferData(gl2.PIXEL_UNPACK_BUFFER, 1024, gl2.DYNAMIC_COPY); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0863 - * @tc.name testBufferData_87_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_87_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_87_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.PIXEL_UNPACK_BUFFER, buffer); - gl.bufferData(gl2.PIXEL_UNPACK_BUFFER, 1024, gl2.STREAM_COPY); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0864 - * @tc.name testBufferData_80_1 - * @tc.desc Test bufferData. - */ - it('testBufferData_80_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_80_1 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0865 - * @tc.name testBufferData_81_1 - * @tc.desc Test bufferData. - */ - it('testBufferData_81_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_81_1 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.COPY_READ_BUFFER, buffer); - gl.bufferData(gl2.COPY_READ_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0866 - * @tc.name testBufferData_82_1 - * @tc.desc Test bufferData. - */ - it('testBufferData_82_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_82_1 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.COPY_WRITE_BUFFER, buffer); - gl.bufferData(gl2.COPY_WRITE_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0867 - * @tc.name testBufferData_83_1 - * @tc.desc Test bufferData. - */ - it('testBufferData_83_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_83_1 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.TRANSFORM_FEEDBACK_BUFFER, buffer); - gl.bufferData(gl2.TRANSFORM_FEEDBACK_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0868 - * @tc.name testBufferData_84_1 - * @tc.desc Test bufferData. - */ - it('testBufferData_84_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_84_1 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.UNIFORM_BUFFER, buffer); - gl.bufferData(gl2.UNIFORM_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0869 - * @tc.name testBufferData_85_1 - * @tc.desc Test bufferData. - */ - it('testBufferData_85_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_85_1 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.PIXEL_PACK_BUFFER, buffer); - gl.bufferData(gl2.PIXEL_PACK_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0870 - * @tc.name testBufferData_86_1 - * @tc.desc Test bufferData. - */ - it('testBufferData_86_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_86_1 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.PIXEL_UNPACK_BUFFER, buffer); - gl.bufferData(gl2.PIXEL_UNPACK_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0871 - * @tc.name testBufferData_80_1_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_80_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_80_1_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.DYNAMIC_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0872 - * @tc.name testBufferData_81_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_81_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_81_1_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.COPY_READ_BUFFER, buffer); - gl.bufferData(gl2.COPY_READ_BUFFER, new ArrayBuffer(8), gl.STREAM_DRAW); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0873 - * @tc.name testBufferData_82_1_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_82_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_82_1_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.COPY_WRITE_BUFFER, buffer); - gl.bufferData(gl2.COPY_WRITE_BUFFER, new ArrayBuffer(8), gl2.STATIC_READ); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0874 - * @tc.name testBufferData_83_1_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_83_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_83_1_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.TRANSFORM_FEEDBACK_BUFFER, buffer); - gl.bufferData(gl2.TRANSFORM_FEEDBACK_BUFFER, new ArrayBuffer(8), gl2.DYNAMIC_READ); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0875 - * @tc.name testBufferData_84_1_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_84_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_84_1_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.UNIFORM_BUFFER, buffer); - gl.bufferData(gl2.UNIFORM_BUFFER, new ArrayBuffer(8), gl2.STREAM_READ); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0876 - * @tc.name testBufferData_85_1_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_85_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_85_1_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.PIXEL_PACK_BUFFER, buffer); - gl.bufferData(gl2.PIXEL_PACK_BUFFER, new ArrayBuffer(8), gl2.STATIC_COPY); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0877 - * @tc.name testBufferData_86_1_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_86_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_86_1_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.PIXEL_UNPACK_BUFFER, buffer); - gl.bufferData(gl2.PIXEL_UNPACK_BUFFER, new ArrayBuffer(8), gl2.DYNAMIC_COPY); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0878 - * @tc.name testBufferData_87_1_01 - * @tc.desc Test bufferData. - */ - it('testBufferData_87_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferData_87_1_01 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl2.PIXEL_UNPACK_BUFFER, buffer); - gl.bufferData(gl2.PIXEL_UNPACK_BUFFER, new ArrayBuffer(8), gl2.STREAM_COPY); - const bufferDataError = gl.getError(); - console.info("bufferDataError: " + bufferDataError); - expect(bufferDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0879 - * @tc.name testBufferSubData_1_02 - * @tc.desc Test bufferSubData. - */ - it('testBufferSubData_1_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferSubData_1_02 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - gl.bufferSubData(gl.ARRAY_BUFFER, 512, new ArrayBuffer(8)); - const bufferSubDataError = gl.getError(); - console.info("bufferSubDataError: " + bufferSubDataError); - expect(bufferSubDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0880 - * @tc.name testBufferSubData_1_03 - * @tc.desc Test bufferSubData. - */ - it('testBufferSubData_1_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferSubData_1_03 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 512, new ArrayBuffer(8)); - const bufferSubDataError = gl.getError(); - console.info("bufferSubDataError: " + bufferSubDataError); - expect(bufferSubDataError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0881 - * @tc.name testBufferSubData_1_04 - * @tc.desc Test bufferSubData. - */ - it('testBufferSubData_1_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferSubData_1_04 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - gl.bufferSubData(gl2.COPY_WRITE_BUFFER, 512, new ArrayBuffer(8)); - const bufferSubDataError = gl.getError(); - console.info("bufferSubDataError: " + bufferSubDataError); - expect(bufferSubDataError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0882 - * @tc.name testBufferSubData_1_05 - * @tc.desc Test bufferSubData. - */ - it('testBufferSubData_1_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferSubData_1_05 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - gl.bufferSubData(gl2.TRANSFORM_FEEDBACK_BUFFER, 512, new ArrayBuffer(8)); - const bufferSubDataError = gl.getError(); - console.info("bufferSubDataError: " + bufferSubDataError); - expect(bufferSubDataError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0883 - * @tc.name testBufferSubData_1_06 - * @tc.desc Test bufferSubData. - */ - it('testBufferSubData_1_06', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferSubData_1_06 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - gl.bufferSubData(gl2.UNIFORM_BUFFER, 512, new ArrayBuffer(8)); - const bufferSubDataError = gl.getError(); - console.info("bufferSubDataError: " + bufferSubDataError); - expect(bufferSubDataError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0884 - * @tc.name testBufferSubData_1_07 - * @tc.desc Test bufferSubData. - */ - it('testBufferSubData_1_07', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferSubData_1_07 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - gl.bufferSubData(gl2.PIXEL_PACK_BUFFER, 512, new ArrayBuffer(8)); - const bufferSubDataError = gl.getError(); - console.info("bufferSubDataError: " + bufferSubDataError); - expect(bufferSubDataError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0885 - * @tc.name testBufferSubData_1_08 - * @tc.desc Test bufferSubData. - */ - it('testBufferSubData_1_08', 0, async function(done) { - //initContext(); - console.info('jsWebGL testBufferSubData_1_08 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - gl.bufferSubData(gl2.PIXEL_UNPACK_BUFFER, 512, new ArrayBuffer(8)); - const bufferSubDataError = gl.getError(); - console.info("bufferSubDataError: " + bufferSubDataError); - expect(bufferSubDataError).assertEqual(gl.INVALID_VALUE); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0886 - * @tc.name testCompressedTexImage2D_1_01 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexImage2D_1_01 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0x83F3, 512, 512, 0, 0); - const compressedTexImage2DError = gl.getError(); - console.info("compressedTexImage2DError: " + compressedTexImage2DError); - expect(compressedTexImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0887 - * @tc.name testCompressedTexImage2D_1_02 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D_1_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexImage2D_1_02 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0x83F3, 512, 512, 0, 0); - const compressedTexImage2DError = gl.getError(); - console.info("compressedTexImage2DError: " + compressedTexImage2DError); - expect(compressedTexImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0888 - * @tc.name testCompressedTexImage2D_1_03 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D_1_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexImage2D_1_03 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0x83F3, 512, 512, 0, 0); - const compressedTexImage2DError = gl.getError(); - console.info("compressedTexImage2DError: " + compressedTexImage2DError); - expect(compressedTexImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0889 - * @tc.name testCompressedTexImage2D_1_04 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D_1_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexImage2D_1_04 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0x83F3, 512, 512, 0, 0); - const compressedTexImage2DError = gl.getError(); - console.info("compressedTexImage2DError: " + compressedTexImage2DError); - expect(compressedTexImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0890 - * @tc.name testCompressedTexImage2D_1_05 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D_1_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexImage2D_1_05 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0x83F3, 512, 512, 0, 0); - const compressedTexImage2DError = gl.getError(); - console.info("compressedTexImage2DError: " + compressedTexImage2DError); - expect(compressedTexImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0891 - * @tc.name testCompressedTexImage2D_1_06 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D_1_06', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexImage2D_1_06 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0x83F3, 512, 512, 0, 0); - const compressedTexImage2DError = gl.getError(); - console.info("compressedTexImage2DError: " + compressedTexImage2DError); - expect(compressedTexImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0892 - * @tc.name testCompressedTexSubImage2D_1_01 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexSubImage2D_1_01 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); - gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 256, 256, 512, 512, 0x83F3, - gl.PIXEL_UNPACK_BUFFER, 0); - const compressedTexSubImage2DError = gl.getError(); - console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); - expect(compressedTexSubImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0893 - * @tc.name testCompressedTexSubImage2D_1_02 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D_1_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexSubImage2D_1_02 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); - gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 256, 256, 512, 512, 0x83F3, - gl.PIXEL_UNPACK_BUFFER, 0); - const compressedTexSubImage2DError = gl.getError(); - console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); - expect(compressedTexSubImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0894 - * @tc.name testCompressedTexSubImage2D_1_03 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D_1_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexSubImage2D_1_03 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); - gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 256, 256, 512, 512, 0x83F3, - gl.PIXEL_UNPACK_BUFFER, 0); - const compressedTexSubImage2DError = gl.getError(); - console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); - expect(compressedTexSubImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0895 - * @tc.name testCompressedTexSubImage2D_1_04 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D_1_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexSubImage2D_1_04 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); - gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 256, 256, 512, 512, 0x83F3, - gl.PIXEL_UNPACK_BUFFER, 0); - const compressedTexSubImage2DError = gl.getError(); - console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); - expect(compressedTexSubImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0896 - * @tc.name testCompressedTexSubImage2D_1_05 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D_1_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexSubImage2D_1_05 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); - gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 256, 256, 512, 512, 0x83F3, - gl.PIXEL_UNPACK_BUFFER, 0); - const compressedTexSubImage2DError = gl.getError(); - console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); - expect(compressedTexSubImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0897 - * @tc.name testCompressedTexSubImage2D_1_06 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D_1_06', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCompressedTexSubImage2D_1_06 test start ...66'); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); - gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 256, 256, 512, 512, 0x83F3, - gl.PIXEL_UNPACK_BUFFER, 0); - const compressedTexSubImage2DError = gl.getError(); - console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); - expect(compressedTexSubImage2DError).assertEqual(0); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0898 - * @tc.name testTexImage2D_1_01 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D_1_01 test start ...66'); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl - .UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0899 - * @tc.name testTexImage2D_1_02 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_1_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D_1_02 test start ...66'); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl - .UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0900 - * @tc.name testTexImage2D_1_03 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_1_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D_1_03 test start ...66'); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl - .UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test10.js b/graphic/webGL/src/main/js/default/test/WebGL.test10.js deleted file mode 100644 index 792e844d67218b5c3be026ffb043884bff1df9c1..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test10.js +++ /dev/null @@ -1,2047 +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_webgl10', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_0901 - * @tc.name testTexImage2D_1_04 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_1_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D_1_04 test start ...66'); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl - .UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0902 - * @tc.name testTexImage2D_1_05 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_1_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D_1_05 test start ...66'); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl - .UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0903 - * @tc.name testTexImage2D_1_06 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_1_06', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D_1_06 test start ...66'); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl - .UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0904 - * @tc.name testTexImage2D_1_07 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_1_07', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D_1_07 test start ...66'); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0911 - * @tc.name testTexSubImage2D_1_01 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexSubImage2D_1_01 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, - view); - const ttexSubImage2DError = gl.getError(); - console.info("ttexSubImage2DError: " + ttexSubImage2DError); - expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0912 - * @tc.name testTexSubImage2D_1_02 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_1_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexSubImage2D_1_02 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, - view); - const ttexSubImage2DError = gl.getError(); - console.info("ttexSubImage2DError: " + ttexSubImage2DError); - expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0913 - * @tc.name testTexSubImage2D_1_03 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_1_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexSubImage2D_1_03 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, - view); - const ttexSubImage2DError = gl.getError(); - console.info("ttexSubImage2DError: " + ttexSubImage2DError); - expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0914 - * @tc.name testTexSubImage2D_1_04 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_1_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexSubImage2D_1_04 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, - view); - const ttexSubImage2DError = gl.getError(); - console.info("ttexSubImage2DError: " + ttexSubImage2DError); - expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0915 - * @tc.name testTexSubImage2D_1_05 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_1_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexSubImage2D_1_05 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, - view); - const ttexSubImage2DError = gl.getError(); - console.info("ttexSubImage2DError: " + ttexSubImage2DError); - expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0916 - * @tc.name testTexSubImage2D_1_06 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_1_06', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexSubImage2D_1_06 test start ...66'); - const buf = new ArrayBuffer(8); - const view = new DataView(buf, 0); - view[0] = 2; - gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, - view); - const ttexSubImage2DError = gl.getError(); - console.info("ttexSubImage2DError: " + ttexSubImage2DError); - expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0924 - * @tc.name testCopyBufferSubData_1_02 - * @tc.desc Test copyBufferSubData. - */ - it('testCopyBufferSubData_1_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCopyBufferSubData_1_02 test start ...66'); - const srcBuffer = gl.createBuffer(); - const dstBuffer = gl.createBuffer(); - const vertices = [1, 2]; - const data = new Float32Array(vertices); - const length = vertices.length * 4; - gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); - gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); - gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); - gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); - gl2.copyBufferSubData(gl.COPY_READ_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); - const copyBufferSubDataError = gl.getError(); - console.info("copyBufferSubDataError: " + copyBufferSubDataError); - expect(copyBufferSubDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0925 - * @tc.name testCopyBufferSubData_1_03 - * @tc.desc Test copyBufferSubData. - */ - it('testCopyBufferSubData_1_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCopyBufferSubData_1_03 test start ...66'); - const srcBuffer = gl.createBuffer(); - const dstBuffer = gl.createBuffer(); - const vertices = [1, 2]; - const data = new Float32Array(vertices); - const length = vertices.length * 4; - gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); - gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); - gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); - gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); - gl2.copyBufferSubData(gl.COPY_WRITE_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); - const copyBufferSubDataError = gl.getError(); - console.info("copyBufferSubDataError: " + copyBufferSubDataError); - expect(copyBufferSubDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0926 - * @tc.name testCopyBufferSubData_1_04 - * @tc.desc Test copyBufferSubData. - */ - it('testCopyBufferSubData_1_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCopyBufferSubData_1_04 test start ...66'); - const srcBuffer = gl.createBuffer(); - const dstBuffer = gl.createBuffer(); - const vertices = [1, 2]; - const data = new Float32Array(vertices); - const length = vertices.length * 4; - gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); - gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); - gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); - gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); - gl2.copyBufferSubData(gl.TRANSFORM_FEEDBACK_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); - const copyBufferSubDataError = gl.getError(); - console.info("copyBufferSubDataError: " + copyBufferSubDataError); - expect(copyBufferSubDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0927 - * @tc.name testCopyBufferSubData_1_05 - * @tc.desc Test copyBufferSubData. - */ - it('testCopyBufferSubData_1_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCopyBufferSubData_1_05 test start ...66'); - const srcBuffer = gl.createBuffer(); - const dstBuffer = gl.createBuffer(); - const vertices = [1, 2]; - const data = new Float32Array(vertices); - const length = vertices.length * 4; - gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); - gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); - gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); - gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); - gl2.copyBufferSubData(gl.UNIFORM_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); - const copyBufferSubDataError = gl.getError(); - console.info("copyBufferSubDataError: " + copyBufferSubDataError); - expect(copyBufferSubDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0928 - * @tc.name testCopyBufferSubData_1_06 - * @tc.desc Test copyBufferSubData. - */ - it('testCopyBufferSubData_1_06', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCopyBufferSubData_1_06 test start ...66'); - const srcBuffer = gl.createBuffer(); - const dstBuffer = gl.createBuffer(); - const vertices = [1, 2]; - const data = new Float32Array(vertices); - const length = vertices.length * 4; - gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); - gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); - gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); - gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); - gl2.copyBufferSubData(gl.PIXEL_PACK_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); - const copyBufferSubDataError = gl.getError(); - console.info("copyBufferSubDataError: " + copyBufferSubDataError); - expect(copyBufferSubDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0929 - * @tc.name testCopyBufferSubData_1_07 - * @tc.desc Test copyBufferSubData. - */ - it('testCopyBufferSubData_1_07', 0, async function(done) { - //initContext(); - console.info('jsWebGL testCopyBufferSubData_1_07 test start ...66'); - const srcBuffer = gl.createBuffer(); - const dstBuffer = gl.createBuffer(); - const vertices = [1, 2]; - const data = new Float32Array(vertices); - const length = vertices.length * 4; - gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); - gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); - gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); - gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); - gl2.copyBufferSubData(gl.PIXEL_UNPACK_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); - const copyBufferSubDataError = gl.getError(); - console.info("copyBufferSubDataError: " + copyBufferSubDataError); - expect(copyBufferSubDataError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0931 - * @tc.name testGetBufferSubData_1_02 - * @tc.desc Test getBufferSubData. - */ - it('testGetBufferSubData_1_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetBufferSubData_1_02 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const vertices = [1, 2]; - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); - var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); - gl2.getBufferSubData(gl.COPY_READ_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); - const getBufferSubDataError = gl.getError(); - console.info("getBufferSubDataError: " + getBufferSubDataError); - expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0932 - * @tc.name testGetBufferSubData_1_03 - * @tc.desc Test getBufferSubData. - */ - it('testGetBufferSubData_1_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetBufferSubData_1_03 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const vertices = [1, 2]; - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); - var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); - gl2.getBufferSubData(gl.COPY_WRITE_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); - const getBufferSubDataError = gl.getError(); - console.info("getBufferSubDataError: " + getBufferSubDataError); - expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0933 - * @tc.name testGetBufferSubData_1_04 - * @tc.desc Test getBufferSubData. - */ - it('testGetBufferSubData_1_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetBufferSubData_1_04 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const vertices = [1, 2]; - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); - var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); - gl2.getBufferSubData(gl.TRANSFORM_FEEDBACK_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); - const getBufferSubDataError = gl.getError(); - console.info("getBufferSubDataError: " + getBufferSubDataError); - expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0934 - * @tc.name testGetBufferSubData_1_05 - * @tc.desc Test getBufferSubData. - */ - it('testGetBufferSubData_1_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetBufferSubData_1_05 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const vertices = [1, 2]; - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); - var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); - gl2.getBufferSubData(gl.UNIFORM_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); - const getBufferSubDataError = gl.getError(); - console.info("getBufferSubDataError: " + getBufferSubDataError); - expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0935 - * @tc.name testGetBufferSubData_1_06 - * @tc.desc Test getBufferSubData. - */ - it('testGetBufferSubData_1_06', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetBufferSubData_1_06 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const vertices = [1, 2]; - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); - var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); - gl2.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); - const getBufferSubDataError = gl.getError(); - console.info("getBufferSubDataError: " + getBufferSubDataError); - expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0936 - * @tc.name testGetBufferSubData_1_07 - * @tc.desc Test getBufferSubData. - */ - it('testGetBufferSubData_1_07', 0, async function(done) { - //initContext(); - console.info('jsWebGL testGetBufferSubData_1_07 test start ...66'); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const vertices = [1, 2]; - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); - var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); - gl2.getBufferSubData(gl.PIXEL_UNPACK_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); - const getBufferSubDataError = gl.getError(); - console.info("getBufferSubDataError: " + getBufferSubDataError); - expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0937 - * @tc.name testFramebufferTextureLayer_1_01 - * @tc.desc Test framebufferTextureLayer. - */ - it('testFramebufferTextureLayer_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testFramebufferTextureLayer_1_01 test start ...66'); - const texture = gl.createTexture(); - gl.bindTexture(gl2.TEXTURE_2D_ARRAY, texture); - gl2.texStorage3D(gl2.TEXTURE_2D_ARRAY, 1, gl2.RGBA8, 256, 256, 8); - gl.texParameteri(gl2.TEXTURE_CUBE_MAP, gl2.TEXTURE_MAG_FILTER, gl2.NEAREST); - const framebuffer = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - gl2.framebufferTextureLayer(gl.DRAW_FRAMEBUFFER, gl2.COLOR_ATTACHMENT0, texture, 0, 8) - const framebufferTextureLayerError = gl.getError(); - console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); - expect(framebufferTextureLayerError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0938 - * @tc.name testFramebufferTextureLayer_1_02 - * @tc.desc Test framebufferTextureLayer. - */ - it('testFramebufferTextureLayer_1_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testFramebufferTextureLayer_1_02 test start ...66'); - const texture = gl.createTexture(); - gl.bindTexture(gl2.TEXTURE_2D_ARRAY, texture); - gl2.texStorage3D(gl2.TEXTURE_2D_ARRAY, 1, gl2.RGBA8, 256, 256, 8); - gl.texParameteri(gl2.TEXTURE_CUBE_MAP, gl2.TEXTURE_MAG_FILTER, gl2.NEAREST); - const framebuffer = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - gl2.framebufferTextureLayer(gl.READ_FRAMEBUFFER, gl2.COLOR_ATTACHMENT0, texture, 0, 8) - const framebufferTextureLayerError = gl.getError(); - console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); - expect(framebufferTextureLayerError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0939 - * @tc.name testFramebufferTextureLayer_1_03 - * @tc.desc Test framebufferTextureLayer. - */ - it('testFramebufferTextureLayer_1_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testFramebufferTextureLayer_1_03 test start ...66'); - const texture = gl.createTexture(); - gl.bindTexture(gl2.TEXTURE_2D_ARRAY, texture); - gl2.texStorage3D(gl2.TEXTURE_2D_ARRAY, 1, gl2.RGBA8, 256, 256, 8); - gl.texParameteri(gl2.TEXTURE_CUBE_MAP, gl2.TEXTURE_MAG_FILTER, gl2.NEAREST); - const framebuffer = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - gl2.framebufferTextureLayer(gl.FRAMEBUFFER, gl2.DEPTH_ATTACHMENT, texture, 0, 8) - const framebufferTextureLayerError = gl.getError(); - console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); - expect(framebufferTextureLayerError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0940 - * @tc.name testFramebufferTextureLayer_1_04 - * @tc.desc Test framebufferTextureLayer. - */ - it('testFramebufferTextureLayer_1_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testFramebufferTextureLayer_1_04 test start ...66'); - const texture = gl.createTexture(); - gl.bindTexture(gl2.TEXTURE_2D_ARRAY, texture); - gl2.texStorage3D(gl2.TEXTURE_2D_ARRAY, 1, gl2.RGBA8, 256, 256, 8); - gl.texParameteri(gl2.TEXTURE_CUBE_MAP, gl2.TEXTURE_MAG_FILTER, gl2.NEAREST); - const framebuffer = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - gl2.framebufferTextureLayer(gl.FRAMEBUFFER, gl2.STENCIL_ATTACHMENT, texture, 0, 8) - const framebufferTextureLayerError = gl.getError(); - console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); - expect(framebufferTextureLayerError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0941 - * @tc.name testFramebufferTextureLayer_1_05 - * @tc.desc Test framebufferTextureLayer. - */ - it('testFramebufferTextureLayer_1_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testFramebufferTextureLayer_1_05 test start ...66'); - const texture = gl.createTexture(); - gl.bindTexture(gl2.TEXTURE_2D_ARRAY, texture); - gl2.texStorage3D(gl2.TEXTURE_2D_ARRAY, 1, gl2.RGBA8, 256, 256, 8); - gl.texParameteri(gl2.TEXTURE_CUBE_MAP, gl2.TEXTURE_MAG_FILTER, gl2.NEAREST); - const framebuffer = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - gl2.framebufferTextureLayer(gl.FRAMEBUFFER, gl2.DEPTH_STENCIL_ATTACHMENT, texture, 0, 8) - const framebufferTextureLayerError = gl.getError(); - console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); - expect(framebufferTextureLayerError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0942 - * @tc.name testInvalidateFramebuffer_1_01 - * @tc.desc Test invalidateFramebuffer. - */ - it('testInvalidateFramebuffer_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateFramebuffer_1_01 test start ...66'); - gl2.invalidateFramebuffer(gl.DRAW_FRAMEBUFFER, - [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1]); - const invalidateFramebufferError = gl.getError(); - console.info("invalidateFramebufferError: " + invalidateFramebufferError); - expect(invalidateFramebufferError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0943 - * @tc.name testInvalidateFramebuffer_1_02 - * @tc.desc Test invalidateFramebuffer. - */ - it('testInvalidateFramebuffer_1_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateFramebuffer_1_02 test start ...66'); - gl2.invalidateFramebuffer(gl.FRAMEBUFFER, - [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1]); - const invalidateFramebufferError = gl.getError(); - console.info("invalidateFramebufferError: " + invalidateFramebufferError); - expect(invalidateFramebufferError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0944 - * @tc.name testInvalidateFramebuffer_1_03 - * @tc.desc Test invalidateFramebuffer. - */ - it('testInvalidateFramebuffer_1_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateFramebuffer_1_03 test start ...66'); - gl2.invalidateFramebuffer(gl.READ_FRAMEBUFFER, - [gl.COLOR_ATTACHMENT0, gl.DEPTH_ATTACHMENT]); - const invalidateFramebufferError = gl.getError(); - console.info("invalidateFramebufferError: " + invalidateFramebufferError); - expect(invalidateFramebufferError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0945 - * @tc.name testInvalidateFramebuffer_1_04 - * @tc.desc Test invalidateFramebuffer. - */ - it('testInvalidateFramebuffer_1_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateFramebuffer_1_04 test start ...66'); - gl2.invalidateFramebuffer(gl.READ_FRAMEBUFFER, - [gl.STENCIL_ATTACHMENT, gl.COLOR_ATTACHMENT1]); - const invalidateFramebufferError = gl.getError(); - console.info("invalidateFramebufferError: " + invalidateFramebufferError); - expect(invalidateFramebufferError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0946 - * @tc.name testInvalidateFramebuffer_1_05 - * @tc.desc Test invalidateFramebuffer. - */ - it('testInvalidateFramebuffer_1_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateFramebuffer_1_05 test start ...66'); - gl2.invalidateFramebuffer(gl.READ_FRAMEBUFFER, - [gl.DEPTH_STENCIL_ATTACHMENT, gl.COLOR_ATTACHMENT1]); - const invalidateFramebufferError = gl.getError(); - console.info("invalidateFramebufferError: " + invalidateFramebufferError); - expect(invalidateFramebufferError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0947 - * @tc.name testInvalidateFramebuffer_1_06 - * @tc.desc Test invalidateFramebuffer. - */ - it('testInvalidateFramebuffer_1_06', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateFramebuffer_1_06 test start ...66'); - gl2.invalidateFramebuffer(gl.READ_FRAMEBUFFER, - [gl.DEPTH_ATTACHMENT, gl.STENCIL_ATTACHMENT]); - const invalidateFramebufferError = gl.getError(); - console.info("invalidateFramebufferError: " + invalidateFramebufferError); - expect(invalidateFramebufferError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0948 - * @tc.name testInvalidateFramebuffer_1_01 - * @tc.desc Test invalidateFramebuffer. - */ - it('testInvalidateFramebuffer_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateFramebuffer_1_01 test start ...66'); - gl2.invalidateFramebuffer(gl.READ_FRAMEBUFFER, - [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1]); - const invalidateFramebufferError = gl.getError(); - console.info("invalidateFramebufferError: " + invalidateFramebufferError); - expect(invalidateFramebufferError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0949 - * @tc.name testInvalidateSubFramebuffer_1_01 - * @tc.desc Test invalidateSubFramebuffer. - */ - it('testInvalidateSubFramebuffer_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateSubFramebuffer_1_01 test start ...66'); - gl2.invalidateSubFramebuffer(gl.FRAMEBUFFER, - [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1], - 0, 0, 256, 256); - const invalidateSubFramebufferError = gl.getError(); - console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); - expect(invalidateSubFramebufferError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0950 - * @tc.name testInvalidateSubFramebuffer_1_02 - * @tc.desc Test invalidateSubFramebuffer. - */ - it('testInvalidateSubFramebuffer_1_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateSubFramebuffer_1_02 test start ...66'); - gl2.invalidateSubFramebuffer(gl.DRAW_FRAMEBUFFER, - [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1], - 0, 0, 256, 256); - const invalidateSubFramebufferError = gl.getError(); - console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); - expect(invalidateSubFramebufferError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0951 - * @tc.name testInvalidateSubFramebuffer_1_03 - * @tc.desc Test invalidateSubFramebuffer. - */ - it('testInvalidateSubFramebuffer_1_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateSubFramebuffer_1_03 test start ...66'); - gl2.invalidateSubFramebuffer(gl.READ_FRAMEBUFFER, - [gl.DEPTH_ATTACHMENT, gl.COLOR_ATTACHMENT1], - 0, 0, 256, 256); - const invalidateSubFramebufferError = gl.getError(); - console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); - expect(invalidateSubFramebufferError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0952 - * @tc.name testInvalidateSubFramebuffer_1_04 - * @tc.desc Test invalidateSubFramebuffer. - */ - it('testInvalidateSubFramebuffer_1_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateSubFramebuffer_1_04 test start ...66'); - gl2.invalidateSubFramebuffer(gl.READ_FRAMEBUFFER, - [gl.COLOR_ATTACHMENT0, gl.STENCIL_ATTACHMENT], - 0, 0, 256, 256); - const invalidateSubFramebufferError = gl.getError(); - console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); - expect(invalidateSubFramebufferError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0953 - * @tc.name testInvalidateSubFramebuffer_1_05 - * @tc.desc Test invalidateSubFramebuffer. - */ - it('testInvalidateSubFramebuffer_1_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testInvalidateSubFramebuffer_1_05 test start ...66'); - gl2.invalidateSubFramebuffer(gl.READ_FRAMEBUFFER, - [gl.DEPTH_STENCIL_ATTACHMENT, gl.STENCIL_ATTACHMENT], - 0, 0, 256, 256); - const invalidateSubFramebufferError = gl.getError(); - console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); - expect(invalidateSubFramebufferError).assertEqual(0); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0954 - * @tc.name testRenderbufferStorageMultisample_1_01 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample_1_01 test start ...66'); - gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R8, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0955 - * @tc.name testRenderbufferStorageMultisample_1_02 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_1_02', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample_1_02 test start ...66'); - gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R8UI, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0956 - * @tc.name testRenderbufferStorageMultisample_1_03 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_1_03', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample_1_03 test start ...66'); - gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R8I, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0957 - * @tc.name testRenderbufferStorageMultisample_1_04 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_1_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample_1_04 test start ...66'); - gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R16UI, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0958 - * @tc.name testRenderbufferStorageMultisample_1_05 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_1_05', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample_1_05 test start ...66'); - gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R16I, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0959 - * @tc.name testRenderbufferStorageMultisample_1_06 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_1_06', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample_1_06 test start ...66'); - gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R32UI, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0960 - * @tc.name testRenderbufferStorageMultisample_1_07 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_1_07', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample_1_07 test start ...66'); - gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R32I, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(0); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0961 - * @tc.name testRenderbufferStorageMultisample_1_08 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_1_08', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample_1_08 test start ...66'); - gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.RG8, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(0); - done(); - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0962 - * @tc.name testTexStorage2D_1_01 - * @tc.desc Test texStorage2D. - */ - it('testTexStorage2D_1_01', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexStorage2D_1_01 test start ...66'); - gl2.texStorage2D(gl.TEXTURE_CUBE_MAP, 1, gl.RGB8, 256, 256); - const texStorage2DError = gl.getError(); - console.info("texStorage2DError: " + texStorage2DError); - expect(texStorage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0963 - * @tc.name testBindBufferBase_1_01 - * @tc.desc Test bindBufferBase. - */ - it('testBindBufferBase_1_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testBindBufferBase_1_01 test start ...66'); - let buffer = gl.createBuffer(); - gl2.bindBufferBase(gl.UNIFORM_BUFFER, 0, buffer); - const bindBufferBaseError = gl.getError(); - console.info("bindBufferBaseError: " + bindBufferBaseError); - expect(bindBufferBaseError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("bindBufferBaseError has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0964 - * @tc.name bindBufferRange_1_01 - * @tc.desc Test bindBufferRange. - */ - it('bindBufferRange_1_01', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL bindBufferRange_1_01 test start ...66'); - const buffer = gl.createBuffer(); - gl2.bindBufferRange(gl.UNIFORM_BUFFER, 1, buffer, 0, 4); - const bindBufferRangeError = gl.getError(); - console.info("bindBufferRangeError: " + bindBufferRangeError); - expect(bindBufferRangeError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("bindBufferRange has failed for " + e) - expect(null).assertFail() - } - }) - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0965 - * @tc.name testVertexAttrib2f2 - * @tc.desc Test vertexAttrib2f. - */ - it('testVertexAttrib2f2', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib2f test start ...66'); - gl.vertexAttrib2f(1, 10.0, 10.0); - const vertexAttrib2fError = gl.getError(); - console.info("vertexAttrib2fError: " + vertexAttrib2fError); - expect(vertexAttrib2fError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib2f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0966 - * @tc.name testVertexAttrib3f2 - * @tc.desc Test vertexAttrib3f. - */ - it('testVertexAttrib3f2', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testvertexAttrib3f test start ...66'); - console.info('jsWebGL testvertexAttrib3f test start ...' + JSON.stringify(gl)); - gl.vertexAttrib3f(1, 10.0, 10.0, 10.0); - const vertexAttrib3fError = gl.getError(); - console.info("vertexAttrib3fError: " + vertexAttrib3fError); - expect(vertexAttrib3fError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib3f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0967 - * @tc.name testVertexAttrib4f2 - * @tc.desc Test vertexAttrib4f. - */ - it('testVertexAttrib4f2', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib4f test start ...66'); - console.info('jsWebGL testVertexAttrib4f test start ...' + JSON.stringify(gl)); - gl.vertexAttrib4f(1, 10.0, 10.0, 10.0, 10.0); - const vertexAttrib4fError = gl.getError(); - console.info("vertexAttrib4fError: " + vertexAttrib4fError); - expect(vertexAttrib4fError).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - } catch (e) { - console.log("testvertexAttrib4f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0968 - * @tc.name testVertexAttrib1f2 - * @tc.desc Test vertexAttrib1f. - */ - it('testVertexAttrib1f2', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib1f test start ...66'); - console.info('jsWebGL testVertexAttrib1f test start ...' + JSON.stringify(gl)); - gl.vertexAttrib1f(-1, 10.0); - const vertexAttrib1fError = gl.getError(); - console.info("vertexAttrib1fError: " + vertexAttrib1fError); - expect(vertexAttrib1fError).assertEqual(gl.INVALID_VALUE); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib1f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0969 - * @tc.name testVertexAttrib2f3 - * @tc.desc Test vertexAttrib2f. - */ - it('testVertexAttrib2f3', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib2f test start ...66'); - gl.vertexAttrib2f(-1, 10.0, 10.0); - const vertexAttrib2fError = gl.getError(); - console.info("vertexAttrib2fError: " + vertexAttrib2fError); - expect(vertexAttrib2fError).assertEqual(gl.INVALID_VALUE); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib2f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0970 - * @tc.name testVertexAttrib3f3 - * @tc.desc Test vertexAttrib3f. - */ - it('testVertexAttrib3f3', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testvertexAttrib3f test start ...66'); - console.info('jsWebGL testvertexAttrib3f test start ...' + JSON.stringify(gl)); - gl.vertexAttrib3f(-1, 10.0, 10.0, 10.0); - const vertexAttrib3fError = gl.getError(); - console.info("vertexAttrib3fError: " + vertexAttrib3fError); - expect(vertexAttrib3fError).assertEqual(gl.INVALID_VALUE); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttrib3f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0971 - * @tc.name testVertexAttrib4f22 - * @tc.desc Test vertexAttrib4f. - */ - it('testVertexAttrib4f22', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttrib4f test start ...66'); - console.info('jsWebGL testVertexAttrib4f test start ...' + JSON.stringify(gl)); - gl.vertexAttrib4f(-1, 10.0, 10.0, 10.0, 10.0); - const vertexAttrib4fError = gl.getError(); - console.info("vertexAttrib4fError: " + vertexAttrib4fError); - expect(vertexAttrib4fError).assertEqual(gl.INVALID_VALUE); - //deleteContext(); - done(); - } catch (e) { - console.log("testvertexAttrib4f has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0972 - * @tc.name testVertexAttribPointer2 - * @tc.desc Test vertexAttribPointer. - */ - it('testVertexAttribPointer2', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttribPointer test start ...66'); - console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); - gl.vertexAttribPointer(1, 4, gl.BYTE, true, 20, 12); - const vertexAttribPointerError = gl.getError(); - console.info("vertexAttribPointerError: " + vertexAttribPointerError); - expect(vertexAttribPointerError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttribPointer has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0973 - * @tc.name testVertexAttribPointer3 - * @tc.desc Test vertexAttribPointer. - */ - it('testVertexAttribPointer3', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttribPointer test start ...66'); - console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); - gl.vertexAttribPointer(2, 2, gl.UNSIGNED_SHORT, true, 20, 16); - const vertexAttribPointerError = gl.getError(); - console.info("vertexAttribPointerError: " + vertexAttribPointerError); - expect(vertexAttribPointerError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttribPointer has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0974 - * @tc.name testVertexAttribPointer4 - * @tc.desc Test vertexAttribPointer. - */ - it('testVertexAttribPointer4', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttribPointer test start ...66'); - console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); - console.info("webgltest into enableVertexAttribArray"); - //顶点着色器程序 - 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); - const locPosition = gl.getAttribLocation(programObj, 'position'); - gl.vertexAttribPointer(locPosition, 3, gl.FLOAT, false, 20, 0); - const vertexAttribPointerError = gl.getError(); - console.info("vertexAttribPointerError: " + vertexAttribPointerError); - expect(vertexAttribPointerError).assertEqual(gl.INVALID_VALUE); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttribPointer has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0975 - * @tc.name testVertexAttribPointer5 - * @tc.desc Test vertexAttribPointer. - */ - it('testVertexAttribPointer5', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttribPointer test start ...66'); - console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); - console.info("webgltest into enableVertexAttribArray"); - //顶点着色器程序 - 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); - const locNormal = gl.getAttribLocation(programObj, 'normal'); - gl.vertexAttribPointer(locNormal, 4, gl.BYTE, true, 20, 12); - const vertexAttribPointerError = gl.getError(); - console.info("vertexAttribPointerError: " + vertexAttribPointerError); - expect(vertexAttribPointerError).assertEqual(gl.INVALID_VALUE); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttribPointer has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0976 - * @tc.name testVertexAttribPointer6 - * @tc.desc Test vertexAttribPointer. - */ - it('testVertexAttribPointer6', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttribPointer test start ...66'); - console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(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); - const locTexUV = gl.getAttribLocation(programObj, 'texUV'); - gl.vertexAttribPointer(locTexUV, 2, gl.UNSIGNED_SHORT, true, 20, 16); - const vertexAttribPointerError = gl.getError(); - console.info("vertexAttribPointerError: " + vertexAttribPointerError); - expect(vertexAttribPointerError).assertEqual(gl.INVALID_VALUE); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttribPointer has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0977 - * @tc.name testTexImage3D2 - * @tc.desc Test texImage3D. - */ - it('testTexImage3D2', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D test start ...66'); - console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); - gl2.texImage3D(gl2.TEXTURE_3D, 0, gl.R8, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0978 - * @tc.name testTexImage3D3 - * @tc.desc Test texImage3D. - */ - it('testTexImage3D3', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D test start ...66'); - console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); - gl2.texImage3D(gl2.TEXTURE_3D, 0, gl.LUMINANCE, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, - 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0979 - * @tc.name testTexImage3D4 - * @tc.desc Test texImage3D. - */ - it('testTexImage3D4', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D test start ...66'); - console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); - gl2.texImage3D(gl2.TEXTURE_3D, 0, gl.RGB8UI, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0980 - * @tc.name testTexSubImage3D - * @tc.desc Test texSubImage3D. - */ - it('testTexSubImage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexSubImage3D test start ...66'); - console.info('jsWebGL testTexSubImage3D test start ...' + JSON.stringify(gl)); - gl2.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 200, 200, 1, gl.RGB8UI, gl.UNSIGNED_BYTE, - 1); - const texSubImage3DError = gl.getError(); - console.info("texSubImage3DError: " + texSubImage3DError); - expect(texSubImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexSubImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0981 - * @tc.name testTexSubImage3D - * @tc.desc Test texSubImage3D. - */ - it('testTexSubImage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexSubImage3D test start ...66'); - console.info('jsWebGL testTexSubImage3D test start ...' + JSON.stringify(gl)); - gl2.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 200, 200, 1, gl.R8, gl.UNSIGNED_BYTE, 1); - const texSubImage3DError = gl.getError(); - console.info("texSubImage3DError: " + texSubImage3DError); - expect(texSubImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexSubImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0982 - * @tc.name testTexSubImage3D - * @tc.desc Test texSubImage3D. - */ - it('testTexSubImage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexSubImage3D test start ...66'); - console.info('jsWebGL testTexSubImage3D test start ...' + JSON.stringify(gl)); - gl2.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 200, 200, 1, gl.LUMINANCE, gl - .UNSIGNED_BYTE, 1); - const texSubImage3DError = gl.getError(); - console.info("texSubImage3DError: " + texSubImage3DError); - expect(texSubImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexSubImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0983 - * @tc.name testCompressedTexImage3D - * @tc.desc Test compressedTexImage3D. - */ - it('testCompressedTexImage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexImage3D test start ...66'); - console.info('jsWebGL testCompressedTexImage3D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - gl2.compressedTexImage3D(gl.TEXTURE_3D, 0, 0x83F0, 512, 512, 0, buffer); - const compressedTexImage3DError = gl.getError(); - console.info("compressedTexImage3DError: " + compressedTexImage3DError); - expect(compressedTexImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0984 - * @tc.name testCompressedTexImage3D - * @tc.desc Test compressedTexImage3D. - */ - it('testCompressedTexImage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexImage3D test start ...66'); - console.info('jsWebGL testCompressedTexImage3D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - gl2.compressedTexImage3D(gl.TEXTURE_3D, 0, 0x83F0, 512, 512, 0, buffer, 0, 0); - const compressedTexImage3DError = gl.getError(); - console.info("compressedTexImage3DError: " + compressedTexImage3DError); - expect(compressedTexImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0985 - * @tc.name testCompressedTexImage3D - * @tc.desc Test compressedTexImage3D. - */ - it('testCompressedTexImage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexImage3D test start ...66'); - console.info('jsWebGL testCompressedTexImage3D test start ...' + JSON.stringify(gl)); - gl2.compressedTexImage3D(gl.TEXTURE_3D, 0, 0x83F0, 512, 512, 0, gl2.PIXEL_UNPACK_BUFFER, - 0); - const compressedTexImage3DError = gl.getError(); - console.info("compressedTexImage3DError: " + compressedTexImage3DError); - expect(compressedTexImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0986 - * @tc.name testCompressedTexImage3D - * @tc.desc Test compressedTexImage3D. - */ - it('testCompressedTexImage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexImage3D test start ...66'); - console.info('jsWebGL testCompressedTexImage3D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - gl2.compressedTexImage3D(gl.TEXTURE_3D, false, 0x83F0, 512, 512, 0, buffer); - const compressedTexImage3DError = gl.getError(); - console.info("compressedTexImage3DError: " + compressedTexImage3DError); - expect(compressedTexImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0987 - * @tc.name testCompressedTexImage3D - * @tc.desc Test compressedTexImage3D. - */ - it('testCompressedTexImage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexImage3D test start ...66'); - console.info('jsWebGL testCompressedTexImage3D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - gl2.compressedTexImage3D(gl.TEXTURE_3D, false, 0x83F0, 512, 512, 0, buffer, 0, 0); - const compressedTexImage3DError = gl.getError(); - console.info("compressedTexImage3DError: " + compressedTexImage3DError); - expect(compressedTexImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0988 - * @tc.name testCompressedTexImage3D - * @tc.desc Test compressedTexImage3D. - */ - it('testCompressedTexImage3D', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testCompressedTexImage3D test start ...66'); - console.info('jsWebGL testCompressedTexImage3D test start ...' + JSON.stringify(gl)); - gl2.compressedTexImage3D(gl.TEXTURE_3D, false, 0x83F0, 512, 512, 0, gl2 - .PIXEL_UNPACK_BUFFER, 0); - const compressedTexImage3DError = gl.getError(); - console.info("compressedTexImage3DError: " + compressedTexImage3DError); - expect(compressedTexImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testCompressedTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0989 - * @tc.name testFrontFace2 - * @tc.desc Test frontFace. - */ - it('testFrontFace2', 0, async function(done) { - //initContext(); - console.info('jsWebGL frontFace test start ...' + JSON.stringify(gl)); - gl.enable(gl.CULL_FACE); - gl.cullFace(gl.FRONT_AND_BACK); - gl.frontFace(gl.CCW); - const frontFaceParameter = gl.getParameter(gl.CULL_FACE_MODE); - console.info('frontFace -> frontFaceParameter' + frontFaceParameter); - gl.disable(gl.CULL_FACE); - expect(frontFaceParameter).assertEqual(gl.FRONT_AND_BACK); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0990 - * @tc.name testGenerateMipmap2 - * @tc.desc Test generateMipmap. - */ - it('testGenerateMipmap2', 0, async function(done) { - //initContext(); - console.info('jsWebGL generateMipmap test start ...' + JSON.stringify(gl)); - gl.generateMipmap(gl2.TEXTURE_CUBE_MAP); - const error = gl.getError(); - console.info('generateMipmap error ' + error); - expect(error).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0993 - * @tc.name testGetFramebufferAttachmentParameter2 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter2', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .STENCIL_ATTACHMENT, - gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0994 - * @tc.name testGetFramebufferAttachmentParameter3 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0995 - * @tc.name testGetShaderPrecisionFormat1 - * @tc.desc Test getShaderPrecisionFormat. - */ - it('testGetShaderPrecisionFormat1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); - const shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_FLOAT); - console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); - const type = ((typeof shaderPrecisionFormat) === "object") - expect(type).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0996 - * @tc.name testGetShaderPrecisionFormat2 - * @tc.desc Test getShaderPrecisionFormat. - */ - it('testGetShaderPrecisionFormat2', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); - const shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl - .HIGH_FLOAT); - console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); - const type = ((typeof shaderPrecisionFormat) === "object") - expect(type).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0997 - * @tc.name testGetShaderPrecisionFormat3 - * @tc.desc Test getShaderPrecisionFormat. - */ - it('testGetShaderPrecisionFormat3', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); - const shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT); - console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); - const type = ((typeof shaderPrecisionFormat) === "object") - expect(type).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0998 - * @tc.name testGetShaderPrecisionFormat4 - * @tc.desc Test getShaderPrecisionFormat. - */ - it('testGetShaderPrecisionFormat4', 0, async function(done) { - //initContext(); - console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); - const shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl - .MEDIUM_INT); - console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); - const type = ((typeof shaderPrecisionFormat) === "object") - expect(type).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0999 - * @tc.name testGetTexParameter3 - * @tc.desc Test getTexParameter. - */ - it('testGetTexParameter3', 0, async function(done) { - //initContext(); - console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); - gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(gl.LINEAR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1000 - * @tc.name testGetActiveUniformBlockParameter1 - * @tc.desc Test getActiveUniformBlockParameter. - */ - it('testGetActiveUniformBlockParameter1', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( - gl2)); - const program = globalFunction(); - const uniformLocation = gl.getUniformLocation(program, "a_Position"); - const int32Array = new Int32Array([1, 2]); - gl2.uniform1iv(uniformLocation, int32Array); - const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); - gl2.uniformBlockBinding(program, blockIndex, 1); - const blockSize = gl2.getActiveUniformBlockParameter(program, blockIndex, - gl.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER); - console.info("getActiveUniformBlockParameter blockSize" + blockSize); - const errorCode = gl.getError(); - console.info("jsWebGL getActiveUniformBlockParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_VALUE); - done(); - }); -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test11.js b/graphic/webGL/src/main/js/default/test/WebGL.test11.js deleted file mode 100644 index dc16cbf55c54387f468de61548aa3cb60276e990..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test11.js +++ /dev/null @@ -1,2101 +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_webgl11', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_1001 - * @tc.name testBufferDataFirst - * @tc.desc Test bufferData. - */ - it('testBufferDataFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - const buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl2.bufferData(gl2.ELEMENT_ARRAY_BUFFER, 1024, gl2.DYNAMIC_DRAW); - const errorCode = gl.getError(); - console.info("webgl2test bufferData getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1002 - * @tc.name testBufferData__2 - * @tc.desc Test bufferData. - */ - it('testBufferData__2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - const buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl2.bufferData(gl2.ELEMENT_ARRAY_BUFFER, 1024, gl2.DYNAMIC_DRAW); - const errorCode = gl.getError(); - console.info("webgl2test bufferData getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1003 - * @tc.name testBufferData__3 - * @tc.desc Test bufferData. - */ - it('testBufferData__3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - const buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl2.bufferData(gl2.COPY_READ_BUFFER, 1024, gl2.STREAM_DRAW); - const errorCode = gl.getError(); - console.info("webgl2test bufferData getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1004 - * @tc.name testBufferData__4 - * @tc.desc Test bufferData. - */ - it('testBufferData__4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - const buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl2.bufferData(gl2.COPY_READ_BUFFER, 1024, gl2.STREAM_DRAW); - const errorCode = gl.getError(); - console.info("webgl2test bufferData getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1005 - * @tc.name testBufferData__3 - * @tc.desc Test bufferData. - */ - it('testBufferData__3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - const buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl2.bufferData(gl2.COPY_READ_BUFFER, 1024, gl2.STREAM_DRAW); - const errorCode = gl.getError(); - console.info("webgl2test bufferData getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1006 - * @tc.name testBufferSubData__1 - * @tc.desc Test bufferData. - */ - it('testBufferSubData__1', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - gl2.bufferSubData(gl2.ELEMENT_ARRAY_BUFFER, 512, new ArrayBuffer(8)); - const errorCode = gl.getError(); - console.info("webgl2test bufferSubData getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1007 - * @tc.name testBufferSubData__2 - * @tc.desc Test bufferData. - */ - it('testBufferSubData__2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - gl2.bufferSubData(gl.ARRAY_BUFFER, 512, new ArrayBuffer(8)); - const errorCode = gl.getError(); - console.info("webgl2test bufferSubData getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_VALUE); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1008 - * @tc.name testBufferSubData__3 - * @tc.desc Test bufferData. - */ - it('testBufferSubData__3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); - gl2.bufferSubData(gl.COPY_WRITE_BUFFER, 512, new ArrayBuffer(8)); - const errorCode = gl.getError(); - console.info("webgl2test bufferSubData getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1009 - * @tc.name testTexImage2D__1 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D__1', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 32, 512, 512, 0, 32, 32, view); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1010 - * @tc.name testTexImage2D__2 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D__2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 32, 512, 512, 0, 32, 32, view); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1011 - * @tc.name testTexImage2D__3 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D__3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 32, 512, 512, 0, 32, 32, view); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1012 - * @tc.name testTexSubImage2D__1 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D__1', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texSubImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 512, 512, gl.RED, gl.FLOAT, - view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1013 - * @tc.name testTexSubImage2D__2 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texSubImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 512, 512, gl.RED, gl.FLOAT, - view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1014 - * @tc.name testTexSubImage2D__3 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texSubImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 512, 512, gl.RED, gl.FLOAT, - view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1015 - * @tc.name testCompressedTexImage2D__1 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D__1', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 compressedTexImage2D test start ...' + JSON.stringify(gl2)); - gl2.compressedTexImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0x83F3, 512, 512, 0, gl - .PIXEL_UNPACK_BUFFER, 0); - const errorCode = gl.getError(); - console.info("webgl2test compressedTexImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1016 - * @tc.name testCompressedTexImage2D__2 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D__2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 compressedTexImage2D test start ...' + JSON.stringify(gl2)); - gl2.compressedTexImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0x83F3, 512, 512, 0, gl - .PIXEL_UNPACK_BUFFER, 0); - const errorCode = gl.getError(); - console.info("webgl2test compressedTexImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1017 - * @tc.name testCompressedTexImage2D__3 - * @tc.desc Test compressedTexImage2D. - */ - it('testCompressedTexImage2D__3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 compressedTexImage2D test start ...' + JSON.stringify(gl2)); - gl2.compressedTexImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0x83F3, 512, 512, 0, gl - .PIXEL_UNPACK_BUFFER, 0); - const errorCode = gl.getError(); - console.info("webgl2test compressedTexImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1018 - * @tc.name testCompressedTexSubImage2D__1 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D__1', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 compressedTexSubImage2D test start ...' + JSON.stringify(gl2)); - gl2.compressedTexSubImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 256, 256, 512, 512, 0x83F3, - gl.PIXEL_UNPACK_BUFFER, 0); - const errorCode = gl.getError(); - console.info("webgl2test compressedTexSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1019 - * @tc.name testCompressedTexSubImage2D__2 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D__2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 compressedTexSubImage2D test start ...' + JSON.stringify(gl2)); - gl2.compressedTexSubImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 256, 256, 512, 512, 0x83F3, - gl.PIXEL_UNPACK_BUFFER, 0); - const errorCode = gl.getError(); - console.info("webgl2test compressedTexSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1020 - * @tc.name testCompressedTexSubImage2D__3 - * @tc.desc Test compressedTexSubImage2D. - */ - it('testCompressedTexSubImage2D__3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 compressedTexSubImage2D test start ...' + JSON.stringify(gl2)); - gl2.compressedTexSubImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 256, 256, 512, 512, 0x83F3, - gl.PIXEL_UNPACK_BUFFER, 0); - const errorCode = gl.getError(); - console.info("webgl2test compressedTexSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1021 - * @tc.name testHint1 - * @tc.desc Test hint. - */ - it('testHint1', 0, async function(done) { - //initContext(); - console.info('jsWebGL hint test start ...' + JSON.stringify(gl)); - gl.hint(gl.GENERATE_MIPMAP_HINT, gl.NICEST); - gl.generateMipmap(gl2.TEXTURE_2D); - const error = gl.getError(); - console.info('error' + error); - expect(error).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1022 - * @tc.name testHint2 - * @tc.desc Test hint. - */ - it('testHint2', 0, async function(done) { - //initContext(); - console.info('jsWebGL hint test start ...' + JSON.stringify(gl)); - gl.hint(gl.GENERATE_MIPMAP_HINT, gl.DONT_CARE); - gl.generateMipmap(gl2.TEXTURE_2D); - const error = gl.getError(); - console.info('error' + error); - expect(error).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1023 - * @tc.name testIsEnabled1 - * @tc.desc Test isEnabled. - */ - it('testIsEnabled1', 0, async function(done) { - //initContext(); - console.info('jsWebGL isEnabled test start ...' + JSON.stringify(gl)); - - gl.enable(gl.CULL_FACE); - const isEnabledValue1 = gl.isEnabled(gl.CULL_FACE); - console.info("isEnabledValue1: " + isEnabledValue1); - expect(isEnabledValue1).assertEqual(true); - - // false - // 启用或说明给定的能力项,使用WebGLRenderingContext.enable()方法和WebGLRenderingContext.disable()方法: - gl.disable(gl.CULL_FACE); - const isEnabledValue2 = gl.isEnabled(gl.CULL_FACE); - console.info("isEnabledValue2: " + isEnabledValue2); - expect(isEnabledValue2).assertEqual(false); - - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1024 - * @tc.name testIsEnabled2 - * @tc.desc Test isEnabled. - */ - it('testIsEnabled2', 0, async function(done) { - //initContext(); - console.info('jsWebGL isEnabled test start ...' + JSON.stringify(gl)); - - gl.enable(gl.BLEND); - const isEnabledValue1 = gl.isEnabled(gl.BLEND); - console.info("isEnabledValue1: " + isEnabledValue1); - expect(isEnabledValue1).assertEqual(true); - - // false - // 启用或说明给定的能力项,使用WebGLRenderingContext.enable()方法和WebGLRenderingContext.disable()方法: - gl.disable(gl.BLEND); - const isEnabledValue2 = gl.isEnabled(gl.BLEND); - console.info("isEnabledValue2: " + isEnabledValue2); - expect(isEnabledValue2).assertEqual(false); - - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1025 - * @tc.name testIsEnabled3 - * @tc.desc Test isEnabled. - */ - it('testIsEnabled3', 0, async function(done) { - //initContext(); - console.info('jsWebGL isEnabled test start ...' + JSON.stringify(gl)); - - gl.enable(gl.POLYGON_OFFSET_FILL); - const isEnabledValue1 = gl.isEnabled(gl.POLYGON_OFFSET_FILL); - console.info("isEnabledValue1: " + isEnabledValue1); - expect(isEnabledValue1).assertEqual(true); - - // false - // 启用或说明给定的能力项,使用WebGLRenderingContext.enable()方法和WebGLRenderingContext.disable()方法: - gl.disable(gl.POLYGON_OFFSET_FILL); - const isEnabledValue2 = gl.isEnabled(gl.POLYGON_OFFSET_FILL); - console.info("isEnabledValue2: " + isEnabledValue2); - expect(isEnabledValue2).assertEqual(false); - - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1026 - * @tc.name testIsEnabled4 - * @tc.desc Test isEnabled. - */ - it('testIsEnabled4', 0, async function(done) { - //initContext(); - console.info('jsWebGL isEnabled test start ...' + JSON.stringify(gl)); - - gl.enable(gl.SAMPLE_COVERAGE); - const isEnabledValue1 = gl.isEnabled(gl.SAMPLE_COVERAGE); - console.info("isEnabledValue1: " + isEnabledValue1); - expect(isEnabledValue1).assertEqual(true); - - // false - // 启用或说明给定的能力项,使用WebGLRenderingContext.enable()方法和WebGLRenderingContext.disable()方法: - gl.disable(gl.SAMPLE_COVERAGE); - const isEnabledValue2 = gl.isEnabled(gl.SAMPLE_COVERAGE); - console.info("isEnabledValue2: " + isEnabledValue2); - expect(isEnabledValue2).assertEqual(false); - - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1027 - * @tc.name testRenderbufferStorage1 - * @tc.desc Test renderbufferStorage. - */ - it('testRenderbufferStorage1', 0, async function(done) { - //initContext(); - console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGB565, 256, 256); - - const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT); - expect(width).assertEqual(gl.RGB565); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1028 - * @tc.name testRenderbufferStorage2 - * @tc.desc Test renderbufferStorage. - */ - it('testRenderbufferStorage2', 0, async function(done) { - //initContext(); - console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGB5_A1, 256, 256); - - const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT); - expect(width).assertEqual(gl.RGB5_A1); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1029 - * @tc.name testRenderbufferStorage3 - * @tc.desc Test renderbufferStorage. - */ - it('testRenderbufferStorage3', 0, async function(done) { - //initContext(); - console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, 256, 256); - - const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT); - expect(width).assertEqual(gl.RGBA4); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1030 - * @tc.name testStencilFunc1 - * @tc.desc Test stencilFunc. - */ - it('testStencilFunc1', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilFunc test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - gl.stencilFunc(gl.NEVER, 0, 0b1110011); - const stencilFuncParameter = gl.getParameter(gl.STENCIL_FUNC); - console.info("stencilFunc stencilFuncParameter: " + stencilFuncParameter); - expect(stencilFuncParameter).assertEqual(gl.NEVER); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1031 - * @tc.name testStencilFunc2 - * @tc.desc Test stencilFunc. - */ - it('testStencilFunc2', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilFunc test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - gl.stencilFunc(gl.EQUAL, 0, 0b1110011); - const stencilFuncParameter = gl.getParameter(gl.STENCIL_FUNC); - console.info("stencilFunc stencilFuncParameter: " + stencilFuncParameter); - expect(stencilFuncParameter).assertEqual(gl.EQUAL); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1032 - * @tc.name testStencilFunc3 - * @tc.desc Test stencilFunc. - */ - it('testStencilFunc3', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilFunc test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - gl.stencilFunc(gl.GREATER, 0, 0b1110011); - const stencilFuncParameter = gl.getParameter(gl.STENCIL_FUNC); - console.info("stencilFunc stencilFuncParameter: " + stencilFuncParameter); - expect(stencilFuncParameter).assertEqual(gl.GREATER); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1033 - * @tc.name testStencilFuncSeparate1 - * @tc.desc Test stencilFuncSeparate. - */ - it('testStencilFuncSeparate1', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilFuncSeparate test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - gl.stencilFuncSeparate(gl.BACK, gl.EQUAL, 0.2, 1110011); - const stencilFuncSeparateParameter = gl.getParameter(gl.STENCIL_FUNC); - console.info("stencilFuncSeparate stencilFuncSeparateParameter: " + - stencilFuncSeparateParameter); - expect(stencilFuncSeparateParameter).assertEqual(gl.GREATER); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1034 - * @tc.name testStencilFuncSeparate2 - * @tc.desc Test stencilFuncSeparate. - */ - it('testStencilFuncSeparate2', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilFuncSeparate test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - gl.stencilFuncSeparate(gl.FRONT_AND_BACK, gl.LEQUAL, 0.2, 1110011); - const stencilFuncSeparateParameter = gl.getParameter(gl.STENCIL_FUNC); - console.info("stencilFuncSeparate stencilFuncSeparateParameter: " + - stencilFuncSeparateParameter); - expect(stencilFuncSeparateParameter).assertEqual(gl.LEQUAL); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1036 - * @tc.name testStencilMaskSeparate2 - * @tc.desc Test stencilMaskSeparate. - */ - it('testStencilMaskSeparate2', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilMaskSeparate test start ...' + JSON.stringify(gl)); - gl.stencilMaskSeparate(gl.FRONT_AND_BACK, 110101); - const stencilMaskSeparateParameter = gl.getParameter(gl.STENCIL_WRITEMASK); - console.info("stencilMaskSeparate stencilMaskSeparateParameter: " + - stencilMaskSeparateParameter); - expect(stencilMaskSeparateParameter).assertEqual(110101); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1037 - * @tc.name webgl_test_bindFramebuffer_1 - * @tc.desc Test bindFramebuffer. - */ - it('webgl_test_bindFramebuffer_1', 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(gl2.READ_FRAMEBUFFER, framebuffer); - - const isFrameBuffer2 = gl.isFramebuffer(framebuffer); - console.info("createFramebuffer --> bindFramebuffer --> isFramebuffer_2: " + - isFrameBuffer2); - expect(isFrameBuffer2).assertEqual(true); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1038 - * @tc.name webgl_test_bindFramebuffer_2 - * @tc.desc Test bindFramebuffer. - */ - it('webgl_test_bindFramebuffer_2', 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(gl2.DRAW_FRAMEBUFFER, framebuffer); - - const isFrameBuffer2 = gl.isFramebuffer(framebuffer); - console.info("createFramebuffer --> bindFramebuffer --> isFramebuffer_2: " + - isFrameBuffer2); - expect(isFrameBuffer2).assertEqual(true); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1039 - * @tc.name testGetRenderbufferParameter_1 - * @tc.desc Test getRenderbufferParameter. - */ - it('testGetRenderbufferParameter_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); - - const height = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_HEIGHT); - expect(height).assertEqual(256); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1040 - * @tc.name testGetRenderbufferParameter_2 - * @tc.desc Test getRenderbufferParameter. - */ - it('testGetRenderbufferParameter_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); - - const size = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_BLUE_SIZE); - expect(size).assertEqual(4); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1041 - * @tc.name testGetRenderbufferParameter_3 - * @tc.desc Test getRenderbufferParameter. - */ - it('testGetRenderbufferParameter_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); - - const size = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_RED_SIZE); - expect(size).assertEqual(4); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1042 - * @tc.name testGetRenderbufferParameter_4 - * @tc.desc Test getRenderbufferParameter. - */ - it('testGetRenderbufferParameter_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); - - const size = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_ALPHA_SIZE); - expect(size).assertEqual(4); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1043 - * @tc.name testGetRenderbufferParameter_5 - * @tc.desc Test getRenderbufferParameter. - */ - it('testGetRenderbufferParameter_5', 0, async function(done) { - //initContext(); - console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); - const size = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_DEPTH_SIZE); - expect(size).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1044 - * @tc.name testGetRenderbufferParameter_6 - * @tc.desc Test getRenderbufferParameter. - */ - it('testGetRenderbufferParameter_6', 0, async function(done) { - //initContext(); - console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl2.RENDERBUFFER, renderBuffer); - gl2.renderbufferStorageMultisample(gl2.RENDERBUFFER, 4, gl.RBGA4, 256, 256); - const size = gl.getRenderbufferParameter(gl2.RENDERBUFFER, gl2.RENDERBUFFER_SAMPLES); - expect(size).assertEqual(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1045 - * @tc.name testGetRenderbufferParameter_7 - * @tc.desc Test getRenderbufferParameter. - */ - it('testGetRenderbufferParameter_7', 0, async function(done) { - //initContext(); - console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); - - const size = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_STENCIL_SIZE); - expect(size).assertEqual(0); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1046 - * @tc.name webgl_test_copyTexSubImage2D1 - * @tc.desc Test copyTexSubImage2D. - */ - it('webgl_test_copyTexSubImage2D1', 0, async function(done) { - //initContext(); - console.info("webgltest into copyTexSubImage2D"); - - gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 16, 16); - let errorCode = gl.getError(); - console.info("webgltest copyTexSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_ENUM); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1047 - * @tc.name webgl_test_copyTexSubImage2D2 - * @tc.desc Test copyTexSubImage2D. - */ - it('webgl_test_copyTexSubImage2D2', 0, async function(done) { - //initContext(); - console.info("webgltest into copyTexSubImage2D"); - gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 16, 16); - let errorCode = gl.getError(); - console.info("webgltest copyTexSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1048 - * @tc.name webgl_test_drawElements_3 - * @tc.desc Test drawElements. - */ - it('webgl_test_drawElements_3', 0, async function(done) { - //initContext(); - console.info("webgltest into drawElements"); - - gl.drawElements(gl.LINE_STRIP, 8, gl.UNSIGNED_BYTE, 0); - - let errorCode = gl.getError(); - console.info("webgltest drawElements getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1049 - * @tc.name webgl_test_drawElements_4 - * @tc.desc Test drawElements. - */ - it('webgl_test_drawElements_4', 0, async function(done) { - //initContext(); - console.info("webgltest into drawElements"); - - gl.drawElements(gl.POINTS, 8, gl.UNSIGNED_INT, 0); - - let errorCode = gl.getError(); - console.info("webgltest drawElements getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1050 - * @tc.name webgl_test_drawElements_5 - * @tc.desc Test drawElements. - */ - it('webgl_test_drawElements_5', 0, async function(done) { - //initContext(); - console.info("webgltest into drawElements"); - - gl.drawElements(gl.LINE_LOOP, 8, gl.UNSIGNED_INT, 0); - - let errorCode = gl.getError(); - console.info("webgltest drawElements getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1051 - * @tc.name webgl_test_drawElements_6 - * @tc.desc Test drawElements. - */ - it('webgl_test_drawElements_6', 0, async function(done) { - //initContext(); - console.info("webgltest into drawElements"); - - gl.drawElements(gl.LINES, 8, gl.UNSIGNED_INT, 0); - - let errorCode = gl.getError(); - console.info("webgltest drawElements getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1052 - * @tc.name webgl_test_framebufferRenderbuffer1 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer1', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT1, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1053 - * @tc.name webgl_test_framebufferRenderbuffer2 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer2', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT2, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1054 - * @tc.name webgl_test_framebufferRenderbuffer3 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer3', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT3, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1055 - * @tc.name webgl_test_framebufferRenderbuffer4 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer4', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT4, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1056 - * @tc.name webgl_test_framebufferRenderbuffer5 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer5', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT5, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1057 - * @tc.name webgl_test_framebufferRenderbuffer6 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer6', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT6, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1058 - * @tc.name webgl_test_framebufferRenderbuffer7 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer7', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT7, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1059 - * @tc.name webgl_test_framebufferRenderbuffer8 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer8', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT8, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1060 - * @tc.name webgl_test_framebufferRenderbuffer9 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer9', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT9, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1061 - * @tc.name webgl_test_framebufferRenderbuffer10 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer10', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT10, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1062 - * @tc.name webgl_test_framebufferRenderbuffer11 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer11', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT11, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1063 - * @tc.name webgl_test_framebufferRenderbuffer12 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer12', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT12, gl.RENDERBUFFER, - renderbuffer); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1064 - * @tc.name webgl_test_framebufferRenderbuffer13 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer13', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT13, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1065 - * @tc.name webgl_test_framebufferRenderbuffer14 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer14', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT14, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1066 - * @tc.name webgl_test_framebufferRenderbuffer15 - * @tc.desc Test framebufferRenderbuffer. - */ - it('webgl_test_framebufferRenderbuffer15', 0, async function(done) { - //initContext(); - console.info("webgltest into framebufferRenderbuffer"); - - const renderbuffer = gl.createRenderbuffer(); - gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT15, gl.RENDERBUFFER, - renderbuffer); - - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1067 - * @tc.name testGetParameter_1 - * @tc.desc Test getParameter. - */ - it('testGetParameter_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.BLEND_DST_ALPHA); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1068 - * @tc.name testGetParameter_2 - * @tc.desc Test getParameter. - */ - it('testGetParameter_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1069 - * @tc.name testGetParameter_3 - * @tc.desc Test getParameter. - */ - it('testGetParameter_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.BLUE_BITS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1070 - * @tc.name testGetParameter_4 - * @tc.desc Test getParameter. - */ - it('testGetParameter_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.ALPHA_BITS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1071 - * @tc.name testGetParameter_5 - * @tc.desc Test getParameter. - */ - it('testGetParameter_5', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.COMPRESSED_TEXTURE_FORMATS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1072 - * @tc.name testGetParameter_6 - * @tc.desc Test getParameter. - */ - it('testGetParameter_6', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1073 - * @tc.name testGetParameter_7 - * @tc.desc Test getParameter. - */ - it('testGetParameter_7', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.FRONT_FACE); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1074 - * @tc.name testGetParameter_8 - * @tc.desc Test getParameter. - */ - it('testGetParameter_8', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.GREEN_BITS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1075 - * @tc.name testGetParameter_9 - * @tc.desc Test getParameter. - */ - it('testGetParameter_9', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1076 - * @tc.name testGetParameter_10 - * @tc.desc Test getParameter. - */ - it('testGetParameter_10', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1077 - * @tc.name testGetParameter_11 - * @tc.desc Test getParameter. - */ - it('testGetParameter_11', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1078 - * @tc.name testGetParameter_12 - * @tc.desc Test getParameter. - */ - it('testGetParameter_12', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1079 - * @tc.name testGetParameter_13 - * @tc.desc Test getParameter. - */ - it('testGetParameter_13', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1080 - * @tc.name testGetParameter_14 - * @tc.desc Test getParameter. - */ - it('testGetParameter_14', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.MAX_RENDERBUFFER_SIZE); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1081 - * @tc.name testGetParameter_15 - * @tc.desc Test getParameter. - */ - it('testGetParameter_15', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1082 - * @tc.name testGetParameter_16 - * @tc.desc Test getParameter. - */ - it('testGetParameter_16', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.MAX_TEXTURE_SIZE); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1083 - * @tc.name testGetParameter_17 - * @tc.desc Test getParameter. - */ - it('testGetParameter_17', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.MAX_VARYING_VECTORS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1084 - * @tc.name testGetParameter_18 - * @tc.desc Test getParameter. - */ - it('testGetParameter_18', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1085 - * @tc.name testGetParameter_19 - * @tc.desc Test getParameter. - */ - it('testGetParameter_19', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1086 - * @tc.name testGetParameter_20 - * @tc.desc Test getParameter. - */ - it('testGetParameter_20', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1087 - * @tc.name testGetParameter_21 - * @tc.desc Test getParameter. - */ - it('testGetParameter_21', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.POLYGON_OFFSET_FACTOR); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1088 - * @tc.name testGetParameter_22 - * @tc.desc Test getParameter. - */ - it('testGetParameter_22', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.POLYGON_OFFSET_UNITS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1089 - * @tc.name testGetParameter_23 - * @tc.desc Test getParameter. - */ - it('testGetParameter_23', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.RED_BITS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1090 - * @tc.name testGetParameter_24 - * @tc.desc Test getParameter. - */ - it('testGetParameter_24', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.RENDERER); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1091 - * @tc.name testGetParameter_25 - * @tc.desc Test getParameter. - */ - it('testGetParameter_25', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.SAMPLE_BUFFERS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1092 - * @tc.name testGetParameter_26 - * @tc.desc Test getParameter. - */ - it('testGetParameter_26', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.STENCIL_BACK_FAIL); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1093 - * @tc.name testGetParameter_27 - * @tc.desc Test getParameter. - */ - it('testGetParameter_27', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.STENCIL_BACK_FUNC); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1094 - * @tc.name testGetParameter_28 - * @tc.desc Test getParameter. - */ - it('testGetParameter_28', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_FAIL); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1095 - * @tc.name testGetParameter_29 - * @tc.desc Test getParameter. - */ - it('testGetParameter_29', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_PASS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1096 - * @tc.name testGetParameter_30 - * @tc.desc Test getParameter. - */ - it('testGetParameter_30', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.STENCIL_BACK_REF); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1097 - * @tc.name testGetParameter_31 - * @tc.desc Test getParameter. - */ - it('testGetParameter_31', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.STENCIL_BACK_VALUE_MASK); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1098 - * @tc.name testGetParameter_32 - * @tc.desc Test getParameter. - */ - it('testGetParameter_32', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.STENCIL_BACK_WRITEMASK); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1099 - * @tc.name testGetParameter_33 - * @tc.desc Test getParameter. - */ - it('testGetParameter_33', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.STENCIL_BITS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1100 - * @tc.name testGetParameter_34 - * @tc.desc Test getParameter. - */ - it('testGetParameter_34', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test12.js b/graphic/webGL/src/main/js/default/test/WebGL.test12.js deleted file mode 100644 index 2f79870f765a9f2f70e74a2c1e209e5161881999..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test12.js +++ /dev/null @@ -1,1810 +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_webgl12', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_1101 - * @tc.name testGetParameter_35 - * @tc.desc Test getParameter. - */ - it('testGetParameter_35', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1102 - * @tc.name testGetParameter_36 - * @tc.desc Test getParameter. - */ - it('testGetParameter_36', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.STENCIL_REF); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1103 - * @tc.name testGetParameter_37 - * @tc.desc Test getParameter. - */ - it('testGetParameter_37', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.STENCIL_VALUE_MASK); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1104 - * @tc.name testGetParameter_38 - * @tc.desc Test getParameter. - */ - it('testGetParameter_38', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.SUBPIXEL_BITS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1105 - * @tc.name testGetParameter_39 - * @tc.desc Test getParameter. - */ - it('testGetParameter_39', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1106 - * @tc.name testGetParameter_40 - * @tc.desc Test getParameter. - */ - it('testGetParameter_40', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.VENDOR); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1107 - * @tc.name testGetParameter_41 - * @tc.desc Test getParameter. - */ - it('testGetParameter_41', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.VERSION); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1108 - * @tc.name testGetParameter_webgl2_1 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.COPY_READ_BUFFER_BINDING); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1109 - * @tc.name testGetParameter_webgl2_2 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.COPY_WRITE_BUFFER_BINDING); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1110 - * @tc.name testGetParameter_webgl2_3 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_FRAMEBUFFER_BINDING); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1111 - * @tc.name testGetParameter_webgl2_4 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.FRAGMENT_SHADER_DERIVATIVE_HINT); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1112 - * @tc.name testGetParameter_webgl2_5 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_5', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_3D_TEXTURE_SIZE); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1113 - * @tc.name testGetParameter_webgl2_6 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_6', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_ARRAY_TEXTURE_LAYERS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1114 - * @tc.name testGetParameter_webgl2_7 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_7', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_CLIENT_WAIT_TIMEOUT_WEBGL); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1115 - * @tc.name testGetParameter_webgl2_8 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_8', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_COLOR_ATTACHMENTS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1116 - * @tc.name testGetParameter_webgl2_9 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_9', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1117 - * @tc.name testGetParameter_webgl2_10 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_10', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_COMBINED_UNIFORM_BLOCKS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1118 - * @tc.name testGetParameter_webgl2_11 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_11', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1119 - * @tc.name testGetParameter_webgl2_12 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_12', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_DRAW_BUFFERS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1120 - * @tc.name testGetParameter_webgl2_13 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_13', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_ELEMENT_INDEX); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1121 - * @tc.name testGetParameter_webgl2_14 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_14', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_ELEMENTS_INDICES); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1122 - * @tc.name testGetParameter_webgl2_15 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_15', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_ELEMENTS_VERTICES); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1123 - * @tc.name testGetParameter_webgl2_16 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_16', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_FRAGMENT_INPUT_COMPONENTS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1124 - * @tc.name testGetParameter_webgl2_17 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_17', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_FRAGMENT_UNIFORM_BLOCKS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1125 - * @tc.name testGetParameter_webgl2_18 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_18', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_FRAGMENT_UNIFORM_COMPONENTS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1126 - * @tc.name testGetParameter_webgl2_19 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_19', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_PROGRAM_TEXEL_OFFSET); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1127 - * @tc.name testGetParameter_webgl2_20 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_20', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_SAMPLES); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1128 - * @tc.name testGetParameter_webgl2_21 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_21', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_SERVER_WAIT_TIMEOUT); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1129 - * @tc.name testGetParameter_webgl2_22 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_22', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_TEXTURE_LOD_BIAS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1130 - * @tc.name testGetParameter_webgl2_23 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_23', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1131 - * @tc.name testGetParameter_webgl2_24 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_24', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1132 - * @tc.name testGetParameter_webgl2_25 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_25', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1133 - * @tc.name testGetParameter_webgl2_26 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_26', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_UNIFORM_BLOCK_SIZE); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1134 - * @tc.name testGetParameter_webgl2_27 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_27', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_UNIFORM_BUFFER_BINDINGS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1135 - * @tc.name testGetParameter_webgl2_28 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_28', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_VARYING_COMPONENTS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1136 - * @tc.name testGetParameter_webgl2_29 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_29', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_VERTEX_OUTPUT_COMPONENTS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1137 - * @tc.name testGetParameter_webgl2_30 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_30', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_VERTEX_UNIFORM_BLOCKS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1138 - * @tc.name testGetParameter_webgl2_31 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_31', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MAX_VERTEX_UNIFORM_COMPONENTS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1139 - * @tc.name testGetParameter_webgl2_32 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_32', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.MIN_PROGRAM_TEXEL_OFFSET); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1140 - * @tc.name testGetParameter_webgl2_33 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_33', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.PIXEL_PACK_BUFFER_BINDING); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1141 - * @tc.name testGetParameter_webgl2_34 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_34', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.PIXEL_UNPACK_BUFFER_BINDING); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1142 - * @tc.name testGetParameter_webgl2_35 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_35', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.READ_BUFFER); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1143 - * @tc.name testGetParameter_webgl2_36 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_36', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.READ_FRAMEBUFFER_BINDING); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1144 - * @tc.name testGetParameter_webgl2_37 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_37', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.SAMPLER_BINDING); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1145 - * @tc.name testGetParameter_webgl2_38 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_38', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.TEXTURE_BINDING_2D_ARRAY); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1146 - * @tc.name testGetParameter_webgl2_39 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_39', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.TEXTURE_BINDING_3D); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1147 - * @tc.name testGetParameter_webgl2_40 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_40', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.TRANSFORM_FEEDBACK_ACTIVE); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1148 - * @tc.name testGetParameter_webgl2_41 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_41', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.TRANSFORM_FEEDBACK_BINDING); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1149 - * @tc.name testGetParameter_webgl2_42 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_42', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.TRANSFORM_FEEDBACK_PAUSED); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1150 - * @tc.name testGetParameter_webgl2_43 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_43', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.UNIFORM_BUFFER_OFFSET_ALIGNMENT); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1151 - * @tc.name testGetParameter_webgl2_44 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_44', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.VERTEX_ARRAY_BINDING); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1152 - * @tc.name testGetProgramParameter_1 - * @tc.desc Test getProgramParameter. - */ - it('testGetProgramParameter_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getProgramParameter test start ...' + JSON.stringify(gl)); - const program = globalFunction(); - const attachedShaders = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS); - console.info('attachedShaders' + attachedShaders); - expect(attachedShaders).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1153 - * @tc.name testGetProgramParameter_2 - * @tc.desc Test getProgramParameter. - */ - it('testGetProgramParameter_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL getProgramParameter test start ...' + JSON.stringify(gl)); - const program = globalFunction(); - const attachedShaders = gl.getProgramParameter(program, gl2.TRANSFORM_FEEDBACK_BUFFER_MODE); - console.info('attachedShaders' + attachedShaders); - expect(attachedShaders).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1154 - * @tc.name testGetProgramParameter_3 - * @tc.desc Test getProgramParameter. - */ - it('testGetProgramParameter_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL getProgramParameter test start ...' + JSON.stringify(gl)); - const program = globalFunction(); - const attachedShaders = gl.getProgramParameter(program, gl2.TRANSFORM_FEEDBACK_VARYINGS); - console.info('attachedShaders' + attachedShaders); - expect(attachedShaders).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1155 - * @tc.name testGetProgramParameter_4 - * @tc.desc Test getProgramParameter. - */ - it('testGetProgramParameter_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL getProgramParameter test start ...' + JSON.stringify(gl)); - const program = globalFunction(); - const attachedShaders = gl.getProgramParameter(program, gl2.ACTIVE_UNIFORM_BLOCKS); - console.info('attachedShaders' + attachedShaders); - expect(attachedShaders).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1160 - * @tc.name testTexImage2D_1_5 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_1_5', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texImage2D(gl.TEXTURE_2D, 0, gl2.RG16UI, 1, 1, 0, gl2.RG, gl2 - .UNSIGNED_INT_2_10_10_10_REV, view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1170 - * @tc.name testTexImage2D_1_15 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_1_15', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texImage2D(gl.TEXTURE_2D, 0, gl2.RG16UI, 1, 1, 0, gl2.RG, gl2.UNSIGNED_INT_5_9_9_9_REV, - view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1171 - * @tc.name testTexImage2D_1_16 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_1_16', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texImage2D(gl.TEXTURE_2D, 0, gl2.RG16UI, 1, 1, 0, gl2.RG, gl2 - .UNSIGNED_INT_10F_11F_11F_REV, view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1172 - * @tc.name testTexImage2D_1_16 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_1_16', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texImage2D(gl.TEXTURE_2D, 0, gl2.RG16UI, 1, 1, 0, gl2.RG, gl2 - .FLOAT_32_UNSIGNED_INT_24_8_REV, view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1173 - * @tc.name testTexImage2D_1_18 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_1_18', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texImage2D(gl.TEXTURE_2D, 0, gl2.RG16UI, 1, 1, 0, gl2.RG, gl2.UNSIGNED_INT_24_8, view, - 0); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1174 - * @tc.name testTexSubImage2D_1_1 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_1_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl2.RG, gl.FLOAT, view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1175 - * @tc.name testTexSubImage2D_1_2 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_1_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl2.RED_INTEGER, gl.FLOAT, view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1176 - * @tc.name testTexSubImage2D_1_3 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_1_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl2.RG_INTEGER, gl.FLOAT, view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1177 - * @tc.name testTexSubImage2D_1_4 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_1_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl2.RGB_INTEGER, gl.FLOAT, view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1178 - * @tc.name testTexSubImage2D_1_5 - * @tc.desc Test texSubImage2D. - */ - it('testTexSubImage2D_1_5', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl2.RGBA_INTEGER, gl.FLOAT, view, 0); - const errorCode = gl.getError(); - console.info("webgl2test texSubImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1179 - * @tc.name webgl_test_activeTexture4_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture4_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE4); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33988); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1180 - * @tc.name webgl_test_activeTexture5_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture5_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE5); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33989); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1181 - * @tc.name webgl_test_activeTexture6_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture6_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE6); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33990); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1182 - * @tc.name webgl_test_activeTexture7_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture7_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE7); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33991); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1183 - * @tc.name webgl_test_activeTexture8_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture8_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE8); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33992); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1184 - * @tc.name webgl_test_activeTexture9_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture9_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE9); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33993); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1185 - * @tc.name webgl_test_activeTexture10_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture10_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE10); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33994); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1186 - * @tc.name webgl_test_activeTexture11_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture11_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE11); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33995); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1187 - * @tc.name webgl_test_activeTexture12_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture12_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE12); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33996); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1188 - * @tc.name webgl_test_activeTexture13_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture13_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE13); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33997); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1189 - * @tc.name webgl_test_activeTexture14_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture14_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE14); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33998); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1190 - * @tc.name webgl_test_activeTexture15_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture15_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE15); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(33999); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1191 - * @tc.name webgl_test_activeTexture16_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture16_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE16); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34000); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1192 - * @tc.name webgl_test_activeTexture17_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture17_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE17); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34001); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1193 - * @tc.name webgl_test_activeTexture18_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture18_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE18); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34002); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1194 - * @tc.name webgl_test_activeTexture19_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture19_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE19); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34003); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1195 - * @tc.name webgl_test_activeTexture20_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture20_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE20); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34004); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1196 - * @tc.name webgl_test_activeTexture21_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture21_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE21); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34005); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1197 - * @tc.name webgl_test_activeTexture22_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture22_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE22); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34006); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1198 - * @tc.name webgl_test_activeTexture23_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture23_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE23); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34007); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1199 - * @tc.name webgl_test_activeTexture24_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture24_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE24); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34008); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1200 - * @tc.name webgl_test_activeTexture25_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture25_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE25); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34009); - //deleteContext(); - done(); - }); -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test13.js b/graphic/webGL/src/main/js/default/test/WebGL.test13.js deleted file mode 100644 index 10f57c57a8fee119a439afaba98d19ac6a8739e0..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test13.js +++ /dev/null @@ -1,2124 +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_webgl13', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_1201 - * @tc.name webgl_test_activeTexture26_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture26_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE26); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34010); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1202 - * @tc.name webgl_test_activeTexture27_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture27_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE27); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34011); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1203 - * @tc.name webgl_test_activeTexture28_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture28_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE28); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34012); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1204 - * @tc.name webgl_test_activeTexture29_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture29_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE29); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34013); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1205 - * @tc.name webgl_test_activeTexture30_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture30_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE30); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34014); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1206 - * @tc.name webgl_test_activeTexture31_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture31_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE31); - const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); - console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); - expect(activeTextureParameter).assertEqual(34015); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1207 - * @tc.name webgl_test_blendEquation_7 - * @tc.desc Test blendEquation. - */ - it('webgl_test_blendEquation_7', 0, async function(done) { - //initContext(); - console.info("webgltest into blendEquation"); - - gl.blendEquation(gl2.MIN); - - const blendEquationValue = gl.getParameter(gl.BLEND_EQUATION_RGB); - console.info("blendEquation --> getParameter: " + blendEquationValue); - expect(blendEquationValue).assertEqual(32775); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1208 - * @tc.name webgl_test_blendEquation_2 - * @tc.desc Test blendEquation. - */ - it('webgl_test_blendEquation_2', 0, async function(done) { - //initContext(); - console.info("webgltest into blendEquation"); - - gl.blendEquation(gl2.MAX); - - const blendEquationValue = gl.getParameter(gl.BLEND_EQUATION_RGB); - console.info("blendEquation --> getParameter: " + blendEquationValue); - expect(blendEquationValue).assertEqual(32776); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1210 - * @tc.name webgl_test_disable_40 - * @tc.desc Test disable. - */ - it('webgl_test_disable_40', 0, async function(done) { - //initContext(); - console.info("webgltest into disable"); - - gl.disable(gl2.RASTERIZER_DISCARD); - // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: - const isEnabled = gl.isEnabled(gl.DITHER); - // false - console.info("webgltest disable isEnabled: " + isEnabled); - expect(isEnabled).assertEqual(true); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1211 - * @tc.name webgl_test_clientWaitSync_2 - * @tc.desc Test clientWaitSync. - */ - it('webgl_test_clientWaitSync_2', 0, async function(done) { - //initContext(); - console.info("webgltest into clientWaitSync"); - let sync = gl2.fenceSync(0x9117, 0); - let status = gl2.clientWaitSync(sync, gl.SYNC_FLUSH_COMMANDS_BIT, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(true); - - console.info("webgltest fenceSync clientWaitSync: " + status); - - expect(status).assertEqual(0); - - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1212 - * @tc.name webgl_test_getSyncParameter_1 - * @tc.desc Test getSyncParameter. - */ - it('webgl_test_getSyncParameter_1', 0, async function(done) { - //initContext(); - console.info("webgltest into getSyncParameter"); - - console.info("webgltest into isSync"); - let sync = gl2.fenceSync(0x9117, 0); - let status = gl2.clientWaitSync(sync, 0, 0); - gl2.waitSync(sync, 0, -1); - const isSync1 = gl2.isSync(sync); - console.info("webgltest fenceSync isSync1: " + isSync1); - expect(isSync1).assertEqual(true); - const syncParameter = gl2.getSyncParameter(sync, 0x9112); - - console.info("webgltest fenceSync getSyncParameter: " + syncParameter); - expect(syncParameter).assertEqual(gl2.SYNC_FENCE); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1213 - * @tc.name testReadPixelsFirst_1 - * @tc.desc Test readPixels. - */ - it('testReadPixelsFirst_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_SHORT_5_6_5, view); - const errorCode = gl.getError(); - console.info("webgl2test readPixels getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1214 - * @tc.name testReadPixelsFirst_2 - * @tc.desc Test readPixels. - */ - it('testReadPixelsFirst_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_SHORT_4_4_4_4, view); - const errorCode = gl.getError(); - console.info("webgl2test readPixels getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1215 - * @tc.name testReadPixelsFirst_3 - * @tc.desc Test readPixels. - */ - it('testReadPixelsFirst_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_SHORT_5_5_5_1, view); - const errorCode = gl.getError(); - console.info("webgl2test readPixels getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1216 - * @tc.name testReadPixelsFirst_4 - * @tc.desc Test readPixels. - */ - it('testReadPixelsFirst_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.SHORT, view); - const errorCode = gl.getError(); - console.info("webgl2test readPixels getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1217 - * @tc.name testReadPixelsFirst_5 - * @tc.desc Test readPixels. - */ - it('testReadPixelsFirst_5', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); - var buffer = new ArrayBuffer(8); - var view = new DataView(buffer, 0); - view.setInt16(1, 42); - gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.INT, view); - const errorCode = gl.getError(); - console.info("webgl2test readPixels getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1218 - * @tc.name testTexImage2D_10_1 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_10_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.R8_SNORM, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1219 - * @tc.name testTexImage2D_11_1 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RG8_SNORM, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1220 - * @tc.name testTexImage2D_11_0 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_0', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB8_SNORM, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1221 - * @tc.name testTexImage2D_11_1 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA8_SNORM, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1222 - * @tc.name testTexImage2D_11_2 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB10_A2UI, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1223 - * @tc.name testTexImage2D_11_3 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.SRGB8, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1224 - * @tc.name testTexImage2D_11_4 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.R32F, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1225 - * @tc.name testTexImage2D_11_5 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_5', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RG8I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1226 - * @tc.name testTexImage2D_11_6 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_6', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RG16I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1227 - * @tc.name testTexImage2D_11_7 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_7', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RG32I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1228 - * @tc.name testTexImage2D_11_8 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_8', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RG32UI, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1229 - * @tc.name testTexImage2D_11_9 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_9', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB8I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1230 - * @tc.name testTexImage2D_11_10 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_10', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB16I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1231 - * @tc.name testTexImage2D_11_11 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_11', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB16UI, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1232 - * @tc.name testTexImage2D_11_12 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_12', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB32I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1233 - * @tc.name testTexImage2D_11_13 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_13', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB32UI, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1234 - * @tc.name testTexImage2D_11_14 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_14', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA8I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1235 - * @tc.name testTexImage2D_11_15 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_15', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA16I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1236 - * @tc.name testTexImage2D_11_16 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_16', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA16UI, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1237 - * @tc.name testTexImage2D_11_17 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_17', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA32I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1238 - * @tc.name testTexImage2D_11_18 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_18', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA32UI, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1239 - * @tc.name testTexImage2D_11_19 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D_11_19', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTexImage2D test start ...66'); - console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); - const buffer = new ArrayBuffer(8); - const z = new Uint8Array(buffer, 1, 4); - gl.texImage2D(gl.TEXTURE_2D, 0, gl2.DEPTH_COMPONENT, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, - z); - const texImage2DError = gl.getError(); - console.info("texImage2DError: " + texImage2DError); - expect(texImage2DError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1241 - * @tc.name testRenderbufferStorageMultisample_2 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); - gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.DEPTH_COMPONENT24, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1242 - * @tc.name testRenderbufferStorageMultisample_3 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); - gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.DEPTH_COMPONENT32F, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1243 - * @tc.name testRenderbufferStorageMultisample_4 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); - gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.DEPTH24_STENCIL8, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1244 - * @tc.name testRenderbufferStorageMultisample_5 - * @tc.desc Test renderbufferStorageMultisample. - */ - it('testRenderbufferStorageMultisample_5', 0, async function(done) { - //initContext(); - console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); - gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.DEPTH32F_STENCIL8, 256, 256); - const renderbufferStorageMultisampleError = gl.getError(); - console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); - expect(renderbufferStorageMultisampleError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1246 - * @tc.name testTransformFeedbackVaryings_7 - * @tc.desc Test transformFeedbackVaryings. - */ - it('testTransformFeedbackVaryings_7', 0, async function(done) { - //initContext(); - console.info('jsWebGL testTransformFeedbackVaryings test start ...66'); - console.info('jsWebGL testTransformFeedbackVaryings test start ...' + JSON.stringify(gl)); - const program = gl.createProgram(); - var transformFeedbackOutputs = ['gl_Position', 'anotherOutput']; - gl2.transformFeedbackVaryings(program, transformFeedbackOutputs, gl.SEPARATE_ATTRIBS); - const transformFeedbackVaryingsError = gl.getError(); - console.info("transformFeedbackVaryingsError: " + transformFeedbackVaryingsError); - expect(transformFeedbackVaryingsError).assertEqual(0); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1247 - * @tc.name testGetVertexAttrib_EnumSize - * @tc.desc Test getVertexAttrib. - */ - it('testGetVertexAttrib_EnumSize', 0, async function(done) { - //initContext(); - console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const bufferVertexAttrib = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_SIZE); - const isBuffer = gl.isBuffer(bufferVertexAttrib); - console.info("getVertexAttrib: bufferVertexAttrib" + bufferVertexAttrib); - expect(isBuffer).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1248 - * @tc.name testGetVertexAttrib_EnumStride - * @tc.desc Test getVertexAttrib. - */ - it('testGetVertexAttrib_EnumStride', 0, async function(done) { - //initContext(); - console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const bufferVertexAttrib = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_STRIDE); - const isBuffer = gl.isBuffer(bufferVertexAttrib); - console.info("getVertexAttrib: bufferVertexAttrib" + bufferVertexAttrib); - expect(isBuffer).assertEqual(false); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1249 - * @tc.name testGetVertexAttrib_EnumType - * @tc.desc Test getVertexAttrib. - */ - it('testGetVertexAttrib_EnumType', 0, async function(done) { - //initContext(); - console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const bufferVertexAttrib = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_TYPE); - const isBuffer = gl.isBuffer(bufferVertexAttrib); - console.info("getVertexAttrib: bufferVertexAttrib" + bufferVertexAttrib); - expect(isBuffer).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1250 - * @tc.name testGetVertexAttrib_EnumNormalized - * @tc.desc Test getVertexAttrib. - */ - it('testGetVertexAttrib_EnumNormalized', 0, async function(done) { - //initContext(); - console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const bufferVertexAttrib = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_NORMALIZED); - const isBuffer = gl.isBuffer(bufferVertexAttrib); - console.info("getVertexAttrib: bufferVertexAttrib" + bufferVertexAttrib); - expect(isBuffer).assertEqual(false); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1251 - * @tc.name testRenderbufferStorage_DepthComponent16 - * @tc.desc Test renderbufferStorage. - */ - it('testRenderbufferStorage_DepthComponent16', 0, async function(done) { - //initContext(); - console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, 256, 256); - - const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT); - expect(width).assertEqual(gl.DEPTH_COMPONENT16); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1252 - * @tc.name testRenderbufferStorage_StencilIndex8 - * @tc.desc Test renderbufferStorage - */ - it('testRenderbufferStorage_StencilIndex8', 0, async function(done) { - //initContext(); - console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.STENCIL_INDEX8, 256, 256); - - const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT); - expect(width).assertEqual(gl.STENCIL_INDEX8); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1253 - * @tc.name testStencilOp_KeepReplaceIncrWrap - * @tc.desc Test stencilOp - */ - it('testStencilOp_KeepReplaceIncrWrap', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilOp test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - gl.stencilOp(gl.KEEP, gl.REPLACE, gl.INCR_WRAP); - const stencilOpParameter = gl.getParameter(gl.STENCIL_FAIL); - console.info("stencilOp stencilOpParameter: " + stencilOpParameter); - expect(stencilOpParameter).assertEqual(gl.KEEP); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1254 - * @tc.name testStencilOp_KeepReplaceDecrWrap - * @tc.desc Test stencilOp - */ - it('testStencilOp_KeepReplaceDecrWrap', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilOp test start ...' + JSON.stringify(gl)); - gl.enable(gl.STENCIL_TEST); - gl.stencilOp(gl.KEEP, gl.REPLACE, gl.DECR_WRAP); - const stencilOpParameter = gl.getParameter(gl.STENCIL_FAIL); - console.info("stencilOp stencilOpParameter: " + stencilOpParameter); - expect(stencilOpParameter).assertEqual(gl.KEEP); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1255 - * @tc.name testTexParameterf_TextureBaseLevel - * @tc.desc Test texParameterf. - */ - it('testTexParameterf_TextureBaseLevel', 0, async function(done) { - //initContext(); - console.info('jsWebGL texParameterf test start ...' + JSON.stringify(gl)); - gl.texParameterf(gl.TEXTURE_2D, gl2.TEXTURE_BASE_LEVEL, gl.LINEAR); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl2.TEXTURE_BASE_LEVEL); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1256 - * @tc.name testTexParameterf_TextureMaxLevel - * @tc.desc Test texParameterf. - */ - it('testTexParameterf_TextureMaxLevel', 0, async function(done) { - //initContext(); - console.info('jsWebGL texParameterf test start ...' + JSON.stringify(gl)); - gl.texParameterf(gl.TEXTURE_2D, gl2.TEXTURE_MAX_LEVEL, gl.LINEAR); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl2.TEXTURE_MAX_LEVEL); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(undefined); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1257 - * @tc.name testVertexAttribPointer_Short - * @tc.desc Test vertexAttribPointer. - */ - it('testVertexAttribPointer_Short', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testVertexAttribPointer test start ...66'); - console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); - gl.vertexAttribPointer(0, 3, gl.SHORT, false, 20, 0); - const vertexAttribPointerError = gl.getError(); - console.info("vertexAttribPointerError: " + vertexAttribPointerError); - expect(vertexAttribPointerError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testVertexAttribPointer has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1258 - * @tc.name testTexStorage3D_Srgb8 - * @tc.desc Test texStorage3D. - */ - it('testTexStorage3D_Srgb8', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexStorage3D test start ...66'); - console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); - gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.SRGB8, 256, 256, 256); - const texStorage3DError = gl.getError(); - console.info("texStorage3DError: " + texStorage3DError); - expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexStorage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1259 - * @tc.name testTexStorage3D_Rgba32f - * @tc.desc Test texStorage3D. - */ - it('testTexStorage3D_Rgba32f', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexStorage3D test start ...66'); - console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); - gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RGBA32F, 256, 256, 256); - const texStorage3DError = gl.getError(); - console.info("texStorage3DError: " + texStorage3DError); - expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexStorage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1260 - * @tc.name testTexStorage3D_Rgb32f - * @tc.desc Test texStorage3D. - */ - it('testTexStorage3D_Rgb32f', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexStorage3D test start ...66'); - console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); - gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RGB32F, 256, 256, 256); - const texStorage3DError = gl.getError(); - console.info("texStorage3DError: " + texStorage3DError); - expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexStorage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1261 - * @tc.name testTexStorage3D_Rgba16f - * @tc.desc Test texStorage3D. - */ - it('testTexStorage3D_Rgba16f', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexStorage3D test start ...66'); - console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); - gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RGBA16F, 256, 256, 256); - const texStorage3DError = gl.getError(); - console.info("texStorage3DError: " + texStorage3DError); - expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexStorage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1262 - * @tc.name testTexStorage3D_Rgb16f - * @tc.desc Test texStorage3D. - */ - it('testTexStorage3D_Rgb16f', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexStorage3D test start ...66'); - console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); - gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RGB16F, 256, 256, 256); - const texStorage3DError = gl.getError(); - console.info("texStorage3DError: " + texStorage3DError); - expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexStorage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1263 - * @tc.name testTexStorage3D_R11FG11FB10F - * @tc.desc Test texStorage3D. - */ - it('testTexStorage3D_R11FG11FB10F', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexStorage3D test start ...66'); - console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); - gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.R11F_G11F_B10F, 256, 256, 256); - const texStorage3DError = gl.getError(); - console.info("texStorage3DError: " + texStorage3DError); - expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexStorage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1264 - * @tc.name testTexStorage3D_RGB9E5 - * @tc.desc Test texStorage3D. - */ - it('testTexStorage3D_RGB9E5', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexStorage3D test start ...66'); - console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); - gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RGB9_E5, 256, 256, 256); - const texStorage3DError = gl.getError(); - console.info("texStorage3DError: " + texStorage3DError); - expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexStorage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1265 - * @tc.name testTexStorage3D_RGBA8UI - * @tc.desc Test texStorage3D. - */ - it('testTexStorage3D_RGBA8UI', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexStorage3D test start ...66'); - console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); - gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RGBA8UI, 256, 256, 256); - const texStorage3DError = gl.getError(); - console.info("texStorage3DError: " + texStorage3DError); - expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexStorage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1266 - * @tc.name testTexStorage3D_R32F - * @tc.desc Test texStorage3D. - */ - it('testTexStorage3D_R32F', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexStorage3D test start ...66'); - console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); - gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.R32F, 256, 256, 256); - const texStorage3DError = gl.getError(); - console.info("texStorage3DError: " + texStorage3DError); - expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexStorage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1267 - * @tc.name testTexStorage3D_RG16F - * @tc.desc Test texStorage3D. - */ - it('testTexStorage3D_RG16F', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexStorage3D test start ...66'); - console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); - gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RG16F, 256, 256, 256); - const texStorage3DError = gl.getError(); - console.info("texStorage3DError: " + texStorage3DError); - expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexStorage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1268 - * @tc.name testTexStorage3D_RG32F - * @tc.desc Test texStorage3D. - */ - it('testTexStorage3D_RG32F', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexStorage3D test start ...66'); - console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); - gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RG32F, 256, 256, 256); - const texStorage3DError = gl.getError(); - console.info("texStorage3DError: " + texStorage3DError); - expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexStorage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1269 - * @tc.name testTexImage3D_SRGB8ALPHA8 - * @tc.desc Test texImage3D. - */ - it('testTexImage3D_SRGB8ALPHA8', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D test start ...66'); - console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); - gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, gl2 - .UNSIGNED_BYTE, 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(0); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1270 - * @tc.name testTexImage3D_HALFFLOAT - * @tc.desc Test texImage3D. - */ - it('testTexImage3D_HALFFLOAT', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D test start ...66'); - console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); - gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, gl2.HALF_FLOAT, - 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1271 - * @tc.name testTexImage3D_UNSIGNED_INT_2_10_10_10_REV - * @tc.desc Test texImage3D. - */ - it('testTexImage3D_UNSIGNED_INT_2_10_10_10_REV', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D test start ...66'); - console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); - gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, - gl2.UNSIGNED_INT_2_10_10_10_REV, 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1272 - * @tc.name testTexImage3D_UNSIGNED_INT_10F_11F_11F_REV - * @tc.desc Test texImage3D. - */ - it('testTexImage3D_UNSIGNED_INT_10F_11F_11F_REV', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D test start ...66'); - console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); - gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, - gl2.UNSIGNED_INT_10F_11F_11F_REV, 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1273 - * @tc.name testTexImage3D_UNSIGNED_INT_5_9_9_9_REV - * @tc.desc Test texImage3D. - */ - it('testTexImage3D_UNSIGNED_INT_5_9_9_9_REV', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D test start ...66'); - console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); - gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, gl2 - .UNSIGNED_INT_5_9_9_9_REV, 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1274 - * @tc.name testTexImage3D_UNSIGNED_INT_24_8 - * @tc.desc Test texImage3D. - */ - it('testTexImage3D_UNSIGNED_INT_24_8', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D test start ...66'); - console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); - gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, gl2 - .UNSIGNED_INT_24_8, 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(gl.INVALID_OPERATION); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1275 - * @tc.name testGetParameter_webgl2_45 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_45', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER0); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1276 - * @tc.name testGetParameter_webgl2_46 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_46', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER1); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1277 - * @tc.name testGetParameter_webgl2_47 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_47', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER2); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1278 - * @tc.name testGetParameter_webgl2_48 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_48', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER3); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1279 - * @tc.name testGetParameter_webgl2_49 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_49', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER4); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1280 - * @tc.name testGetParameter_webgl2_50 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_50', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER5); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1281 - * @tc.name testGetParameter_webgl2_51 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_51', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER6); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1282 - * @tc.name testGetParameter_webgl2_52 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_52', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER8); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1283 - * @tc.name testGetParameter_webgl2_53 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_53', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER9); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1284 - * @tc.name testGetParameter_webgl2_54 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_54', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER10); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1285 - * @tc.name testGetParameter_webgl2_55 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_55', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER11); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1286 - * @tc.name testGetParameter_webgl2_56 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_56', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER12); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1287 - * @tc.name testGetParameter_webgl2_57 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_57', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER13); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1288 - * @tc.name testGetParameter_webgl2_58 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_58', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER14); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1289 - * @tc.name testGetParameter_webgl2_59 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_59', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER15); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1290 - * @tc.name testGetParameter_webgl2_60 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl2_60', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl2.DRAW_BUFFER7); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1291 - * @tc.name testGetFramebufferAttachmentParameter3_1 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl2.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1292 - * @tc.name testGetFramebufferAttachmentParameter3_2 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl2.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1293 - * @tc.name testGetFramebufferAttachmentParameter3_3 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl2.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1294 - * @tc.name testGetFramebufferAttachmentParameter3_4 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl2.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1295 - * @tc.name testGetFramebufferAttachmentParameter3_5 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_5', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl2.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1296 - * @tc.name testGetFramebufferAttachmentParameter3_6 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_6', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl2.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1298 - * @tc.name testGetFramebufferAttachmentParameter3_8 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_8', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl2.FRAMEBUFFER_ATTACHMENT_RED_SIZE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1299 - * @tc.name testGetFramebufferAttachmentParameter3_9 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_9', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl2.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1300 - * @tc.name testGetFramebufferAttachmentParameter3_10 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_10', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test14.js b/graphic/webGL/src/main/js/default/test/WebGL.test14.js deleted file mode 100644 index 04507ee1452dd5ff4089c672617cfe568c60dda6..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test14.js +++ /dev/null @@ -1,1005 +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_webgl14', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_1301 - * @tc.name testGetFramebufferAttachmentParameter3_11 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_11', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl2.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1302 - * @tc.name testGetFramebufferAttachmentParameter3_12 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_12', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1303 - * @tc.name testGetFramebufferAttachmentParameter3_13 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_13', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1304 - * @tc.name testGetFramebufferAttachmentParameter3_14 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_14', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_OPERATION); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1306 - * @tc.name webgl_test_checkFramebufferStatus2_1 - * @tc.desc Test checkFramebufferStatus. - */ - it('webgl_test_checkFramebufferStatus2_1', 0, async function(done) { - //initContext(); - console.info("webgltest into checkFramebufferStatus"); - - var framebuffer = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - - const checkFramebufferStatus = gl.checkFramebufferStatus(gl2 - .FRAMEBUFFER_INCOMPLETE_MULTISAMPLE); - console.info("createFramebuffer --> bindFramebuffer --> checkFramebufferStatus: " + - checkFramebufferStatus); - expect(checkFramebufferStatus).assertEqual(0); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1307 - * @tc.name webgl_test_checkFramebufferStatus2_2 - * @tc.desc Test checkFramebufferStatus. - */ - it('webgl_test_checkFramebufferStatus2_2', 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_INCOMPLETE_ATTACHMENT); - console.info("createFramebuffer --> bindFramebuffer --> checkFramebufferStatus: " + - checkFramebufferStatus); - expect(checkFramebufferStatus).assertEqual(0); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1308 - * @tc.name webgl_test_checkFramebufferStatus2_3 - * @tc.desc Test checkFramebufferStatus. - */ - it('webgl_test_checkFramebufferStatus2_3', 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_INCOMPLETE_DIMENSIONS); - console.info("createFramebuffer --> bindFramebuffer --> checkFramebufferStatus: " + - checkFramebufferStatus); - expect(checkFramebufferStatus).assertEqual(0); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1309 - * @tc.name webgl_test_checkFramebufferStatus2_4 - * @tc.desc Test checkFramebufferStatus. - */ - it('webgl_test_checkFramebufferStatus2_4', 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_UNSUPPORTED); - console.info("createFramebuffer --> bindFramebuffer --> checkFramebufferStatus: " + - checkFramebufferStatus); - expect(checkFramebufferStatus).assertEqual(0); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1310 - * @tc.name testGetVertexAttribFirst_1 - * @tc.desc Test getVertexAttrib. - */ - it('testGetVertexAttribFirst_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); - const vertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); - const shaderProgram = globalFunction(); - const aVertexPosition = gl.getAttribLocation(shaderProgram, "a_position"); - - gl.enableVertexAttribArray(aVertexPosition); - gl.vertexAttribPointer(aVertexPosition, 3, gl.FLOAT, false, 20, 0); - - gl.drawArrays(gl.TRIANGLES, 0, 8); - gl.vertexAttrib1f(0, 2.8); - const type = gl.getVertexAttrib(0, gl.CURRENT_VERTEX_ATTRIB); - console.info("getVertexAttrib: type" + type); - expect(type.toString()).assertEqual([2.799999952316284, 0, 0, 1].toString()); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1311 - * @tc.name testGetParameter_webgl_1 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.BLEND_EQUATION); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(1281); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1312 - * @tc.name testGetParameter_webgl_2 - * @tc.desc Test getParameter. - */ - it('testGetParameter_webgl_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.DEPTH_BITS); - // returns "33984" (0x84C0, gl.TEXTURE0 enum value) - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(1286); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1313 - * @tc.name testGetVertexAttribFirst_2 - * @tc.desc Test getVertexAttrib. - */ - it('testGetVertexAttribFirst_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); - const vertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); - const shaderProgram = globalFunction(); - const aVertexPosition = gl.getAttribLocation(shaderProgram, "a_position"); - - gl.enableVertexAttribArray(aVertexPosition); - gl.vertexAttribPointer(aVertexPosition, 3, gl.FLOAT, false, 20, 0); - - gl.drawArrays(gl.TRIANGLES, 0, 8); - gl.vertexAttrib1f(0, 2.8); - const type = gl.getVertexAttrib(0, gl2.VERTEX_ATTRIB_ARRAY_INTEGER); - console.info("getVertexAttrib: type" + type); - expect(type).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1314 - * @tc.name testGetVertexAttribFirst_3 - * @tc.desc Test getVertexAttrib. - */ - it('testGetVertexAttribFirst_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); - const vertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); - const shaderProgram = globalFunction(); - const aVertexPosition = gl.getAttribLocation(shaderProgram, "a_position"); - - gl.enableVertexAttribArray(aVertexPosition); - gl.vertexAttribPointer(aVertexPosition, 3, gl.FLOAT, false, 20, 0); - - gl.drawArrays(gl.TRIANGLES, 0, 8); - gl.vertexAttrib1f(0, 2.8); - const type = gl.getVertexAttrib(0, gl2.VERTEX_ATTRIB_ARRAY_DIVISOR); - console.info("getVertexAttrib: type" + type); - expect(type).assertEqual(0); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1315 - * @tc.name testGetTexParameterFirst_1 - * @tc.desc Test getTexParameter. - */ - it('testGetTexParameterFirst_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_NEAREST); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(gl.NEAREST_MIPMAP_NEAREST); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1316 - * @tc.name testGetTexParameterFirst_2 - * @tc.desc Test getTexParameter. - */ - it('testGetTexParameterFirst_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_LINEAR); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(gl.NEAREST_MIPMAP_LINEAR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1317 - * @tc.name testGetTexParameterFirst_3 - * @tc.desc Test getTexParameter. - */ - it('testGetTexParameterFirst_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(gl.LINEAR_MIPMAP_LINEAR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1318 - * @tc.name webgl_test_activeTexture_webgl_1 - * @tc.desc Test activeTexture. - */ - it('webgl_test_activeTexture_webgl_1', 0, async function(done) { - //initContext(); - console.info("webgltest into activeTexture"); - gl.activeTexture(gl.TEXTURE); - 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_1319 - * @tc.name testGetUniform_11 - * @tc.desc Test getUniform. - */ - it('testGetUniform_11', 0, async function(done) { - //initContext(); - console.info('jsWebGL getUniform test start ...' + JSON.stringify(gl)); - const programObj = globalFunction(); - - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - const uniform = gl.getUniform(programObj, uniformLocation); - let type = []; - if ((typeof uniform) === 'boolean') { - type = [gl.BOOL]; - } else if ((typeof uniform) === 'number') { - type = [gl.SAMPLER_2D, gl.SAMPLER_CUBE]; - } else { - type = [gl.FLOAT_VEC2, gl.FLOAT_VEC3, gl.FLOAT_VEC4, gl.INT_VEC2, gl.INT_VEC3, gl - .INT_VEC4, gl.FLOAT_MAT2, - gl.FLOAT_MAT3, gl.FLOAT_MAT4, gl.BOOL_VEC2, gl.BOOL_VEC3, gl.BOOL_VEC4 - ] - } - const typeBool = type.length > 0 - console.info('getUniformLocation uniform' + uniform); - expect(typeBool).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1320 - * @tc.name testGetTexParameterError_1 - * @tc.desc Test getTexParameter. - */ - it('testGetTexParameterError_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl2.TEXTURE_IMMUTABLE_FORMAT); - console.info('texParameterfValue' + texParameterValue); - const type = (texParameterValue === gl2.TEXTURE_IMMUTABLE_FORMAT); - expect(type).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1321 - * @tc.name testGetTexParameterError_2 - * @tc.desc Test getTexParameter. - */ - it('testGetTexParameterError_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl2.TEXTURE_IMMUTABLE_LEVELS); - console.info('texParameterfValue' + texParameterValue); - const type = (texParameterValue === gl2.TEXTURE_IMMUTABLE_LEVELS); - expect(type).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1322 - * @tc.name testGetUniform_11_1 - * @tc.desc Test getUniform. - */ - it('testGetUniform_11_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getUniform test start ...' + JSON.stringify(gl)); - const programObj = globalFunction(); - - const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); - const uniform = gl.getUniform(programObj, uniformLocation); - let type = []; - if ((typeof uniform) === 'number') { - type = [gl2.SIGNED_NORMALIZED, gl2.UNSIGNED_NORMALIZED, gl2.SAMPLER_3D, gl2 - .SAMPLER_2D_SHADOW, - gl2.SAMPLER_2D_ARRAY, gl2.SAMPLER_2D_ARRAY_SHADOW, gl2.SAMPLER_CUBE_SHADOW, gl2 - .INT_SAMPLER_2D, - gl2.INT_SAMPLER_3D, gl2.INT_SAMPLER_CUBE, gl2.INT_SAMPLER_2D_ARRAY, gl2 - .UNSIGNED_INT_SAMPLER_2D, - gl2.UNSIGNED_INT_SAMPLER_3D, gl2.UNSIGNED_INT_SAMPLER_CUBE, gl2 - .UNSIGNED_INT_SAMPLER_2D_ARRAY - ]; - } else { - type = [gl2.UNSIGNED_INT_VEC2, gl2.UNSIGNED_INT_VEC3, - gl2.UNSIGNED_INT_VEC4, gl2.FLOAT_MAT2x3, gl2.FLOAT_MAT2x4, gl2.FLOAT_MAT3x2, gl2 - .FLOAT_MAT3x4, - gl2.FLOAT_MAT4x2, gl2.FLOAT_MAT4x3, gl.BOOL_VEC2, gl.BOOL_VEC3, gl.BOOL_VEC4 - ] - } - const typeBool = type.length > 0 - console.info('getUniformLocation uniform' + uniform); - expect(typeBool).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1323 - * @tc.name testTexImage3D_INT_2_10_10_10_REV - * @tc.desc Test testTexImage3D. - */ - it('testTexImage3D_INT_2_10_10_10_REV', 0, async function(done) { - //initContext(); - try { - console.info('jsWebGL testTexImage3D test start ...66'); - console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); - gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, gl2 - .INT_2_10_10_10_REV, 0); - const texImage3DError = gl.getError(); - console.info("texImage3DError: " + texImage3DError); - expect(texImage3DError).assertEqual(gl.INVALID_ENUM); - //deleteContext(); - done(); - } catch (e) { - console.log("testTexImage3D has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1324 - * @tc.name testTexImage2D2_1 - * @tc.desc Test texImage2D. - */ - it('testTexImage2D2_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); - gl2.texImage2D(gl2.TEXTURE_2D, 0, gl2.SRGB, 512, 512, 0, gl.RGB, gl.UNSIGNED_BYTE, 0); - const errorCode = gl.getError(); - console.info("webgl2test texImage2D getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1325 - * @tc.name testGetTexParameter3_1 - * @tc.desc Test getTexParameter. - */ - it('testGetTexParameter3_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); - gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(gl.REPEAT); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1326 - * @tc.name testGetTexParameter3_2 - * @tc.desc Test getTexParameter. - */ - it('testGetTexParameter3_2', 0, async function(done) { - //initContext(); - console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); - gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(10497); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1327 - * @tc.name testGetTexParameter3_3 - * @tc.desc Test getTexParameter. - */ - it('testGetTexParameter3_3', 0, async function(done) { - //initContext(); - console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); - gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.MIRRORED_REPEAT); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(10497); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1328 - * @tc.name webgl_test_clearBufferfv_22 - * @tc.desc Test clearBufferfv. - */ - it('webgl_test_clearBufferfv_22', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferfv"); - - gl2.clearBufferfv(gl2.INVALID_INDEX, 0, [0.0, 0.0, 0.0, 0.0]); - - let errorCode = gl.getError(); - console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_ENUM); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1329 - * @tc.name testGetFramebufferAttachmentParameter3_10_1 - * @tc.desc Test getFramebufferAttachmentParameter. - */ - it('testGetFramebufferAttachmentParameter3_10_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( - gl)); - const renderBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, - renderBuffer); - const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl - .DEPTH_STENCIL_ATTACHMENT, - gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE); - console.info('Framebuffer' + framebuffer); - const errorCode = gl.getError(); - const type = (errorCode === gl.OUT_OF_MEMORY) - console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); - expect(type).assertEqual(false); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1330 - * @tc.name testGetParameter_20_1 - * @tc.desc Test getParameter. - */ - it('testGetParameter_20_1', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - gl.activeTexture(gl.TEXTURE0); - var textureParameter = gl.getParameter(gl.BROWSER_DEFAULT_WEBGL); - console.info("activeTexture --> getParameter: " + textureParameter); - let errorCode = gl.getError(); - console.info("webgltest framebufferRenderbuffer getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1331 - * @tc.name webgl_test_clearBufferfv_22 - * @tc.desc Test clearBufferfv. - */ - it('webgl_test_clearBufferfv_22', 0, async function(done) { - //initContext(); - console.info("webgltest into clearBufferfv"); - - gl2.clearBufferfv(gl2.INVALID_INDEX, 0, [0.0, 0.0, 0.0, 0.0]); - - let errorCode = gl.getError(); - console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); - expect(errorCode).assertEqual(gl.INVALID_ENUM); - //deleteContext(); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1332 - * @tc.name testGetTexParameter3_4 - * @tc.desc Test getTexParameter. - */ - it('testGetTexParameter3_4', 0, async function(done) { - //initContext(); - console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); - gl.texParameterf(gl.TEXTURE_2D, gl2.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE); - const texParameterValue = gl.getTexParameter(gl.TEXTURE_CUBE_MAP, gl2.TEXTURE_COMPARE_MODE); - console.info('texParameterfValue' + texParameterValue); - expect(texParameterValue).assertEqual(gl.COMPARE_REF_TO_TEXTURE); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1335 - * @tc.name testRangeMin - * @tc.desc Test RangeMin. - */ - it('testRangeMin', 0, async function(done) { - console.info('jsWebGL testRangeMin test start'); - gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT).rangeMin; - gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT).rangeMax; - gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT).precision; - const errorCode = gl.getError(); - console.info("WebGLShaderPrecisionFormat getError: " + errorCode); - expect(errorCode).assertEqual(gl.NO_ERROR); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1337 - * @tc.name testRendingContextBase - * @tc.desc Test RendingContextBase. - */ - it('testRendingContextBase', 0, async function(done) { - console.info('jsWebGL testRendingContextBase test start'); - const buffer = gl.createBuffer(); - expect(typeof(buffer)).assertEqual('object'); - - var x1 = gl2.COLOR; - expect(x1).assertEqual(6144); - - var x2 = gl2.STENCIL; - expect(x2).assertEqual(6146); - - var x3 = gl2.MIN; - expect(x3).assertEqual(32775); - - var x4 = gl2.MAX; - expect(x4).assertEqual(32776); - - var x5 = gl2.RG; - expect(x5).assertEqual(33319); - - var x6 = gl2.SYNC_CONDITION; - expect(x6).assertEqual(37139); - - var x7 = gl2.SYNC_STATUS; - expect(x7).assertEqual(37140); - - var x8 = gl2.SYNC_FLAGS; - expect(x8).assertEqual(37141); - - var x9 = gl2.OBJECT_TYPE; - expect(x9).assertEqual(37138); - - var x10 = gl2.FRAMEBUFFER_DEFAULT; - expect(x10).assertEqual(33304); - - var x11 = gl2.RG8UI; - expect(x11).assertEqual(33336); - - var x12 = gl2.UNIFORM_IS_ROW_MAJOR; - expect(x12).assertEqual(35390); - - var x13 = gl2.ANY_SAMPLES_PASSED_CONSERVATIVE; - expect(x13).assertEqual(36202); - - var x14 = gl2.RGB10_A2; - expect(x14).assertEqual(32857); - - var y1 = gl.LUMINANCE_ALPHA; - expect(y1).assertEqual(6410); - - var y2 = gl.SHADER_TYPE; - expect(y2).assertEqual(35663); - - var y3 = gl.LINK_STATUS; - expect(y3).assertEqual(35714); - - var y4 = gl.VALIDATE_STATUS; - expect(y4).assertEqual(35715); - - var y5 = gl.VERTEX_ATTRIB_ARRAY_POINTER; - expect(y5).assertEqual(34373); - - var y6 = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME; - expect(y6).assertEqual(36049); - - var y7 = gl.CONTEXT_LOST_WEBGL; - expect(y7).assertEqual(37442); - - var y8 = gl.ACTIVE_ATTRIBUTES; - expect(y8).assertEqual(35721); - - done(); - }); -}) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test15.js b/graphic/webGL/src/main/js/default/test/WebGL.test15.js deleted file mode 100644 index 0e3094fcf21a9b1ab2e489eeeb04e88eef6297cc..0000000000000000000000000000000000000000 --- a/graphic/webGL/src/main/js/default/test/WebGL.test15.js +++ /dev/null @@ -1,532 +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_webgl15', 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 el = global.el; - const el2 = global.el2; - // 获取webgl上下文 - gl = el.getContext('webgl'); - if (!gl) { - console.log('webgltest Failed to get the rendering context for WebGL'); - } - gl2 = el2.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_0220 - * @tc.name testGetParameter3 - * @tc.desc Test getParameter. - */ - it('testGetParameter3', 0, async function(done) { - //initContext(); - console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); - const buffer = gl.getParameter(gl.ARRAY_BUFFER_BINDING); - console.info("buffer: " + buffer); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - const isBuffer = gl.isBuffer(buffer); - console.info("isBuffer: " + isBuffer); - expect(isBuffer).assertEqual(true); - done(); - }); - - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0231 - * @tc.name testGetVertexAttribFirst - * @tc.desc Test getVertexAttrib. - */ - it('testGetVertexAttribFirst', 0, async function(done) { - //initContext(); - console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); - const vertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); - const shaderProgram = globalFunction(); - const aVertexPosition = gl.getAttribLocation(shaderProgram, "a_position"); - - gl.enableVertexAttribArray(aVertexPosition); - gl.vertexAttribPointer(aVertexPosition, 3, gl.FLOAT, false, 20, 0); - - gl.drawArrays(gl.TRIANGLES, 0, 8); - gl.vertexAttrib1f(0, 2.8); - const type = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_ENABLED); - console.info("getVertexAttrib: type" + type); - expect(type).assertEqual(true); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0370 - * @tc.name testIsRenderbuffer_04 - * @tc.desc Test isRenderbuffer. - */ - it('testIsRenderbuffer_04', 0, async function(done) { - //initContext(); - console.info('jsWebGL testIsRenderbuffer_04 test start ...66'); - var texture = gl.createTexture(); - const isrenderbuffer = gl.isRenderbuffer(texture); - console.info("createRenderbuffer --> isRenderbuffer: " + isrenderbuffer); - expect(isrenderbuffer).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0991 - * @tc.name testGetBufferParameter3 - * @tc.desc Test getBufferParameter. - */ - it('testGetBufferParameter3', 0, async function(done) { - //initContext(); - console.info('jsWebGL getBufferParameter test start ...' + JSON.stringify(gl)); - const buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); - const bufferSize = gl.getBufferParameter(gl.ELEMENT_ARRAY_BUFFER, gl.BUFFER_SIZE); - console.info('bufferSize' + bufferSize); - expect(bufferSize).assertEqual(8); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1035 - * @tc.name testStencilMaskSeparate1 - * @tc.desc Test stencilMaskSeparate. - */ - it('testStencilMaskSeparate1', 0, async function(done) { - //initContext(); - console.info('jsWebGL stencilMaskSeparate test start ...' + JSON.stringify(gl)); - gl.stencilMaskSeparate(gl.BACK, 110101); - const stencilMaskSeparateParameter = gl.getParameter(gl.STENCIL_WRITEMASK); - console.info("stencilMaskSeparate stencilMaskSeparateParameter: " + - stencilMaskSeparateParameter); - expect(stencilMaskSeparateParameter).assertEqual(110101); - done(); - }); - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1338 - * @tc.name webgl_test_webglContextAttributes - * @tc.desc Test webglContextAttributes. - */ - it('webgl_test_webglContextAttributes_0', 0, async function(done) { - console.info("webgltest into webglContextAttributes"); - const ContextAttributesValue = gl.getContextAttributes(); - ContextAttributesValue.alpha = true; - const alphaValue = ContextAttributesValue.alpha; - console.info("webgltest webglContextAttributes: " + alphaValue); - expect(alphaValue).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1339 - * @tc.name webgl_test_webglContextAttributes - * @tc.desc Test webglContextAttributes. - */ - it('webgl_test_webglContextAttributes_1', 0, async function(done) { - console.info("webgltest into webglContextAttributes_1"); - const ContextAttributesValue = gl.getContextAttributes(); - ContextAttributesValue.antialias = true; - const antialiasValue = ContextAttributesValue.antialias; - console.info("webgltest webglContextAttributes_1: " + antialiasValue); - expect(antialiasValue).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1341 - * @tc.name webgl_test_webglContextAttributes - * @tc.desc Test webglContextAttributes. - */ - it('webgl_test_webglContextAttributes_2', 0, async function(done) { - console.info("webgltest into webglContextAttributes_2"); - const ContextAttributesValue = gl.getContextAttributes(); - ContextAttributesValue.depth = true; - const depthValue = ContextAttributesValue.depth; - console.info("webgltest webglContextAttributes_2: " + depthValue); - expect(depthValue).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1342 - * @tc.name webgl_test_webglContextAttributes - * @tc.desc Test webglContextAttributes. - */ - it('webgl_test_webglContextAttributes_3', 0, async function(done) { - console.info("webgltest into webglContextAttributes_3"); - const ContextAttributesValue = gl.getContextAttributes(); - ContextAttributesValue.failIfMajorPerformanceCaveat = false; - const failIfMajorPerformanceCaveatValue = ContextAttributesValue.failIfMajorPerformanceCaveat; - console.info("webgltest webglContextAttributes_3: " + failIfMajorPerformanceCaveatValue); - expect(failIfMajorPerformanceCaveatValue).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1343 - * @tc.name webgl_test_webglContextAttributes - * @tc.desc Test webglContextAttributes. - */ - it('webgl_test_webglContextAttributes_4', 0, async function(done) { - console.info("webgltest into webglContextAttributes_4"); - const ContextAttributesValue = gl.getContextAttributes(); - ContextAttributesValue.desynchronized = false; - const desynchronizedValue = ContextAttributesValue.desynchronized; - console.info("webgltest webglContextAttributes_4: " + desynchronizedValue); - expect(desynchronizedValue).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1344 - * @tc.name webgl_test_webglContextAttributes - * @tc.desc Test webglContextAttributes. - */ - it('webgl_test_webglContextAttributes_5', 0, async function(done) { - console.info("webgltest into webglContextAttributes_5"); - const ContextAttributesValue = gl.getContextAttributes(); - const powerPreferenceValue = ContextAttributesValue.powerPreference; - console.info("webgltest webglContextAttributes_5: " + powerPreferenceValue); - expect(powerPreferenceValue).assertEqual("default"); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1345 - * @tc.name webgl_test_webglContextAttributes - * @tc.desc Test webglContextAttributes. - */ - it('webgl_test_webglContextAttributes_6', 0, async function(done) { - console.info("webgltest into webglContextAttributes_6"); - const ContextAttributesValue = gl.getContextAttributes(); - ContextAttributesValue.premultipliedAlpha = true; - const premultipliedAlphaValue = ContextAttributesValue.premultipliedAlpha; - console.info("webgltest webglContextAttributes_6: " + premultipliedAlphaValue); - expect(premultipliedAlphaValue).assertEqual(true); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1346 - * @tc.name webgl_test_webglContextAttributes - * @tc.desc Test webglContextAttributes. - */ - it('webgl_test_webglContextAttributes_7', 0, async function(done) { - console.info("webgltest into webglContextAttributes_7"); - const ContextAttributesValue = gl.getContextAttributes(); - ContextAttributesValue.preserveDrawingBuffer = false; - const preserveDrawingBufferValue = ContextAttributesValue.preserveDrawingBuffer; - console.info("webgltest webglContextAttributes_7: " + preserveDrawingBufferValue); - expect(preserveDrawingBufferValue).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1347 - * @tc.name webgl_test_webglContextAttributes - * @tc.desc Test webglContextAttributes. - */ - it('webgl_test_webglContextAttributes_8', 0, async function(done) { - console.info("webgltest into webglContextAttributes_8"); - const ContextAttributesValue = gl.getContextAttributes(); - ContextAttributesValue.stencil = false; - const stencilValue = ContextAttributesValue.stencil; - console.info("webgltest webglContextAttributes_8: " + stencilValue); - expect(stencilValue).assertEqual(false); - done(); - }) - - /** - * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1348 - * @tc.name webgl_test_endTransformFeedback - * @tc.desc Test endTransformFeedback. - */ - it('webgl_test_endTransformFeedback', 0, async function(done) { - let transformFeedback = gl2.createTransformFeedback(); - gl2.endTransformFeedback(); - let errorCode = gl.getError(); - console.info("webgltest endTransformFeedback getError: " + errorCode); - expect(errorCode).assertLarger(gl.NO_ERROR); - //deleteContext(); - done(); - }); -}) diff --git a/graphic/webGL/src/main/js/test/List.test.js b/graphic/webGL/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..19441bb2217d9e18afa5d0e4b86d282a7b66d8f6 --- /dev/null +++ b/graphic/webGL/src/main/js/test/List.test.js @@ -0,0 +1,47 @@ +/* + * 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 webgl1Test_webgl1 from './WebGL.test01.js' +import webgl1Test_webgl2 from './WebGL.test02.js' +import webgl1Test_webgl3 from './WebGL.test03.js' +import webgl1Test_webgl4 from './WebGL.test04.js' +import webgl1Test_webgl5 from './WebGL.test05.js' +import webgl1Test_webgl6 from './WebGL.test06.js' +import webgl1Test_webgl7 from './WebGL.test07.js' +import webgl1Test_webgl8 from './WebGL.test08.js' +import webgl1Test_webgl9 from './WebGL.test09.js' +import webgl1Test_webgl10 from './WebGL.test10.js' +import webgl1Test_webgl11 from './WebGL.test11.js' +import webgl1Test_webgl12 from './WebGL.test12.js' +import webgl1Test_webgl13 from './WebGL.test13.js' +import webgl1Test_webgl14 from './WebGL.test14.js' +import webgl1Test_webgl15 from './WebGL.test15.js' + +export default function testsuite(){ + webgl1Test_webgl1() + webgl1Test_webgl2() + webgl1Test_webgl3() + webgl1Test_webgl4() + webgl1Test_webgl5() + webgl1Test_webgl6() + webgl1Test_webgl7() + webgl1Test_webgl8() + webgl1Test_webgl9() + webgl1Test_webgl10() + webgl1Test_webgl11() + webgl1Test_webgl12() + webgl1Test_webgl13() + webgl1Test_webgl14() + webgl1Test_webgl15() +} \ No newline at end of file diff --git a/graphic/webGL/src/main/js/test/WebGL.test01.js b/graphic/webGL/src/main/js/test/WebGL.test01.js new file mode 100644 index 0000000000000000000000000000000000000000..0c18b130366e6a3bee1e3c8d962e61493f864fe2 --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test01.js @@ -0,0 +1,2493 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl1(){ + 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; + } + + const indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices.buffer, gl.STATIC_DRAW); + + 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); + + // 指定清空的颜色 + gl.clearColor(0.0, 0.0, 0.0, 1.0); + + // 清空 + // COLOR_BUFFER_BIT 0x00004000 + gl.clear(gl.COLOR_BUFFER_BIT); + + console.info("indices.length: " + indices.length) + gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_SHORT, 0); + + let errorCode = gl.getError(); + console.info("webgltest drawArrays getError: " + errorCode); + expect(errorCode).assertEqual(1280); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0079 + * @tc.name webgl_test_drawElements_2 + * @tc.desc Test drawElements. + */ + it('webgl_test_drawElements_2', 0, async function(done) { + //initContext(); + console.info("webgltest into drawElements"); + + gl.drawElements(1, 2, 3, 4); + + let errorCode = gl.getError(); + console.info("webgltest drawElements getError: " + errorCode); + expect(errorCode).assertEqual(0x0500); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0080 + * @tc.name webgl_test_enable + * @tc.desc Test enable. + */ + it('webgl_test_enable', 0, async function(done) { + //initContext(); + console.info("webgltest into enable"); + + gl.enable(gl.DITHER); + + const isEnabled = gl.isEnabled(gl.DITHER); + // true + console.info("webgltest enable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(true); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0081 + * @tc.name webgl_test_enable_2 + * @tc.desc Test enable. + */ + it('webgl_test_enable_2', 0, async function(done) { + //initContext(); + console.info("webgltest into enable"); + + gl.enable(gl.DITHER); + + const isEnabled = gl.isEnabled(gl.DITHER); + // true + console.info("webgltest enable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(true); + + gl.disable(gl.DITHER); + // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: + const isEnabled2 = gl.isEnabled(gl.DITHER); + // false + console.info("webgltest disable isEnabled2: " + isEnabled2); + expect(isEnabled2).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0082 + * @tc.name webgl_test_enableVertexAttribArray + * @tc.desc Test enableVertexAttribArray. + */ + it('webgl_test_enableVertexAttribArray', 0, async function(done) { + //initContext(); + console.info("webgltest into enableVertexAttribArray"); + //顶点着色器程序 + 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); + + const aVertexPosition = gl.getAttribLocation(programObj, "a_Position"); + + gl.enableVertexAttribArray(aVertexPosition); + gl.vertexAttribPointer(aVertexPosition, 4, gl.FLOAT, false, 0, 0); + gl.drawArrays(gl.TRIANGLES, 0, 3); + + let errorCode = gl.getError(); + console.info("webgltest enableVertexAttribArray getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0083 + * @tc.name webgl_test_finish + * @tc.desc Test finish. + */ + it('webgl_test_finish', 0, async function(done) { + //initContext(); + console.info("webgltest into finish"); + gl.finish(); + let errorCode = gl.getError(); + console.info("webgltest finish getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0084 + * @tc.name webgl_test_flush + * @tc.desc Test flush. + */ + it('webgl_test_flush', 0, async function(done) { + //initContext(); + console.info("webgltest into flush"); + gl.flush(); + let errorCode = gl.getError(); + console.info("webgltest flush getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0085 + * @tc.name webgl_test_framebufferRenderbuffer + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer', 0, async function(done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0086 + * @tc.name webgl_test_framebufferRenderbuffer_2 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer_2', 0, async function(done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, "11", gl.RENDERBUFFER, renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0087 + * @tc.name webgl_test_framebufferTexture2D + * @tc.desc Test framebufferTexture2D. + */ + it('webgl_test_framebufferTexture2D', 0, async function(done) { + //initContext(); + console.info("webgltest into framebufferTexture2D"); + const texture = gl.createTexture(); + gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, + 0); + + let errorCode = gl.getError(); + console.info("webgltest framebufferTexture2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0088 + * @tc.name webgl_test_framebufferTexture2D_1 + * @tc.desc Test framebufferTexture2D. + */ + it('webgl_test_framebufferTexture2D_1', 0, async function(done) { + //initContext(); + console.info("webgltest into framebufferTexture2D"); + const texture = gl.createTexture(); + gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, + "123"); + + let errorCode = gl.getError(); + console.info("webgltest framebufferTexture2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + + //deleteContext(); + done(); + }); + + + //********************************************* webgl2 ****************************************************** + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0089 + * @tc.name webgl_test_drawBuffers + * @tc.desc Test drawBuffers. + */ + it('webgl_test_drawBuffers', 0, async function(done) { + //initContext(); + console.info("webgltest into drawBuffers"); + + gl2.drawBuffers([gl2.NONE, gl2.COLOR_ATTACHMENT1]); + + let errorCode = gl.getError(); + console.info("webgltest drawBuffers getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0090 + * @tc.name webgl_test_drawBuffers_2 + * @tc.desc Test drawBuffers. + */ + it('webgl_test_drawBuffers_2', 0, async function(done) { + //initContext(); + console.info("webgltest into drawBuffers"); + gl2.drawBuffers(["gl2.NONE", "gl2.COLOR_ATTACHMENT1"]); + let errorCode = gl.getError(); + console.info("webgltest drawBuffers getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_091 + * @tc.name webgl_test_clearBufferfv + * @tc.desc Test clearBufferfv. + */ + it('webgl_test_clearBufferfv', 0, async function(done) { + //initContext(); + console.info("webgltest into clearBufferfv"); + + gl2.clearBufferfv(gl.COLOR, 0, [0.0, 0.0, 0.0, 0.0]); + + let errorCode = gl.getError(); + console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0092 + * @tc.name webgl_test_clearBufferfv_2 + * @tc.desc Test clearBufferfv. + */ + it('webgl_test_clearBufferfv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into clearBufferfv"); + + gl2.clearBufferfv(gl.COLOR, "0", [0.0, 0.0, 0.0, 0.0]); + + let errorCode = gl.getError(); + console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0093 + * @tc.name webgl_test_clearBufferiv + * @tc.desc Test clearBufferiv. + */ + it('webgl_test_clearBufferiv', 0, async function(done) { + //initContext(); + console.info("webgltest into clearBufferiv"); + + gl2.clearBufferiv(gl.COLOR, 0, new Int32Array([0, 1, 0, 0.5])); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0094 + * @tc.name webgl_test_clearBufferiv_2 + * @tc.desc Test clearBufferiv. + */ + it('webgl_test_clearBufferiv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into clearBufferiv"); + + gl2.clearBufferiv(gl.COLOR, "0", new Int32Array([0, 1, 0, 0.5])); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0095 + * @tc.name webgl_test_clearBufferuiv + * @tc.desc Test clearBufferuiv. + */ + it('webgl_test_clearBufferuiv', 0, async function(done) { + //initContext(); + console.info("webgltest into clearBufferuiv"); + + gl2.clearBufferuiv(gl.COLOR, 0, new Uint32Array([0, 1, 0, 0])); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferuiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0096 + * @tc.name webgl_test_clearBufferuiv_2 + * @tc.desc Test clearBufferuiv. + */ + it('webgl_test_clearBufferuiv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into clearBufferuiv"); + + gl2.clearBufferuiv(gl.COLOR, "0", new Uint32Array([0, 1, 0, 0])); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferuiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0097 + * @tc.name webgl_test_clearBufferfi + * @tc.desc Test clearBufferfi. + */ + it('webgl_test_clearBufferfi', 0, async function(done) { + //initContext(); + console.info("webgltest into clearBufferfi"); + + gl2.clearBufferfi(gl.DEPTH_STENCIL, 0, 1.0, 0); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferfi getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0098 + * @tc.name webgl_test_clearBufferfi_2 + * @tc.desc Test clearBufferfi. + */ + it('webgl_test_clearBufferfi_2', 0, async function(done) { + //initContext(); + console.info("webgltest into clearBufferfi"); + + gl2.clearBufferfi(gl.DEPTH_STENCIL, "0", 1.0, 0); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferfi getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0099 + * @tc.name webgl_test_createQuery + * @tc.desc Test createQuery. + */ + it('webgl_test_createQuery', 0, async function(done) { + //initContext(); + console.info("webgltest into createQuery"); + + const query = gl2.createQuery(); + gl2.beginQuery(0x8C2F, query); + + const currentQuery = gl2.getQuery(gl2.ANY_SAMPLES_PASSED, 0x8865); + const isQuery = gl2.isQuery(currentQuery); + + console.info("webgltest createQuery isQuery: " + isQuery); + expect(isQuery).assertEqual(true); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0100 + * @tc.name webgl_test_beginQuery + * @tc.desc Test beginQuery. + */ + it('webgl_test_beginQuery', 0, async function(done) { + //initContext(); + console.info("webgltest into beginQuery"); + + var query = gl2.createQuery(); + gl2.beginQuery(0x8C2F, query); + + const currentQuery = gl2.getQuery(0x8C2F, 0x8865); + const isQuery1 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery isQuery1: " + isQuery1); + expect(isQuery1).assertEqual(true); + //deleteContext(); + done(); + }); + }) + } diff --git a/graphic/webGL/src/main/js/test/WebGL.test02.js b/graphic/webGL/src/main/js/test/WebGL.test02.js new file mode 100644 index 0000000000000000000000000000000000000000..f267d46b2b8e413bbc3ff0d361f9671fff1e2d2f --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test02.js @@ -0,0 +1,2819 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl2(){ + describe('webgl1Test_webgl2', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_0101 + * @tc.name webgl_test_getQuery + * @tc.desc Test getQuery. + */ + it('webgl_test_getQuery', 0, async function(done) { + //initContext(); + console.info("webgltest into getQuery"); + + var query = gl2.createQuery(); + gl2.beginQuery(0x8C2F, query); + + var currentQuery = gl2.getQuery(0x8C2F, 0x8865); + const isQuery1 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery isQuery1: " + isQuery1); + expect(isQuery1).assertEqual(true); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0102 + * @tc.name webgl_test_isQuery + * @tc.desc Test isQuery. + */ + it('webgl_test_isQuery', 0, async function(done) { + //initContext(); + console.info("webgltest into isQuery"); + const query = gl2.createQuery(); + gl2.beginQuery(0x8C2F, query); + + const currentQuery = gl2.getQuery(0x8C2F, 0x8865); + const isQuery1 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery isQuery1: " + isQuery1); + expect(isQuery1).assertEqual(true); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0103 + * @tc.name webgl_test_isQuery_2 + * @tc.desc Test isQuery. + */ + it('webgl_test_isQuery_2', 0, async function(done) { + //initContext(); + console.info("webgltest into isQuery"); + const query = gl2.createQuery(); + + const isQuery1 = gl2.isQuery(query); + console.info("webgltest createQuery isQuery1: " + isQuery1); + expect(isQuery1).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0104 + * @tc.name webgl_test_endQuery + * @tc.desc Test endQuery. + */ + it('webgl_test_endQuery', 0, async function(done) { + //initContext(); + console.info("webgltest into endQuery"); + + var query = gl2.createQuery(); + gl2.beginQuery(0x8C2F, query); + + const currentQuery = gl2.getQuery(0x8C2F, 0x8865); + const isQuery1 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery isQuery1: " + isQuery1); + expect(isQuery1).assertEqual(true); + + gl2.endQuery(0x8C2F); + + const isQuery2 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery isQuery2: " + isQuery2); + expect(isQuery2).assertEqual(true); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0105 + * @tc.name webgl_test_getQueryParameter + * @tc.desc Test getQueryParameter. + */ + it('webgl_test_getQueryParameter', 0, async function(done) { + //initContext(); + console.info("webgltest into getQueryParameter"); + var query = gl2.createQuery(); + gl2.beginQuery(0x8C2F, query); + + var currentQuery = gl2.getQuery(0x8C2F, 0x8865); + const isQuery1 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery isQuery1: " + isQuery1); + expect(isQuery1).assertEqual(true); + + // 返回一个GLboolean 指示查询结果是否可用。 + var result = gl2.getQueryParameter(currentQuery, gl2.QUERY_RESULT_AVAILABLE); + + console.info("webgltest createQuery beginQuery getQueryParameter: " + result); + expect(typeof(result)).assertEqual("boolean"); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0106 + * @tc.name webgl_test_getQueryParameter2 + * @tc.desc Test getQueryParameter. + */ + it('webgl_test_getQueryParameter2', 0, async function(done) { + //initContext(); + console.info("webgltest into getQueryParameter"); + var query = gl2.createQuery(); + gl2.beginQuery(0x8C2F, query); + + var currentQuery = gl2.getQuery(0x8C2F, gl2.CURRENT_QUERY); + const isQuery1 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery isQuery1: " + isQuery1); + expect(isQuery1).assertEqual(true); + + // 返回一个GLboolean 指示查询结果是否可用。 + var result = gl2.getQueryParameter(currentQuery, gl2.QUERY_RESULT); + + console.info("webgltest createQuery beginQuery getQueryParameter: " + result); + expect(typeof(result)).assertEqual("number"); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0107 + * @tc.name webgl_test_deleteQuery + * @tc.desc Test deleteQuery. + */ + it('webgl_test_deleteQuery', 0, async function(done) { + //initContext(); + console.info("webgltest into deleteQuery"); + + var query = gl2.createQuery(); + gl2.beginQuery(0x8C2F, query); + + const currentQuery = gl2.getQuery(0x8C2F, 0x8865); + const isQuery1 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery isQuery1: " + isQuery1); + expect(isQuery1).assertEqual(true); + + gl2.deleteQuery(currentQuery); + + const isQuery2 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery deleteQuery isQuery2: " + isQuery2); + + expect(isQuery2).assertEqual(false); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0108 + * @tc.name webgl_test_createSampler + * @tc.desc Test createSampler. + */ + it('webgl_test_createSampler', 0, async function(done) { + //initContext(); + console.info("webgltest into createSampler"); + const sampler = gl2.createSampler(); + const isSampler1 = gl2.isSampler(sampler); + console.info("webgltest createSampler isSampler1: " + isSampler1); + expect(isSampler1).assertEqual(true); + + gl2.bindSampler(0, sampler); + const isSampler2 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); + expect(isSampler2).assertEqual(true); + + gl2.deleteSampler(sampler); + const isSampler3 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); + expect(isSampler3).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0109 + * @tc.name webgl_test_samplerParameterf + * @tc.desc Test samplerParameterf. + */ + it('webgl_test_samplerParameterf', 0, async function(done) { + //initContext(); + console.info("webgltest into samplerParameterf"); + + let sampler = gl2.createSampler(); + // gl2.bindSampler(0, sampler); + gl2.samplerParameterf(sampler, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameterf getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0110 + * @tc.name webgl_test_samplerParameteri + * @tc.desc Test samplerParameteri. + */ + it('webgl_test_samplerParameteri', 0, async function(done) { + //initContext(); + console.info("webgltest into samplerParameteri"); + let sampler = gl2.createSampler(); + // gl2.bindSampler(0, sampler); + // gl2.samplerParameteri(sampler, 0x884D, 0x2600); + gl2.samplerParameteri(sampler, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameteri getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0111 + * @tc.name webgl_test_deleteSampler + * @tc.desc Test deleteSampler. + */ + it('webgl_test_deleteSampler', 0, async function(done) { + //initContext(); + console.info("webgltest into deleteSampler"); + const sampler = gl2.createSampler(); + const isSampler1 = gl2.isSampler(sampler); + console.info("webgltest createSampler isSampler1: " + isSampler1); + expect(isSampler1).assertEqual(true); + + gl2.bindSampler(0, sampler); + const isSampler2 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); + expect(isSampler2).assertEqual(true); + + gl2.deleteSampler(sampler); + const isSampler3 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); + expect(isSampler3).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0112 + * @tc.name webgl_test_isSampler + * @tc.desc Test isSampler. + */ + it('webgl_test_isSampler', 0, async function(done) { + //initContext(); + console.info("webgltest into isSampler"); + const sampler = gl2.createSampler(); + const isSampler1 = gl2.isSampler(sampler); + console.info("webgltest createSampler isSampler1: " + isSampler1); + expect(isSampler1).assertEqual(true); + + gl2.bindSampler(0, sampler); + const isSampler2 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); + expect(isSampler2).assertEqual(true); + + gl2.deleteSampler(sampler); + const isSampler3 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); + expect(isSampler3).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0113 + * @tc.name webgl_test_isSampler_2 + * @tc.desc Test isSampler. + */ + it('webgl_test_isSampler_2', 0, async function(done) { + //initContext(); + console.info("webgltest into isSampler"); + const sampler = gl2.createSampler(); + + gl2.bindSampler(0, sampler); + const isSampler2 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); + expect(isSampler2).assertEqual(true); + + gl2.deleteSampler(sampler); + const isSampler3 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); + expect(isSampler3).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0114 + * @tc.name webgl_test_bindSampler + * @tc.desc Test bindSampler. + */ + it('webgl_test_bindSampler', 0, async function(done) { + //initContext(); + console.info("webgltest into bindSampler"); + const sampler = gl2.createSampler(); + const isSampler1 = gl2.isSampler(sampler); + console.info("webgltest createSampler isSampler1: " + isSampler1); + expect(isSampler1).assertEqual(true); + + gl2.bindSampler(0, sampler); + const isSampler2 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); + expect(isSampler2).assertEqual(true); + + gl2.deleteSampler(sampler); + const isSampler3 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); + expect(isSampler3).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0115 + * @tc.name webgl_test_getSamplerParameter_1 + * @tc.desc Test getSamplerParameter. + */ + it('webgl_test_getSamplerParameter_1', 0, async function(done) { + //initContext(); + console.info("webgltest into getSamplerParameter"); + + let sampler = gl2.createSampler(); + // const samplerParameter = gl2.getSamplerParameter(sampler, gl.TEXTURE_COMPARE_FUNC); + + const samplerParameter = gl2.getSamplerParameter(sampler, 0x884D); + + console.info("webgltest createSampler getSamplerParameter_1: " + samplerParameter); + expect(typeof(samplerParameter)).assertEqual("number"); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0116 + * @tc.name webgl_test_getSamplerParameter_2 + * @tc.desc Test getSamplerParameter. + */ + it('webgl_test_getSamplerParameter_2', 0, async function(done) { + //initContext(); + console.info("webgltest into getSamplerParameter"); + + let sampler = gl2.createSampler(); + const samplerParameter = gl2.getSamplerParameter(sampler, 0x884C); + + console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); + expect(typeof(samplerParameter)).assertEqual("number"); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0117 + * @tc.name webgl_test_getSamplerParameter_3 + * @tc.desc Test getSamplerParameter. + */ + it('webgl_test_getSamplerParameter_3', 0, async function(done) { + //initContext(); + console.info("webgltest into getSamplerParameter"); + + let sampler = gl2.createSampler(); + const samplerParameter = gl2.getSamplerParameter(sampler, gl.TEXTURE_MAG_FILTER); + + console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); + expect(typeof(samplerParameter)).assertEqual("number"); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0118 + * @tc.name webgl_test_getSamplerParameter_4 + * @tc.desc Test getSamplerParameter. + */ + it('webgl_test_getSamplerParameter_4', 0, async function(done) { + //initContext(); + console.info("webgltest into getSamplerParameter"); + + let sampler = gl2.createSampler(); + const samplerParameter = gl2.getSamplerParameter(sampler, 0x813B); + + console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); + expect(typeof(samplerParameter)).assertEqual("number"); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0119 + * @tc.name webgl_test_getSamplerParameter_5 + * @tc.desc Test getSamplerParameter. + */ + it('webgl_test_getSamplerParameter_5', 0, async function(done) { + //initContext(); + console.info("webgltest into getSamplerParameter"); + + let sampler = gl2.createSampler(); + const samplerParameter = gl2.getSamplerParameter(sampler, gl.TEXTURE_MIN_FILTER); + + console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); + expect(typeof(samplerParameter)).assertEqual("number"); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0120 + * @tc.name webgl_test_getSamplerParameter_6 + * @tc.desc Test getSamplerParameter. + */ + it('webgl_test_getSamplerParameter_6', 0, async function(done) { + //initContext(); + console.info("webgltest into getSamplerParameter"); + + let sampler = gl2.createSampler(); + const samplerParameter = gl2.getSamplerParameter(sampler, 0x813A); + + console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); + expect(typeof(samplerParameter)).assertEqual("number"); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0121 + * @tc.name webgl_test_getSamplerParameter_7 + * @tc.desc Test getSamplerParameter. + */ + it('webgl_test_getSamplerParameter_7', 0, async function(done) { + //initContext(); + console.info("webgltest into getSamplerParameter"); + + let sampler = gl2.createSampler(); + const samplerParameter = gl2.getSamplerParameter(sampler, 0x8072); + + console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); + expect(typeof(samplerParameter)).assertEqual("number"); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0122 + * @tc.name webgl_test_getSamplerParameter_8 + * @tc.desc Test getSamplerParameter. + */ + it('webgl_test_getSamplerParameter_8', 0, async function(done) { + //initContext(); + console.info("webgltest into getSamplerParameter"); + + let sampler = gl2.createSampler(); + const samplerParameter = gl2.getSamplerParameter(sampler, gl.TEXTURE_WRAP_S); + + console.info("webgltest createSampler getSamplerParameter: " + samplerParameter); + expect(typeof(samplerParameter)).assertEqual("number"); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0123 + * @tc.name webgl_test_fenceSync + * @tc.desc Test fenceSync. + */ + it('webgl_test_fenceSync', 0, async function(done) { + //initContext(); + console.info("webgltest into fenceSync"); + + let sync = gl2.fenceSync(0x9117, 0); + let status = gl2.clientWaitSync(sync, 0, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(true); + + gl2.deleteSync(sync); + + const isSync2 = gl2.isSync(sync); + console.info("webgltest fenceSync deleteSync isSync2: " + isSync2); + expect(isSync2).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0124 + * @tc.name webgl_test_clientWaitSync + * @tc.desc Test clientWaitSync. + */ + it('webgl_test_clientWaitSync', 0, async function(done) { + //initContext(); + console.info("webgltest into clientWaitSync"); + let sync = gl2.fenceSync(0x9117, 0); + let status = gl2.clientWaitSync(sync, 0, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(true); + + console.info("webgltest fenceSync clientWaitSync: " + status); + + expect(status).assertEqual(gl2.ALREADY_SIGNALED || gl2.TIMEOUT_EXPIRED || gl + .CONDITION_SATISFIED || + gl.WAIT_FAILED); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0125 + * @tc.name webgl_test_waitSync + * @tc.desc Test waitSync. + */ + it('webgl_test_waitSync', 0, async function(done) { + //initContext(); + console.info("webgltest into waitSync"); + + let sync = gl2.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0); + gl2.waitSync(sync, 0, gl.TIMEOUT_IGNORED); + + let errorCode = gl.getError(); + console.info("webgltest framebufferTexture2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0126 + * @tc.name webgl_test_isSync + * @tc.desc Test isSync. + */ + it('webgl_test_isSync', 0, async function(done) { + //initContext(); + console.info("webgltest into isSync"); + let sync = gl2.fenceSync(0x9117, 0); + let status = gl2.clientWaitSync(sync, 0, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(true); + + gl2.deleteSync(sync); + + const isSync2 = gl2.isSync(sync); + console.info("webgltest fenceSync deleteSync isSync2: " + isSync2); + expect(isSync2).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0127 + * @tc.name webgl_test_getSyncParameter + * @tc.desc Test getSyncParameter. + */ + it('webgl_test_getSyncParameter', 0, async function(done) { + //initContext(); + console.info("webgltest into getSyncParameter"); + + console.info("webgltest into isSync"); + let sync = gl2.fenceSync(0x9117, 0); + let status = gl2.clientWaitSync(sync, 0, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(true); + const syncParameter = gl2.getSyncParameter(sync, 0x9112); + + console.info("webgltest fenceSync getSyncParameter: " + syncParameter); + expect(syncParameter).assertEqual(0x9116); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0128 + * @tc.name webgl_test_getSyncParameter2 + * @tc.desc Test getSyncParameter. + */ + it('webgl_test_getSyncParameter2', 0, async function(done) { + //initContext(); + console.info("webgltest into getSyncParameter"); + + console.info("webgltest into isSync"); + let sync = gl2.fenceSync(0x9117, 0); + let status = gl2.clientWaitSync(sync, 0, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(true); + + const syncParameter = gl2.getSyncParameter(sync, 0x9114); + + console.info("webgltest fenceSync getSyncParameter: " + syncParameter); + let syncParameterFlag = false; + + if (syncParameter == gl2.SIGNALED || syncParameter == gl2.UNSIGNALED) { + syncParameterFlag = true; + } + expect(syncParameterFlag).assertEqual(true); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0129 + * @tc.name webgl_test_getSyncParameter3 + * @tc.desc Test getSyncParameter. + */ + it('webgl_test_getSyncParameter3', 0, async function(done) { + //initContext(); + console.info("webgltest into getSyncParameter"); + + let sync = gl2.fenceSync(0x9117, 0); + let status = gl2.clientWaitSync(sync, 0, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(true); + const syncParameter = gl2.getSyncParameter(sync, 0x9113); + + console.info("webgltest fenceSync getSyncParameter: " + syncParameter); + expect(syncParameter).assertEqual(0x9117); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0130 + * @tc.name webgl_test_getSyncParameter4 + * @tc.desc Test getSyncParameter. + */ + it('webgl_test_getSyncParameter4', 0, async function(done) { + //initContext(); + console.info("webgltest into getSyncParameter"); + + let sync = gl2.fenceSync(0x9117, 0); + let status = gl2.clientWaitSync(sync, 0, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(true); + const syncParameter = gl2.getSyncParameter(sync, 0x9115); + + console.info("webgltest fenceSync getSyncParameter: " + syncParameter); + expect(syncParameter).assertEqual(0); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0131 + * @tc.name webgl_test_deleteSync + * @tc.desc Test deleteSync. + */ + it('webgl_test_deleteSync', 0, async function(done) { + //initContext(); + console.info("webgltest into deleteSync"); + let sync = gl2.fenceSync(0x9117, 0); + let status = gl2.clientWaitSync(sync, 0, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(true); + + gl2.deleteSync(sync); + + const isSync2 = gl2.isSync(sync); + console.info("webgltest fenceSync deleteSync isSync2: " + isSync2); + expect(isSync2).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0132 + * @tc.name webgl_test_createTransformFeedback + * @tc.desc Test createTransformFeedback. + */ + it('webgl_test_createTransformFeedback', 0, async function(done) { + //initContext(); + console.info("webgltest into createTransformFeedback"); + + const transformFeedback = gl2.createTransformFeedback(); + + + console.info("webgltest into createTransformFeedback: " + transformFeedback) + + gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); + + gl2.beginTransformFeedback(gl2.TRIANGLES); + + const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); + + console.info("BindTransformFeedback : " + isTransformFeedback2); + expect(isTransformFeedback2).assertEqual(true); + + gl2.deleteTransformFeedback(transformFeedback); + const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); + console.info("webgltest createTransformFeedback bindTransformFeedback " + + "deleteTransformFeedback isTransformFeedback3: " + isTransformFeedback3); + expect(isTransformFeedback3).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0133 + * @tc.name webgl_test_isTransformFeedback + * @tc.desc Test isTransformFeedback. + */ + it('webgl_test_isTransformFeedback', 0, async function(done) { + //initContext(); + console.info("webgltest into isTransformFeedback"); + let transformFeedback = gl2.createTransformFeedback(); + const isTransformFeedback1 = gl2.isTransformFeedback(transformFeedback); + console.info("webgltest createTransformFeedback isTransformFeedback1: " + + isTransformFeedback1); + expect(isTransformFeedback1).assertEqual(false); + + gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); + + const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); + console.info( + "webgltest createTransformFeedback bindTransformFeedback isTransformFeedback2: " + + isTransformFeedback2); + expect(isTransformFeedback2).assertEqual(true); + + gl2.deleteTransformFeedback(transformFeedback); + const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); + console.info("webgltest createTransformFeedback bindTransformFeedback " + + "deleteTransformFeedback isTransformFeedback3: " + isTransformFeedback3); + expect(isTransformFeedback3).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0134 + * @tc.name webgl_test_bindTransformFeedback + * @tc.desc Test bindTransformFeedback. + */ + it('webgl_test_bindTransformFeedback', 0, async function(done) { + //initContext(); + console.info("webgltest into bindTransformFeedback"); + let transformFeedback = gl2.createTransformFeedback(); + const isTransformFeedback1 = gl2.isTransformFeedback(transformFeedback); + console.info("webgltest createTransformFeedback isTransformFeedback1: " + + isTransformFeedback1); + expect(isTransformFeedback1).assertEqual(false); + + gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); + + const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); + console.info( + "webgltest createTransformFeedback bindTransformFeedback isTransformFeedback2: " + + isTransformFeedback2); + expect(isTransformFeedback2).assertEqual(true); + + gl2.deleteTransformFeedback(transformFeedback); + const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); + console.info( + "webgltest createTransformFeedback bindTransformFeedback deleteTransformFeedback " + + "isTransformFeedback3: " + isTransformFeedback3); + expect(isTransformFeedback3).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0135 + * @tc.name webgl_test_beginTransformFeedback + * @tc.desc Test beginTransformFeedback. + */ + it('webgl_test_beginTransformFeedback', 0, async function(done) { + //initContext(); + console.info("webgltest into beginTransformFeedback"); + + let transformFeedback = gl2.createTransformFeedback(); + // gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); + gl2.beginTransformFeedback(gl2.TRIANGLES); + + + let errorCode = gl.getError(); + console.info("webgltest framebufferTexture2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0137 + * @tc.name webgl_test_deleteTransformFeedback + * @tc.desc Test deleteTransformFeedback. + */ + it('webgl_test_deleteTransformFeedback', 0, async function(done) { + //initContext(); + console.info("webgltest into deleteTransformFeedback"); + const transformFeedback = gl2.createTransformFeedback(); + + gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); + + const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); + console.info( + "webgltest createTransformFeedback bindTransformFeedback isTransformFeedback2: " + + isTransformFeedback2); + expect(isTransformFeedback2).assertEqual(true); + + gl2.deleteTransformFeedback(transformFeedback); + const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); + console.info( + "webgltest createTransformFeedback bindTransformFeedback deleteTransformFeedback " + + "isTransformFeedback3: " + isTransformFeedback3); + expect(isTransformFeedback3).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0138 + * @tc.name webgl_test_getFragDataLocation + * @tc.desc Test getFragDataLocation. + */ + it('webgl_test_getFragDataLocation', 0, async function(done) { + //initContext(); + console.info("webgltest into getFragDataLocation"); + + //顶点着色器程序 + 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); + + gl2.getFragDataLocation(programObj, 'a_Position'); + + let errorCode = gl.getError(); + console.info("webgltest getFragDataLocation getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0139 + * @tc.name webgl_test_uniform1ui + * @tc.desc Test uniform1ui. + */ + it('webgl_test_uniform1ui', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform1ui"); + + //顶点着色器程序 + 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); + + const location = gl.getUniformLocation(programObj, "a_Position"); + gl2.uniform1ui(location, 1.8); + + let errorCode = gl.getError(); + console.info("webgltest uniform1ui getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0140 + * @tc.name webgl_test_uniform1ui_2 + * @tc.desc Test uniform1ui. + */ + it('webgl_test_uniform1ui_2', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform1ui"); + + const programObj = gl.createProgram(); + console.log("testUseProgram has failed for " + programObj) + + const location = gl.getUniformLocation(programObj, "v_color"); + gl2.uniform1ui(location, 1.8); + + let errorCode = gl.getError(); + console.info("webgltest uniform1ui getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0141 + * @tc.name webgl_test_uniform2ui + * @tc.desc Test uniform2ui. + */ + it('webgl_test_uniform2ui', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform2ui"); + + //顶点着色器程序 + 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); + + const location = gl.getUniformLocation(programObj, "a_Position"); + const a = gl2.uniform2ui(location, 2.8, 2.8); + + let errorCode = gl.getError(); + console.info("webgltest uniform2ui getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0142 + * @tc.name webgl_test_uniform2ui_2 + * @tc.desc Test uniform2ui. + */ + it('webgl_test_uniform2ui_2', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform2ui"); + + const programObj = gl.createProgram(); + console.log("testUseProgram has failed for " + programObj) + + const location = gl.getUniformLocation(programObj, "v_color"); + const a = gl2.uniform2ui(location, 2.8, 2.8); + + let errorCode = gl.getError(); + console.info("webgltest uniform2ui getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0143 + * @tc.name webgl_test_uniform3ui + * @tc.desc Test uniform3ui. + */ + it('webgl_test_uniform3ui', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform3ui"); + + //顶点着色器程序 + 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); + + const location = gl.getUniformLocation(programObj, "a_Position"); + const a = gl2.uniform3ui(location, 3.8, 3.8, 3.8); + + let errorCode = gl.getError(); + console.info("webgltest uniform3ui getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0144 + * @tc.name webgl_test_uniform3ui_2 + * @tc.desc Test uniform3ui. + */ + it('webgl_test_uniform3ui_2', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform3ui"); + + const programObj = gl.createProgram(); + console.log("testUseProgram has failed for " + programObj) + + const location = gl.getUniformLocation(programObj, "v_color"); + const a = gl2.uniform3ui(location, 3.8, 3.8, 3.8); + + let errorCode = gl.getError(); + console.info("webgltest uniform3ui getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0145 + * @tc.name webgl_test_uniform4ui + * @tc.desc Test uniform4ui. + */ + it('webgl_test_uniform4ui', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform4ui"); + + //顶点着色器程序 + 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); + + const location = gl.getUniformLocation(programObj, "a_Position"); + const a = gl2.uniform4ui(location, 4.8, 4.8, 4.8, 4.8); + + let errorCode = gl.getError(); + console.info("webgltest uniform4ui getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0146 + * @tc.name webgl_test_uniform4ui_2 + * @tc.desc Test uniform4ui. + */ + it('webgl_test_uniform4ui_2', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform4ui"); + + const programObj = gl.createProgram(); + console.log("testUseProgram has failed for " + programObj) + + const location = gl.getUniformLocation(programObj, "v_color"); + const a = gl2.uniform4ui(location, 4.8, 4.8, 4.8, 4.8); + + let errorCode = gl.getError(); + console.info("webgltest uniform4ui getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0147 + * @tc.name webgl_test_uniform1uiv + * @tc.desc Test uniform1uiv. + */ + it('webgl_test_uniform1uiv', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform1uiv"); + + //顶点着色器程序 + 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); + const location = gl.getUniformLocation(programObj, "a_Position"); + const a = gl2.uniform1uiv(location, float1, 1, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniform1uiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0148 + * @tc.name webgl_test_uniform1uiv_2 + * @tc.desc Test uniform1uiv. + */ + it('webgl_test_uniform1uiv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform1uiv"); + + const programObj = gl.createProgram(); + + const location = gl.getUniformLocation(programObj, "v_Color"); + const a = gl2.uniform1uiv(location, float1, 1, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniform1uiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0149 + * @tc.name webgl_test_uniform2uiv + * @tc.desc Test uniform2uiv. + */ + it('webgl_test_uniform2uiv', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform2uiv"); + + //顶点着色器程序 + 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); + + const location = gl.getUniformLocation(programObj, "a_Position"); + const a = gl2.uniform2uiv(location, float1, 2, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniform2uiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0150 + * @tc.name webgl_test_uniform2uiv_2 + * @tc.desc Test uniform2uiv. + */ + it('webgl_test_uniform2uiv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform2uiv"); + + + const programObj = gl.createProgram(); + + + const location = gl.getUniformLocation(programObj, "v_Color"); + const a = gl2.uniform2uiv(location, float2, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniform2uiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0151 + * @tc.name webgl_test_uniform3uiv + * @tc.desc Test uniform3uiv. + */ + it('webgl_test_uniform3uiv', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform3uiv"); + + //顶点着色器程序 + 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); + + const location = gl.getUniformLocation(programObj, "a_Position"); + const a = gl2.uniform3uiv(location, float1, 3, 255); + + 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_0152 + * @tc.name webgl_test_uniform3uiv_3 + * @tc.desc Test uniform3uiv. + */ + it('webgl_test_uniform3uiv_3', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform3uiv"); + + + const programObj = gl.createProgram(); + + + const location = gl.getUniformLocation(programObj, "v_Color"); + const a = gl2.uniform3uiv(location, float2, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniform3uiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0153 + * @tc.name webgl_test_uniform4uiv + * @tc.desc Test uniform4uiv. + */ + it('webgl_test_uniform4uiv', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform4uiv"); + + //顶点着色器程序 + 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); + + const location = gl.getUniformLocation(programObj, "a_Position"); + const a = gl2.uniform4uiv(location, float1, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniform4uiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0154 + * @tc.name webgl_test_uniform4uiv_2 + * @tc.desc Test uniform4uiv. + */ + it('webgl_test_uniform4uiv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into uniform4uiv"); + + + const programObj = gl.createProgram(); + + const location = gl.getUniformLocation(programObj, "v_Color"); + const a = gl2.uniform4uiv(location, float2, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniform4uiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0155 + * @tc.name webgl_test_uniformMatrix3x2fv + * @tc.desc Test uniformMatrix3x2fv. + */ + it('webgl_test_uniformMatrix3x2fv', 0, async function(done) { + //initContext(); + console.info("webgltest into uniformMatrix3x2fv"); + + //顶点着色器程序 + 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); + + const location = gl.getUniformLocation(programObj, "a_Position"); + const a = gl2.uniformMatrix3x2fv(location, false, float1, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniformMatrix3x2fv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0156 + * @tc.name webgl_test_uniformMatrix3x2fv_2 + * @tc.desc Test uniformMatrix3x2fv. + */ + it('webgl_test_uniformMatrix3x2fv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into uniformMatrix3x2fv"); + + + const programObj = gl.createProgram(); + + + const location = gl.getUniformLocation(programObj, "v_Color"); + const a = gl2.uniformMatrix3x2fv(location, false, float2, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniformMatrix3x2fv getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0157 + * @tc.name webgl_test_uniformMatrix4x2fv + * @tc.desc Test uniformMatrix4x2fv. + */ + it('webgl_test_uniformMatrix4x2fv', 0, async function(done) { + //initContext(); + console.info("webgltest into uniformMatrix4x2fv"); + + //顶点着色器程序 + 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); + const location = gl.getUniformLocation(programObj, "a_Position"); + const a = gl2.uniformMatrix4x2fv(location, false, float1, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniformMatrix4x2fv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0158 + * @tc.name webgl_test_uniformMatrix4x2fv_2 + * @tc.desc Test uniformMatrix4x2fv. + */ + it('webgl_test_uniformMatrix4x2fv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into uniformMatrix4x2fv"); + + + const programObj = gl.createProgram(); + + const location = gl.getUniformLocation(programObj, "v_Color"); + const a = gl2.uniformMatrix4x2fv(location, false, float2, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniformMatrix4x2fv getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0159 + * @tc.name webgl_test_uniformMatrix2x3fv + * @tc.desc Test uniformMatrix2x3fv. + */ + it('webgl_test_uniformMatrix2x3fv', 0, async function(done) { + //initContext(); + console.info("webgltest into uniformMatrix2x3fv"); + + //顶点着色器程序 + 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); + const location = gl.getUniformLocation(programObj, "a_Position"); + const a = gl2.uniformMatrix2x3fv(location, false, float1, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniformMatrix2x3fv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0160 + * @tc.name webgl_test_uniformMatrix2x3fv_2 + * @tc.desc Test uniformMatrix2x3fv. + */ + it('webgl_test_uniformMatrix2x3fv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into uniformMatrix2x3fv"); + + const programObj = gl.createProgram(); + + const location = gl.getUniformLocation(programObj, "v_Color"); + const a = gl2.uniformMatrix2x3fv(location, false, float2, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniformMatrix2x3fv getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0161 + * @tc.name webgl_test_uniformMatrix4x3fv + * @tc.desc Test uniformMatrix4x3fv. + */ + it('webgl_test_uniformMatrix4x3fv', 0, async function(done) { + //initContext(); + console.info("webgltest into uniformMatrix4x3fv"); + + //顶点着色器程序 + 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); + const location = gl.getUniformLocation(programObj, "a_Position"); + const a = gl2.uniformMatrix4x3fv(location, false, float1, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniformMatrix4x3fv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0162 + * @tc.name webgl_test_uniformMatrix4x3fv_2 + * @tc.desc Test uniformMatrix4x3fv. + */ + it('webgl_test_uniformMatrix4x3fv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into uniformMatrix4x3fv"); + + + const programObj = gl.createProgram(); + + const location = gl.getUniformLocation(programObj, "v_Color"); + const a = gl2.uniformMatrix4x3fv(location, false, float2, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniformMatrix4x3fv getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0163 + * @tc.name webgl_test_uniformMatrix2x4fv + * @tc.desc Test uniformMatrix2x4fv. + */ + it('webgl_test_uniformMatrix2x4fv', 0, async function(done) { + //initContext(); + console.info("webgltest into uniformMatrix2x4fv"); + + //顶点着色器程序 + 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); + const location = gl.getUniformLocation(programObj, "a_Position"); + const a = gl2.uniformMatrix2x4fv(location, false, float1, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniformMatrix2x4fv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0164 + * @tc.name webgl_test_uniformMatrix2x4fv_2 + * @tc.desc Test uniformMatrix2x4fv. + */ + it('webgl_test_uniformMatrix2x4fv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into uniformMatrix2x4fv"); + + + const programObj = gl.createProgram(); + + const location = gl.getUniformLocation(programObj, "v_Color"); + const a = gl2.uniformMatrix2x4fv(location, false, float2, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniformMatrix2x4fv getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0165 + * @tc.name webgl_test_uniformMatrix3x4fv + * @tc.desc Test uniformMatrix3x4fv. + */ + it('webgl_test_uniformMatrix3x4fv', 0, async function(done) { + //initContext(); + console.info("webgltest into uniformMatrix3x4fv"); + + //顶点着色器程序 + 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); + const location = gl.getUniformLocation(programObj, "a_Position"); + const a = gl2.uniformMatrix3x4fv(location, false, float1, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniformMatrix3x4fv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0166 + * @tc.name webgl_test_uniformMatrix3x4fv_2 + * @tc.desc Test uniformMatrix3x4fv. + */ + it('webgl_test_uniformMatrix3x4fv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into uniformMatrix3x4fv"); + + + const programObj = gl.createProgram(); + + const location = gl.getUniformLocation(programObj, "v_Color"); + const a = gl2.uniformMatrix3x4fv(location, false, float2, 0, 255); + + let errorCode = gl.getError(); + console.info("webgltest uniformMatrix3x4fv getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0167 + * @tc.name webgl_test_vertexAttribI4i + * @tc.desc Test vertexAttribI4i. + */ + it('webgl_test_vertexAttribI4i', 0, async function(done) { + //initContext(); + console.info("webgltest into vertexAttribI4i"); + + const a = gl2.vertexAttribI4i(1, 10, 11, 12, 13); + + let errorCode = gl.getError(); + console.info("webgltest vertexAttribI4i getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0168 + * @tc.name webgl_test_vertexAttribI4iv + * @tc.desc Test vertexAttribI4iv. + */ + it('webgl_test_vertexAttribI4iv', 0, async function(done) { + //initContext(); + console.info("webgltest into vertexAttribI4iv"); + + const a = gl2.vertexAttribI4iv(1, int1); + + let errorCode = gl.getError(); + console.info("webgltest vertexAttribI4iv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0169 + * @tc.name webgl_test_vertexAttribI4iv_2 + * @tc.desc Test vertexAttribI4iv. + */ + it('webgl_test_vertexAttribI4iv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into vertexAttribI4iv"); + + const a = gl2.vertexAttribI4iv(1, int2); + + let errorCode = gl.getError(); + console.info("webgltest vertexAttribI4iv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0170 + * @tc.name webgl_test_vertexAttribI4ui + * @tc.desc Test vertexAttribI4ui. + */ + it('webgl_test_vertexAttribI4ui', 0, async function(done) { + //initContext(); + console.info("webgltest into vertexAttribI4ui"); + + const a = gl2.vertexAttribI4ui(1, 10, 11, 12, 13); + + let errorCode = gl.getError(); + console.info("webgltest vertexAttribI4ui getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0171 + * @tc.name webgl_test_vertexAttribI4uiv + * @tc.desc Test vertexAttribI4uiv. + */ + it('webgl_test_vertexAttribI4uiv', 0, async function(done) { + //initContext(); + console.info("webgltest into vertexAttribI4uiv"); + + const a = gl2.vertexAttribI4uiv(1, uint1); + + let errorCode = gl.getError(); + console.info("webgltest vertexAttribI4uiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0172 + * @tc.name webgl_test_vertexAttribI4uiv_2 + * @tc.desc Test vertexAttribI4uiv. + */ + it('webgl_test_vertexAttribI4uiv_2', 0, async function(done) { + //initContext(); + console.info("webgltest into vertexAttribI4uiv"); + + const a = gl2.vertexAttribI4uiv(1, uint2); + + let errorCode = gl.getError(); + console.info("webgltest vertexAttribI4uiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0173 + * @tc.name webgl_test_vertexAttribIPointer + * @tc.desc Test vertexAttribIPointer. + */ + it('webgl_test_vertexAttribIPointer', 0, async function(done) { + //initContext(); + console.info("webgltest into vertexAttribIPointer"); + + const a = gl2.vertexAttribIPointer(2, 4, gl.UNSIGNED_BYTE, 20, 16); + + let errorCode = gl.getError(); + console.info("webgltest vertexAttribIPointer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0174 + * @tc.name webgl_test_vertexAttribDivisor + * @tc.desc Test vertexAttribDivisor. + */ + it('webgl_test_vertexAttribDivisor', 0, async function(done) { + //initContext(); + console.info("webgltest into vertexAttribDivisor"); + + const a = gl2.vertexAttribDivisor(0, 2); + + let errorCode = gl.getError(); + console.info("webgltest vertexAttribDivisor getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0175 + * @tc.name webgl_test_vertexAttribDivisor_2 + * @tc.desc Test vertexAttribDivisor. + */ + it('webgl_test_vertexAttribDivisor_2', 0, async function(done) { + //initContext(); + console.info("webgltest into vertexAttribDivisor"); + + const a = gl2.vertexAttribDivisor(0, "2"); + + let errorCode = gl.getError(); + console.info("webgltest vertexAttribDivisor getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0176 + * @tc.name webgl_test_drawArraysInstanced + * @tc.desc Test drawArraysInstanced. + */ + it('webgl_test_drawArraysInstanced', 0, async function(done) { + //initContext(); + console.info("webgltest into drawArraysInstanced"); + + const a = gl2.drawArraysInstanced(gl.POINTS, 0, 8, 4); + + let errorCode = gl.getError(); + console.info("webgltest drawArraysInstanced getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0177 + * @tc.name webgl_test_drawElementsInstanced + * @tc.desc Test drawElementsInstanced. + */ + it('webgl_test_drawElementsInstanced', 0, async function(done) { + //initContext(); + console.info("webgltest into drawElementsInstanced"); + const indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices.buffer, gl.STATIC_DRAW); + + const a = gl2.drawElementsInstanced(gl.POINTS, 2, gl.UNSIGNED_SHORT, 0, 4); + + let errorCode = gl.getError(); + console.info("webgltest drawElementsInstanced getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0178 + * @tc.name webgl_test_drawRangeElements + * @tc.desc Test drawRangeElements. + */ + it('webgl_test_drawRangeElements', 0, async function(done) { + //initContext(); + console.info("webgltest into drawRangeElements"); + const indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices.buffer, gl.STATIC_DRAW); + + const a = gl2.drawRangeElements(gl.POINTS, 0, 7, 8, gl.UNSIGNED_BYTE, 0); + + let errorCode = gl.getError(); + console.info("webgltest drawRangeElements getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0179 + * @tc.name testFrontFaceFirst + * @tc.desc Test frontFace. + */ + it('testFrontFaceFirst', 0, async function(done) { + //initContext(); + console.info('jsWebGL frontFace test start ...' + JSON.stringify(gl)); + gl.enable(gl.CULL_FACE); + gl.cullFace(gl.FRONT_AND_BACK); + gl.frontFace(gl.CW); + const frontFaceParameter = gl.getParameter(gl.CULL_FACE_MODE); + console.info('frontFace -> frontFaceParameter' + frontFaceParameter); + gl.disable(gl.CULL_FACE); + expect(frontFaceParameter).assertEqual(gl.FRONT_AND_BACK); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0180 + * @tc.name testFrontFace_Third + * @tc.desc Test frontFace. + */ + it('testFrontFace_Third', 0, async function(done) { + //initContext(); + console.info('jsWebGL frontFace test start ...' + JSON.stringify(gl)); + gl.enable(gl.CULL_FACE); + gl.cullFace(gl.BACK); + gl.frontFace(gl.CW); + const frontFaceParameter = gl.getParameter(gl.CULL_FACE_MODE); + console.info('frontFace -> frontFaceParameter' + frontFaceParameter); + gl.disable(gl.CULL_FACE); + expect(frontFaceParameter).assertEqual(gl.BACK); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0181 + * @tc.name testFrontFaceError + * @tc.desc Test frontFace. + */ + it('testFrontFaceError', 0, async function(done) { + //initContext(); + console.info('jsWebGL frontFace test start ...' + JSON.stringify(gl)); + gl.cullFace(gl.BACK); + gl.frontFace(gl.CW); + const frontFaceParameter = gl.getParameter(gl.CULL_FACE_MODE); + console.info('frontFace -> frontFaceParameter' + frontFaceParameter); + gl.disable(gl.CULL_FACE); + expect(frontFaceParameter).assertEqual(gl.BACK); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0182 + * @tc.name testGenerateMipmap + * @tc.desc Test generateMipmap. + */ + it('testGenerateMipmap', 0, async function(done) { + //initContext(); + console.info('jsWebGL generateMipmap test start ...' + JSON.stringify(gl)); + gl.generateMipmap(gl2.TEXTURE_2D); + const error = gl.getError(); + console.info('generateMipmap error ' + error); + expect(error).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0183 + * @tc.name testGenerateMipmapError + * @tc.desc Test generateMipmap. + */ + it('testGenerateMipmapError', 0, async function(done) { + //initContext(); + console.info('jsWebGL generateMipmap test start ...' + JSON.stringify(gl)); + gl.generateMipmap(gl.TEXTURE_2D); + const error = gl.getError(); + console.info('generateMipmap error ' + error); + expect(error).assertEqual(1282); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0184 + * @tc.name testGetActiveAttrib + * @tc.desc Test getActiveAttrib. + */ + it('testGetActiveAttrib', 0, async function(done) { + //initContext(); + console.info('jsWebGL getActiveAttrib test start ...' + JSON.stringify(gl)); + const programObj = globalFunction(); + gl.bindAttribLocation(programObj, 0, 'a_Position'); + // const numAttribs = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES); + const info = gl.getActiveAttrib(programObj, 0); + const error = gl.getError(); + expect(error).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0185 + * @tc.name testGetActiveUniform + * @tc.desc Test getActiveUniform. + */ + it('testGetActiveUniform', 0, async function(done) { + //initContext(); + console.info('jsWebGL getActiveUniform test start ...' + JSON.stringify(gl)); + const programObj = globalFunction(); + const info = gl.getActiveUniform(programObj, 0); + const error = gl.getError(); + expect(error).assertEqual(1281); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0186 + * @tc.name testGetAttachedShaders + * @tc.desc Test getAttachedShaders. + */ + it('testGetAttachedShaders', 0, async function(done) { + //initContext(); + console.info('jsWebGL getAttachedShaders test start ...' + JSON.stringify(gl)); + const programObj = globalFunction(); + const shaderArray = gl.getAttachedShaders(programObj); + const type = ((typeof shaderArray) === "object") + console.info('getAttachedShaders shaderArray' + shaderArray); + expect(type).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0187 + * @tc.name testGetAttribLocationError + * @tc.desc Test getAttribLocation. + */ + it('testGetAttribLocationError', 0, async function(done) { + //initContext(); + console.info('jsWebGL getAttribLocation test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + const index = gl.getAttribLocation(program, 'webgl_Color'); + console.info('getAttribLocation index' + index); + expect(index).assertEqual(-1); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0188 + * @tc.name testGetAttribLocationFirst + * @tc.desc Test getAttribLocation. + */ + it('testGetAttribLocationFirst', 0, async function(done) { + //initContext(); + console.info('jsWebGL getAttribLocation test start ...' + JSON.stringify(gl)); + 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.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); + + const aVertexPosition = gl.getAttribLocation(programObj, "a_Position"); + expect(aVertexPosition).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0189 + * @tc.name testGetBufferParameterFirst + * @tc.desc Test getBufferParameter. + */ + it('testGetBufferParameterFirst', 0, async function(done) { + //initContext(); + console.info('jsWebGL getBufferParameter test start ...' + JSON.stringify(gl)); + const buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + const bufferSize = gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE); + console.info('bufferSize' + bufferSize); + expect(bufferSize).assertEqual(1024); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0190 + * @tc.name testGetBufferParameterSecond + * @tc.desc Test getBufferParameter. + */ + it('testGetBufferParameterSecond', 0, async function(done) { + //initContext(); + console.info('jsWebGL getBufferParameter test start ...' + JSON.stringify(gl)); + const buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + const bufferUsage = gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_USAGE); + console.info('bufferUsage' + bufferUsage); + expect(bufferUsage).assertEqual(gl.STATIC_DRAW); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0191 + * @tc.name testGetErrorFirst + * @tc.desc Test getError. + */ + it('testGetErrorFirst', 0, async function(done) { + //initContext(); + console.info('jsWebGL getError test start ...' + JSON.stringify(gl)); + // turn on scissor test + gl.enable(gl.SCISSOR_TEST); + // set the scissor rectangle + gl.scissor(0, 0, -200, 200); + // 如果宽度或高度为负值, gl.INVALID_VALUE(DEC:1281)则会引发错误 + const scissorErrorCode = gl.getError(); + console.info("scissorErrorCode: " + scissorErrorCode); + expect(scissorErrorCode).assertEqual(1281); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0192 + * @tc.name testGetErrorSecond + * @tc.desc Test getError. + */ + it('testGetErrorSecond', 0, async function(done) { + //initContext(); + console.info('jsWebGL getError test start ...' + JSON.stringify(gl)); + gl.getError(); // 0 (0) + gl.enable(gl.DITHER); + const errorCode = gl.getError(); // gl.INVALID_ENUM; + console.info('getError 2 errorCode' + errorCode); + expect(errorCode).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0193 + * @tc.name testGetFramebufferAttachmentParameter + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter', 0, async function(done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .COLOR_ATTACHMENT0, + gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0197 + * @tc.name testGetProgramParameterFourth + * @tc.desc Test getProgramParameter. + */ + it('testGetProgramParameterFourth', 0, async function(done) { + //initContext(); + console.info('jsWebGL getProgramParameter test start ...' + JSON.stringify(gl)); + const program = globalFunction(); + const attachedShaders = gl.getProgramParameter(program, gl.ATTACHED_SHADERS); + console.info('attachedShaders' + attachedShaders); + expect(attachedShaders).assertEqual(2); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0198 + * @tc.name testGetProgramParameterError + * @tc.desc Test getProgramParameter. + */ + it('testGetProgramParameterError', 0, async function(done) { + //initContext(); + console.info('jsWebGL getProgramParameter test start ...' + JSON.stringify(gl)); + const vertexShader = gl.createShader(gl.VERTEX_SHADER); + gl.shaderSource(vertexShader, VSHADER_SOURCE); + gl.compileShader(vertexShader); + + const programObj = gl.createProgram(); + // gl.attachShader(programObj, vertexShader); + const attachedShaders = gl.getProgramParameter(programObj, gl.ATTACHED_SHADERS); + console.info('attachedShaders' + attachedShaders); + const type = (attachedShaders === 1); + expect(type).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0199 + * @tc.name testGetProgramInfoLog + * @tc.desc Test getProgramInfoLog. + */ + it('testGetProgramInfoLog', 0, async function(done) { + //initContext(); + console.info('jsWebGL getProgramInfoLog test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + // Attach pre-existing shaders + gl.attachShader(program, VSHADER_SOURCE); + gl.attachShader(program, FSHADER_SOURCE); + gl.linkProgram(program); + gl.validateProgram(program); + const info = gl.getProgramInfoLog(program); + gl.useProgram(program); + expect(info).assertEqual('The program object is incomplete.'); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0200 + * @tc.name testGetRenderbufferParameterFirst + * @tc.desc Test getRenderbufferParameter. + */ + it('testGetRenderbufferParameterFirst', 0, async function(done) { + //initContext(); + console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); + + const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH); + expect(width).assertEqual(256); + done(); + }); +}) +} \ No newline at end of file diff --git a/graphic/webGL/src/main/js/test/WebGL.test03.js b/graphic/webGL/src/main/js/test/WebGL.test03.js new file mode 100644 index 0000000000000000000000000000000000000000..629769d7d1d884b83d8fc09bebf515b7f6aed50a --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test03.js @@ -0,0 +1,2001 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl3() { + describe('webgl1Test_webgl3', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_0201 + * @tc.name testGetRenderbufferParameterSecond + * @tc.desc Test getRenderbufferParameter. + */ + it('testGetRenderbufferParameterSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); + + const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT); + expect(width).assertEqual(gl.RGBA4); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0202 + * @tc.name testGetRenderbufferParameterThird + * @tc.desc Test getRenderbufferParameter. + */ + it('testGetRenderbufferParameterThird', 0, async function (done) { + //initContext(); + console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); + const internalFormat = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl + .RENDERBUFFER_INTERNAL_FORMAT); + expect(internalFormat).assertEqual(gl.RGBA4); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0203 + * @tc.name testGetRenderbufferParameterFourth + * @tc.desc Test getRenderbufferParameter. + */ + it('testGetRenderbufferParameterFourth', 0, async function (done) { + //initContext(); + console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); + const greenSize = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_GREEN_SIZE); + expect(greenSize).assertEqual(4); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0204 + * @tc.name testGetRenderbufferParameterError + * @tc.desc Test getRenderbufferParameter. + */ + it('testGetRenderbufferParameterError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + // gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); + const greenSize = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_GREEN_SIZE); + expect(greenSize).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0206 + * @tc.name testGetShaderParameterSecond + * @tc.desc Test getShaderParameter. + */ + it('testGetShaderParameterSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderParameter test start ...' + JSON.stringify(gl)); + const vertexShader = gl.createShader(gl.VERTEX_SHADER); + // const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + // gl.deleteShader(vertexShader); + const deleteStatus = gl.getShaderParameter(vertexShader, gl.DELETE_STATUS); + console.info('deleteStatus' + deleteStatus); + expect(deleteStatus).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0207 + * @tc.name testGetShaderParameterThird + * @tc.desc Test getShaderParameter. + */ + it('testGetShaderParameterThird', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderParameter test start ...' + JSON.stringify(gl)); + const vertexShader = gl.createShader(gl.VERTEX_SHADER); + gl.shaderSource(vertexShader, VSHADER_SOURCE); + gl.compileShader(vertexShader); + const compileStatus = gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS); + console.info('compileStatus' + compileStatus); + expect(compileStatus).assertEqual(true); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0208 + * @tc.name testGetShaderParameterFourth + * @tc.desc Test getShaderParameter. + */ + it('testGetShaderParameterFourth', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderParameter test start ...' + JSON.stringify(gl)); + var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + gl.shaderSource(fragmentShader, FSHADER_SOURCE); + gl.compileShader(fragmentShader); + const compileStatus = gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS); + console.info('compileStatus' + compileStatus); + expect(compileStatus).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0209 + * @tc.name testGetShaderParameterError + * @tc.desc Test getShaderParameter. + */ + it('testGetShaderParameterError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderParameter test start ...' + JSON.stringify(gl)); + var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + // gl.shaderSource(fragmentShader, FSHADER_SOURCE); + // gl.compileShader(fragmentShader); + const compileStatus = gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS); + console.info('compileStatus' + compileStatus); + const type = (compileStatus === true) + expect(type).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0210 + * @tc.name testGetShaderPrecisionFormat + * @tc.desc Test getShaderPrecisionFormat. + */ + it('testGetShaderPrecisionFormat', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); + const shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl + .MEDIUM_FLOAT); + console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); + const type = ((typeof shaderPrecisionFormat) === "object") + expect(type).assertEqual(true); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0211 + * @tc.name testGetTexParameterError + * @tc.desc Test getTexParameter. + */ + it('testGetTexParameterError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER); + console.info('texParameterfValue' + texParameterValue); + const type = (texParameterValue === gl.LINEAR_MIPMAP_NEAREST); + expect(type).assertEqual(false); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0212 + * @tc.name testGetTexParameterFirst + * @tc.desc Test getTexParameter. + */ + it('testGetTexParameterFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(gl.LINEAR_MIPMAP_NEAREST); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0213 + * @tc.name testGetTexParameterSecond + * @tc.desc Test getTexParameter. + */ + it('testGetTexParameterSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); + gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(gl.LINEAR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0214 + * @tc.name testGetUniform + * @tc.desc Test getUniform. + */ + it('testGetUniform', 0, async function (done) { + //initContext(); + console.info('jsWebGL getUniform test start ...' + JSON.stringify(gl)); + // const programObj = globalFunction(); + // + // const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + // const uniform = gl.getUniform(programObj, uniformLocation); + // console.info('getUniformLocation uniform' + uniform); + // expect(uniform.toString()).assertEqual([0,0,0,0].toString()); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0215 + * @tc.name testGetUniformError + * @tc.desc Test getUniform. + */ + it('testGetUniformError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getUniform test start ...' + JSON.stringify(gl)); + const programObj = gl.createProgram(); + + + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + const uniform = gl.getUniform(programObj, uniformLocation); + console.info('getUniformLocation uniform' + uniform); + expect(uniform).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0216 + * @tc.name testGetUniformLocation + * @tc.desc Test getUniformLocation. + */ + it('testGetUniformLocation', 0, async function (done) { + //initContext(); + console.info('jsWebGL getUniformLocation test start ...' + JSON.stringify(gl)); + // let programObj = globalFunction(); + // const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + // const uniform = gl.getUniform(programObj, uniformLocation); + // console.info('getUniformLocation uniform' + uniform); + // expect(uniform.toString()).assertEqual([0,0,0,0].toString()); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0217 + * @tc.name testGetUniformLocationError + * @tc.desc Test getUniformLocation. + */ + it('testGetUniformLocationError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getUniformLocation test start ...' + JSON.stringify(gl)); + const programObj = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + const uniform = gl.getUniform(programObj, uniformLocation); + console.info('getUniformLocation uniform' + uniform); + expect(uniform).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0218 + * @tc.name testGetParameter1 + * @tc.desc Test getParameter. + */ + it('testGetParameter1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + expect(textureParameter).assertEqual(33984); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0219 + * @tc.name testGetParameter2 + * @tc.desc Test getParameter. + */ + it('testGetParameter2', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + + //设置线宽: + gl.lineWidth(5); + // 获取线宽: + const lineWidthValue = gl.getParameter(gl.LINE_WIDTH); + console.info("lineWidthValue: " + lineWidthValue); + // 获取可用宽度的范围。返回一个Float32Array. + const lineWidthArray = gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE); + console.info("lineWidthArray: " + lineWidthArray); + expect(lineWidthValue).assertEqual(5); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0221 + * @tc.name testGetParameter4 + * @tc.desc Test getParameter. + */ + it('testGetParameter4', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + var framebuffer = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + + const framebufferParameter = gl.getParameter(gl.FRAMEBUFFER_BINDING); + console.info("framebufferParameter: " + framebufferParameter); + const isFramebuffer = gl.isFramebuffer(framebufferParameter); + console.info("isFramebuffer: " + isFramebuffer); + expect(isFramebuffer).assertEqual(true); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0222 + * @tc.name testGetParameter5 + * @tc.desc Test getParameter. + */ + it('testGetParameter5', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + const renderbuffer = gl.getParameter(gl.RENDERBUFFER_BINDING); + console.info("renderbuffer: " + renderbuffer); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer); + const isRenderbuffer = gl.isRenderbuffer(renderbuffer); + console.info("isRenderbuffer: " + isRenderbuffer); + expect(isRenderbuffer).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0223 + * @tc.name testGetParameter6 + * @tc.desc Test getParameter. + */ + it('testGetParameter6', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + const textureParameter = gl.getParameter(gl.TEXTURE_BINDING_2D); + console.info("texture: " + texture); + + const isTexture = gl.isTexture(textureParameter); + console.info("isTexture: " + isTexture); + expect(isTexture).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0224 + * @tc.name testGetParameter7 + * @tc.desc Test getParameter. + */ + it('testGetParameter7', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.blendColor(0, 0.5, 1, 1); + const blendColorValue = gl.getParameter(gl.BLEND_COLOR); + // Float32Array[0, 0.5, 1, 1] + console.info("blendColor --> getParameter: " + blendColorValue); + var blendColorArr = new Float32Array([0, 0.5, 1, 1]); + + const equalsblendColorType = (blendColorValue.constructor === blendColorArr.constructor); + console.info("blendColorequalsType: " + equalsblendColorType); + + const equalsblendColorValue = (blendColorValue.toString() === blendColorArr.toString()); + console.info("equalsblendColorValue: " + equalsblendColorValue); + expect(equalsblendColorType).assertEqual(true); + expect(equalsblendColorValue).assertEqual(true); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0225 + * @tc.name testGetParameter8 + * @tc.desc Test getParameter. + */ + it('testGetParameter8', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.depthMask(false); + // 要获得当前的深度遮罩值,传入 DEPTH_WRITEMASK 常量,返回 Boolean. + const depthMaskValue = gl.getParameter(gl.DEPTH_WRITEMASK); + // false + console.info("depthMaskValue: " + depthMaskValue); + expect(depthMaskValue).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0226 + * @tc.name testGetParameter9 + * @tc.desc Test getParameter. + */ + it('testGetParameter9', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.colorMask(true, true, true, false); + // 要获取当前的颜色掩码,请查询COLOR_WRITEMASK返回Array. + const colorMaskValue = gl.getParameter(gl.COLOR_WRITEMASK); + // [true, true, true, false] + console.info("colorMask --> getParameter: " + colorMaskValue); + expect(colorMaskValue.toString()).assertEqual([true, true, true, false].toString()); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0227 + * @tc.name testGetParameter10 + * @tc.desc Test getParameter. + */ + it('testGetParameter10', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + //用于设置深度缓冲区的深度清除值。 + gl.clearDepth(0.5); + //若要获取当前深度清除值,查询DEPTH_CLEAR_VALUE 常量。 + const clearDepthValue = gl.getParameter(gl.DEPTH_CLEAR_VALUE); + // 0.5 + console.info("clearDepth --> getParameter: " + clearDepthValue); + expect(clearDepthValue).assertEqual(0.5); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0228 + * @tc.name testGetParameter11 + * @tc.desc Test getParameter. + */ + it('testGetParameter11', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + const tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl.PACK_ALIGNMENT, 2); + gl.pixelStorei(gl.UNPACK_ALIGNMENT, 8); + //要检查像素数据的打包和解包值,可以使用 查询相同的像素存储参数WebGLRenderingContext.getParameter()。 + const packValue = gl.getParameter(gl.PACK_ALIGNMENT); + const unpackValue = gl.getParameter(gl.UNPACK_ALIGNMENT); + console.info("packValue: " + packValue); + console.info("unpackValue: " + unpackValue); + expect(packValue).assertEqual(2); + expect(unpackValue).assertEqual(8); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0229 + * @tc.name testGetParameter12 + * @tc.desc Test getParameter. + */ + it('testGetParameter12', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + const str = gl.getParameter(gl.SHADING_LANGUAGE_VERSION); + console.info("getParameter str: " + str); + // const strType = ((typeof str) === "object"); + const str1 = str.join(" "); + console.info("strType: " + str1); + expect(str1).assertEqual('OpenGL ES GLSL ES 3.20'); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0230 + * @tc.name testGetParameter13 + * @tc.desc Test getParameter. + */ + it('testGetParameter13', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.enable(gl.SAMPLE_COVERAGE); + gl.sampleCoverage(0.5, false); + // To check the sample coverage values, query the SAMPLE_COVERAGE_VALUE and SAMPLE_COVERAGE_INVERT constants. + const sampleCoverageValue = gl.getParameter(gl.SAMPLE_COVERAGE_VALUE); // 0.5 + const sampleCoverageInvert = gl.getParameter(gl.SAMPLE_COVERAGE_INVERT); // false + console.info("sampleCoverageValue: " + sampleCoverageValue); + console.info("sampleCoverageInvert: " + sampleCoverageInvert); + expect(sampleCoverageValue).assertEqual(0.5); + expect(sampleCoverageInvert).assertEqual(false); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0232 + * @tc.name testGetVertexAttrib + * @tc.desc Test getVertexAttrib. + */ + it('testGetVertexAttrib', 0, async function (done) { + //initContext(); + console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const bufferVertexAttrib = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING); + const isBuffer = gl.isBuffer(bufferVertexAttrib); + console.info("getVertexAttrib: bufferVertexAttrib" + bufferVertexAttrib); + expect(isBuffer).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0234 + * @tc.name testUniform1f + * @tc.desc Test uniform1f. + */ + it('testUniform1f', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform1f test start ...' + JSON.stringify(gl)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl.uniform1f(uniformLocation, 0.8); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(0); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0235 + * @tc.name testUniform1fError + * @tc.desc Test uniform1f. + */ + it('testUniform1fError', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform1f test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + + gl.uniform1f(uniformLocation, 0.8, 0.8); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0236 + * @tc.name testUniform2f + * @tc.desc Test uniform2f. + */ + it('testUniform2f', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform2f test start ...' + JSON.stringify(gl)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl.uniform2f(uniformLocation, 0.8, 0.8); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0237 + * @tc.name testUniform2fError + * @tc.desc Test uniform2f. + */ + it('testUniform2fError', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform2f test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + + gl.uniform2f(uniformLocation, 0.8); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0238 + * @tc.name testUniform3f + * @tc.desc Test uniform3f. + */ + it('testUniform3f', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform3f test start ...' + JSON.stringify(gl)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl.uniform3f(uniformLocation, 0.8, 0.8, 0.8); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(0); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0239 + * @tc.name testUniform3fError + * @tc.desc Test frontFace. + */ + it('testUniform3fError', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform3f test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + + gl.uniform3f(uniformLocation, 0.8, 0.8); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0240 + * @tc.name testUniform4f + * @tc.desc Test uniform4f. + */ + it('testUniform4f', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform4f test start ...' + JSON.stringify(gl)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl.uniform4f(uniformLocation, 0.8, 0.8, 0.8, 0.8); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0241 + * @tc.name testUniform4fError + * @tc.desc Test uniform4f. + */ + it('testUniform4fError', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform4f test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + + gl.uniform4f(uniformLocation, 0.8, 0.8); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0242 + * @tc.name testUniform1i + * @tc.desc Test uniform1i. + */ + it('testUniform1i', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform1i test start ...' + JSON.stringify(gl)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl.uniform1i(uniformLocation, 2); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(0); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0243 + * @tc.name testUniform1iError + * @tc.desc Test uniform1i. + */ + it('testUniform1iError', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform1i test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + + gl.uniform1i(uniformLocation, 0.8, 0.8); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0244 + * @tc.name testUniform2i + * @tc.desc Test uniform2i. + */ + it('testUniform2i', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform2i test start ...' + JSON.stringify(gl)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl.uniform2i(uniformLocation, 2, 2); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0245 + * @tc.name testUniform2iError + * @tc.desc Test uniform2i. + */ + it('testUniform2iError', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform2i test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + + gl.uniform2i(uniformLocation, 0.8, 0.8); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0246 + * @tc.name testUniform3i + * @tc.desc Test uniform3i. + */ + it('testUniform3i', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform3i test start ...' + JSON.stringify(gl)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl.uniform3i(uniformLocation, 2, 2, 2); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0247 + * @tc.name testUniform3iError + * @tc.desc Test uniform3i. + */ + it('testUniform3iError', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform3i test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + + gl.uniform3i(uniformLocation, 0.8, 0.8); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0248 + * @tc.name testUniform4i + * @tc.desc Test uniform4i. + */ + it('testUniform4i', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform4i test start ...' + JSON.stringify(gl)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl.uniform4i(uniformLocation, 2, 2, 2, 2); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0249 + * @tc.name testUniform4iError + * @tc.desc Test uniform4i. + */ + it('testUniform4iError', 0, async function (done) { + //initContext(); + console.info('jsWebGL uniform4i test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + + gl.uniform4i(uniformLocation, 0.8, 0.8); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0250 + * @tc.name testTexParameterf + * @tc.desc Test texParameterf. + */ + it('testTexParameterf', 0, async function (done) { + //initContext(); + console.info('jsWebGL texParameterf test start ...' + JSON.stringify(gl)); + gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(gl.LINEAR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0251 + * @tc.name testTexParameteri + * @tc.desc Test texParameteri. + */ + it('testTexParameteri', 0, async function (done) { + //initContext(); + console.info('jsWebGL texParameteri test start ...' + JSON.stringify(gl)); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(gl.LINEAR_MIPMAP_NEAREST); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0252 + * @tc.name testHint + * @tc.desc Test hint. + */ + it('testHint', 0, async function (done) { + //initContext(); + console.info('jsWebGL hint test start ...' + JSON.stringify(gl)); + gl.hint(gl.GENERATE_MIPMAP_HINT, gl.FASTEST); + gl.generateMipmap(gl2.TEXTURE_2D); + const error = gl.getError(); + console.info('error' + error); + expect(error).assertEqual(0); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0253 + * @tc.name testHintError + * @tc.desc Test hint. + */ + it('testHintError', 0, async function (done) { + //initContext(); + console.info('jsWebGL hint test start ...' + JSON.stringify(gl)); + gl.hint(gl.GENERATE_MIPMAP_HINT, gl.FASTEST); + gl.generateMipmap(gl.TEXTURE_2D); + const error = gl.getError(); + console.info('hintError' + error); + expect(error).assertEqual(1282); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0254 + * @tc.name testIsBuffer + * @tc.desc Test isBuffer. + */ + it('testIsBuffer', 0, async function (done) { + //initContext(); + console.info('jsWebGL isBuffer test start ...' + JSON.stringify(gl)); + const buffer = gl.createBuffer(); + + const isBuffer1 = gl.isBuffer(buffer); + console.info('isBuffer1' + isBuffer1); + expect(isBuffer1).assertEqual(false); + + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + + const isBuffer = gl.isBuffer(buffer); + console.info('isBuffer' + isBuffer); + expect(isBuffer).assertEqual(true); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0255 + * @tc.name testIsEnabled + * @tc.desc Test isEnabled. + */ + it('testIsEnabled', 0, async function (done) { + //initContext(); + console.info('jsWebGL isEnabled test start ...' + JSON.stringify(gl)); + + gl.enable(gl.STENCIL_TEST); + const isEnabledValue1 = gl.isEnabled(gl.STENCIL_TEST); + console.info("isEnabledValue1: " + isEnabledValue1); + expect(isEnabledValue1).assertEqual(true); + + // false + // 启用或说明给定的能力项,使用WebGLRenderingContext.enable()方法和WebGLRenderingContext.disable()方法: + gl.disable(gl.STENCIL_TEST); + const isEnabledValue2 = gl.isEnabled(gl.STENCIL_TEST); + console.info("isEnabledValue2: " + isEnabledValue2); + expect(isEnabledValue2).assertEqual(false); + + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0256 + * @tc.name testSampleCoverageFirst + * @tc.desc Test sampleCoverage. + */ + it('testSampleCoverageFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL sampleCoverage test start ...' + JSON.stringify(gl)); + gl.enable(gl.SAMPLE_COVERAGE); + gl.sampleCoverage(0.5, false); + // To check the sample coverage values, query the SAMPLE_COVERAGE_VALUE and SAMPLE_COVERAGE_INVERT constants. + const sampleCoverageInvert = gl.getParameter(gl.SAMPLE_COVERAGE_INVERT); // false + console.info("sampleCoverageInvert: " + sampleCoverageInvert); + + expect(sampleCoverageInvert).assertEqual(false); + + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0257 + * @tc.name testSampleCoverageSecond + * @tc.desc Test sampleCoverage. + */ + it('testSampleCoverageSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL sampleCoverage test start ...' + JSON.stringify(gl)); + gl.enable(gl.SAMPLE_COVERAGE); + gl.sampleCoverage(0.5, false); + // To check the sample coverage values, query the SAMPLE_COVERAGE_VALUE and SAMPLE_COVERAGE_INVERT constants. + const sampleCoverageValue = gl.getParameter(gl.SAMPLE_COVERAGE_VALUE); // 0.5 + console.info("sampleCoverageValue: " + sampleCoverageValue); + expect(sampleCoverageValue).assertEqual(0.5); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0258 + * @tc.name testScissor + * @tc.desc Test scissor. + */ + it('testScissor', 0, async function (done) { + //initContext(); + console.info('jsWebGL scissor test start ...' + JSON.stringify(gl)); + + // turn on scissor test + gl.enable(gl.SCISSOR_TEST); + // set the scissor rectangle + gl.scissor(0, 0, -200, 200); + // 如果宽度或高度为负值, gl.INVALID_VALUE(DEC:1281)则会引发错误 + const scissorErrorCode = gl.getError(); + console.info("scissorErrorCode: " + scissorErrorCode); + expect(scissorErrorCode).assertEqual(1281); + + gl.scissor(0, 0, 200, 200); + const scissorValue = gl.getParameter(gl.SCISSOR_BOX); + console.info("scissorValue: " + scissorValue); + // Int32Array[0, 0, 200, 200] + var testInt32Array = new Int32Array([0, 0, 200, 200]); + + // 判断数据类型 + const equalsScissorType = (scissorValue.constructor === testInt32Array.constructor); + // 判断数据值 + const equalsScissorValue = (scissorValue.toString() === testInt32Array.toString()); + + expect(equalsScissorType).assertEqual(true); + expect(equalsScissorValue).assertEqual(true); + + // execute drawing commands in the scissor box (e.g. clear) + // turn off scissor test again + gl.disable(gl.SCISSOR_TEST); + + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0259 + * @tc.name testRenderbufferStorage + * @tc.desc Test renderbufferStorage. + */ + it('testRenderbufferStorage', 0, async function (done) { + //initContext(); + console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); + const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH); + console.info("getRenderbufferParameter width: " + width); + expect(width).assertEqual(256); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0260 + * @tc.name testStencilFunc + * @tc.desc Test stencilFunc. + */ + it('testStencilFunc', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilFunc test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + gl.stencilFunc(gl.LESS, 0, 0b1110011); + const stencilFuncParameter = gl.getParameter(gl.STENCIL_FUNC); + console.info("stencilFunc stencilFuncParameter: " + stencilFuncParameter); + expect(stencilFuncParameter).assertEqual(gl.LESS); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0261 + * @tc.name testStencilFuncSeparate + * @tc.desc Test stencilFuncSeparate. + */ + it('testStencilFuncSeparate', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilFuncSeparate test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + gl.stencilFuncSeparate(gl.FRONT, gl.LESS, 0.2, 1110011); + const stencilFuncSeparateParameter = gl.getParameter(gl.STENCIL_FUNC); + console.info("stencilFuncSeparate stencilFuncSeparateParameter: " + + stencilFuncSeparateParameter); + expect(stencilFuncSeparateParameter).assertEqual(gl.LESS); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0262 + * @tc.name testStencilMask + * @tc.desc Test stencilMask. + */ + it('testStencilMask', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilMask test start ...' + JSON.stringify(gl)); + gl.stencilMask(110101); + const stencilMaskParameter = gl.getParameter(gl.STENCIL_WRITEMASK); + console.info("stencilMask stencilMaskParameter: " + stencilMaskParameter); + expect(stencilMaskParameter).assertEqual(110101); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0263 + * @tc.name testStencilMaskSeparate + * @tc.desc Test stencilMaskSeparate. + */ + it('testStencilMaskSeparate', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilMaskSeparate test start ...' + JSON.stringify(gl)); + gl.stencilMaskSeparate(gl.FRONT, 110101); + const stencilMaskSeparateParameter = gl.getParameter(gl.STENCIL_WRITEMASK); + console.info("stencilMaskSeparate stencilMaskSeparateParameter: " + + stencilMaskSeparateParameter); + expect(stencilMaskSeparateParameter).assertEqual(110101); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0264 + * @tc.name testStencilOp + * @tc.desc Test stencilOp. + */ + it('testStencilOp', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilOp test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + gl.stencilOp(gl.INCR, gl.DECR, gl.INVERT); + const stencilOpParameter = gl.getParameter(gl.STENCIL_FAIL); + console.info("stencilOp stencilOpParameter: " + stencilOpParameter); + expect(stencilOpParameter).assertEqual(gl.INCR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0265 + * @tc.name testStencilOpSeparate + * @tc.desc Test stencilOpSeparate. + */ + it('testStencilOpSeparate', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilOpSeparate test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + gl.stencilOpSeparate(gl.FRONT, gl.INCR, gl.DECR, gl.INVERT); + const stencilOpSeparateParameter = gl.getParameter(gl.STENCIL_FAIL); + console.info("stencilOpSeparate stencilOpSeparateParameter: " + stencilOpSeparateParameter); + expect(stencilOpSeparateParameter).assertEqual(gl.INCR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0266 + * @tc.name testShaderSource + * @tc.desc Test shaderSource. + */ + it('testShaderSource', 0, async function (done) { + //initContext(); + console.info('jsWebGL shaderSource test start ...' + JSON.stringify(gl)); + var shader = gl.createShader(gl.VERTEX_SHADER); + gl.shaderSource(shader, 'originalSource'); + + var source = gl.getShaderSource(shader); + console.info("shaderSource source: " + source); + expect(source).assertEqual('originalSource'); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0267 + * @tc.name testGetShaderSource + * @tc.desc Test getShaderSource. + */ + it('testGetShaderSource', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderSource test start ...' + JSON.stringify(gl)); + var shader = gl.createShader(gl.VERTEX_SHADER); + gl.shaderSource(shader, 'originalSource'); + + var source = gl.getShaderSource(shader); + console.info("getShaderSource source: " + source); + expect(source).assertEqual('originalSource'); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0269 + * @tc.name testGetShaderInfoLog + * @tc.desc Test getShaderInfoLog. + */ + it('testGetShaderInfoLog', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderInfoLog test start ...' + JSON.stringify(gl)); + var shader = gl.createShader(gl.VERTEX_SHADER); + gl.shaderSource(shader, "shaderCode"); + + /* compile shader source code. */ + gl.compileShader(shader); + const message = gl.getShaderInfoLog(shader); + console.info("getShaderInfoLog message: " + message); + expect(message).assertContain("0:1: L0001: Typename expected, found 'shaderCode'"); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0270 + * @tc.name testFrontFaceSecond + * @tc.desc Test frontFace. + */ + it('testFrontFaceSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL frontFace test start ...' + JSON.stringify(gl)); + gl.enable(gl.CULL_FACE); + gl.cullFace(gl.FRONT); + gl.frontFace(gl.CW); + const frontFaceParameter = gl.getParameter(gl.CULL_FACE_MODE); + console.info('frontFace -> frontFaceParameter' + frontFaceParameter); + gl.disable(gl.CULL_FACE); + expect(frontFaceParameter).assertEqual(gl.FRONT); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0271 + * @tc.name testGetUniformBlockIndex + * @tc.desc Test getUniformBlockIndex. + */ + it('testGetUniformBlockIndex', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 getUniformBlockIndex test start ...' + JSON.stringify(gl2)); + const program = gl.createProgram(); + const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); + gl2.uniformBlockBinding(program, blockIndex, 1); + console.info("uniformBlockBinding blockIndex: " + blockIndex); + expect(blockIndex).assertEqual(4294967295); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0272 + * @tc.name testGetActiveUniformBlockParameter + * @tc.desc Test getActiveUniformBlockParameter. + */ + it('testGetActiveUniformBlockParameter', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( + gl2)); + const program = globalFunction(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + const int32Array = new Int32Array([1, 2]); + gl2.uniform1iv(uniformLocation, int32Array); + const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); + gl2.uniformBlockBinding(program, blockIndex, 1); + const blockSize = gl2.getActiveUniformBlockParameter(program, blockIndex, gl + .UNIFORM_BLOCK_DATA_SIZE); + console.info("getActiveUniformBlockParameter blockSize" + blockSize); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_VALUE); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0275 + * @tc.name testCreateVertexArray + * @tc.desc Test createVertexArray. + */ + it('testCreateVertexArray', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 createVertexArray test start ...' + JSON.stringify(gl2)); + const vao = gl2.createVertexArray(); + const isVertexArray1 = gl2.isVertexArray(vao); + console.info("isVertexArray1" + isVertexArray1); + gl2.bindVertexArray(vao); + const isVertexArray = gl2.isVertexArray(vao); + console.info("isVertexArray" + isVertexArray); + expect(isVertexArray).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0276 + * @tc.name testBindVertexArray + * @tc.desc Test bindVertexArray. + */ + it('testBindVertexArray', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bindVertexArray test start ...' + JSON.stringify(gl2)); + const vao = gl2.createVertexArray(); + const isVertexArray1 = gl2.isVertexArray(vao); + console.info("isVertexArray1" + isVertexArray1); + gl2.bindVertexArray(vao); + const isVertexArray = gl2.isVertexArray(vao); + console.info("isVertexArray" + isVertexArray); + expect(isVertexArray).assertEqual(true); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0277 + * @tc.name testDeleteVertexArray + * @tc.desc Test deleteVertexArray. + */ + it('testDeleteVertexArray', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 deleteVertexArray test start ...' + JSON.stringify(gl2)); + const vao = gl2.createVertexArray(); + gl2.bindVertexArray(vao); + const isVertexArray1 = gl2.isVertexArray(vao); + console.info("isVertexArray1" + isVertexArray1); + gl2.deleteVertexArray(vao); + const isVertexArray = gl2.isVertexArray(vao); + console.info("isVertexArray" + isVertexArray); + expect(isVertexArray).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0278 + * @tc.name testUniform1fvFirst + * @tc.desc Test uniform1fv. + */ + it('testUniform1fvFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform1fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const flaot32list = new Float32Array([1.2, 2.2]); + gl2.uniform1fv(uniformLocation, flaot32list); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0279 + * @tc.name testUniform1fvSecond + * @tc.desc Test uniform1fv. + */ + it('testUniform1fvSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform1fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const flaot32list = new Float32Array([1.2, 2.2]); + gl2.uniform1fv(uniformLocation, flaot32list, 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0280 + * @tc.name testUniform1fvError + * @tc.desc Test uniform1fv. + */ + it('testUniform1fvError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform1fv test start ...' + JSON.stringify(gl2)); + const programObj = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const flaot32list = new Float32Array([1.2, 2.2]); + gl2.uniform1fv(uniformLocation, flaot32list); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0281 + * @tc.name testUniform1fvThird + * @tc.desc Test uniform1fv. + */ + it('testUniform1fvThird', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform1fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform1fv(uniformLocation, [1.2, 2.2]); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0282 + * @tc.name testUniform1fv4 + * @tc.desc Test uniform1fv. + */ + it('testUniform1fv4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform1fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform1fv(uniformLocation, [1.2, 2.2], 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0283 + * @tc.name testUniform2fvFirst + * @tc.desc Test uniform2fv. + */ + it('testUniform2fvFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform2fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const flaot32list = new Float32Array([1.2, 2.2]); + gl2.uniform2fv(uniformLocation, flaot32list); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0284 + * @tc.name testUniform2fvSecond + * @tc.desc Test uniform2fv. + */ + it('testUniform2fvSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform2fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const flaot32list = new Float32Array([1.2, 2.2], 0, 0); + gl2.uniform2fv(uniformLocation, flaot32list); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0285 + * @tc.name testUniform2fvError + * @tc.desc Test uniform2fv. + */ + it('testUniform2fvError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform2fv test start ...' + JSON.stringify(gl2)); + const programObj = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const flaot32list = new Float32Array([1.2, 2.2]); + gl2.uniform2fv(uniformLocation, flaot32list); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0286 + * @tc.name testUniform2fv3 + * @tc.desc Test uniform2fv. + */ + it('testUniform2fv3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform2fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform2fv(uniformLocation, [1.2, 2.2]); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0287 + * @tc.name testUniform2fv4 + * @tc.desc Test uniform2fv. + */ + it('testUniform2fv4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform2fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform2fv(uniformLocation, [1.2, 2.2], 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0288 + * @tc.name testUniform3fvFirst + * @tc.desc Test frontFace. + */ + it('testUniform3fvFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform3fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const flaot32list = new Float32Array([1.2, 2.2]); + gl2.uniform3fv(uniformLocation, flaot32list); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0289 + * @tc.name testUniform3fvSecond + * @tc.desc Test uniform3fv. + */ + it('testUniform3fvSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform3fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const flaot32list = new Float32Array([1.2, 2.2]); + gl2.uniform3fv(uniformLocation, flaot32list, 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0290 + * @tc.name testUniform3fvError + * @tc.desc Test uniform3fv. + */ + it('testUniform3fvError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform3fv test start ...' + JSON.stringify(gl2)); + const programObj = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const flaot32list = new Float32Array([1.2, 2.2]); + gl2.uniform3fv(uniformLocation, flaot32list); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0291 + * @tc.name testUniform3fv3 + * @tc.desc Test uniform3fv. + */ + it('testUniform3fv3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform3fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform3fv(uniformLocation, [1.2, 2.2]); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0292 + * @tc.name testUniform3fv4 + * @tc.desc Test uniform3fv. + */ + it('testUniform3fv4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform3fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform3fv(uniformLocation, [1.2, 2.2], 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0293 + * @tc.name testUniform4fvFirst + * @tc.desc Test uniform4fv. + */ + it('testUniform4fvFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform4fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const flaot32list = new Float32Array([1.2, 2.2]); + gl2.uniform4fv(uniformLocation, flaot32list); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0294 + * @tc.name testUniform4fvSecond + * @tc.desc Test uniform4fv. + */ + it('testUniform4fvSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform4fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const flaot32list = new Float32Array([1.2, 2.2]); + gl2.uniform4fv(uniformLocation, flaot32list, 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0295 + * @tc.name testUniform4fvError + * @tc.desc Test uniform4fv. + */ + it('testUniform4fvError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform4fv test start ...' + JSON.stringify(gl2)); + const programObj = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const flaot32list = new Float32Array([1.2, 2.2]); + gl2.uniform4fv(uniformLocation, flaot32list); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0296 + * @tc.name testUniform4fv3 + * @tc.desc Test uniform4fv. + */ + it('testUniform4fv3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform4fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform4fv(uniformLocation, [1.2, 2.2]); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0297 + * @tc.name testUniform4fvThird + * @tc.desc Test uniform4fv. + */ + it('testUniform4fvThird', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform4fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform4fv(uniformLocation, [1.2, 2.2], 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0298 + * @tc.name testUniform1ivFirst + * @tc.desc Test uniform1iv. + */ + it('testUniform1ivFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform1iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const int32Array = new Int32Array([1, 2]); + gl2.uniform1iv(uniformLocation, int32Array); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0299 + * @tc.name testUniform1ivSecond + * @tc.desc Test uniform1iv. + */ + it('testUniform1ivSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform1iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const int32Array = new Int32Array([1, 2]); + gl2.uniform1iv(uniformLocation, int32Array, 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0300 + * @tc.name testUniform1ivError + * @tc.desc Test uniform1iv. + */ + it('testUniform1ivError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform1iv test start ...' + JSON.stringify(gl2)); + const programObj = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const int32Array = new Int32Array([1, 2]); + gl2.uniform1iv(uniformLocation, int32Array); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + }) +} diff --git a/graphic/webGL/src/main/js/test/WebGL.test04.js b/graphic/webGL/src/main/js/test/WebGL.test04.js new file mode 100644 index 0000000000000000000000000000000000000000..0de1efc3711977ab2cae3770f0eaa10f7e975dd4 --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test04.js @@ -0,0 +1,1922 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl4() { + describe('webgl1Test_webgl4', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_0301 + * @tc.name testUniform1iv3 + * @tc.desc Test uniform1iv. + */ + it('testUniform1iv3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform1iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform1iv(uniformLocation, [1, 2]); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0302 + * @tc.name testUniform1iv4 + * @tc.desc Test uniform1iv. + */ + it('testUniform1iv4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform1iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform1iv(uniformLocation, [1, 2], 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0303 + * @tc.name testUniform2ivFirst + * @tc.desc Test uniform2iv. + */ + it('testUniform2ivFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform2iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const int32Array = new Int32Array([1, 2]); + gl2.uniform2iv(uniformLocation, int32Array); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0304 + * @tc.name testUniform2ivSecond + * @tc.desc Test uniform2iv. + */ + it('testUniform2ivSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform2iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const int32Array = new Int32Array([1, 2]); + gl2.uniform2iv(uniformLocation, int32Array, 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0305 + * @tc.name testUniform2ivError + * @tc.desc Test uniform2iv. + */ + it('testUniform2ivError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform2iv test start ...' + JSON.stringify(gl2)); + const programObj = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const int32Array = new Int32Array([1, 2]); + gl2.uniform2iv(uniformLocation, int32Array); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0306 + * @tc.name testUniform2iv3 + * @tc.desc Test uniform2iv. + */ + it('testUniform2iv3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform2iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform2iv(uniformLocation, [1, 2]); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0307 + * @tc.name testUniform2iv4 + * @tc.desc Test uniform2iv. + */ + it('testUniform2iv4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform2iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform2iv(uniformLocation, [1, 2], 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0308 + * @tc.name testUniform3ivFirst + * @tc.desc Test uniform3iv. + */ + it('testUniform3ivFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform3iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const int32Array = new Int32Array([1, 2]); + gl2.uniform3iv(uniformLocation, int32Array); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0309 + * @tc.name testUniform3ivSecond + * @tc.desc Test uniform3iv. + */ + it('testUniform3ivSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform3iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const int32Array = new Int32Array([1, 2]); + gl2.uniform3iv(uniformLocation, int32Array, 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0310 + * @tc.name testUniform3ivError + * @tc.desc Test uniform3iv. + */ + it('testUniform3ivError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform3iv test start ...' + JSON.stringify(gl2)); + const programObj = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const int32Array = new Int32Array([1, 2]); + gl2.uniform3iv(uniformLocation, int32Array); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0311 + * @tc.name testUniform3iv3 + * @tc.desc Test uniform3iv. + */ + it('testUniform3iv3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform3iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform3iv(uniformLocation, [1, 2]); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0312 + * @tc.name testUniform3iv4 + * @tc.desc Test uniform3iv. + */ + it('testUniform3iv4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform3iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform3iv(uniformLocation, [1, 2], 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0313 + * @tc.name testUniform4ivFirst + * @tc.desc Test uniform4iv. + */ + it('testUniform4ivFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform4iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const int32Array = new Int32Array([1, 2]); + gl2.uniform4iv(uniformLocation, int32Array); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0314 + * @tc.name testUniform4ivSecond + * @tc.desc Test uniform4iv. + */ + it('testUniform4ivSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform4iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const int32Array = new Int32Array([1, 2]); + gl2.uniform4iv(uniformLocation, int32Array, 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0315 + * @tc.name testUniform4ivError + * @tc.desc Test uniform4iv. + */ + it('testUniform4ivError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform4iv test start ...' + JSON.stringify(gl2)); + const programObj = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + const int32Array = new Int32Array([1, 2]); + gl2.uniform4iv(uniformLocation, int32Array); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0316 + * @tc.name testUniform4iv3 + * @tc.desc Test uniform4iv. + */ + it('testUniform4iv3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform4iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform4iv(uniformLocation, [1, 2]); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0317 + * @tc.name testUniform4iv4 + * @tc.desc Test uniform4iv. + */ + it('testUniform4iv4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniform4iv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniform4iv(uniformLocation, [1, 2], 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0318 + * @tc.name testUniformMatrix4fvFirst + * @tc.desc Test uniformMatrix4fv. + */ + it('testUniformMatrix4fvFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix4fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + var flaot32list = new Float32Array([1, 2]); + gl2.uniformMatrix4fv(uniformLocation, true, flaot32list); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0319 + * @tc.name testUniformMatrix4fv2 + * @tc.desc Test uniformMatrix4fv. + */ + it('testUniformMatrix4fv2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix4fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + var flaot32list = new Float32Array([1, 2]); + gl2.uniformMatrix4fv(uniformLocation, true, flaot32list, 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0320 + * @tc.name testUniformMatrix4fvError + * @tc.desc Test uniformMatrix4fv. + */ + it('testUniformMatrix4fvError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix4fv test start ...' + JSON.stringify(gl2)); + const programObj = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + var flaot32list = new Float32Array([1, 2]); + gl2.uniformMatrix4fv(uniformLocation, true, flaot32list); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0321 + * @tc.name testUniformMatrix4fv3 + * @tc.desc Test uniformMatrix4fv. + */ + it('testUniformMatrix4fv3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix4fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniformMatrix4fv(uniformLocation, true, [1, 2]); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0322 + * @tc.name testUniformMatrix4fv4 + * @tc.desc Test uniformMatrix4fv. + */ + it('testUniformMatrix4fv4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix4fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniformMatrix4fv(uniformLocation, true, [1, 2], 0, 0); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0323 + * @tc.name testUniformMatrix3fvFirst + * @tc.desc Test uniformMatrix3fv. + */ + it('testUniformMatrix3fvFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix3fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + var flaot32list = new Float32Array([1, 2]); + gl2.uniformMatrix3fv(uniformLocation, true, flaot32list); + + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0324 + * @tc.name testUniformMatrix3fv2 + * @tc.desc Test uniformMatrix3fv. + */ + it('testUniformMatrix3fv2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix3fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + var flaot32list = new Float32Array([1, 2]); + gl2.uniformMatrix3fv(uniformLocation, true, flaot32list, 0, 0); + + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0325 + * @tc.name testUniformMatrix3fvError + * @tc.desc Test uniformMatrix3fv. + */ + it('testUniformMatrix3fvError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix3fv test start ...' + JSON.stringify(gl2)); + const programObj = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + var flaot32list = new Float32Array([1, 2]); + gl2.uniformMatrix3fv(uniformLocation, true, flaot32list); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0326 + * @tc.name testUniformMatrix3fv3 + * @tc.desc Test uniformMatrix3fv. + */ + it('testUniformMatrix3fv3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix3fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniformMatrix3fv(uniformLocation, true, [1, 2]); + + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0327 + * @tc.name testUniformMatrix3fv4 + * @tc.desc Test uniformMatrix3fv. + */ + it('testUniformMatrix3fv4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix3fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniformMatrix3fv(uniformLocation, true, [1, 2], 0, 0); + + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0328 + * @tc.name testUniformMatrix2fv1 + * @tc.desc Test uniformMatrix2fv. + */ + it('testUniformMatrix2fv1', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix2fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + var flaot32list = new Float32Array([1, 2]); + gl2.uniformMatrix2fv(uniformLocation, true, flaot32list); + + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0329 + * @tc.name testUniformMatrix2fv2 + * @tc.desc Test uniformMatrix2fv. + */ + it('testUniformMatrix2fv2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix2fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + var flaot32list = new Float32Array([1, 2]); + gl2.uniformMatrix2fv(uniformLocation, true, flaot32list, 0, 0); + + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0330 + * @tc.name testUniformMatrix2fvError + * @tc.desc Test uniformMatrix2fv. + */ + it('testUniformMatrix2fvError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix2fv test start ...' + JSON.stringify(gl2)); + const programObj = gl.createProgram(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + var flaot32list = new Float32Array([1, 2]); + gl2.uniformMatrix2fv(uniformLocation, true, flaot32list); + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(1282); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0331 + * @tc.name testUniformMatrix2fv3 + * @tc.desc Test uniformMatrix2fv. + */ + it('testUniformMatrix2fv3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix2fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniformMatrix2fv(uniformLocation, true, [1, 2]); + + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0332 + * @tc.name testUniformMatrix2fv4 + * @tc.desc Test uniformMatrix2fv. + */ + it('testUniformMatrix2fv4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformMatrix2fv test start ...' + JSON.stringify(gl2)); + const programObj = globalFunction(); + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + + gl2.uniformMatrix2fv(uniformLocation, true, [1, 2], 0, 0); + + const error = gl.getError(); + console.info("error: " + error); + expect(error).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0333 + * @tc.name testBufferData1 + * @tc.desc Test bufferData. + */ + it('testBufferData1', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + const buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl2.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + const bufferSize = gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE); + console.info('bufferSize' + bufferSize); + expect(bufferSize).assertEqual(1024); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0334 + * @tc.name testBufferData2 + * @tc.desc Test bufferData. + */ + it('testBufferData2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + const buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl2.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + const bufferUsage = gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_USAGE); + console.info('bufferUsage' + bufferUsage); + expect(bufferUsage).assertEqual(gl.STATIC_DRAW); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0335 + * @tc.name testBufferData3 + * @tc.desc Test bufferData. + */ + it('testBufferData3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + gl2.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.DYNAMIC_READ); + const errorCode = gl.getError(); + console.info("webgltest bufferData getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0336 + * @tc.name testBufferData4 + * @tc.desc Test bufferData. + */ + it('testBufferData4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + gl2.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.DYNAMIC_READ, 0, 0); + const errorCode = gl.getError(); + console.info("webgl2test bufferData getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0337 + * @tc.name testBufferDataError + * @tc.desc Test bufferData. + */ + it('testBufferDataError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + gl2.bufferData(1024, gl.STATIC_DRAW); + const bufferSize = gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE); + console.info('bufferSize' + bufferSize); + const type = (bufferSize === 1024) + expect(type).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0338 + * @tc.name testBufferSubData + * @tc.desc Test bufferData. + */ + it('testBufferSubData', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + gl2.bufferSubData(gl.COPY_READ_BUFFER, 512, new ArrayBuffer(8)); + const errorCode = gl.getError(); + console.info("webgl2test bufferSubData getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0339 + * @tc.name testBufferSubData2 + * @tc.desc Test bufferData. + */ + it('testBufferSubData2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + gl2.bufferSubData(gl.COPY_READ_BUFFER, 512, new ArrayBuffer(8), 0, 0); + const errorCode = gl.getError(); + console.info("webgl2test bufferSubData getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0340 + * @tc.name testTexImage2D + * @tc.desc Test texImage2D. + */ + it('testTexImage2D', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texImage2D(gl2.TEXTURE_2D, 0, 32, 512, 512, 0, 32, 32, view); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0341 + * @tc.name testTexImage2D2 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + gl2.texImage2D(gl2.TEXTURE_2D, 0, gl.RGB8, 512, 512, 0, gl.RGB, gl.UNSIGNED_BYTE, 0); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0342 + * @tc.name testTexImage2D3 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texImage2D(gl2.TEXTURE_2D, 0, gl.R16F, 512, 512, 0, gl.RED, gl.FLOAT, view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0343 + * @tc.name testTexImage2D4 + * @tc.desc Test frontFace. + */ + it('testTexImage2D4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texImage2D(gl2.TEXTURE_2D, 0, gl.R16F, 512, 512, 0, gl.RED, gl.FLOAT, view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0344 + * @tc.name testTexSubImage2D5 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D5', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl.RED, gl.FLOAT, view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0345 + * @tc.name testTexSubImage2D6 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D6', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); + gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl.RED, gl.FLOAT, 0); + const errorCode = gl.getError(); + console.info("webgl2test texSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0346 + * @tc.name testTexSubImage2D7 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D7', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl.RGBA, gl.UNSIGNED_BYTE, view); + const errorCode = gl.getError(); + console.info("webgl2test texSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0347 + * @tc.name testTexSubImage2D_8 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_8', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl.RGBA, gl.UNSIGNED_BYTE, view); + const errorCode = gl.getError(); + console.info("webgl2test texSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0348 + * @tc.name testCompressedTexImage2D9 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D9', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 compressedTexImage2D test start ...' + JSON.stringify(gl2)); + gl2.compressedTexImage2D(gl2.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, gl.PIXEL_UNPACK_BUFFER, 0); + const errorCode = gl.getError(); + console.info("webgl2test compressedTexImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0349 + * @tc.name testCompressedTexImage2D11 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D11', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 compressedTexImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.compressedTexImage2D(gl2.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, view, 0, 0); + const errorCode = gl.getError(); + console.info("webgl2test compressedTexImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0350 + * @tc.name testCompressedTexSubImage2D12 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D12', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 compressedTexSubImage2D test start ...' + JSON.stringify(gl2)); + gl2.compressedTexSubImage2D(gl2.TEXTURE_2D, 0, 256, 256, 512, 512, 0x83F3, gl + .PIXEL_UNPACK_BUFFER, 0); + const errorCode = gl.getError(); + console.info("webgl2test compressedTexSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0351 + * @tc.name testCompressedTexSubImage2D13 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D13', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 compressedTexSubImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.compressedTexSubImage2D(gl2.TEXTURE_2D, 0, 256, 256, 512, 512, 0x83F3, view, 0, 0); + const errorCode = gl.getError(); + console.info("webgl2test compressedTexSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0352 + * @tc.name testReadPixelsFirst + * @tc.desc Test readPixels. + */ + it('testReadPixelsFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_BYTE, view); + const errorCode = gl.getError(); + console.info("webgl2test readPixels getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0353 + * @tc.name testReadPixelsSecond + * @tc.desc Test readPixels. + */ + it('testReadPixelsSecond', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); + gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_BYTE, 0); + const errorCode = gl.getError(); + console.info("webgl2test readPixels getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0354 + * @tc.name testReadPixelsThird + * @tc.desc Test readPixels. + */ + it('testReadPixelsThird', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_BYTE, view, 0); + const errorCode = gl.getError(); + console.info("webgl2test readPixels getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0355 + * @tc.name testReadPixelsError + * @tc.desc Test readPixels. + */ + it('testReadPixelsError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + const returnVale = gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_BYTE, view, 0); + const errorCode = gl.getError(); + console.info("webgl2test readPixels getError: " + errorCode); + const type = + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /* + * ***************************************** GT ************************************************ + */ + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0356 + * @tc.name testIsFramebuffer + * @tc.desc Test isFramebuffer. + */ + it('testIsFramebuffer', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testIsFramebuffer test start ...66'); + var framebuffer = gl.createFramebuffer(); + const isFramebuffer = gl.isFramebuffer(framebuffer); + console.info("createFramebuffer --> isFramebuffer: " + isFramebuffer); + expect(isFramebuffer).assertEqual(false); + //deleteContext(); + done(); + } catch (e) { + console.log("testIsFramebuffer has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0357 + * @tc.name testIsFramebuffer_01 + * @tc.desc Test isFramebuffer. + */ + it('testIsFramebuffer_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testIsFramebuffer_01 test start ...66'); + var framebuffer = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + const isFramebuffer = gl.isFramebuffer(framebuffer); + console.info("createFramebuffer --> bindFramebuffer --> isFramebuffer: " + + isFramebuffer); + expect(isFramebuffer).assertEqual(true); + //deleteContext(); + done(); + } catch (e) { + console.log("testIsFramebuffer_01 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0358 + * @tc.name testIsFramebuffer_02 + * @tc.desc Test isFramebuffer. + */ + it('testIsFramebuffer_02', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testIsFramebuffer_02 test start ...66'); + var programobject = gl.createProgram(); + const isFramebuffer = gl.isFramebuffer(programobject); + console.info("createFramebuffer --> isFramebuffer: " + isFramebuffer); + expect(isFramebuffer).assertEqual(false); + //deleteContext(); + done(); + } catch (e) { + console.log("testIsFramebuffer_02 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0359 + * @tc.name testIsFramebuffer_03 + * @tc.desc Test isFramebuffer. + */ + it('testIsFramebuffer_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsFramebuffer_03 test start ...66'); + var shader = gl.createShader(gl.VERTEX_SHADER) + const isFramebuffer = gl.isFramebuffer(shader); + console.info("createFramebuffer --> isFramebuffer: " + isFramebuffer); + expect(isFramebuffer).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0360 + * @tc.name testIsFramebuffer_04 + * @tc.desc Test isFramebuffer. + */ + it('testIsFramebuffer_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsFramebuffer_04 test start ...66'); + var renderbufferObject = gl.createRenderbuffer(); + const isFramebuffer = gl.isFramebuffer(renderbufferObject); + console.info("createFramebuffer --> isFramebuffer: " + isFramebuffer); + expect(isFramebuffer).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0361 + * @tc.name testIsProgram + * @tc.desc Test isProgram. + */ + it('testIsProgram', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsProgram test start ...66'); + var program = gl.createProgram(); + const isProgram = gl.isProgram(program); + console.info("createProgram --> isProgram: " + isProgram); + expect(isProgram).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0362 + * @tc.name testIsProgram_01 + * @tc.desc Test isProgram. + */ + it('testIsProgram_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsProgram_01 test start ...66'); + var framebuffer = gl.createFramebuffer(); + const programError = gl.getError(); + console.info("createProgram --> programError: " + programError); + const isProgram = gl.isProgram(framebuffer); + console.info("createProgram --> isProgram: " + isProgram); + expect(isProgram).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0363 + * @tc.name testIsProgram_02 + * @tc.desc Test isProgram. + */ + it('testIsProgram_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsProgram_02 test start ...66'); + var renderbuffer = gl.createRenderbuffer(); + const programError = gl.getError(); + console.info("createProgram --> programError: " + programError); + const isProgram = gl.isProgram(renderbuffer); + console.info("createProgram --> isProgram: " + isProgram); + expect(isProgram).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0364 + * @tc.name testIsProgram_03 + * @tc.desc Test isProgram. + */ + it('testIsProgram_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsProgram_03 test start ...66'); + var shader = gl.createShader(gl.VERTEX_SHADER); + const programError = gl.getError(); + console.info("createProgram --> programError: " + programError); + const isProgram = gl.isProgram(shader); + console.info("createProgram --> isProgram: " + isProgram); + expect(isProgram).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0366 + * @tc.name testIsRenderbuffer + * @tc.desc Test isRenderbuffer. + */ + it('testIsRenderbuffer', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsRenderbuffer test start ...66'); + var renderbuffer = gl.createRenderbuffer(); + const isrenderbuffer = gl.isRenderbuffer(renderbuffer); + console.info("createRenderbuffer --> isRenderbuffer: " + isrenderbuffer); + expect(isrenderbuffer).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0367 + * @tc.name testIsRenderbuffer_01 + * @tc.desc Test isRenderbuffer. + */ + it('testIsRenderbuffer_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsRenderbuffer_01 test start ...66'); + var renderbuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer); + const isrenderbuffer = gl.isRenderbuffer(renderbuffer); + console.info("createRenderbuffer --> isRenderbuffer: " + isrenderbuffer); + expect(isrenderbuffer).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0368 + * @tc.name testIsRenderbuffer_02 + * @tc.desc Test isRenderbuffer. + */ + it('testIsRenderbuffer_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsRenderbuffer_02 test start ...66'); + var framebuffer = gl.createFramebuffer(); + const isrenderbuffer = gl.isRenderbuffer(framebuffer); + console.info("createRenderbuffer --> isRenderbuffer: " + isrenderbuffer); + expect(isrenderbuffer).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0369 + * @tc.name testIsRenderbuffer_03 + * @tc.desc Test isRenderbuffer. + */ + it('testIsRenderbuffer_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsRenderbuffer_03 test start ...66'); + var programobject = gl.createProgram(); + const isrenderbuffer = gl.isRenderbuffer(programobject); + console.info("createRenderbuffer --> isRenderbuffer: " + isrenderbuffer); + expect(isrenderbuffer).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0371 + * @tc.name testIsShader + * @tc.desc Test isShader. + */ + it('testIsShader', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsShader test start ...66'); + var shader = gl.createShader(gl.VERTEX_SHADER) + const isShader = gl.isShader(shader); + console.info("createShader --> isShader: " + isShader); + expect(isShader).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0372 + * @tc.name testIsShader_01 + * @tc.desc Test isShader. + */ + it('testIsShader_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsShader_01 test start ...66'); + var shader = gl.createShader(gl.FRAGMENT_SHADER) + const isShader = gl.isShader(shader); + console.info("createShader --> isShader: " + isShader); + expect(isShader).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0373 + * @tc.name testIsShader_02 + * @tc.desc Test isShader. + */ + it('testIsShader_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsShader_02 test start ...66'); + var renderbuffer = gl.createRenderbuffer(); + const isShader = gl.isShader(renderbuffer); + console.info("createShader --> isShader: " + isShader); + expect(isShader).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0374 + * @tc.name testIsShader_03 + * @tc.desc Test isShader. + */ + it('testIsShader_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsShader_03 test start ...66'); + var framebuffer = gl.createFramebuffer(); + const isShader = gl.isShader(framebuffer); + console.info("createShader --> isShader: " + isShader); + expect(isShader).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0375 + * @tc.name testIsShader_04 + * @tc.desc Test isShader. + */ + it('testIsShader_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsShader_04 test start ...66'); + var programobject = gl.createProgram(); + const isShader = gl.isShader(programobject); + console.info("createShader --> isShader: " + isShader); + expect(isShader).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0376 + * @tc.name testIsTexture + * @tc.desc Test isTexture. + */ + it('testIsTexture', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsTexture test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + const isTexture = gl.isTexture(texture); + console.info("createShader --> isTexture: " + isTexture); + expect(isTexture).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0377 + * @tc.name testIsTexture_01 + * @tc.desc Test isTexture. + */ + it('testIsTexture_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsTexture_01 test start ...66'); + var texture = gl.createTexture(); + const isTexture = gl.isTexture(texture); + console.info("createShader --> isTexture: " + isTexture); + expect(isTexture).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0378 + * @tc.name testIsTexture_02 + * @tc.desc Test isTexture. + */ + it('testIsTexture_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsTexture_02 test start ...66'); + var programobject = gl.createProgram(); + const isTexture = gl.isTexture(programobject); + console.info("createShader --> isTexture: " + isTexture); + expect(isTexture).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0379 + * @tc.name testIsTexture_03 + * @tc.desc Test isTexture. + */ + it('testIsTexture_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsTexture_03 test start ...66'); + var renderbuffer = gl.createRenderbuffer(); + const isTexture = gl.isTexture(renderbuffer); + console.info("createShader --> isTexture: " + isTexture); + expect(isTexture).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0380 + * @tc.name testIsTexture_04 + * @tc.desc Test isTexture. + */ + it('testIsTexture_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsTexture_04 test start ...66'); + var framebuffer = gl.createFramebuffer(); + const isTexture = gl.isTexture(framebuffer); + console.info("createShader --> isTexture: " + isTexture); + expect(isTexture).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0383 + * @tc.name testLineWidth_01 + * @tc.desc Test lineWidth. + */ + it('testLineWidth_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testLineWidth_01 test start ...66'); + gl.lineWidth(-1); + const windtherror = gl.getError(); + console.info("windtherror: " + windtherror); + expect(windtherror).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0384 + * @tc.name testLineWidth_02 + * @tc.desc Test lineWidth. + */ + it('testLineWidth_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testLineWidth_02 test start ...66'); + gl.lineWidth(0); + const windtherror = gl.getError(); + console.info("windtherror: " + windtherror); + expect(windtherror).assertEqual(gl.INVALID_VALUE); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0385 + * @tc.name testLinkProgram + * @tc.desc Test linkProgram. + */ + it('testLinkProgram', 0, async function (done) { + //initContext(); + console.info('jsWebGL testLinkProgram test start ...66'); + console.info('jsWebGL testLinkProgram test start ...' + JSON.stringify(gl)); + var shaderProg = gl.createProgram(); + gl.linkProgram(shaderProg); + const linkProgramError = gl.getError(); + console.info("linkProgramError: " + linkProgramError); + expect(linkProgramError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0388 + * @tc.name testLinkProgram_03 + * @tc.desc Test linkProgram. + */ + it('testLinkProgram_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testLinkProgram_03 test start ...66'); + var shader = gl.createShader(gl.VERTEX_SHADER); + gl.linkProgram(shader); + const linkProgramError = gl.getError(); + console.info("linkProgramError: " + linkProgramError); + expect(linkProgramError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0389 + * @tc.name testLinkProgram_04 + * @tc.desc Test linkProgram. + */ + it('testLinkProgram_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testLinkProgram_04 test start ...66'); + gl.linkProgram("-123"); + const linkProgramError = gl.getError(); + console.info("linkProgramError: " + linkProgramError); + expect(linkProgramError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0390 + * @tc.name testPixelStorei + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei test start ...66'); + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl.PACK_ALIGNMENT, 4); + gl.pixelStorei(gl.UNPACK_ALIGNMENT, 8); + const packValue = gl.getParameter(gl.PACK_ALIGNMENT); + const unpackValue = gl.getParameter(gl.UNPACK_ALIGNMENT); + console.info("packValue: " + packValue); + console.info("unpackValue: " + unpackValue); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0391 + * @tc.name testPixelStorei_01 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_01 test start ...66'); + var tex = gl.createTexture(); + gl.pixelStorei(gl.UNPACK_ALIGNMENT, 8); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0392 + * @tc.name testPixelStorei_02 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_02 test start ...66'); + var tex = gl.createTexture(); + gl.pixelStorei(gl.LINE_LOOP, 8); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0393 + * @tc.name testPixelStorei_03 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_03 test start ...66'); + var tex = gl.createTexture(); + gl.pixelStorei(gl.ONE_MINUS_SRC_COLOR, 8); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0394 + * @tc.name testPixelStorei_04 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_04 test start ...66'); + var tex = gl.createTexture(); + gl.pixelStorei(gl.ONE_MINUS_SRC_COLOR, -1); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0395 + * @tc.name testPolygonOffset + * @tc.desc Test polygonOffset. + */ + it('testPolygonOffset', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPolygonOffset test start ...66'); + gl.enable(gl.POLYGON_OFFSET_FILL); + gl.polygonOffset(2, 3); + const polygonOffsetError = gl.getError(); + console.info("polygonOffsetError: " + polygonOffsetError); + expect(polygonOffsetError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0396 + * @tc.name testPolygonOffset_01 + * @tc.desc Test polygonOffset. + */ + it('testPolygonOffset_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPolygonOffset_01 test start ...66'); + gl.enable(gl.TRIANGLE_STRIP); + gl.polygonOffset(-2, 3); + const polygonOffsetError = gl.getError(); + console.info("polygonOffsetError: " + polygonOffsetError); + expect(polygonOffsetError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0397 + * @tc.name testPolygonOffset_02 + * @tc.desc Test polygonOffset. + */ + it('testPolygonOffset_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPolygonOffset_02 test start ...66'); + gl.enable(gl.TRIANGLES); + gl.polygonOffset(-2, -3); + const polygonOffsetError = gl.getError(); + console.info("polygonOffsetError: " + polygonOffsetError); + expect(polygonOffsetError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0398 + * @tc.name testPolygonOffset_03 + * @tc.desc Test polygonOffset. + */ + it('testPolygonOffset_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPolygonOffset_03 test start ...66'); + gl.enable(gl.LINES); + gl.polygonOffset(0, 0); + const polygonOffsetError = gl.getError(); + console.info("polygonOffsetError: " + polygonOffsetError); + expect(polygonOffsetError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0399 + * @tc.name testPolygonOffset_04 + * @tc.desc Test polygonOffset. + */ + it('testPolygonOffset_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPolygonOffset_04 test start ...66'); + gl.enable(gl.LINE_STRIP); + gl.polygonOffset(0, 0); + const polygonOffsetError = gl.getError(); + console.info("polygonOffsetError: " + polygonOffsetError); + expect(polygonOffsetError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0400 + * @tc.name testBufferData + * @tc.desc Test bufferData. + */ + it('testBufferData', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData test start ...66'); + console.info('jsWebGL testBufferData test start ...' + JSON.stringify(gl)); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + }) +} \ No newline at end of file diff --git a/graphic/webGL/src/main/js/test/WebGL.test05.js b/graphic/webGL/src/main/js/test/WebGL.test05.js new file mode 100644 index 0000000000000000000000000000000000000000..da0a7d7c369c195bc45f66c60568d6d79df37d89 --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test05.js @@ -0,0 +1,1831 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl5() { + describe('webgl1Test_webgl5', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_0401 + * @tc.name testBufferData_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.INVALID_ENUM); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0402 + * @tc.name testBufferData_02 + * @tc.desc Test bufferData. + */ + it('testBufferData_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_02 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.SRC_COLOR); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0403 + * @tc.name testBufferData_03 + * @tc.desc Test bufferData. + */ + it('testBufferData_03', 0, async function (done) { + console.info('jsWebGL testBufferData_03 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.SRC_ALPHA); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0404 + * @tc.name testBufferData_04 + * @tc.desc Test bufferData. + */ + it('testBufferData_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_04 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.SRC_ALPHA); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0405 + * @tc.name testBufferData_1 + * @tc.desc Test bufferData. + */ + it('testBufferData_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_1 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0406 + * @tc.name testBufferData_1_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_1_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(gl.NO_ERROR); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0407 + * @tc.name testBufferData_1_02 + * @tc.desc Test bufferData. + */ + it('testBufferData_1_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_1_02 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.ONE_MINUS_SRC_ALPHA); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0408 + * @tc.name testBufferData_1_03 + * @tc.desc Test bufferData. + */ + it('testBufferData_1_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_1_03 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.ONE_MINUS_DST_ALPHA); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0409 + * @tc.name testBufferData_1_04 + * @tc.desc Test bufferData. + */ + it('testBufferData_1_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_1_03 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, -1, gl.INVALID_VALUE); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0410 + * @tc.name testBufferSubData + * @tc.desc Test bufferSubData. + */ + it('testBufferSubData', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferSubData test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + gl.bufferSubData(gl.COPY_READ_BUFFER, 512, new ArrayBuffer(8)); + const bufferSubDataError = gl.getError(); + console.info("bufferSubDataError: " + bufferSubDataError); + expect(bufferSubDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0411 + * @tc.name testBufferSubData_1 + * @tc.desc Test bufferData. + */ + it('testBufferSubData_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferSubData_1 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.TRIANGLE_FAN); + gl.bufferSubData(gl.TRIANGLE_FAN, 512, new ArrayBuffer(8)); + const bufferSubDataError = gl.getError(); + console.info("bufferSubDataError: " + bufferSubDataError); + expect(bufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0412 + * @tc.name testBufferSubData_2 + * @tc.desc Test bufferSubData. + */ + it('testBufferSubData_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferSubData_2 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + gl.bufferSubData(gl.COPY_READ_BUFFER, 512, new ArrayBuffer(8)); + const bufferSubDataError = gl.getError(); + console.info("bufferSubDataError: " + bufferSubDataError); + expect(bufferSubDataError).assertEqual(gl.NO_ERROR); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0413 + * @tc.name testBufferSubData_3 + * @tc.desc Test bufferSubData. + */ + it('testBufferSubData_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferSubData_3 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.TRIANGLE_STRIP); + gl.bufferSubData(gl.COPY_READ_BUFFER, 512, new ArrayBuffer(8)); + const bufferSubDataError = gl.getError(); + console.info("bufferSubDataError: " + bufferSubDataError); + expect(bufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0414 + * @tc.name testBufferSubData_4 + * @tc.desc Test bufferSubData. + */ + it('testBufferSubData_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferSubData_4 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.TRIANGLE_STRIP); + gl.bufferSubData(gl.COPY_READ_BUFFER, 512, new ArrayBuffer(8)); + const bufferSubDataError = gl.getError(); + console.info("bufferSubDataError: " + bufferSubDataError); + expect(bufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0415 + * @tc.name testCompressedTexImage2D + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexImage2D test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); + const compressedTexImage2DError = gl.getError(); + console.info("compressedTexImage2DError: " + compressedTexImage2DError); + expect(compressedTexImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0416 + * @tc.name testCompressedTexImage2D_01 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexImage2D_01 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_3D, texture); + gl.compressedTexImage2D(gl.TEXTURE_3D, [0, 0], 0x83F3, 512, 512, -1, 0); + const compressedTexImage2DError = gl.getError(); + console.info("compressedTexImage2DError: " + compressedTexImage2DError); + expect(compressedTexImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0417 + * @tc.name testCompressedTexImage2D_02 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexImage2D_02 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_3D, texture); + gl.compressedTexImage2D(gl.SRC_COLOR, -1, 0x83F3, -1, [-1, -1], 0, 0); + const compressedTexImage2DError = gl.getError(); + console.info("compressedTexImage2DError: " + compressedTexImage2DError); + expect(compressedTexImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0418 + * @tc.name testCompressedTexImage2D_03 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexImage2D_03 test start ...66'); + var program = gl.createProgram(); + gl.bindTexture(gl.TEXTURE_3D, program); + gl.compressedTexImage2D(gl.TEXTURE_3D, 0, [0x83F3, 0x83F3], 512, 512, 0, 0); + const compressedTexImage2DError = gl.getError(); + console.info("compressedTexImage2DError: " + compressedTexImage2DError); + expect(compressedTexImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0419 + * @tc.name testCompressedTexImage2D_04 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexImage2D_04 test start ...66'); + var framebuffer = gl.createFramebuffer(); + gl.bindTexture(gl.TEXTURE_3D, framebuffer); + gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x0307, 512, 512, 0, "abc"); + const compressedTexImage2DError = gl.getError(); + console.info("compressedTexImage2DError: " + compressedTexImage2DError); + expect(compressedTexImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0420 + * @tc.name testCompressedTexSubImage2D_1 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexSubImage2D_1 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); + gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 256, 256, 512, 512, 0x83F3, gl + .PIXEL_UNPACK_BUFFER, 0); + const compressedTexSubImage2DError = gl.getError(); + console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); + expect(compressedTexSubImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0421 + * @tc.name testReadPixels + * @tc.desc Test readPixels. + */ + it('testReadPixels', 0, async function (done) { + //initContext(); + console.info('jsWebGL testReadPixels test start ...66'); + var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); + gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl + .UNSIGNED_BYTE, pixels); + const readPixelsError = gl.getError(); + console.info("readPixelsError: " + readPixelsError); + expect(readPixelsError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0422 + * @tc.name testReadPixels_01 + * @tc.desc Test readPixels. + */ + it('testReadPixels_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testReadPixels_01 test start ...66'); + var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); + gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.DST_COLOR, + pixels); + const readPixelsError = gl.getError(); + console.info("readPixelsError: " + readPixelsError); + expect(readPixelsError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0423 + * @tc.name testReadPixels_02 + * @tc.desc Test readPixels. + */ + it('testReadPixels_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testReadPixels_02 test start ...66'); + var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); + gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.DST_COLOR, + 0); + const readPixelsError = gl.getError(); + console.info("readPixelsError: " + readPixelsError); + expect(readPixelsError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0424 + * @tc.name testReadPixels_03 + * @tc.desc Test readPixels. + */ + it('testReadPixels_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testReadPixels_03 test start ...66'); + var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); + gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, -1, gl.DST_COLOR, -2); + const readPixelsError = gl.getError(); + console.info("readPixelsError: " + readPixelsError); + expect(readPixelsError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0425 + * @tc.name testReadPixels_04 + * @tc.desc Test readPixels. + */ + it('testReadPixels_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testReadPixels_04 test start ...66'); + var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); + gl.readPixels(-1, -1, gl.drawingBufferWidth, gl.drawingBufferHeight, -1, gl.CONSTANT_COLOR, + 0); + const readPixelsError = gl.getError(); + console.info("readPixelsError: " + readPixelsError); + expect(readPixelsError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0426 + * @tc.name testTexImage2D + * @tc.desc Test texImage2D. + */ + it('testTexImage2D', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0427 + * @tc.name testTexImage2D_01 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D_01 test start ...66'); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB8, 512, 512, [0, 0], gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0428 + * @tc.name testTexImage2D_02 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D_02 test start ...66'); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl.CONSTANT_ALPHA, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0429 + * @tc.name testTexImage2D_03 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D_03 test start ...66'); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl.FUNC_SUBTRACT, -1); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0430 + * @tc.name testTexImage2D_04 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D_04 test start ...66'); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.DST_COLOR, 512, 512, 0, gl.RGB8, gl.CONSTANT_ALPHA, -1); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0431 + * @tc.name testTexSubImage2D + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexSubImage2D test start ...66'); + console.info('jsWebGL testTexSubImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(16); + const z = new Float32Array(buffer, 0, 4); + gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 512, 512, gl.RED, gl.FLOAT, z, 0); + const ttexSubImage2DError = gl.getError(); + console.info("ttexSubImage2DError: " + ttexSubImage2DError); + expect(ttexSubImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0432 + * @tc.name testUniform1fv + * @tc.desc Test uniform1fv. + */ + it('testUniform1fv', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform1fv test start ...66'); + const programObj = createProgram(gl); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniform1fv(uniformlocationObj, flaot32list); + const uniform1fvError = gl.getError(); + console.info("uniform1fvError: " + uniform1fvError); + const errorCode = gl.getError(); + expect(uniform1fvError).assertEqual(0); + + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0433 + * @tc.name testUniform1fv_1 + * @tc.desc Test uniform1fv. + */ + it('testUniform1fv_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform1fv_1 test start ...66'); + const shader = gl.createShader(gl.VERTEX_SHADER); + const uniformlocationObj = gl.getUniformLocation(shader, "a_Position1"); + const flaot32list = new Float32Array([1, 2]); + gl.uniform1fv(uniformlocationObj, flaot32list); + const uniform1fvError = gl.getError(); + console.info("uniform1fvError: " + uniform1fvError); + expect(uniform1fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0435 + * @tc.name testUniform1fv_3 + * @tc.desc Test uniform1fv. + */ + it('testUniform1fv_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform1fv_3 test start ...66'); + const programobject = gl.createProgram(); + const uniformlocationObj = gl.getUniformLocation(programobject, "a_Position1"); + const flaot32list = new Float32Array([-1, -2]); + gl.uniform1fv(uniformlocationObj, flaot32list); + const uniform1fvError = gl.getError(); + console.info("uniform1fvError: " + uniform1fvError); + const errorCode = gl.getError(); + expect(uniform1fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0437 + * @tc.name testUniform2fv + * @tc.desc Test uniform2fv. + */ + it('testUniform2fv', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform2fv test start ...66'); + const programObj = createProgram(gl); + const uniformlocationObj = gl.getUniformLocation(programObj, "123"); + const flaot32list = new Float32Array([1, 2]); + gl.uniform2fv(uniformlocationObj, flaot32list); + const uniform2fvError = gl.getError(); + console.info("uniform2fvError: " + uniform2fvError); + expect(uniform2fvError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0439 + * @tc.name testUniform2fv_2 + * @tc.desc Test uniform2fv. + */ + it('testUniform2fv_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform2fv_2 test start ...66'); + const programObj = gl.createProgram(); + const uniformlocationObj = gl.getUniformLocation(programObj, "123"); + const flaot32list = new Float32Array([1, 2]); + gl.uniform2fv(uniformlocationObj, flaot32list); + const uniform2fvError = gl.getError(); + console.info("uniform2fvError: " + uniform2fvError); + expect(uniform2fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0441 + * @tc.name testUniform2fv_4 + * @tc.desc Test uniform2fv. + */ + it('testUniform2fv_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform2fv_4 test start ...66'); + const shader = gl.createShader(gl.VERTEX_SHADER); + const uniformlocationObj = gl.getUniformLocation(shader, "a_Position1"); + const flaot32list = new Float32Array([1, 2]); + gl.uniform2fv(uniformlocationObj, flaot32list); + const uniform2fvError = gl.getError(); + console.info("uniform2fvError1: " + uniform2fvError); + expect(uniform2fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0442 + * @tc.name testUniform3fv + * @tc.desc Test uniform3fv. + */ + it('testUniform3fv', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform3fv test start ...66'); + const programObj = createProgram(gl); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniform3fv(uniformlocationObj, flaot32list); + const uniform3fvError = gl.getError(); + console.info("uniform3fvError: " + uniform3fvError); + expect(uniform3fvError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0443 + * @tc.name testUniform3fv_1 + * @tc.desc Test uniform3fv. + */ + it('testUniform3fv_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform3fv_1 test start ...66'); + const programObj = gl.createProgram(); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniform3fv(uniformlocationObj, flaot32list); + const uniform3fvError = gl.getError(); + console.info("uniform3fvError: " + uniform3fvError); + expect(uniform3fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0446 + * @tc.name testUniform3fv_4 + * @tc.desc Test uniform3fv. + */ + it('testUniform3fv_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform3fv_4 test start ...66'); + const shader = gl.createShader(gl.VERTEX_SHADER); + const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniform3fv(uniformlocationObj, flaot32list); + const uniform3fvError = gl.getError(); + console.info("uniform3fvError: " + uniform3fvError); + expect(uniform3fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0447 + * @tc.name testUniform4fv + * @tc.desc Test uniform4fv. + */ + it('testUniform4fv', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform4fv test start ...66'); + const programObj = createProgram(gl); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniform4fv(uniformlocationObj, flaot32list); + const uniform4fvError = gl.getError(); + console.info("uniform4fvError: " + uniform4fvError); + expect(uniform4fvError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0448 + * @tc.name testUniform4fv_01 + * @tc.desc Test uniform4fv. + */ + it('testUniform4fv_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform4fv_01 test start ...66'); + const programObj = gl.createProgram(); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniform4fv(uniformlocationObj, flaot32list); + const uniform4fvError = gl.getError(); + console.info("uniform4fvError: " + uniform4fvError); + expect(uniform4fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0451 + * @tc.name testUniform4fv_04 + * @tc.desc Test uniform4fv. + */ + it('testUniform4fv_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform4fv_04 test start ...66'); + const shader = gl.createShader(gl.VERTEX_SHADER); + const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniform4fv(uniformlocationObj, flaot32list); + const uniform4fvError = gl.getError(); + console.info("uniform4fvError: " + uniform4fvError); + expect(uniform4fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0452 + * @tc.name testUniform1iv + * @tc.desc Test uniform1iv. + */ + it('testUniform1iv', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform1iv test start ...66'); + const programObj = createProgram(gl); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const int32list = new Int32Array([1, 2]); + gl.uniform1iv(uniformlocationObj, int32list); + const uniform1ivError = gl.getError(); + console.info("uniform1ivError: " + uniform1ivError); + expect(uniform1ivError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0453 + * @tc.name testUniform1iv_01 + * @tc.desc Test uniform1iv. + */ + it('testUniform1iv_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform1iv_01 test start ...66'); + const programObj = gl.createProgram(); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const int32list = new Int32Array([1, 2]); + gl.uniform1iv(uniformlocationObj, int32list); + const uniform1ivError = gl.getError(); + console.info("uniform1ivError: " + uniform1ivError); + expect(uniform1ivError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0457 + * @tc.name testUniform2iv + * @tc.desc Test uniform2iv. + */ + it('testUniform2iv', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform2iv test start ...66'); + const programObj = createProgram(gl); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const int32list = new Int32Array([1, 2]); + gl.uniform2iv(uniformlocationObj, int32list); + const uniform2ivError = gl.getError(); + console.info("testUniform2ivError: " + uniform2ivError); + expect(uniform2ivError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0458 + * @tc.name testUniform2iv_01 + * @tc.desc Test uniform2iv. + */ + it('testUniform2iv_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform2iv_01 test start ...66'); + const programObj = gl.createProgram(); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const int32list = new Int32Array([1, 2]); + gl.uniform2iv(uniformlocationObj, int32list); + const uniform2ivError = gl.getError(); + console.info("testUniform2ivError: " + uniform2ivError); + expect(uniform2ivError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0461 + * @tc.name testUniform2iv_04 + * @tc.desc Test uniform2iv. + */ + it('testUniform2iv_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform2iv_04 test start ...66'); + const shader = gl.createShader(gl.VERTEX_SHADER); + const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); + const int32list = new Int32Array([1, 2]); + gl.uniform2iv(uniformlocationObj, int32list); + const uniform2ivError = gl.getError(); + console.info("testUniform2ivError: " + uniform2ivError); + expect(uniform2ivError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0462 + * @tc.name testUniform3iv + * @tc.desc Test uniform3iv. + */ + it('testUniform3iv', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform3iv test start ...66'); + const programObj = createProgram(gl); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const int32list = new Int32Array([1, 2]); + gl.uniform3iv(uniformlocationObj, int32list); + const uniform3ivError = gl.getError(); + console.info("testUniform3ivError: " + uniform3ivError); + expect(uniform3ivError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0463 + * @tc.name testUniform3iv_01 + * @tc.desc Test uniform3iv. + */ + it('testUniform3iv_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform3iv_01 test start ...66'); + const programObj = gl.createProgram(); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const int32list = new Int32Array([1, 2]); + gl.uniform3iv(uniformlocationObj, int32list); + const uniform3ivError = gl.getError(); + console.info("testUniform3ivError: " + uniform3ivError); + expect(uniform3ivError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0466 + * @tc.name testUniform3iv_04 + * @tc.desc Test uniform3iv. + */ + it('testUniform3iv_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform3iv_04 test start ...66'); + const shader = gl.createShader(gl.VERTEX_SHADER); + const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); + const int32list = new Int32Array([1, 2]); + gl.uniform3iv(uniformlocationObj, int32list); + const uniform3ivError = gl.getError(); + console.info("testUniform3ivError: " + uniform3ivError); + expect(uniform3ivError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0467 + * @tc.name testUniform4iv + * @tc.desc Test uniform4iv. + */ + it('testUniform4iv', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform4iv test start ...66'); + const programObj = createProgram(gl); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const int32list = new Int32Array([1, 2]); + gl.uniform4iv(uniformlocationObj, int32list); + const uniform4ivError = gl.getError(); + console.info("testUniform4ivError: " + uniform4ivError); + expect(uniform4ivError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0468 + * @tc.name testUniform4iv_01 + * @tc.desc Test uniform4iv. + */ + it('testUniform4iv_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform4iv_01 test start ...66'); + const programObj = gl.createProgram(); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const int32list = new Int32Array([1, 2]); + gl.uniform4iv(uniformlocationObj, int32list); + const uniform4ivError = gl.getError(); + console.info("testUniform4ivError: " + uniform4ivError); + expect(uniform4ivError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0469 + * @tc.name testUniform4iv_02 + * @tc.desc Test uniform4iv. + */ + it('testUniform4iv_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform4iv_02 test start ...66'); + const buffer = gl.createBuffer(); + const uniformlocationObj = gl.getUniformLocation(buffer, "a_Position"); + const int32list = new Int32Array([1, 2]); + gl.uniform4iv(uniformlocationObj, int32list); + const uniform4ivError = gl.getError(); + console.info("testUniform4ivError: " + uniform4ivError); + expect(uniform4ivError).assertEqual(gl.NO_ERROR); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0470 + * @tc.name testUniform4iv_03 + * @tc.desc Test uniform4iv. + */ + it('testUniform4iv_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform4iv_03 test start ...66'); + const buffer = gl.createBuffer(); + const uniformlocationObj = gl.getUniformLocation(buffer, "a_Position"); + const int32list = new Int32Array([1, 2]); + gl.uniform4iv(uniformlocationObj, int32list); + const uniform4ivError = gl.getError(); + console.info("testUniform4ivError: " + uniform4ivError); + expect(uniform4ivError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0471 + * @tc.name testUniform4iv_04 + * @tc.desc Test Uniform4uiv. + */ + it('testUniform4iv_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniform4iv_03 test start ...66'); + const shader = gl.createShader(gl.VERTEX_SHADER); + const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); + const int32list = new Int32Array([1, 2]); + gl.uniform4iv(uniformlocationObj, int32list); + const uniform4ivError = gl.getError(); + console.info("testUniform4ivError: " + uniform4ivError); + expect(uniform4ivError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0472 + * @tc.name testUniformMatrix2fv + * @tc.desc Test uniformMatrix2fv. + */ + it('testUniformMatrix2fv', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix2fv test start ...66'); + const programObj = createProgram(gl); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniformMatrix2fv(uniformlocationObj, true, flaot32list); + const uniformMatrix2fvError = gl.getError(); + console.info("uniformMatrix2fvError: " + uniformMatrix2fvError); + expect(uniformMatrix2fvError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0473 + * @tc.name testUniformMatrix2fv_01 + * @tc.desc Test uniformMatrix2fv. + */ + it('testUniformMatrix2fv_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix2fv_01 test start ...66'); + const programObj = gl.createProgram(); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniformMatrix2fv(uniformlocationObj, true, flaot32list); + const uniformMatrix2fvError = gl.getError(); + console.info("uniformMatrix2fvError: " + uniformMatrix2fvError); + expect(uniformMatrix2fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0475 + * @tc.name testUniformMatrix2fv_03 + * @tc.desc Test uniformMatrix2fv. + */ + it('testUniformMatrix2fv_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix2fv_03 test start ...66'); + const buffer = gl.createBuffer(); + const uniformlocationObj = gl.getUniformLocation(buffer, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniformMatrix2fv(uniformlocationObj, true, flaot32list); + const uniformMatrix2fvError = gl.getError(); + console.info("uniformMatrix2fvError: " + uniformMatrix2fvError); + expect(uniformMatrix2fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0476 + * @tc.name testUniformMatrix2fv_04 + * @tc.desc Test uniformMatrix2fv. + */ + it('testUniformMatrix2fv_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix2fv_04 test start ...66'); + const shader = gl.createShader(gl.VERTEX_SHADER); + const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniformMatrix2fv(uniformlocationObj, true, flaot32list); + const uniformMatrix2fvError = gl.getError(); + console.info("uniformMatrix2fvError: " + uniformMatrix2fvError); + expect(uniformMatrix2fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0477 + * @tc.name testUniformMatrix3fv + * @tc.desc Test uniformMatrix3fv. + */ + it('testUniformMatrix3fv', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix3fv test start ...66'); + const programObj = createProgram(gl); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniformMatrix3fv(uniformlocationObj, true, flaot32list); + const uniformMatrix3fvError = gl.getError(); + console.info("uniformMatrix3fvError: " + uniformMatrix3fvError); + expect(uniformMatrix3fvError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0478 + * @tc.name testUniformMatrix3fv_01 + * @tc.desc Test uniformMatrix3fv. + */ + it('testUniformMatrix3fv_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix3fv_01 test start ...66'); + const programObj = gl.createProgram(); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniformMatrix3fv(uniformlocationObj, true, flaot32list); + const uniformMatrix3fvError = gl.getError(); + console.info("uniformMatrix3fvError: " + uniformMatrix3fvError); + expect(uniformMatrix3fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0479 + * @tc.name testUniformMatrix3fv_02 + * @tc.desc Test uniformMatrix3fv. + */ + it('testUniformMatrix3fv_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix3fv_02 test start ...66'); + const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + const uniformlocationObj = gl.getUniformLocation(fragmentShader, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniformMatrix3fv(uniformlocationObj, true, flaot32list); + const uniformMatrix3fvError = gl.getError(); + console.info("uniformMatrix3fvError: " + uniformMatrix3fvError); + expect(uniformMatrix3fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0480 + * @tc.name testUniformMatrix3fv_03 + * @tc.desc Test uniformMatrix3fv. + */ + it('testUniformMatrix3fv_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix3fv_03 test start ...66'); + const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + const uniformlocationObj = gl.getUniformLocation(fragmentShader, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniformMatrix3fv(uniformlocationObj, true, flaot32list); + const uniformMatrix3fvError = gl.getError(); + console.info("uniformMatrix3fvError: " + uniformMatrix3fvError); + expect(uniformMatrix3fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0481 + * @tc.name testUniformMatrix3fv_04 + * @tc.desc Test uniformMatrix3fv. + */ + it('testUniformMatrix3fv_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix3fv_04 test start ...66'); + var shader = gl.createShader(gl.VERTEX_SHADER); + const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + gl.uniformMatrix3fv(uniformlocationObj, true, flaot32list); + const uniformMatrix3fvError = gl.getError(); + console.info("uniformMatrix3fvError: " + uniformMatrix3fvError); + expect(uniformMatrix3fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0482 + * @tc.name testUniformMatrix4fv + * @tc.desc Test uniformMatrix4fv. + */ + it('testUniformMatrix4fv', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix4fv test start ...66'); + const programObj = createProgram(gl); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + const a = gl.uniformMatrix4fv(uniformlocationObj, true, flaot32list); + console.info("a: " + a); + const uniformMatrix4fvError = gl.getError(); + console.info("uniformMatrix4fvError: " + uniformMatrix4fvError); + expect(uniformMatrix4fvError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0483 + * @tc.name testUniformMatrix4fv_01 + * @tc.desc Test uniformMatrix4fv. + */ + it('testUniformMatrix4fv_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix4fv_01 test start ...66'); + const programObj = gl.createProgram(); + const uniformlocationObj = gl.getUniformLocation(programObj, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + const a = gl.uniformMatrix4fv(uniformlocationObj, true, flaot32list); + console.info("a: " + a); + const uniformMatrix4fvError = gl.getError(); + console.info("uniformMatrix4fvError: " + uniformMatrix4fvError); + expect(uniformMatrix4fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0484 + * @tc.name testUniformMatrix4fv_02 + * @tc.desc Test uniformMatrix4fv. + */ + it('testUniformMatrix4fv_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix4fv_02 test start ...66'); + const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + const uniformlocationObj = gl.getUniformLocation(fragmentShader, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + const a = gl.uniformMatrix4fv(uniformlocationObj, true, flaot32list); + console.info("a: " + a); + const uniformMatrix4fvError = gl.getError(); + console.info("uniformMatrix4fvError: " + uniformMatrix4fvError); + expect(uniformMatrix4fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0485 + * @tc.name testUniformMatrix4fv_03 + * @tc.desc Test uniformMatrix4fv. + */ + it('testUniformMatrix4fv_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix4fv_03 test start ...66'); + var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + const uniformlocationObj = gl.getUniformLocation(fragmentShader, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + const a = gl.uniformMatrix4fv(uniformlocationObj, true, flaot32list); + console.info("a: " + a); + const uniformMatrix4fvError = gl.getError(); + console.info("uniformMatrix4fvError: " + uniformMatrix4fvError); + expect(uniformMatrix4fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0486 + * @tc.name testUniformMatrix4fv_04 + * @tc.desc Test uniformMatrix4fv. + */ + it('testUniformMatrix4fv_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testUniformMatrix4fv_04 test start ...66'); + const shader = gl.createShader(gl.VERTEX_SHADER); + const uniformlocationObj = gl.getUniformLocation(shader, "a_Position"); + const flaot32list = new Float32Array([1, 2]); + const a = gl.uniformMatrix4fv(uniformlocationObj, true, flaot32list); + console.info("a: " + a); + const uniformMatrix4fvError = gl.getError(); + console.info("uniformMatrix4fvError: " + uniformMatrix4fvError); + expect(uniformMatrix4fvError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0487 + * @tc.name testCopyBufferSubData + * @tc.desc Test copyBufferSubData. + */ + it('testCopyBufferSubData', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCopyBufferSubData test start ...66'); + console.info('jsWebGL testCopyBufferSubData test start ...' + JSON.stringify(gl)); + const srcBuffer = gl.createBuffer(); + const dstBuffer = gl.createBuffer(); + const vertices = [1, 2]; + const data = new Float32Array(vertices); + const length = vertices.length * 4; + gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); + gl2.copyBufferSubData(gl.COPY_READ_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); + const copyBufferSubDataError = gl.getError(); + console.info("copyBufferSubDataError: " + copyBufferSubDataError); + expect(copyBufferSubDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0488 + * @tc.name testCopyBufferSubData_01 + * @tc.desc Test copyBufferSubData. + */ + it('testCopyBufferSubData_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCopyBufferSubData_01 test start ...66'); + const srcBuffer = gl.createBuffer(); + const dstBuffer = gl.createBuffer(); + const vertices = [1, 2]; + const data = new Float32Array(vertices); + const length = vertices.length * 4; + gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + + gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); + gl2.copyBufferSubData(gl.ONE_MINUS_CONSTANT_ALPHA, gl.ONE_MINUS_CONSTANT_ALPHA, 0, 0, 0); + const copyBufferSubDataError = gl.getError(); + console.info("copyBufferSubDataError: " + copyBufferSubDataError); + expect(copyBufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0489 + * @tc.name testCopyBufferSubData_02 + * @tc.desc Test copyBufferSubData. + */ + it('testCopyBufferSubData_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCopyBufferSubData_02 test start ...66'); + const srcBuffer = gl.createBuffer(); + const dstBuffer = gl.createBuffer(); + const vertices = [1, 2]; + const data = new Float32Array(vertices); + const length = vertices.length * 4; + gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + + gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); + gl2.copyBufferSubData(gl.SRC_ALPHA_SATURATE, gl.SRC_ALPHA_SATURATE, 0, 0, 0); + const copyBufferSubDataError = gl.getError(); + console.info("copyBufferSubDataError: " + copyBufferSubDataError); + expect(copyBufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0490 + * @tc.name testCopyBufferSubData_03 + * @tc.desc Test copyBufferSubData. + */ + it('testCopyBufferSubData_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCopyBufferSubData_03 test start ...66'); + const srcBuffer = gl.createBuffer(); + const dstBuffer = gl.createBuffer(); + const vertices = [1, 2]; + const data = new Float32Array(vertices); + const length = vertices.length * 4; + gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); + gl2.copyBufferSubData(gl.SRC_ALPHA_SATURATE, gl.SRC_ALPHA_SATURATE, 0, 0, length); + const copyBufferSubDataError = gl.getError(); + console.info("copyBufferSubDataError: " + copyBufferSubDataError); + expect(copyBufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0491 + * @tc.name testCopyBufferSubData_04 + * @tc.desc Test copyBufferSubData. + */ + it('testCopyBufferSubData_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCopyBufferSubData_04 test start ...66'); + const srcBuffer = gl.createBuffer(); + const dstBuffer = gl.createBuffer(); + const vertices = [1, 2]; + const data = new Float32Array(vertices); + const length = vertices.length * 4; + gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); + gl2.copyBufferSubData(gl.SRC_ALPHA_SATURATE, gl.SRC_ALPHA_SATURATE, 0, 0, gl + .ONE_MINUS_CONSTANT_COLOR); + const copyBufferSubDataError = gl.getError(); + console.info("copyBufferSubDataError: " + copyBufferSubDataError); + expect(copyBufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0492 + * @tc.name testGetBufferSubData + * @tc.desc Test getBufferSubData. + */ + it('testGetBufferSubData', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetBufferSubData test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const vertices = [1, 2]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); + gl2.getBufferSubData(gl.ARRAY_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); + const getBufferSubDataError = gl.getError(); + console.info("getBufferSubDataError: " + getBufferSubDataError); + expect(getBufferSubDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0493 + * @tc.name testGetBufferSubData_01 + * @tc.desc Test getBufferSubData. + */ + it('testGetBufferSubData_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetBufferSubData_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const vertices = [1, 2]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); + gl2.getBufferSubData(gl.SRC_ALPHA_SATURATE, 0, new Float32Array(arrBuffer), 0, 0); + const getBufferSubDataError = gl.getError(); + console.info("getBufferSubDataError: " + getBufferSubDataError); + expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0494 + * @tc.name testGetBufferSubData_02 + * @tc.desc Test getBufferSubData. + */ + it('testGetBufferSubData_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetBufferSubData_02 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const vertices = [1, 2]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); + gl2.getBufferSubData(gl.FUNC_SUBTRACT, 0, new Float32Array(arrBuffer), 0, 0); + const getBufferSubDataError = gl.getError(); + console.info("getBufferSubDataError: " + getBufferSubDataError); + expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0495 + * @tc.name testGetBufferSubData_03 + * @tc.desc Test getBufferSubData. + */ + it('testGetBufferSubData_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetBufferSubData_03 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const vertices = [1, 2]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); + gl2.getBufferSubData(gl.BLEND_DST_RGB, 0, new Int32Array(arrBuffer), 0, 0); + const getBufferSubDataError = gl.getError(); + console.info("getBufferSubDataError: " + getBufferSubDataError); + expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0496 + * @tc.name testGetBufferSubData_04 + * @tc.desc Test getBufferSubData. + */ + it('testGetBufferSubData_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetBufferSubData_04 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const vertices = [1, 2]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.BLEND_SRC_ALPHA); + var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); + gl2.getBufferSubData(gl.ARRAY_BUFFER, 0, new Int32Array(arrBuffer), 0, 0); + const getBufferSubDataError = gl.getError(); + console.info("getBufferSubDataError: " + getBufferSubDataError); + expect(getBufferSubDataError).assertEqual(gl.NO_ERROR); + for (let err; (err = gl.getError()) != gl.NO_ERROR; ) { + } + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0497 + * @tc.name testBlitFramebuffer + * @tc.desc Test blitFramebuffer. + */ + it('testBlitFramebuffer', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBlitFramebuffer test start ...66'); + console.info('jsWebGL testBlitFramebuffer test start ...' + JSON.stringify(gl)); + gl2.blitFramebuffer(0, 0, 400, 1080, 0, 0, 400, 1080, gl2.COLOR_BUFFER_BIT, gl2.NEAREST); + const blitFramebufferError = gl.getError(); + console.info("blitFramebufferError: " + blitFramebufferError); + expect(blitFramebufferError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0498 + * @tc.name testFramebufferTextureLayer + * @tc.desc Test framebufferTextureLayer. + */ + it('testFramebufferTextureLayer', 0, async function (done) { + //initContext(); + console.info('jsWebGL testFramebufferTextureLayer test start ...66'); + console.info('jsWebGL testFramebufferTextureLayer test start ...' + JSON.stringify(gl)); + var texture = gl.createTexture(); + gl2.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, + texture, 0, 8) + const framebufferTextureLayerError = gl.getError(); + console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); + expect(framebufferTextureLayerError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0499 + * @tc.name testInvalidateFramebuffer + * @tc.desc Test invalidateFramebuffer. + */ + it('testInvalidateFramebuffer', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateFramebuffer test start ...66'); + console.info('jsWebGL testInvalidateFramebuffer test start ...' + JSON.stringify(gl)); + gl2.invalidateFramebuffer(gl.READ_FRAMEBUFFER, + [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1]); + const invalidateFramebufferError = gl.getError(); + console.info("invalidateFramebufferError: " + invalidateFramebufferError); + expect(invalidateFramebufferError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0500 + * @tc.name testInvalidateSubFramebuffer + * @tc.desc Test invalidateSubFramebuffer. + */ + it('testInvalidateSubFramebuffer', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateSubFramebuffer test start ...66'); + console.info('jsWebGL testInvalidateSubFramebuffer test start ...' + JSON.stringify(gl)); + gl2.invalidateSubFramebuffer(gl.READ_FRAMEBUFFER, + [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1], + 0, 0, 256, 256); + const invalidateSubFramebufferError = gl.getError(); + console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); + expect(invalidateSubFramebufferError).assertEqual(0); + done(); + }) + }) +} diff --git a/graphic/webGL/src/main/js/test/WebGL.test06.js b/graphic/webGL/src/main/js/test/WebGL.test06.js new file mode 100644 index 0000000000000000000000000000000000000000..5ecd283c88c9f3dac222d7d440d79aa72ba903be --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test06.js @@ -0,0 +1,2431 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl6() { + describe('webgl1Test_webgl6', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_0502 + * @tc.name testGetInternalformatParameter + * @tc.desc Test getInternalformatParameter. + */ + it('testGetInternalformatParameter', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetInternalformatParameter test start ...66'); + var samples = gl2.getInternalformatParameter(gl.RENDERBUFFER, gl2.RGBA8, gl.SAMPLES); + console.info("samples: " + samples); + const int32list = [-1, -1, -1]; + expect(samples.toString() != int32list.toString()).assertEqual(true); + //判断数据类型是否正确 + // expect(samples.constructor).assertEqual(int32list.constructor); + //判断数据值是否正确 + // expect(samples.toString()).assertEqual(int32list.toString()); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0503 + * @tc.name testGetInternalformatParameter_01 + * @tc.desc Test getInternalformatParameter. + */ + it('testGetInternalformatParameter_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetInternalformatParameter_01 test start ...66'); + var samples = gl2.getInternalformatParameter(gl.RENDERBUFFER, gl2.RGBA8, gl.SAMPLES); + console.info("samples: " + samples); + const int32list = new Int32Array([-1, -1, -1]); + expect(samples.constructor).assertEqual(int32list.constructor); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0504 + * @tc.name testRenderbufferStorageMultisample + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); + gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.RBGA4, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0505 + * @tc.name testTexStorage2D + * @tc.desc Test texStorage2D. + */ + it('testTexStorage2D', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexStorage2D test start ...66'); + console.info('jsWebGL testTexStorage2D test start ...' + JSON.stringify(gl)); + gl2.texStorage2D(gl.TEXTURE_2D, 1, gl.RGB8, 256, 256); + const texStorage2DError = gl.getError(); + console.info("texStorage2DError: " + texStorage2DError); + expect(texStorage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0506 + * @tc.name testTransformFeedbackVaryings + * @tc.desc Test transformFeedbackVaryings. + */ + it('testTransformFeedbackVaryings', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTransformFeedbackVaryings test start ...66'); + console.info('jsWebGL testTransformFeedbackVaryings test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + var transformFeedbackOutputs = ['gl_Position', 'anotherOutput']; + gl2.transformFeedbackVaryings(program, transformFeedbackOutputs, gl.INTERLEAVED_ATTRIBS); + const transformFeedbackVaryingsError = gl.getError(); + console.info("transformFeedbackVaryingsError: " + transformFeedbackVaryingsError); + expect(transformFeedbackVaryingsError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0508 + * @tc.name testPauseTransformFeedback + * @tc.desc Test pauseTransformFeedback. + */ + it('testPauseTransformFeedback', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testPauseTransformFeedback test start ...66'); + console.info('jsWebGL testPauseTransformFeedback test start ...' + JSON.stringify(gl)); + const transformFeedback = gl2.createTransformFeedback(); + gl2.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, transformFeedback); + gl2.beginTransformFeedback(gl2.TRIANGLES); + gl2.pauseTransformFeedback(); + const pauseTransformFeedbackError = gl.getError(); + console.info("pauseTransformFeedbackError: " + pauseTransformFeedbackError); + expect(pauseTransformFeedbackError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testPauseTransformFeedback has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0509 + * @tc.name testResumeTransformFeedback + * @tc.desc Test resumeTransformFeedback. + */ + it('testResumeTransformFeedback', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testPauseTransformFeedback test start ...66'); + console.info('jsWebGL testPauseTransformFeedback test start ...' + JSON.stringify(gl)); + gl2.resumeTransformFeedback(); + const resumeTransformFeedbackError = gl.getError(); + console.info("resumeTransformFeedbackError: " + resumeTransformFeedbackError); + expect(resumeTransformFeedbackError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("resumeTransformFeedbackError has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0510 + * @tc.name testBindBufferBase + * @tc.desc Test bindBufferBase. + */ + it('testBindBufferBase', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testBindBufferBase test start ...66'); + console.info('jsWebGL testBindBufferBase test start ...' + JSON.stringify(gl)); + let buffer = gl.createBuffer(); + gl2.bindBufferBase(gl.TRANSFORM_FEEDBACK_BUFFER, 0, buffer); + const bindBufferBaseError = gl.getError(); + console.info("bindBufferBaseError: " + bindBufferBaseError); + expect(bindBufferBaseError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("bindBufferBaseError has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0511 + * @tc.name testGetIndexedParameter + * @tc.desc Test getIndexedParameter. + */ + it('testGetIndexedParameter', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetIndexedParameter test start ...66'); + console.info('jsWebGL testGetIndexedParameter test start ...' + JSON.stringify(gl)); + const WebGLBufferobject = gl2.getIndexedParameter(gl.TRANSFORM_FEEDBACK_BUFFER_BINDING, + 0); + const isBuffer = gl.isBuffer(WebGLBufferobject); + expect(isBuffer).assertEqual(false); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetIndexedParameter has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0512 + * @tc.name testGetIndexedParameter_01 + * @tc.desc Test getIndexedParameter. + */ + it('testGetIndexedParameter_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetIndexedParameter_01 test start ...66'); + console.info('jsWebGL testGetIndexedParameter_01 test start ...' + JSON.stringify(gl)); + const reurGLsizeiptr = gl2.getIndexedParameter(gl.TRANSFORM_FEEDBACK_BUFFER_SIZE, 0); + const typeGLsizeiptr = typeof (reurGLsizeiptr); + expect(typeGLsizeiptr).assertInstanceOf('String'); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetIndexedParameter_01 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0513 + * @tc.name testGetIndexedParameter_02 + * @tc.desc Test getIndexedParameter. + */ + it('testGetIndexedParameter_02', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetIndexedParameter_02 test start ...66'); + console.info('jsWebGL testGetIndexedParameter_02 test start ...' + JSON.stringify(gl)); + const retuGLintptr = gl2.getIndexedParameter(gl.TRANSFORM_FEEDBACK_BUFFER_START, 0); + const typeGLintptr = typeof (retuGLintptr); + expect(typeGLintptr).assertInstanceOf('String'); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetIndexedParameter_02 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0514 + * @tc.name testGetIndexedParameter_03 + * @tc.desc Test getIndexedParameter. + */ + it('testGetIndexedParameter_03', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetIndexedParameter_03 test start ...66'); + console.info('jsWebGL testGetIndexedParameter_03 test start ...' + JSON.stringify(gl)); + const WebGLBufferobject = gl2.getIndexedParameter(gl.UNIFORM_BUFFER_BINDING, 0); + const isBuffer = gl.isBuffer(WebGLBufferobject); + expect(isBuffer).assertEqual(false); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetIndexedParameter_03 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0515 + * @tc.name testGetIndexedParameter_04 + * @tc.desc Test getIndexedParameter. + */ + it('testGetIndexedParameter_04', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetIndexedParameter_04 test start ...66'); + console.info('jsWebGL testGetIndexedParameter_04 test start ...' + JSON.stringify(gl)); + const reurGLsizeiptr = gl2.getIndexedParameter(gl.UNIFORM_BUFFER_SIZE, 0); + const typeGLsizeiptr = typeof (reurGLsizeiptr); + expect(typeGLsizeiptr).assertInstanceOf('String'); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetIndexedParameter_04 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0516 + * @tc.name testGetIndexedParameter_05 + * @tc.desc Test getIndexedParameter. + */ + it('testGetIndexedParameter_05', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetIndexedParameter_05 test start ...66'); + console.info('jsWebGL testGetIndexedParameter_05 test start ...' + JSON.stringify(gl)); + const retuGLintptr = gl2.getIndexedParameter(gl.UNIFORM_BUFFER_START, 0); + const typeGLintptr = typeof (retuGLintptr); + expect(typeGLintptr).assertInstanceOf('String'); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetIndexedParameter_05 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0517 + * @tc.name testGetUniformIndices + * @tc.desc Test getUniformIndices. + */ + it('testGetUniformIndices', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetUniformIndices test start ...66'); + console.info('jsWebGL testGetUniformIndices test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + const retuGLintptr = gl2.getUniformIndices(program, ['UBORed', 'UBOGreen', 'UBOBlue']); + console.log("testGetUniformIndices has failed for " + retuGLintptr) + const int32list = [-1, -1, -1]; + console.log("testGetUniformIndices has failed for " + int32list) + //判断数据类型是否正确 + expect(retuGLintptr.constructor).assertEqual(int32list.constructor); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetUniformIndices has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0518 + * @tc.name testGetUniformIndices_01 + * @tc.desc Test getUniformIndices. + */ + it('testGetUniformIndices_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetUniformIndices_01 test start ...66'); + const program = gl.createProgram(); + const retuGLintptr = gl2.getUniformIndices(program, ['UBORed', 'UBOGreen', 'UBOBlue']); + console.log("testGetUniformIndices has failed for " + retuGLintptr) + const int32list = [-1, -1, -1]; + console.log("testGetUniformIndices_01 has failed for " + int32list) + //判断数据值是否正确 + expect(retuGLintptr.toString() != int32list.toString()).assertEqual(true); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetUniformIndices has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0519 + * @tc.name testGetActiveUniforms + * @tc.desc Test getActiveUniforms. + */ + it('testGetActiveUniforms', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetActiveUniforms test start ...66'); + console.info('jsWebGL testGetActiveUniforms test start ...' + JSON.stringify(gl)); + // const programObj = 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); + + + const uniformIndices = [1, 2, 3]; + const uniformType = gl2.getActiveUniforms(programObj, uniformIndices, gl2.UNIFORM_TYPE) + const glenumList = [-1, -1, -1]; + expect(uniformType.toString() != glenumList.toString()).assertEqual(true); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetActiveUniforms has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0520 + * @tc.name testGetActiveUniforms_01 + * @tc.desc Test getActiveUniforms. + */ + it('testGetActiveUniforms_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetActiveUniforms_01 test start ...66'); + //顶点着色器程序 + 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); + + const uniformIndices = [1, 2, 3]; + const uniformType = gl2.getActiveUniforms(programObj, uniformIndices, gl2.UNIFORM_TYPE) + const glenumList = [-1, -1, -1]; + expect(uniformType.constructor).assertEqual(glenumList.constructor); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetActiveUniforms has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0521 + * @tc.name testGetActiveUniforms_02 + * @tc.desc Test getActiveUniforms. + */ + it('testGetActiveUniforms_02', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetActiveUniforms_02 test start ...66'); + //顶点着色器程序 + 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); + + const uniformIndices = [4, 5, 6]; + const uniformSize = gl2.getActiveUniforms(programObj, uniformIndices, gl2.UNIFORM_SIZE) + const gluintList = [-1, 0, 0]; + expect(uniformSize.toString() != gluintList.toString()).assertEqual(true); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetActiveUniforms_02 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0522 + * @tc.name testGetActiveUniforms_03 + * @tc.desc Test getActiveUniforms. + */ + it('testGetActiveUniforms_03', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetActiveUniforms_03 test start ...66'); + //顶点着色器程序 + 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); + const uniformIndices = [7, 8, 9]; + const uniformBlockIndex = gl2.getActiveUniforms(programObj, uniformIndices, gl2 + .UNIFORM_BLOCK_INDEX) + const glintlist = [-1, 0, 0]; + expect(uniformBlockIndex.toString() != glintlist.toString()).assertEqual(true); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetActiveUniforms_03 has failed for " + e) + expect(null).assertFail() + } + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0523 + * @tc.name testGetActiveUniforms_04 + * @tc.desc Test getActiveUniforms. + */ + it('testGetActiveUniforms_04', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetActiveUniforms_04 test start ...66'); + //顶点着色器程序 + 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); + const uniformIndices = [1, 2, 3]; + const uniformOffset = gl2.getActiveUniforms(programObj, uniformIndices, gl2 + .UNIFORM_OFFSET) + const glintlist = [-1, 0, 0]; + expect(uniformOffset.toString() != glintlist.toString()).assertEqual(true); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetActiveUniforms_04 has failed for " + e) + expect(null).assertFail() + } + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0524 + * @tc.name testGetActiveUniforms_05 + * @tc.desc Test getActiveUniforms. + */ + it('testGetActiveUniforms_05', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetActiveUniforms_05 test start ...66'); + //顶点着色器程序 + 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); + const uniformIndices = [1, 2, 3]; + const uniformStride = gl2.getActiveUniforms(programObj, uniformIndices, gl2 + .UNIFORM_ARRAY_STRIDE) + const glintlist = [-1, 0, 0]; + expect(uniformStride.toString() != glintlist.toString()).assertEqual(true); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetActiveUniforms_05 has failed for " + e) + expect(null).assertFail() + } + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0525 + * @tc.name testGetActiveUniforms_06 + * @tc.desc Test getActiveUniforms. + */ + it('testGetActiveUniforms_06', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetActiveUniforms_06 test start ...66'); + //顶点着色器程序 + 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); + const uniformIndices = [1, 2, 3]; + const uniformMatrixStride = gl2.getActiveUniforms(programObj, uniformIndices, gl2 + .UNIFORM_MATRIX_STRIDE) + const glbooleanlist = [-1, 0, 0]; + expect(uniformMatrixStride.toString() != glbooleanlist.toString()).assertEqual(true); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetActiveUniforms_06 has failed for " + e) + expect(null).assertFail() + } + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0527 + * @tc.name testUseProgram + * @tc.desc Test useProgram. + */ + it('testUseProgram', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testUseProgram test start ...66'); + console.info('jsWebGL testUseProgram test start ...' + JSON.stringify(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 program = gl.createProgram(); + console.log("testUseProgram has failed for " + program) + const useProgramError1 = gl.getError(); + console.info("useProgramError: " + useProgramError1); + const renderBufferValue1 = gl.getParameter(gl.CURRENT_PROGRAM); + console.log("testUseProgram has failed for " + program) + gl.attachShader(program, vertexShader); + gl.attachShader(program, fragmentShader); + gl.linkProgram(program); + gl.useProgram(program); + const useProgramError = gl.getError(); + console.info("useProgramError: " + useProgramError); + expect(useProgramError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testUseProgram has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0528 + * @tc.name testValidateProgram + * @tc.desc Test validateProgram. + */ + it('testValidateProgram', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testValidateProgram test start ...66'); + console.info('jsWebGL testValidateProgram test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + gl.validateProgram(program); + const validateProgramError = gl.getError(); + console.info("validateProgramError: " + validateProgramError); + expect(validateProgramError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testValidateProgram has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0529 + * @tc.name testVertexAttrib1f + * @tc.desc Test vertexAttrib1f. + */ + it('testVertexAttrib1f', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib1f test start ...66'); + console.info('jsWebGL testVertexAttrib1f test start ...' + JSON.stringify(gl)); + gl.vertexAttrib1f(1, 10.0); + const vertexAttrib1fError = gl.getError(); + console.info("vertexAttrib1fError: " + vertexAttrib1fError); + expect(vertexAttrib1fError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib1f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0530 + * @tc.name testVertexAttrib2f + * @tc.desc Test vertexAttrib2f. + */ + it('testVertexAttrib2f', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib2f test start ...66'); + gl.vertexAttrib2f(1, 10.0); + const vertexAttrib2fError = gl.getError(); + console.info("vertexAttrib2fError: " + vertexAttrib2fError); + expect(vertexAttrib2fError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib2f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0531 + * @tc.name testVertexAttrib3f + * @tc.desc Test vertexAttrib3f. + */ + it('testVertexAttrib3f', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testvertexAttrib3f test start ...66'); + console.info('jsWebGL testvertexAttrib3f test start ...' + JSON.stringify(gl)); + gl.vertexAttrib3f(1, 10.0); + const vertexAttrib3fError = gl.getError(); + console.info("vertexAttrib3fError: " + vertexAttrib3fError); + expect(vertexAttrib3fError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib3f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0532 + * @tc.name testVertexAttrib4f + * @tc.desc Test vertexAttrib4f. + */ + it('testVertexAttrib4f', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib4f test start ...66'); + console.info('jsWebGL testVertexAttrib4f test start ...' + JSON.stringify(gl)); + gl.vertexAttrib4f(1, 10.0); + const vertexAttrib4fError = gl.getError(); + console.info("vertexAttrib4fError: " + vertexAttrib4fError); + expect(vertexAttrib4fError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testvertexAttrib4f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0533 + * @tc.name testVertexAttrib1fv + * @tc.desc Test vertexAttrib1fv. + */ + it('testVertexAttrib1fv', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib1fv test start ...66'); + console.info('jsWebGL testVertexAttrib1fv test start ...' + JSON.stringify(gl)); + const floatArray = new Float32Array([10.0, 5.0, 2.0]); + gl.vertexAttrib1fv(1, floatArray); + const vertexAttrib1fvError = gl.getError(); + console.info("vertexAttrib1fvError: " + vertexAttrib1fvError); + expect(vertexAttrib1fvError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib1fv has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0534 + * @tc.name testVertexAttrib2fv + * @tc.desc Test vertexAttrib2fv. + */ + it('testVertexAttrib2fv', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib2fv test start ...66'); + console.info('jsWebGL testVertexAttrib2fv test start ...' + JSON.stringify(gl)); + const floatArray = new Float32Array([10.0, 5.0, 2.0]); + gl.vertexAttrib2fv(1, floatArray); + const vertexAttrib2fvError = gl.getError(); + console.info("vertexAttrib2fvError: " + vertexAttrib2fvError); + expect(vertexAttrib2fvError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib2fv has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0535 + * @tc.name testVertexAttrib3fv + * @tc.desc Test vertexAttrib3fv. + */ + it('testVertexAttrib3fv', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib3fv test start ...66'); + console.info('jsWebGL testVertexAttrib3fv test start ...' + JSON.stringify(gl)); + const floatArray = new Float32Array([10.0, 5.0, 2.0]); + gl.vertexAttrib3fv(1, floatArray); + const vertexAttrib3fvError = gl.getError(); + console.info("vertexAttrib3fvError: " + vertexAttrib3fvError); + expect(vertexAttrib3fvError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib3fv has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0536 + * @tc.name testVertexAttrib4fv + * @tc.desc Test vertexAttrib4fv. + */ + it('testVertexAttrib4fv', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib4fv test start ...66'); + console.info('jsWebGL testVertexAttrib4fv test start ...' + JSON.stringify(gl)); + const floatArray = new Float32Array([10.0, 5.0, 2.0]); + gl.vertexAttrib4fv(1, floatArray); + const vertexAttrib4fvError = gl.getError(); + console.info("vertexAttrib4fvError: " + vertexAttrib4fvError); + expect(vertexAttrib4fvError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib4fv has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0537 + * @tc.name testVertexAttribPointer + * @tc.desc Test vertexAttribPointer. + */ + it('testVertexAttribPointer', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttribPointer test start ...66'); + console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 20, 0); + const vertexAttribPointerError = gl.getError(); + console.info("vertexAttribPointerError: " + vertexAttribPointerError); + expect(vertexAttribPointerError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttribPointer has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0538 + * @tc.name testViewport + * @tc.desc Test viewport. + */ + it('testViewport', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testViewport test start ...66'); + console.info('jsWebGL testViewport test start ...' + JSON.stringify(gl)); + gl.viewport(1, 2, 3, 4); + const viewportError = gl.getError(); + console.info("viewportError: " + viewportError); + expect(viewportError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testViewport has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0539 + * @tc.name testTexStorage3D + * @tc.desc Test texStorage3D. + */ + it('testTexStorage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexStorage3D test start ...66'); + console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); + gl2.texStorage3D(gl.TEXTURE_3D, 1, gl.RGB8, 256, 256, 256); + const texStorage3DError = gl.getError(); + console.info("texStorage3DError: " + texStorage3DError); + expect(texStorage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexStorage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0540 + * @tc.name testTexImage3D + * @tc.desc Test texImage3D. + */ + it('testTexImage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D test start ...66'); + console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); + gl2.texImage3D(gl2.TEXTURE_3D, 0, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0541 + * @tc.name testTexImage3D_01 + * @tc.desc Test texImage3D. + */ + it('testTexImage3D_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D_01 test start ...66'); + console.info('jsWebGL testTexImage3D_01 test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + gl2.texImage3D(gl2.TEXTURE_3D, 0, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, + buffer); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D_01 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0542 + * @tc.name testTexImage3D_02 + * @tc.desc Test texImage3D. + */ + it('testTexImage3D_02', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D_02 test start ...66'); + console.info('jsWebGL testTexImage3D_02 test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + gl2.texImage3D(gl2.TEXTURE_3D, 0, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, + buffer, 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D_02 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0543 + * @tc.name testTexSubImage3D + * @tc.desc Test texSubImage3D. + */ + it('testTexSubImage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexSubImage3D test start ...66'); + console.info('jsWebGL testTexSubImage3D test start ...' + JSON.stringify(gl)); + gl2.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 200, 200, 1, gl.RGBA, gl.UNSIGNED_BYTE, 1); + const texSubImage3DError = gl.getError(); + console.info("texSubImage3DError: " + texSubImage3DError); + expect(texSubImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexSubImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0544 + * @tc.name testTexSubImage3D_01 + * @tc.desc Test texSubImage3D. + */ + it('testTexSubImage3D_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexSubImage3D_01 test start ...66'); + console.info('jsWebGL testTexSubImage3D_01 test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(16); + const view = new DataView(buffer, 12, 4); + gl2.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 200, 200, 1, gl.RGBA, gl.UNSIGNED_BYTE, + buffer, 0); + const texSubImage3DError = gl.getError(); + console.info("texSubImage3DError: " + texSubImage3DError); + expect(texSubImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexSubImage3D_01 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0545 + * @tc.name testCopyTexSubImage3D + * @tc.desc Test copyTexSubImage3D. + */ + it('testCopyTexSubImage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCopyTexSubImage3D test start ...66'); + console.info('jsWebGL testCopyTexSubImage3D test start ...' + JSON.stringify(gl)); + gl2.copyTexSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 0, 0, 16, 16); + const copyTexSubImage3DError = gl.getError(); + console.info("copyTexSubImage3DError: " + copyTexSubImage3DError); + expect(copyTexSubImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCopyTexSubImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0546 + * @tc.name testCompressedTexImage3D_01 + * @tc.desc Test compressedTexImage3D. + */ + it('testCompressedTexImage3D_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexImage3D_01 test start ...66'); + console.info('jsWebGL testCompressedTexImage3D_01 test start ...' + JSON.stringify(gl)); + gl2.compressedTexImage3D(gl.TEXTURE_3D, 0, 0x83F0, 512, 512, 512, 0, gl2 + .PIXEL_UNPACK_BUFFER, 0); + const compressedTexImage3DError = gl.getError(); + console.info("compressedTexImage3DError: " + compressedTexImage3DError); + expect(compressedTexImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexImage3D_01 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0547 + * @tc.name testCompressedTexImage3D_02 + * @tc.desc Test compressedTexImage3D. + */ + it('testCompressedTexImage3D_02', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexImage3D_02 test start ...66'); + console.info('jsWebGL testCompressedTexImage3D_02 test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + gl2.compressedTexImage3D(gl.TEXTURE_3D, 0, 0x83F0, 512, 512, 512, 0, buffer, 0, 0); + const compressedTexImage3DError = gl.getError(); + console.info("compressedTexImage3DError: " + compressedTexImage3DError); + expect(compressedTexImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexImage3D_02 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0548 + * @tc.name testCompressedTexSubImage3D + * @tc.desc Test compressedTexSubImage3D. + */ + it('testCompressedTexSubImage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexSubImage3D test start ...66'); + console.info('jsWebGL testCompressedTexSubImage3D test start ...' + JSON.stringify(gl)); + gl2.compressedTexSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 512, 512, 512, gl2 + .COMPRESSED_R11_EAC, + gl2.PIXEL_UNPACK_BUFFER, 0); + const compressedTexSubImage3DError = gl.getError(); + console.info("compressedTexSubImage3DError: " + compressedTexSubImage3DError); + expect(compressedTexSubImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexSubImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0549 + * @tc.name testCompressedTexSubImage3D_01 + * @tc.desc Test compressedTexSubImage3D. + */ + it('testCompressedTexSubImage3D_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexSubImage3D test start ...66'); + console.info('jsWebGL testCompressedTexSubImage3D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + gl2.compressedTexSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 512, 512, 512, gl2 + .COMPRESSED_R11_EAC, buffer, 0, 256); + const compressedTexSubImage3DError = gl.getError(); + console.info("compressedTexSubImage3DError: " + compressedTexSubImage3DError); + expect(compressedTexSubImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexSubImage3D_01 has failed for " + e) + expect(null).assertFail() + } + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0550 + * @tc.name testGetActiveAttribError + * @tc.desc Test getActiveAttrib. + */ + it('testGetActiveAttribError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getActiveAttrib test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + const info = gl.getActiveAttrib(); + expect(info).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0551 + * @tc.name testGetActiveUniformError + * @tc.desc Test getActiveUniform. + */ + it('testGetActiveUniformError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getActiveUniform test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + const info = gl.getActiveUniform(program); + expect(info).assertEqual(undefined); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0552 + * @tc.name testGetAttachedShadersError + * @tc.desc Test getAttachedShaders. + */ + it('testGetAttachedShadersError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getAttachedShaders test start ...' + JSON.stringify(gl)); + const shaderArray = gl.getAttachedShaders(); + console.info('getAttachedShaders shaderArray' + shaderArray); + expect(shaderArray).assertEqual(undefined); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0553 + * @tc.name testGetBufferParameterError + * @tc.desc Test getBufferParameter. + */ + it('testGetBufferParameterError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getBufferParameter test start ...' + JSON.stringify(gl)); + const buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + const bufferSize = gl.getBufferParameter(gl.ARRAY_BUFFER); + expect(bufferSize).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0554 + * @tc.name testGetParameterError + * @tc.desc Test getParameter. + */ + it('testGetParameterError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + var textureParameter = gl.getParameter(); + console.info("activeTexture --> getParameter: " + textureParameter); + expect(textureParameter).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0555 + * @tc.name testGetError_error + * @tc.desc Test getParameter. + */ + it('testGetError_error', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.enable(gl.SCISSOR_TEST); + const scissorErrorCode = gl.scissor(0); + console.info("scissorErrorCode: " + scissorErrorCode); + expect(scissorErrorCode).assertEqual(undefined); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0556 + * @tc.name testGetFramebufferAttachmentParameterError + * @tc.desc Test frontFace. + */ + it('testGetFramebufferAttachmentParameterError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const framebuffer = gl.getFramebufferAttachmentParameter(gl + .FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); + console.info('Framebuffer' + framebuffer); + expect(framebuffer).assertEqual(undefined); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0557 + * @tc.name testGetProgramInfoLog + * @tc.desc Test getProgramInfoLog. + */ + it('testGetProgramInfoLog', 0, async function (done) { + //initContext(); + console.info('jsWebGL getProgramInfoLog test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + // Attach pre-existing shaders + gl.attachShader(program, VSHADER_SOURCE); + gl.attachShader(program, FSHADER_SOURCE); + gl.linkProgram(program); + gl.validateProgram(program); + const info = gl.getProgramInfoLog(); + gl.useProgram(program); + expect(info).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0558 + * @tc.name testGetShaderPrecisionFormatError + * @tc.desc Test getShaderPrecisionFormat. + */ + it('testGetShaderPrecisionFormatError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); + const shaderPrecisionFormat = gl.getShaderPrecisionFormat(); + console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); + expect(shaderPrecisionFormat).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0559 + * @tc.name testGetShaderInfoLogError + * @tc.desc Test getShaderInfoLog. + */ + it('testGetShaderInfoLogError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderInfoLog test start ...' + JSON.stringify(gl)); + var shader = gl.createShader(gl.VERTEX_SHADER); + gl.shaderSource(shader, "shaderCode"); + + /* compile shader source code. */ + gl.compileShader(shader); + const message = gl.getShaderInfoLog(); + console.info("getShaderInfoLog message: " + message); + const type = (message === null); + expect(type).assertEqual(true); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0560 + * @tc.name testGetShaderSource + * @tc.desc Test getShaderSource. + */ + it('testGetShaderSourceError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderSource test start ...' + JSON.stringify(gl)); + var shader = gl.createShader(gl.VERTEX_SHADER); + gl.shaderSource(shader, 'originalSource'); + + var source = gl.getShaderSource(); + console.info("getShaderSource source: " + source); + expect(source).assertEqual(undefined); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0561 + * @tc.name testGetVertexAttribFirst + * @tc.desc Test getVertexAttrib. + */ + it('testGetVertexAttribFirstError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); + const type = gl.getVertexAttrib(0); + console.info("getVertexAttrib: type" + type); + expect(type).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0562 + * @tc.name testGetVertexAttribOffset + * @tc.desc Test getVertexAttribOffset. + */ + it('testGetVertexAttribOffsetError', 0, async function (done) { + //initContext(); + console.info('jsWebGL getVertexAttribOffset test start ...' + JSON.stringify(gl)); + const index = gl.getVertexAttribOffset(); + console.info("getVertexAttribOffset: index" + index); + expect(index).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0563 + * @tc.name testIsBufferError + * @tc.desc Test isBuffer. + */ + it('testIsBufferError', 0, async function (done) { + //initContext(); + console.info('jsWebGL isBuffer test start ...' + JSON.stringify(gl)); + const buffer = gl.createBuffer(); + const isBuffer1 = gl.isBuffer(buffer); + console.info('isBuffer1' + isBuffer1); + expect(isBuffer1).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0564 + * @tc.name testIsEnabledError + * @tc.desc Test isEnabled. + */ + it('testIsEnabledError', 0, async function (done) { + //initContext(); + console.info('jsWebGL isEnabled test start ...' + JSON.stringify(gl)); + gl.disable(gl.STENCIL_TEST); + const isEnabledValue2 = gl.isEnabled(gl.STENCIL_TEST); + console.info("isEnabledValue2: " + isEnabledValue2); + expect(isEnabledValue2).assertEqual(false); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0565 + * @tc.name testRenderbufferStorageError + * @tc.desc Test renderbufferStorage. + */ + it('testRenderbufferStorageError', 0, async function (done) { + //initContext(); + console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); + const returnValue = gl.renderbufferStorage(256, 256); + console.info("getRenderbufferParameter returnValue: " + returnValue); + expect(returnValue).assertEqual(undefined); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0566 + * @tc.name testSampleCoverageError + * @tc.desc Test sampleCoverage. + */ + it('testSampleCoverageError', 0, async function (done) { + //initContext(); + console.info('jsWebGL sampleCoverage test start ...' + JSON.stringify(gl)); + //initContext(); + console.info('jsWebGL sampleCoverage test start ...' + JSON.stringify(gl)); + + const sampleCoverageInvert = gl.sampleCoverage(); + + console.info("sampleCoverageInvert: " + sampleCoverageInvert); + + expect(sampleCoverageInvert).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0567 + * @tc.name testScissorError + * @tc.desc Test scissor. + */ + it('testScissorError', 0, async function (done) { + //initContext(); + console.info('jsWebGL scissor test start ...' + JSON.stringify(gl)); + const scissorValue = gl.scissor(200); + console.info("scissorValue: " + scissorValue); + expect(scissorValue).assertEqual(undefined); + + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0568 + * @tc.name testShaderSourceError + * @tc.desc Test shaderSource. + */ + it('testShaderSourceError', 0, async function (done) { + //initContext(); + console.info('jsWebGL shaderSource test start ...' + JSON.stringify(gl)); + var shader = gl.createShader(gl.VERTEX_SHADER); + var source = gl.shaderSource(shader); + console.info("shaderSource source: " + source); + expect(source).assertEqual(undefined); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0569 + * @tc.name testStencilFuncError + * @tc.desc Test stencilFunc. + */ + it('testStencilFuncError', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilFunc test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + const stencilFuncParameter = gl.stencilFunc(gl.LESS); + console.info("stencilFunc stencilFuncParameter: " + stencilFuncParameter); + expect(stencilFuncParameter).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0570 + * @tc.name testStencilFuncSeparateError + * @tc.desc Test stencilFuncSeparate. + */ + it('testStencilFuncSeparateError', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilFuncSeparate test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + const stencilFuncSeparateParameter = gl.stencilFuncSeparate(gl.FRONT); + console.info("stencilFuncSeparate stencilFuncSeparateParameter: " + + stencilFuncSeparateParameter); + expect(stencilFuncSeparateParameter).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0571 + * @tc.name testStencilMaskError + * @tc.desc Test stencilMask. + */ + it('testStencilMaskError', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilMask test start ...' + JSON.stringify(gl)); + const stencilMaskParameter = gl.stencilMask(); + console.info("stencilMask stencilMaskParameter: " + stencilMaskParameter); + expect(stencilMaskParameter).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0572 + * @tc.name testStencilMaskSeparateError + * @tc.desc Test stencilMaskSeparate. + */ + it('testStencilMaskSeparateError', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilMaskSeparate test start ...' + JSON.stringify(gl)); + const stencilMaskSeparateParameter = gl.stencilMaskSeparate(gl.FRONT); + console.info("stencilMaskSeparate stencilMaskSeparateParameter: " + + stencilMaskSeparateParameter); + expect(stencilMaskSeparateParameter).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0573 + * @tc.name testStencilOpError + * @tc.desc Test stencilOp. + */ + it('testStencilOpError', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilOp test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + const stencilOpParameter = gl.stencilOp(); + console.info("stencilOp stencilOpParameter: " + stencilOpParameter); + expect(stencilOpParameter).assertEqual(undefined); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0574 + * @tc.name testStencilOpSeparate + * @tc.desc Test stencilOpSeparate. + */ + it('testStencilOpSeparateError', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilOpSeparate test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + const stencilOpSeparateParameter = gl.stencilOpSeparate(gl.FRONT, gl.INCR, gl.DECR, gl + .INVERT); + console.info("stencilOpSeparate stencilOpSeparateParameter: " + stencilOpSeparateParameter); + expect(stencilOpSeparateParameter).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0575 + * @tc.name testTexParameterfError + * @tc.desc Test texParameterf. + */ + it('testTexParameterfError', 0, async function (done) { + //initContext(); + console.info('jsWebGL texParameterf test start ...' + JSON.stringify(gl)); + const texParameterValue = gl.texParameterf(); + console.info('texParameterValue' + texParameterValue); + expect(texParameterValue).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0576 + * @tc.name testTexParameteriError + * @tc.desc Test texParameteri. + */ + it('testTexParameteriError', 0, async function (done) { + //initContext(); + console.info('jsWebGL texParameteri test start ...' + JSON.stringify(gl)); + const texParameterValue = gl.texParameteri(); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(undefined); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0577 + * @tc.name testGetUniformBlockIndexError + * @tc.desc Test getUniformBlockIndex. + */ + it('testGetUniformBlockIndexError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 getUniformBlockIndex test start ...' + JSON.stringify(gl2)); + const program = gl.createProgram(); + const blockIndex = gl2.getUniformBlockIndex(program); + gl2.uniformBlockBinding(program, blockIndex, 1); + console.info("uniformBlockBinding blockIndex: " + blockIndex); + expect(blockIndex).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0578 + * @tc.name testGetActiveUniformBlockParameterError + * @tc.desc Test getActiveUniformBlockParameter. + */ + it('testGetActiveUniformBlockParameterError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( + gl2)); + const program = globalFunction(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + const int32Array = new Int32Array([1, 2]); + gl2.uniform1iv(uniformLocation, int32Array); + const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); + gl2.uniformBlockBinding(program, blockIndex, 1); + const blockSize = gl2.getActiveUniformBlockParameter(); + console.info("getActiveUniformBlockParameter blockSize" + blockSize); + expect(blockSize).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0579 + * @tc.name testGetActiveUniformBlockNameError + * @tc.desc Test getActiveUniformBlockName. + */ + it('testGetActiveUniformBlockNameError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 getActiveUniformBlockName test start ...' + JSON.stringify(gl2)); + const program = gl.createProgram(); + const blockIndex = gl2.getUniformBlockIndex(program, 'UBOData'); + console.info("getActiveUniformBlockName blockIndex" + blockIndex); + + gl2.uniformBlockBinding(program, blockIndex, 1); + const blockName = gl2.getActiveUniformBlockName(program); + console.info("blockName" + blockName); + expect(blockName).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0580 + * @tc.name testUniformBlockBindingError + * @tc.desc Test uniformBlockBinding. + */ + it('testUniformBlockBindingError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 uniformBlockBinding test start ...' + JSON.stringify(gl2)); + const program = gl.createProgram(); + const blockIndex = gl2.getUniformBlockIndex(program); + gl2.uniformBlockBinding(program, blockIndex, 1); + const blockName = gl2.getActiveUniformBlockName(program); + console.info("blockName" + blockName); + + expect(blockName).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0581 + * @tc.name testCreateVertexArrayError + * @tc.desc Test createVertexArray. + */ + it('testCreateVertexArrayError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 createVertexArray test start ...' + JSON.stringify(gl2)); + const vao = gl2.createVertexArray(); + const isVertexArray1 = gl2.isVertexArray(vao); + console.info("isVertexArray1" + isVertexArray1); + const isVertexArray = gl2.isVertexArray(vao); + console.info("isVertexArray" + isVertexArray); + expect(isVertexArray).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0582 + * @tc.name testBindVertexArray + * @tc.desc Test bindVertexArray. + */ + it('testBindVertexArrayError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bindVertexArray test start ...' + JSON.stringify(gl2)); + const vao = gl2.createVertexArray(); + const isVertexArray1 = gl2.isVertexArray(vao); + console.info("isVertexArray1" + isVertexArray1); + gl2.bindVertexArray(); + const isVertexArray = gl2.isVertexArray(vao); + console.info("isVertexArray" + isVertexArray); + expect(isVertexArray).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0583 + * @tc.name testDeleteVertexArray + * @tc.desc Test deleteVertexArray. + */ + it('testDeleteVertexArrayError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 deleteVertexArray test start ...' + JSON.stringify(gl2)); + const vao = gl2.createVertexArray(); + gl2.bindVertexArray(vao); + const isVertexArray1 = gl2.isVertexArray(vao); + console.info("isVertexArray1" + isVertexArray1); + gl2.deleteVertexArray(vao); + const isVertexArray = gl2.isVertexArray(vao); + console.info("isVertexArray" + isVertexArray); + expect(isVertexArray).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0584 + * @tc.name testIsVertexArrayError + * @tc.desc Test bindVertexArray. + */ + it('testIsVertexArray', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 isVertexArray test start ...' + JSON.stringify(gl2)); + const vao = gl2.createVertexArray(); + const isVertexArray1 = gl2.isVertexArray(vao); + console.info("isVertexArray1" + isVertexArray1); + gl2.bindVertexArray(vao); + const isVertexArray = gl2.isVertexArray(vao); + console.info("isVertexArray" + isVertexArray); + expect(isVertexArray).assertEqual(true); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0585 + * @tc.name testIsVertexArrayError + * @tc.desc Test bindVertexArray. + */ + it('testIsVertexArrayError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 isVertexArray test start ...' + JSON.stringify(gl2)); + const vao = gl2.createVertexArray(); + const isVertexArray1 = gl2.isVertexArray(vao); + console.info("isVertexArray1" + isVertexArray1); + gl2.bindVertexArray(); + const isVertexArray = gl2.isVertexArray(); + console.info("isVertexArray" + isVertexArray); + expect(isVertexArray).assertEqual(false); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0586 + * @tc.name testTexImage2DError + * @tc.desc Test texImage2D. + */ + it('testTexImage2DError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + gl2.texImage2D(-gl.TEXTURE_2D, -0, -32, -512, -512, -0, -32, -32, -new ArrayBuffer(8)); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(1281); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0587 + * @tc.name testTexSubImage2DError + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2DError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); + gl2.texSubImage2D(-gl.TEXTURE_2D, -0, -0, -0, -512, -512, -gl.RED, gl.FLOAT, - + new ArrayBuffer(16), -0); + const errorCode = gl.getError(); + console.info("webgl2test texSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(1280); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0588 + * @tc.name testCompressedTexImage2DError + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2DError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 compressedTexImage2D test start ...' + JSON.stringify(gl2)); + gl2.compressedTexImage2D(-gl.TEXTURE_2D, -0, -0x83F3, -512, -512, -0, -gl + .PIXEL_UNPACK_BUFFER, -0); + const errorCode = gl.getError(); + console.info("webgl2test compressedTexImage2D getError: " + errorCode); + expect(errorCode).assertEqual(1280); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0589 + * @tc.name testCompressedTexSubImage2DError + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2DError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 compressedTexSubImage2D test start ...' + JSON.stringify(gl2)); + gl2.compressedTexSubImage2D(-gl.TEXTURE_2D, -0, -256, -256, -512, -512, -0x83F3, -gl + .PIXEL_UNPACK_BUFFER, 0); + const errorCode = gl.getError(); + console.info("webgl2test compressedTexSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(1281); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0590 + * @tc.name testBufferSubDataError + * @tc.desc Test bufferData. + */ + it('testBufferSubDataError', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + gl2.bufferSubData(-gl.COPY_READ_BUFFER, -512, -new ArrayBuffer(8)); + const errorCode = gl.getError(); + console.info("webgl2test bufferSubData getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0591 + * @tc.name webgl_test_getContextAttributes2 + * @tc.desc Test getContextAttributes. + */ + it('webgl_test_getContextAttributes2', 0, async function (done) { + //initContext(); + console.info("webgltest into getContextAttributes"); + const getContextAttributesValue = gl.getContextAttributes("error"); + console.info("webgltest getContextAttributes: " + getContextAttributesValue); + expect(getContextAttributesValue).assertEqual(null); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0592 + * @tc.name webgl_test_isContextLost2 + * @tc.desc Test isContextLost. + */ + it('webgl_test_isContextLost2', 0, async function (done) { + //initContext(); + console.info("webgltest into isContextLost"); + const isContextLostValue = gl.isContextLost("error"); + console.info("webgltest isContextLost: " + isContextLostValue); + expect(isContextLostValue).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0593 + * @tc.name webgl_test_getSupportedExtensions2 + * @tc.desc Test getSupportedExtensions. + */ + it('webgl_test_getSupportedExtensions2', 0, async function (done) { + //initContext(); + console.info("webgltest into getSupportedExtensions"); + const getSupportedExtensionsValue = gl.getSupportedExtensions("error"); + console.info("webgltest getSupportedExtensions: " + getSupportedExtensionsValue); + expect(typeof (getSupportedExtensionsValue)).assertEqual('object'); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0595 + * @tc.name webgl_test_getExtension2 + * @tc.desc Test getExtension. + */ + it('webgl_test_getExtension2', 0, async function (done) { + //initContext(); + console.info("webgltest into getExtension"); + const getExtensionValue = gl.getExtension("error"); + console.info("webgltest getExtension: " + getExtensionValue); + expect(getExtensionValue).assertEqual(undefined); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0596 + * @tc.name webgl_test_activeTexture2 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture2', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE8B4C); + 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_0597 + * @tc.name webgl_test_activeTexture_12 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture_12', 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_0598 + * @tc.name webgl_test_attachShader2 + * @tc.desc Test attachShader. + */ + it('webgl_test_attachShader2', 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.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0599 + * @tc.name webgl_test_bindAttribLocation2 + * @tc.desc Test bindAttribLocation. + */ + it('webgl_test_bindAttribLocation2', 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, 'V_color'); + + 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_0600 + * @tc.name webgl_test_bindBuffer2 + * @tc.desc Test bindBuffer. + */ + it('webgl_test_bindBuffer2', 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(); + }); + }) +} diff --git a/graphic/webGL/src/main/js/test/WebGL.test07.js b/graphic/webGL/src/main/js/test/WebGL.test07.js new file mode 100644 index 0000000000000000000000000000000000000000..7c322884d879e8f6983f22b014c760d1e148ddf8 --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test07.js @@ -0,0 +1,2149 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl7() { + describe('webgl1Test_webgl7', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_0601 + * @tc.name webgl_test_bindBuffer_12 + * @tc.desc Test bindBuffer. + */ + it('webgl_test_bindBuffer_12', 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(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0602 + * @tc.name webgl_test_bindFramebuffer2 + * @tc.desc Test bindFramebuffer. + */ + it('webgl_test_bindFramebuffer2', 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 --> isFramebuffer_2: " + + isFrameBuffer2); + expect(isFrameBuffer2).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0603 + * @tc.name webgl_test_bindRenderbuffer2 + * @tc.desc Test bindRenderbuffer. + */ + it('webgl_test_bindRenderbuffer2', 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(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0604 + * @tc.name webgl_test_bindTexture2 + * @tc.desc Test bindTexture. + */ + it('webgl_test_bindTexture2', 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(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0605 + * @tc.name webgl_test_blendColor2 + * @tc.desc Test blendColor. + */ + it('webgl_test_blendColor2', 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_0606 + * @tc.name webgl_test_blendColor_12 + * @tc.desc Test blendColor. + */ + it('webgl_test_blendColor_12', 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_0607 + * @tc.name webgl_test_blendEquation2 + * @tc.desc Test blendEquation. + */ + it('webgl_test_blendEquation2', 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_0608 + * @tc.name webgl_test_blendEquation_12 + * @tc.desc Test blendEquation. + */ + it('webgl_test_blendEquation_12', 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(gl.FUNC_ADD); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0609 + * @tc.name webgl_test_blendEquationSeparate2 + * @tc.desc Test blendEquationSeparate. + */ + it('webgl_test_blendEquationSeparate2', 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_0613 + * @tc.name webgl_test_clear2 + * @tc.desc Test clear. + */ + it('webgl_test_clear2', 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_0614 + * @tc.name webgl_test_clearColor2 + * @tc.desc Test clearColor. + */ + it('webgl_test_clearColor2', 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_0615 + * @tc.name webgl_test_clearDepth2 + * @tc.desc Test clearDepth. + */ + it('webgl_test_clearDepth2', 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); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0616 + * @tc.name webgl_test_clearDepth_22 + * @tc.desc Test clearDepth. + */ + it('webgl_test_clearDepth_22', 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(0); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0617 + * @tc.name webgl_test_clearStencil2 + * @tc.desc Test clearStencil. + */ + it('webgl_test_clearStencil2', 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_0618 + * @tc.name webgl_test_clearStencil_12 + * @tc.desc Test clearStencil. + */ + it('webgl_test_clearStencil_12', 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_0620 + * @tc.name webgl_test_colorMask_12 + * @tc.desc Test colorMask. + */ + it('webgl_test_colorMask_12', 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_0622 + * @tc.name webgl_test_createProgram2 + * @tc.desc Test createProgram. + */ + it('webgl_test_createProgram2', 0, async function (done) { + //initContext(); + console.info("webgltest into createProgram"); + const program = gl.createProgram("error"); + const isProgram = gl.isProgram(program); + console.info("webgltest createProgram isProgram: " + isProgram); + expect(isProgram).assertEqual(true); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0623 + * @tc.name webgl_test_createShader2 + * @tc.desc Test createShader. + */ + it('webgl_test_createShader2', 0, async function (done) { + //initContext(); + console.info("webgltest into createShader"); + + const shader = gl.createShader('VERTEX_SHADER'); + const isShader = gl.isShader(shader); + console.info("webgltest createShader isShader: " + isShader); + expect(isShader).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0624 + * @tc.name webgl_test_deleteFramebuffer2 + * @tc.desc Test deleteFramebuffer. + */ + it('webgl_test_deleteFramebuffer2', 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(); + + const isFramebuffer2 = gl.isFramebuffer(framebuffer); + console.info("webgltest createFramebuffer bindFramebuffer isFramebuffer2: " + + isFramebuffer2); + expect(isFramebuffer2).assertEqual(true); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0625 + * @tc.name webgl_test_deleteRenderbuffer2 + * @tc.desc Test deleteRenderbuffer. + */ + it('webgl_test_deleteRenderbuffer2', 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(); + + const isRenderbuffer2 = gl.isRenderbuffer(renderbuffer); + console.info( + "webgltest createRenderbuffer bindRenderbuffer deleteRenderbuffer isRenderbuffer2: " + + isRenderbuffer2); + expect(isRenderbuffer2).assertEqual(true); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0628 + * @tc.name webgl_test_enableVertexAttribArray2 + * @tc.desc Test enableVertexAttribArray. + */ + it('webgl_test_enableVertexAttribArray2', 0, async function (done) { + //initContext(); + console.info("webgltest into enableVertexAttribArray"); + //顶点着色器程序 + 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); + + const aVertexPosition = gl.getAttribLocation(programObj, "a_Position"); + + gl.enableVertexAttribArray(aVertexPosition); + gl.vertexAttribPointer(aVertexPosition, 4, gl.FLOAT, false, 0, 0); + + gl.drawArrays(gl.TRIANGLES, 0, 3); + + + let errorCode = gl.getError(); + console.info("webgltest enableVertexAttribArray getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0629 + * @tc.name webgl_test_finish2 + * @tc.desc Test finish. + */ + it('webgl_test_finish2', 0, async function (done) { + //initContext(); + console.info("webgltest into finish"); + gl.finish(); + let errorCode = gl.getError(); + console.info("webgltest finish getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0630 + * @tc.name webgl_test_flush2 + * @tc.desc Test flush. + */ + it('webgl_test_flush2', 0, async function (done) { + //initContext(); + console.info("webgltest into flush"); + gl.flush("error"); + let errorCode = gl.getError(); + console.info("webgltest flush getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0637 + * @tc.name webgl_test_createSampler2 + * @tc.desc Test createSampler. + */ + it('webgl_test_createSampler2', 0, async function (done) { + //initContext(); + console.info("webgltest into createSampler"); + const sampler = gl2.createSampler('error'); + const isSampler1 = gl2.isSampler(sampler); + console.info("webgltest createSampler isSampler1: " + isSampler1); + expect(isSampler1).assertEqual(true); + + gl2.bindSampler(0, sampler); + const isSampler2 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); + expect(isSampler2).assertEqual(true); + + gl2.deleteSampler(sampler); + const isSampler3 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); + expect(isSampler3).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0638 + * @tc.name webgl_test_deleteSampler2 + * @tc.desc Test deleteSampler. + */ + it('webgl_test_deleteSampler2', 0, async function (done) { + //initContext(); + console.info("webgltest into deleteSampler"); + const sampler = gl2.createSampler(); + const isSampler1 = gl2.isSampler(sampler); + console.info("webgltest createSampler isSampler1: " + isSampler1); + expect(isSampler1).assertEqual(true); + + gl2.bindSampler(0, sampler); + const isSampler2 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); + expect(isSampler2).assertEqual(true); + + gl2.deleteSampler('sampler'); + const isSampler3 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); + expect(isSampler3).assertEqual(true); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0639 + * @tc.name webgl_test_bindSampler2 + * @tc.desc Test bindSampler. + */ + it('webgl_test_bindSampler2', 0, async function (done) { + //initContext(); + console.info("webgltest into bindSampler"); + const sampler = gl2.createSampler(); + const isSampler1 = gl2.isSampler(sampler); + console.info("webgltest createSampler isSampler1: " + isSampler1); + expect(isSampler1).assertEqual(true); + + gl2.bindSampler(0, 'sampler'); + const isSampler2 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); + expect(isSampler2).assertEqual(true); + + gl2.deleteSampler(sampler); + const isSampler3 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); + expect(isSampler3).assertEqual(false); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0641 + * @tc.name webgl_test_samplerParameterf2 + * @tc.desc Test samplerParameterf. + */ + it('webgl_test_samplerParameterf2', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameterf"); + + let sampler = gl2.createSampler(); + // gl2.bindSampler(0, sampler); + gl2.samplerParameterf(sampler, gl.TEXTURE_MAG_FILTER); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameterf getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0642 + * @tc.name webgl_test_getSamplerParameter_12 + * @tc.desc Test getSamplerParameter. + */ + it('webgl_test_getSamplerParameter_12', 0, async function (done) { + //initContext(); + console.info("webgltest into getSamplerParameter"); + + let sampler = gl2.createSampler(); + + const samplerParameter = gl2.getSamplerParameter(sampler, '0x884D'); + + console.info("webgltest createSampler getSamplerParameter_1: " + samplerParameter); + expect(samplerParameter).assertEqual(undefined); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0643 + * @tc.name webgl_test_fenceSync2 + * @tc.desc Test fenceSync. + */ + it('webgl_test_fenceSync2', 0, async function (done) { + //initContext(); + console.info("webgltest into fenceSync"); + + let sync = gl2.fenceSync('0x9117', 0); + let status = gl2.clientWaitSync(sync, 0, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(false); + + gl2.deleteSync(sync); + + const isSync2 = gl2.isSync(sync); + console.info("webgltest fenceSync deleteSync isSync2: " + isSync2); + expect(isSync2).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0644 + * @tc.name webgl_test_isSync2 + * @tc.desc Test isSync. + */ + it('webgl_test_isSync2', 0, async function (done) { + //initContext(); + console.info("webgltest into isSync"); + let sync = gl2.fenceSync(0x9117, 0); + let status = gl2.clientWaitSync(sync, 0, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(true); + + gl2.deleteSync(sync); + + const isSync2 = gl2.isSync('sync'); + console.info("webgltest fenceSync deleteSync isSync2: " + isSync2); + expect(isSync2).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0645 + * @tc.name webgl_test_deleteSync2 + * @tc.desc Test deleteSync. + */ + it('webgl_test_deleteSync2', 0, async function (done) { + //initContext(); + console.info("webgltest into deleteSync"); + let sync = gl2.fenceSync(0x9117, 0); + let status = gl2.clientWaitSync(sync, 0, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(true); + + gl2.deleteSync('sync'); + + const isSync2 = gl2.isSync(sync); + console.info("webgltest fenceSync deleteSync isSync2: " + isSync2); + expect(isSync2).assertEqual(true); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0646 + * @tc.name webgl_test_clientWaitSync2 + * @tc.desc Test clientWaitSync. + */ + it('webgl_test_clientWaitSync2', 0, async function (done) { + //initContext(); + console.info("webgltest into clientWaitSync"); + let sync = gl2.fenceSync(0x9117, 0); + let status = gl2.clientWaitSync('sync', 0, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(true); + + console.info("webgltest fenceSync clientWaitSync: " + status); + + expect(status).assertEqual(0); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0647 + * @tc.name webgl_test_waitSync2 + * @tc.desc Test waitSync. + */ + it('webgl_test_waitSync2', 0, async function (done) { + //initContext(); + console.info("webgltest into waitSync"); + + let sync = gl2.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0); + gl2.waitSync('sync', 0, gl.TIMEOUT_IGNORED); + + let errorCode = gl.getError(); + console.info("webgltest framebufferTexture2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0648 + * @tc.name webgl_test_createTransformFeedback2 + * @tc.desc Test createTransformFeedback. + */ + it('webgl_test_createTransformFeedback2', 0, async function (done) { + //initContext(); + console.info("webgltest into createTransformFeedback"); + + const transformFeedback = gl2.createTransformFeedback(); + + + console.info("webgltest into createTransformFeedback: " + transformFeedback) + + gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); + + gl2.beginTransformFeedback(gl2.TRIANGLES); + + const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); + + console.info("BindTransformFeedback : " + isTransformFeedback2); + expect(isTransformFeedback2).assertEqual(true); + + gl2.deleteTransformFeedback(transformFeedback); + const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); + console.info("webgltest createTransformFeedback bindTransformFeedback " + + "deleteTransformFeedback isTransformFeedback3: " + isTransformFeedback3); + expect(isTransformFeedback3).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0649 + * @tc.name webgl_test_isTransformFeedback2 + * @tc.desc Test isTransformFeedback. + */ + it('webgl_test_isTransformFeedback2', 0, async function (done) { + //initContext(); + console.info("webgltest into isTransformFeedback"); + let transformFeedback = gl2.createTransformFeedback(); + const isTransformFeedback1 = gl2.isTransformFeedback(transformFeedback); + console.info("webgltest createTransformFeedback isTransformFeedback1: " + + isTransformFeedback1); + expect(isTransformFeedback1).assertEqual(false); + + gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); + + const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); + console.info( + "webgltest createTransformFeedback bindTransformFeedback isTransformFeedback2: " + + isTransformFeedback2); + expect(isTransformFeedback2).assertEqual(true); + + gl2.deleteTransformFeedback(transformFeedback); + const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); + console.info("webgltest createTransformFeedback bindTransformFeedback " + + "deleteTransformFeedback isTransformFeedback3: " + isTransformFeedback3); + expect(isTransformFeedback3).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0650 + * @tc.name webgl_test_bindTransformFeedback2 + * @tc.desc Test bindTransformFeedback. + */ + it('webgl_test_bindTransformFeedback2', 0, async function (done) { + //initContext(); + console.info("webgltest into bindTransformFeedback"); + let transformFeedback = gl2.createTransformFeedback(); + const isTransformFeedback1 = gl2.isTransformFeedback(transformFeedback); + console.info("webgltest createTransformFeedback isTransformFeedback1: " + + isTransformFeedback1); + expect(isTransformFeedback1).assertEqual(false); + + gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); + + const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); + console.info("webgltest createTransformFeedback bindTransformFeedback " + + "isTransformFeedback2: " + isTransformFeedback2); + expect(isTransformFeedback2).assertEqual(true); + + gl2.deleteTransformFeedback(transformFeedback); + const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); + console.info("webgltest createTransformFeedback bindTransformFeedback " + + "deleteTransformFeedback isTransformFeedback3: " + isTransformFeedback3); + expect(isTransformFeedback3).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0651 + * @tc.name webgl_test_beginTransformFeedback2 + * @tc.desc Test beginTransformFeedback. + */ + it('webgl_test_beginTransformFeedback2', 0, async function (done) { + //initContext(); + console.info("webgltest into beginTransformFeedback"); + + let transformFeedback = gl2.createTransformFeedback(); + + gl2.beginTransformFeedback('TRIANGLES'); + + let errorCode = gl.getError(); + console.info("webgltest framebufferTexture2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0653 + * @tc.name webgl_test_deleteTransformFeedback2 + * @tc.desc Test deleteTransformFeedback. + */ + it('webgl_test_deleteTransformFeedback2', 0, async function (done) { + //initContext(); + console.info("webgltest into deleteTransformFeedback"); + const transformFeedback = gl2.createTransformFeedback(); + + gl2.bindTransformFeedback(gl2.TRANSFORM_FEEDBACK, transformFeedback); + + const isTransformFeedback2 = gl2.isTransformFeedback(transformFeedback); + console.info("webgltest createTransformFeedback bindTransformFeedback " + + "isTransformFeedback2: " + isTransformFeedback2); + expect(isTransformFeedback2).assertEqual(true); + + gl2.deleteTransformFeedback('transformFeedback'); + const isTransformFeedback3 = gl2.isTransformFeedback(transformFeedback); + console.info( + "webgltest createTransformFeedback bindTransformFeedback deleteTransformFeedback " + + "isTransformFeedback3: " + isTransformFeedback3); + expect(isTransformFeedback3).assertEqual(true); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0654 + * @tc.name testUseProgramError + * @tc.desc Test useProgram. + */ + it('testUseProgramError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testUseProgram test start ...66'); + console.info('jsWebGL testUseProgram test start ...' + JSON.stringify(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 program = gl.createProgram(); + console.log("testUseProgram has failed for " + program) + const useProgramError1 = gl.getError(); + console.info("useProgramError: " + useProgramError1); + const renderBufferValue1 = gl.getParameter(gl.CURRENT_PROGRAM); + console.log("testUseProgram has failed for " + program) + gl.attachShader(program, vertexShader); + gl.attachShader(program, fragmentShader); + gl.linkProgram(program); + gl.useProgram(false); + const useProgramError = gl.getError(); + console.info("useProgramError: " + useProgramError); + expect(useProgramError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testUseProgram has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0655 + * @tc.name testValidateProgramError + * @tc.desc Test validateProgram. + */ + it('testValidateProgramError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testValidateProgram test start ...66'); + console.info('jsWebGL testValidateProgram test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + gl.validateProgram(false); + const validateProgramError = gl.getError(); + console.info("validateProgramError: " + validateProgramError); + expect(validateProgramError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testValidateProgram has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0656 + * @tc.name testVertexAttrib1fError + * @tc.desc Test vertexAttrib1f. + */ + it('testVertexAttrib1fError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib1f test start ...66'); + console.info('jsWebGL testVertexAttrib1f test start ...' + JSON.stringify(gl)); + gl.vertexAttrib1f(false, 10.0); + const vertexAttrib1fError = gl.getError(); + console.info("vertexAttrib1fError: " + vertexAttrib1fError); + expect(vertexAttrib1fError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib1f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0657 + * @tc.name testVertexAttrib2fError + * @tc.desc Test vertexAttrib2f. + */ + it('testVertexAttrib2fError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib2f test start ...66'); + gl.vertexAttrib2f(false, 10.0); + const vertexAttrib2fError = gl.getError(); + console.info("vertexAttrib2fError: " + vertexAttrib2fError); + expect(vertexAttrib2fError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib2f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0658 + * @tc.name testVertexAttrib3fError + * @tc.desc Test vertexAttrib3f. + */ + it('testVertexAttrib3fError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testvertexAttrib3f test start ...66'); + console.info('jsWebGL testvertexAttrib3f test start ...' + JSON.stringify(gl)); + gl.vertexAttrib3f(false, 10.0); + const vertexAttrib3fError = gl.getError(); + console.info("vertexAttrib3fError: " + vertexAttrib3fError); + expect(vertexAttrib3fError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib3f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0659 + * @tc.name testVertexAttrib4fError + * @tc.desc Test vertexAttrib4f. + */ + it('testVertexAttrib4fError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib4f test start ...66'); + console.info('jsWebGL testVertexAttrib4f test start ...' + JSON.stringify(gl)); + gl.vertexAttrib4f(false, 10.0); + const vertexAttrib4fError = gl.getError(); + console.info("vertexAttrib4fError: " + vertexAttrib4fError); + expect(vertexAttrib4fError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testvertexAttrib4f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0660 + * @tc.name testVertexAttrib1fvError + * @tc.desc Test vertexAttrib1fv. + */ + it('testVertexAttrib1fvError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib1fv test start ...66'); + console.info('jsWebGL testVertexAttrib1fv test start ...' + JSON.stringify(gl)); + const floatArray = new Float32Array([10.0, 5.0, 2.0]); + gl.vertexAttrib1fv(false, floatArray); + const vertexAttrib1fvError = gl.getError(); + console.info("vertexAttrib1fvError: " + vertexAttrib1fvError); + expect(vertexAttrib1fvError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib1fv has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0661 + * @tc.name testVertexAttrib2fvError + * @tc.desc Test vertexAttrib2fv. + */ + it('testVertexAttrib2fvError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib2fv test start ...66'); + console.info('jsWebGL testVertexAttrib2fv test start ...' + JSON.stringify(gl)); + const floatArray = new Float32Array([10.0, 5.0, 2.0]); + gl.vertexAttrib2fv(false, floatArray); + const vertexAttrib2fvError = gl.getError(); + console.info("vertexAttrib2fvError: " + vertexAttrib2fvError); + expect(vertexAttrib2fvError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib2fv has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0662 + * @tc.name testVertexAttrib3fvError + * @tc.desc Test vertexAttrib3fv. + */ + it('testVertexAttrib3fvError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib3fv test start ...66'); + console.info('jsWebGL testVertexAttrib3fv test start ...' + JSON.stringify(gl)); + const floatArray = new Float32Array([10.0, 5.0, 2.0]); + gl.vertexAttrib3fv(false, floatArray); + const vertexAttrib3fvError = gl.getError(); + console.info("vertexAttrib3fvError: " + vertexAttrib3fvError); + expect(vertexAttrib3fvError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib3fv has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0663 + * @tc.name testVertexAttrib4fvError + * @tc.desc Test vertexAttrib4fv. + */ + it('testVertexAttrib4fvError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib4fv test start ...66'); + console.info('jsWebGL testVertexAttrib4fv test start ...' + JSON.stringify(gl)); + const floatArray = new Float32Array([10.0, 5.0, 2.0]); + gl.vertexAttrib4fv(false, floatArray); + const vertexAttrib4fvError = gl.getError(); + console.info("vertexAttrib4fvError: " + vertexAttrib4fvError); + expect(vertexAttrib4fvError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib4fv has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0664 + * @tc.name testVertexAttribPointerError + * @tc.desc Test vertexAttribPointer. + */ + it('testVertexAttribPointerError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttribPointer test start ...66'); + console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 20, 0); + const vertexAttribPointerError = gl.getError(); + console.info("vertexAttribPointerError: " + vertexAttribPointerError); + expect(vertexAttribPointerError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttribPointer has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0665 + * @tc.name testViewportError + * @tc.desc Test viewport. + */ + it('testViewportError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testViewport test start ...66'); + console.info('jsWebGL testViewport test start ...' + JSON.stringify(gl)); + gl.viewport(false, 2, 3, 4); + const viewportError = gl.getError(); + console.info("viewportError: " + viewportError); + expect(viewportError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testViewport has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0666 + * @tc.name testTexStorage3DError + * @tc.desc Test texStorage3D. + */ + it('testTexStorage3DError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexStorage3D test start ...66'); + console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); + gl2.texStorage3D(gl.TEXTURE_3D, false, gl.RGB8, 256, 256, 256); + const texStorage3DError = gl.getError(); + console.info("texStorage3DError: " + texStorage3DError); + expect(texStorage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexStorage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0667 + * @tc.name testTexImage3DError + * @tc.desc Test texImage3D. + */ + it('testTexImage3DError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D test start ...66'); + console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); + gl2.texImage3D(gl2.TEXTURE_3D, false, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, + 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0668 + * @tc.name testTexImage3D_01Error + * @tc.desc Test texImage3D. + */ + it('testTexImage3D_01Error', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D_01Error test start ...66'); + console.info('jsWebGL testTexImage3D_01Error test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + gl2.texImage3D(gl2.TEXTURE_3D, false, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, + buffer); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D_01 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0669 + * @tc.name testTexImage3D_02Error + * @tc.desc Test texImage3D. + */ + it('testTexImage3D_02Error', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D_02Error test start ...66'); + console.info('jsWebGL testTexImage3D_02Error test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + gl2.texImage3D(gl2.TEXTURE_3D, false, gl.RGBA, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, + buffer, 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D_02 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0670 + * @tc.name testTexSubImage3D_01Error + * @tc.desc Test texSubImage3D. + */ + it('testTexSubImage3D_01Error', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexSubImage3D_01Error test start ...66'); + console.info('jsWebGL testTexSubImage3D_01Error test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(16); + const view = new DataView(buffer, 12, 4); + gl2.texSubImage3D(gl.TEXTURE_3D, false, 0, 0, 0, 200, 200, 1, gl.RGBA, gl.UNSIGNED_BYTE, + buffer, 0); + const texSubImage3DError = gl.getError(); + console.info("texSubImage3DError: " + texSubImage3DError); + expect(texSubImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexSubImage3D_01 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0671 + * @tc.name testTexSubImage3DError + * @tc.desc Test texSubImage3D. + */ + it('testTexSubImage3DError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexSubImage3DError test start ...66'); + console.info('jsWebGL testTexSubImage3DError test start ...' + JSON.stringify(gl)); + gl2.texSubImage3D(gl.TEXTURE_3D, false, 0, 0, 0, 200, 200, 1, gl.RGBA, gl.UNSIGNED_BYTE, + 1); + const texSubImage3DError = gl.getError(); + console.info("texSubImage3DError: " + texSubImage3DError); + expect(texSubImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexSubImage3DError has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0672 + * @tc.name testCopyTexSubImage3DError + * @tc.desc Test copyTexSubImage3D. + */ + it('testCopyTexSubImage3DError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCopyTexSubImage3DError test start ...66'); + console.info('jsWebGL testCopyTexSubImage3DError test start ...' + JSON.stringify(gl)); + gl2.copyTexSubImage3D(gl.TEXTURE_3D, false, 0, 0, 0, 0, 0, 16, 16); + const copyTexSubImage3DError = gl.getError(); + console.info("copyTexSubImage3DError: " + copyTexSubImage3DError); + expect(copyTexSubImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCopyTexSubImage3DError has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0673 + * @tc.name testCompressedTexImage3D_01Error + * @tc.desc Test compressedTexImage3D. + */ + it('testCompressedTexImage3D_01Error', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexImage3D_01Error test start ...66'); + console.info('jsWebGL testCompressedTexImage3D_01Error test start ...' + JSON.stringify( + gl)); + gl2.compressedTexImage3D(gl.TEXTURE_3D, false, 0x83F0, 512, 512, 512, 0, gl2 + .PIXEL_UNPACK_BUFFER, 0); + const compressedTexImage3DError = gl.getError(); + console.info("compressedTexImage3DError: " + compressedTexImage3DError); + expect(compressedTexImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexImage3D_01Error has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0674 + * @tc.name testCompressedTexImage3D_02Error + * @tc.desc Test compressedTexImage3D. + */ + it('testCompressedTexImage3D_02Error', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexImage3D_02Error test start ...66'); + console.info('jsWebGL testCompressedTexImage3D_02Error test start ...' + JSON.stringify( + gl)); + const buffer = new ArrayBuffer(8); + gl2.compressedTexImage3D(gl.TEXTURE_3D, false, 0x83F0, 512, 512, 512, 0, buffer, 0, 0); + const compressedTexImage3DError = gl.getError(); + console.info("compressedTexImage3DError: " + compressedTexImage3DError); + expect(compressedTexImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexImage3D_02Error has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0675 + * @tc.name testCompressedTexSubImage3DError + * @tc.desc Test compressedTexSubImage3D. + */ + it('testCompressedTexSubImage3DError', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexSubImage3DError test start ...66'); + console.info('jsWebGL testCompressedTexSubImage3DError test start ...' + JSON.stringify( + gl)); + gl2.compressedTexSubImage3D(gl.TEXTURE_3D, false, 0, 0, 0, 512, 512, 512, gl2 + .COMPRESSED_R11_EAC, + gl2.PIXEL_UNPACK_BUFFER, 0); + const compressedTexSubImage3DError = gl.getError(); + console.info("compressedTexSubImage3DError: " + compressedTexSubImage3DError); + expect(compressedTexSubImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexSubImage3DError has failed for " + e) + expect(null).assertFail() + } + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0676 + * @tc.name testCompressedTexSubImage3D_01Error + * @tc.desc Test compressedTexSubImage3D. + */ + it('testCompressedTexSubImage3D_01Error', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexSubImage3D_01Error test start ...66'); + console.info('jsWebGL testCompressedTexSubImage3D_01Error test start ...' + JSON + .stringify(gl)); + const buffer = new ArrayBuffer(8); + gl2.compressedTexSubImage3D(gl.TEXTURE_3D, false, 0, 0, 0, 512, 512, 512, gl2 + .COMPRESSED_R11_EAC, + buffer, 0, 256); + const compressedTexSubImage3DError = gl.getError(); + console.info("testCompressedTexSubImage3D_01Error: " + compressedTexSubImage3DError); + expect(compressedTexSubImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexSubImage3D_01Error has failed for " + e) + expect(null).assertFail() + } + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0677 + * @tc.name webgl_test_getFragDataLocationError + * @tc.desc Test getFragDataLocation. + */ + it('webgl_test_getFragDataLocationError', 0, async function (done) { + //initContext(); + console.info("webgltest into getFragDataLocation"); + + //顶点着色器程序 + 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); + + gl2.getFragDataLocation(programObj, false); + + let errorCode = gl.getError(); + console.info("webgltest webgl_test_getFragDataLocationError getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0678 + * @tc.name webgl_test_vertexAttribI4uiError + * @tc.desc Test vertexAttribI4ui. + */ + it('webgl_test_vertexAttribI4uiError', 0, async function (done) { + //initContext(); + console.info("webgltest into vertexAttribI4ui"); + + const a = gl2.vertexAttribI4ui(false, 10, 11, 12, 13); + + let errorCode = gl.getError(); + console.info("webgltest vertexAttribI4ui getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0679 + * @tc.name webgl_test_vertexAttribIPointerError + * @tc.desc Test vertexAttribIPointer. + */ + it('webgl_test_vertexAttribIPointerError', 0, async function (done) { + //initContext(); + console.info("webgltest into vertexAttribIPointer"); + + const a = gl2.vertexAttribIPointer(false, 4, gl.UNSIGNED_BYTE, 20, 16); + + let errorCode = gl.getError(); + console.info("webgltest vertexAttribIPointer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0680 + * @tc.name webgl_test_drawArraysInstancedError + * @tc.desc Test drawArraysInstanced. + */ + it('webgl_test_drawArraysInstancedError', 0, async function (done) { + //initContext(); + console.info("webgltest into drawArraysInstanced"); + + const a = gl2.drawArraysInstanced(gl.POINTS, false, 8, 4); + + let errorCode = gl.getError(); + console.info("webgltest drawArraysInstanced getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0681 + * @tc.name webgl_test_drawElementsInstancedError + * @tc.desc Test drawElementsInstanced. + */ + it('webgl_test_drawElementsInstancedError', 0, async function (done) { + //initContext(); + console.info("webgltest into drawElementsInstanced"); + + const a = gl2.drawElementsInstanced(gl.POINTS, false, gl.UNSIGNED_SHORT, 0, 4); + + let errorCode = gl.getError(); + console.info("webgltest drawElementsInstanced getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0682 + * @tc.name webgl_test_drawRangeElementsError + * @tc.desc Test drawRangeElements. + */ + it('webgl_test_drawRangeElementsError', 0, async function (done) { + //initContext(); + console.info("webgltest into drawRangeElements"); + + const a = gl2.drawRangeElements(gl.POINTS, false, 7, 8, gl.UNSIGNED_BYTE, 0); + + let errorCode = gl.getError(); + console.info("webgltest drawRangeElements getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0683 + * @tc.name testCompressedTexImage2D_0415 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D_0415', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexImage2D_0415 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + var texture = gl.createTexture(); + gl.bindTexture(texture, texture); + gl.compressedTexImage2D(-texture, -8, -"abc", -8, -512, -8, view); + const compressedTexImage2DError = gl.getError(); + console.info("compressedTexImage2DError: " + compressedTexImage2DError); + expect(compressedTexImage2DError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0684 + * @tc.name testCompressedTexImage2D_0416 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D_0416', 0, async function (done) { + //initContext(); + console.info('jsWebGL GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0415_02 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + var texture = gl.createTexture(); + gl.bindTexture(texture, texture); + gl.compressedTexImage2D(-texture, -8, -texture, -8, -512, -8, view); + const compressedTexImage2DError = gl.getError(); + console.info("compressedTexImage2DError: " + compressedTexImage2DError); + expect(compressedTexImage2DError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0685 + * @tc.name testCompressedTexSubImage2D_0420 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D_0420', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexSubImage2D_0420 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, -0); + gl.compressedTexSubImage2D(-texture, -0, -256, -texture, -512, -0x83F3, -gl + .PIXEL_UNPACK_BUFFER, view); + const compressedTexSubImage2DError = gl.getError(); + console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); + expect(compressedTexSubImage2DError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0686 + * @tc.name testCompressedTexSubImage2D_0421 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D_0421', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexSubImage2D_0421 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, -0); + gl.compressedTexSubImage2D(-texture, -8, -256, -256, -512, -0x83F3, -gl.PIXEL_UNPACK_BUFFER, + view); + const compressedTexSubImage2DError = gl.getError(); + console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); + expect(compressedTexSubImage2DError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_687 + * @tc.name testReadPixels_422 + * @tc.desc Test readPixels. + */ + it('testReadPixels_422', 0, async function (done) { + //initContext(); + console.info('jsWebGL testReadPixels_422 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); + gl.readPixels(-0, 0, -1, -1, -1, gl.ONE_MINUS_SRC_ALPHA, view); + const readPixelsError = gl.getError(); + console.info("readPixelsError: " + readPixelsError); + expect(readPixelsError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0688 + * @tc.name testReadPixels_423 + * @tc.desc Test readPixels. + */ + it('testReadPixels_423', 0, async function (done) { + //initContext(); + console.info('jsWebGL testReadPixels_423 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); + gl.readPixels(0, 0, -1, -1, -1, gl.ONE_MINUS_SRC_ALPHA, view); + const readPixelsError = gl.getError(); + console.info("readPixelsError: " + readPixelsError); + expect(readPixelsError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0689 + * @tc.name testTexImage2D_0426 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_0426', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D_0426 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + gl.texImage2D(-gl.TEXTURE_2D, -0, -gl.RGB8, -512, -512, -0, -gl.RGB8, gl.UNSIGNED_BYTE, + view); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0690 + * @tc.name testTexImage2D_0427 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_0427', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D_0427 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + gl.texImage2D(-gl.TEXTURE_2D, -0, -gl.RGB8, -512, -512, -0, -gl.RGB8, gl.UNSIGNED_BYTE, + view); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0694 + * @tc.name testTexSubImage2D_01 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexSubImage2D test start ...66'); + console.info('jsWebGL testTexSubImage2D test start ...' + JSON.stringify(gl)); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, view); + const ttexSubImage2DError = gl.getError(); + console.info("ttexSubImage2DError: " + ttexSubImage2DError); + expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0695 + * @tc.name testTexSubImage2D_02 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexSubImage2D_02 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + gl.texSubImage2D(-gl.TEXTURE_2D, -gl.RED, 0, 0, -0, 512, -gl.RED, -gl.FLOAT, view); + const ttexSubImage2DError = gl.getError(); + console.info("ttexSubImage2DError: " + ttexSubImage2DError); + expect(ttexSubImage2DError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0699 + * @tc.name testBlitFramebuffer_01 + * @tc.desc Test blitFramebuffer. + */ + it('testBlitFramebuffer_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBlitFramebuffer_01 test start ...66'); + gl2.blitFramebuffer(-0, -0, -400, 1080, 0, -0, 400, 1080, -gl2.COLOR_BUFFER_BIT, -gl2 + .NEAREST); + const blitFramebufferError = gl.getError(); + console.info("blitFramebufferError: " + blitFramebufferError); + expect(blitFramebufferError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0700 + * @tc.name testBlitFramebuffer_02 + * @tc.desc Test blitFramebuffer. + */ + it('testBlitFramebuffer_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBlitFramebuffer_02 test start ...66'); + gl2.blitFramebuffer(-gl2.NEAREST, -0, -400, -gl2.NEAREST, -0, -0, 400, 1080, + -gl2.COLOR_BUFFER_BIT, -gl2.NEAREST); + const blitFramebufferError = gl.getError(); + console.info("blitFramebufferError: " + blitFramebufferError); + expect(blitFramebufferError).assertEqual(gl.INVALID_ENUM); + done(); + }) + }) +} \ No newline at end of file diff --git a/graphic/webGL/src/main/js/test/WebGL.test08.js b/graphic/webGL/src/main/js/test/WebGL.test08.js new file mode 100644 index 0000000000000000000000000000000000000000..f9e9003254118895ead05f5771c7dac240904c72 --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test08.js @@ -0,0 +1,2380 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl8() { + describe('webgl1Test_webgl8', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_0701 + * @tc.name testFramebufferTextureLayer_01 + * @tc.desc Test framebufferTextureLayer. + */ + it('testFramebufferTextureLayer_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testFramebufferTextureLayer_01 test start ...66'); + const shader = gl.createShader(gl.VERTEX_SHADER); + gl2.framebufferTextureLayer(-gl.FRAMEBUFFER, -gl.COLOR_ATTACHMENT0, shader, -0, -8) + const framebufferTextureLayerError = gl.getError(); + console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); + expect(framebufferTextureLayerError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0702 + * @tc.name testFramebufferTextureLayer_02 + * @tc.desc Test framebufferTextureLayer. + */ + it('testFramebufferTextureLayer_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testFramebufferTextureLayer_02 test start ...66'); + const texture = gl.createTexture(); + gl.bindTexture(gl2.TEXTURE_2D_ARRAY, texture); + gl2.texStorage3D(gl2.TEXTURE_2D_ARRAY, 1, gl2.RGBA8, 256, 256, 8); + gl.texParameteri(gl2.TEXTURE_CUBE_MAP, gl2.TEXTURE_MAG_FILTER, gl2.NEAREST); + const framebuffer = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + gl2.framebufferTextureLayer(gl.FRAMEBUFFER, gl2.COLOR_ATTACHMENT0, texture, 0, 8) + const framebufferTextureLayerError = gl.getError(); + console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); + expect(framebufferTextureLayerError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0703 + * @tc.name testInvalidateFramebuffer_01 + * @tc.desc Test invalidateFramebuffer. + */ + it('testInvalidateFramebuffer_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateFramebuffer_01 test start ...66'); + gl2.invalidateFramebuffer(-0, + [-0, -gl.COLOR_ATTACHMENT1]); + const invalidateFramebufferError = gl.getError(); + console.info("invalidateFramebufferError: " + invalidateFramebufferError); + expect(invalidateFramebufferError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0704 + * @tc.name testInvalidateFramebuffer_02 + * @tc.desc Test invalidateFramebuffer. + */ + it('testInvalidateFramebuffer_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateFramebuffer_02 test start ...66'); + gl2.invalidateFramebuffer(-gl.READ_FRAMEBUFFER, + [gl.COLOR_ATTACHMENT0, -gl.COLOR_ATTACHMENT1]); + const invalidateFramebufferError = gl.getError(); + console.info("invalidateFramebufferError: " + invalidateFramebufferError); + expect(invalidateFramebufferError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0705 + * @tc.name testInvalidateSubFramebuffer_01 + * @tc.desc Test invalidateSubFramebuffer. + */ + it('testInvalidateSubFramebuffer_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateSubFramebuffer_01 test start ...66'); + console.info('jsWebGL testInvalidateSubFramebuffer test start ...' + JSON.stringify(gl)); + gl2.invalidateSubFramebuffer(-gl.READ_FRAMEBUFFER, + [gl.COLOR_ATTACHMENT0, -gl.COLOR_ATTACHMENT1], + 0, 0, 256, 256); + const invalidateSubFramebufferError = gl.getError(); + console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); + expect(invalidateSubFramebufferError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0706 + * @tc.name testInvalidateSubFramebuffer_01 + * @tc.desc Test invalidateSubFramebuffer. + */ + it('testInvalidateSubFramebuffer_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateSubFramebuffer_02 test start ...66'); + console.info('jsWebGL testInvalidateSubFramebuffer test start ...' + JSON.stringify(gl)); + gl2.invalidateSubFramebuffer(-gl.READ_FRAMEBUFFER, + [-0, -gl.COLOR_ATTACHMENT1], + 0, -0, 256, -256); + const invalidateSubFramebufferError = gl.getError(); + console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); + expect(invalidateSubFramebufferError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0707 + * @tc.name testReadBuffer_01 + * @tc.desc Test readBuffer. + */ + it('testReadBuffer_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testReadBuffer_01 test start ...66'); + gl2.readBuffer(-gl.COLOR_ATTACHMENT0); + const readBufferError = gl.getError(); + console.info("readBufferError: " + readBufferError); + expect(readBufferError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0708 + * @tc.name testReadBuffer_02 + * @tc.desc Test readBuffer. + */ + it('testReadBuffer_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testReadBuffer_02 test start ...66'); + gl2.readBuffer(gl.INVALID_ENUM); + const readBufferError = gl.getError(); + console.info("readBufferError: " + readBufferError); + expect(readBufferError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0709 + * @tc.name testGetInternalformatParameter_02 + * @tc.desc Test getInternalformatParameter. + */ + it('testGetInternalformatParameter_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetInternalformatParameter_02 test start ...66'); + var samples = gl2.getInternalformatParameter(gl.RENDERBUFFER, gl2.RGBA8, gl.SAMPLES); + console.info("samples: " + samples); + const int32list = [-1, -1, -1]; + expect(samples.constructor == int32list.constructor).assertEqual(false); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0710 + * @tc.name testRenderbufferStorageMultisample_01 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); + gl2.renderbufferStorageMultisample(-gl.RENDERBUFFER, -4, -gl.RBGA4, -256, -256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0711 + * @tc.name testRenderbufferStorageMultisample_02 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); + gl2.renderbufferStorageMultisample(gl.ONE_MINUS_DST_COLOR, -0, -0, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0712 + * @tc.name testTexStorage2D_01 + * @tc.desc Test texStorage2D. + */ + it('testTexStorage2D_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexStorage2D_01 test start ...66'); + gl2.texStorage2D(-gl.TEXTURE_2D, -1, -gl.RGB8, -256, -256); + const texStorage2DError = gl.getError(); + console.info("texStorage2DError: " + texStorage2DError); + expect(texStorage2DError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0713 + * @tc.name testTexStorage2D_02 + * @tc.desc Test texStorage2D. + */ + it('testTexStorage2D_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexStorage2D_02 test start ...66'); + gl2.texStorage2D(-gl.SRC_ALPHA_SATURATE, -0, -gl.RGB8, 256, -256); + const texStorage2DError = gl.getError(); + console.info("texStorage2DError: " + texStorage2DError); + expect(texStorage2DError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0714 + * @tc.name testTransformFeedbackVaryings_01 + * @tc.desc Test transformFeedbackVaryings. + */ + it('testTransformFeedbackVaryings_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTransformFeedbackVaryings_01 test start ...66'); + const program = gl.createProgram(); + var transformFeedbackOutputs = ['-gl_Position', 'anotherOutput']; + gl2.transformFeedbackVaryings(program, transformFeedbackOutputs, -gl.INTERLEAVED_ATTRIBS); + const transformFeedbackVaryingsError = gl.getError(); + console.info("transformFeedbackVaryingsError: " + transformFeedbackVaryingsError); + expect(transformFeedbackVaryingsError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0715 + * @tc.name testTransformFeedbackVaryings_02 + * @tc.desc Test transformFeedbackVaryings. + */ + it('testTransformFeedbackVaryings_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTransformFeedbackVaryings_02 test start ...66'); + const program = gl.createProgram(); + var transformFeedbackOutputs = [-'gl_Position', -'anotherOutput']; + gl2.transformFeedbackVaryings(program, transformFeedbackOutputs, gl.ONE_MINUS_DST_COLOR); + const transformFeedbackVaryingsError = gl.getError(); + console.info("transformFeedbackVaryingsError: " + transformFeedbackVaryingsError); + expect(transformFeedbackVaryingsError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0716 + * @tc.name testGetTransformFeedbackVarying_01 + * @tc.desc Test getTransformFeedbackVarying. + */ + it('testGetTransformFeedbackVarying_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetTransformFeedbackVarying_01 test start ...66'); + const programObj = createProgram(gl); + var getTransformFeedbackVaryingobject = gl2.getTransformFeedbackVarying(-programObj, - + 0); + console.info("getTransformFeedbackVaryingobject: " + getTransformFeedbackVaryingobject); + const getTransformFeedbackVaryingError = gl.getError(); + console.info("getTransformFeedbackVaryingError: " + getTransformFeedbackVaryingError); + expect(getTransformFeedbackVaryingError).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetTransformFeedbackVarying has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0717 + * @tc.name testBindBufferBase_01 + * @tc.desc Test bindBufferBase. + */ + it('testBindBufferBase_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testBindBufferBase_01 test start ...66'); + let buffer = gl.createBuffer(); + gl2.bindBufferBase(-gl.TRANSFORM_FEEDBACK_BUFFER, -0, buffer); + const bindBufferBaseError = gl.getError(); + console.info("bindBufferBaseError: " + bindBufferBaseError); + expect(bindBufferBaseError).assertEqual(gl.INVALID_ENUM); + //deleteContext(); + done(); + } catch (e) { + console.log("bindBufferBaseError has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0718 + * @tc.name testBindBufferBase_02 + * @tc.desc Test bindBufferBase. + */ + it('testBindBufferBase_02', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testBindBufferBase_02 test start ...66'); + var programobject = gl.createProgram(); + gl2.bindBufferBase(-gl.SRC_ALPHA_SATURATE, -0, programobject); + const bindBufferBaseError = gl.getError(); + console.info("bindBufferBaseError: " + bindBufferBaseError); + expect(bindBufferBaseError).assertEqual(gl.INVALID_ENUM); + //deleteContext(); + done(); + } catch (e) { + console.log("bindBufferBaseError has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0719 + * @tc.name testGetTransformFeedbackVarying_02 + * @tc.desc Test getTransformFeedbackVarying. + */ + it('testGetTransformFeedbackVarying_02', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetTransformFeedbackVarying_02 test start ...66'); + const programObj = gl.createProgram(); + var getTransformFeedbackVaryingobject = gl2.getTransformFeedbackVarying(programObj, 0); + console.info("getTransformFeedbackVaryingobject: " + getTransformFeedbackVaryingobject); + const getTransformFeedbackVaryingError = gl.getError(); + console.info("getTransformFeedbackVaryingError: " + getTransformFeedbackVaryingError); + expect(getTransformFeedbackVaryingError).assertEqual(gl.INVALID_VALUE); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetTransformFeedbackVarying has failed for " + e) + expect(null).assertFail() + } + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0720 + * @tc.name bindBufferRange + * @tc.desc Test bindBufferRange. + */ + it('bindBufferRange', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL bindBufferRange test start ...66'); + const buffer = gl.createBuffer(); + gl2.bindBufferRange(gl.TRANSFORM_FEEDBACK_BUFFER, 1, buffer, 0, 4); + const bindBufferRangeError = gl.getError(); + console.info("bindBufferRangeError: " + bindBufferRangeError); + expect(bindBufferRangeError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("bindBufferRange has failed for " + e) + expect(null).assertFail() + } + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0721 + * @tc.name bindBufferRange_01 + * @tc.desc Test bindBufferRange. + */ + it('bindBufferRange_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL bindBufferRange_01 test start ...66'); + const buffer = gl.createBuffer(); + gl2.bindBufferRange(-gl.TRANSFORM_FEEDBACK_BUFFER, -0, buffer, -0, -4); + const bindBufferRangeError = gl.getError(); + console.info("bindBufferRangeError: " + bindBufferRangeError); + expect(bindBufferRangeError).assertEqual(gl.INVALID_VALUE); + //deleteContext(); + done(); + } catch (e) { + console.log("bindBufferRange has failed for " + e) + expect(null).assertFail() + } + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0722 + * @tc.name bindBufferRange_02 + * @tc.desc Test bindBufferRange. + */ + it('bindBufferRange_02', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL bindBufferRange_01 test start ...66'); + const buffer = gl.createBuffer(); + gl2.bindBufferRange(-gl.TRANSFORM_FEEDBACK_BUFFER, -1, buffer, -0, 4); + const bindBufferRangeError = gl.getError(); + console.info("bindBufferRangeError: " + bindBufferRangeError); + expect(bindBufferRangeError).assertEqual(gl.INVALID_ENUM); + //deleteContext(); + done(); + } catch (e) { + console.log("bindBufferRange has failed for " + e) + expect(null).assertFail() + } + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0723 + * @tc.name testIsShader_05 + * @tc.desc Test isShader. + */ + it('testIsShader_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsShader_05 test start ...66'); + var programobject = gl.createProgram(); + const isShader = gl.isShader(-0); + console.info("createShader --> isShader: " + isShader); + expect(isShader).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0724 + * @tc.name testLinkProgram_05 + * @tc.desc Test linkProgram. + */ + it('testLinkProgram_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testLinkProgram_05 test start ...66'); + const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + gl.linkProgram(fragmentShader); + const linkProgramError = gl.getError(); + console.info("linkProgramError: " + linkProgramError); + expect(linkProgramError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0725 + * @tc.name testPauseTransformFeedback_01 + * @tc.desc Test pauseTransformFeedback. + */ + it('testPauseTransformFeedback_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testPauseTransformFeedback_01 test start ...66'); + const transformFeedback = gl2.createTransformFeedback(); + gl2.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, transformFeedback); + gl2.beginTransformFeedback(gl2.TRIANGLES); + gl2.pauseTransformFeedback(); + const pauseTransformFeedbackError = gl.getError(); + console.info("pauseTransformFeedbackError: " + pauseTransformFeedbackError); + expect(pauseTransformFeedbackError == gl.INVALID_OPERATION).assertEqual(true); + //deleteContext(); + done(); + } catch (e) { + console.log("testPauseTransformFeedback_01 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0726 + * @tc.name testResumeTransformFeedback_01 + * @tc.desc Test resumeTransformFeedback. + */ + it('testResumeTransformFeedback_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testResumeTransformFeedback_01 test start ...66'); + gl2.resumeTransformFeedback(); + const resumeTransformFeedbackError = gl.getError(); + console.info("resumeTransformFeedbackError: " + resumeTransformFeedbackError); + expect(resumeTransformFeedbackError == gl.INVALID_OPERATION).assertEqual(true); + //deleteContext(); + done(); + } catch (e) { + console.log("testResumeTransformFeedback_01 has failed for " + e) + expect(null).assertFail() + } + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0727 + * @tc.name webgl_test_blendEquation2 + * @tc.desc Test blendEquation. + */ + it('webgl_test_blendEquation2', 0, async function (done) { + //initContext(); + console.info("webgltest into blendEquation"); + + gl.blendEquation(gl.FUNC_REVERSE_SUBTRACT); + + const blendEquationValue = gl.getParameter(gl.BLEND_EQUATION_RGB); + console.info("blendEquation --> getParameter: " + blendEquationValue); + expect(blendEquationValue).assertEqual(gl.FUNC_REVERSE_SUBTRACT); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0728 + * @tc.name webgl_test_activeTexture_2 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE2); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33986); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0729 + * @tc.name webgl_test_activeTexture_3 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE3); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33987); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0730 + * @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.INVALID_VALUE); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0731 + * @tc.name webgl_test_bindBuffer_2 + * @tc.desc Test bindBuffer. + */ + it('webgl_test_bindBuffer_2', 0, async function (done) { + //initContext(); + console.info("webgltest into bindBuffer"); + + var buffer = gl.createBuffer(); + + gl.bindBuffer(gl.ELEMENT_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_0732 + * @tc.name webgl_test_bindTexture_2 + * @tc.desc Test bindTexture. + */ + it('webgl_test_bindTexture_2', 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_CUBE_MAP, 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_0733 + * @tc.name webgl_test_blendEquation__2 + * @tc.desc Test blendEquation. + */ + it('webgl_test_blendEquation__2', 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(32774); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0734 + * @tc.name webgl_test_blendEquation_3 + * @tc.desc Test blendEquation. + */ + it('webgl_test_blendEquation_3', 0, async function (done) { + //initContext(); + console.info("webgltest into blendEquation"); + + gl.blendEquation(gl.FUNC_SUBTRACT); + + const blendEquationValue = gl.getParameter(gl.BLEND_EQUATION_RGB); + console.info("blendEquation --> getParameter: " + blendEquationValue); + expect(blendEquationValue).assertEqual(gl.FUNC_SUBTRACT); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0735 + * @tc.name webgl_test_blendEquationSeparate_2 + * @tc.desc Test blendEquationSeparate. + */ + it('webgl_test_blendEquationSeparate_2', 0, async function (done) { + //initContext(); + console.info("webgltest into blendEquationSeparate"); + gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_REVERSE_SUBTRACT); + + const blendEquationSeparateValue = gl.getParameter(gl.BLEND_EQUATION_RGB); + console.info("blendEquationSeparate --> getParameter: " + blendEquationSeparateValue); + expect(blendEquationSeparateValue).assertEqual(gl.FUNC_ADD); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0736 + * @tc.name webgl_test_blendEquationSeparate_3 + * @tc.desc Test blendEquationSeparate. + */ + it('webgl_test_blendEquationSeparate_3', 0, async function (done) { + //initContext(); + console.info("webgltest into blendEquationSeparate"); + gl.blendEquationSeparate(gl.FUNC_SUBTRACT, gl.FUNC_REVERSE_SUBTRACT); + + const blendEquationSeparateValue = gl.getParameter(gl.BLEND_EQUATION_RGB); + console.info("blendEquationSeparate --> getParameter: " + blendEquationSeparateValue); + expect(blendEquationSeparateValue).assertEqual(gl.FUNC_SUBTRACT); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0737 + * @tc.name webgl_test_blendFunc_2 + * @tc.desc Test blendFunc. + */ + it('webgl_test_blendFunc_2', 0, async function (done) { + //initContext(); + console.info("webgltest into blendFunc"); + + gl.enable(gl.BLEND); + + gl.blendFunc(gl.ZERO, gl.ONE); + + const blendFuncValue = gl.getParameter(gl.BLEND_SRC_RGB); + console.info("blendFunc --> getParameter: " + blendFuncValue); + expect(blendFuncValue).assertEqual(gl.ZERO); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0738 + * @tc.name webgl_test_blendFunc_3 + * @tc.desc Test blendFunc. + */ + it('webgl_test_blendFunc_3', 0, async function (done) { + //initContext(); + console.info("webgltest into blendFunc"); + + gl.enable(gl.BLEND); + + gl.blendFunc(gl.SRC_ALPHA, gl.DST_ALPHA); + + const blendFuncValue = gl.getParameter(gl.BLEND_SRC_RGB); + console.info("blendFunc --> getParameter: " + blendFuncValue); + expect(blendFuncValue).assertEqual(gl.SRC_ALPHA); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0739 + * @tc.name webgl_test_blendFuncSeparate_2 + * @tc.desc Test blendFuncSeparate. + */ + it('webgl_test_blendFuncSeparate_2', 0, async function (done) { + //initContext(); + console.info("webgltest into blendFuncSeparate"); + + gl.enable(gl.BLEND); + + gl.blendFuncSeparate(gl.DST_ALPHA, gl.CONSTANT_COLOR, gl.CONSTANT_ALPHA, gl + .ONE_MINUS_CONSTANT_ALPHA); + + const blendFuncSeparateParameter = gl.getParameter(gl.BLEND_SRC_RGB) + console.info("blendFuncSeparate --> getParameter: " + blendFuncSeparateParameter); + expect(blendFuncSeparateParameter).assertEqual(gl.DST_ALPHA); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0740 + * @tc.name webgl_test_blendFuncSeparate_3 + * @tc.desc Test blendFuncSeparate. + */ + it('webgl_test_blendFuncSeparate_3', 0, async function (done) { + //initContext(); + console.info("webgltest into blendFuncSeparate"); + + gl.enable(gl.BLEND); + + gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.DST_ALPHA, gl + .ONE_MINUS_DST_ALPHA); + + const blendFuncSeparateParameter = gl.getParameter(gl.BLEND_SRC_RGB) + console.info("blendFuncSeparate --> getParameter: " + blendFuncSeparateParameter); + expect(blendFuncSeparateParameter).assertEqual(gl.SRC_ALPHA); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0741 + * @tc.name webgl_test_checkFramebufferStatus22 + * @tc.desc Test checkFramebufferStatus. + */ + it('webgl_test_checkFramebufferStatus22', 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_0742 + * @tc.name webgl_test_clear_2 + * @tc.desc Test clear. + */ + it('webgl_test_clear_2', 0, async function (done) { + //initContext(); + console.info("webgltest into clear"); + gl.clear(gl.DEPTH_BUFFER_BIT); + var float32Array = new Float32Array([0, 0, 0, 0]); + const clearParameter = gl.getParameter(gl.DEPTH_CLEAR_VALUE); + console.info("webgltest clear getParameter: " + clearParameter); + expect(typeof (clearParameter)).assertEqual('number'); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0743 + * @tc.name webgl_test_clear_3 + * @tc.desc Test clear. + */ + it('webgl_test_clear_3', 0, async function (done) { + //initContext(); + console.info("webgltest into clear"); + gl.clear(gl.STENCIL_BUFFER_BIT); + var float32Array = new Float32Array([0, 0, 0, 0]); + const clearParameter = gl.getParameter(gl.STENCIL_CLEAR_VALUE); + console.info("webgltest clear getParameter: " + clearParameter); + expect(typeof (clearParameter)).assertEqual('number'); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0744 + * @tc.name webgl_test_clearColor_2 + * @tc.desc Test clearColor. + */ + it('webgl_test_clearColor_2', 0, async function (done) { + //initContext(); + console.info("webgltest into clearColor"); + gl.clearColor(1, 3, 0.5, 3); + + const clearColorParameter = gl.getParameter(gl.COLOR_CLEAR_VALUE); + + var float32ArrayValue = new Float32Array([1, 3, 0.5, 3]); + + console.info("webgltest clearColor: " + clearColorParameter); + expect(clearColorParameter.toString()).assertEqual(float32ArrayValue.toString()); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0745 + * @tc.name webgl_test_copyTexImage2D_2 + * @tc.desc Test copyTexImage2D. + */ + it('webgl_test_copyTexImage2D_2', 0, async function (done) { + //initContext(); + console.info("webgltest into copyTexImage2D"); + gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.ALPHA, 0, 0, 512, 512, 0); + let errorCode = gl.getError(); + console.info("webgltest copyTexImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0746 + * @tc.name webgl_test_copyTexImage2D_3 + * @tc.desc Test copyTexImage2D. + */ + it('webgl_test_copyTexImage2D_3', 0, async function (done) { + //initContext(); + console.info("webgltest into copyTexImage2D"); + gl.copyTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.LUMINANCE, 0, 0, 512, 512, 0); + let errorCode = gl.getError(); + console.info("webgltest copyTexImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0747 + * @tc.name webgl_test_copyTexSubImage2D_2 + * @tc.desc Test copyTexSubImage2D. + */ + it('webgl_test_copyTexSubImage2D_2', 0, async function (done) { + //initContext(); + console.info("webgltest into copyTexSubImage2D"); + + gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 0, 0, 16, 16); + let errorCode = gl.getError(); + console.info("webgltest copyTexSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0748 + * @tc.name webgl_test_copyTexSubImage2D_3 + * @tc.desc Test copyTexSubImage2D. + */ + it('webgl_test_copyTexSubImage2D_3', 0, async function (done) { + //initContext(); + console.info("webgltest into copyTexSubImage2D"); + + gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 0, 0, 16, 16); + let errorCode = gl.getError(); + console.info("webgltest copyTexSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0749 + * @tc.name webgl_test_copyTexSubImage2D_4 + * @tc.desc Test copyTexSubImage2D. + */ + it('webgl_test_copyTexSubImage2D_4', 0, async function (done) { + //initContext(); + console.info("webgltest into copyTexSubImage2D"); + + gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 0, 0, 16, 16); + let errorCode = gl.getError(); + console.info("webgltest copyTexSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0750 + * @tc.name webgl_test_createShader_2 + * @tc.desc Test createShader. + */ + it('webgl_test_createShader_2', 0, async function (done) { + //initContext(); + console.info("webgltest into createShader"); + + const shader = gl.createShader(gl.FRAGMENT_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_0751 + * @tc.name webgl_test_disable_22 + * @tc.desc Test disable. + */ + it('webgl_test_disable_22', 0, async function (done) { + //initContext(); + console.info("webgltest into disable"); + gl.enable(gl.BLEND); + const isEnabled2 = gl.isEnabled(gl.BLEND); + // true + console.info("webgltest disable isEnabled2: " + isEnabled2); + expect(isEnabled2).assertEqual(true); + + gl.disable(gl.BLEND); + // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: + const isEnabled = gl.isEnabled(gl.BLEND); + // false + console.info("webgltest disable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0752 + * @tc.name webgl_test_disable_23 + * @tc.desc Test disable. + */ + it('webgl_test_disable_23', 0, async function (done) { + //initContext(); + console.info("webgltest into disable"); + gl.enable(gl.BLEND); + const isEnabled2 = gl.isEnabled(gl.BLEND); + // true + console.info("webgltest disable isEnabled2: " + isEnabled2); + expect(isEnabled2).assertEqual(true); + + gl.disable(gl.BLEND); + // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: + const isEnabled = gl.isEnabled(gl.BLEND); + // false + console.info("webgltest disable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0753 + * @tc.name webgl_test_disable_24 + * @tc.desc Test disable. + */ + it('webgl_test_disable_24', 0, async function (done) { + //initContext(); + console.info("webgltest into disable"); + gl.enable(gl.DEPTH_TEST); + const isEnabled2 = gl.isEnabled(gl.DEPTH_TEST); + // true + console.info("webgltest disable isEnabled2: " + isEnabled2); + expect(isEnabled2).assertEqual(true); + + gl.disable(gl.DEPTH_TEST); + // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: + const isEnabled = gl.isEnabled(gl.DEPTH_TEST); + // false + console.info("webgltest disable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0754 + * @tc.name webgl_test_disable_25 + * @tc.desc Test disable. + */ + it('webgl_test_disable_25', 0, async function (done) { + //initContext(); + console.info("webgltest into disable"); + gl.enable(gl.POLYGON_OFFSET_FILL); + const isEnabled2 = gl.isEnabled(gl.POLYGON_OFFSET_FILL); + // true + console.info("webgltest disable isEnabled2: " + isEnabled2); + expect(isEnabled2).assertEqual(true); + + gl.disable(gl.POLYGON_OFFSET_FILL); + // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: + const isEnabled = gl.isEnabled(gl.POLYGON_OFFSET_FILL); + // false + console.info("webgltest disable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0755 + * @tc.name webgl_test_disable_26 + * @tc.desc Test disable. + */ + it('webgl_test_disable_26', 0, async function (done) { + //initContext(); + console.info("webgltest into disable"); + gl.enable(gl.SCISSOR_TEST); + const isEnabled2 = gl.isEnabled(gl.SCISSOR_TEST); + // true + console.info("webgltest disable isEnabled2: " + isEnabled2); + expect(isEnabled2).assertEqual(true); + + gl.disable(gl.SCISSOR_TEST); + // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: + const isEnabled = gl.isEnabled(gl.SCISSOR_TEST); + // false + console.info("webgltest disable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(false); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0756 + * @tc.name webgl_test_disableVertexAttribArray_2 + * @tc.desc Test disableVertexAttribArray. + */ + it('webgl_test_disableVertexAttribArray_2', 0, async function (done) { + //initContext(); + console.info("webgltest into disableVertexAttribArray"); + gl.disableVertexAttribArray(-1); + let errorCode = gl.getError(); + console.info("webgltest disableVertexAttribArray getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_VALUE); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0757 + * @tc.name webgl_test_drawArrays2 + * @tc.desc Test drawArrays. + */ + it('webgl_test_drawArrays2', 0, async function (done) { + //initContext(); + console.info("webgltest into drawArrays"); + + gl.drawArrays(gl.LINE_STRIP, 0, 8); + let errorCode = gl.getError(); + console.info("webgltest drawArrays getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0758 + * @tc.name webgl_test_drawArrays3 + * @tc.desc Test drawArrays. + */ + it('webgl_test_drawArrays3', 0, async function (done) { + //initContext(); + console.info("webgltest into drawArrays"); + + gl.drawArrays(gl.LINE_LOOP, 0, 8); + let errorCode = gl.getError(); + console.info("webgltest drawArrays getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0759 + * @tc.name webgl_test_drawArrays4 + * @tc.desc Test drawArrays. + */ + it('webgl_test_drawArrays4', 0, async function (done) { + //initContext(); + console.info("webgltest into drawArrays"); + + gl.drawArrays(gl.LINES, 0, 8); + let errorCode = gl.getError(); + console.info("webgltest drawArrays getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0760 + * @tc.name webgl_test_drawArrays5 + * @tc.desc Test drawArrays. + */ + it('webgl_test_drawArrays5', 0, async function (done) { + //initContext(); + console.info("webgltest into drawArrays"); + + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 8); + let errorCode = gl.getError(); + console.info("webgltest drawArrays getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0761 + * @tc.name webgl_test_drawArrays6 + * @tc.desc Test drawArrays. + */ + it('webgl_test_drawArrays6', 0, async function (done) { + //initContext(); + console.info("webgltest into drawArrays"); + + gl.drawArrays(gl.TRIANGLE_FAN, 0, 8); + let errorCode = gl.getError(); + console.info("webgltest drawArrays getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0762 + * @tc.name webgl_test_drawArrays7 + * @tc.desc Test drawArrays. + */ + it('webgl_test_drawArrays7', 0, async function (done) { + //initContext(); + console.info("webgltest into drawArrays"); + + gl.drawArrays(gl.TRIANGLES, 0, 8); + let errorCode = gl.getError(); + console.info("webgltest drawArrays getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0763 + * @tc.name webgl_test_drawElements22 + * @tc.desc Test drawElements. + */ + it('webgl_test_drawElements22', 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 viewPortParameter = gl.getParameter(gl.MAX_VIEWPORT_DIMS); + console.log('viewPortParameter: ' + viewPortParameter); + + const isContextLostValue = gl.isContextLost(); + console.info("isContextLostValue: " + isContextLostValue); + + // 指定清空的颜色 + gl.clearColor(0.0, 0.0, 0.0, 1.0); + + // 清空 + // COLOR_BUFFER_BIT 0x00004000 + gl.clear(gl.COLOR_BUFFER_BIT); + + console.info("indices.length: " + indices.length) + gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_SHORT, 0); + + let errorCode = gl.getError(); + console.info("webgltest drawArrays getError: " + errorCode); + expect(errorCode).assertEqual(1280); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0764 + * @tc.name webgl_test_drawElements23 + * @tc.desc Test drawElements. + */ + it('webgl_test_drawElements23', 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 viewPortParameter = gl.getParameter(gl.MAX_VIEWPORT_DIMS); + console.log('viewPortParameter: ' + viewPortParameter); + + const isContextLostValue = gl.isContextLost(); + console.info("isContextLostValue: " + isContextLostValue); + + // 指定清空的颜色 + gl.clearColor(0.0, 0.0, 0.0, 1.0); + + // 清空 + // COLOR_BUFFER_BIT 0x00004000 + gl.clear(gl.COLOR_BUFFER_BIT); + + console.info("indices.length: " + indices.length) + gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_SHORT, 0); + + let errorCode = gl.getError(); + console.info("webgltest drawArrays getError: " + errorCode); + expect(errorCode).assertEqual(1280); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0765 + * @tc.name webgl_test_drawElements24 + * @tc.desc Test drawElements. + */ + it('webgl_test_drawElements24', 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 viewPortParameter = gl.getParameter(gl.MAX_VIEWPORT_DIMS); + console.log('viewPortParameter: ' + viewPortParameter); + + const isContextLostValue = gl.isContextLost(); + console.info("isContextLostValue: " + isContextLostValue); + + // 指定清空的颜色 + gl.clearColor(0.0, 0.0, 0.0, 1.0); + + // 清空 + // COLOR_BUFFER_BIT 0x00004000 + gl.clear(gl.COLOR_BUFFER_BIT); + + console.info("indices.length: " + indices.length) + gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_SHORT, 0); + + let errorCode = gl.getError(); + console.info("webgltest drawArrays getError: " + errorCode); + expect(errorCode).assertEqual(1280); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0766 + * @tc.name webgl_test_enable + * @tc.desc Test enable. + */ + it('webgl_test_enable', 0, async function (done) { + //initContext(); + console.info("webgltest into enable"); + + gl.enable(gl.BLEND); + + const isEnabled = gl.isEnabled(gl.BLEND); + // true + console.info("webgltest enable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(true); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0767 + * @tc.name webgl_test_enable22 + * @tc.desc Test enable. + */ + it('webgl_test_enable22', 0, async function (done) { + //initContext(); + console.info("webgltest into enable"); + + gl.enable(gl.CULL_FACE); + + const isEnabled = gl.isEnabled(gl.CULL_FACE); + // true + console.info("webgltest enable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(true); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0768 + * @tc.name webgl_test_enable23 + * @tc.desc Test enable. + */ + it('webgl_test_enable23', 0, async function (done) { + //initContext(); + console.info("webgltest into enable"); + + gl.enable(gl.DEPTH_TEST); + + const isEnabled = gl.isEnabled(gl.DEPTH_TEST); + // true + console.info("webgltest enable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(true); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0769 + * @tc.name webgl_test_enable24 + * @tc.desc Test enable. + */ + it('webgl_test_enable24', 0, async function (done) { + //initContext(); + console.info("webgltest into enable"); + + gl.enable(gl.DITHER); + + const isEnabled = gl.isEnabled(gl.DITHER); + // true + console.info("webgltest enable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(true); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0770 + * @tc.name webgl_test_enable25 + * @tc.desc Test enable. + */ + it('webgl_test_enable25', 0, async function (done) { + //initContext(); + console.info("webgltest into enable"); + + gl.enable(gl.POLYGON_OFFSET_FILL); + + const isEnabled = gl.isEnabled(gl.POLYGON_OFFSET_FILL); + // true + console.info("webgltest enable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(true); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0771 + * @tc.name webgl_test_enable26 + * @tc.desc Test enable. + */ + it('webgl_test_enable26', 0, async function (done) { + //initContext(); + console.info("webgltest into enable"); + + gl.enable(gl.SAMPLE_ALPHA_TO_COVERAGE); + + const isEnabled = gl.isEnabled(gl.SAMPLE_ALPHA_TO_COVERAGE); + // true + console.info("webgltest enable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(true); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0772 + * @tc.name webgl_test_enable27 + * @tc.desc Test enable. + */ + it('webgl_test_enable27', 0, async function (done) { + //initContext(); + console.info("webgltest into enable"); + + gl.enable(gl.SAMPLE_COVERAGE); + + const isEnabled = gl.isEnabled(gl.SAMPLE_COVERAGE); + // true + console.info("webgltest enable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(true); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0773 + * @tc.name webgl_test_enable28 + * @tc.desc Test enable. + */ + it('webgl_test_enable28', 0, async function (done) { + //initContext(); + console.info("webgltest into enable"); + + gl.enable(gl.SCISSOR_TEST); + + const isEnabled = gl.isEnabled(gl.SCISSOR_TEST); + // true + console.info("webgltest enable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(true); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0774 + * @tc.name webgl_test_enable29 + * @tc.desc Test enable. + */ + it('webgl_test_enable29', 0, async function (done) { + //initContext(); + console.info("webgltest into enable"); + + gl.enable(gl.STENCIL_TEST); + + const isEnabled = gl.isEnabled(gl.STENCIL_TEST); + // true + console.info("webgltest enable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(true); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0775 + * @tc.name webgl_test_framebufferRenderbuffer22 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer22', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0776 + * @tc.name webgl_test_framebufferRenderbuffer23 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer23', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0777 + * @tc.name webgl_test_framebufferRenderbuffer24 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer24', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl + .RENDERBUFFER, renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0778 + * @tc.name webgl_test_framebufferRenderbuffer25 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer25', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.DRAW_FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0779 + * @tc.name webgl_test_framebufferTexture2D22 + * @tc.desc Test framebufferTexture2D. + */ + it('webgl_test_framebufferTexture2D22', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferTexture2D"); + const texture = gl.createTexture(); + gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, texture, + 0); + + let errorCode = gl.getError(); + console.info("webgltest framebufferTexture2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0780 + * @tc.name webgl_test_framebufferTexture2D23 + * @tc.desc Test framebufferTexture2D. + */ + it('webgl_test_framebufferTexture2D23', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferTexture2D"); + const texture = gl.createTexture(); + gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.TEXTURE_2D, texture, + 0); + + let errorCode = gl.getError(); + console.info("webgltest framebufferTexture2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0781 + * @tc.name webgl_test_framebufferTexture2D24 + * @tc.desc Test framebufferTexture2D. + */ + it('webgl_test_framebufferTexture2D24', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferTexture2D"); + const texture = gl.createTexture(); + gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl + .TEXTURE_CUBE_MAP_POSITIVE_X, texture, 0); + + let errorCode = gl.getError(); + console.info("webgltest framebufferTexture2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0782 + * @tc.name webgl_test_framebufferTexture2D25 + * @tc.desc Test framebufferTexture2D. + */ + it('webgl_test_framebufferTexture2D25', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferTexture2D"); + const texture = gl.createTexture(); + gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl + .TEXTURE_CUBE_MAP_POSITIVE_Y, texture, 0); + + let errorCode = gl.getError(); + console.info("webgltest framebufferTexture2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0783 + * @tc.name webgl_test_framebufferTexture2D26 + * @tc.desc Test framebufferTexture2D. + */ + it('webgl_test_framebufferTexture2D26', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferTexture2D"); + const texture = gl.createTexture(); + gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl + .TEXTURE_CUBE_MAP_POSITIVE_Z, texture, 0); + + let errorCode = gl.getError(); + console.info("webgltest framebufferTexture2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0784 + * @tc.name webgl_test_framebufferTexture2D25 + * @tc.desc Test framebufferTexture2D. + */ + it('webgl_test_framebufferTexture2D25', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferTexture2D"); + const texture = gl.createTexture(); + gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, + 0); + + let errorCode = gl.getError(); + console.info("webgltest framebufferTexture2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0785 + * @tc.name webgl_test_drawBuffers22 + * @tc.desc Test drawBuffers. + */ + it('webgl_test_drawBuffers22', 0, async function (done) { + //initContext(); + console.info("webgltest into drawBuffers"); + + gl2.drawBuffers([gl2.BACK, gl2.COLOR_ATTACHMENT2]); + + let errorCode = gl.getError(); + console.info("webgltest drawBuffers getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0786 + * @tc.name webgl_test_drawBuffers23 + * @tc.desc Test drawBuffers. + */ + it('webgl_test_drawBuffers23', 0, async function (done) { + //initContext(); + console.info("webgltest into drawBuffers"); + + gl2.drawBuffers([gl2.NONE, gl2.COLOR_ATTACHMENT3]); + + let errorCode = gl.getError(); + console.info("webgltest drawBuffers getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0787 + * @tc.name webgl_test_drawBuffers24 + * @tc.desc Test drawBuffers. + */ + it('webgl_test_drawBuffers24', 0, async function (done) { + //initContext(); + console.info("webgltest into drawBuffers"); + + gl2.drawBuffers([gl2.BACK, gl2.COLOR_ATTACHMENT4]); + + let errorCode = gl.getError(); + console.info("webgltest drawBuffers getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0788 + * @tc.name webgl_test_drawBuffers25 + * @tc.desc Test drawBuffers. + */ + it('webgl_test_drawBuffers25', 0, async function (done) { + //initContext(); + console.info("webgltest into drawBuffers"); + + gl2.drawBuffers([gl2.NONE, gl2.COLOR_ATTACHMENT5]); + + let errorCode = gl.getError(); + console.info("webgltest drawBuffers getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0789 + * @tc.name webgl_test_drawBuffers26 + * @tc.desc Test drawBuffers. + */ + it('webgl_test_drawBuffers26', 0, async function (done) { + //initContext(); + console.info("webgltest into drawBuffers"); + + gl2.drawBuffers([gl2.BACK, gl2.COLOR_ATTACHMENT6]); + + let errorCode = gl.getError(); + console.info("webgltest drawBuffers getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0790 + * @tc.name webgl_test_clearBufferfv22 + * @tc.desc Test clearBufferfv. + */ + it('webgl_test_clearBufferfv22', 0, async function (done) { + //initContext(); + console.info("webgltest into clearBufferfv"); + + gl2.clearBufferfv(gl.DEPTH, 0, [0.0, 0.0, 0.0, 0.0]); + + let errorCode = gl.getError(); + console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0791 + * @tc.name webgl_test_clearBufferfv_22 + * @tc.desc Test clearBufferfv. + */ + it('webgl_test_clearBufferfv_22', 0, async function (done) { + //initContext(); + console.info("webgltest into clearBufferfv"); + + gl2.clearBufferfv(gl.STENCIL, 0, [0.0, 0.0, 0.0, 0.0]); + + let errorCode = gl.getError(); + console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0792 + * @tc.name webgl_test_clearBufferfv23 + * @tc.desc Test clearBufferfv. + */ + it('webgl_test_clearBufferfv23', 0, async function (done) { + //initContext(); + console.info("webgltest into clearBufferfv"); + + gl2.clearBufferfv(gl.DEPTH_STENCIL, 0, [0.0, 0.0, 0.0, 0.0]); + + let errorCode = gl.getError(); + console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_ENUM); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0793 + * @tc.name webgl_test_clearBufferiv22 + * @tc.desc Test clearBufferiv. + */ + it('webgl_test_clearBufferiv22', 0, async function (done) { + //initContext(); + console.info("webgltest into clearBufferiv"); + + gl2.clearBufferiv(gl.DEPTH, 0, new Int32Array([0, 1, 0, 0.5])); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0794 + * @tc.name webgl_test_clearBufferiv23 + * @tc.desc Test clearBufferiv. + */ + it('webgl_test_clearBufferiv23', 0, async function (done) { + //initContext(); + console.info("webgltest into clearBufferiv"); + + gl2.clearBufferiv(gl.STENCIL, 0, new Int32Array([0, 1, 0, 0.5])); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0795 + * @tc.name webgl_test_clearBufferiv24 + * @tc.desc Test clearBufferiv. + */ + it('webgl_test_clearBufferiv24', 0, async function (done) { + //initContext(); + console.info("webgltest into clearBufferiv"); + + gl2.clearBufferiv(gl.DEPTH_STENCIL, 0, new Int32Array([0, 1, 0, 0.5])); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0796 + * @tc.name webgl_test_clearBufferuiv23 + * @tc.desc Test clearBufferuiv. + */ + it('webgl_test_clearBufferuiv23', 0, async function (done) { + //initContext(); + console.info("webgltest into clearBufferuiv"); + + gl2.clearBufferuiv(gl.DEPTH, 0, new Uint32Array([0, 1, 0, 0])); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferuiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0797 + * @tc.name webgl_test_clearBufferuiv24 + * @tc.desc Test clearBufferuiv. + */ + it('webgl_test_clearBufferuiv24', 0, async function (done) { + //initContext(); + console.info("webgltest into clearBufferuiv"); + + gl2.clearBufferuiv(gl.STENCIL, 0, new Uint32Array([0, 1, 0, 0])); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferuiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0798 + * @tc.name webgl_test_clearBufferuiv25 + * @tc.desc Test clearBufferuiv. + */ + it('webgl_test_clearBufferuiv25', 0, async function (done) { + //initContext(); + console.info("webgltest into clearBufferuiv"); + + gl2.clearBufferuiv(gl.DEPTH_STENCIL, 0, new Uint32Array([0, 1, 0, 0])); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferuiv getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0799 + * @tc.name webgl_test_clearBufferfi22 + * @tc.desc Test clearBufferfi. + */ + it('webgl_test_clearBufferfi22', 0, async function (done) { + //initContext(); + console.info("webgltest into clearBufferfi"); + + gl2.clearBufferfi(gl.DEPTH, 0, 1.0, 0); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferfi getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0800 + * @tc.name webgl_test_clearBufferfi23 + * @tc.desc Test clearBufferfi. + */ + it('webgl_test_clearBufferfi23', 0, async function (done) { + //initContext(); + console.info("webgltest into clearBufferfi"); + + gl2.clearBufferfi(gl.STENCIL, 0, 1.0, 0); + + let errorCode = gl.getError(); + console.info("webgltest clearBufferfi getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + }) +} \ No newline at end of file diff --git a/graphic/webGL/src/main/js/test/WebGL.test09.js b/graphic/webGL/src/main/js/test/WebGL.test09.js new file mode 100644 index 0000000000000000000000000000000000000000..697f511029ee89c39da7f9d33af573f0821ccdc8 --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test09.js @@ -0,0 +1,2056 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl9() { + describe('webgl1Test_webgl9', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_0802 + * @tc.name webgl_test_beginQuery22 + * @tc.desc Test beginQuery. + */ + it('webgl_test_beginQuery22', 0, async function (done) { + //initContext(); + console.info("webgltest into beginQuery"); + + var query = gl2.createQuery(); + gl2.beginQuery(gl2.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, query); + + const currentQuery = gl2.getQuery(gl2.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl2 + .CURRENT_QUERY); + const isQuery1 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery isQuery1: " + isQuery1); + expect(isQuery1).assertEqual(true); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0805 + * @tc.name webgl_test_endQuery24 + * @tc.desc Test endQuery. + */ + it('webgl_test_endQuery24', 0, async function (done) { + //initContext(); + console.info("webgltest into endQuery"); + + var query = gl2.createQuery(); + gl2.beginQuery(gl2.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, query); + + const currentQuery = gl2.getQuery(gl2.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl2 + .CURRENT_QUERY); + const isQuery1 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery isQuery1: " + isQuery1); + expect(isQuery1).assertEqual(true); + + gl2.endQuery(0x8C2F); + + const isQuery2 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery isQuery2: " + isQuery2); + expect(isQuery2).assertEqual(true); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0807 + * @tc.name webgl_test_getQuery24 + * @tc.desc Test endQuery. + */ + it('webgl_test_getQuery24', 0, async function (done) { + //initContext(); + console.info("webgltest into endQuery"); + + var query = gl2.createQuery(); + gl2.beginQuery(gl2.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, query); + + const currentQuery = gl2.getQuery(gl2.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl2 + .CURRENT_QUERY); + const isQuery1 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery isQuery1: " + isQuery1); + expect(isQuery1).assertEqual(true); + + gl2.endQuery(0x8C2F); + + const isQuery2 = gl2.isQuery(currentQuery); + console.info("webgltest createQuery isQuery2: " + isQuery2); + expect(isQuery2).assertEqual(true); + + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0808 + * @tc.name webgl_test_bindSampler23 + * @tc.desc Test bindSampler. + */ + it('webgl_test_bindSampler23', 0, async function (done) { + //initContext(); + console.info("webgltest into bindSampler"); + const sampler = gl2.createSampler(); + const isSampler1 = gl2.isSampler(sampler); + console.info("webgltest createSampler isSampler1: " + isSampler1); + expect(isSampler1).assertEqual(true); + + gl2.bindSampler(-1, sampler); + const isSampler2 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler isSampler2: " + isSampler2); + expect(isSampler2).assertEqual(true); + + gl2.deleteSampler(sampler); + const isSampler3 = gl2.isSampler(sampler); + console.info("webgltest createSampler bindSampler deleteSampler isSampler3: " + isSampler3); + expect(isSampler3).assertEqual(false); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0809 + * @tc.name webgl_test_samplerParameterf24 + * @tc.desc Test samplerParameterf. + */ + it('webgl_test_samplerParameterf24', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameterf"); + + let sampler = gl2.createSampler(); + // gl2.bindSampler(0, sampler); + gl2.samplerParameterf(sampler, gl.TEXTURE_COMPARE_FUNC, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameterf getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0810 + * @tc.name webgl_test_samplerParameterf25 + * @tc.desc Test samplerParameterf. + */ + it('webgl_test_samplerParameterf25', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameterf"); + + let sampler = gl2.createSampler(); + // gl2.bindSampler(0, sampler); + gl2.samplerParameterf(sampler, gl.TEXTURE_COMPARE_MODE, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameterf getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0811 + * @tc.name webgl_test_samplerParameterf26 + * @tc.desc Test samplerParameterf. + */ + it('webgl_test_samplerParameterf26', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameterf"); + + let sampler = gl2.createSampler(); + // gl2.bindSampler(0, sampler); + gl2.samplerParameterf(sampler, gl.TEXTURE_MAX_LOD, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameterf getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0812 + * @tc.name webgl_test_samplerParameterf27 + * @tc.desc Test samplerParameterf. + */ + it('webgl_test_samplerParameterf27', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameterf"); + + let sampler = gl2.createSampler(); + // gl2.bindSampler(0, sampler); + gl2.samplerParameterf(sampler, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameterf getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0813 + * @tc.name webgl_test_samplerParameterf28 + * @tc.desc Test samplerParameterf. + */ + it('webgl_test_samplerParameterf28', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameterf"); + + let sampler = gl2.createSampler(); + // gl2.bindSampler(0, sampler); + gl2.samplerParameterf(sampler, gl.TEXTURE_MIN_LOD, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameterf getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0814 + * @tc.name webgl_test_samplerParameterf29 + * @tc.desc Test samplerParameterf. + */ + it('webgl_test_samplerParameterf29', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameterf"); + + let sampler = gl2.createSampler(); + // gl2.bindSampler(0, sampler); + gl2.samplerParameterf(sampler, gl.TEXTURE_WRAP_R, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameterf getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0815 + * @tc.name webgl_test_samplerParameterf30 + * @tc.desc Test samplerParameterf. + */ + it('webgl_test_samplerParameterf30', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameterf"); + + let sampler = gl2.createSampler(); + // gl2.bindSampler(0, sampler); + gl2.samplerParameterf(sampler, gl.TEXTURE_WRAP_S, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameterf getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_ENUM); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0816 + * @tc.name webgl_test_samplerParameterf31 + * @tc.desc Test samplerParameterf. + */ + it('webgl_test_samplerParameterf31', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameterf"); + + let sampler = gl2.createSampler(); + // gl2.bindSampler(0, sampler); + gl2.samplerParameterf(sampler, gl.TEXTURE_WRAP_T, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameterf getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_ENUM); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0817 + * @tc.name webgl_test_samplerParameteri24 + * @tc.desc Test samplerParameteri. + */ + it('webgl_test_samplerParameteri24', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameteri"); + let sampler = gl2.createSampler(); + gl2.samplerParameteri(sampler, gl.TEXTURE_COMPARE_FUNC, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameteri getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0818 + * @tc.name webgl_test_samplerParameteri25 + * @tc.desc Test samplerParameteri. + */ + it('webgl_test_samplerParameteri25', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameteri"); + let sampler = gl2.createSampler(); + gl2.samplerParameteri(sampler, gl.TEXTURE_COMPARE_MODE, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameteri getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0819 + * @tc.name webgl_test_samplerParameteri26 + * @tc.desc Test samplerParameteri. + */ + it('webgl_test_samplerParameteri26', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameteri"); + let sampler = gl2.createSampler(); + gl2.samplerParameteri(sampler, gl.TEXTURE_MAX_LOD, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameteri getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0820 + * @tc.name webgl_test_samplerParameteri27 + * @tc.desc Test samplerParameteri. + */ + it('webgl_test_samplerParameteri27', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameteri"); + let sampler = gl2.createSampler(); + gl2.samplerParameteri(sampler, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameteri getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0821 + * @tc.name webgl_test_samplerParameteri28 + * @tc.desc Test samplerParameteri. + */ + it('webgl_test_samplerParameteri28', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameteri"); + let sampler = gl2.createSampler(); + gl2.samplerParameteri(sampler, gl.TEXTURE_MIN_LOD, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameteri getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0822 + * @tc.name webgl_test_samplerParameteri29 + * @tc.desc Test samplerParameteri. + */ + it('webgl_test_samplerParameteri29', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameteri"); + let sampler = gl2.createSampler(); + gl2.samplerParameteri(sampler, gl.TEXTURE_WRAP_R, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameteri getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0823 + * @tc.name webgl_test_samplerParameteri211 + * @tc.desc Test samplerParameteri. + */ + it('webgl_test_samplerParameteri211', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameteri"); + let sampler = gl2.createSampler(); + gl2.samplerParameteri(sampler, gl.TEXTURE_WRAP_S, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameteri getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_ENUM); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0824 + * @tc.name webgl_test_samplerParameteri212 + * @tc.desc Test samplerParameteri. + */ + it('webgl_test_samplerParameteri212', 0, async function (done) { + //initContext(); + console.info("webgltest into samplerParameteri"); + let sampler = gl2.createSampler(); + gl2.samplerParameteri(sampler, gl.TEXTURE_WRAP_T, gl.NEAREST); + + let errorCode = gl.getError(); + console.info("webgltest samplerParameteri getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_ENUM); + gl2.deleteSampler(sampler); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0825 + * @tc.name testGetShaderPrecisionFormat + * @tc.desc Test getShaderPrecisionFormat. + */ + it('testGetShaderPrecisionFormat', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); + const shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_INT); + console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); + const type = ((typeof shaderPrecisionFormat) === "object") + expect(type).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0826 + * @tc.name testGetActiveUniformBlockParameter_1 + * @tc.desc Test getActiveUniformBlockParameter. + */ + it('testGetActiveUniformBlockParameter_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( + gl2)); + const program = globalFunction(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + const int32Array = new Int32Array([1, 2]); + gl2.uniform1iv(uniformLocation, int32Array); + const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); + gl2.uniformBlockBinding(program, blockIndex, 1); + const blockSize = gl2.getActiveUniformBlockParameter(program, blockIndex, gl2 + .UNIFORM_BLOCK_BINDING); + console.info("getActiveUniformBlockParameter blockSize" + blockSize); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_VALUE); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0827 + * @tc.name testGetActiveUniformBlockParameter_2 + * @tc.desc Test getActiveUniformBlockParameter. + */ + it('testGetActiveUniformBlockParameter_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( + gl2)); + const program = globalFunction(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + const int32Array = new Int32Array([1, 2]); + gl2.uniform1iv(uniformLocation, int32Array); + const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); + gl2.uniformBlockBinding(program, blockIndex, 1); + const blockSize = gl2.getActiveUniformBlockParameter(program, blockIndex, gl2 + .UNIFORM_BLOCK_ACTIVE_UNIFORMS); + console.info("getActiveUniformBlockParameter blockSize" + blockSize); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_VALUE); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0828 + * @tc.name testGetActiveUniformBlockParameter_3 + * @tc.desc Test getActiveUniformBlockParameter. + */ + it('testGetActiveUniformBlockParameter_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( + gl2)); + const program = globalFunction(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + const int32Array = new Int32Array([1, 2]); + gl2.uniform1iv(uniformLocation, int32Array); + const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); + gl2.uniformBlockBinding(program, blockIndex, 1); + const blockSize = gl2.getActiveUniformBlockParameter(program, blockIndex, + gl2.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES); + console.info("getActiveUniformBlockParameter blockSize" + blockSize); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_VALUE); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0829 + * @tc.name testGetActiveUniformBlockParameter_4 + * @tc.desc Test getActiveUniformBlockParameter. + */ + it('testGetActiveUniformBlockParameter_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( + gl2)); + const program = globalFunction(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + const int32Array = new Int32Array([1, 2]); + gl2.uniform1iv(uniformLocation, int32Array); + const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); + gl2.uniformBlockBinding(program, blockIndex, 1); + const blockSize = gl2.getActiveUniformBlockParameter(program, blockIndex, + gl2.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER); + console.info("getActiveUniformBlockParameter blockSize" + blockSize); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_VALUE); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0830 + * @tc.name testGetIndexedParameter_01_01 + * @tc.desc Test getIndexedParameter. + */ + it('testGetIndexedParameter_01_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetIndexedParameter_01_01 test start ...66'); + console.info('jsWebGL testGetIndexedParameter_01 test start ...' + JSON.stringify(gl)); + const reurGLsizeiptr = gl2.getIndexedParameter(-gl.TRANSFORM_FEEDBACK_BUFFER_SIZE, -0); + const typeGLsizeiptr = typeof (reurGLsizeiptr); + expect(typeGLsizeiptr == 'String').assertEqual(false); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetIndexedParameter_01 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0831 + * @tc.name testGetIndexedParameter_02_01 + * @tc.desc Test getIndexedParameter. + */ + it('testGetIndexedParameter_02_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetIndexedParameter_02_01 test start ...66'); + console.info('jsWebGL testGetIndexedParameter_02 test start ...' + JSON.stringify(gl)); + const retuGLintptr = gl2.getIndexedParameter(-gl.TRANSFORM_FEEDBACK_BUFFER_START, -1); + const typeGLintptr = typeof (retuGLintptr); + expect(typeGLintptr == 'String').assertEqual(false); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetIndexedParameter_02 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0832 + * @tc.name testGetIndexedParameter_03 + * @tc.desc Test getIndexedParameter. + */ + it('testGetIndexedParameter_03_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetIndexedParameter_03_01 test start ...66'); + console.info('jsWebGL testGetIndexedParameter_03 test start ...' + JSON.stringify(gl)); + const WebGLBufferobject = gl2.getIndexedParameter(gl.UNIFORM_BUFFER_BINDING, -0); + const isBuffer = gl.isBuffer(WebGLBufferobject); + expect(isBuffer).assertEqual(false); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetIndexedParameter_03 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0833 + * @tc.name testGetIndexedParameter_04 + * @tc.desc Test getIndexedParameter. + */ + it('testGetIndexedParameter_04_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetIndexedParameter_04_01 test start ...66'); + console.info('jsWebGL testGetIndexedParameter_04 test start ...' + JSON.stringify(gl)); + const reurGLsizeiptr = gl2.getIndexedParameter(-gl.UNIFORM_BUFFER_SIZE, null); + const typeGLsizeiptr = typeof (reurGLsizeiptr); + expect(typeGLsizeiptr == 'String').assertEqual(false); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetIndexedParameter_04 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0834 + * @tc.name testGetIndexedParameter_05_01 + * @tc.desc Test getIndexedParameter. + */ + it('testGetIndexedParameter_05_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testGetIndexedParameter_05 test start ...66'); + console.info('jsWebGL testGetIndexedParameter_05 test start ...' + JSON.stringify(gl)); + const retuGLintptr = gl2.getIndexedParameter(-gl.UNIFORM_BUFFER_START, -0); + const typeGLintptr = typeof (retuGLintptr); + expect(typeGLintptr == 'String').assertEqual(false); + //deleteContext(); + done(); + } catch (e) { + console.log("testGetIndexedParameter_05 has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0838 + * @tc.name testPixelStorei_1_02 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_1_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_1_02 test start ...66'); + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 4); + const unpackValue = gl.getParameter(gl.UNPACK_FLIP_Y_WEBGL); + console.info("unpackValue: " + unpackValue); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0839 + * @tc.name testPixelStorei_1_03 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_1_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_1_03 test start ...66'); + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 4); + const unpackValue = gl.getParameter(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL); + console.info("unpackValue: " + unpackValue); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0840 + * @tc.name testPixelStorei_1_04 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_1_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_1_04 test start ...66'); + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 4); + const unpackValue = gl.getParameter(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL); + console.info("unpackValue: " + unpackValue); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0841 + * @tc.name testPixelStorei_1_05 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_1_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_1_05 test start ...66'); + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl2.PACK_ROW_LENGTH, 4); + const unpackValue = gl.getParameter(gl2.PACK_ROW_LENGTH); + console.info("unpackValue: " + unpackValue); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0842 + * @tc.name testPixelStorei_1_06 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_1_06', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_1_06 test start ...66'); + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl2.PACK_SKIP_PIXELS, 4); + const unpackValue = gl.getParameter(gl2.PACK_SKIP_PIXELS); + console.info("unpackValue: " + unpackValue); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0843 + * @tc.name testPixelStorei_1_07 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_1_07', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_1_07 test start ...66'); + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl2.PACK_SKIP_ROWS, 4); + const unpackValue = gl.getParameter(gl2.PACK_SKIP_ROWS); + console.info("unpackValue: " + unpackValue); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0844 + * @tc.name testPixelStorei_1_08 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_1_08', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_1_08 test start ...66'); + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl2.UNPACK_ROW_LENGTH, 4); + const unpackValue = gl.getParameter(gl2.UNPACK_ROW_LENGTH); + console.info("unpackValue: " + unpackValue); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0845 + * @tc.name testPixelStorei_1_09 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_1_09', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_1_09 test start ...66'); + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl2.UNPACK_IMAGE_HEIGHT, 4); + const unpackValue = gl.getParameter(gl2.UNPACK_IMAGE_HEIGHT); + console.info("unpackValue: " + unpackValue); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0846 + * @tc.name testPixelStorei_1_10 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_1_10', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_1_10 test start ...66'); + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl2.UNPACK_SKIP_PIXELS, 4); + const unpackValue = gl.getParameter(gl2.UNPACK_SKIP_PIXELS); + console.info("unpackValue: " + unpackValue); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0847 + * @tc.name testPixelStorei_1_11 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_1_11', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_1_11 test start ...66'); + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl2.UNPACK_SKIP_ROWS, 4); + const unpackValue = gl.getParameter(gl2.UNPACK_SKIP_ROWS); + console.info("unpackValue: " + unpackValue); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0848 + * @tc.name testPixelStorei_1_12 + * @tc.desc Test pixelStorei. + */ + it('testPixelStorei_1_12', 0, async function (done) { + //initContext(); + console.info('jsWebGL testPixelStorei_1_12 test start ...66'); + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.pixelStorei(gl2.UNPACK_SKIP_IMAGES, 4); + const unpackValue = gl.getParameter(gl2.UNPACK_SKIP_IMAGES); + console.info("unpackValue: " + unpackValue); + const pixelStoreiError = gl.getError(); + console.info("pixelStoreiError: " + pixelStoreiError); + expect(pixelStoreiError).assertEqual(0); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0849 + * @tc.name testBufferData_80 + * @tc.desc Test bufferData. + */ + it('testBufferData_80', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_80 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0850 + * @tc.name testBufferData_81 + * @tc.desc Test bufferData. + */ + it('testBufferData_81', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_81 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.COPY_READ_BUFFER, buffer); + gl.bufferData(gl2.COPY_READ_BUFFER, 1024, gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0851 + * @tc.name testBufferData_82 + * @tc.desc Test bufferData. + */ + it('testBufferData_82', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_82 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.COPY_WRITE_BUFFER, buffer); + gl.bufferData(gl2.COPY_WRITE_BUFFER, 1024, gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0852 + * @tc.name testBufferData_83 + * @tc.desc Test bufferData. + */ + it('testBufferData_83', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_83 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.TRANSFORM_FEEDBACK_BUFFER, buffer); + gl.bufferData(gl2.TRANSFORM_FEEDBACK_BUFFER, 1024, gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0853 + * @tc.name testBufferData_84 + * @tc.desc Test bufferData. + */ + it('testBufferData_84', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_84 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.UNIFORM_BUFFER, buffer); + gl.bufferData(gl2.UNIFORM_BUFFER, 1024, gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0854 + * @tc.name testBufferData_85 + * @tc.desc Test bufferData. + */ + it('testBufferData_85', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_85 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.PIXEL_PACK_BUFFER, buffer); + gl.bufferData(gl2.PIXEL_PACK_BUFFER, 1024, gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0855 + * @tc.name testBufferData_86 + * @tc.desc Test bufferData. + */ + it('testBufferData_86', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_86 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.PIXEL_UNPACK_BUFFER, buffer); + gl.bufferData(gl2.PIXEL_UNPACK_BUFFER, 1024, gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0856 + * @tc.name testBufferData_80_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_80_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_80_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.DYNAMIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0857 + * @tc.name testBufferData_81_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_81_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_81_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.COPY_READ_BUFFER, buffer); + gl.bufferData(gl2.COPY_READ_BUFFER, 1024, gl.STREAM_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0858 + * @tc.name testBufferData_82_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_82_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_82_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.COPY_WRITE_BUFFER, buffer); + gl.bufferData(gl2.COPY_WRITE_BUFFER, 1024, gl2.STATIC_READ); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0859 + * @tc.name testBufferData_83_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_83_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_83_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.TRANSFORM_FEEDBACK_BUFFER, buffer); + gl.bufferData(gl2.TRANSFORM_FEEDBACK_BUFFER, 1024, gl2.DYNAMIC_READ); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0860 + * @tc.name testBufferData_84_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_84_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_84_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.UNIFORM_BUFFER, buffer); + gl.bufferData(gl2.UNIFORM_BUFFER, 1024, gl2.STREAM_READ); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0861 + * @tc.name testBufferData_85_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_85_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_85_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.PIXEL_PACK_BUFFER, buffer); + gl.bufferData(gl2.PIXEL_PACK_BUFFER, 1024, gl2.STATIC_COPY); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0862 + * @tc.name testBufferData_86_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_86_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_86_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.PIXEL_UNPACK_BUFFER, buffer); + gl.bufferData(gl2.PIXEL_UNPACK_BUFFER, 1024, gl2.DYNAMIC_COPY); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0863 + * @tc.name testBufferData_87_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_87_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_87_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.PIXEL_UNPACK_BUFFER, buffer); + gl.bufferData(gl2.PIXEL_UNPACK_BUFFER, 1024, gl2.STREAM_COPY); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0864 + * @tc.name testBufferData_80_1 + * @tc.desc Test bufferData. + */ + it('testBufferData_80_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_80_1 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0865 + * @tc.name testBufferData_81_1 + * @tc.desc Test bufferData. + */ + it('testBufferData_81_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_81_1 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.COPY_READ_BUFFER, buffer); + gl.bufferData(gl2.COPY_READ_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0866 + * @tc.name testBufferData_82_1 + * @tc.desc Test bufferData. + */ + it('testBufferData_82_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_82_1 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.COPY_WRITE_BUFFER, buffer); + gl.bufferData(gl2.COPY_WRITE_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0867 + * @tc.name testBufferData_83_1 + * @tc.desc Test bufferData. + */ + it('testBufferData_83_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_83_1 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.TRANSFORM_FEEDBACK_BUFFER, buffer); + gl.bufferData(gl2.TRANSFORM_FEEDBACK_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0868 + * @tc.name testBufferData_84_1 + * @tc.desc Test bufferData. + */ + it('testBufferData_84_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_84_1 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.UNIFORM_BUFFER, buffer); + gl.bufferData(gl2.UNIFORM_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0869 + * @tc.name testBufferData_85_1 + * @tc.desc Test bufferData. + */ + it('testBufferData_85_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_85_1 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.PIXEL_PACK_BUFFER, buffer); + gl.bufferData(gl2.PIXEL_PACK_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0870 + * @tc.name testBufferData_86_1 + * @tc.desc Test bufferData. + */ + it('testBufferData_86_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_86_1 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.PIXEL_UNPACK_BUFFER, buffer); + gl.bufferData(gl2.PIXEL_UNPACK_BUFFER, new ArrayBuffer(8), gl.STATIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0871 + * @tc.name testBufferData_80_1_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_80_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_80_1_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new ArrayBuffer(8), gl.DYNAMIC_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0872 + * @tc.name testBufferData_81_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_81_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_81_1_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.COPY_READ_BUFFER, buffer); + gl.bufferData(gl2.COPY_READ_BUFFER, new ArrayBuffer(8), gl.STREAM_DRAW); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0873 + * @tc.name testBufferData_82_1_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_82_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_82_1_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.COPY_WRITE_BUFFER, buffer); + gl.bufferData(gl2.COPY_WRITE_BUFFER, new ArrayBuffer(8), gl2.STATIC_READ); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0874 + * @tc.name testBufferData_83_1_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_83_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_83_1_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.TRANSFORM_FEEDBACK_BUFFER, buffer); + gl.bufferData(gl2.TRANSFORM_FEEDBACK_BUFFER, new ArrayBuffer(8), gl2.DYNAMIC_READ); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0875 + * @tc.name testBufferData_84_1_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_84_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_84_1_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.UNIFORM_BUFFER, buffer); + gl.bufferData(gl2.UNIFORM_BUFFER, new ArrayBuffer(8), gl2.STREAM_READ); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0876 + * @tc.name testBufferData_85_1_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_85_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_85_1_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.PIXEL_PACK_BUFFER, buffer); + gl.bufferData(gl2.PIXEL_PACK_BUFFER, new ArrayBuffer(8), gl2.STATIC_COPY); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0877 + * @tc.name testBufferData_86_1_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_86_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_86_1_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.PIXEL_UNPACK_BUFFER, buffer); + gl.bufferData(gl2.PIXEL_UNPACK_BUFFER, new ArrayBuffer(8), gl2.DYNAMIC_COPY); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0878 + * @tc.name testBufferData_87_1_01 + * @tc.desc Test bufferData. + */ + it('testBufferData_87_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferData_87_1_01 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl2.PIXEL_UNPACK_BUFFER, buffer); + gl.bufferData(gl2.PIXEL_UNPACK_BUFFER, new ArrayBuffer(8), gl2.STREAM_COPY); + const bufferDataError = gl.getError(); + console.info("bufferDataError: " + bufferDataError); + expect(bufferDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0879 + * @tc.name testBufferSubData_1_02 + * @tc.desc Test bufferSubData. + */ + it('testBufferSubData_1_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferSubData_1_02 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + gl.bufferSubData(gl.ARRAY_BUFFER, 512, new ArrayBuffer(8)); + const bufferSubDataError = gl.getError(); + console.info("bufferSubDataError: " + bufferSubDataError); + expect(bufferSubDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0880 + * @tc.name testBufferSubData_1_03 + * @tc.desc Test bufferSubData. + */ + it('testBufferSubData_1_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferSubData_1_03 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 512, new ArrayBuffer(8)); + const bufferSubDataError = gl.getError(); + console.info("bufferSubDataError: " + bufferSubDataError); + expect(bufferSubDataError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0881 + * @tc.name testBufferSubData_1_04 + * @tc.desc Test bufferSubData. + */ + it('testBufferSubData_1_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferSubData_1_04 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + gl.bufferSubData(gl2.COPY_WRITE_BUFFER, 512, new ArrayBuffer(8)); + const bufferSubDataError = gl.getError(); + console.info("bufferSubDataError: " + bufferSubDataError); + expect(bufferSubDataError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0882 + * @tc.name testBufferSubData_1_05 + * @tc.desc Test bufferSubData. + */ + it('testBufferSubData_1_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferSubData_1_05 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + gl.bufferSubData(gl2.TRANSFORM_FEEDBACK_BUFFER, 512, new ArrayBuffer(8)); + const bufferSubDataError = gl.getError(); + console.info("bufferSubDataError: " + bufferSubDataError); + expect(bufferSubDataError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0883 + * @tc.name testBufferSubData_1_06 + * @tc.desc Test bufferSubData. + */ + it('testBufferSubData_1_06', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferSubData_1_06 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + gl.bufferSubData(gl2.UNIFORM_BUFFER, 512, new ArrayBuffer(8)); + const bufferSubDataError = gl.getError(); + console.info("bufferSubDataError: " + bufferSubDataError); + expect(bufferSubDataError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0884 + * @tc.name testBufferSubData_1_07 + * @tc.desc Test bufferSubData. + */ + it('testBufferSubData_1_07', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferSubData_1_07 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + gl.bufferSubData(gl2.PIXEL_PACK_BUFFER, 512, new ArrayBuffer(8)); + const bufferSubDataError = gl.getError(); + console.info("bufferSubDataError: " + bufferSubDataError); + expect(bufferSubDataError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0885 + * @tc.name testBufferSubData_1_08 + * @tc.desc Test bufferSubData. + */ + it('testBufferSubData_1_08', 0, async function (done) { + //initContext(); + console.info('jsWebGL testBufferSubData_1_08 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + gl.bufferSubData(gl2.PIXEL_UNPACK_BUFFER, 512, new ArrayBuffer(8)); + const bufferSubDataError = gl.getError(); + console.info("bufferSubDataError: " + bufferSubDataError); + expect(bufferSubDataError).assertEqual(gl.INVALID_VALUE); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0886 + * @tc.name testCompressedTexImage2D_1_01 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexImage2D_1_01 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0x83F3, 512, 512, 0, 0); + const compressedTexImage2DError = gl.getError(); + console.info("compressedTexImage2DError: " + compressedTexImage2DError); + expect(compressedTexImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0887 + * @tc.name testCompressedTexImage2D_1_02 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D_1_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexImage2D_1_02 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0x83F3, 512, 512, 0, 0); + const compressedTexImage2DError = gl.getError(); + console.info("compressedTexImage2DError: " + compressedTexImage2DError); + expect(compressedTexImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0888 + * @tc.name testCompressedTexImage2D_1_03 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D_1_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexImage2D_1_03 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0x83F3, 512, 512, 0, 0); + const compressedTexImage2DError = gl.getError(); + console.info("compressedTexImage2DError: " + compressedTexImage2DError); + expect(compressedTexImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0889 + * @tc.name testCompressedTexImage2D_1_04 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D_1_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexImage2D_1_04 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0x83F3, 512, 512, 0, 0); + const compressedTexImage2DError = gl.getError(); + console.info("compressedTexImage2DError: " + compressedTexImage2DError); + expect(compressedTexImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0890 + * @tc.name testCompressedTexImage2D_1_05 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D_1_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexImage2D_1_05 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0x83F3, 512, 512, 0, 0); + const compressedTexImage2DError = gl.getError(); + console.info("compressedTexImage2DError: " + compressedTexImage2DError); + expect(compressedTexImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0891 + * @tc.name testCompressedTexImage2D_1_06 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D_1_06', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexImage2D_1_06 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0x83F3, 512, 512, 0, 0); + const compressedTexImage2DError = gl.getError(); + console.info("compressedTexImage2DError: " + compressedTexImage2DError); + expect(compressedTexImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0892 + * @tc.name testCompressedTexSubImage2D_1_01 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexSubImage2D_1_01 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); + gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 256, 256, 512, 512, 0x83F3, + gl.PIXEL_UNPACK_BUFFER, 0); + const compressedTexSubImage2DError = gl.getError(); + console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); + expect(compressedTexSubImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0893 + * @tc.name testCompressedTexSubImage2D_1_02 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D_1_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexSubImage2D_1_02 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); + gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 256, 256, 512, 512, 0x83F3, + gl.PIXEL_UNPACK_BUFFER, 0); + const compressedTexSubImage2DError = gl.getError(); + console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); + expect(compressedTexSubImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0894 + * @tc.name testCompressedTexSubImage2D_1_03 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D_1_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexSubImage2D_1_03 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); + gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 256, 256, 512, 512, 0x83F3, + gl.PIXEL_UNPACK_BUFFER, 0); + const compressedTexSubImage2DError = gl.getError(); + console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); + expect(compressedTexSubImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0895 + * @tc.name testCompressedTexSubImage2D_1_04 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D_1_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexSubImage2D_1_04 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); + gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 256, 256, 512, 512, 0x83F3, + gl.PIXEL_UNPACK_BUFFER, 0); + const compressedTexSubImage2DError = gl.getError(); + console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); + expect(compressedTexSubImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0896 + * @tc.name testCompressedTexSubImage2D_1_05 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D_1_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexSubImage2D_1_05 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); + gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 256, 256, 512, 512, 0x83F3, + gl.PIXEL_UNPACK_BUFFER, 0); + const compressedTexSubImage2DError = gl.getError(); + console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); + expect(compressedTexSubImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0897 + * @tc.name testCompressedTexSubImage2D_1_06 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D_1_06', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCompressedTexSubImage2D_1_06 test start ...66'); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.compressedTexImage2D(gl.TEXTURE_2D, 0, 0x83F3, 512, 512, 0, 0); + gl.compressedTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 256, 256, 512, 512, 0x83F3, + gl.PIXEL_UNPACK_BUFFER, 0); + const compressedTexSubImage2DError = gl.getError(); + console.info("compressedTexSubImage2DError: " + compressedTexSubImage2DError); + expect(compressedTexSubImage2DError).assertEqual(0); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0898 + * @tc.name testTexImage2D_1_01 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D_1_01 test start ...66'); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl + .UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0899 + * @tc.name testTexImage2D_1_02 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_1_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D_1_02 test start ...66'); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl + .UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0900 + * @tc.name testTexImage2D_1_03 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_1_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D_1_03 test start ...66'); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl + .UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + }) +} \ No newline at end of file diff --git a/graphic/webGL/src/main/js/test/WebGL.test10.js b/graphic/webGL/src/main/js/test/WebGL.test10.js new file mode 100644 index 0000000000000000000000000000000000000000..119c21d978b9c729ffc58dcd374e4e87ea55ff8c --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test10.js @@ -0,0 +1,2039 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl10() { + describe('webgl1Test_webgl10', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_0901 + * @tc.name testTexImage2D_1_04 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_1_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D_1_04 test start ...66'); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl + .UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0902 + * @tc.name testTexImage2D_1_05 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_1_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D_1_05 test start ...66'); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl + .UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0903 + * @tc.name testTexImage2D_1_06 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_1_06', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D_1_06 test start ...66'); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl + .UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0904 + * @tc.name testTexImage2D_1_07 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_1_07', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D_1_07 test start ...66'); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB8, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0911 + * @tc.name testTexSubImage2D_1_01 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexSubImage2D_1_01 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, + view); + const ttexSubImage2DError = gl.getError(); + console.info("ttexSubImage2DError: " + ttexSubImage2DError); + expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0912 + * @tc.name testTexSubImage2D_1_02 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_1_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexSubImage2D_1_02 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, + view); + const ttexSubImage2DError = gl.getError(); + console.info("ttexSubImage2DError: " + ttexSubImage2DError); + expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0913 + * @tc.name testTexSubImage2D_1_03 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_1_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexSubImage2D_1_03 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, + view); + const ttexSubImage2DError = gl.getError(); + console.info("ttexSubImage2DError: " + ttexSubImage2DError); + expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0914 + * @tc.name testTexSubImage2D_1_04 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_1_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexSubImage2D_1_04 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, + view); + const ttexSubImage2DError = gl.getError(); + console.info("ttexSubImage2DError: " + ttexSubImage2DError); + expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0915 + * @tc.name testTexSubImage2D_1_05 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_1_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexSubImage2D_1_05 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, + view); + const ttexSubImage2DError = gl.getError(); + console.info("ttexSubImage2DError: " + ttexSubImage2DError); + expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0916 + * @tc.name testTexSubImage2D_1_06 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_1_06', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexSubImage2D_1_06 test start ...66'); + const buf = new ArrayBuffer(8); + const view = new DataView(buf, 0); + view[0] = 2; + gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 512, 512, -gl.RED, -gl.FLOAT, + view); + const ttexSubImage2DError = gl.getError(); + console.info("ttexSubImage2DError: " + ttexSubImage2DError); + expect(ttexSubImage2DError).assertEqual(gl.INVALID_OPERATION); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0924 + * @tc.name testCopyBufferSubData_1_02 + * @tc.desc Test copyBufferSubData. + */ + it('testCopyBufferSubData_1_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCopyBufferSubData_1_02 test start ...66'); + const srcBuffer = gl.createBuffer(); + const dstBuffer = gl.createBuffer(); + const vertices = [1, 2]; + const data = new Float32Array(vertices); + const length = vertices.length * 4; + gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); + gl2.copyBufferSubData(gl.COPY_READ_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); + const copyBufferSubDataError = gl.getError(); + console.info("copyBufferSubDataError: " + copyBufferSubDataError); + expect(copyBufferSubDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0925 + * @tc.name testCopyBufferSubData_1_03 + * @tc.desc Test copyBufferSubData. + */ + it('testCopyBufferSubData_1_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCopyBufferSubData_1_03 test start ...66'); + const srcBuffer = gl.createBuffer(); + const dstBuffer = gl.createBuffer(); + const vertices = [1, 2]; + const data = new Float32Array(vertices); + const length = vertices.length * 4; + gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); + gl2.copyBufferSubData(gl.COPY_WRITE_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); + const copyBufferSubDataError = gl.getError(); + console.info("copyBufferSubDataError: " + copyBufferSubDataError); + expect(copyBufferSubDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0926 + * @tc.name testCopyBufferSubData_1_04 + * @tc.desc Test copyBufferSubData. + */ + it('testCopyBufferSubData_1_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCopyBufferSubData_1_04 test start ...66'); + const srcBuffer = gl.createBuffer(); + const dstBuffer = gl.createBuffer(); + const vertices = [1, 2]; + const data = new Float32Array(vertices); + const length = vertices.length * 4; + gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); + gl2.copyBufferSubData(gl.TRANSFORM_FEEDBACK_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); + const copyBufferSubDataError = gl.getError(); + console.info("copyBufferSubDataError: " + copyBufferSubDataError); + expect(copyBufferSubDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0927 + * @tc.name testCopyBufferSubData_1_05 + * @tc.desc Test copyBufferSubData. + */ + it('testCopyBufferSubData_1_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCopyBufferSubData_1_05 test start ...66'); + const srcBuffer = gl.createBuffer(); + const dstBuffer = gl.createBuffer(); + const vertices = [1, 2]; + const data = new Float32Array(vertices); + const length = vertices.length * 4; + gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); + gl2.copyBufferSubData(gl.UNIFORM_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); + const copyBufferSubDataError = gl.getError(); + console.info("copyBufferSubDataError: " + copyBufferSubDataError); + expect(copyBufferSubDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0928 + * @tc.name testCopyBufferSubData_1_06 + * @tc.desc Test copyBufferSubData. + */ + it('testCopyBufferSubData_1_06', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCopyBufferSubData_1_06 test start ...66'); + const srcBuffer = gl.createBuffer(); + const dstBuffer = gl.createBuffer(); + const vertices = [1, 2]; + const data = new Float32Array(vertices); + const length = vertices.length * 4; + gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); + gl2.copyBufferSubData(gl.PIXEL_PACK_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); + const copyBufferSubDataError = gl.getError(); + console.info("copyBufferSubDataError: " + copyBufferSubDataError); + expect(copyBufferSubDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0929 + * @tc.name testCopyBufferSubData_1_07 + * @tc.desc Test copyBufferSubData. + */ + it('testCopyBufferSubData_1_07', 0, async function (done) { + //initContext(); + console.info('jsWebGL testCopyBufferSubData_1_07 test start ...66'); + const srcBuffer = gl.createBuffer(); + const dstBuffer = gl.createBuffer(); + const vertices = [1, 2]; + const data = new Float32Array(vertices); + const length = vertices.length * 4; + gl.bindBuffer(gl.ARRAY_BUFFER, srcBuffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, dstBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(length), gl.STATIC_DRAW); + gl2.copyBufferSubData(gl.PIXEL_UNPACK_BUFFER, gl.ARRAY_BUFFER, 0, 0, length); + const copyBufferSubDataError = gl.getError(); + console.info("copyBufferSubDataError: " + copyBufferSubDataError); + expect(copyBufferSubDataError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0931 + * @tc.name testGetBufferSubData_1_02 + * @tc.desc Test getBufferSubData. + */ + it('testGetBufferSubData_1_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetBufferSubData_1_02 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const vertices = [1, 2]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); + gl2.getBufferSubData(gl.COPY_READ_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); + const getBufferSubDataError = gl.getError(); + console.info("getBufferSubDataError: " + getBufferSubDataError); + expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0932 + * @tc.name testGetBufferSubData_1_03 + * @tc.desc Test getBufferSubData. + */ + it('testGetBufferSubData_1_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetBufferSubData_1_03 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const vertices = [1, 2]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); + gl2.getBufferSubData(gl.COPY_WRITE_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); + const getBufferSubDataError = gl.getError(); + console.info("getBufferSubDataError: " + getBufferSubDataError); + expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0933 + * @tc.name testGetBufferSubData_1_04 + * @tc.desc Test getBufferSubData. + */ + it('testGetBufferSubData_1_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetBufferSubData_1_04 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const vertices = [1, 2]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); + gl2.getBufferSubData(gl.TRANSFORM_FEEDBACK_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); + const getBufferSubDataError = gl.getError(); + console.info("getBufferSubDataError: " + getBufferSubDataError); + expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0934 + * @tc.name testGetBufferSubData_1_05 + * @tc.desc Test getBufferSubData. + */ + it('testGetBufferSubData_1_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetBufferSubData_1_05 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const vertices = [1, 2]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); + gl2.getBufferSubData(gl.UNIFORM_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); + const getBufferSubDataError = gl.getError(); + console.info("getBufferSubDataError: " + getBufferSubDataError); + expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0935 + * @tc.name testGetBufferSubData_1_06 + * @tc.desc Test getBufferSubData. + */ + it('testGetBufferSubData_1_06', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetBufferSubData_1_06 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const vertices = [1, 2]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); + gl2.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); + const getBufferSubDataError = gl.getError(); + console.info("getBufferSubDataError: " + getBufferSubDataError); + expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0936 + * @tc.name testGetBufferSubData_1_07 + * @tc.desc Test getBufferSubData. + */ + it('testGetBufferSubData_1_07', 0, async function (done) { + //initContext(); + console.info('jsWebGL testGetBufferSubData_1_07 test start ...66'); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const vertices = [1, 2]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT); + gl2.getBufferSubData(gl.PIXEL_UNPACK_BUFFER, 0, new Float32Array(arrBuffer), 0, 0); + const getBufferSubDataError = gl.getError(); + console.info("getBufferSubDataError: " + getBufferSubDataError); + expect(getBufferSubDataError).assertEqual(gl.INVALID_ENUM); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0937 + * @tc.name testFramebufferTextureLayer_1_01 + * @tc.desc Test framebufferTextureLayer. + */ + it('testFramebufferTextureLayer_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testFramebufferTextureLayer_1_01 test start ...66'); + const texture = gl.createTexture(); + gl.bindTexture(gl2.TEXTURE_2D_ARRAY, texture); + gl2.texStorage3D(gl2.TEXTURE_2D_ARRAY, 1, gl2.RGBA8, 256, 256, 8); + gl.texParameteri(gl2.TEXTURE_CUBE_MAP, gl2.TEXTURE_MAG_FILTER, gl2.NEAREST); + const framebuffer = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + gl2.framebufferTextureLayer(gl.DRAW_FRAMEBUFFER, gl2.COLOR_ATTACHMENT0, texture, 0, 8) + const framebufferTextureLayerError = gl.getError(); + console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); + expect(framebufferTextureLayerError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0938 + * @tc.name testFramebufferTextureLayer_1_02 + * @tc.desc Test framebufferTextureLayer. + */ + it('testFramebufferTextureLayer_1_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testFramebufferTextureLayer_1_02 test start ...66'); + const texture = gl.createTexture(); + gl.bindTexture(gl2.TEXTURE_2D_ARRAY, texture); + gl2.texStorage3D(gl2.TEXTURE_2D_ARRAY, 1, gl2.RGBA8, 256, 256, 8); + gl.texParameteri(gl2.TEXTURE_CUBE_MAP, gl2.TEXTURE_MAG_FILTER, gl2.NEAREST); + const framebuffer = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + gl2.framebufferTextureLayer(gl.READ_FRAMEBUFFER, gl2.COLOR_ATTACHMENT0, texture, 0, 8) + const framebufferTextureLayerError = gl.getError(); + console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); + expect(framebufferTextureLayerError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0939 + * @tc.name testFramebufferTextureLayer_1_03 + * @tc.desc Test framebufferTextureLayer. + */ + it('testFramebufferTextureLayer_1_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testFramebufferTextureLayer_1_03 test start ...66'); + const texture = gl.createTexture(); + gl.bindTexture(gl2.TEXTURE_2D_ARRAY, texture); + gl2.texStorage3D(gl2.TEXTURE_2D_ARRAY, 1, gl2.RGBA8, 256, 256, 8); + gl.texParameteri(gl2.TEXTURE_CUBE_MAP, gl2.TEXTURE_MAG_FILTER, gl2.NEAREST); + const framebuffer = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + gl2.framebufferTextureLayer(gl.FRAMEBUFFER, gl2.DEPTH_ATTACHMENT, texture, 0, 8) + const framebufferTextureLayerError = gl.getError(); + console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); + expect(framebufferTextureLayerError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0940 + * @tc.name testFramebufferTextureLayer_1_04 + * @tc.desc Test framebufferTextureLayer. + */ + it('testFramebufferTextureLayer_1_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testFramebufferTextureLayer_1_04 test start ...66'); + const texture = gl.createTexture(); + gl.bindTexture(gl2.TEXTURE_2D_ARRAY, texture); + gl2.texStorage3D(gl2.TEXTURE_2D_ARRAY, 1, gl2.RGBA8, 256, 256, 8); + gl.texParameteri(gl2.TEXTURE_CUBE_MAP, gl2.TEXTURE_MAG_FILTER, gl2.NEAREST); + const framebuffer = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + gl2.framebufferTextureLayer(gl.FRAMEBUFFER, gl2.STENCIL_ATTACHMENT, texture, 0, 8) + const framebufferTextureLayerError = gl.getError(); + console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); + expect(framebufferTextureLayerError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0941 + * @tc.name testFramebufferTextureLayer_1_05 + * @tc.desc Test framebufferTextureLayer. + */ + it('testFramebufferTextureLayer_1_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testFramebufferTextureLayer_1_05 test start ...66'); + const texture = gl.createTexture(); + gl.bindTexture(gl2.TEXTURE_2D_ARRAY, texture); + gl2.texStorage3D(gl2.TEXTURE_2D_ARRAY, 1, gl2.RGBA8, 256, 256, 8); + gl.texParameteri(gl2.TEXTURE_CUBE_MAP, gl2.TEXTURE_MAG_FILTER, gl2.NEAREST); + const framebuffer = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + gl2.framebufferTextureLayer(gl.FRAMEBUFFER, gl2.DEPTH_STENCIL_ATTACHMENT, texture, 0, 8) + const framebufferTextureLayerError = gl.getError(); + console.info("framebufferTextureLayerError: " + framebufferTextureLayerError); + expect(framebufferTextureLayerError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0942 + * @tc.name testInvalidateFramebuffer_1_01 + * @tc.desc Test invalidateFramebuffer. + */ + it('testInvalidateFramebuffer_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateFramebuffer_1_01 test start ...66'); + gl2.invalidateFramebuffer(gl.DRAW_FRAMEBUFFER, + [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1]); + const invalidateFramebufferError = gl.getError(); + console.info("invalidateFramebufferError: " + invalidateFramebufferError); + expect(invalidateFramebufferError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0943 + * @tc.name testInvalidateFramebuffer_1_02 + * @tc.desc Test invalidateFramebuffer. + */ + it('testInvalidateFramebuffer_1_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateFramebuffer_1_02 test start ...66'); + gl2.invalidateFramebuffer(gl.FRAMEBUFFER, + [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1]); + const invalidateFramebufferError = gl.getError(); + console.info("invalidateFramebufferError: " + invalidateFramebufferError); + expect(invalidateFramebufferError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0944 + * @tc.name testInvalidateFramebuffer_1_03 + * @tc.desc Test invalidateFramebuffer. + */ + it('testInvalidateFramebuffer_1_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateFramebuffer_1_03 test start ...66'); + gl2.invalidateFramebuffer(gl.READ_FRAMEBUFFER, + [gl.COLOR_ATTACHMENT0, gl.DEPTH_ATTACHMENT]); + const invalidateFramebufferError = gl.getError(); + console.info("invalidateFramebufferError: " + invalidateFramebufferError); + expect(invalidateFramebufferError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0945 + * @tc.name testInvalidateFramebuffer_1_04 + * @tc.desc Test invalidateFramebuffer. + */ + it('testInvalidateFramebuffer_1_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateFramebuffer_1_04 test start ...66'); + gl2.invalidateFramebuffer(gl.READ_FRAMEBUFFER, + [gl.STENCIL_ATTACHMENT, gl.COLOR_ATTACHMENT1]); + const invalidateFramebufferError = gl.getError(); + console.info("invalidateFramebufferError: " + invalidateFramebufferError); + expect(invalidateFramebufferError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0946 + * @tc.name testInvalidateFramebuffer_1_05 + * @tc.desc Test invalidateFramebuffer. + */ + it('testInvalidateFramebuffer_1_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateFramebuffer_1_05 test start ...66'); + gl2.invalidateFramebuffer(gl.READ_FRAMEBUFFER, + [gl.DEPTH_STENCIL_ATTACHMENT, gl.COLOR_ATTACHMENT1]); + const invalidateFramebufferError = gl.getError(); + console.info("invalidateFramebufferError: " + invalidateFramebufferError); + expect(invalidateFramebufferError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0947 + * @tc.name testInvalidateFramebuffer_1_06 + * @tc.desc Test invalidateFramebuffer. + */ + it('testInvalidateFramebuffer_1_06', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateFramebuffer_1_06 test start ...66'); + gl2.invalidateFramebuffer(gl.READ_FRAMEBUFFER, + [gl.DEPTH_ATTACHMENT, gl.STENCIL_ATTACHMENT]); + const invalidateFramebufferError = gl.getError(); + console.info("invalidateFramebufferError: " + invalidateFramebufferError); + expect(invalidateFramebufferError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0948 + * @tc.name testInvalidateFramebuffer_1_01 + * @tc.desc Test invalidateFramebuffer. + */ + it('testInvalidateFramebuffer_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateFramebuffer_1_01 test start ...66'); + gl2.invalidateFramebuffer(gl.READ_FRAMEBUFFER, + [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1]); + const invalidateFramebufferError = gl.getError(); + console.info("invalidateFramebufferError: " + invalidateFramebufferError); + expect(invalidateFramebufferError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0949 + * @tc.name testInvalidateSubFramebuffer_1_01 + * @tc.desc Test invalidateSubFramebuffer. + */ + it('testInvalidateSubFramebuffer_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateSubFramebuffer_1_01 test start ...66'); + gl2.invalidateSubFramebuffer(gl.FRAMEBUFFER, + [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1], + 0, 0, 256, 256); + const invalidateSubFramebufferError = gl.getError(); + console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); + expect(invalidateSubFramebufferError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0950 + * @tc.name testInvalidateSubFramebuffer_1_02 + * @tc.desc Test invalidateSubFramebuffer. + */ + it('testInvalidateSubFramebuffer_1_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateSubFramebuffer_1_02 test start ...66'); + gl2.invalidateSubFramebuffer(gl.DRAW_FRAMEBUFFER, + [gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1], + 0, 0, 256, 256); + const invalidateSubFramebufferError = gl.getError(); + console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); + expect(invalidateSubFramebufferError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0951 + * @tc.name testInvalidateSubFramebuffer_1_03 + * @tc.desc Test invalidateSubFramebuffer. + */ + it('testInvalidateSubFramebuffer_1_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateSubFramebuffer_1_03 test start ...66'); + gl2.invalidateSubFramebuffer(gl.READ_FRAMEBUFFER, + [gl.DEPTH_ATTACHMENT, gl.COLOR_ATTACHMENT1], + 0, 0, 256, 256); + const invalidateSubFramebufferError = gl.getError(); + console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); + expect(invalidateSubFramebufferError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0952 + * @tc.name testInvalidateSubFramebuffer_1_04 + * @tc.desc Test invalidateSubFramebuffer. + */ + it('testInvalidateSubFramebuffer_1_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateSubFramebuffer_1_04 test start ...66'); + gl2.invalidateSubFramebuffer(gl.READ_FRAMEBUFFER, + [gl.COLOR_ATTACHMENT0, gl.STENCIL_ATTACHMENT], + 0, 0, 256, 256); + const invalidateSubFramebufferError = gl.getError(); + console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); + expect(invalidateSubFramebufferError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0953 + * @tc.name testInvalidateSubFramebuffer_1_05 + * @tc.desc Test invalidateSubFramebuffer. + */ + it('testInvalidateSubFramebuffer_1_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testInvalidateSubFramebuffer_1_05 test start ...66'); + gl2.invalidateSubFramebuffer(gl.READ_FRAMEBUFFER, + [gl.DEPTH_STENCIL_ATTACHMENT, gl.STENCIL_ATTACHMENT], + 0, 0, 256, 256); + const invalidateSubFramebufferError = gl.getError(); + console.info("invalidateSubFramebufferError: " + invalidateSubFramebufferError); + expect(invalidateSubFramebufferError).assertEqual(0); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0954 + * @tc.name testRenderbufferStorageMultisample_1_01 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample_1_01 test start ...66'); + gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R8, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0955 + * @tc.name testRenderbufferStorageMultisample_1_02 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_1_02', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample_1_02 test start ...66'); + gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R8UI, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0956 + * @tc.name testRenderbufferStorageMultisample_1_03 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_1_03', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample_1_03 test start ...66'); + gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R8I, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0957 + * @tc.name testRenderbufferStorageMultisample_1_04 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_1_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample_1_04 test start ...66'); + gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R16UI, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0958 + * @tc.name testRenderbufferStorageMultisample_1_05 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_1_05', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample_1_05 test start ...66'); + gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R16I, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0959 + * @tc.name testRenderbufferStorageMultisample_1_06 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_1_06', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample_1_06 test start ...66'); + gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R32UI, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0960 + * @tc.name testRenderbufferStorageMultisample_1_07 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_1_07', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample_1_07 test start ...66'); + gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.R32I, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(0); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0961 + * @tc.name testRenderbufferStorageMultisample_1_08 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_1_08', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample_1_08 test start ...66'); + gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.RG8, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(0); + done(); + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0962 + * @tc.name testTexStorage2D_1_01 + * @tc.desc Test texStorage2D. + */ + it('testTexStorage2D_1_01', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexStorage2D_1_01 test start ...66'); + gl2.texStorage2D(gl.TEXTURE_CUBE_MAP, 1, gl.RGB8, 256, 256); + const texStorage2DError = gl.getError(); + console.info("texStorage2DError: " + texStorage2DError); + expect(texStorage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0963 + * @tc.name testBindBufferBase_1_01 + * @tc.desc Test bindBufferBase. + */ + it('testBindBufferBase_1_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testBindBufferBase_1_01 test start ...66'); + let buffer = gl.createBuffer(); + gl2.bindBufferBase(gl.UNIFORM_BUFFER, 0, buffer); + const bindBufferBaseError = gl.getError(); + console.info("bindBufferBaseError: " + bindBufferBaseError); + expect(bindBufferBaseError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("bindBufferBaseError has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0964 + * @tc.name bindBufferRange_1_01 + * @tc.desc Test bindBufferRange. + */ + it('bindBufferRange_1_01', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL bindBufferRange_1_01 test start ...66'); + const buffer = gl.createBuffer(); + gl2.bindBufferRange(gl.UNIFORM_BUFFER, 1, buffer, 0, 4); + const bindBufferRangeError = gl.getError(); + console.info("bindBufferRangeError: " + bindBufferRangeError); + expect(bindBufferRangeError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("bindBufferRange has failed for " + e) + expect(null).assertFail() + } + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0965 + * @tc.name testVertexAttrib2f2 + * @tc.desc Test vertexAttrib2f. + */ + it('testVertexAttrib2f2', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib2f test start ...66'); + gl.vertexAttrib2f(1, 10.0, 10.0); + const vertexAttrib2fError = gl.getError(); + console.info("vertexAttrib2fError: " + vertexAttrib2fError); + expect(vertexAttrib2fError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib2f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0966 + * @tc.name testVertexAttrib3f2 + * @tc.desc Test vertexAttrib3f. + */ + it('testVertexAttrib3f2', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testvertexAttrib3f test start ...66'); + console.info('jsWebGL testvertexAttrib3f test start ...' + JSON.stringify(gl)); + gl.vertexAttrib3f(1, 10.0, 10.0, 10.0); + const vertexAttrib3fError = gl.getError(); + console.info("vertexAttrib3fError: " + vertexAttrib3fError); + expect(vertexAttrib3fError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib3f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0967 + * @tc.name testVertexAttrib4f2 + * @tc.desc Test vertexAttrib4f. + */ + it('testVertexAttrib4f2', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib4f test start ...66'); + console.info('jsWebGL testVertexAttrib4f test start ...' + JSON.stringify(gl)); + gl.vertexAttrib4f(1, 10.0, 10.0, 10.0, 10.0); + const vertexAttrib4fError = gl.getError(); + console.info("vertexAttrib4fError: " + vertexAttrib4fError); + expect(vertexAttrib4fError).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + } catch (e) { + console.log("testvertexAttrib4f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0968 + * @tc.name testVertexAttrib1f2 + * @tc.desc Test vertexAttrib1f. + */ + it('testVertexAttrib1f2', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib1f test start ...66'); + console.info('jsWebGL testVertexAttrib1f test start ...' + JSON.stringify(gl)); + gl.vertexAttrib1f(-1, 10.0); + const vertexAttrib1fError = gl.getError(); + console.info("vertexAttrib1fError: " + vertexAttrib1fError); + expect(vertexAttrib1fError).assertEqual(gl.INVALID_VALUE); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib1f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0969 + * @tc.name testVertexAttrib2f3 + * @tc.desc Test vertexAttrib2f. + */ + it('testVertexAttrib2f3', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib2f test start ...66'); + gl.vertexAttrib2f(-1, 10.0, 10.0); + const vertexAttrib2fError = gl.getError(); + console.info("vertexAttrib2fError: " + vertexAttrib2fError); + expect(vertexAttrib2fError).assertEqual(gl.INVALID_VALUE); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib2f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0970 + * @tc.name testVertexAttrib3f3 + * @tc.desc Test vertexAttrib3f. + */ + it('testVertexAttrib3f3', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testvertexAttrib3f test start ...66'); + console.info('jsWebGL testvertexAttrib3f test start ...' + JSON.stringify(gl)); + gl.vertexAttrib3f(-1, 10.0, 10.0, 10.0); + const vertexAttrib3fError = gl.getError(); + console.info("vertexAttrib3fError: " + vertexAttrib3fError); + expect(vertexAttrib3fError).assertEqual(gl.INVALID_VALUE); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttrib3f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0971 + * @tc.name testVertexAttrib4f22 + * @tc.desc Test vertexAttrib4f. + */ + it('testVertexAttrib4f22', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttrib4f test start ...66'); + console.info('jsWebGL testVertexAttrib4f test start ...' + JSON.stringify(gl)); + gl.vertexAttrib4f(-1, 10.0, 10.0, 10.0, 10.0); + const vertexAttrib4fError = gl.getError(); + console.info("vertexAttrib4fError: " + vertexAttrib4fError); + expect(vertexAttrib4fError).assertEqual(gl.INVALID_VALUE); + //deleteContext(); + done(); + } catch (e) { + console.log("testvertexAttrib4f has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0972 + * @tc.name testVertexAttribPointer2 + * @tc.desc Test vertexAttribPointer. + */ + it('testVertexAttribPointer2', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttribPointer test start ...66'); + console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); + gl.vertexAttribPointer(1, 4, gl.BYTE, true, 20, 12); + const vertexAttribPointerError = gl.getError(); + console.info("vertexAttribPointerError: " + vertexAttribPointerError); + expect(vertexAttribPointerError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttribPointer has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0973 + * @tc.name testVertexAttribPointer3 + * @tc.desc Test vertexAttribPointer. + */ + it('testVertexAttribPointer3', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttribPointer test start ...66'); + console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); + gl.vertexAttribPointer(2, 2, gl.UNSIGNED_SHORT, true, 20, 16); + const vertexAttribPointerError = gl.getError(); + console.info("vertexAttribPointerError: " + vertexAttribPointerError); + expect(vertexAttribPointerError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttribPointer has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0974 + * @tc.name testVertexAttribPointer4 + * @tc.desc Test vertexAttribPointer. + */ + it('testVertexAttribPointer4', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttribPointer test start ...66'); + console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); + console.info("webgltest into enableVertexAttribArray"); + //顶点着色器程序 + 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); + const locPosition = gl.getAttribLocation(programObj, 'position'); + gl.vertexAttribPointer(locPosition, 3, gl.FLOAT, false, 20, 0); + const vertexAttribPointerError = gl.getError(); + console.info("vertexAttribPointerError: " + vertexAttribPointerError); + expect(vertexAttribPointerError).assertEqual(gl.INVALID_VALUE); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttribPointer has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0975 + * @tc.name testVertexAttribPointer5 + * @tc.desc Test vertexAttribPointer. + */ + it('testVertexAttribPointer5', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttribPointer test start ...66'); + console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); + console.info("webgltest into enableVertexAttribArray"); + //顶点着色器程序 + 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); + const locNormal = gl.getAttribLocation(programObj, 'normal'); + gl.vertexAttribPointer(locNormal, 4, gl.BYTE, true, 20, 12); + const vertexAttribPointerError = gl.getError(); + console.info("vertexAttribPointerError: " + vertexAttribPointerError); + expect(vertexAttribPointerError).assertEqual(gl.INVALID_VALUE); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttribPointer has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0976 + * @tc.name testVertexAttribPointer6 + * @tc.desc Test vertexAttribPointer. + */ + it('testVertexAttribPointer6', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttribPointer test start ...66'); + console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(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); + const locTexUV = gl.getAttribLocation(programObj, 'texUV'); + gl.vertexAttribPointer(locTexUV, 2, gl.UNSIGNED_SHORT, true, 20, 16); + const vertexAttribPointerError = gl.getError(); + console.info("vertexAttribPointerError: " + vertexAttribPointerError); + expect(vertexAttribPointerError).assertEqual(gl.INVALID_VALUE); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttribPointer has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0977 + * @tc.name testTexImage3D2 + * @tc.desc Test texImage3D. + */ + it('testTexImage3D2', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D test start ...66'); + console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); + gl2.texImage3D(gl2.TEXTURE_3D, 0, gl.R8, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0978 + * @tc.name testTexImage3D3 + * @tc.desc Test texImage3D. + */ + it('testTexImage3D3', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D test start ...66'); + console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); + gl2.texImage3D(gl2.TEXTURE_3D, 0, gl.LUMINANCE, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, + 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0979 + * @tc.name testTexImage3D4 + * @tc.desc Test texImage3D. + */ + it('testTexImage3D4', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D test start ...66'); + console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); + gl2.texImage3D(gl2.TEXTURE_3D, 0, gl.RGB8UI, 1, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0980 + * @tc.name testTexSubImage3D + * @tc.desc Test texSubImage3D. + */ + it('testTexSubImage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexSubImage3D test start ...66'); + console.info('jsWebGL testTexSubImage3D test start ...' + JSON.stringify(gl)); + gl2.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 200, 200, 1, gl.RGB8UI, gl.UNSIGNED_BYTE, + 1); + const texSubImage3DError = gl.getError(); + console.info("texSubImage3DError: " + texSubImage3DError); + expect(texSubImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexSubImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0981 + * @tc.name testTexSubImage3D + * @tc.desc Test texSubImage3D. + */ + it('testTexSubImage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexSubImage3D test start ...66'); + console.info('jsWebGL testTexSubImage3D test start ...' + JSON.stringify(gl)); + gl2.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 200, 200, 1, gl.R8, gl.UNSIGNED_BYTE, 1); + const texSubImage3DError = gl.getError(); + console.info("texSubImage3DError: " + texSubImage3DError); + expect(texSubImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexSubImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0982 + * @tc.name testTexSubImage3D + * @tc.desc Test texSubImage3D. + */ + it('testTexSubImage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexSubImage3D test start ...66'); + console.info('jsWebGL testTexSubImage3D test start ...' + JSON.stringify(gl)); + gl2.texSubImage3D(gl.TEXTURE_3D, 0, 0, 0, 0, 200, 200, 1, gl.LUMINANCE, gl + .UNSIGNED_BYTE, 1); + const texSubImage3DError = gl.getError(); + console.info("texSubImage3DError: " + texSubImage3DError); + expect(texSubImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexSubImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0983 + * @tc.name testCompressedTexImage3D + * @tc.desc Test compressedTexImage3D. + */ + it('testCompressedTexImage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexImage3D test start ...66'); + console.info('jsWebGL testCompressedTexImage3D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + gl2.compressedTexImage3D(gl.TEXTURE_3D, 0, 0x83F0, 512, 512, 0, buffer); + const compressedTexImage3DError = gl.getError(); + console.info("compressedTexImage3DError: " + compressedTexImage3DError); + expect(compressedTexImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0984 + * @tc.name testCompressedTexImage3D + * @tc.desc Test compressedTexImage3D. + */ + it('testCompressedTexImage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexImage3D test start ...66'); + console.info('jsWebGL testCompressedTexImage3D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + gl2.compressedTexImage3D(gl.TEXTURE_3D, 0, 0x83F0, 512, 512, 0, buffer, 0, 0); + const compressedTexImage3DError = gl.getError(); + console.info("compressedTexImage3DError: " + compressedTexImage3DError); + expect(compressedTexImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0985 + * @tc.name testCompressedTexImage3D + * @tc.desc Test compressedTexImage3D. + */ + it('testCompressedTexImage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexImage3D test start ...66'); + console.info('jsWebGL testCompressedTexImage3D test start ...' + JSON.stringify(gl)); + gl2.compressedTexImage3D(gl.TEXTURE_3D, 0, 0x83F0, 512, 512, 0, gl2.PIXEL_UNPACK_BUFFER, + 0); + const compressedTexImage3DError = gl.getError(); + console.info("compressedTexImage3DError: " + compressedTexImage3DError); + expect(compressedTexImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0986 + * @tc.name testCompressedTexImage3D + * @tc.desc Test compressedTexImage3D. + */ + it('testCompressedTexImage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexImage3D test start ...66'); + console.info('jsWebGL testCompressedTexImage3D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + gl2.compressedTexImage3D(gl.TEXTURE_3D, false, 0x83F0, 512, 512, 0, buffer); + const compressedTexImage3DError = gl.getError(); + console.info("compressedTexImage3DError: " + compressedTexImage3DError); + expect(compressedTexImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0987 + * @tc.name testCompressedTexImage3D + * @tc.desc Test compressedTexImage3D. + */ + it('testCompressedTexImage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexImage3D test start ...66'); + console.info('jsWebGL testCompressedTexImage3D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + gl2.compressedTexImage3D(gl.TEXTURE_3D, false, 0x83F0, 512, 512, 0, buffer, 0, 0); + const compressedTexImage3DError = gl.getError(); + console.info("compressedTexImage3DError: " + compressedTexImage3DError); + expect(compressedTexImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0988 + * @tc.name testCompressedTexImage3D + * @tc.desc Test compressedTexImage3D. + */ + it('testCompressedTexImage3D', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testCompressedTexImage3D test start ...66'); + console.info('jsWebGL testCompressedTexImage3D test start ...' + JSON.stringify(gl)); + gl2.compressedTexImage3D(gl.TEXTURE_3D, false, 0x83F0, 512, 512, 0, gl2 + .PIXEL_UNPACK_BUFFER, 0); + const compressedTexImage3DError = gl.getError(); + console.info("compressedTexImage3DError: " + compressedTexImage3DError); + expect(compressedTexImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testCompressedTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0989 + * @tc.name testFrontFace2 + * @tc.desc Test frontFace. + */ + it('testFrontFace2', 0, async function (done) { + //initContext(); + console.info('jsWebGL frontFace test start ...' + JSON.stringify(gl)); + gl.enable(gl.CULL_FACE); + gl.cullFace(gl.FRONT_AND_BACK); + gl.frontFace(gl.CCW); + const frontFaceParameter = gl.getParameter(gl.CULL_FACE_MODE); + console.info('frontFace -> frontFaceParameter' + frontFaceParameter); + gl.disable(gl.CULL_FACE); + expect(frontFaceParameter).assertEqual(gl.FRONT_AND_BACK); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0990 + * @tc.name testGenerateMipmap2 + * @tc.desc Test generateMipmap. + */ + it('testGenerateMipmap2', 0, async function (done) { + //initContext(); + console.info('jsWebGL generateMipmap test start ...' + JSON.stringify(gl)); + gl.generateMipmap(gl2.TEXTURE_CUBE_MAP); + const error = gl.getError(); + console.info('generateMipmap error ' + error); + expect(error).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0993 + * @tc.name testGetFramebufferAttachmentParameter2 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter2', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .STENCIL_ATTACHMENT, + gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0994 + * @tc.name testGetFramebufferAttachmentParameter3 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0995 + * @tc.name testGetShaderPrecisionFormat1 + * @tc.desc Test getShaderPrecisionFormat. + */ + it('testGetShaderPrecisionFormat1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); + const shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_FLOAT); + console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); + const type = ((typeof shaderPrecisionFormat) === "object") + expect(type).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0996 + * @tc.name testGetShaderPrecisionFormat2 + * @tc.desc Test getShaderPrecisionFormat. + */ + it('testGetShaderPrecisionFormat2', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); + const shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl + .HIGH_FLOAT); + console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); + const type = ((typeof shaderPrecisionFormat) === "object") + expect(type).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0997 + * @tc.name testGetShaderPrecisionFormat3 + * @tc.desc Test getShaderPrecisionFormat. + */ + it('testGetShaderPrecisionFormat3', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); + const shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT); + console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); + const type = ((typeof shaderPrecisionFormat) === "object") + expect(type).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0998 + * @tc.name testGetShaderPrecisionFormat4 + * @tc.desc Test getShaderPrecisionFormat. + */ + it('testGetShaderPrecisionFormat4', 0, async function (done) { + //initContext(); + console.info('jsWebGL getShaderPrecisionFormat test start ...' + JSON.stringify(gl)); + const shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl + .MEDIUM_INT); + console.info('shaderPrecisionFormat' + JSON.stringify(shaderPrecisionFormat)); + const type = ((typeof shaderPrecisionFormat) === "object") + expect(type).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0999 + * @tc.name testGetTexParameter3 + * @tc.desc Test getTexParameter. + */ + it('testGetTexParameter3', 0, async function (done) { + //initContext(); + console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); + gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(gl.LINEAR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1000 + * @tc.name testGetActiveUniformBlockParameter1 + * @tc.desc Test getActiveUniformBlockParameter. + */ + it('testGetActiveUniformBlockParameter1', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 getActiveUniformBlockParameter test start ...' + JSON.stringify( + gl2)); + const program = globalFunction(); + const uniformLocation = gl.getUniformLocation(program, "a_Position"); + const int32Array = new Int32Array([1, 2]); + gl2.uniform1iv(uniformLocation, int32Array); + const blockIndex = gl2.getUniformBlockIndex(program, 'a_Position'); + gl2.uniformBlockBinding(program, blockIndex, 1); + const blockSize = gl2.getActiveUniformBlockParameter(program, blockIndex, + gl.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER); + console.info("getActiveUniformBlockParameter blockSize" + blockSize); + const errorCode = gl.getError(); + console.info("jsWebGL getActiveUniformBlockParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_VALUE); + done(); + }); + }) +} \ No newline at end of file diff --git a/graphic/webGL/src/main/js/test/WebGL.test11.js b/graphic/webGL/src/main/js/test/WebGL.test11.js new file mode 100644 index 0000000000000000000000000000000000000000..4db5284f27536aceaecfdb5087ef0c734aaaf085 --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test11.js @@ -0,0 +1,2093 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl11() { + describe('webgl1Test_webgl11', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_1001 + * @tc.name testBufferDataFirst + * @tc.desc Test bufferData. + */ + it('testBufferDataFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + const buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl2.bufferData(gl2.ELEMENT_ARRAY_BUFFER, 1024, gl2.DYNAMIC_DRAW); + const errorCode = gl.getError(); + console.info("webgl2test bufferData getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1002 + * @tc.name testBufferData__2 + * @tc.desc Test bufferData. + */ + it('testBufferData__2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + const buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl2.bufferData(gl2.ELEMENT_ARRAY_BUFFER, 1024, gl2.DYNAMIC_DRAW); + const errorCode = gl.getError(); + console.info("webgl2test bufferData getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1003 + * @tc.name testBufferData__3 + * @tc.desc Test bufferData. + */ + it('testBufferData__3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + const buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl2.bufferData(gl2.COPY_READ_BUFFER, 1024, gl2.STREAM_DRAW); + const errorCode = gl.getError(); + console.info("webgl2test bufferData getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1004 + * @tc.name testBufferData__4 + * @tc.desc Test bufferData. + */ + it('testBufferData__4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + const buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl2.bufferData(gl2.COPY_READ_BUFFER, 1024, gl2.STREAM_DRAW); + const errorCode = gl.getError(); + console.info("webgl2test bufferData getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1005 + * @tc.name testBufferData__3 + * @tc.desc Test bufferData. + */ + it('testBufferData__3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + const buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl2.bufferData(gl2.COPY_READ_BUFFER, 1024, gl2.STREAM_DRAW); + const errorCode = gl.getError(); + console.info("webgl2test bufferData getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1006 + * @tc.name testBufferSubData__1 + * @tc.desc Test bufferData. + */ + it('testBufferSubData__1', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + gl2.bufferSubData(gl2.ELEMENT_ARRAY_BUFFER, 512, new ArrayBuffer(8)); + const errorCode = gl.getError(); + console.info("webgl2test bufferSubData getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1007 + * @tc.name testBufferSubData__2 + * @tc.desc Test bufferData. + */ + it('testBufferSubData__2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + gl2.bufferSubData(gl.ARRAY_BUFFER, 512, new ArrayBuffer(8)); + const errorCode = gl.getError(); + console.info("webgl2test bufferSubData getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_VALUE); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1008 + * @tc.name testBufferSubData__3 + * @tc.desc Test bufferData. + */ + it('testBufferSubData__3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 bufferData test start ...' + JSON.stringify(gl2)); + gl2.bufferSubData(gl.COPY_WRITE_BUFFER, 512, new ArrayBuffer(8)); + const errorCode = gl.getError(); + console.info("webgl2test bufferSubData getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1009 + * @tc.name testTexImage2D__1 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D__1', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 32, 512, 512, 0, 32, 32, view); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1010 + * @tc.name testTexImage2D__2 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D__2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 32, 512, 512, 0, 32, 32, view); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1011 + * @tc.name testTexImage2D__3 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D__3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 32, 512, 512, 0, 32, 32, view); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1012 + * @tc.name testTexSubImage2D__1 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D__1', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texSubImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, 512, 512, gl.RED, gl.FLOAT, + view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1013 + * @tc.name testTexSubImage2D__2 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texSubImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0, 0, 512, 512, gl.RED, gl.FLOAT, + view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1014 + * @tc.name testTexSubImage2D__3 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texSubImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0, 0, 512, 512, gl.RED, gl.FLOAT, + view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1015 + * @tc.name testCompressedTexImage2D__1 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D__1', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 compressedTexImage2D test start ...' + JSON.stringify(gl2)); + gl2.compressedTexImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0x83F3, 512, 512, 0, gl + .PIXEL_UNPACK_BUFFER, 0); + const errorCode = gl.getError(); + console.info("webgl2test compressedTexImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1016 + * @tc.name testCompressedTexImage2D__2 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D__2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 compressedTexImage2D test start ...' + JSON.stringify(gl2)); + gl2.compressedTexImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 0x83F3, 512, 512, 0, gl + .PIXEL_UNPACK_BUFFER, 0); + const errorCode = gl.getError(); + console.info("webgl2test compressedTexImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1017 + * @tc.name testCompressedTexImage2D__3 + * @tc.desc Test compressedTexImage2D. + */ + it('testCompressedTexImage2D__3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 compressedTexImage2D test start ...' + JSON.stringify(gl2)); + gl2.compressedTexImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 0x83F3, 512, 512, 0, gl + .PIXEL_UNPACK_BUFFER, 0); + const errorCode = gl.getError(); + console.info("webgl2test compressedTexImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1018 + * @tc.name testCompressedTexSubImage2D__1 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D__1', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 compressedTexSubImage2D test start ...' + JSON.stringify(gl2)); + gl2.compressedTexSubImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_X, 0, 256, 256, 512, 512, 0x83F3, + gl.PIXEL_UNPACK_BUFFER, 0); + const errorCode = gl.getError(); + console.info("webgl2test compressedTexSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1019 + * @tc.name testCompressedTexSubImage2D__2 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D__2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 compressedTexSubImage2D test start ...' + JSON.stringify(gl2)); + gl2.compressedTexSubImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 256, 256, 512, 512, 0x83F3, + gl.PIXEL_UNPACK_BUFFER, 0); + const errorCode = gl.getError(); + console.info("webgl2test compressedTexSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1020 + * @tc.name testCompressedTexSubImage2D__3 + * @tc.desc Test compressedTexSubImage2D. + */ + it('testCompressedTexSubImage2D__3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 compressedTexSubImage2D test start ...' + JSON.stringify(gl2)); + gl2.compressedTexSubImage2D(gl2.TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 256, 256, 512, 512, 0x83F3, + gl.PIXEL_UNPACK_BUFFER, 0); + const errorCode = gl.getError(); + console.info("webgl2test compressedTexSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1021 + * @tc.name testHint1 + * @tc.desc Test hint. + */ + it('testHint1', 0, async function (done) { + //initContext(); + console.info('jsWebGL hint test start ...' + JSON.stringify(gl)); + gl.hint(gl.GENERATE_MIPMAP_HINT, gl.NICEST); + gl.generateMipmap(gl2.TEXTURE_2D); + const error = gl.getError(); + console.info('error' + error); + expect(error).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1022 + * @tc.name testHint2 + * @tc.desc Test hint. + */ + it('testHint2', 0, async function (done) { + //initContext(); + console.info('jsWebGL hint test start ...' + JSON.stringify(gl)); + gl.hint(gl.GENERATE_MIPMAP_HINT, gl.DONT_CARE); + gl.generateMipmap(gl2.TEXTURE_2D); + const error = gl.getError(); + console.info('error' + error); + expect(error).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1023 + * @tc.name testIsEnabled1 + * @tc.desc Test isEnabled. + */ + it('testIsEnabled1', 0, async function (done) { + //initContext(); + console.info('jsWebGL isEnabled test start ...' + JSON.stringify(gl)); + + gl.enable(gl.CULL_FACE); + const isEnabledValue1 = gl.isEnabled(gl.CULL_FACE); + console.info("isEnabledValue1: " + isEnabledValue1); + expect(isEnabledValue1).assertEqual(true); + + // false + // 启用或说明给定的能力项,使用WebGLRenderingContext.enable()方法和WebGLRenderingContext.disable()方法: + gl.disable(gl.CULL_FACE); + const isEnabledValue2 = gl.isEnabled(gl.CULL_FACE); + console.info("isEnabledValue2: " + isEnabledValue2); + expect(isEnabledValue2).assertEqual(false); + + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1024 + * @tc.name testIsEnabled2 + * @tc.desc Test isEnabled. + */ + it('testIsEnabled2', 0, async function (done) { + //initContext(); + console.info('jsWebGL isEnabled test start ...' + JSON.stringify(gl)); + + gl.enable(gl.BLEND); + const isEnabledValue1 = gl.isEnabled(gl.BLEND); + console.info("isEnabledValue1: " + isEnabledValue1); + expect(isEnabledValue1).assertEqual(true); + + // false + // 启用或说明给定的能力项,使用WebGLRenderingContext.enable()方法和WebGLRenderingContext.disable()方法: + gl.disable(gl.BLEND); + const isEnabledValue2 = gl.isEnabled(gl.BLEND); + console.info("isEnabledValue2: " + isEnabledValue2); + expect(isEnabledValue2).assertEqual(false); + + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1025 + * @tc.name testIsEnabled3 + * @tc.desc Test isEnabled. + */ + it('testIsEnabled3', 0, async function (done) { + //initContext(); + console.info('jsWebGL isEnabled test start ...' + JSON.stringify(gl)); + + gl.enable(gl.POLYGON_OFFSET_FILL); + const isEnabledValue1 = gl.isEnabled(gl.POLYGON_OFFSET_FILL); + console.info("isEnabledValue1: " + isEnabledValue1); + expect(isEnabledValue1).assertEqual(true); + + // false + // 启用或说明给定的能力项,使用WebGLRenderingContext.enable()方法和WebGLRenderingContext.disable()方法: + gl.disable(gl.POLYGON_OFFSET_FILL); + const isEnabledValue2 = gl.isEnabled(gl.POLYGON_OFFSET_FILL); + console.info("isEnabledValue2: " + isEnabledValue2); + expect(isEnabledValue2).assertEqual(false); + + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1026 + * @tc.name testIsEnabled4 + * @tc.desc Test isEnabled. + */ + it('testIsEnabled4', 0, async function (done) { + //initContext(); + console.info('jsWebGL isEnabled test start ...' + JSON.stringify(gl)); + + gl.enable(gl.SAMPLE_COVERAGE); + const isEnabledValue1 = gl.isEnabled(gl.SAMPLE_COVERAGE); + console.info("isEnabledValue1: " + isEnabledValue1); + expect(isEnabledValue1).assertEqual(true); + + // false + // 启用或说明给定的能力项,使用WebGLRenderingContext.enable()方法和WebGLRenderingContext.disable()方法: + gl.disable(gl.SAMPLE_COVERAGE); + const isEnabledValue2 = gl.isEnabled(gl.SAMPLE_COVERAGE); + console.info("isEnabledValue2: " + isEnabledValue2); + expect(isEnabledValue2).assertEqual(false); + + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1027 + * @tc.name testRenderbufferStorage1 + * @tc.desc Test renderbufferStorage. + */ + it('testRenderbufferStorage1', 0, async function (done) { + //initContext(); + console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGB565, 256, 256); + + const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT); + expect(width).assertEqual(gl.RGB565); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1028 + * @tc.name testRenderbufferStorage2 + * @tc.desc Test renderbufferStorage. + */ + it('testRenderbufferStorage2', 0, async function (done) { + //initContext(); + console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGB5_A1, 256, 256); + + const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT); + expect(width).assertEqual(gl.RGB5_A1); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1029 + * @tc.name testRenderbufferStorage3 + * @tc.desc Test renderbufferStorage. + */ + it('testRenderbufferStorage3', 0, async function (done) { + //initContext(); + console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, 256, 256); + + const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT); + expect(width).assertEqual(gl.RGBA4); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1030 + * @tc.name testStencilFunc1 + * @tc.desc Test stencilFunc. + */ + it('testStencilFunc1', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilFunc test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + gl.stencilFunc(gl.NEVER, 0, 0b1110011); + const stencilFuncParameter = gl.getParameter(gl.STENCIL_FUNC); + console.info("stencilFunc stencilFuncParameter: " + stencilFuncParameter); + expect(stencilFuncParameter).assertEqual(gl.NEVER); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1031 + * @tc.name testStencilFunc2 + * @tc.desc Test stencilFunc. + */ + it('testStencilFunc2', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilFunc test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + gl.stencilFunc(gl.EQUAL, 0, 0b1110011); + const stencilFuncParameter = gl.getParameter(gl.STENCIL_FUNC); + console.info("stencilFunc stencilFuncParameter: " + stencilFuncParameter); + expect(stencilFuncParameter).assertEqual(gl.EQUAL); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1032 + * @tc.name testStencilFunc3 + * @tc.desc Test stencilFunc. + */ + it('testStencilFunc3', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilFunc test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + gl.stencilFunc(gl.GREATER, 0, 0b1110011); + const stencilFuncParameter = gl.getParameter(gl.STENCIL_FUNC); + console.info("stencilFunc stencilFuncParameter: " + stencilFuncParameter); + expect(stencilFuncParameter).assertEqual(gl.GREATER); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1033 + * @tc.name testStencilFuncSeparate1 + * @tc.desc Test stencilFuncSeparate. + */ + it('testStencilFuncSeparate1', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilFuncSeparate test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + gl.stencilFuncSeparate(gl.BACK, gl.EQUAL, 0.2, 1110011); + const stencilFuncSeparateParameter = gl.getParameter(gl.STENCIL_FUNC); + console.info("stencilFuncSeparate stencilFuncSeparateParameter: " + + stencilFuncSeparateParameter); + expect(stencilFuncSeparateParameter).assertEqual(gl.GREATER); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1034 + * @tc.name testStencilFuncSeparate2 + * @tc.desc Test stencilFuncSeparate. + */ + it('testStencilFuncSeparate2', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilFuncSeparate test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + gl.stencilFuncSeparate(gl.FRONT_AND_BACK, gl.LEQUAL, 0.2, 1110011); + const stencilFuncSeparateParameter = gl.getParameter(gl.STENCIL_FUNC); + console.info("stencilFuncSeparate stencilFuncSeparateParameter: " + + stencilFuncSeparateParameter); + expect(stencilFuncSeparateParameter).assertEqual(gl.LEQUAL); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1036 + * @tc.name testStencilMaskSeparate2 + * @tc.desc Test stencilMaskSeparate. + */ + it('testStencilMaskSeparate2', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilMaskSeparate test start ...' + JSON.stringify(gl)); + gl.stencilMaskSeparate(gl.FRONT_AND_BACK, 110101); + const stencilMaskSeparateParameter = gl.getParameter(gl.STENCIL_WRITEMASK); + console.info("stencilMaskSeparate stencilMaskSeparateParameter: " + + stencilMaskSeparateParameter); + expect(stencilMaskSeparateParameter).assertEqual(110101); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1037 + * @tc.name webgl_test_bindFramebuffer_1 + * @tc.desc Test bindFramebuffer. + */ + it('webgl_test_bindFramebuffer_1', 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(gl2.READ_FRAMEBUFFER, framebuffer); + + const isFrameBuffer2 = gl.isFramebuffer(framebuffer); + console.info("createFramebuffer --> bindFramebuffer --> isFramebuffer_2: " + + isFrameBuffer2); + expect(isFrameBuffer2).assertEqual(true); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1038 + * @tc.name webgl_test_bindFramebuffer_2 + * @tc.desc Test bindFramebuffer. + */ + it('webgl_test_bindFramebuffer_2', 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(gl2.DRAW_FRAMEBUFFER, framebuffer); + + const isFrameBuffer2 = gl.isFramebuffer(framebuffer); + console.info("createFramebuffer --> bindFramebuffer --> isFramebuffer_2: " + + isFrameBuffer2); + expect(isFrameBuffer2).assertEqual(true); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1039 + * @tc.name testGetRenderbufferParameter_1 + * @tc.desc Test getRenderbufferParameter. + */ + it('testGetRenderbufferParameter_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); + + const height = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_HEIGHT); + expect(height).assertEqual(256); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1040 + * @tc.name testGetRenderbufferParameter_2 + * @tc.desc Test getRenderbufferParameter. + */ + it('testGetRenderbufferParameter_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); + + const size = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_BLUE_SIZE); + expect(size).assertEqual(4); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1041 + * @tc.name testGetRenderbufferParameter_3 + * @tc.desc Test getRenderbufferParameter. + */ + it('testGetRenderbufferParameter_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); + + const size = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_RED_SIZE); + expect(size).assertEqual(4); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1042 + * @tc.name testGetRenderbufferParameter_4 + * @tc.desc Test getRenderbufferParameter. + */ + it('testGetRenderbufferParameter_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); + + const size = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_ALPHA_SIZE); + expect(size).assertEqual(4); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1043 + * @tc.name testGetRenderbufferParameter_5 + * @tc.desc Test getRenderbufferParameter. + */ + it('testGetRenderbufferParameter_5', 0, async function (done) { + //initContext(); + console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); + const size = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_DEPTH_SIZE); + expect(size).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1044 + * @tc.name testGetRenderbufferParameter_6 + * @tc.desc Test getRenderbufferParameter. + */ + it('testGetRenderbufferParameter_6', 0, async function (done) { + //initContext(); + console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl2.RENDERBUFFER, renderBuffer); + gl2.renderbufferStorageMultisample(gl2.RENDERBUFFER, 4, gl.RBGA4, 256, 256); + const size = gl.getRenderbufferParameter(gl2.RENDERBUFFER, gl2.RENDERBUFFER_SAMPLES); + expect(size).assertEqual(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1045 + * @tc.name testGetRenderbufferParameter_7 + * @tc.desc Test getRenderbufferParameter. + */ + it('testGetRenderbufferParameter_7', 0, async function (done) { + //initContext(); + console.info('jsWebGL getRenderbufferParameter test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256); + + const size = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_STENCIL_SIZE); + expect(size).assertEqual(0); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1046 + * @tc.name webgl_test_copyTexSubImage2D1 + * @tc.desc Test copyTexSubImage2D. + */ + it('webgl_test_copyTexSubImage2D1', 0, async function (done) { + //initContext(); + console.info("webgltest into copyTexSubImage2D"); + + gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 0, 0, 0, 0, 16, 16); + let errorCode = gl.getError(); + console.info("webgltest copyTexSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_ENUM); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1047 + * @tc.name webgl_test_copyTexSubImage2D2 + * @tc.desc Test copyTexSubImage2D. + */ + it('webgl_test_copyTexSubImage2D2', 0, async function (done) { + //initContext(); + console.info("webgltest into copyTexSubImage2D"); + gl.copyTexSubImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 0, 0, 0, 0, 16, 16); + let errorCode = gl.getError(); + console.info("webgltest copyTexSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1048 + * @tc.name webgl_test_drawElements_3 + * @tc.desc Test drawElements. + */ + it('webgl_test_drawElements_3', 0, async function (done) { + //initContext(); + console.info("webgltest into drawElements"); + + gl.drawElements(gl.LINE_STRIP, 8, gl.UNSIGNED_BYTE, 0); + + let errorCode = gl.getError(); + console.info("webgltest drawElements getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1049 + * @tc.name webgl_test_drawElements_4 + * @tc.desc Test drawElements. + */ + it('webgl_test_drawElements_4', 0, async function (done) { + //initContext(); + console.info("webgltest into drawElements"); + + gl.drawElements(gl.POINTS, 8, gl.UNSIGNED_INT, 0); + + let errorCode = gl.getError(); + console.info("webgltest drawElements getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1050 + * @tc.name webgl_test_drawElements_5 + * @tc.desc Test drawElements. + */ + it('webgl_test_drawElements_5', 0, async function (done) { + //initContext(); + console.info("webgltest into drawElements"); + + gl.drawElements(gl.LINE_LOOP, 8, gl.UNSIGNED_INT, 0); + + let errorCode = gl.getError(); + console.info("webgltest drawElements getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1051 + * @tc.name webgl_test_drawElements_6 + * @tc.desc Test drawElements. + */ + it('webgl_test_drawElements_6', 0, async function (done) { + //initContext(); + console.info("webgltest into drawElements"); + + gl.drawElements(gl.LINES, 8, gl.UNSIGNED_INT, 0); + + let errorCode = gl.getError(); + console.info("webgltest drawElements getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1052 + * @tc.name webgl_test_framebufferRenderbuffer1 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer1', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT1, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1053 + * @tc.name webgl_test_framebufferRenderbuffer2 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer2', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT2, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1054 + * @tc.name webgl_test_framebufferRenderbuffer3 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer3', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT3, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1055 + * @tc.name webgl_test_framebufferRenderbuffer4 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer4', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT4, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1056 + * @tc.name webgl_test_framebufferRenderbuffer5 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer5', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT5, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1057 + * @tc.name webgl_test_framebufferRenderbuffer6 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer6', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT6, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1058 + * @tc.name webgl_test_framebufferRenderbuffer7 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer7', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT7, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1059 + * @tc.name webgl_test_framebufferRenderbuffer8 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer8', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT8, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1060 + * @tc.name webgl_test_framebufferRenderbuffer9 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer9', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT9, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1061 + * @tc.name webgl_test_framebufferRenderbuffer10 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer10', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT10, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1062 + * @tc.name webgl_test_framebufferRenderbuffer11 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer11', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT11, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1063 + * @tc.name webgl_test_framebufferRenderbuffer12 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer12', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT12, gl.RENDERBUFFER, + renderbuffer); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1064 + * @tc.name webgl_test_framebufferRenderbuffer13 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer13', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT13, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1065 + * @tc.name webgl_test_framebufferRenderbuffer14 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer14', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT14, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1066 + * @tc.name webgl_test_framebufferRenderbuffer15 + * @tc.desc Test framebufferRenderbuffer. + */ + it('webgl_test_framebufferRenderbuffer15', 0, async function (done) { + //initContext(); + console.info("webgltest into framebufferRenderbuffer"); + + const renderbuffer = gl.createRenderbuffer(); + gl.framebufferRenderbuffer(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT15, gl.RENDERBUFFER, + renderbuffer); + + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1067 + * @tc.name testGetParameter_1 + * @tc.desc Test getParameter. + */ + it('testGetParameter_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.BLEND_DST_ALPHA); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1068 + * @tc.name testGetParameter_2 + * @tc.desc Test getParameter. + */ + it('testGetParameter_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1069 + * @tc.name testGetParameter_3 + * @tc.desc Test getParameter. + */ + it('testGetParameter_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.BLUE_BITS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1070 + * @tc.name testGetParameter_4 + * @tc.desc Test getParameter. + */ + it('testGetParameter_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.ALPHA_BITS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1071 + * @tc.name testGetParameter_5 + * @tc.desc Test getParameter. + */ + it('testGetParameter_5', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.COMPRESSED_TEXTURE_FORMATS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1072 + * @tc.name testGetParameter_6 + * @tc.desc Test getParameter. + */ + it('testGetParameter_6', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1073 + * @tc.name testGetParameter_7 + * @tc.desc Test getParameter. + */ + it('testGetParameter_7', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.FRONT_FACE); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1074 + * @tc.name testGetParameter_8 + * @tc.desc Test getParameter. + */ + it('testGetParameter_8', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.GREEN_BITS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1075 + * @tc.name testGetParameter_9 + * @tc.desc Test getParameter. + */ + it('testGetParameter_9', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1076 + * @tc.name testGetParameter_10 + * @tc.desc Test getParameter. + */ + it('testGetParameter_10', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1077 + * @tc.name testGetParameter_11 + * @tc.desc Test getParameter. + */ + it('testGetParameter_11', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1078 + * @tc.name testGetParameter_12 + * @tc.desc Test getParameter. + */ + it('testGetParameter_12', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1079 + * @tc.name testGetParameter_13 + * @tc.desc Test getParameter. + */ + it('testGetParameter_13', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1080 + * @tc.name testGetParameter_14 + * @tc.desc Test getParameter. + */ + it('testGetParameter_14', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.MAX_RENDERBUFFER_SIZE); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1081 + * @tc.name testGetParameter_15 + * @tc.desc Test getParameter. + */ + it('testGetParameter_15', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1082 + * @tc.name testGetParameter_16 + * @tc.desc Test getParameter. + */ + it('testGetParameter_16', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.MAX_TEXTURE_SIZE); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1083 + * @tc.name testGetParameter_17 + * @tc.desc Test getParameter. + */ + it('testGetParameter_17', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.MAX_VARYING_VECTORS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1084 + * @tc.name testGetParameter_18 + * @tc.desc Test getParameter. + */ + it('testGetParameter_18', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1085 + * @tc.name testGetParameter_19 + * @tc.desc Test getParameter. + */ + it('testGetParameter_19', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1086 + * @tc.name testGetParameter_20 + * @tc.desc Test getParameter. + */ + it('testGetParameter_20', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1087 + * @tc.name testGetParameter_21 + * @tc.desc Test getParameter. + */ + it('testGetParameter_21', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.POLYGON_OFFSET_FACTOR); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1088 + * @tc.name testGetParameter_22 + * @tc.desc Test getParameter. + */ + it('testGetParameter_22', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.POLYGON_OFFSET_UNITS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1089 + * @tc.name testGetParameter_23 + * @tc.desc Test getParameter. + */ + it('testGetParameter_23', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.RED_BITS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1090 + * @tc.name testGetParameter_24 + * @tc.desc Test getParameter. + */ + it('testGetParameter_24', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.RENDERER); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1091 + * @tc.name testGetParameter_25 + * @tc.desc Test getParameter. + */ + it('testGetParameter_25', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.SAMPLE_BUFFERS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1092 + * @tc.name testGetParameter_26 + * @tc.desc Test getParameter. + */ + it('testGetParameter_26', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.STENCIL_BACK_FAIL); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1093 + * @tc.name testGetParameter_27 + * @tc.desc Test getParameter. + */ + it('testGetParameter_27', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.STENCIL_BACK_FUNC); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1094 + * @tc.name testGetParameter_28 + * @tc.desc Test getParameter. + */ + it('testGetParameter_28', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_FAIL); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1095 + * @tc.name testGetParameter_29 + * @tc.desc Test getParameter. + */ + it('testGetParameter_29', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_PASS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1096 + * @tc.name testGetParameter_30 + * @tc.desc Test getParameter. + */ + it('testGetParameter_30', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.STENCIL_BACK_REF); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1097 + * @tc.name testGetParameter_31 + * @tc.desc Test getParameter. + */ + it('testGetParameter_31', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.STENCIL_BACK_VALUE_MASK); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1098 + * @tc.name testGetParameter_32 + * @tc.desc Test getParameter. + */ + it('testGetParameter_32', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.STENCIL_BACK_WRITEMASK); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1099 + * @tc.name testGetParameter_33 + * @tc.desc Test getParameter. + */ + it('testGetParameter_33', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.STENCIL_BITS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_FRAMEBUFFER_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1100 + * @tc.name testGetParameter_34 + * @tc.desc Test getParameter. + */ + it('testGetParameter_34', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + }) +} \ No newline at end of file diff --git a/graphic/webGL/src/main/js/test/WebGL.test12.js b/graphic/webGL/src/main/js/test/WebGL.test12.js new file mode 100644 index 0000000000000000000000000000000000000000..5bc3605c9f673483a2ebbc563638aca8ecd15af7 --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test12.js @@ -0,0 +1,1803 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl12() { + describe('webgl1Test_webgl12', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_1101 + * @tc.name testGetParameter_35 + * @tc.desc Test getParameter. + */ + it('testGetParameter_35', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1102 + * @tc.name testGetParameter_36 + * @tc.desc Test getParameter. + */ + it('testGetParameter_36', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.STENCIL_REF); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1103 + * @tc.name testGetParameter_37 + * @tc.desc Test getParameter. + */ + it('testGetParameter_37', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.STENCIL_VALUE_MASK); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1104 + * @tc.name testGetParameter_38 + * @tc.desc Test getParameter. + */ + it('testGetParameter_38', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.SUBPIXEL_BITS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1105 + * @tc.name testGetParameter_39 + * @tc.desc Test getParameter. + */ + it('testGetParameter_39', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1106 + * @tc.name testGetParameter_40 + * @tc.desc Test getParameter. + */ + it('testGetParameter_40', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.VENDOR); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1107 + * @tc.name testGetParameter_41 + * @tc.desc Test getParameter. + */ + it('testGetParameter_41', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.VERSION); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1108 + * @tc.name testGetParameter_webgl2_1 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.COPY_READ_BUFFER_BINDING); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1109 + * @tc.name testGetParameter_webgl2_2 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.COPY_WRITE_BUFFER_BINDING); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1110 + * @tc.name testGetParameter_webgl2_3 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_FRAMEBUFFER_BINDING); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1111 + * @tc.name testGetParameter_webgl2_4 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.FRAGMENT_SHADER_DERIVATIVE_HINT); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1112 + * @tc.name testGetParameter_webgl2_5 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_5', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_3D_TEXTURE_SIZE); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1113 + * @tc.name testGetParameter_webgl2_6 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_6', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_ARRAY_TEXTURE_LAYERS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1114 + * @tc.name testGetParameter_webgl2_7 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_7', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_CLIENT_WAIT_TIMEOUT_WEBGL); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1115 + * @tc.name testGetParameter_webgl2_8 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_8', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_COLOR_ATTACHMENTS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1116 + * @tc.name testGetParameter_webgl2_9 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_9', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1117 + * @tc.name testGetParameter_webgl2_10 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_10', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_COMBINED_UNIFORM_BLOCKS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1118 + * @tc.name testGetParameter_webgl2_11 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_11', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1119 + * @tc.name testGetParameter_webgl2_12 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_12', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_DRAW_BUFFERS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1120 + * @tc.name testGetParameter_webgl2_13 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_13', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_ELEMENT_INDEX); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1121 + * @tc.name testGetParameter_webgl2_14 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_14', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_ELEMENTS_INDICES); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1122 + * @tc.name testGetParameter_webgl2_15 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_15', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_ELEMENTS_VERTICES); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1123 + * @tc.name testGetParameter_webgl2_16 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_16', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_FRAGMENT_INPUT_COMPONENTS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1124 + * @tc.name testGetParameter_webgl2_17 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_17', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_FRAGMENT_UNIFORM_BLOCKS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1125 + * @tc.name testGetParameter_webgl2_18 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_18', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_FRAGMENT_UNIFORM_COMPONENTS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1126 + * @tc.name testGetParameter_webgl2_19 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_19', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_PROGRAM_TEXEL_OFFSET); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1127 + * @tc.name testGetParameter_webgl2_20 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_20', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_SAMPLES); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1128 + * @tc.name testGetParameter_webgl2_21 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_21', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_SERVER_WAIT_TIMEOUT); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1129 + * @tc.name testGetParameter_webgl2_22 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_22', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_TEXTURE_LOD_BIAS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1130 + * @tc.name testGetParameter_webgl2_23 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_23', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1131 + * @tc.name testGetParameter_webgl2_24 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_24', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1132 + * @tc.name testGetParameter_webgl2_25 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_25', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1133 + * @tc.name testGetParameter_webgl2_26 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_26', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_UNIFORM_BLOCK_SIZE); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1134 + * @tc.name testGetParameter_webgl2_27 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_27', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_UNIFORM_BUFFER_BINDINGS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1135 + * @tc.name testGetParameter_webgl2_28 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_28', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_VARYING_COMPONENTS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1136 + * @tc.name testGetParameter_webgl2_29 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_29', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_VERTEX_OUTPUT_COMPONENTS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1137 + * @tc.name testGetParameter_webgl2_30 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_30', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_VERTEX_UNIFORM_BLOCKS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1138 + * @tc.name testGetParameter_webgl2_31 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_31', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MAX_VERTEX_UNIFORM_COMPONENTS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1139 + * @tc.name testGetParameter_webgl2_32 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_32', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.MIN_PROGRAM_TEXEL_OFFSET); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1140 + * @tc.name testGetParameter_webgl2_33 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_33', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.PIXEL_PACK_BUFFER_BINDING); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1141 + * @tc.name testGetParameter_webgl2_34 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_34', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.PIXEL_UNPACK_BUFFER_BINDING); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1142 + * @tc.name testGetParameter_webgl2_35 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_35', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.READ_BUFFER); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1143 + * @tc.name testGetParameter_webgl2_36 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_36', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.READ_FRAMEBUFFER_BINDING); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1144 + * @tc.name testGetParameter_webgl2_37 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_37', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.SAMPLER_BINDING); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1145 + * @tc.name testGetParameter_webgl2_38 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_38', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.TEXTURE_BINDING_2D_ARRAY); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1146 + * @tc.name testGetParameter_webgl2_39 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_39', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.TEXTURE_BINDING_3D); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1147 + * @tc.name testGetParameter_webgl2_40 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_40', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.TRANSFORM_FEEDBACK_ACTIVE); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1148 + * @tc.name testGetParameter_webgl2_41 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_41', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.TRANSFORM_FEEDBACK_BINDING); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1149 + * @tc.name testGetParameter_webgl2_42 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_42', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.TRANSFORM_FEEDBACK_PAUSED); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1150 + * @tc.name testGetParameter_webgl2_43 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_43', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.UNIFORM_BUFFER_OFFSET_ALIGNMENT); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1151 + * @tc.name testGetParameter_webgl2_44 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_44', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.VERTEX_ARRAY_BINDING); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1152 + * @tc.name testGetProgramParameter_1 + * @tc.desc Test getProgramParameter. + */ + it('testGetProgramParameter_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getProgramParameter test start ...' + JSON.stringify(gl)); + const program = globalFunction(); + const attachedShaders = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS); + console.info('attachedShaders' + attachedShaders); + expect(attachedShaders).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1153 + * @tc.name testGetProgramParameter_2 + * @tc.desc Test getProgramParameter. + */ + it('testGetProgramParameter_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL getProgramParameter test start ...' + JSON.stringify(gl)); + const program = globalFunction(); + const attachedShaders = gl.getProgramParameter(program, gl2.TRANSFORM_FEEDBACK_BUFFER_MODE); + console.info('attachedShaders' + attachedShaders); + expect(attachedShaders).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1154 + * @tc.name testGetProgramParameter_3 + * @tc.desc Test getProgramParameter. + */ + it('testGetProgramParameter_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL getProgramParameter test start ...' + JSON.stringify(gl)); + const program = globalFunction(); + const attachedShaders = gl.getProgramParameter(program, gl2.TRANSFORM_FEEDBACK_VARYINGS); + console.info('attachedShaders' + attachedShaders); + expect(attachedShaders).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1155 + * @tc.name testGetProgramParameter_4 + * @tc.desc Test getProgramParameter. + */ + it('testGetProgramParameter_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL getProgramParameter test start ...' + JSON.stringify(gl)); + const program = globalFunction(); + const attachedShaders = gl.getProgramParameter(program, gl2.ACTIVE_UNIFORM_BLOCKS); + console.info('attachedShaders' + attachedShaders); + expect(attachedShaders).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1160 + * @tc.name testTexImage2D_1_5 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_1_5', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texImage2D(gl.TEXTURE_2D, 0, gl2.RG16UI, 1, 1, 0, gl2.RG, gl2 + .UNSIGNED_INT_2_10_10_10_REV, view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1170 + * @tc.name testTexImage2D_1_15 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_1_15', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texImage2D(gl.TEXTURE_2D, 0, gl2.RG16UI, 1, 1, 0, gl2.RG, gl2.UNSIGNED_INT_5_9_9_9_REV, + view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1171 + * @tc.name testTexImage2D_1_16 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_1_16', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texImage2D(gl.TEXTURE_2D, 0, gl2.RG16UI, 1, 1, 0, gl2.RG, gl2 + .UNSIGNED_INT_10F_11F_11F_REV, view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1172 + * @tc.name testTexImage2D_1_16 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_1_16', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texImage2D(gl.TEXTURE_2D, 0, gl2.RG16UI, 1, 1, 0, gl2.RG, gl2 + .FLOAT_32_UNSIGNED_INT_24_8_REV, view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1173 + * @tc.name testTexImage2D_1_18 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_1_18', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texImage2D(gl.TEXTURE_2D, 0, gl2.RG16UI, 1, 1, 0, gl2.RG, gl2.UNSIGNED_INT_24_8, view, + 0); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1174 + * @tc.name testTexSubImage2D_1_1 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_1_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl2.RG, gl.FLOAT, view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1175 + * @tc.name testTexSubImage2D_1_2 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_1_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl2.RED_INTEGER, gl.FLOAT, view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1176 + * @tc.name testTexSubImage2D_1_3 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_1_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl2.RG_INTEGER, gl.FLOAT, view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1177 + * @tc.name testTexSubImage2D_1_4 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_1_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl2.RGB_INTEGER, gl.FLOAT, view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1178 + * @tc.name testTexSubImage2D_1_5 + * @tc.desc Test texSubImage2D. + */ + it('testTexSubImage2D_1_5', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texSubImage2D test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.texSubImage2D(gl2.TEXTURE_2D, 0, 0, 0, 512, 512, gl2.RGBA_INTEGER, gl.FLOAT, view, 0); + const errorCode = gl.getError(); + console.info("webgl2test texSubImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1179 + * @tc.name webgl_test_activeTexture4_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture4_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE4); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33988); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1180 + * @tc.name webgl_test_activeTexture5_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture5_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE5); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33989); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1181 + * @tc.name webgl_test_activeTexture6_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture6_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE6); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33990); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1182 + * @tc.name webgl_test_activeTexture7_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture7_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE7); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33991); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1183 + * @tc.name webgl_test_activeTexture8_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture8_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE8); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33992); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1184 + * @tc.name webgl_test_activeTexture9_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture9_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE9); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33993); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1185 + * @tc.name webgl_test_activeTexture10_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture10_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE10); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33994); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1186 + * @tc.name webgl_test_activeTexture11_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture11_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE11); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33995); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1187 + * @tc.name webgl_test_activeTexture12_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture12_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE12); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33996); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1188 + * @tc.name webgl_test_activeTexture13_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture13_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE13); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33997); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1189 + * @tc.name webgl_test_activeTexture14_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture14_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE14); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33998); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1190 + * @tc.name webgl_test_activeTexture15_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture15_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE15); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(33999); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1191 + * @tc.name webgl_test_activeTexture16_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture16_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE16); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34000); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1192 + * @tc.name webgl_test_activeTexture17_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture17_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE17); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34001); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1193 + * @tc.name webgl_test_activeTexture18_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture18_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE18); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34002); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1194 + * @tc.name webgl_test_activeTexture19_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture19_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE19); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34003); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1195 + * @tc.name webgl_test_activeTexture20_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture20_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE20); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34004); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1196 + * @tc.name webgl_test_activeTexture21_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture21_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE21); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34005); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1197 + * @tc.name webgl_test_activeTexture22_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture22_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE22); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34006); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1198 + * @tc.name webgl_test_activeTexture23_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture23_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE23); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34007); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1199 + * @tc.name webgl_test_activeTexture24_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture24_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE24); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34008); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1200 + * @tc.name webgl_test_activeTexture25_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture25_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE25); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34009); + //deleteContext(); + done(); + }); + }) +} \ No newline at end of file diff --git a/graphic/webGL/src/main/js/test/WebGL.test13.js b/graphic/webGL/src/main/js/test/WebGL.test13.js new file mode 100644 index 0000000000000000000000000000000000000000..115ee67c155add654716775062a42d65d9121692 --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test13.js @@ -0,0 +1,2117 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl13() { + describe('webgl1Test_webgl13', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_1201 + * @tc.name webgl_test_activeTexture26_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture26_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE26); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34010); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1202 + * @tc.name webgl_test_activeTexture27_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture27_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE27); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34011); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1203 + * @tc.name webgl_test_activeTexture28_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture28_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE28); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34012); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1204 + * @tc.name webgl_test_activeTexture29_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture29_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE29); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34013); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1205 + * @tc.name webgl_test_activeTexture30_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture30_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE30); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34014); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1206 + * @tc.name webgl_test_activeTexture31_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture31_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE31); + const activeTextureParameter = gl.getParameter(gl.ACTIVE_TEXTURE); + console.info("webgltest activeTexture --> getParameter: " + activeTextureParameter); + expect(activeTextureParameter).assertEqual(34015); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1207 + * @tc.name webgl_test_blendEquation_7 + * @tc.desc Test blendEquation. + */ + it('webgl_test_blendEquation_7', 0, async function (done) { + //initContext(); + console.info("webgltest into blendEquation"); + + gl.blendEquation(gl2.MIN); + + const blendEquationValue = gl.getParameter(gl.BLEND_EQUATION_RGB); + console.info("blendEquation --> getParameter: " + blendEquationValue); + expect(blendEquationValue).assertEqual(32775); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1208 + * @tc.name webgl_test_blendEquation_2 + * @tc.desc Test blendEquation. + */ + it('webgl_test_blendEquation_2', 0, async function (done) { + //initContext(); + console.info("webgltest into blendEquation"); + + gl.blendEquation(gl2.MAX); + + const blendEquationValue = gl.getParameter(gl.BLEND_EQUATION_RGB); + console.info("blendEquation --> getParameter: " + blendEquationValue); + expect(blendEquationValue).assertEqual(32776); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1210 + * @tc.name webgl_test_disable_40 + * @tc.desc Test disable. + */ + it('webgl_test_disable_40', 0, async function (done) { + //initContext(); + console.info("webgltest into disable"); + + gl.disable(gl2.RASTERIZER_DISCARD); + // 要检查功能是否被禁用,请使用以下WebGLRenderingContext.isEnabled()方法: + const isEnabled = gl.isEnabled(gl.DITHER); + // false + console.info("webgltest disable isEnabled: " + isEnabled); + expect(isEnabled).assertEqual(true); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1211 + * @tc.name webgl_test_clientWaitSync_2 + * @tc.desc Test clientWaitSync. + */ + it('webgl_test_clientWaitSync_2', 0, async function (done) { + //initContext(); + console.info("webgltest into clientWaitSync"); + let sync = gl2.fenceSync(0x9117, 0); + let status = gl2.clientWaitSync(sync, gl.SYNC_FLUSH_COMMANDS_BIT, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(true); + + console.info("webgltest fenceSync clientWaitSync: " + status); + + expect(status).assertEqual(0); + + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1212 + * @tc.name webgl_test_getSyncParameter_1 + * @tc.desc Test getSyncParameter. + */ + it('webgl_test_getSyncParameter_1', 0, async function (done) { + //initContext(); + console.info("webgltest into getSyncParameter"); + + console.info("webgltest into isSync"); + let sync = gl2.fenceSync(0x9117, 0); + let status = gl2.clientWaitSync(sync, 0, 0); + gl2.waitSync(sync, 0, -1); + const isSync1 = gl2.isSync(sync); + console.info("webgltest fenceSync isSync1: " + isSync1); + expect(isSync1).assertEqual(true); + const syncParameter = gl2.getSyncParameter(sync, 0x9112); + + console.info("webgltest fenceSync getSyncParameter: " + syncParameter); + expect(syncParameter).assertEqual(gl2.SYNC_FENCE); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1213 + * @tc.name testReadPixelsFirst_1 + * @tc.desc Test readPixels. + */ + it('testReadPixelsFirst_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_SHORT_5_6_5, view); + const errorCode = gl.getError(); + console.info("webgl2test readPixels getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1214 + * @tc.name testReadPixelsFirst_2 + * @tc.desc Test readPixels. + */ + it('testReadPixelsFirst_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_SHORT_4_4_4_4, view); + const errorCode = gl.getError(); + console.info("webgl2test readPixels getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1215 + * @tc.name testReadPixelsFirst_3 + * @tc.desc Test readPixels. + */ + it('testReadPixelsFirst_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.UNSIGNED_SHORT_5_5_5_1, view); + const errorCode = gl.getError(); + console.info("webgl2test readPixels getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1216 + * @tc.name testReadPixelsFirst_4 + * @tc.desc Test readPixels. + */ + it('testReadPixelsFirst_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.SHORT, view); + const errorCode = gl.getError(); + console.info("webgl2test readPixels getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1217 + * @tc.name testReadPixelsFirst_5 + * @tc.desc Test readPixels. + */ + it('testReadPixelsFirst_5', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 readPixels test start ...' + JSON.stringify(gl2)); + var buffer = new ArrayBuffer(8); + var view = new DataView(buffer, 0); + view.setInt16(1, 42); + gl2.readPixels(0, 0, 512, 512, gl2.RGBA, gl2.INT, view); + const errorCode = gl.getError(); + console.info("webgl2test readPixels getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1218 + * @tc.name testTexImage2D_10_1 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_10_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.R8_SNORM, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1219 + * @tc.name testTexImage2D_11_1 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RG8_SNORM, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1220 + * @tc.name testTexImage2D_11_0 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_0', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB8_SNORM, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1221 + * @tc.name testTexImage2D_11_1 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA8_SNORM, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1222 + * @tc.name testTexImage2D_11_2 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB10_A2UI, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1223 + * @tc.name testTexImage2D_11_3 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.SRGB8, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1224 + * @tc.name testTexImage2D_11_4 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.R32F, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1225 + * @tc.name testTexImage2D_11_5 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_5', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RG8I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1226 + * @tc.name testTexImage2D_11_6 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_6', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RG16I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1227 + * @tc.name testTexImage2D_11_7 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_7', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RG32I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1228 + * @tc.name testTexImage2D_11_8 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_8', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RG32UI, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1229 + * @tc.name testTexImage2D_11_9 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_9', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB8I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1230 + * @tc.name testTexImage2D_11_10 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_10', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB16I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1231 + * @tc.name testTexImage2D_11_11 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_11', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB16UI, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1232 + * @tc.name testTexImage2D_11_12 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_12', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB32I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1233 + * @tc.name testTexImage2D_11_13 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_13', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGB32UI, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1234 + * @tc.name testTexImage2D_11_14 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_14', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA8I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1235 + * @tc.name testTexImage2D_11_15 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_15', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA16I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1236 + * @tc.name testTexImage2D_11_16 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_16', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA16UI, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1237 + * @tc.name testTexImage2D_11_17 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_17', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA32I, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1238 + * @tc.name testTexImage2D_11_18 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_18', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.RGBA32UI, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1239 + * @tc.name testTexImage2D_11_19 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D_11_19', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTexImage2D test start ...66'); + console.info('jsWebGL testTexImage2D test start ...' + JSON.stringify(gl)); + const buffer = new ArrayBuffer(8); + const z = new Uint8Array(buffer, 1, 4); + gl.texImage2D(gl.TEXTURE_2D, 0, gl2.DEPTH_COMPONENT, 512, 512, 0, gl.RGB8, gl.UNSIGNED_BYTE, + z); + const texImage2DError = gl.getError(); + console.info("texImage2DError: " + texImage2DError); + expect(texImage2DError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1241 + * @tc.name testRenderbufferStorageMultisample_2 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); + gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.DEPTH_COMPONENT24, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1242 + * @tc.name testRenderbufferStorageMultisample_3 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); + gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.DEPTH_COMPONENT32F, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1243 + * @tc.name testRenderbufferStorageMultisample_4 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); + gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.DEPTH24_STENCIL8, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1244 + * @tc.name testRenderbufferStorageMultisample_5 + * @tc.desc Test renderbufferStorageMultisample. + */ + it('testRenderbufferStorageMultisample_5', 0, async function (done) { + //initContext(); + console.info('jsWebGL testRenderbufferStorageMultisample test start ...66'); + gl2.renderbufferStorageMultisample(gl.RENDERBUFFER, 4, gl.DEPTH32F_STENCIL8, 256, 256); + const renderbufferStorageMultisampleError = gl.getError(); + console.info("renderbufferStorageMultisampleError: " + renderbufferStorageMultisampleError); + expect(renderbufferStorageMultisampleError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1246 + * @tc.name testTransformFeedbackVaryings_7 + * @tc.desc Test transformFeedbackVaryings. + */ + it('testTransformFeedbackVaryings_7', 0, async function (done) { + //initContext(); + console.info('jsWebGL testTransformFeedbackVaryings test start ...66'); + console.info('jsWebGL testTransformFeedbackVaryings test start ...' + JSON.stringify(gl)); + const program = gl.createProgram(); + var transformFeedbackOutputs = ['gl_Position', 'anotherOutput']; + gl2.transformFeedbackVaryings(program, transformFeedbackOutputs, gl.SEPARATE_ATTRIBS); + const transformFeedbackVaryingsError = gl.getError(); + console.info("transformFeedbackVaryingsError: " + transformFeedbackVaryingsError); + expect(transformFeedbackVaryingsError).assertEqual(0); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1247 + * @tc.name testGetVertexAttrib_EnumSize + * @tc.desc Test getVertexAttrib. + */ + it('testGetVertexAttrib_EnumSize', 0, async function (done) { + //initContext(); + console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const bufferVertexAttrib = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_SIZE); + const isBuffer = gl.isBuffer(bufferVertexAttrib); + console.info("getVertexAttrib: bufferVertexAttrib" + bufferVertexAttrib); + expect(isBuffer).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1248 + * @tc.name testGetVertexAttrib_EnumStride + * @tc.desc Test getVertexAttrib. + */ + it('testGetVertexAttrib_EnumStride', 0, async function (done) { + //initContext(); + console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const bufferVertexAttrib = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_STRIDE); + const isBuffer = gl.isBuffer(bufferVertexAttrib); + console.info("getVertexAttrib: bufferVertexAttrib" + bufferVertexAttrib); + expect(isBuffer).assertEqual(false); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1249 + * @tc.name testGetVertexAttrib_EnumType + * @tc.desc Test getVertexAttrib. + */ + it('testGetVertexAttrib_EnumType', 0, async function (done) { + //initContext(); + console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const bufferVertexAttrib = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_TYPE); + const isBuffer = gl.isBuffer(bufferVertexAttrib); + console.info("getVertexAttrib: bufferVertexAttrib" + bufferVertexAttrib); + expect(isBuffer).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1250 + * @tc.name testGetVertexAttrib_EnumNormalized + * @tc.desc Test getVertexAttrib. + */ + it('testGetVertexAttrib_EnumNormalized', 0, async function (done) { + //initContext(); + console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const bufferVertexAttrib = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_NORMALIZED); + const isBuffer = gl.isBuffer(bufferVertexAttrib); + console.info("getVertexAttrib: bufferVertexAttrib" + bufferVertexAttrib); + expect(isBuffer).assertEqual(false); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1251 + * @tc.name testRenderbufferStorage_DepthComponent16 + * @tc.desc Test renderbufferStorage. + */ + it('testRenderbufferStorage_DepthComponent16', 0, async function (done) { + //initContext(); + console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, 256, 256); + + const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT); + expect(width).assertEqual(gl.DEPTH_COMPONENT16); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1252 + * @tc.name testRenderbufferStorage_StencilIndex8 + * @tc.desc Test renderbufferStorage + */ + it('testRenderbufferStorage_StencilIndex8', 0, async function (done) { + //initContext(); + console.info('jsWebGL renderbufferStorage test start ...' + JSON.stringify(gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.STENCIL_INDEX8, 256, 256); + + const width = gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT); + expect(width).assertEqual(gl.STENCIL_INDEX8); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1253 + * @tc.name testStencilOp_KeepReplaceIncrWrap + * @tc.desc Test stencilOp + */ + it('testStencilOp_KeepReplaceIncrWrap', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilOp test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + gl.stencilOp(gl.KEEP, gl.REPLACE, gl.INCR_WRAP); + const stencilOpParameter = gl.getParameter(gl.STENCIL_FAIL); + console.info("stencilOp stencilOpParameter: " + stencilOpParameter); + expect(stencilOpParameter).assertEqual(gl.KEEP); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1254 + * @tc.name testStencilOp_KeepReplaceDecrWrap + * @tc.desc Test stencilOp + */ + it('testStencilOp_KeepReplaceDecrWrap', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilOp test start ...' + JSON.stringify(gl)); + gl.enable(gl.STENCIL_TEST); + gl.stencilOp(gl.KEEP, gl.REPLACE, gl.DECR_WRAP); + const stencilOpParameter = gl.getParameter(gl.STENCIL_FAIL); + console.info("stencilOp stencilOpParameter: " + stencilOpParameter); + expect(stencilOpParameter).assertEqual(gl.KEEP); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1255 + * @tc.name testTexParameterf_TextureBaseLevel + * @tc.desc Test texParameterf. + */ + it('testTexParameterf_TextureBaseLevel', 0, async function (done) { + //initContext(); + console.info('jsWebGL texParameterf test start ...' + JSON.stringify(gl)); + gl.texParameterf(gl.TEXTURE_2D, gl2.TEXTURE_BASE_LEVEL, gl.LINEAR); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl2.TEXTURE_BASE_LEVEL); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1256 + * @tc.name testTexParameterf_TextureMaxLevel + * @tc.desc Test texParameterf. + */ + it('testTexParameterf_TextureMaxLevel', 0, async function (done) { + //initContext(); + console.info('jsWebGL texParameterf test start ...' + JSON.stringify(gl)); + gl.texParameterf(gl.TEXTURE_2D, gl2.TEXTURE_MAX_LEVEL, gl.LINEAR); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl2.TEXTURE_MAX_LEVEL); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(undefined); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1257 + * @tc.name testVertexAttribPointer_Short + * @tc.desc Test vertexAttribPointer. + */ + it('testVertexAttribPointer_Short', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testVertexAttribPointer test start ...66'); + console.info('jsWebGL testVertexAttribPointer test start ...' + JSON.stringify(gl)); + gl.vertexAttribPointer(0, 3, gl.SHORT, false, 20, 0); + const vertexAttribPointerError = gl.getError(); + console.info("vertexAttribPointerError: " + vertexAttribPointerError); + expect(vertexAttribPointerError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testVertexAttribPointer has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1258 + * @tc.name testTexStorage3D_Srgb8 + * @tc.desc Test texStorage3D. + */ + it('testTexStorage3D_Srgb8', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexStorage3D test start ...66'); + console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); + gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.SRGB8, 256, 256, 256); + const texStorage3DError = gl.getError(); + console.info("texStorage3DError: " + texStorage3DError); + expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexStorage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1259 + * @tc.name testTexStorage3D_Rgba32f + * @tc.desc Test texStorage3D. + */ + it('testTexStorage3D_Rgba32f', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexStorage3D test start ...66'); + console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); + gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RGBA32F, 256, 256, 256); + const texStorage3DError = gl.getError(); + console.info("texStorage3DError: " + texStorage3DError); + expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexStorage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1260 + * @tc.name testTexStorage3D_Rgb32f + * @tc.desc Test texStorage3D. + */ + it('testTexStorage3D_Rgb32f', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexStorage3D test start ...66'); + console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); + gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RGB32F, 256, 256, 256); + const texStorage3DError = gl.getError(); + console.info("texStorage3DError: " + texStorage3DError); + expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexStorage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1261 + * @tc.name testTexStorage3D_Rgba16f + * @tc.desc Test texStorage3D. + */ + it('testTexStorage3D_Rgba16f', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexStorage3D test start ...66'); + console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); + gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RGBA16F, 256, 256, 256); + const texStorage3DError = gl.getError(); + console.info("texStorage3DError: " + texStorage3DError); + expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexStorage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1262 + * @tc.name testTexStorage3D_Rgb16f + * @tc.desc Test texStorage3D. + */ + it('testTexStorage3D_Rgb16f', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexStorage3D test start ...66'); + console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); + gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RGB16F, 256, 256, 256); + const texStorage3DError = gl.getError(); + console.info("texStorage3DError: " + texStorage3DError); + expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexStorage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1263 + * @tc.name testTexStorage3D_R11FG11FB10F + * @tc.desc Test texStorage3D. + */ + it('testTexStorage3D_R11FG11FB10F', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexStorage3D test start ...66'); + console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); + gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.R11F_G11F_B10F, 256, 256, 256); + const texStorage3DError = gl.getError(); + console.info("texStorage3DError: " + texStorage3DError); + expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexStorage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1264 + * @tc.name testTexStorage3D_RGB9E5 + * @tc.desc Test texStorage3D. + */ + it('testTexStorage3D_RGB9E5', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexStorage3D test start ...66'); + console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); + gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RGB9_E5, 256, 256, 256); + const texStorage3DError = gl.getError(); + console.info("texStorage3DError: " + texStorage3DError); + expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexStorage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1265 + * @tc.name testTexStorage3D_RGBA8UI + * @tc.desc Test texStorage3D. + */ + it('testTexStorage3D_RGBA8UI', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexStorage3D test start ...66'); + console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); + gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RGBA8UI, 256, 256, 256); + const texStorage3DError = gl.getError(); + console.info("texStorage3DError: " + texStorage3DError); + expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexStorage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1266 + * @tc.name testTexStorage3D_R32F + * @tc.desc Test texStorage3D. + */ + it('testTexStorage3D_R32F', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexStorage3D test start ...66'); + console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); + gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.R32F, 256, 256, 256); + const texStorage3DError = gl.getError(); + console.info("texStorage3DError: " + texStorage3DError); + expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexStorage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1267 + * @tc.name testTexStorage3D_RG16F + * @tc.desc Test texStorage3D. + */ + it('testTexStorage3D_RG16F', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexStorage3D test start ...66'); + console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); + gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RG16F, 256, 256, 256); + const texStorage3DError = gl.getError(); + console.info("texStorage3DError: " + texStorage3DError); + expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexStorage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1268 + * @tc.name testTexStorage3D_RG32F + * @tc.desc Test texStorage3D. + */ + it('testTexStorage3D_RG32F', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexStorage3D test start ...66'); + console.info('jsWebGL testTexStorage3D test start ...' + JSON.stringify(gl)); + gl2.texStorage3D(gl2.TEXTURE_3D, 1, gl2.RG32F, 256, 256, 256); + const texStorage3DError = gl.getError(); + console.info("texStorage3DError: " + texStorage3DError); + expect(texStorage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexStorage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1269 + * @tc.name testTexImage3D_SRGB8ALPHA8 + * @tc.desc Test texImage3D. + */ + it('testTexImage3D_SRGB8ALPHA8', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D test start ...66'); + console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); + gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, gl2 + .UNSIGNED_BYTE, 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(0); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1270 + * @tc.name testTexImage3D_HALFFLOAT + * @tc.desc Test texImage3D. + */ + it('testTexImage3D_HALFFLOAT', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D test start ...66'); + console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); + gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, gl2.HALF_FLOAT, + 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1271 + * @tc.name testTexImage3D_UNSIGNED_INT_2_10_10_10_REV + * @tc.desc Test texImage3D. + */ + it('testTexImage3D_UNSIGNED_INT_2_10_10_10_REV', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D test start ...66'); + console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); + gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, + gl2.UNSIGNED_INT_2_10_10_10_REV, 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1272 + * @tc.name testTexImage3D_UNSIGNED_INT_10F_11F_11F_REV + * @tc.desc Test texImage3D. + */ + it('testTexImage3D_UNSIGNED_INT_10F_11F_11F_REV', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D test start ...66'); + console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); + gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, + gl2.UNSIGNED_INT_10F_11F_11F_REV, 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1273 + * @tc.name testTexImage3D_UNSIGNED_INT_5_9_9_9_REV + * @tc.desc Test texImage3D. + */ + it('testTexImage3D_UNSIGNED_INT_5_9_9_9_REV', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D test start ...66'); + console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); + gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, gl2 + .UNSIGNED_INT_5_9_9_9_REV, 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1274 + * @tc.name testTexImage3D_UNSIGNED_INT_24_8 + * @tc.desc Test texImage3D. + */ + it('testTexImage3D_UNSIGNED_INT_24_8', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D test start ...66'); + console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); + gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, gl2 + .UNSIGNED_INT_24_8, 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(gl.INVALID_OPERATION); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1275 + * @tc.name testGetParameter_webgl2_45 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_45', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER0); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1276 + * @tc.name testGetParameter_webgl2_46 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_46', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER1); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1277 + * @tc.name testGetParameter_webgl2_47 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_47', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER2); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1278 + * @tc.name testGetParameter_webgl2_48 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_48', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER3); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1279 + * @tc.name testGetParameter_webgl2_49 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_49', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER4); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1280 + * @tc.name testGetParameter_webgl2_50 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_50', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER5); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1281 + * @tc.name testGetParameter_webgl2_51 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_51', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER6); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1282 + * @tc.name testGetParameter_webgl2_52 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_52', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER8); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1283 + * @tc.name testGetParameter_webgl2_53 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_53', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER9); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1284 + * @tc.name testGetParameter_webgl2_54 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_54', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER10); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1285 + * @tc.name testGetParameter_webgl2_55 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_55', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER11); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1286 + * @tc.name testGetParameter_webgl2_56 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_56', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER12); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1287 + * @tc.name testGetParameter_webgl2_57 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_57', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER13); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1288 + * @tc.name testGetParameter_webgl2_58 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_58', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER14); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1289 + * @tc.name testGetParameter_webgl2_59 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_59', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER15); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1290 + * @tc.name testGetParameter_webgl2_60 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl2_60', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl2.DRAW_BUFFER7); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1291 + * @tc.name testGetFramebufferAttachmentParameter3_1 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl2.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1292 + * @tc.name testGetFramebufferAttachmentParameter3_2 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl2.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1293 + * @tc.name testGetFramebufferAttachmentParameter3_3 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl2.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1294 + * @tc.name testGetFramebufferAttachmentParameter3_4 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl2.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1295 + * @tc.name testGetFramebufferAttachmentParameter3_5 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_5', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl2.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1296 + * @tc.name testGetFramebufferAttachmentParameter3_6 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_6', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl2.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1298 + * @tc.name testGetFramebufferAttachmentParameter3_8 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_8', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl2.FRAMEBUFFER_ATTACHMENT_RED_SIZE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1299 + * @tc.name testGetFramebufferAttachmentParameter3_9 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_9', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl2.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1300 + * @tc.name testGetFramebufferAttachmentParameter3_10 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_10', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + }) +} \ No newline at end of file diff --git a/graphic/webGL/src/main/js/test/WebGL.test14.js b/graphic/webGL/src/main/js/test/WebGL.test14.js new file mode 100644 index 0000000000000000000000000000000000000000..2b3087639b1f4be077282b2db7244021439c3c7a --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test14.js @@ -0,0 +1,998 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl14() { + describe('webgl1Test_webgl14', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_1301 + * @tc.name testGetFramebufferAttachmentParameter3_11 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_11', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl2.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1302 + * @tc.name testGetFramebufferAttachmentParameter3_12 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_12', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1303 + * @tc.name testGetFramebufferAttachmentParameter3_13 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_13', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1304 + * @tc.name testGetFramebufferAttachmentParameter3_14 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_14', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_OPERATION); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1306 + * @tc.name webgl_test_checkFramebufferStatus2_1 + * @tc.desc Test checkFramebufferStatus. + */ + it('webgl_test_checkFramebufferStatus2_1', 0, async function (done) { + //initContext(); + console.info("webgltest into checkFramebufferStatus"); + + var framebuffer = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + + const checkFramebufferStatus = gl.checkFramebufferStatus(gl2 + .FRAMEBUFFER_INCOMPLETE_MULTISAMPLE); + console.info("createFramebuffer --> bindFramebuffer --> checkFramebufferStatus: " + + checkFramebufferStatus); + expect(checkFramebufferStatus).assertEqual(0); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1307 + * @tc.name webgl_test_checkFramebufferStatus2_2 + * @tc.desc Test checkFramebufferStatus. + */ + it('webgl_test_checkFramebufferStatus2_2', 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_INCOMPLETE_ATTACHMENT); + console.info("createFramebuffer --> bindFramebuffer --> checkFramebufferStatus: " + + checkFramebufferStatus); + expect(checkFramebufferStatus).assertEqual(0); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1308 + * @tc.name webgl_test_checkFramebufferStatus2_3 + * @tc.desc Test checkFramebufferStatus. + */ + it('webgl_test_checkFramebufferStatus2_3', 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_INCOMPLETE_DIMENSIONS); + console.info("createFramebuffer --> bindFramebuffer --> checkFramebufferStatus: " + + checkFramebufferStatus); + expect(checkFramebufferStatus).assertEqual(0); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1309 + * @tc.name webgl_test_checkFramebufferStatus2_4 + * @tc.desc Test checkFramebufferStatus. + */ + it('webgl_test_checkFramebufferStatus2_4', 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_UNSUPPORTED); + console.info("createFramebuffer --> bindFramebuffer --> checkFramebufferStatus: " + + checkFramebufferStatus); + expect(checkFramebufferStatus).assertEqual(0); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1310 + * @tc.name testGetVertexAttribFirst_1 + * @tc.desc Test getVertexAttrib. + */ + it('testGetVertexAttribFirst_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); + const vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); + const shaderProgram = globalFunction(); + const aVertexPosition = gl.getAttribLocation(shaderProgram, "a_position"); + + gl.enableVertexAttribArray(aVertexPosition); + gl.vertexAttribPointer(aVertexPosition, 3, gl.FLOAT, false, 20, 0); + + gl.drawArrays(gl.TRIANGLES, 0, 8); + gl.vertexAttrib1f(0, 2.8); + const type = gl.getVertexAttrib(0, gl.CURRENT_VERTEX_ATTRIB); + console.info("getVertexAttrib: type" + type); + expect(type.toString()).assertEqual([2.799999952316284, 0, 0, 1].toString()); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1311 + * @tc.name testGetParameter_webgl_1 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.BLEND_EQUATION); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(1281); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1312 + * @tc.name testGetParameter_webgl_2 + * @tc.desc Test getParameter. + */ + it('testGetParameter_webgl_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.DEPTH_BITS); + // returns "33984" (0x84C0, gl.TEXTURE0 enum value) + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(1286); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1313 + * @tc.name testGetVertexAttribFirst_2 + * @tc.desc Test getVertexAttrib. + */ + it('testGetVertexAttribFirst_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); + const vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); + const shaderProgram = globalFunction(); + const aVertexPosition = gl.getAttribLocation(shaderProgram, "a_position"); + + gl.enableVertexAttribArray(aVertexPosition); + gl.vertexAttribPointer(aVertexPosition, 3, gl.FLOAT, false, 20, 0); + + gl.drawArrays(gl.TRIANGLES, 0, 8); + gl.vertexAttrib1f(0, 2.8); + const type = gl.getVertexAttrib(0, gl2.VERTEX_ATTRIB_ARRAY_INTEGER); + console.info("getVertexAttrib: type" + type); + expect(type).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1314 + * @tc.name testGetVertexAttribFirst_3 + * @tc.desc Test getVertexAttrib. + */ + it('testGetVertexAttribFirst_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); + const vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); + const shaderProgram = globalFunction(); + const aVertexPosition = gl.getAttribLocation(shaderProgram, "a_position"); + + gl.enableVertexAttribArray(aVertexPosition); + gl.vertexAttribPointer(aVertexPosition, 3, gl.FLOAT, false, 20, 0); + + gl.drawArrays(gl.TRIANGLES, 0, 8); + gl.vertexAttrib1f(0, 2.8); + const type = gl.getVertexAttrib(0, gl2.VERTEX_ATTRIB_ARRAY_DIVISOR); + console.info("getVertexAttrib: type" + type); + expect(type).assertEqual(0); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1315 + * @tc.name testGetTexParameterFirst_1 + * @tc.desc Test getTexParameter. + */ + it('testGetTexParameterFirst_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_NEAREST); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(gl.NEAREST_MIPMAP_NEAREST); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1316 + * @tc.name testGetTexParameterFirst_2 + * @tc.desc Test getTexParameter. + */ + it('testGetTexParameterFirst_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_LINEAR); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(gl.NEAREST_MIPMAP_LINEAR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1317 + * @tc.name testGetTexParameterFirst_3 + * @tc.desc Test getTexParameter. + */ + it('testGetTexParameterFirst_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(gl.LINEAR_MIPMAP_LINEAR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1318 + * @tc.name webgl_test_activeTexture_webgl_1 + * @tc.desc Test activeTexture. + */ + it('webgl_test_activeTexture_webgl_1', 0, async function (done) { + //initContext(); + console.info("webgltest into activeTexture"); + gl.activeTexture(gl.TEXTURE); + 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_1319 + * @tc.name testGetUniform_11 + * @tc.desc Test getUniform. + */ + it('testGetUniform_11', 0, async function (done) { + //initContext(); + console.info('jsWebGL getUniform test start ...' + JSON.stringify(gl)); + const programObj = globalFunction(); + + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + const uniform = gl.getUniform(programObj, uniformLocation); + let type = []; + if ((typeof uniform) === 'boolean') { + type = [gl.BOOL]; + } else if ((typeof uniform) === 'number') { + type = [gl.SAMPLER_2D, gl.SAMPLER_CUBE]; + } else { + type = [gl.FLOAT_VEC2, gl.FLOAT_VEC3, gl.FLOAT_VEC4, gl.INT_VEC2, gl.INT_VEC3, gl + .INT_VEC4, gl.FLOAT_MAT2, + gl.FLOAT_MAT3, gl.FLOAT_MAT4, gl.BOOL_VEC2, gl.BOOL_VEC3, gl.BOOL_VEC4 + ] + } + const typeBool = type.length > 0 + console.info('getUniformLocation uniform' + uniform); + expect(typeBool).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1320 + * @tc.name testGetTexParameterError_1 + * @tc.desc Test getTexParameter. + */ + it('testGetTexParameterError_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl2.TEXTURE_IMMUTABLE_FORMAT); + console.info('texParameterfValue' + texParameterValue); + const type = (texParameterValue === gl2.TEXTURE_IMMUTABLE_FORMAT); + expect(type).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1321 + * @tc.name testGetTexParameterError_2 + * @tc.desc Test getTexParameter. + */ + it('testGetTexParameterError_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_2D, gl2.TEXTURE_IMMUTABLE_LEVELS); + console.info('texParameterfValue' + texParameterValue); + const type = (texParameterValue === gl2.TEXTURE_IMMUTABLE_LEVELS); + expect(type).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1322 + * @tc.name testGetUniform_11_1 + * @tc.desc Test getUniform. + */ + it('testGetUniform_11_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getUniform test start ...' + JSON.stringify(gl)); + const programObj = globalFunction(); + + const uniformLocation = gl.getUniformLocation(programObj, "a_Position"); + const uniform = gl.getUniform(programObj, uniformLocation); + let type = []; + if ((typeof uniform) === 'number') { + type = [gl2.SIGNED_NORMALIZED, gl2.UNSIGNED_NORMALIZED, gl2.SAMPLER_3D, gl2 + .SAMPLER_2D_SHADOW, + gl2.SAMPLER_2D_ARRAY, gl2.SAMPLER_2D_ARRAY_SHADOW, gl2.SAMPLER_CUBE_SHADOW, gl2 + .INT_SAMPLER_2D, + gl2.INT_SAMPLER_3D, gl2.INT_SAMPLER_CUBE, gl2.INT_SAMPLER_2D_ARRAY, gl2 + .UNSIGNED_INT_SAMPLER_2D, + gl2.UNSIGNED_INT_SAMPLER_3D, gl2.UNSIGNED_INT_SAMPLER_CUBE, gl2 + .UNSIGNED_INT_SAMPLER_2D_ARRAY + ]; + } else { + type = [gl2.UNSIGNED_INT_VEC2, gl2.UNSIGNED_INT_VEC3, + gl2.UNSIGNED_INT_VEC4, gl2.FLOAT_MAT2x3, gl2.FLOAT_MAT2x4, gl2.FLOAT_MAT3x2, gl2 + .FLOAT_MAT3x4, + gl2.FLOAT_MAT4x2, gl2.FLOAT_MAT4x3, gl.BOOL_VEC2, gl.BOOL_VEC3, gl.BOOL_VEC4 + ] + } + const typeBool = type.length > 0 + console.info('getUniformLocation uniform' + uniform); + expect(typeBool).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1323 + * @tc.name testTexImage3D_INT_2_10_10_10_REV + * @tc.desc Test testTexImage3D. + */ + it('testTexImage3D_INT_2_10_10_10_REV', 0, async function (done) { + //initContext(); + try { + console.info('jsWebGL testTexImage3D test start ...66'); + console.info('jsWebGL testTexImage3D test start ...' + JSON.stringify(gl)); + gl2.texImage3D(gl2.TEXTURE_3D, 0, gl2.SRGB8_ALPHA8, 1, 1, 1, 0, gl.RGBA, gl2 + .INT_2_10_10_10_REV, 0); + const texImage3DError = gl.getError(); + console.info("texImage3DError: " + texImage3DError); + expect(texImage3DError).assertEqual(gl.INVALID_ENUM); + //deleteContext(); + done(); + } catch (e) { + console.log("testTexImage3D has failed for " + e) + expect(null).assertFail() + } + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1324 + * @tc.name testTexImage2D2_1 + * @tc.desc Test texImage2D. + */ + it('testTexImage2D2_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL2 texImage2D test start ...' + JSON.stringify(gl2)); + gl2.texImage2D(gl2.TEXTURE_2D, 0, gl2.SRGB, 512, 512, 0, gl.RGB, gl.UNSIGNED_BYTE, 0); + const errorCode = gl.getError(); + console.info("webgl2test texImage2D getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1325 + * @tc.name testGetTexParameter3_1 + * @tc.desc Test getTexParameter. + */ + it('testGetTexParameter3_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); + gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(gl.REPEAT); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1326 + * @tc.name testGetTexParameter3_2 + * @tc.desc Test getTexParameter. + */ + it('testGetTexParameter3_2', 0, async function (done) { + //initContext(); + console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); + gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(10497); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1327 + * @tc.name testGetTexParameter3_3 + * @tc.desc Test getTexParameter. + */ + it('testGetTexParameter3_3', 0, async function (done) { + //initContext(); + console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); + gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.MIRRORED_REPEAT); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(10497); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1328 + * @tc.name webgl_test_clearBufferfv_22 + * @tc.desc Test clearBufferfv. + */ + it('webgl_test_clearBufferfv_22', 0, async function (done) { + //initContext(); + console.info("webgltest into clearBufferfv"); + + gl2.clearBufferfv(gl2.INVALID_INDEX, 0, [0.0, 0.0, 0.0, 0.0]); + + let errorCode = gl.getError(); + console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_ENUM); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1329 + * @tc.name testGetFramebufferAttachmentParameter3_10_1 + * @tc.desc Test getFramebufferAttachmentParameter. + */ + it('testGetFramebufferAttachmentParameter3_10_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getFramebufferAttachmentParameter test start ...' + JSON.stringify( + gl)); + const renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, + renderBuffer); + const framebuffer = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl + .DEPTH_STENCIL_ATTACHMENT, + gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE); + console.info('Framebuffer' + framebuffer); + const errorCode = gl.getError(); + const type = (errorCode === gl.OUT_OF_MEMORY) + console.info("jsWebGL getFramebufferAttachmentParameter errorCode: " + errorCode); + expect(type).assertEqual(false); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1330 + * @tc.name testGetParameter_20_1 + * @tc.desc Test getParameter. + */ + it('testGetParameter_20_1', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + gl.activeTexture(gl.TEXTURE0); + var textureParameter = gl.getParameter(gl.BROWSER_DEFAULT_WEBGL); + console.info("activeTexture --> getParameter: " + textureParameter); + let errorCode = gl.getError(); + console.info("webgltest framebufferRenderbuffer getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1331 + * @tc.name webgl_test_clearBufferfv_22 + * @tc.desc Test clearBufferfv. + */ + it('webgl_test_clearBufferfv_22', 0, async function (done) { + //initContext(); + console.info("webgltest into clearBufferfv"); + + gl2.clearBufferfv(gl2.INVALID_INDEX, 0, [0.0, 0.0, 0.0, 0.0]); + + let errorCode = gl.getError(); + console.info("webgltest webgl_test_clearBufferfv getError: " + errorCode); + expect(errorCode).assertEqual(gl.INVALID_ENUM); + //deleteContext(); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1332 + * @tc.name testGetTexParameter3_4 + * @tc.desc Test getTexParameter. + */ + it('testGetTexParameter3_4', 0, async function (done) { + //initContext(); + console.info('jsWebGL getTexParameter test start ...' + JSON.stringify(gl)); + gl.texParameterf(gl.TEXTURE_2D, gl2.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE); + const texParameterValue = gl.getTexParameter(gl.TEXTURE_CUBE_MAP, gl2.TEXTURE_COMPARE_MODE); + console.info('texParameterfValue' + texParameterValue); + expect(texParameterValue).assertEqual(gl.COMPARE_REF_TO_TEXTURE); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1335 + * @tc.name testRangeMin + * @tc.desc Test RangeMin. + */ + it('testRangeMin', 0, async function (done) { + console.info('jsWebGL testRangeMin test start'); + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT).rangeMin; + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT).rangeMax; + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT).precision; + const errorCode = gl.getError(); + console.info("WebGLShaderPrecisionFormat getError: " + errorCode); + expect(errorCode).assertEqual(gl.NO_ERROR); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1337 + * @tc.name testRendingContextBase + * @tc.desc Test RendingContextBase. + */ + it('testRendingContextBase', 0, async function (done) { + console.info('jsWebGL testRendingContextBase test start'); + const buffer = gl.createBuffer(); + expect(typeof (buffer)).assertEqual('object'); + + var x1 = gl2.COLOR; + expect(x1).assertEqual(6144); + + var x2 = gl2.STENCIL; + expect(x2).assertEqual(6146); + + var x3 = gl2.MIN; + expect(x3).assertEqual(32775); + + var x4 = gl2.MAX; + expect(x4).assertEqual(32776); + + var x5 = gl2.RG; + expect(x5).assertEqual(33319); + + var x6 = gl2.SYNC_CONDITION; + expect(x6).assertEqual(37139); + + var x7 = gl2.SYNC_STATUS; + expect(x7).assertEqual(37140); + + var x8 = gl2.SYNC_FLAGS; + expect(x8).assertEqual(37141); + + var x9 = gl2.OBJECT_TYPE; + expect(x9).assertEqual(37138); + + var x10 = gl2.FRAMEBUFFER_DEFAULT; + expect(x10).assertEqual(33304); + + var x11 = gl2.RG8UI; + expect(x11).assertEqual(33336); + + var x12 = gl2.UNIFORM_IS_ROW_MAJOR; + expect(x12).assertEqual(35390); + + var x13 = gl2.ANY_SAMPLES_PASSED_CONSERVATIVE; + expect(x13).assertEqual(36202); + + var x14 = gl2.RGB10_A2; + expect(x14).assertEqual(32857); + + var y1 = gl.LUMINANCE_ALPHA; + expect(y1).assertEqual(6410); + + var y2 = gl.SHADER_TYPE; + expect(y2).assertEqual(35663); + + var y3 = gl.LINK_STATUS; + expect(y3).assertEqual(35714); + + var y4 = gl.VALIDATE_STATUS; + expect(y4).assertEqual(35715); + + var y5 = gl.VERTEX_ATTRIB_ARRAY_POINTER; + expect(y5).assertEqual(34373); + + var y6 = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME; + expect(y6).assertEqual(36049); + + var y7 = gl.CONTEXT_LOST_WEBGL; + expect(y7).assertEqual(37442); + + var y8 = gl.ACTIVE_ATTRIBUTES; + expect(y8).assertEqual(35721); + + done(); + }); + }) +} \ No newline at end of file diff --git a/graphic/webGL/src/main/js/test/WebGL.test15.js b/graphic/webGL/src/main/js/test/WebGL.test15.js new file mode 100644 index 0000000000000000000000000000000000000000..ff894e2433e3d6f595bdca0ddb29aff921255cfa --- /dev/null +++ b/graphic/webGL/src/main/js/test/WebGL.test15.js @@ -0,0 +1,525 @@ +/* + * 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 '@ohos/hypium' + +export default function webgl1Test_webgl5() { + describe('webgl1Test_webgl15', 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 el = global.el; + const el2 = global.el2; + // 获取webgl上下文 + gl = el.getContext('webgl'); + if (!gl) { + console.log('webgltest Failed to get the rendering context for WebGL'); + } + gl2 = el2.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_0220 + * @tc.name testGetParameter3 + * @tc.desc Test getParameter. + */ + it('testGetParameter3', 0, async function (done) { + //initContext(); + console.info('jsWebGL getParameter test start ...' + JSON.stringify(gl)); + const buffer = gl.getParameter(gl.ARRAY_BUFFER_BINDING); + console.info("buffer: " + buffer); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + const isBuffer = gl.isBuffer(buffer); + console.info("isBuffer: " + isBuffer); + expect(isBuffer).assertEqual(true); + done(); + }); + + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0231 + * @tc.name testGetVertexAttribFirst + * @tc.desc Test getVertexAttrib. + */ + it('testGetVertexAttribFirst', 0, async function (done) { + //initContext(); + console.info('jsWebGL getVertexAttrib test start ...' + JSON.stringify(gl)); + const vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); + const shaderProgram = globalFunction(); + const aVertexPosition = gl.getAttribLocation(shaderProgram, "a_position"); + + gl.enableVertexAttribArray(aVertexPosition); + gl.vertexAttribPointer(aVertexPosition, 3, gl.FLOAT, false, 20, 0); + + gl.drawArrays(gl.TRIANGLES, 0, 8); + gl.vertexAttrib1f(0, 2.8); + const type = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_ENABLED); + console.info("getVertexAttrib: type" + type); + expect(type).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0370 + * @tc.name testIsRenderbuffer_04 + * @tc.desc Test isRenderbuffer. + */ + it('testIsRenderbuffer_04', 0, async function (done) { + //initContext(); + console.info('jsWebGL testIsRenderbuffer_04 test start ...66'); + var texture = gl.createTexture(); + const isrenderbuffer = gl.isRenderbuffer(texture); + console.info("createRenderbuffer --> isRenderbuffer: " + isrenderbuffer); + expect(isrenderbuffer).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_0991 + * @tc.name testGetBufferParameter3 + * @tc.desc Test getBufferParameter. + */ + it('testGetBufferParameter3', 0, async function (done) { + //initContext(); + console.info('jsWebGL getBufferParameter test start ...' + JSON.stringify(gl)); + const buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW); + const bufferSize = gl.getBufferParameter(gl.ELEMENT_ARRAY_BUFFER, gl.BUFFER_SIZE); + console.info('bufferSize' + bufferSize); + expect(bufferSize).assertEqual(8); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1035 + * @tc.name testStencilMaskSeparate1 + * @tc.desc Test stencilMaskSeparate. + */ + it('testStencilMaskSeparate1', 0, async function (done) { + //initContext(); + console.info('jsWebGL stencilMaskSeparate test start ...' + JSON.stringify(gl)); + gl.stencilMaskSeparate(gl.BACK, 110101); + const stencilMaskSeparateParameter = gl.getParameter(gl.STENCIL_WRITEMASK); + console.info("stencilMaskSeparate stencilMaskSeparateParameter: " + + stencilMaskSeparateParameter); + expect(stencilMaskSeparateParameter).assertEqual(110101); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1338 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_0', 0, async function (done) { + console.info("webgltest into webglContextAttributes"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.alpha = true; + const alphaValue = ContextAttributesValue.alpha; + console.info("webgltest webglContextAttributes: " + alphaValue); + expect(alphaValue).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1339 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_1', 0, async function (done) { + console.info("webgltest into webglContextAttributes_1"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.antialias = true; + const antialiasValue = ContextAttributesValue.antialias; + console.info("webgltest webglContextAttributes_1: " + antialiasValue); + expect(antialiasValue).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1341 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_2', 0, async function (done) { + console.info("webgltest into webglContextAttributes_2"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.depth = true; + const depthValue = ContextAttributesValue.depth; + console.info("webgltest webglContextAttributes_2: " + depthValue); + expect(depthValue).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1342 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_3', 0, async function (done) { + console.info("webgltest into webglContextAttributes_3"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.failIfMajorPerformanceCaveat = false; + const failIfMajorPerformanceCaveatValue = ContextAttributesValue.failIfMajorPerformanceCaveat; + console.info("webgltest webglContextAttributes_3: " + failIfMajorPerformanceCaveatValue); + expect(failIfMajorPerformanceCaveatValue).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1343 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_4', 0, async function (done) { + console.info("webgltest into webglContextAttributes_4"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.desynchronized = false; + const desynchronizedValue = ContextAttributesValue.desynchronized; + console.info("webgltest webglContextAttributes_4: " + desynchronizedValue); + expect(desynchronizedValue).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1344 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_5', 0, async function (done) { + console.info("webgltest into webglContextAttributes_5"); + const ContextAttributesValue = gl.getContextAttributes(); + const powerPreferenceValue = ContextAttributesValue.powerPreference; + console.info("webgltest webglContextAttributes_5: " + powerPreferenceValue); + expect(powerPreferenceValue).assertEqual("default"); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1345 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_6', 0, async function (done) { + console.info("webgltest into webglContextAttributes_6"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.premultipliedAlpha = true; + const premultipliedAlphaValue = ContextAttributesValue.premultipliedAlpha; + console.info("webgltest webglContextAttributes_6: " + premultipliedAlphaValue); + expect(premultipliedAlphaValue).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1346 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_7', 0, async function (done) { + console.info("webgltest into webglContextAttributes_7"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.preserveDrawingBuffer = false; + const preserveDrawingBufferValue = ContextAttributesValue.preserveDrawingBuffer; + console.info("webgltest webglContextAttributes_7: " + preserveDrawingBufferValue); + expect(preserveDrawingBufferValue).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1347 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_8', 0, async function (done) { + console.info("webgltest into webglContextAttributes_8"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.stencil = false; + const stencilValue = ContextAttributesValue.stencil; + console.info("webgltest webglContextAttributes_8: " + stencilValue); + expect(stencilValue).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1348 + * @tc.name webgl_test_endTransformFeedback + * @tc.desc Test endTransformFeedback. + */ + it('webgl_test_endTransformFeedback', 0, async function (done) { + let transformFeedback = gl2.createTransformFeedback(); + gl2.endTransformFeedback(); + let errorCode = gl.getError(); + console.info("webgltest endTransformFeedback getError: " + errorCode); + expect(errorCode).assertLarger(gl.NO_ERROR); + //deleteContext(); + done(); + }); + }) +} \ No newline at end of file diff --git a/graphic/webGL/src/main/resources/base/element/string.json b/graphic/webGL/src/main/resources/base/element/string.json index 32842fc54d4861f14a47d12bd326fcc09d33cc47..7b50a247f8a6cff2e018b332f866a7fec176f272 100644 --- a/graphic/webGL/src/main/resources/base/element/string.json +++ b/graphic/webGL/src/main/resources/base/element/string.json @@ -7,6 +7,22 @@ { "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/graphic/windowStage/entry/src/main/ets/test/List.test.ets b/graphic/windowStage/entry/src/main/ets/test/List.test.ets index 5fcf104031c3f3ed65a3eb19502054af540fc515..a548c635d4584e7ecd7d79f3d4ee38d32e07c4c8 100644 --- a/graphic/windowStage/entry/src/main/ets/test/List.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/List.test.ets @@ -18,9 +18,8 @@ import windowRefactorInterfaceTest from './windowRefactorInterface.test' import displayAndWindowRefactorInterfaceTest from './displayAndWindowRefactorInterface.test' export default function testsuite() { - windowPromiseTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage) windowCallbackTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage) + windowPromiseTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage) windowRefactorInterfaceTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage) displayAndWindowRefactorInterfaceTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage) - } \ No newline at end of file diff --git a/graphic/windowStage/entry/src/main/ets/test/displayAndWindowRefactorInterface.test.ets b/graphic/windowStage/entry/src/main/ets/test/displayAndWindowRefactorInterface.test.ets index 33ef4bdf3af299e0ddf38205d7e75cad9caddd17..415df8478d47522dc8a2115a535215532ba436fa 100644 --- a/graphic/windowStage/entry/src/main/ets/test/displayAndWindowRefactorInterface.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/displayAndWindowRefactorInterface.test.ets @@ -113,23 +113,26 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta done(); } - function sleep(time) { - return new Promise(resolve => { - setTimeout(() => { + async function sleep(time) { + let timeoutId= null; + let promise = new Promise(resolve => { + timeoutId = setTimeout(() => { resolve('sleep finished'); }, time); }) + let result = await promise; + clearTimeout(timeoutId) } /** - * @tc.number SUB_WINDOW_GETALLDISPLAYS_JSAPI_001 - * @tc.name Test getAllDisplaysTest1 - * @tc.desc Gets all current display objects - */ + * @tc.number SUB_WINDOW_GETALLDISPLAYS_JSAPI_001 + * @tc.name Test getAllDisplaysTest1 + * @tc.desc Gets all current display objects + */ it('getAllDisplaysTest1', 0, async function (done) { let caseName = 'getAllDisplaysTest1'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin'); - display.getAllDisplays().then((data) => { + await display.getAllDisplays().then((data) => { console.info(msgStr + 'Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); expect(data[0].id != null).assertTrue(); expect(data[0].refreshRate != null).assertTrue(); @@ -152,10 +155,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta }); }) /** - * @tc.number SUB_WINDOW_GETALLDISPLAYS_JSAPI_002 - * @tc.name Test getAllDisplaysTest2 - * @tc.desc Gets all current display objects - */ + * @tc.number SUB_WINDOW_GETALLDISPLAYS_JSAPI_002 + * @tc.name Test getAllDisplaysTest2 + * @tc.desc Gets all current display objects + */ it('getAllDisplaysTest2', 0, async function (done) { let caseName = 'getAllDisplaysTest2'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -189,20 +192,17 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta }); }) /** - * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_001 - * @tc.name Test createWindowTest1 - * @tc.desc Verify the scenario of creating the application type window - */ + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_001 + * @tc.name Test createWindowTest1 + * @tc.desc Verify the scenario of creating the application type window + */ it('createWindowTest1', 0, async function (done) { let caseName = 'createWindowTest1'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin'); let loopCount = systemWindowTypeDicArr.length; console.log(msgStr + 'loopCount: ' + loopCount); - let num = 0 - getData(0, loopCount) - - async function getData(i, length) { + for(let i=0;i { - console.log(msgStr + 'ohosWindow.createWindow ' + tempType + 'catched, err: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.createWindow', done); - }); - console.log(msgStr + 'ohosWindow.createWindow ' + tempType + 'finished, wnd: ' + JSON.stringify(tempWnd)); - expect(!!tempWnd).assertTrue(); - num++; - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + console.log(msgStr + 'ohosWindow.createWindow ' + tempType + 'catched, err: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + return; + }); + console.log(msgStr + 'ohosWindow.createWindow ' + tempType + 'finished, wnd: ' + JSON.stringify(tempWnd)); + console.log(msgStr + 'ohosWindow.createWindow ' + tempType + 'finished, step: ' + i); + expect(!!tempWnd).assertTrue(); + await tempWnd.destroyWindow(); + if (i == loopCount-1) done(); } }) /** - * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_002 - * @tc.name Test createWindowTest2 - * @tc.desc Verify the scenario of creating a window with duplicate IDs - */ + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_002 + * @tc.name Test createWindowTest2 + * @tc.desc Verify the scenario of creating a window with duplicate IDs + */ it('createWindowTest2', 0, async function (done) { let caseName = 'createWindowTest2'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -248,16 +241,20 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let windowConfig = { name: windowId, windowType: 1, ctx: context }; + let ohosData; try { - let ohosData = await ohosWindow.createWindow(windowConfig).catch((err) => { + ohosData = await ohosWindow.createWindow(windowConfig).catch((err) => { console.log(msgStr + 'ohosWindow.createWindow 1 once err: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + expect().assertFail(); + done(); + return; }) expect(!!ohosData).assertTrue(); try { - let ohosDataError = await ohosWindow.createWindow(windowConfig).catch((errSencond) => { + let ohosDataError = await ohosWindow.createWindow(windowConfig).catch(async (errSencond) => { console.log(msgStr + 'ohosWindow.createWindow 1 twice err: ' + JSON.stringify(errSencond)); - expect(errSencond.code).assertEqual(1300002) + expect(errSencond.code).assertEqual(1300001) + await ohosData.destroyWindow(); done(); }) console.log(msgStr + 'ohosWindow.createWindow 1 twice ohosDataError: ' + JSON.stringify(ohosDataError)); @@ -269,14 +266,13 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } ; - }) /** - * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_004 - * @tc.name Test createWindowTest4 - * @tc.desc Verify the scenario of creating the application type window + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_004 + * @tc.name Test createWindowTest4 + * @tc.desc Verify the scenario of creating the application type window */ - it('createWindowTest4', 0, done => { + it('createWindowTest4', 0, async function (done) { sleep(1000) let caseName = 'createWindowTest4'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -291,43 +287,60 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let windowConfigTwo = { name: windIdTwo, windowType: tempType, ctx: context }; - try { - ohosWindow.createWindow(windowConfig, (err, data) => { - if (err && err.code) { - console.log(msgStr + 'ohosWindow.createWindow err.code==' + JSON.stringify(err.code)) - return; - } - console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data)); - try { - expect(!!data).assertTrue(); - } catch (error) { - console.info(`ohosWindow.crreateWindow catch error: ${JSON.stringify(error)}`) - } + + function createFirstWindow() { + return new Promise((resolve, reject) => { try { - ohosWindow.createWindow(windowConfigTwo, (err, dataTwo) => { - console.log(msgStr + 'ohosWindow.createWindow two twice' + JSON.stringify(err)); + ohosWindow.createWindow(windowConfig, (err, data) => { if (err && err.code) { - console.log(msgStr + 'ohosWindow.createWindow two twice data: ' + JSON.stringify(dataTwo)); - unexpectedError(err, caseName, 'ohosWindow.createWindow', done); - } else { - console.log(msgStr + 'ohosWindow.createWindow two success twice data: ' + JSON.stringify(dataTwo)); + console.log(msgStr + 'ohosWindow.createWindow err.code==' + JSON.stringify(err.code)) + try { + expect().assertFail(); + } catch (err) { + console.log(msgStr + 'assertFail catch' + JSON.stringify(err)); + } done(); + reject(null) } + console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data)); + resolve(data) }) } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } ; }) + } + + let dataOne; + dataOne = await createFirstWindow(); + expect(!!dataOne).assertTrue(); + try { + ohosWindow.createWindow(windowConfigTwo, async (err, dataTwo) => { + console.log(msgStr + 'ohosWindow.createWindow two twice' + JSON.stringify(err)); + if (err && err.code) { + console.log(msgStr + 'ohosWindow.createWindow two twice data: ' + JSON.stringify(dataTwo)); + try { + expect().assertFail(); + } catch (error) { + console.info(`ohosWindow.createWindow two twice catch error: ${JSON.stringify(error)}`) + } + } else { + console.log(msgStr + 'ohosWindow.createWindow two success twice data: ' + JSON.stringify(dataTwo)); + await dataOne.destroyWindow(); + await dataTwo.destroyWindow(); + } + done(); + }) } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } ; }) /** - * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_005 - * @tc.name Test createWindowTest5 - * @tc.desc Verify the scenario of creating the system type window + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_005 + * @tc.name Test createWindowTest5 + * @tc.desc Verify the scenario of creating the system type window */ it('createWindowTest5', 0, done => { let caseName = 'createWindowTest5'; @@ -342,15 +355,20 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta name: windId, windowType: tempType, ctx: context }; try { - ohosWindow.createWindow(windowConfig, (err, data) => { + ohosWindow.createWindow(windowConfig, async (err, data) => { if (err && err.code) { - unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done); + try { + expect().assertFail(); + } catch (error) { + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(error)}`) + } + done(); return; } try { expect(!!data).assertTrue(); } catch (error) { - console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`) + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(error)}`) } let tempWnd = data console.log(msgStr + 'ohosWindow.createWindow ' + tempType + ' wnd: ' + tempWnd); @@ -358,6 +376,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let proData = tempWnd.getWindowProperties(); console.log(msgStr + 'proData.type:' + proData.type); expect(proData.type == tempType).assertTrue(); + await tempWnd.destroyWindow(); done(); } catch (exception) { console.error(msgStr + 'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); @@ -370,11 +389,11 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_006 - * @tc.name Test createWindowTest6 - * @tc.desc Verify the scenario of creating a window with duplicate IDs + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_006 + * @tc.name Test createWindowTest6 + * @tc.desc Verify the scenario of creating a window with duplicate IDs */ - it('createWindowTest6', 0, done => { + it('createWindowTest6', 0, async function (done) { let caseName = 'createWindowTest6'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin'); @@ -382,50 +401,60 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let winsowConfig = { name: windowId, windowType: 1, ctx: context }; - try { - ohosWindow.createWindow(winsowConfig, (err, data) => { - console.log(msgStr + 'ohosWindow.createWindow 1 once err: ' + JSON.stringify(err)); - if (err && err.code) { - unexpectedError(err, caseName, 'ohosWindow.createWindow', done); - return - } - try { - expect(!!data).assertTrue(); - } catch (error) { - console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`) - } + + function createFirstWindow() { + return new Promise((resolve, reject) => { try { - ohosWindow.createWindow(winsowConfig, (err, dataTwo) => { - console.log(msgStr + 'ohosWindow.createWindow 1 twice err: ' + JSON.stringify(err)); + ohosWindow.createWindow(winsowConfig, (err, data) => { + console.log(msgStr + 'ohosWindow.createWindow 1 once err: ' + JSON.stringify(err)); if (err && err.code) { - console.log(msgStr + 'ohosWindow.createWindow 1 twice data: ' + JSON.stringify(dataTwo)); try { - expect(err.code).assertEqual(1300002) + expect().assertFail(); } catch (error) { - console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`) + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(error)}`) } done(); - } else { - unexpectedError(err, caseName, 'ohosWindow.createWindow', done); - console.log(msgStr + 'ohosWindow.createWindow 1 twice data: ' + JSON.stringify(dataTwo)); + reject(null) } + resolve(data) }) } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } ; + }) + } + let dataOne; + dataOne = await createFirstWindow(); + expect(!!dataOne).assertTrue(); + try { + ohosWindow.createWindow(winsowConfig, async (err, dataTwo) => { + console.log(msgStr + 'ohosWindow.createWindow 1 twice err: ' + JSON.stringify(err)); + if (err && err.code) { + console.log(msgStr + 'ohosWindow.createWindow 1 twice data: ' + JSON.stringify(dataTwo)); + try { + expect(err.code).assertEqual(1300001) + } catch (error) { + console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`) + } + } else { + console.log(msgStr + 'ohosWindow.createWindow 1 twice data: ' + JSON.stringify(dataTwo)); + } + await dataOne.destroyWindow(); + done(); }) } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; - }) /** - * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_001 - * @tc.name Test getWindowAvoidAreaTest1 - * @tc.desc Obtain the area that the window content avoids + * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_001 + * @tc.name Test getWindowAvoidAreaTest1 + * @tc.desc Obtain the area that the window content avoids */ it('getWindowAvoidAreaTest1', 0, async function (done) { let caseName = 'getWindowAvoidAreaTest1'; @@ -456,9 +485,9 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta }) /** - * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_002 - * @tc.name Test getWindowAvoidAreaTest2 - * @tc.desc Obtain the area that the window content avoids + * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_002 + * @tc.name Test getWindowAvoidAreaTest2 + * @tc.desc Obtain the area that the window content avoids */ it('getWindowAvoidAreaTest2', 0, async function (done) { let caseName = 'getWindowAvoidAreaTest2'; @@ -489,9 +518,9 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_003 - * @tc.name Test getWindowAvoidAreaTest3 - * @tc.desc Obtain the area that the window content avoids + * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_003 + * @tc.name Test getWindowAvoidAreaTest3 + * @tc.desc Obtain the area that the window content avoids */ it('getWindowAvoidAreaTest3', 0, async function (done) { let caseName = 'getWindowAvoidAreaTest3'; @@ -521,9 +550,9 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_004 - * @tc.name Test getWindowAvoidAreaTest4 - * @tc.desc Obtain the area that the window content avoids + * @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_004 + * @tc.name Test getWindowAvoidAreaTest4 + * @tc.desc Obtain the area that the window content avoids */ it('getWindowAvoidAreaTest4', 0, async function (done) { let caseName = 'getWindowAvoidAreaTest4'; @@ -553,9 +582,9 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_GETWINDOWPROPERTIES_JSAPI_001 - * @tc.name Test getWindowPropertiesTest1 - * @tc.desc Gets the properties of the current window + * @tc.number SUB_WINDOW_GETWINDOWPROPERTIES_JSAPI_001 + * @tc.name Test getWindowPropertiesTest1 + * @tc.desc Gets the properties of the current window */ it('getWindowPropertiesTest1', 0, async function (done) { let caseName = 'getWindowPropertiesTest1'; @@ -584,6 +613,8 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta done(); } catch (exception) { console.error(msgStr + 'Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; } catch (exception) { @@ -592,10 +623,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_GETLASTWINDOW_JSAPI_001 - * @tc.name Test getLastWindowTest1 - * @tc.desc Get the final show window - */ + * @tc.number SUB_WINDOW_GETLASTWINDOW_JSAPI_001 + * @tc.name Test getLastWindowTest1 + * @tc.desc Get the final show window + */ it('getLastWindowTest1', 0, async function (done) { let caseName = 'getLastWindowTest1'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -604,20 +635,23 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta try { let lastWindow = await ohosWindow.getLastWindow(context).catch((err) => { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + expect().assertFail(); + done(); }) expect(lastWindow != null).assertTrue(); done(); } catch (exception) { console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_GETLASTWINDOW_JSAPI_002 - * @tc.name Test getLastWindowTest2 - * @tc.desc Get the final show window - */ + * @tc.number SUB_WINDOW_GETLASTWINDOW_JSAPI_002 + * @tc.name Test getLastWindowTest2 + * @tc.desc Get the final show window + */ it('getLastWindowTest2', 0, async function (done) { let caseName = 'getLastWindowTest2'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -626,7 +660,12 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ohosWindow.getLastWindow(context, (err, data) => { if (err.code) { console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + try { + expect().assertFail(); + } catch (error) { + console.info(msgStr + `ohosWindow.getLastWindow catch error: ${JSON.stringify(error)}`) + } + done(); return; } console.info(msgStr + 'Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); @@ -638,10 +677,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_SHOWWINDOW_JSAPI_001 - * @tc.name Test showWindowTest1 - * @tc.desc show window - */ + * @tc.number SUB_WINDOW_SHOWWINDOW_JSAPI_001 + * @tc.name Test showWindowTest1 + * @tc.desc show window + */ it('showWindowTest1', 0, async function (done) { let caseName = 'showWindowTest1'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -654,27 +693,32 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let tempWnd = null; try { tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { - unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + expect().assertFail(); + done(); }); console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + JSON.stringify(tempWnd)); expect(!!tempWnd).assertTrue(); - tempWnd.showWindow().then((data) => { + await tempWnd.showWindow().then(async (data) => { console.info(msgStr + 'Succeeded in showing the window. Data: ' + JSON.stringify(data)); + await tempWnd.destroyWindow(); done(); }).catch((err) => { console.error(msgStr + 'Failed to show the window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.showWindow', done); + expect().assertFail(); + done(); }) } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_SHOWWINDOW_JSAPI_002 - * @tc.name Test showWindowTest2 - * @tc.desc show window - */ + * @tc.number SUB_WINDOW_SHOWWINDOW_JSAPI_002 + * @tc.name Test showWindowTest2 + * @tc.desc show window + */ it('showWindowTest2', 0, async function (done) { let caseName = 'showWindowTest2'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -684,38 +728,55 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let winsowConfig = { name: windowId, windowType: baseWndType, ctx: context }; - try { - ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { - console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); - if (create_err && create_err.code) { - unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); - return; - } + + function createFirstWindow() { + return new Promise((resolve, reject) => { try { - expect(!!create_data).assertTrue(); - } catch (error) { - console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`) + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + try { + expect().assertFail(); + } catch (err) { + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(err)}`) + } + done(); + reject(null) + } + resolve(create_data) + }) + } catch (exception) { + console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } - create_data.showWindow((err, data) => { - if (err.code) { - console.error(msgStr + 'Failed to show the window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.createWindow', done); - return; - } - console.info(msgStr + 'Succeeded in showing the window. Data: ' + JSON.stringify(data)); - done(); - }) + ; }) - } catch (exception) { - console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } - ; + + let winData; + winData = await createFirstWindow(); + expect(!!winData).assertTrue(); + winData.showWindow(async (err, data) => { + if (err.code) { + console.error(msgStr + 'Failed to show the window. Cause: ' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (err) { + console.info(msgStr + `ohosWindow.showWindow catch error: ${JSON.stringify(err)}`) + } + done(); + return; + } + console.info(msgStr + 'Succeeded in showing the window. Data: ' + JSON.stringify(data)); + await winData.destroyWindow(); + done(); + }) + }) /** - * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_001 - * @tc.name Test moveWindowToTest1 - * @tc.desc Set the position of a window. - */ + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_001 + * @tc.name Test moveWindowToTest1 + * @tc.desc Set the position of a window. + */ it('moveWindowToTest1', 0, async function (done) { let caseName = 'moveWindowToTest1'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -726,34 +787,43 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta name: windowId, windowType: baseWndType, ctx: context }; try { - ohosWindow.createWindow(windowConfig).then((wnd) => { + await ohosWindow.createWindow(windowConfig).then(async (wnd) => { console.info(msgStr + 'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd)); expect(wnd != null).assertTrue(); try { - wnd.moveWindowTo(300, 300).then(() => { + await wnd.moveWindowTo(300, 300).then(async () => { console.info(msgStr + 'Succeeded in moving the window.'); + await wnd.destroyWindow(); done(); - }).catch((err) => { + }).catch(async (err) => { console.error(msgStr + 'Failed to move the window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done); + expect().assertFail(); + await wnd.destroyWindow(); + done(); }); } catch (exception) { console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }).catch((err) => { console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + done(); }); } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_002 - * @tc.name Test moveWindowToTest2 - * @tc.desc Set the position of a window. - */ + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_002 + * @tc.name Test moveWindowToTest2 + * @tc.desc Set the position of a window. + */ it('moveWindowToTest2', 0, async function (done) { let caseName = 'moveWindowToTest2'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -764,34 +834,43 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta name: windowId, windowType: baseWndType, ctx: context }; try { - ohosWindow.createWindow(windowConfig).then((wnd) => { + await ohosWindow.createWindow(windowConfig).then(async (wnd) => { console.info(msgStr + 'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd)); expect(wnd != null).assertTrue(); try { - wnd.moveWindowTo(100, 50).then(() => { + await wnd.moveWindowTo(100, 50).then(async () => { console.info(msgStr + 'Succeeded in moving the window.'); + await wnd.destroyWindow(); done(); - }).catch((err) => { + }).catch(async (err) => { console.error(msgStr + 'Failed to move the window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done); + expect().assertFail(); + await wnd.destroyWindow(); + done(); }); } catch (exception) { console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }).catch((err) => { console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + done(); }); } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_003 - * @tc.name Test moveWindowToTest3 - * @tc.desc Set the position of a window. - */ + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_003 + * @tc.name Test moveWindowToTest3 + * @tc.desc Set the position of a window. + */ it('moveWindowToTest3', 0, async function (done) { let caseName = 'moveWindowToTest3'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -802,34 +881,43 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta name: windowId, windowType: baseWndType, ctx: context }; try { - ohosWindow.createWindow(windowConfig).then((wnd) => { + await ohosWindow.createWindow(windowConfig).then(async (wnd) => { console.info(msgStr + 'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd)); expect(wnd != null).assertTrue(); try { - wnd.moveWindowTo(20000, 20000).then(() => { + await wnd.moveWindowTo(20000, 20000).then(async () => { console.info(msgStr + 'Succeeded in moving the window.'); + await wnd.destroyWindow(); done(); - }).catch((err) => { + }).catch(async (err) => { console.error(msgStr + 'Failed to move the window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done); + expect().assertFail(); + await wnd.destroyWindow(); + done(); }); } catch (exception) { console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }).catch((err) => { console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + done(); }); } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_004 - * @tc.name Test moveWindowToTest4 - * @tc.desc Set the position of a window. - */ + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_004 + * @tc.name Test moveWindowToTest4 + * @tc.desc Set the position of a window. + */ it('moveWindowToTest4', 0, async function (done) { let caseName = 'moveWindowToTest4'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -840,34 +928,43 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta name: windowId, windowType: baseWndType, ctx: context }; try { - ohosWindow.createWindow(windowConfig).then((wnd) => { + await ohosWindow.createWindow(windowConfig).then(async (wnd) => { console.info(msgStr + 'Succeeded in obtaining the top window. Data: ' + JSON.stringify(wnd)); expect(wnd != null).assertTrue(); try { - wnd.moveWindowTo(-200, -200).then(() => { + await wnd.moveWindowTo(-200, -200).then(async () => { console.info(msgStr + 'Succeeded in moving the window.'); + await wnd.destroyWindow(); done(); - }).catch((err) => { + }).catch(async (err) => { console.error(msgStr + 'Failed to move the window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'tempWnd.moveWindowTo', done); + expect().assertFail(); + await wnd.destroyWindow(); + done(); }); } catch (exception) { console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }).catch((err) => { console.error(msgStr + 'Failed to obtain the top window. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + done(); }); } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_005 - * @tc.name Test moveWindowToTest5 - * @tc.desc Set the position of a window. - */ + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_005 + * @tc.name Test moveWindowToTest5 + * @tc.desc Set the position of a window. + */ it('moveWindowToTest5', 0, async function (done) { let caseName = 'moveWindowToTest5'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -877,38 +974,57 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let winsowConfig = { name: windowId, windowType: baseWndType, ctx: context }; - try { - ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { - console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); - if (create_err && create_err.code) { - unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); - return; - } + function createFirstWindow() { + return new Promise((resolve, reject) => { try { - create_data.moveWindowTo(300, 300, (err, data) => { - if (err.code) { - console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done); - return; + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + try { + expect().assertFail(); + } catch (err) { + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(err)}`) + } + done(); + reject(null) } - console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data)); - done(); + resolve(create_data) }) } catch (exception) { - console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception)); + console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } ; }) - } catch (exception) { - console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } - ; + let winData; + winData = await createFirstWindow(); + expect(!!winData).assertTrue(); + try { + winData.moveWindowTo(300, 300, async (err, data) => { + if (err.code) { + console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (err) { + console.log(msgStr + 'ohosWindow.moveWindow catch' + JSON.stringify(err)); + } + await winData.destroyWindow(); + done(); + return; + } + console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data)); + await winData.destroyWindow(); + done(); + }) + } catch (exception) { + console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception)); + }; }) /** - * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_006 - * @tc.name Test moveWindowToTest6 - * @tc.desc Set the position of a window. - */ + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_006 + * @tc.name Test moveWindowToTest6 + * @tc.desc Set the position of a window. + */ it('moveWindowToTest6', 0, async function (done) { let caseName = 'moveWindowToTest6'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -918,38 +1034,57 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let winsowConfig = { name: windowId, windowType: baseWndType, ctx: context }; - try { - ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { - console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); - if (create_err && create_err.code) { - unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); - return; - } + function createFirstWindow() { + return new Promise((resolve, reject) => { try { - create_data.moveWindowTo(100, 50, (err, data) => { - if (err.code) { - console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done); - return; + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + try { + expect().assertFail(); + } catch (err) { + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(err)}`) + } + done(); + reject(null) } - console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data)); - done(); + resolve(create_data) }) } catch (exception) { - console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception)); + console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } ; }) - } catch (exception) { - console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } - ; + let winData; + winData = await createFirstWindow(); + expect(!!winData).assertTrue(); + try { + winData.moveWindowTo(100, 50, async (err, data) => { + if (err.code) { + console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (err) { + console.log(msgStr + 'assertFail catch' + JSON.stringify(err)); + } + await winData.destroyWindow(); + done(); + return; + } + console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data)); + await winData.destroyWindow(); + done(); + }) + } catch (exception) { + console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception)); + }; }) /** - * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_007 - * @tc.name Test moveWindowToTest7 - * @tc.desc Set the position of a window. - */ + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_007 + * @tc.name Test moveWindowToTest7 + * @tc.desc Set the position of a window. + */ it('moveWindowToTest7', 0, async function (done) { let caseName = 'moveWindowToTest7'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -959,38 +1094,57 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let winsowConfig = { name: windowId, windowType: baseWndType, ctx: context }; - try { - ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { - console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); - if (create_err && create_err.code) { - unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); - return; - } + function createFirstWindow() { + return new Promise((resolve, reject) => { try { - create_data.moveWindowTo(20000, 20000, (err, data) => { - if (err.code) { - console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done); - return; + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + try { + expect().assertFail(); + } catch (err) { + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(err)}`) + } + done(); + reject(null) } - console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data)); - done(); + resolve(create_data) }) } catch (exception) { - console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception)); + console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } ; }) - } catch (exception) { - console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } - ; + let winData; + winData = await createFirstWindow(); + expect(!!winData).assertTrue(); + try { + winData.moveWindowTo(20000, 20000, async (err, data) => { + if (err.code) { + console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (err) { + console.log(msgStr + 'assertFail catch' + JSON.stringify(err)); + } + await winData.destroyWindow(); + done(); + return; + } + console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data)); + await winData.destroyWindow(); + done(); + }) + } catch (exception) { + console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception)); + }; }) /** - * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_008 - * @tc.name Test moveWindowToTest8 - * @tc.desc Set the position of a window. - */ + * @tc.number SUB_WINDOW_MOVEWINDOWTO_JSAPI_008 + * @tc.name Test moveWindowToTest8 + * @tc.desc Set the position of a window. + */ it('moveWindowToTest8', 0, async function (done) { let caseName = 'moveWindowToTest8'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1000,38 +1154,57 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let winsowConfig = { name: windowId, windowType: baseWndType, ctx: context }; - try { - ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { - console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); - if (create_err && create_err.code) { - unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); - return; - } + function createFirstWindow() { + return new Promise((resolve, reject) => { try { - create_data.moveWindowTo(-200, -200, (err, data) => { - if (err.code) { - console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.moveWindowTo', done); - return; - } - console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data)); - done(); + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + try { + expect().assertFail(); + } catch (err) { + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(err)}`) + } + done(); + reject(null) + } + resolve(create_data) }) } catch (exception) { - console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception)); + console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } ; }) - } catch (exception) { - console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } - ; + let winData; + winData = await createFirstWindow(); + expect(!!winData).assertTrue(); + try { + winData.moveWindowTo(-200, -200, async (err, data) => { + if (err.code) { + console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (err) { + console.log(msgStr + 'assertFail catch' + JSON.stringify(err)); + } + await winData.destroyWindow(); + done(); + return; + } + console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data)); + await winData.destroyWindow(); + done(); + }) + } catch (exception) { + console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(exception)); + }; }) /** - * @tc.number SUB_WINDOW_RESIZE_JSAPI_001 - * @tc.name Test resizeTest1 - * @tc.desc Set the size of a window - */ + * @tc.number SUB_WINDOW_RESIZE_JSAPI_001 + * @tc.name Test resizeTest1 + * @tc.desc Set the size of a window + */ it('resizeTest1', 0, async function (done) { let caseName = 'resizeTest1'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1049,27 +1222,34 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); expect(!!tempWnd).assertTrue(); try { - tempWnd.resize(200, 600).then((data) => { + await tempWnd.resize(200, 600).then(async (data) => { console.info(msgStr + 'Succeeded in changing the window size. Data:' + JSON.stringify(data)); + await tempWnd.destroyWindow(); done(); - }).catch((err) => { + }).catch(async (err) => { console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'tempWnd.resize', done); + expect().assertFail(); + await tempWnd.destroyWindow(); + done(); }) } catch (exception) { console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_RESIZE_JSAPI_002 - * @tc.name Test resizeTest2 - * @tc.desc Set the size of a window - */ + * @tc.number SUB_WINDOW_RESIZE_JSAPI_002 + * @tc.name Test resizeTest2 + * @tc.desc Set the size of a window + */ it('resizeTest2', 0, async function (done) { let caseName = 'resizeTest2'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1087,27 +1267,34 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); expect(!!tempWnd).assertTrue(); try { - tempWnd.resize(20000, 20000).then((data) => { + await tempWnd.resize(20000, 20000).then(async (data) => { console.info(msgStr + 'Succeeded in changing the window size. Data:' + JSON.stringify(data)); + await tempWnd.destroyWindow(); done(); - }).catch((err) => { + }).catch(async (err) => { console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'tempWnd.resize', done); + expect().assertFail(); + await tempWnd.destroyWindow(); + done(); }) } catch (exception) { console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_RESIZE_JSAPI_003 - * @tc.name Test resizeTest3 - * @tc.desc Set the size of a window - */ + * @tc.number SUB_WINDOW_RESIZE_JSAPI_003 + * @tc.name Test resizeTest3 + * @tc.desc Set the size of a window + */ it('resizeTest3', 0, async function (done) { let caseName = 'resizeTest3'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1120,35 +1307,42 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let tempWnd = null; try { tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { - unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + expect().assertFail(); + done(); + return; }); console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); expect(!!tempWnd).assertTrue(); try { - tempWnd.resize(0, 0).then((data) => { + await tempWnd.resize(0, 0).then(async (data) => { console.info(msgStr + 'Succeeded in changing the window size. Data:' + JSON.stringify(data)); + await tempWnd.destroyWindow(); done(); - }).catch((err) => { + }).catch(async (err) => { console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(err)); expect(err.code).assertEqual(401); + await tempWnd.destroyWindow(); done(); }) } catch (exception) { console.error(msgStr + 'try catch Failed to change the window size. Cause: ' + JSON.stringify(exception)); expect(exception.code).assertEqual(401); + await tempWnd.destroyWindow(); done(); } ; } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_RESIZE_JSAPI_004 - * @tc.name Test resizeTest4 - * @tc.desc Set the size of a window - */ + * @tc.number SUB_WINDOW_RESIZE_JSAPI_004 + * @tc.name Test resizeTest4 + * @tc.desc Set the size of a window + */ it('resizeTest4', 0, async function (done) { let caseName = 'resizeTest4'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1161,35 +1355,42 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let tempWnd = null; try { tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { - unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + expect().assertFail(); + done(); + return; }); console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); expect(!!tempWnd).assertTrue(); try { - tempWnd.resize(-1, -1).then((data) => { + await tempWnd.resize(-1, -1).then(async (data) => { console.info(msgStr + 'Succeeded in changing the window size. Data:' + JSON.stringify(data)); + await tempWnd.destroyWindow(); done(); - }).catch((err) => { + }).catch(async (err) => { console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(err)); expect(err.code).assertEqual(401); + await tempWnd.destroyWindow(); done(); }) } catch (exception) { console.error(msgStr + 'try catch Failed to change the window size. Cause: ' + JSON.stringify(exception)); expect(exception.code).assertEqual(401); + await tempWnd.destroyWindow(); done(); } ; } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_RESIZE_JSAPI_005 - * @tc.name Test resizeTest5 - * @tc.desc Set the size of a window - */ + * @tc.number SUB_WINDOW_RESIZE_JSAPI_005 + * @tc.name Test resizeTest5 + * @tc.desc Set the size of a window + */ it('resizeTest5', 0, async function (done) { let caseName = 'resizeTest5'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1202,44 +1403,39 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let tempWnd = null; try { tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { - unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + expect().assertFail(); + done(); + return; }); console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + tempWnd); expect(!!tempWnd).assertTrue(); - getData(1, 5) - - function getData(i, length) { - try { - tempWnd.resize(100, 100).then((data) => { - console.info(msgStr + 'Succeeded in changing the window size. Data:' + JSON.stringify(data)); - done(); - }).catch((err) => { - console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(err)); - expect(err.code).assertEqual(6); - if (++i <= length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + console.error(msgStr + 'Failed to change the window size. Cause: ' + JSON.stringify(err)); + expect(err.code).assertEqual(6); + done() + return; + }) + console.log(msgStr + 'success resize current step:' + i) + if(i==4){ + console.log(msgStr + 'finish resize current step:' + i) + done() } - ; } + await tempWnd.destroyWindow(); } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_RESIZE_JSAPI_006 - * @tc.name Test resizeTest6 - * @tc.desc Set the size of a window - */ + * @tc.number SUB_WINDOW_RESIZE_JSAPI_006 + * @tc.name Test resizeTest6 + * @tc.desc Set the size of a window + */ it('resizeTest6', 0, async function (done) { let caseName = 'resizeTest6'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1249,93 +1445,133 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let winsowConfig = { name: windowId, windowType: baseWndType, ctx: context }; - try { - ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { - console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); - if (create_err && create_err.code) { - unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); - return; - } + function createFirstWindow() { + return new Promise((resolve, reject) => { try { - create_data.resize(200, 200, (err) => { - if (err.code) { - console.error(msgStr + 'Failed to change the window size. Cause:' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.resize', done); - return; + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + try { + expect().assertFail(); + } catch (err) { + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(err)}`) + } + done(); + reject(null) } - console.info(msgStr + 'Succeeded in changing the window size.'); - done(); - }); + resolve(create_data) + }) } catch (exception) { - console.error(msgStr + 'Failed to change the window size. Cause:' + JSON.stringify(exception)); + console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } ; }) - } catch (exception) { - console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } - ; + + let winData; + winData = await createFirstWindow(); + expect(!!winData).assertTrue(); + try { + winData.resize(200, 200, async (err) => { + if (err.code) { + console.error(msgStr + 'Failed to change the window size. Cause:' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (err) { + console.log(msgStr + 'assertFail catch' + JSON.stringify(err)); + } + await winData.destroyWindow(); + done(); + return; + } + console.info(msgStr + 'Succeeded in changing the window size.'); + await winData.destroyWindow(); + done(); + }); + } catch (exception) { + console.error(msgStr + 'Failed to change the window size. Cause:' + JSON.stringify(exception)); + }; }) /** - * @tc.number SUB_WINDOW_RESIZE_JSAPI_007 - * @tc.name Test resizeTest7 - * @tc.desc Set the size of a window - */ + * @tc.number SUB_WINDOW_RESIZE_JSAPI_007 + * @tc.name Test resizeTest7 + * @tc.desc Set the size of a window + */ it('resizeTest7', 0, async function (done) { - let caseName = 'resizeTest6'; + let caseName = 'resizeTest7'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin'); let baseWndType = 1; let windowId = 'resizeTest7'; - let width = 100; - let height = 100; let winsowConfig = { name: windowId, windowType: baseWndType, ctx: context }; - try { - ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { - console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); - if (create_err && create_err.code) { - unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); - return; - } - getData(1, 5) - - function getData(i, length) { - width = width * i; - height = height * i; - try { - create_data.resize(width, height, (err) => { - if (err.code) { - console.error(msgStr + 'Failed to change the window size. Cause:' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.resize', done); - return; - } - console.info(msgStr + 'Succeeded in changing the window size.'); - if (++i <= length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + try { + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + try { + expect().assertFail(); + } catch (err) { + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(err)}`) } done(); - }); - } catch (exception) { - console.error(msgStr + 'Failed to change the window size. Cause:' + JSON.stringify(exception)); - } - ; + reject(null) + } + resolve(create_data) + }) + } catch (exception) { + console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } + ; }) - } catch (exception) { - console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } - ; + function resizeFun(width, height,i){ + console.log(msgStr + 'resize begin step:'+i) + return new Promise((resolve,reject)=>{ + try { + winData.resize(width, height, async (err) => { + if (err.code) { + console.error(msgStr + 'Failed to change the window size. Cause:' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (err) { + console.log(msgStr + 'assertFail catch' + JSON.stringify(err)); + } + done(); + reject(null) + } + console.info(msgStr + 'Succeeded in changing the window size. step:'+i); + resolve(true) + }); + } catch (exception) { + console.error(msgStr + 'Failed to change the window size. Cause:' + JSON.stringify(exception)); + }; + }) + } + let winData; + winData = await createFirstWindow(); + expect(!!winData).assertTrue(); + let width = 100; + let height = 100; + for(let i=1;i<5;i++){ + width = width * i; + height = height * i; + await resizeFun(width, height,i); + if(i==4){ + console.log(msgStr + 'resize finished step:'+i) + await winData.destroyWindow(); + done() + } + } }) /** - * @tc.number SUB_WINDOW_DESTROYWINDOW_JSAPI_001 - * @tc.name Test destroyWindowTest1 - * @tc.desc Verification window destruction scenario. - */ + * @tc.number SUB_WINDOW_DESTROYWINDOW_JSAPI_001 + * @tc.name Test destroyWindowTest1 + * @tc.desc Verification window destruction scenario. + */ it('destroyWindowTest1', 0, async function (done) { let caseName = 'destroyWindowTest1'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1348,11 +1584,13 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let tempWnd = null; try { tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { - unexpectedError(err, caseName, 'ohosWindow.createWindow', done); + expect().assertFail(); + done(); + return; }); console.log(msgStr + 'ohosWindow.createWindow ' + baseWndType + ' wnd: ' + JSON.stringify(tempWnd)); expect(!!tempWnd).assertTrue(); - tempWnd.destroyWindow().then(() => { + await tempWnd.destroyWindow().then(() => { console.info(msgStr + 'Succeeded in destroying the window.'); try { let findWnd = ohosWindow.findWindow(windowId) @@ -1366,19 +1604,22 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }).catch((err) => { console.error(msgStr + 'try catch Failed to destroy the window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'tempWnd.destroyWindow', done); + expect().assertFail(); + done(); }) } catch (exception) { console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_DESTROYWINDOW_JSAPI_002 - * @tc.name Test destroyWindowTest2 - * @tc.desc Verification window destruction scenario - */ - it('destroyWindowTest2', 0, function (done) { + * @tc.number SUB_WINDOW_DESTROYWINDOW_JSAPI_002 + * @tc.name Test destroyWindowTest2 + * @tc.desc Verification window destruction scenario + */ + it('destroyWindowTest2', 0, async function (done) { let caseName = 'destroyWindowTest2'; let msgStr = 'jsunittest ' + caseName + ' '; let baseWndType = 1; @@ -1387,45 +1628,57 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta let winsowConfig = { name: windowId, windowType: baseWndType, ctx: context }; - try { - ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { - console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); - if (create_err && create_err.code) { - unexpectedError(create_err, caseName, 'ohosWindow.createWindow', done); - return; - } + function createFirstWindow() { + return new Promise((resolve, reject) => { try { - expect(!!create_data).assertTrue(); - } catch (error) { - console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`) - } - create_data.destroyWindow((err) => { - if (err.code != 0) { - console.log('windowTest DestroyTest2 create callback fail' + JSON.stringify(err)); - unexpectedError(create_err, caseName, 'ohosWindow.destroyWindow', done); - } else { - try { - let findWnd = ohosWindow.findWindow(windowId) - expect(!findWnd).assertTrue(); - done(); - } catch (exception) { - console.error(msgStr + 'try catch Failed to find the Window. Cause: ' + JSON.stringify(exception)); - expect(exception.code === 1300002).assertTrue(); + ohosWindow.createWindow(winsowConfig, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + try { + expect().assertFail(); + } catch (err) { + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(err)}`) + } done(); + reject(null) } - ; - } - }) + resolve(create_data) + }) + } catch (exception) { + console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + } + ; }) - } catch (exception) { - console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } - ; + + let winData; + winData = await createFirstWindow(); + expect(!!winData).assertTrue(); + winData.destroyWindow((err) => { + if (err.code != 0) { + console.log('windowTest DestroyTest2 create callback fail' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (err) { + console.log(msgStr + 'assertFail catch' + JSON.stringify(err)); + } + } else { + try { + let findWnd = ohosWindow.findWindow(windowId) + expect(!findWnd).assertTrue(); + } catch (exception) { + console.error(msgStr + 'try catch Failed to find the Window. Cause: ' + JSON.stringify(exception)); + expect(exception.code === 1300002).assertTrue(); + } + ; + } + done(); + }) }) /** - * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_001 - * @tc.name Test setWindowSystemBarEnableTest1 - * @tc.desc Set the visible mode of navigation bar and status bar + * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_001 + * @tc.name Test setWindowSystemBarEnableTest1 + * @tc.desc Set the visible mode of navigation bar and status bar */ it('setWindowSystemBarEnableTest1', 0, async function (done) { let caseName = 'setWindowSystemBarEnableTest1'; @@ -1434,11 +1687,13 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta try { wnd = await ohosWindow.getLastWindow(context).catch((err) => { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + expect().assertFail(); + done(); + return; }) expect(wnd != null).assertTrue(); try { - wnd.setWindowSystemBarEnable([]).then(() => { + await wnd.setWindowSystemBarEnable([]).then(() => { console.info(msgStr + 'Succeeded in setting the system bar to be invisible.'); expect(TRUE_FLAG).assertTrue(); done(); @@ -1449,17 +1704,21 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta }); } catch (exception) { console.error(msgStr + 'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; } catch (exception) { console.error(msgStr + 'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_002 - * @tc.name Test setWindowSystemBarEnableTest2 - * @tc.desc Set the visible mode of navigation bar and status bar + * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_002 + * @tc.name Test setWindowSystemBarEnableTest2 + * @tc.desc Set the visible mode of navigation bar and status bar */ it('setWindowSystemBarEnableTest2', 0, async function (done) { let caseName = 'setWindowSystemBarEnableTest2'; @@ -1468,11 +1727,13 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta try { wnd = await ohosWindow.getLastWindow(context).catch((err) => { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + expect().assertFail(); + done(); + return; }) expect(wnd != null).assertTrue(); try { - wnd.setWindowSystemBarEnable(['status', 'navigation']).then(() => { + await wnd.setWindowSystemBarEnable(['status', 'navigation']).then(() => { console.info(msgStr + 'Succeeded in setting the system bar to be invisible.'); expect(TRUE_FLAG).assertTrue(); done(); @@ -1483,17 +1744,21 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta }); } catch (exception) { console.error(msgStr + 'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; } catch (exception) { console.error(msgStr + 'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_003 - * @tc.name Test setWindowSystemBarEnableTest3 - * @tc.desc Set the visible mode of navigation bar and status bar + * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_003 + * @tc.name Test setWindowSystemBarEnableTest3 + * @tc.desc Set the visible mode of navigation bar and status bar */ it('setWindowSystemBarEnableTest3', 0, async function (done) { let caseName = 'setWindowSystemBarEnableTest3'; @@ -1502,11 +1767,13 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta try { wnd = await ohosWindow.getLastWindow(context).catch((err) => { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + expect().assertFail(); + done(); + return; }) expect(wnd != null).assertTrue(); try { - wnd.setWindowSystemBarEnable(['status']).then(() => { + await wnd.setWindowSystemBarEnable(['status']).then(() => { console.info(msgStr + 'Succeeded in setting the system bar to be invisible.'); expect(TRUE_FLAG).assertTrue(); done(); @@ -1517,17 +1784,21 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta }); } catch (exception) { console.error(msgStr + 'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; } catch (exception) { console.error(msgStr + 'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_004 - * @tc.name Test setWindowSystemBarEnableTest4 - * @tc.desc Set the visible mode of navigation bar and status bar + * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_004 + * @tc.name Test setWindowSystemBarEnableTest4 + * @tc.desc Set the visible mode of navigation bar and status bar */ it('setWindowSystemBarEnableTest4', 0, async function (done) { let caseName = 'setWindowSystemBarEnableTest4'; @@ -1536,11 +1807,13 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta try { wnd = await ohosWindow.getLastWindow(context).catch((err) => { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + expect().assertFail(); + done(); + return; }) expect(wnd != null).assertTrue(); try { - wnd.setWindowSystemBarEnable(['navigation']).then(() => { + await wnd.setWindowSystemBarEnable(['navigation']).then(() => { console.info(msgStr + 'Succeeded in setting the system bar to be invisible.'); expect(TRUE_FLAG).assertTrue(); done(); @@ -1551,32 +1824,33 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta }); } catch (exception) { console.error(msgStr + 'try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; } catch (exception) { console.error(msgStr + 'try catch Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); + expect().assertFail(); + done(); } ; }) /** - * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_005 - * @tc.name Test setWindowSystemBarEnableTest5 - * @tc.desc Set the visible mode of navigation bar and status bar - */ + * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_005 + * @tc.name Test setWindowSystemBarEnableTest5 + * @tc.desc Set the visible mode of navigation bar and status bar + */ it('setWindowSystemBarEnableTest5', 0, async function (done) { let caseName = 'setWindowSystemBarEnableTest5'; let msgStr = 'jsunittest ' + caseName + ' '; - let baseWndType = 1; - let windowId = 'setWindowSystemBarEnableTest5'; console.log(msgStr + 'begin'); - let winsowConfig = { - name: windowId, windowType: baseWndType, ctx: context - }; let wnd = null; try { wnd = await ohosWindow.getLastWindow(context).catch((err) => { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + expect().assertFail(); + done(); + return; }) expect(wnd != null).assertTrue(); try { @@ -1584,12 +1858,20 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta console.log(msgStr + 'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen(true) callback begin'); if (err.code != 0) { console.log(msgStr + 'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen callback fail' + JSON.stringify(err)); - expect().assertFail(); + try { + expect().assertFail(); + } catch (err) { + console.log(msgStr + 'assertFail catch' + JSON.stringify(err)); + } done(); - } else { + return; + } + try { expect(TRUE_FLAG).assertTrue(); - done(); + } catch (err) { + console.log(msgStr + 'assertTrue catch' + JSON.stringify(err)); } + done(); }) } catch (exception) { console.error(msgStr + ' try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); @@ -1601,37 +1883,42 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_006 - * @tc.name Test setWindowSystemBarEnableTest6 - * @tc.desc Set the visible mode of navigation bar and status bar - */ + * @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_006 + * @tc.name Test setWindowSystemBarEnableTest6 + * @tc.desc Set the visible mode of navigation bar and status bar + */ it('setWindowSystemBarEnableTest6', 0, async function (done) { let caseName = 'setWindowSystemBarEnableTest6'; let msgStr = 'jsunittest ' + caseName + ' '; - let baseWndType = 1; - let windowId = 'setWindowSystemBarEnableTest6'; console.log(msgStr + 'begin'); - let winsowConfig = { - name: windowId, windowType: baseWndType, ctx: context - }; let wnd = null; try { wnd = await ohosWindow.getLastWindow(context).catch((err) => { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.getLastWindow', done); + expect().assertFail(); + done(); + return; }) expect(wnd != null).assertTrue(); try { - wnd.setWindowSystemBarEnable([], (err) => { + await wnd.setWindowSystemBarEnable([], (err) => { console.log(msgStr + 'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen(true) callback begin'); if (err.code != 0) { console.log(msgStr + 'windowTest SetLayoutFullScreenTest2 wnd.setFullScreen callback fail' + JSON.stringify(err)); - expect().assertFail(); + try { + expect().assertFail(); + } catch (err) { + console.log(msgStr + 'assertFail catch' + JSON.stringify(err)); + } done(); - } else { + return; + } + try { expect(TRUE_FLAG).assertTrue(); - done(); + } catch (err) { + console.log(msgStr + 'assertTrue catch' + JSON.stringify(err)); } + done(); }) } catch (exception) { console.error(msgStr + ' try catch Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); @@ -1643,10 +1930,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_003 - * @tc.name Test createWindowTest3 - * @tc.desc Verify the scenario of creating a window of a type that does not exist - */ + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_003 + * @tc.name Test createWindowTest3 + * @tc.desc Verify the scenario of creating a window of a type that does not exist + */ it('createWindowTest3', 0, async function (done) { let caseName = 'createWindowTest3'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1675,9 +1962,9 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_007 - * @tc.name Test createWindowTest7 - * @tc.desc Verify the scenario of creating a window of a type that does not exist + * @tc.number SUB_WINDOW_CREATEWINDOW_JSAPI_007 + * @tc.name Test createWindowTest7 + * @tc.desc Verify the scenario of creating a window of a type that does not exist */ it('createWindowTest7', 0, done => { let caseName = 'createWindowTest7'; @@ -1709,10 +1996,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_001 - * @tc.name Test setWindowLayoutFullScreenTest1 - * @tc.desc set the property of the window can layout in full screen - */ + * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_001 + * @tc.name Test setWindowLayoutFullScreenTest1 + * @tc.desc set the property of the window can layout in full screen + */ it('setWindowLayoutFullScreenTest1', 0, async function (done) { let caseName = 'setWindowLayoutFullScreenTest1'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1723,7 +2010,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta expect(wnd != null).assertTrue(); try { let isLayoutFullScreen = true; - wnd.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { + await wnd.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { console.info(msgStr + 'Succeeded in setting the window layout to full-screen mode.'); try { let propData = wnd.getWindowProperties() @@ -1750,10 +2037,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_002 - * @tc.name Test setWindowLayoutFullScreenTest2 - * @tc.desc set the property of the window can layout in full screen - */ + * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_002 + * @tc.name Test setWindowLayoutFullScreenTest2 + * @tc.desc set the property of the window can layout in full screen + */ it('setWindowLayoutFullScreenTest2', 0, async function (done) { let caseName = 'setWindowLayoutFullScreenTest2'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1763,7 +2050,7 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta expect(wnd != null).assertTrue(); try { let isLayoutFullScreen = false; - wnd.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { + await wnd.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { console.info(msgStr + 'Succeeded in setting the window layout to full-screen mode.'); try { let propData = wnd.getWindowProperties() @@ -1790,10 +2077,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_003 - * @tc.name Test setWindowLayoutFullScreenTest3 - * @tc.desc set the property of the window can layout in full screen - */ + * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_003 + * @tc.name Test setWindowLayoutFullScreenTest3 + * @tc.desc set the property of the window can layout in full screen + */ it('setWindowLayoutFullScreenTest3', 0, async function (done) { let caseName = 'setWindowLayoutFullScreenTest3'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1839,10 +2126,10 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_004 - * @tc.name Test setWindowLayoutFullScreenTest4 - * @tc.desc set the property of the window can layout in full screen - */ + * @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_004 + * @tc.name Test setWindowLayoutFullScreenTest4 + * @tc.desc set the property of the window can layout in full screen + */ it('setWindowLayoutFullScreenTest4', 0, async function (done) { let caseName = 'setWindowLayoutFullScreenTest4'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1888,94 +2175,108 @@ export default function displayAndWindowRefactorInterfaceTest(context, windowSta ; }) /** - * @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_001 - * @tc.name Test setWindowModeTest1 - * @tc.desc Test window.setWindowMode API function test. - */ - it('setWindowModeTest1', 0, function (done) { - let windowModeArr = ['FULLSCREEN', 'PRIMARY', 'SECONDARY', 'FLOATING'] + * @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_001 + * @tc.name Test setWindowModeTest1 + * @tc.desc Test window.setWindowMode API function test. + */ + it('setWindowModeTest1', 0, async function (done) { + let windowModeArr = ['FULLSCREEN', 'PRIMARY', 'SECONDARY', 'FLOATING','FULLSCREEN'] let caseName = 'setWindowModeTest1'; let msgStr = 'jsunittest ' + caseName + ' '; let sumCount = 0 + let baseWndType = 1; + let windowId = 'setWindowModeTest1'; + let windowConfig = { + name: windowId, windowType: baseWndType, ctx: context + }; + let tempWnd; try { - let tempWnd = windowStage.getMainWindowSync(); + tempWnd = await ohosWindow.createWindow(windowConfig).catch((err) => { + console.info(msgStr + 'fail createWindow. Data: ' + JSON.stringify(err)); + }) expect(!!tempWnd).assertTrue(); - let loopCount = windowModeArr; - console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(loopCount)) - getData(0, loopCount.length) - - function getData(i, length) { - let tempType = ohosWindow.WindowMode[loopCount[i]]; - console.log(msgStr + 'tempWnd.setWindowMode ' + tempType + ' start'); + console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(windowModeArr)) + for(let i=0;i { - sumCount++ - console.info(msgStr + 'Succeeded in setting the window mode. count: ' + sumCount); - console.info(msgStr + 'Succeeded in setting the window mode. loopCount.length: ' + loopCount.length); - - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + console.info(msgStr + 'Succeeded in setting the window mode. current tempType:' + tempType); + console.info(msgStr + 'Succeeded in setting the window mode. current step:' + i); + if(i == windowModeArr.length-1){ + console.info(msgStr + 'finished in setting the window mode. current step:' + i); + done() } - if (sumCount == loopCount.length) done(); }).catch((err) => { console.log(msgStr + 'currentType: ' + tempType) console.error(msgStr + 'Failed to set the window mode. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + expect().assertFail(); + done(); }); } catch (exception) { console.error(msgStr + 'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception)); } ; } + await tempWnd.destroyWindow() } catch (exception) { console.error('try catch Failed to obtain the getMainWindowSync. Cause: ' + JSON.stringify(exception)); } ; }) /** - * @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_002 - * @tc.name Test setWindowModeTest2 - * @tc.desc Verify the scenario where the normal window mode is set - */ - it('setWindowModeTest2', 0, function (done) { - let windowModeArr = ['FULLSCREEN', 'PRIMARY', 'SECONDARY', 'FLOATING'] + * @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_002 + * @tc.name Test setWindowModeTest2 + * @tc.desc Verify the scenario where the normal window mode is set + */ + it('setWindowModeTest2', 0, async function (done) { + let windowModeArr = ['FULLSCREEN', 'PRIMARY', 'SECONDARY', 'FLOATING','FULLSCREEN'] let caseName = 'setWindowModeTest2'; let msgStr = 'jsunittest ' + caseName + ' '; let sumCount = 0 + let baseWndType = 1; + let windowId = 'setWindowModeTest2'; + let windowConfig = { + name: windowId, windowType: baseWndType, ctx: context + }; + let wnd; try { - let wnd = windowStage.getMainWindowSync(); + wnd = await ohosWindow.createWindow(windowConfig).catch((err) => { + console.info(msgStr + 'fail createWindow. Data: ' + JSON.stringify(err)); + }) expect(!!wnd).assertTrue(); - let loopCount = windowModeArr; - console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(loopCount)) - getData(0, loopCount.length) - function getData(i, length) { - try { - let tempType = ohosWindow.WindowMode[loopCount[i]]; - console.log(msgStr + 'tempWnd.setWindowMode tempType:' + tempType + ' start i:' + i); - wnd.setWindowMode(tempType, (err, data) => { - if (err && err.code) { - console.log(msgStr + 'currentType: ' + tempType) - console.error(msgStr + 'Failed to set the window mode. Cause: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'tempWnd.setWindowType', done); - } else { - sumCount++ - console.info(msgStr + 'Succeeded in setting the window mode. count: ' + sumCount); - console.info(msgStr + 'Succeeded in setting the window mode. loopCount.length: ' + loopCount.length); - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++{ + try { + wnd.setWindowMode(tempType, (err, data) => { + if (err && err.code) { + console.log(msgStr + 'currentType: ' + tempType) + console.error(msgStr + 'Failed to set the window mode. Cause: ' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (err) { + console.log(msgStr + 'assertFail catch' + JSON.stringify(err)); + } + done(); + reject(false) } - if (sumCount == loopCount.length) done(); - } - }) - } catch (exception) { - console.error(msgStr + 'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception)); + resolve(true) + console.log(msgStr + 'tempWnd.setWindowMode tempType:' + tempType + ' successed i:' + i); + }) + } catch (exception) { + console.error(msgStr + 'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception)); + } + }) + } + for(let i=0;i { + console.info(msgStr + 'fail createWindow. Data: ' + JSON.stringify(err)); + }) expect(!!tempWnd).assertTrue(); - let loopCount = windowModeArr; - console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(loopCount)) - getData(0, loopCount.length) - - function getData(i, length) { - let tempType = ohosWindow.WindowMode[loopCount[i]]; - console.log(msgStr + 'tempWnd.setWindowMode ' + tempType + ' start'); - try { - tempWnd.setWindowMode(tempType).then(() => { - sumCount++ - console.info(msgStr + 'Succeeded in setting the window mode. count: ' + sumCount); - console.info(msgStr + 'Succeeded in setting the window mode. loopCount.length: ' + loopCount.length); - }).catch((err) => { - console.log(msgStr + 'currentType: ' + tempType) - console.error(msgStr + 'Failed to set the window mode. Cause: ' + JSON.stringify(err)); - expect(err.code == 401).assertTrue(); - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + console.error(msgStr + 'Failed to set the window mode. Cause: ' + JSON.stringify(err)); + expect(err.code == 1300002).assertTrue(); + await tempWnd.destroyWindow() + console.log(msgStr + 'tempWnd.setWindowMode failed ' + 'finished'); + done(); + }); } catch (exception) { console.error('try catch Failed to obtain the getMainWindowSync. Cause: ' + JSON.stringify(exception)); } ; }) /** - * @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_004 - * @tc.name Test setWindowModeTest4 - * @tc.desc Verify the scenario where the normal window mode is set - */ - it('setWindowModeTest4', 0, function (done) { - let windowModeArr = ['UNDEFINED'] + * @tc.number SUB_WINDOW_SETWINDOWMODE_JSAPI_004 + * @tc.name Test setWindowModeTest4 + * @tc.desc Verify the scenario where the normal window mode is set + */ + it('setWindowModeTest4', 0, async function (done) { let caseName = 'setWindowModeTest4'; let msgStr = 'jsunittest ' + caseName + ' '; - let sumCount = 0 + let baseWndType = 1; + let windowId = 'setWindowModeTest4'; + let windowConfig = { + name: windowId, windowType: baseWndType, ctx: context + }; + let wnd; try { - let wnd = windowStage.getMainWindowSync(); + wnd = await ohosWindow.createWindow(windowConfig).catch((err) => { + console.info(msgStr + 'fail createWindow. Data: ' + JSON.stringify(err)); + }) expect(!!wnd).assertTrue(); - let loopCount = windowModeArr; - console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(loopCount)) - getData(0, loopCount.length) - - function getData(i, length) { - let tempType = ohosWindow.WindowMode[loopCount[i]]; - console.log(msgStr + 'tempWnd.setWindowMode ' + tempType + ' start'); - try { - wnd.setWindowMode(tempType, (err, data) => { - if (err && err.code) { - console.log(msgStr + 'currentType: ' + tempType) - console.error(msgStr + 'Failed to set the window mode. Cause: ' + JSON.stringify(err)); - try { - expect(err.code == 401).assertTrue(); - } catch (error) { - console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`) - } - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + if (err && err.code) { + console.log(msgStr + 'currentType: ' + tempType) + console.error(msgStr + 'Failed to set the window mode. Cause: ' + JSON.stringify(err)); + try { + expect(err.code == 1300002).assertTrue(); + } catch (error) { + console.info(`ohosWindow.createWindow catch error: ${JSON.stringify(error)}`) } - }) - } catch (exception) { - console.error(msgStr + 'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception)); - } - ; - } + await wnd.destroyWindow() + done(); + } else { + console.info(msgStr + 'Succeeded in setting the window mode'); + } + }) + } catch (exception) { + console.error(msgStr + 'try catch Failed to set the window mode. Cause: ' + JSON.stringify(exception)); + }; } catch (exception) { console.error(msgStr + 'try catch Failed to create the window. Cause: ' + JSON.stringify(exception)); - } - ; + }; }) /** - * @tc.number SUB_WMS_ENUM_WINDOWSTAGEEVENTTYPERENAME_JSAPI_001 - * @tc.name Test enumWindowStageEventTypeReName_Test_001. - * @tc.desc To test the enum value of WindowStageEventType. + * @tc.number SUB_WMS_ENUM_WINDOWSTAGEEVENTTYPERENAME_JSAPI_001 + * @tc.name Test enumWindowStageEventTypeReName_Test_001. + * @tc.desc To test the enum value of WindowStageEventType. */ it('enumWindowStageEventTypeReName_Test_001', 0, async function (done) { console.info('test the enum value of WindowStageEventType begin'); diff --git a/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets b/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets index 18858e0d66a6b254b79d41e1dc524a5dd80ecf19..30e00ff020a88b1d0a8f927fb7530a4a63fc28cb 100644 --- a/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets @@ -88,6 +88,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) console.log('jsunittest systemBarTintChange end off'); } else if (newWindowObj) { newWindowObj.off(listenerData.typeStr); + console.log('jsunittest newWindowObj listenerData.typeStr:' + JSON.stringify(listenerData.typeStr)); } await sleep(3000); } @@ -99,8 +100,12 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) function expectedError(error, caseName, apiName, done, code) { let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: '; console.log(msgStr + JSON.stringify(error)); - expect(TRUE_FLAG).assertTrue(); - expect(error.code === code).assertTrue(); + try { + expect(TRUE_FLAG).assertTrue(); + expect(error.code === code).assertTrue(); + } catch (error) { + console.info(`ohosWindow.on ${JSON.stringify(error)}`) + } done(); } @@ -109,7 +114,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) console.log(msgStr + JSON.stringify(error)); try { expect(TRUE_FLAG).assertFail(); - ; } catch (error) { console.info(`ohosWindow.on ${JSON.stringify(error)}`) } @@ -126,51 +130,76 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) /** * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_006 * @tc.name Test setSystemBarEnableTest6 - * @tc.desc Test ohosWindow.setSystemBarEnable API function test1. + * @tc.desc Verify that the scene shows the status bar and hides the navigation bar */ - it('setSystemBarEnableTest6', 0, function (done) { + it('setSystemBarEnableTest6', 0, async function (done) { let caseName = 'setSystemBarEnableTest6'; let msgStr = 'jsunittest ' + caseName + ' '; - let [flagStatus, flagNav] = [false, false]; + let flagStatus = false; console.log(msgStr + 'begin'); listenerData.on = true; listenerData.typeStr = 'systemBarTintChange'; - ohosWindow.on('systemBarTintChange', systembartintstate => { - console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); - if (flagStatus || flagNav) { - try { - expect(!!systembartintstate).assertTrue(); - expect(!!systembartintstate.regionTint).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on ${JSON.stringify(error)}`) + + function ohosWindowOn() { + ohosWindow.on('systemBarTintChange', systembartintstate => { + console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); + if (flagStatus) { + console.log(msgStr + 'systembartintstate.regionTint[0].type : ' + JSON.stringify(systembartintstate.regionTint[0].type)); + console.log(msgStr + 'systembartintstate.regionTint[0].isEnable : ' + JSON.stringify(systembartintstate.regionTint[0].isEnable)); + try { + expect(!!systembartintstate).assertTrue(); + expect(systembartintstate.regionTint[0].type == 3 && systembartintstate.regionTint[0].isEnable).assertTrue(); + } catch (error) { + console.info(msgStr + `ohosWindow.on ${JSON.stringify(error)}`) + } + done(); } - console.log(msgStr + 'flagStatus || flagNav' + msgStr + 'ohosWindow.on systemBarTintChange regionTint:' + JSON.stringify(systembartintstate.regionTint)); - done(); - } - }) + }) + } + let mainWnd = null; - console.log(msgStr + 'mainWnd = null'); console.log(msgStr + 'windowStage = ' + JSON.stringify(windowStage)); - windowStage.getMainWindow((err, data) => { - console.log(msgStr + 'getMainWindow data2' + JSON.stringify(data)); - if (err && err.code) { - unexpectedError(data, caseName, 'windowStage.getMainWindow', done); - } - try { - expect(!!data).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on ${JSON.stringify(error)}`) - } - mainWnd = data; - console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); - mainWnd.show((err, data) => { - console.log(msgStr + 'mainWnd.show err' + JSON.stringify(err)); - console.log(msgStr + 'mainWnd.show data' + JSON.stringify(data)); - if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.show', done); - } - expect(!data).assertTrue(); - console.log(msgStr + 'mainWnd.show success'); + + function getMainWindow() { + return new Promise(function (resolve, reject) { + windowStage.getMainWindow((err, data) => { + console.log(msgStr + 'getMainWindow data:' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'windowStage.getMainWindow', done); + } + try { + mainWnd = data; + expect(!!data).assertTrue(); + } catch (error) { + console.info(msgStr + `getMainWindow ${JSON.stringify(error)}`) + } + resolve(data); + console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); + }) + }) + } + + function show() { + return new Promise(function (resolve, reject) { + mainWnd.show((err, data) => { + console.log(msgStr + 'mainWnd.show err' + JSON.stringify(err)); + console.log(msgStr + 'mainWnd.show data' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.show', done); + } + try { + expect(!data).assertTrue(); + } catch (err) { + console.info(msgStr + `mainWnd.show err: ${JSON.stringify(err)}`) + } + console.log(msgStr + 'mainWnd.show success'); + resolve(data) + }) + }) + } + + function setFullScreen() { + return new Promise(function (resolve, reject) { mainWnd.setFullScreen(true, (err, data) => { console.log(msgStr + 'mainWnd.setFullScreen data:' + JSON.stringify(data)); if (err && err.code) { @@ -179,88 +208,109 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) try { expect(!data).assertTrue(); } catch (error) { - console.info(`ohosWindow.on ${JSON.stringify(error)}`) + console.info(msgStr + `setFullScreen ${JSON.stringify(error)}`) } console.log(msgStr + 'mainWnd.setFullScreen success'); - flagNav = true; - mainWnd.setSystemBarEnable(['navigation'], (err, data) => { - console.log(msgStr + 'mainWnd.setSystemBarEnable navigation JSON.stringify(data)==' + JSON.stringify(data)); - if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [navigation]', done); - } - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on ${JSON.stringify(error)}`) - } - console.log(msgStr + 'mainWnd.setSystemBarEnable success flagNav==' + flagNav); - }) - flagStatus = true; - mainWnd.setSystemBarEnable(['status'], (err, data) => { - console.log(msgStr + 'mainWnd.setSystemBarEnable status JSON.stringify(data)===' + JSON.stringify(data)); - if (err && err.code) { - console.log(msgStr + 'mainWnd.setSystemBarEnable status JSON.stringify(err)===' + JSON.stringify(err)); - unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status]', done); - } - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on ${JSON.stringify(error)}`) - } - }) + resolve(data) }) }) - }) - console.log(msgStr + 'finished!!'); + } + + function setSystemBarEnableStatus() { + return new Promise(function (resolve, reject) { + mainWnd.setSystemBarEnable(['status'], (err, data) => { + console.log(msgStr + 'mainWnd.setSystemBarEnable status data===' + JSON.stringify(data)); + if (err && err.code) { + console.log(msgStr + 'mainWnd.setSystemBarEnable status err===' + JSON.stringify(err)); + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status]', done); + } + try { + flagStatus = true + expect(!data).assertTrue(); + } catch (error) { + console.info(msgStr + `setSystemBarEnable ${JSON.stringify(error)}`) + } + resolve(data) + }) + }) + } + + await getMainWindow() + await show() + await setFullScreen() + await setSystemBarEnableStatus() + ohosWindowOn() }); /** * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_007 * @tc.name Test setSystemBarEnableTest7 * @tc.desc Verify that the scene hides the status bar and displays the navigation bar. */ - it('setSystemBarEnableTest7', 0, function (done) { + it('setSystemBarEnableTest7', 0, async function (done) { let caseName = 'setSystemBarEnableTest7'; let msgStr = 'jsunittest ' + caseName + ' '; let [flagStatus, flagNav] = [false, false]; console.log(msgStr + 'begin'); listenerData.on = true; listenerData.typeStr = 'systemBarTintChange'; - ohosWindow.on('systemBarTintChange', systembartintstate => { - console.log(msgStr + 'ohosWindow.on systembartintstate :' + JSON.stringify(systembartintstate)); - console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); - if (flagStatus || flagNav) { - console.log(msgStr + 'ohosWindow.on flagStatus || flagNav:'); - try { - expect(!!systembartintstate).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on catch err: ${JSON.stringify(error)}`) + + function ohosWindowOn() { + ohosWindow.on('systemBarTintChange', systembartintstate => { + console.log(msgStr + 'ohosWindow.on systembartintstate :' + JSON.stringify(systembartintstate)); + console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); + if (flagStatus || flagNav) { + console.log(msgStr + 'ohosWindow.on flagStatus || flagNav:'); + try { + expect(!!systembartintstate).assertTrue(); + } catch (error) { + console.info(`ohosWindow.on catch err: ${JSON.stringify(error)}`) + } + done(); } - done(); - } - }) + }) + } + let mainWnd = null; console.log(msgStr + 'mainWnd = null') - windowStage.getMainWindow((err, data) => { - if (err && err.code) { - unexpectedError(data, caseName, 'windowStage.getMainWindow', done); - } - try { - expect(!!data).assertTrue(); - } catch (error) { - console.info(`windowStage.getMainWindow catch err: ${JSON.stringify(error)}`) - } - mainWnd = data; - console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); - mainWnd.show((err, data) => { - if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.show', done); - } - console.log(msgStr + 'mainWnd.show success'); - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`mainWnd.show catch error: ${JSON.stringify(error)}`) - } + + function getMainWindow() { + return new Promise(function (resolve, reject) { + windowStage.getMainWindow((err, data) => { + console.log(msgStr + 'getMainWindow data:' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'windowStage.getMainWindow', done); + } + try { + mainWnd = data; + expect(!!data).assertTrue(); + } catch (error) { + console.info(`ohosWindow.on ${JSON.stringify(error)}`) + } + resolve(data); + console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); + }) + }) + } + + function show() { + return new Promise(function (resolve, reject) { + mainWnd.show((err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.show', done); + } + console.log(msgStr + 'mainWnd.show success'); + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.show catch error: ${JSON.stringify(error)}`) + } + resolve(data) + }) + }) + } + + function setFullScreen() { + return new Promise(function (resolve, reject) { mainWnd.setFullScreen(true, (err, data) => { console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data)); if (err && err.code) { @@ -271,66 +321,105 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) } catch (error) { console.info(`mainWnd.setFullScreen catch err: ${JSON.stringify(error)}`) } - mainWnd.setSystemBarEnable(['status'], (err, data) => { - console.log(msgStr + 'mainWnd.setSystemBarEnable status JSON.stringify(data)==' + JSON.stringify(data)); - if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status]', done); - } - flagStatus = true; - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`) - } - mainWnd.setSystemBarEnable(['navigation'], (err, data) => { - if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [navitgation]', done); - } - flagNav = true; - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`) - } - }) - }) + resolve(data) }) }) - }) + } + + function setSystemBarEnableStatus() { + return new Promise(function (resolve, reject) { + mainWnd.setSystemBarEnable(['status'], (err, data) => { + console.log(msgStr + 'mainWnd.setSystemBarEnable status JSON.stringify(data)==' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status]', done); + } + flagStatus = true; + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`) + } + resolve(data) + }) + }) + } + + function setSystemBarEnableNavigation() { + return new Promise(function (resolve, reject) { + mainWnd.setSystemBarEnable(['navigation'], (err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [navitgation]', done); + } + flagNav = true; + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`) + } + resolve(data) + }) + }) + } + + await getMainWindow() + await show() + await setFullScreen() + ohosWindowOn() + await setSystemBarEnableStatus() + await setSystemBarEnableNavigation() }); /** * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_008 * @tc.name Test setSystemBarEnableTest8 * @tc.desc Verify that the scene displays both the status bar and the navigation bar. */ - it('setSystemBarEnableTest8', 0, function (done) { + it('setSystemBarEnableTest8', 0, async function (done) { let caseName = 'setSystemBarEnableTest8'; let msgStr = 'jsunittest ' + caseName + ' '; let [flagStatus, flagNav] = [false, false]; console.log(msgStr + 'begin'); let mainWnd = null; console.log(msgStr + 'mainWnd = null'); - windowStage.getMainWindow((err, data) => { - if (err && err.code) { - unexpectedError(data, caseName, 'windowStage.getMainWindow', done); - } - try { - expect(!!data).assertTrue(); - } catch (error) { - console.info(`mainWnd.getMainWindow catch err: ${JSON.stringify(error)}`) - } - mainWnd = data; - console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); - mainWnd.show((err, data) => { - if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.show', done); - } - console.log(msgStr + 'mainWnd.show success'); - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`mainWnd.show catch err: ${JSON.stringify(error)}`) - } + listenerData.on = true; + listenerData.typeStr = 'systemBarTintChange'; + + function getMainWindow() { + return new Promise(function (resolve, reject) { + windowStage.getMainWindow((err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'windowStage.getMainWindow', done); + } + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.getMainWindow catch err: ${JSON.stringify(error)}`) + } + mainWnd = data; + console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); + resolve(data) + }) + }) + } + + function show() { + return new Promise(function (resolve, reject) { + mainWnd.show((err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.show', done); + } + console.log(msgStr + 'mainWnd.show success'); + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.show catch err: ${JSON.stringify(error)}`) + } + resolve(data) + }) + }) + } + + function setFullScreen() { + return new Promise(function (resolve, reject) { mainWnd.setFullScreen(true, (err, data) => { console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data)); if (err && err.code) { @@ -341,173 +430,252 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) } catch (error) { console.info(`mainWnd.setFullScreen catch err: ${JSON.stringify(error)}`) } - mainWnd.setSystemBarEnable([], (err, data) => { - console.log(msgStr + 'mainWnd.setSystemBarEnable [] JSON.stringify(data)==' + JSON.stringify(data)); - if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done); - } - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`) - } - listenerData.on = true; - listenerData.typeStr = 'systemBarTintChange'; - setTimeout(() => { - ohosWindow.on('systemBarTintChange', systembartintstate => { - console.log(msgStr + 'ohosWindow.on systemBarTintChange :' + JSON.stringify(systembartintstate)); - console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); - setTimeout(() => { - if (flagStatus || flagNav) { - let enable = systembartintstate.regionTint[0].isEnable - let numType = systembartintstate.regionTint[0].type - console.log(msgStr + 'ohosWindow.on isEnable : ' + JSON.stringify(enable)); - console.log(msgStr + 'ohosWindow.on numType : ' + JSON.stringify(numType)); - try { - expect(numType === ohosWindow.WindowType.TYPE_NAVIGATION_BAR || enable).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on catch err: ${JSON.stringify(error)}`) - } - } - done(); - }, 3000) - }) - }, 2300) - mainWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { - if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status,navigation]', done); - } - flagStatus = true; - flagNav = true; - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`) - } - }) - }) + resolve(data) }) }) - }) + } + + function setSystemBarEnable() { + return new Promise(function (resolve, reject) { + mainWnd.setSystemBarEnable([], (err, data) => { + console.log(msgStr + 'mainWnd.setSystemBarEnable [] JSON.stringify(data)==' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done); + } + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`) + } + listenerData.on = true; + listenerData.typeStr = 'systemBarTintChange'; + resolve(data) + }) + }) + } + + function ohosWindowOn() { + ohosWindow.on('systemBarTintChange', systembartintstate => { + console.log(msgStr + 'ohosWindow.on systemBarTintChange :' + JSON.stringify(systembartintstate)); + console.log(msgStr + 'ohosWindow.on systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); + if (flagStatus || flagNav) { + let enable = systembartintstate.regionTint[0].isEnable + let numType = systembartintstate.regionTint[0].type + let enableNav = systembartintstate.regionTint[1].isEnable + let numTypeNav = systembartintstate.regionTint[1].type + console.log(msgStr + 'ohosWindow.on isEnable : ' + JSON.stringify(enable)); + console.log(msgStr + 'ohosWindow.on numType : ' + JSON.stringify(numType)); + try { + expect(numType === ohosWindow.WindowType.TYPE_STATUS_BAR || enable).assertTrue(); + expect(numTypeNav === ohosWindow.WindowType.TYPE_NAVIGATION_BAR || enableNav).assertTrue(); + } catch (error) { + console.info(`ohosWindow.on catch err: ${JSON.stringify(error)}`) + } + } + done(); + }) + } + + function setSystemBarEnableT() { + return new Promise(function (resolve, reject) { + mainWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status,navigation]', done); + } + flagStatus = true; + flagNav = true; + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`) + } + resolve(data) + }) + }) + } + + await getMainWindow() + await show() + await setFullScreen() + await setSystemBarEnable() + await setSystemBarEnableT() + ohosWindowOn() }); /** * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_009 * @tc.name Test setSystemBarEnableTest9 * @tc.desc Verify that the scene hides both the status bar and the navigation bar. */ - it('setSystemBarEnableTest9', 0, function (done) { + it('setSystemBarEnableTest9', 0, async function (done) { let caseName = 'setSystemBarEnableTest9'; let msgStr = 'jsunittest ' + caseName + ' '; let [flagStatus, flagNav] = [false, false]; console.log(msgStr + 'begin'); let mainWnd = null; console.log(msgStr + 'mainWnd = null'); - windowStage.getMainWindow((err, data) => { - if (err && err.code) { - unexpectedError(data, caseName, 'windowStage.getMainWindow', done); - } - try { - expect(!!data).assertTrue(); - } catch (error) { - console.info(`windowStage.getMainWindow catch err: ${JSON.stringify(error)}`) - } - mainWnd = data; - console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); - mainWnd.show((err, data) => { - if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.show', done); - } - console.log(msgStr + 'mainWnd.show success'); - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`mainWnd.show catch err: ${JSON.stringify(error)}`) - } - mainWnd.setFullScreen(true, (err, data) => { - console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data)); + + function getMainWindow() { + return new Promise(function (resolve, reject) { + windowStage.getMainWindow((err, data) => { if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.setFullScreen', done); + unexpectedError(data, caseName, 'windowStage.getMainWindow', done); + } + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`windowStage.getMainWindow catch err: ${JSON.stringify(error)}`) + } + mainWnd = data; + console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); + resolve(data) + }) + }) + } + + function show() { + return new Promise(function (resolve, reject) { + mainWnd.show((err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.show', done); } + console.log(msgStr + 'mainWnd.show success'); try { expect(!data).assertTrue(); } catch (error) { - console.info(`mainWnd.setFullScreen catch err: ${JSON.stringify(error)}`) + console.info(`mainWnd.show catch err: ${JSON.stringify(error)}`) } - mainWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { - console.log(msgStr + 'mainWnd.setSystemBarEnable status,navigation JSON.stringify(data)==' + JSON.stringify(data)); - if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status,navigation]', done); - } - flagStatus = true; - flagNav = true; - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`) - } - listenerData.on = true; - listenerData.typeStr = 'systemBarTintChange'; - ohosWindow.on('systemBarTintChange', (systembartintstate) => { - console.log(msgStr + 'ohosWindow.on systemBarTintChange :' + JSON.stringify(systembartintstate)); - console.log(msgStr + 'ohosWindow.on systemBarTintChange systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); - if (flagStatus || flagNav) { - try { - expect(!!systembartintstate).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on catch err: ${JSON.stringify(error)}`) - } - done(); - } - }) - mainWnd.setSystemBarEnable([], (err, data) => { - if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done); - } - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`) - } - }) - }) + resolve(data) }) }) - }) + } + + function setFullScreen() { + return new Promise(function (resolve, reject) { + mainWnd.setFullScreen(true, (err, data) => { + console.log(msgStr + 'mainWnd.setFullScreen' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setFullScreen', done); + } + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.setFullScreen catch err: ${JSON.stringify(error)}`) + } + resolve(data) + }) + }) + } + + function setSystemBarEnableT() { + return new Promise(function (resolve, reject) { + mainWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { + console.log(msgStr + 'mainWnd.setSystemBarEnable status,navigation JSON.stringify(data)==' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [status,navigation]', done); + } + flagStatus = true; + flagNav = true; + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`) + } + listenerData.on = true; + listenerData.typeStr = 'systemBarTintChange'; + resolve(data) + }) + }) + } + + function ohosWindowOn() { + ohosWindow.on('systemBarTintChange', (systembartintstate) => { + console.log(msgStr + 'ohosWindow.on systemBarTintChange :' + JSON.stringify(systembartintstate)); + console.log(msgStr + 'ohosWindow.on systemBarTintChange systembartintstate.regionTint : ' + JSON.stringify(systembartintstate.regionTint)); + if (flagStatus || flagNav) { + try { + expect(!!systembartintstate).assertTrue(); + } catch (error) { + console.info(`ohosWindow.on catch err: ${JSON.stringify(error)}`) + } + done(); + } + }) + } + + function setSystemBarEnable() { + return new Promise(function (resolve, reject) { + mainWnd.setSystemBarEnable([], (err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done); + } + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.setSystemBarEnable catch err: ${JSON.stringify(error)}`) + } + resolve(data) + }) + }) + } + + await getMainWindow() + await show() + await setFullScreen() + await setSystemBarEnableT() + ohosWindowOn() + await setSystemBarEnable() }); /** * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_010 * @tc.name Test setSystemBarEnableTest10 * @tc.desc Verify the scene where illegal values are entered when the navigation bar and status bar are displayed or hidden */ - it('setSystemBarEnableTest10', 0, function (done) { + it('setSystemBarEnableTest10', 0, async function (done) { let caseName = 'setSystemBarEnableTest10'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin'); let mainWnd = null; console.log(msgStr + 'mainWnd = null'); - windowStage.getMainWindow((err, data) => { - if (err && err.code) { - unexpectedError(data, caseName, 'windowStage.getMainWindow', done); - } - try { - console.log(msgStr + 'windowStage.getMainWindow JSON.stringify(!!data)===' + JSON.stringify(!!data)); - expect(!!data).assertTrue(); - } catch (error) { - console.info(`windowStage.getMainWindow catch error: ${JSON.stringify(error)}`) - } - mainWnd = data; - console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); - mainWnd.show((err, data) => { - if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.show', done); - } - console.log(msgStr + 'mainWnd.show success'); - try { - console.log(msgStr + 'mainWnd.show JSON.stringify(!data)===' + JSON.stringify(!data)); - expect(!data).assertTrue(); - } catch (error) { - console.info(`mainWnd.show catch error: ${JSON.stringify(error)}`) - } + + function getMainWindow() { + return new Promise(function (resolve, reject) { + windowStage.getMainWindow((err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'windowStage.getMainWindow', done); + } + try { + console.log(msgStr + 'windowStage.getMainWindow JSON.stringify(!!data)===' + JSON.stringify(!!data)); + expect(!!data).assertTrue(); + } catch (error) { + console.info(`windowStage.getMainWindow catch error: ${JSON.stringify(error)}`) + } + mainWnd = data; + console.log(msgStr + 'await windowStage JSON.stringify(mainWnd)===' + JSON.stringify(mainWnd)); + resolve(data) + }) + }) + } + + function show() { + return new Promise(function (resolve, reject) { + mainWnd.show((err, data) => { + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.show', done); + } + console.log(msgStr + 'mainWnd.show success'); + try { + console.log(msgStr + 'mainWnd.show JSON.stringify(!data)===' + JSON.stringify(!data)); + expect(!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.show catch error: ${JSON.stringify(error)}`) + } + resolve(data) + }) + }) + } + + function setFullScreen() { + return new Promise(function (resolve, reject) { mainWnd.setFullScreen(true, (err, data) => { console.log(msgStr + 'mainWnd.setFullScreen: ' + JSON.stringify(data)); if (err && err.code) { @@ -519,108 +687,144 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) } catch (error) { console.info(`mainWnd.setFullScreen catch error: ${JSON.stringify(error)}`) } - mainWnd.setSystemBarEnable([], (err, data) => { - console.log(msgStr + 'mainWnd.setSystemBarEnable [] JSON.stringify(data)==' + JSON.stringify(data)); - if (err && err.code) { - unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done); - } + resolve(data) + }) + }) + } + + function setSystemBarEnable() { + return new Promise(function (resolve, reject) { + mainWnd.setSystemBarEnable([], (err, data) => { + console.log(msgStr + 'mainWnd.setSystemBarEnable [] JSON.stringify(data)==' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done); + } + try { + console.log(msgStr + 'mainWnd.setSystemBarEnable JSON.stringify(!data)===' + JSON.stringify(!data)); + expect(!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`) + } + resolve(data) + }) + }) + } + + function setSystemBarEnableError() { + return new Promise(function (resolve, reject) { + mainWnd.setSystemBarEnable([null, '123'], (err, data) => { + console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringify(data)==' + JSON.stringify(data)); + console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringify(err)==' + JSON.stringify(err)); + if (err && err.code) { try { - console.log(msgStr + 'mainWnd.setSystemBarEnable JSON.stringify(!data)===' + JSON.stringify(!data)); - expect(!data).assertTrue(); + console.log(msgStr + 'mainWnd.setSystemBarEnable JSON.stringify(err.code)===' + JSON.stringify(err.code)); + expect(err.code === 1003).assertTrue(); } catch (error) { console.info(`mainWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`) } - mainWnd.setSystemBarEnable([null, '123'], (err, data) => { - console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringify(data)==' + JSON.stringify(data)); - console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringify(err)==' + JSON.stringify(err)); - if (err && err.code) { - try { - console.log(msgStr + 'mainWnd.setSystemBarEnable JSON.stringify(err.code)===' + JSON.stringify(err.code)); - expect(err.code === 1003).assertTrue(); - } catch (error) { - console.info(`mainWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`) - } - done(); - } else { - unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [null,123]', done); - } - }) - }) + done(); + } else { + unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable [null,123]', done); + } + resolve(data) }) }) - }) + } + + await getMainWindow() + await show() + await setFullScreen() + await setSystemBarEnable() + await setSystemBarEnableError() }); /** * @tc.number SUB_WINDOW_SETSYSTEMBARPROPERTIES_JSAPI_004 * @tc.name Test setSystemBarPropertiesTest1 * @tc.desc TVerify the scene where the colors of the status bar and navigation bar are set in RGB */ - it('setSystemBarPropertiesTest4', 0, done => { + it('setSystemBarPropertiesTest4', 0, async done => { let caseName = 'setSystemBarPropertiesTest4'; let msgStr = 'jsunittest ' + caseName + ' '; let cloneColorArr = JSON.parse(JSON.stringify(commonRGBColorArr)); let compareCount = 0; - let listenerFlag = listenerStatus.ready; + let listenerFlag = false; console.log(msgStr + 'begin'); listenerData.on = true; listenerData.typeStr = 'systemBarTintChange'; - ohosWindow.on('systemBarTintChange', (systemBarData) => { - console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); - if (listenerFlag === listenerStatus.pending) { - try { - expect(!!systemBarData).assertTrue(); - expect(!!systemBarData.regionTint).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) - } - let arrLength = systemBarData.regionTint.length; - getData(0, arrLength) - function getData(i, length) { - let tempData = systemBarData.regionTint[i]; - if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { - console.log(msgStr + 'systemBarTintChange compare start!'); - compareCount++; - let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor); - let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor); - try { - expect(backgroundIndex === -1).assertTrue(); - expect(contentColorIndex === -1).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) + function ohosWindowOn() { + ohosWindow.on('systemBarTintChange', (systemBarData) => { + console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); + if (listenerFlag) { + try { + expect(!!systemBarData).assertTrue(); + expect(!!systemBarData.regionTint).assertTrue(); + } catch (error) { + console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) + } + let arrLength = systemBarData.regionTint.length; + for (let i = 0; i < arrLength; i++) { + let tempData = systemBarData.regionTint[i]; + if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { + console.log(msgStr + 'systemBarTintChange compare start!'); + compareCount++; + let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor); + let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor); + try { + expect(backgroundIndex === -1).assertTrue(); + expect(contentColorIndex === -1).assertTrue(); + } catch (error) { + console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) + } } - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { - if (err && err.code) { - unexpectedError(err, caseName, 'windowStage.getMainWindow', done); - } - let tempWnd = data - try { - expect(!!tempWnd).assertTrue(); - } catch (error) { - console.info(`windowStage.getMainWindow catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); - tempWnd.show((err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.show', done); - } - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'tempWnd.show success'); + console.log(msgStr + 'tempWnd.on systemBarTintChange finished'); + }) + } + + let tempWnd = null + + function getMainWindow() { + return new Promise(function (resolve, reject) { + windowStage.getMainWindow((err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'windowStage.getMainWindow', done); + } + tempWnd = data + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`windowStage.getMainWindow catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); + resolve(data) + }) + }) + } + + function show() { + return new Promise(function (resolve, reject) { + tempWnd.show((err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.show', done); + } + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'tempWnd.show success'); + resolve(data) + }) + }) + } + + function setFullScreen() { + return new Promise(function (resolve, reject) { tempWnd.setFullScreen(true, (err, data) => { if (err && err.code) { unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done); @@ -631,62 +835,68 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) console.info(`tempWnd.setFullScreen catch error: ${JSON.stringify(error)}`) } console.log(msgStr + 'tempWnd.setFullScreen(true) success'); - tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { + resolve(data) + }) + }) + } + + function setSystemBarEnableNavigationT() { + return new Promise(function (resolve, reject) { + tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); + } + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); + listenerFlag = true; + resolve(data) + }) + }) + } + + function setSystemBarProperties() { + return new Promise(function (resolve, reject) { + let loopCount = commonRGBColorArr.length + for (let i = 0; i < loopCount; i++) { + let tempColor = commonRGBColorArr[i]; + let systemBarProperties = { + statusBarColor: tempColor, + isStatusBarLightIcon: true, + statusBarContentColor: tempColor, + navigationBarColor: tempColor, + isNavigationBarLightIcon: false, + navigationBarContentColor: tempColor, + }; + tempWnd.setSystemBarProperties(systemBarProperties, (err, data) => { + console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data)); if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); + unexpectedError(err, caseName, 'tempWnd.setSystemBarProperties' + tempColor + ' ', done); } - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`tempWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); - listenerFlag = listenerStatus.pending; - let loopCount = commonRGBColorArr.length - getData(0, loopCount) - - function getData(i, length) { - let tempColor = commonRGBColorArr[i]; - let systemBarProperties = { - statusBarColor: tempColor, - isStatusBarLightIcon: true, - statusBarContentColor: tempColor, - navigationBarColor: tempColor, - isNavigationBarLightIcon: false, - navigationBarContentColor: tempColor, - }; - tempWnd.setSystemBarProperties(systemBarProperties, (err, data) => { - console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err)); - console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data)); - if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.setSystemBarProperties' + tempColor + ' ', done); - } - console.log(msgStr + 'tempWnd.setSystemBarProperties ' + tempColor + ' success'); - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { - console.log(msgStr + 'time wait finished. compareCount: ' + compareCount); - listenerFlag = listenerStatus.finished; - done(); - }, 10000) + console.log(msgStr + 'tempWnd.setSystemBarProperties ' + tempColor + ' success'); + resolve(data) }) - }) + } }) - }) + } + + await getMainWindow() + await show() + await setFullScreen() + ohosWindowOn() + await setSystemBarEnableNavigationT() + await setSystemBarProperties() }) /** * @tc.number SUB_WINDOW_SETSYSTEMBARPROPERTIES_JSAPI_005 * @tc.name Test setSystemBarPropertiesTest5 * @tc.desc Verify the scene where the status bar and navigation bar colors are set in hexadecimal form */ - it('setSystemBarPropertiesTest5', 0, done => { + it('setSystemBarPropertiesTest5', 0, async done => { let caseName = 'setSystemBarPropertiesTest5'; let msgStr = 'jsunittest ' + caseName + ' '; let cloneColorArr = { @@ -697,111 +907,133 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) }; let compareCount = 0; let endNum = 0; - let listenerFlag = listenerStatus.ready; + let listenerFlag = false; console.log(msgStr + 'begin'); listenerData.on = true; listenerData.typeStr = 'systemBarTintChange'; - ohosWindow.on('systemBarTintChange', (systemBarData) => { - console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); - if (listenerFlag === listenerStatus.pending) { - try { - expect(!!systemBarData).assertTrue(); - expect(!!systemBarData.regionTint).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) - } - let arrLength = systemBarData.regionTint.length; - for (let i = 0; i < arrLength; i++) { - console.log(msgStr + 'for arrLenght compareCount: ' + compareCount + ' ,i:'+i+' ,arrLength:'+arrLength); - let tempData = systemBarData.regionTint[i]; - if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR) { - console.log(msgStr + 'systemBarTintChange compare start! arrLength= ' + arrLength); - compareCount++; - let backgroundIndex = cloneColorArr.SBC.indexOf(tempData.backgroundColor); - let contentColorIndex = cloneColorArr.SCC.indexOf(tempData.contentColor); - if (backgroundIndex >= 0) { - cloneColorArr.SBC.splice(backgroundIndex, 1); - } else { - console.log(msgStr + 'SBC tempData.backgroundColor:' + JSON.stringify(tempData.backgroundColor)); - } - if (contentColorIndex >= 0) { - cloneColorArr.SCC.splice(contentColorIndex, 1); - } else { - console.log(msgStr + 'SCC tempData.contentColor:' + JSON.stringify(tempData.contentColor)); - } - let ca = cloneColorArr; - let flag = ca.NCC.length || ca.NBC.length || ca.SBC.length || ca.SCC.length - if (compareCount === 18 && !flag) { - console.log(msgStr + 'if compareCount: ' + compareCount + ' ,true flag:' + flag); - try { - expect(true).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) + + function ohosWindowOn() { + ohosWindow.on('systemBarTintChange', (systemBarData) => { + console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); + if (listenerFlag) { + try { + expect(!!systemBarData).assertTrue(); + expect(!!systemBarData.regionTint).assertTrue(); + } catch (error) { + console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) + } + let arrLength = systemBarData.regionTint.length; + for (let i = 0; i < arrLength; i++) { + console.log(msgStr + 'for arrLenght compareCount: ' + compareCount + ' ,i:' + i + ' ,arrLength:' + arrLength); + let tempData = systemBarData.regionTint[i]; + if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR) { + console.log(msgStr + 'systemBarTintChange compare start! arrLength= ' + arrLength); + compareCount++; + let backgroundIndex = cloneColorArr.SBC.indexOf(tempData.backgroundColor); + let contentColorIndex = cloneColorArr.SCC.indexOf(tempData.contentColor); + if (backgroundIndex >= 0) { + cloneColorArr.SBC.splice(backgroundIndex, 1); + } else { + console.log(msgStr + 'SBC tempData.backgroundColor:' + JSON.stringify(tempData.backgroundColor)); } - } else { - console.log(msgStr + 'compareCount: ' + compareCount + ' ,flag:' + flag); - } - console.log(msgStr + 'compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.SCC.length) + ' ,cloneColorArr.SBC:' + JSON.stringify(cloneColorArr.SBC)); - console.log(msgStr + 'compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.SCC.length) + ' ,cloneColorArr.SCC' + JSON.stringify(cloneColorArr.SCC)); - done(); - } else if (tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { - console.log(msgStr + 'systemBarTintChange compare start!'); - compareCount++; - let backgroundIndex = cloneColorArr.NBC.indexOf(tempData.backgroundColor); - let contentColorIndex = cloneColorArr.NCC.indexOf(tempData.contentColor); - if (backgroundIndex >= 0) { - cloneColorArr.NBC.splice(backgroundIndex, 1); - } else { - console.log(msgStr + 'NBC tempData.backgroundColor:' + JSON.stringify(tempData.backgroundColor)); - } - if (contentColorIndex >= 0) { - cloneColorArr.NCC.splice(contentColorIndex, 1); - } else { - console.log(msgStr + 'NCC tempData.contentColor:' + JSON.stringify(tempData.contentColor)); - } - let ca = cloneColorArr; - let flag = ca.NCC.length || ca.NBC.length || ca.SBC.length || ca.SCC.length - if (compareCount === 18 && !flag) { - console.log(msgStr + 'else compareCount: ' + compareCount + ' ,true flag:' + flag); - try { - expect(true).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) + if (contentColorIndex >= 0) { + cloneColorArr.SCC.splice(contentColorIndex, 1); + } else { + console.log(msgStr + 'SCC tempData.contentColor:' + JSON.stringify(tempData.contentColor)); + } + let ca = cloneColorArr; + let flag = ca.NCC.length || ca.NBC.length || ca.SBC.length || ca.SCC.length + if (compareCount === 18 && !flag) { + console.log(msgStr + 'if compareCount: ' + compareCount + ' ,true flag:' + flag); + try { + expect(true).assertTrue(); + } catch (error) { + console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) + } + } else { + console.log(msgStr + 'compareCount: ' + compareCount + ' ,flag:' + flag); + } + console.log(msgStr + 'compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.SCC.length) + ' ,cloneColorArr.SBC:' + JSON.stringify(cloneColorArr.SBC)); + console.log(msgStr + 'compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.SCC.length) + ' ,cloneColorArr.SCC' + JSON.stringify(cloneColorArr.SCC)); + done(); + } else if (tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { + console.log(msgStr + 'systemBarTintChange compare start!'); + compareCount++; + let backgroundIndex = cloneColorArr.NBC.indexOf(tempData.backgroundColor); + let contentColorIndex = cloneColorArr.NCC.indexOf(tempData.contentColor); + if (backgroundIndex >= 0) { + cloneColorArr.NBC.splice(backgroundIndex, 1); + } else { + console.log(msgStr + 'NBC tempData.backgroundColor:' + JSON.stringify(tempData.backgroundColor)); + } + if (contentColorIndex >= 0) { + cloneColorArr.NCC.splice(contentColorIndex, 1); + } else { + console.log(msgStr + 'NCC tempData.contentColor:' + JSON.stringify(tempData.contentColor)); } - } else { - console.log(msgStr + 'compareCount: ' + compareCount + ' ,flag:' + flag); + let ca = cloneColorArr; + let flag = ca.NCC.length || ca.NBC.length || ca.SBC.length || ca.SCC.length + if (compareCount === 18 && !flag) { + console.log(msgStr + 'else compareCount: ' + compareCount + ' ,true flag:' + flag); + try { + expect(true).assertTrue(); + } catch (error) { + console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) + } + } else { + console.log(msgStr + 'compareCount: ' + compareCount + ' ,flag:' + flag); + } + console.log(msgStr + 'compareCount: ' + endNum + ' ,compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.NBC.length) + ' ,cloneColorArr.SBC:' + JSON.stringify(cloneColorArr.NBC)); + console.log(msgStr + 'compareCount: ' + endNum + ' ,compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.NCC.length) + ' ,cloneColorArr.SCC' + JSON.stringify(cloneColorArr.NCC)); + endNum = compareCount + done(); } - console.log(msgStr + 'compareCount: ' + endNum + ' ,compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.NBC.length) + ' ,cloneColorArr.SBC:' + JSON.stringify(cloneColorArr.NBC)); - console.log(msgStr + 'compareCount: ' + endNum + ' ,compareCount: ' + compareCount + ' ,length: ' + JSON.stringify(cloneColorArr.NCC.length) + ' ,cloneColorArr.SCC' + JSON.stringify(cloneColorArr.NCC)); - endNum = compareCount - done(); } } - } - }) - console.log(msgStr + 'tempWnd.on systemBarTintChange finished'); - windowStage.getMainWindow((err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'windowStage.getMainWindow', done); - } - let tempWnd = data - try { - expect(!!tempWnd).assertTrue(); - } catch (error) { - console.info(`windowStage.getMainWindow catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); - tempWnd.show((err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.show', done); - } - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'tempWnd.show success'); - tempWnd.setFullScreen(true, (err, data) => { + console.log(msgStr + 'tempWnd.on systemBarTintChange finished'); + }) + } + + let tempWnd = null + + function getMainWindow() { + return new Promise(function (resolve, reject) { + windowStage.getMainWindow((err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'windowStage.getMainWindow', done); + } + tempWnd = data + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`windowStage.getMainWindow catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); + resolve(data) + }) + }) + } + + function show() { + return new Promise(function (resolve, reject) { + tempWnd.show((err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.show', done); + } + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'tempWnd.show success'); + resolve(data) + }) + }) + } + + function setFullScreen() { + return new Promise(function (resolve, reject) { + tempWnd.setFullScreen(true, (err, data) => { if (err && err.code) { unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done); } @@ -811,125 +1043,151 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) console.info(`tempWnd.setFullScreen catch error: ${JSON.stringify(error)}`) } console.log(msgStr + 'tempWnd.setFullScreen(true) success'); - tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { + resolve(data) + }) + }) + } + + function setSystemBarEnableNavigationT() { + return new Promise(function (resolve, reject) { + tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); + } + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.setSystemBatEnable catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); + listenerFlag = true; + resolve(data) + }) + }) + } + + function setSystemBarProperties() { + return new Promise(function (resolve, reject) { + let loopCount = commonNUMBERColorArr.length + for (let i = 0; i < loopCount; i++) { + console.log(msgStr + 'tempWnd.setSystemBarEnable i:' + i); + let tempColor = commonNUMBERColorArr[i]; + let systemBarProperties = { + statusBarColor: tempColor, + isStatusBarLightIcon: true, + statusBarContentColor: tempColor, + navigationBarColor: tempColor, + isNavigationBarLightIcon: true, + navigationBarContentColor: tempColor, + }; + tempWnd.setSystemBarProperties(systemBarProperties, (err, data) => { + console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data)); if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); - } - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`tempWnd.setSystemBatEnable catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); - listenerFlag = listenerStatus.pending; - let loopCount = commonNUMBERColorArr.length - getData(0, loopCount) - - function getData(i, length) { - console.log(msgStr+'tempWnd.setSystemBarEnable i:'+i); - let tempColor = commonNUMBERColorArr[i]; - let systemBarProperties = { - statusBarColor: tempColor, - isStatusBarLightIcon: true, - statusBarContentColor: tempColor, - navigationBarColor: tempColor, - isNavigationBarLightIcon: true, - navigationBarContentColor: tempColor, - }; - tempWnd.setSystemBarProperties(systemBarProperties, (err, data) => { - console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err)); - console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data)); - if (err && err.code) { - try { - expect(TRUE_FLAG).assertFail(); - } catch (error) { - console.info(`tempWnd.setSystemBarProperties catch error: ${JSON.stringify(error)}`) - } - } - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + it('setSystemBarPropertiesTest6', 0, async done => { let caseName = 'setSystemBarPropertiesTest6'; let msgStr = 'jsunittest ' + caseName + ' '; let cloneColorArr = JSON.parse(JSON.stringify(commonKEYColorArr)); let compareCount = 0; - let listenerFlag = listenerStatus.ready; + let listenerFlag = false; console.log(msgStr + 'begin'); listenerData.on = true; listenerData.typeStr = 'systemBarTintChange'; - ohosWindow.on('systemBarTintChange', (systemBarData) => { - console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); - if (listenerFlag === listenerStatus.pending) { - try { - expect(!!systemBarData).assertTrue(); - expect(!!systemBarData.regionTint).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) - } - let arrLength = systemBarData.regionTint.length; - getData(0, arrLength) - function getData(i, length) { - let tempData = systemBarData.regionTint[i]; - if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { - console.log(msgStr + 'systemBarTintChange compare start!'); - compareCount++; - let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor); - let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor); - try { - expect(backgroundIndex === -1).assertTrue(); - expect(contentColorIndex === -1).assertTrue(); - } catch (error) { - console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) - } - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); + if (listenerFlag) { + try { + expect(!!systemBarData).assertTrue(); + expect(!!systemBarData.regionTint).assertTrue(); + } catch (error) { + console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) + } + let arrLength = systemBarData.regionTint.length; + for (let i = 0; i < arrLength; i++) { + let tempData = systemBarData.regionTint[i]; + if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { + console.log(msgStr + 'systemBarTintChange compare start!'); + compareCount++; + let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor); + let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor); + try { + expect(backgroundIndex === -1).assertTrue(); + expect(contentColorIndex === -1).assertTrue(); + } catch (error) { + console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) + } } } } - } - }) - console.log(msgStr + 'tempWnd.on systemBarTintChange finished'); - windowStage.getMainWindow((err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'windowStage.getMainWindow', done); - } - let tempWnd = data - try { - expect(!!tempWnd).assertTrue(); - } catch (error) { - console.info(`winsowStage.getMainWindow catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); - tempWnd.show((err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.show', done); - } - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'tempWnd.show success'); + console.log(msgStr + 'tempWnd.on systemBarTintChange finished'); + }) + } + + let tempWnd = null + + function getMainWindow() { + return new Promise(function (resolve, reject) { + windowStage.getMainWindow((err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'windowStage.getMainWindow', done); + } + tempWnd = data + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`winsowStage.getMainWindow catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); + resolve(data) + }) + }) + } + + function show() { + return new Promise(function (resolve, reject) { + tempWnd.show((err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.show', done); + } + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'tempWnd.show success'); + resolve(data) + }) + }) + } + + function setFullScreen() { + return new Promise(function (resolve, reject) { tempWnd.setFullScreen(true, (err, data) => { if (err && err.code) { unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done); @@ -940,73 +1198,80 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) console.info(`tempWnd.setFullScreen catch error: ${JSON.stringify(error)}`) } console.log(msgStr + 'tempWnd.setFullScreen(true) success'); - tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { + resolve(data) + }) + }) + } + + function setSystemBarEnableNavigationT() { + return new Promise(function (resolve, reject) { + tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); + } + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); + listenerFlag = true; + resolve(data) + }) + }) + } + + function setSystemBarProperties() { + return new Promise(function (resolve, reject) { + let loopCount = commonRGBColorArr.length + for (let i = 0; i < loopCount; i++) { + let tempColor = commonKEYColorArr[i]; + let systemBarProperties = { + statusBarColor: tempColor, + isStatusBarLightIcon: true, + statusBarContentColor: tempColor, + navigationBarColor: tempColor, + isNavigationBarLightIcon: false, + navigationBarContentColor: tempColor, + }; + tempWnd.setSystemBarProperties(systemBarProperties, (err, data) => { + console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data)); if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); - } - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`tempWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); - listenerFlag = listenerStatus.pending; - let loopCount = commonRGBColorArr.length - getData(0, loopCount) - - function getData(i, length) { - let tempColor = commonKEYColorArr[i]; - let systemBarProperties = { - statusBarColor: tempColor, - isStatusBarLightIcon: true, - statusBarContentColor: tempColor, - navigationBarColor: tempColor, - isNavigationBarLightIcon: false, - navigationBarContentColor: tempColor, - }; - tempWnd.setSystemBarProperties(systemBarProperties, (err, data) => { - console.log(msgStr + 'tempWnd.setSystemBarProperties err' + JSON.stringify(err)); - console.log(msgStr + 'tempWnd.setSystemBarProperties data' + JSON.stringify(data)); - if (err && err.code) { - try { - expect(TRUE_FLAG).assertFail(); - } catch (error) { - console.info(`tempWnd.setSystemBarProperties catch error: ${JSON.stringify(error)}`) - } - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { - console.log(msgStr + 'time wait finished. compareCount: ' + compareCount); - listenerFlag = listenerStatus.finished; + try { + expect(TRUE_FLAG).assertFail(); + } catch (error) { + console.info(`tempWnd.setSystemBarProperties catch error: ${JSON.stringify(error)}`) + } + resolve(data) done(); - }, 10000) + } }) - }) + } + listenerFlag = false; + done(); }) - }) + } + + await getMainWindow() + await show() + await setFullScreen() + ohosWindowOn() + await setSystemBarEnableNavigationT() + await setSystemBarProperties() }) /** * @tc.number SUB_WINDOW_CREATE_JSAPI_005 * @tc.name Test create5 * @tc.desc Scheme of Failed to Create Application Type Window in Stage Mode */ - it('createTest5', 0, done => { + it('createTest5', 0, async done => { let caseName = 'createTest5'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin context==' + JSON.stringify(context)); let loopCount = appWindowTypeArr.length; console.log(msgStr + 'loopCount: ' + loopCount); - getData(0, loopCount) - - function getData(i, length) { + for (let i = 0; i < loopCount; i++) { let tempType = ohosWindow.WindowType.TYPE_APP; let windId = 'createTest5' + i; console.log(msgStr + 'ohosWindow.create ' + tempType + ' start'); @@ -1016,19 +1281,13 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) if (err && err.code) { try { expect(err.code === 1003).assertTrue(); - } catch (error) { console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`) } - console.log(msgStr + 'ohosWindow.create err.code==' + JSON.stringify(err.code)) - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + it('createTest6', 0, async done => { let caseName = 'createTest6'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin'); let loopCount = systemWindowTypeArr.length; - console.log('jsunittest loopCount: ' + loopCount); - getData(0, loopCount) + console.log(msgStr + 'loopCount: ' + loopCount); + let tempWnd = null + let tempType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT; - function getData(i, length) { - let tempType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT; - let windId = 'createTest6' + i; - console.log(msgStr + 'ohosWindow.create ' + tempType + ' start'); - ohosWindow.create(context, windId, tempType, (err, data) => { - console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); - console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); - if (err && err.code) { - unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done); - return; - } - try { - expect(!!data).assertTrue(); - } catch (error) { - console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`) - } - let tempWnd = data - console.log(msgStr + 'ohosWindow.create ' + tempType + ' wnd: ' + tempWnd); + function create(i) { + return new Promise(function (resolve, reject) { + let windId = 'createTest6' + i; + console.log(msgStr + 'ohosWindow.create ' + tempType + ' start'); + console.log(msgStr + 'ohosWindow.create windId: ' + windId + ' start'); + ohosWindow.create(context, windId, tempType, (err, data) => { + console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done); + return; + } + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`) + } + tempWnd = data + console.log(msgStr + 'ohosWindow.create ' + tempType + ' wnd: ' + tempWnd); + resolve(i) + }) + }) + } + + function getProperties(i) { + return new Promise(function (resolve, reject) { tempWnd.getProperties((err, data) => { console.log(msgStr + 'tempWnd.getProperties err' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.getProperties data' + JSON.stringify(data)); @@ -1082,236 +1350,488 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) } catch (error) { console.info(`tempWnd.getProperties catch error: ${JSON.stringify(error)}`) } - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); + resolve(i) + }) + }) + } + + function find(i) { + return new Promise(function (resolve, reject) { + console.log(msgStr + 'ohosWindow.find createTest6' + i); + ohosWindow.find('createTest6' + i, (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); } else { - console.log(msgStr + 'i++ { + console.log(msgStr + 'tempWnd.destroy err' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.destroy data' + JSON.stringify(data)); + console.log(msgStr + 'tempWnd.destroy !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.destroy', done); + } else { + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(i) + }) + }) + } + + function findAgain(i) { + return new Promise(function (resolve, reject) { + console.log(msgStr + 'ohosWindow.findAgain createTest6' + i); + ohosWindow.find('createTest6' + i, (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + expect(true).assertTrue(); + } else { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + try { + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(i) + done(); + }) + }) + } + + for (let i = 0; i < loopCount; i++) { + await create(i) + await getProperties(i) + await find(i) + await destroy(i) + await findAgain(i) + } }) /** * @tc.number SUB_WINDOW_CREATE_JSAPI_007 * @tc.name Test createTest7 * @tc.desc Verify the scenario of creating a window of a type that does not exist */ - it('createTest7', 0, done => { + it('createTest7', 0, async done => { let caseName = 'createTest7'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin'); let tempType = 5000; let windId = 'createTest7'; console.log(msgStr + 'ohosWindow.create ' + tempType + ' start'); - ohosWindow.create(context, windId, tempType, (err, data) => { - console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); - if (err && err.code) { - try { - expect(err.code === 1003).assertTrue(); - } catch (error) { - console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`) - } - done(); - return; - } - unexpectedError(err, caseName, 'ohosWindow.create', done); - }) + + function create() { + return new Promise(function (resolve, reject) { + ohosWindow.create(context, windId, tempType, (err, data) => { + console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); + if (err && err.code) { + try { + expect(err.code === 1003).assertTrue(); + } catch (error) { + console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`) + } + done(); + return; + } + unexpectedError(err, caseName, 'ohosWindow.create', done); + resolve(data) + }) + }) + } + + await create() }) + /** - * @tc.number SUB_WINDOW_ON_OFF_JSAPI_005 - * @tc.name Test listenerTest5 - * @tc.desc Verify whether the change of avoidance area and change monitoring can be turned on normally + * @tc.number SUB_WINDOW_CREATE_JSAPI_008 + * @tc.name Test createTest8 + * @tc.desc Verify the scenario of creating a window with duplicate IDs */ - it('listenerTest5', 0, function (done) { - let caseName = 'listenerTest5'; + it('createTest8', 0, async done => { + let caseName = 'createTest8'; let msgStr = 'jsunittest ' + caseName + ' '; - let listenerOnFlag = listenerStatus.ready; console.log(msgStr + 'begin'); + let windowId = 'sameid' let tempWnd = null; - windowStage.getMainWindow((err, data) => { - console.log(msgStr + 'windowStage.getMainWindow err: ' + JSON.stringify(err)); - console.log(msgStr + 'windowStage.getMainWindow data: ' + JSON.stringify(data)); - if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.show', done); - } - tempWnd = data - console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); - try { - expect(!!tempWnd).assertTrue(); - } catch (error) { - console.info(`windowStage.getMainWindow catch error: ${JSON.stringify(error)}`) - } - tempWnd.show((err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.show', done); - } - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'tempWnd.show success'); - tempWnd.setFullScreen(true, (err, data) => { + + function create() { + return new Promise(function (resolve, reject) { + ohosWindow.create(context, windowId, 1, (err, data) => { + console.log(msgStr + 'ohosWindow.create 1 once err: ' + JSON.stringify(err)); if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done); - } - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`tempWnd.setFullScreen catch error: ${JSON.stringify(error)}`) + unexpectedError(err, caseName, 'ohosWindow.create', done); } - console.log(msgStr + 'tempWnd.setFullScreen(true) success'); - tempWnd.on('systemAvoidAreaChange', avoidAreaData => { - console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, avoidAreaData : ' + JSON.stringify(avoidAreaData)); - if (listenerOnFlag === listenerStatus.pending) { - listenerOnFlag = listenerStatus.finished; - try { - expect(!!avoidAreaData).assertTrue(); - } catch (error) { - console.info(`tempWnd.on catch error: ${JSON.stringify(error)}`) - } + expect(!!data).assertTrue(); + tempWnd = data; + resolve(data) + }) + }) + } + + function createAgain() { + return new Promise(function (resolve, reject) { + ohosWindow.create(context, windowId, 1, (err, data) => { + console.log(msgStr + 'ohosWindow.create 1 twice err: ' + JSON.stringify(err)); + if (err && err.code) { + console.log(msgStr + 'ohosWindow.create 1 twice data: ' + JSON.stringify(data)); + try { + expect(err.code).assertEqual(1300001) + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) } - done(); - }) - tempWnd.setSystemBarEnable([], (err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([])', done); + } else { + unexpectedError(err, caseName, 'ohosWindow.create', done); + console.log(msgStr + 'ohosWindow.create 1 twice data: ' + JSON.stringify(data)); + } + resolve(data) + }) + }) + } + + function find() { + return new Promise(function (resolve, reject) { + ohosWindow.find(windowId, (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } else { + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) } + } + resolve(data) + }) + }) + } + + function destroy(params) { + return new Promise(function (resolve, reject) { + tempWnd.destroy((err, data) => { + console.log(msgStr + 'tempWnd.destroy err' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.destroy data' + JSON.stringify(data)); + console.log(msgStr + 'tempWnd.destroy !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.destroy', done); + } else { try { expect(!data).assertTrue(); } catch (error) { - console.info(`tempWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`) + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) } - console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success'); - listenerOnFlag = listenerStatus.pending; - }) - tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); + } + resolve(data) + }) + }) + } + + function findAgain(params) { + return new Promise(function (resolve, reject) { + ohosWindow.find(windowId, (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + expect(true).assertTrue(); + } else { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + try { + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) } - console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); - }) + } + resolve(data) + done(); + }) + }) + } + + await create() + .then(function (params) { + console.log(msgStr + 'create then: ' + JSON.stringify(params)) + return createAgain() + }).then(function (params) { + return find() + }).then(function (params) { + return destroy(params) + }).then(function (params) { + return findAgain(params) + }) + }) + + /** + * @tc.number SUB_WINDOW_ON_OFF_JSAPI_005 + * @tc.name Test listenerTest5 + * @tc.desc Verify whether the change of avoidance area and change monitoring can be turned on normally + */ + it('listenerTest5', 0, async function (done) { + let caseName = 'listenerTest5'; + let msgStr = 'jsunittest ' + caseName + ' '; + let listenerOnFlag = false; + console.log(msgStr + 'begin'); + let tempWnd = null; + listenerData.on = true; + listenerData.typeStr = 'systemAvoidAreaChange'; + + function getMainWindow() { + return new Promise(function (resolve, reject) { + windowStage.getMainWindow((err, data) => { + console.log(msgStr + 'windowStage.getMainWindow err: ' + JSON.stringify(err)); + console.log(msgStr + 'windowStage.getMainWindow data: ' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.show', done); + } + tempWnd = data + newWindowObj = data + console.log(msgStr + 'newWindowObj 1: ' + JSON.stringify(newWindowObj)); + console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`windowStage.getMainWindow catch error: ${JSON.stringify(error)}`) + } + resolve(data) + }) + }) + } + + function show() { + return new Promise(function (resolve, reject) { + tempWnd.show((err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.show', done); + } + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'tempWnd.show success'); + resolve(data) + }) + }) + } + + function setFullScreen() { + return new Promise(function (resolve, reject) { + tempWnd.setFullScreen(true, (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done); + } + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.setFullScreen catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'tempWnd.setFullScreen(true) success'); + resolve(data) + }) + }) + } + + function tempWndOn() { + tempWnd.on('systemAvoidAreaChange', avoidAreaData => { + console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, avoidAreaData : ' + JSON.stringify(avoidAreaData)); + if (listenerOnFlag === true) { + listenerOnFlag = false; + try { + expect(!!avoidAreaData).assertTrue(); + } catch (error) { + console.info(`tempWnd.on catch error: ${JSON.stringify(error)}`) + } + } + }) + } + + function setSystemBarEnable() { + return new Promise(function (resolve, reject) { + tempWnd.setSystemBarEnable([], (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([])', done); + } + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.setSystemBarEnable catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success'); + listenerOnFlag = true; + resolve(data) + }) + }) + } + + function setSystemBarEnableT() { + return new Promise(function (resolve, reject) { + tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); + } + console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); console.log(msgStr + 'tempWnd.on systemAvoidAreaChange finished'); + resolve(data) + tempWnd.off('systemAvoidAreaChange') + done(); }) }) - }) + } + + await getMainWindow() + await show() + await setFullScreen() + tempWndOn() + await setSystemBarEnable() + await setSystemBarEnableT() }) /** * @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_003 * @tc.name Test setWindowTypeTest3 * @tc.desc Verify the scenario where the normal window type is set */ - it('setWindowTypeTest3', 0, function (done) { + it('setWindowTypeTest3', 0, async function (done) { let caseName = 'setWindowTypeTest3'; let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; + let windowId = 'setWindowTypeTest3'; console.log(msgStr + 'begin'); + console.log(msgStr + 'newWindowObj 2: ' + JSON.stringify(newWindowObj)); let tempWnd = null let tempTypeArr = []; - try { - let data = windowStage.getMainWindowSync(); - console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); - console.log(msgStr + 'ohosWindow.create !!data' + !!data); - if (!!data) { - tempWnd = data -// console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' wnd: ' + tempWnd); - try { - expect(!!tempWnd).assertTrue(); - } catch (error) { - console.info(`ohosWindwo.create catch error: ${JSON.stringify(error)}`) - } - let loopCount1 = systemWindowTypeArr; - console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(loopCount1)) - getData(0, loopCount1.length) + let loopCount1 = systemWindowTypeArr; + console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(loopCount1)) - function getData(i, length) { - let tempType = ohosWindow.WindowType[loopCount1[i]]; - console.log(msgStr + 'tempWnd.setWindowType ' + tempType + ' start'); - tempTypeArr.push(tempType); - tempWnd.setWindowType(tempType, (err, data) => { + function create() { + return new Promise(function (resolve, reject) { + ohosWindow.create(context, windowId, baseWndType, (err, data) => { + try { + console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.create !!data' + !!data); + if (!!data) { + tempWnd = data + console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' wnd: ' + tempWnd); try { - console.log(msgStr + 'tempWnd.setWindowType i: ' + i); - console.log(msgStr + 'tempWnd.setWindowType err: ' + JSON.stringify(err)); - console.log(msgStr + 'tempWnd.setWindowType data: ' + JSON.stringify(data)); - console.log(msgStr + 'tempWnd.setWindowType !data: ' + !data); - if (!data) { - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`tempWnd.setWindowType catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'tempWnd.getProperties start'); - tempWnd.getProperties((err, dataProper) => { - try { - console.log(msgStr + 'tempWnd.getProperties err: ' + JSON.stringify(err)); - console.log(msgStr + 'tempWnd.getProperties dataProper: ' + JSON.stringify(dataProper)); - console.log(msgStr + 'tempWnd.getProperties !!dataProper: ' + !!dataProper); - try { - expect(!!dataProper).assertTrue(); - } catch (error) { - console.info(`tempWnd.getProperties catch error: ${JSON.stringify(error)}`) - } - if (!!dataProper) { - console.log(msgStr + 'tempWnd.getProperties true tempTypeArr: ' + JSON.stringify(tempTypeArr)); - console.log(msgStr + 'tempWnd.getProperties true i: ' + i); - tempTypeArr.splice(tempTypeArr.findIndex(item => item === dataProper.type), 1); - console.log(msgStr + 'tempWnd.getProperties true tempTypeArr.length: ' + tempTypeArr.length); - console.log(msgStr + 'tempWnd.getProperties true loopCount1.length: ' + loopCount1.length); - console.log(msgStr + 'tempWnd.getProperties true tempTypeArr.length + 1: ' + Number(tempTypeArr.length + 1)); - console.log(msgStr + 'tempWnd.getProperties true (loopCount1.length - i): ' + (loopCount1.length - i)); - console.log(msgStr + 'tempWnd.getProperties true (tempTypeArr.length + 1): ' + (tempTypeArr.length + 1)); - try { - expect(tempTypeArr.length === 0).assertTrue(); - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } - } catch (error) { - console.info(`tempWnd.getProperties catch error: ${JSON.stringify(error)}`) - } - if (i == loopCount1.length - 1) { - console.log(msgStr + 'tempWnd.getProperties i=' + i + ' , loopCount1.length-1==' + loopCount1.length); - done(); - } - } - } catch (err) { - console.log(msgStr + 'tempWnd.getProperties catch err: ' + JSON.stringify(err)); - } - }) - } - console.log(msgStr + 'tempWnd.setWindowType ' + tempType + ' end'); - } catch (err) { - console.log(msgStr + 'tempWnd.setWindowType catch err: ' + JSON.stringify(err)); + expect(!!tempWnd).assertTrue(); + } catch (error) { + console.info(`ohosWindwo.create catch error: ${JSON.stringify(error)}`) } - }) + } + } catch (err) { + console.log(msgStr + 'ohosWindow.create catch err: ' + JSON.stringify(err)); } - } - } catch (err) { - console.log(msgStr + 'ohosWindow.create catch err: ' + JSON.stringify(err)); + resolve(0) + }) + }) + } + + function setWindowType(tempType, i) { + return new Promise(function (resolve, reject) { + tempWnd.setWindowType(tempType, (err, data) => { + console.log(msgStr + 'tempWnd.setWindowType i: ' + i); + console.log(msgStr + 'tempWnd.setWindowType err: ' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.setWindowType data: ' + JSON.stringify(data)); + console.log(msgStr + 'tempWnd.setWindowType !data: ' + !data); + if (!data) { + expect(!data).assertTrue(); + } else { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } + console.log(msgStr + 'tempWnd.setWindowType ' + tempType + ' end'); + resolve(data) + }) + }) + } + + function getProperties(tempType, i) { + console.log(msgStr + 'getProperties start tempTypeArr:' + JSON.stringify(tempTypeArr) + ',i:' + i); + return new Promise(function (resolve, reject) { + tempWnd.getProperties((err, dataProper) => { + console.log(msgStr + 'tempWnd.getProperties err: ' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.getProperties dataProper: ' + JSON.stringify(dataProper)); + console.log(msgStr + 'tempWnd.getProperties !!dataProper: ' + !!dataProper); + expect(!!dataProper).assertTrue(); + expect(dataProper.type === tempType).assertTrue(); + resolve(dataProper) + }) + }) + } + + await create() + for (let i = 0; i < loopCount1.length; i++) { + let tempType = ohosWindow.WindowType[loopCount1[i]]; + console.log(msgStr + 'tempWnd.setWindowType :' + tempType + ' start'); + tempTypeArr.push(tempType); + console.log(msgStr + 'for tempTypeArr:' + JSON.stringify(tempTypeArr) + ',i:' + i); + await setWindowType(tempType, i) + console.log(msgStr + 'getProperties start'); + await getProperties(tempType, i) + if (i == loopCount1.length - 1) { + console.log(msgStr + 'tempWnd.getProperties i=' + i + ' , loopCount1.length-1==' + loopCount1.length); + tempWnd.destroy(); + done(); } + } }) /** * @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_004 * @tc.name Test setWindowTypeTest4 * @tc.desc Verify the scene of setting illegal window type */ - it('setWindowTypeTest4', 0, function (done) { + it('setWindowTypeTest4', 0, async function (done) { let caseName = 'setWindowTypeTest4'; let msgStr = 'jsunittest ' + caseName + ' '; + let baseWndType = 1; let changedWndType = null; + let windowId = 'setWindowTypeTest4'; console.log(msgStr + 'begin'); let tempWnd = null - let data = windowStage.getMainWindowSync(); - console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); - console.log(msgStr + 'ohosWindow.create !!data' + !!data); - if (!!data) { - tempWnd = data - try { - expect(!!tempWnd).assertTrue(); - } catch (error) { - console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`) - } + + function create() { + return new Promise(function (resolve, reject) { + ohosWindow.create(context, windowId, baseWndType, (err, data) => { + console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.create !!data' + !!data); + if (!!data) { + tempWnd = data + try { + expect(!!tempWnd).assertTrue(); + } catch (error) { + console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`) + } + resolve(data) + } + else { + unexpectedError(err, caseName, 'ohosWindow.create', done); + } + }) + }) + } + + function setWindowType() { + return new Promise(function (resolve, reject) { tempWnd.setWindowType(changedWndType, (err, data) => { console.log(msgStr + 'tempWnd.setWindowType err' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.setWindowType data' + JSON.stringify(data)); @@ -1324,34 +1844,121 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) } catch (error) { console.info(`tempWnd.setWindowType catch error: ${JSON.stringify(error)}`) } - done(); } + resolve(data) + }) + }) + } + + function find() { + return new Promise(function (resolve, reject) { + ohosWindow.find(windowId, (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } else { + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function destroy(params) { + return new Promise(function (resolve, reject) { + tempWnd.destroy((err, data) => { + console.log(msgStr + 'tempWnd.destroy err' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.destroy data' + JSON.stringify(data)); + console.log(msgStr + 'tempWnd.destroy !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.destroy', done); + } else { + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function findAgain(params) { + return new Promise(function (resolve, reject) { + ohosWindow.find(windowId, (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + try { + expect(true).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } else { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } + resolve(data) + done(); }) - } + }) + } + + await create() + .then(function (params) { + console.log(msgStr + 'create then: ' + JSON.stringify(params)) + return setWindowType() + }).then(function (params) { + return find() + }).then(function (params) { + return destroy(params) + }).then(function (params) { + return findAgain(params) + }) }) /** * @tc.number SUB_WINDOW_DESTROY_JSAPI_002 * @tc.name Test destroyTest2 * @tc.desc Verification window destruction scenario */ - it('destroyTest2', 0, function (done) { + it('destroyTest2', 0, async function (done) { let caseName = 'destroyTest2'; let msgStr = 'jsunittest ' + caseName + ' '; let baseWndType = 1; let windowId = 'destroyTest2'; console.log(msgStr + 'begin'); let tempWnd = null - ohosWindow.create(context, windowId, baseWndType, (err, data) => { - console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); - console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); - console.log(msgStr + 'ohosWindow.create !!data' + !!data); - if (!!data) { - tempWnd = data - try { - expect(!!tempWnd).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } + + function create() { + return new Promise(function (resolve, reject) { + ohosWindow.create(context, windowId, baseWndType, (err, data) => { + console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.create !!data' + !!data); + if (!!data) { + tempWnd = data + try { + expect(!!tempWnd).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + resolve(data) + } else { + unexpectedError(err, caseName, 'ohosWindow.create', done); + } + }) + }) + } + + function destroy() { + return new Promise(function (resolve, reject) { tempWnd.destroy((err, data) => { console.log(msgStr + 'tempWnd.destroy err' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.destroy data' + JSON.stringify(data)); @@ -1380,35 +1987,53 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) } }) } + resolve(data) }) - } else { - unexpectedError(err, caseName, 'ohosWindow.create', done); - } - }) + }) + } + + await create() + .then(function (params) { + console.log(msgStr + 'create then: ' + JSON.stringify(params)) + return destroy() + }) }) /** * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_007 * @tc.name Test loadContentTest7 * @tc.desc Verify the scenario of loading an existing page */ - it('loadContentTest7', 0, function (done) { + it('loadContentTest7', 0, async function (done) { let caseName = 'loadContentTest7'; let msgStr = 'jsunittest ' + caseName + ' '; let baseWndType = 1; let windowId = 'loadContentTest7'; console.log(msgStr + 'begin'); let tempWnd = null - ohosWindow.create(context, windowId, baseWndType, (err, data) => { - console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); - console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); - console.log(msgStr + 'ohosWindow.create !!data' + !!data); - if (!!data) { - tempWnd = data - try { - expect(!!tempWnd).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } + + function create() { + return new Promise(function (resolve, reject) { + ohosWindow.create(context, windowId, baseWndType, (err, data) => { + console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.create !!data' + !!data); + if (!!data) { + tempWnd = data + try { + expect(!!tempWnd).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } else { + unexpectedError(err, caseName, 'ohosWindow.create', done); + } + resolve(data) + }) + }) + } + + function loadContent() { + return new Promise(function (resolve, reject) { tempWnd.loadContent('pages/index', (err, data) => { console.log(msgStr + 'tempWnd.loadContent err' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.loadContent data' + JSON.stringify(data)); @@ -1421,37 +2046,121 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) } catch (error) { console.info(`tempWnd.loadContent catch error: ${JSON.stringify(error)}`) } - done(); } + resolve(data) }) - } else { - unexpectedError(err, caseName, 'ohosWindow.create', done); - } - }) + }) + } + + function find() { + return new Promise(function (resolve, reject) { + ohosWindow.find(windowId, (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } else { + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function destroy(params) { + return new Promise(function (resolve, reject) { + tempWnd.destroy((err, data) => { + console.log(msgStr + 'tempWnd.destroy err' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.destroy data' + JSON.stringify(data)); + console.log(msgStr + 'tempWnd.destroy !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.destroy', done); + } else { + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function findAgain(params) { + return new Promise(function (resolve, reject) { + ohosWindow.find(windowId, (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + try { + expect(true).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } else { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } + resolve(data) + done(); + }) + }) + } + + await create() + .then(function (params) { + console.log(msgStr + 'create then: ' + JSON.stringify(params)) + return loadContent() + }).then(function (params) { + return find() + }).then(function (params) { + return destroy(params) + }).then(function (params) { + return findAgain(params) + }) }) /** * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_008 * @tc.name Test loadContentTest8 * @tc.desc Verify the scenario of loading a page that does not exist */ - it('loadContentTest8', 0, function (done) { + it('loadContentTest8', 0, async function (done) { let caseName = 'loadContentTest8'; let msgStr = 'jsunittest ' + caseName + ' '; let baseWndType = 1; let windowId = 'loadContentTest8'; console.log(msgStr + 'begin'); let tempWnd = null - ohosWindow.create(context, windowId, baseWndType, (err, data) => { - console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); - console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); - console.log(msgStr + 'ohosWindow.create !!data' + !!data); - if (!!data) { - tempWnd = data - try { - expect(!!tempWnd).assertTrue(); - } catch (error) { - console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`) - } + + function create() { + return new Promise(function (resolve, reject) { + ohosWindow.create(context, windowId, baseWndType, (err, data) => { + console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.create !!data' + !!data); + if (!!data) { + tempWnd = data + try { + expect(!!tempWnd).assertTrue(); + } catch (error) { + console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`) + } + } else { + unexpectedError(err, caseName, 'ohosWindow.create', done); + } + resolve(data) + }) + }) + } + + function loadContent() { + return new Promise(function (resolve, reject) { tempWnd.loadContent(null, (err, data) => { console.log(msgStr + 'tempWnd.loadContent err' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.loadContent data' + JSON.stringify(data)); @@ -1462,68 +2171,161 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) } catch (error) { console.info(`tempWnd.loadContent catch error: ${JSON.stringify(error)}`) } - done(); } else { unexpectedError(err, caseName, 'tempWnd.loadContent', done); } + resolve(data) }) - } else { - unexpectedError(err, caseName, 'ohosWindow.create', done); - } - }) + }) + } + + function find() { + return new Promise(function (resolve, reject) { + ohosWindow.find(windowId, (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } else { + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function destroy(params) { + return new Promise(function (resolve, reject) { + tempWnd.destroy((err, data) => { + console.log(msgStr + 'tempWnd.destroy err' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.destroy data' + JSON.stringify(data)); + console.log(msgStr + 'tempWnd.destroy !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.destroy', done); + } else { + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function findAgain(params) { + return new Promise(function (resolve, reject) { + ohosWindow.find(windowId, (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + try { + expect(true).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } else { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } + resolve(data) + done(); + }) + }) + } + + await create() + .then(function (params) { + console.log(msgStr + 'create then: ' + JSON.stringify(params)) + return loadContent() + }).then(function (params) { + return find() + }).then(function (params) { + return destroy(params) + }).then(function (params) { + return findAgain(params) + }) }) /** * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_009 * @tc.name Test loadContentTest9 * @tc.desc Verify the scenario of loading an existing page */ - it('loadContentTest9', 0, function (done) { + it('loadContentTest9', 0, async function (done) { let caseName = 'loadContentTest9'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin'); - windowStage.loadContent('pages/index/index.ets', (err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'windowStage.loadContent', done); - console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); - } else { - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'windowStage.loadContent end data=' + JSON.stringify(data)); - } - done(); - }); + + function loadContent() { + return new Promise(function (resolve, reject) { + windowStage.loadContent('pages/index/index.ets', (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'windowStage.loadContent', done); + console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); + } else { + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'windowStage.loadContent end data=' + JSON.stringify(data)); + } + resolve(data) + done(); + }) + }) + } + + await loadContent() + .then(function (params) { + console.log(msgStr + 'loadContent then: ' + JSON.stringify(params)) + }) }) /** * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_010 * @tc.name Test loadContentTest10 * @tc.desc Verify the scenario of loading an existing page */ - it('loadContentTest10', 0, function (done) { + it('loadContentTest10', 0, async function (done) { let caseName = 'loadContentTest10'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin'); - try { - windowStage.loadContent(null, (err, data) => { - console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); + + function loadContent() { + return new Promise(function (resolve, reject) { try { - expect(false).assertTrue(); - } catch (error) { - console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`) + windowStage.loadContent(null, (err, data) => { + console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); + try { + expect(false).assertTrue(); + } catch (error) { + console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`) + } + resolve(data) + }); + } catch (err) { + console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets) catch err' + JSON.stringify(err)); + try { + expect(err.code == 401).assertTrue(); + } catch (error) { + console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`) + } } - }); - } catch (err) { - console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets) catch err' + JSON.stringify(err)); - try { - expect(err.code == 401).assertTrue(); - } catch (error) { - console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`) - } + console.log(msgStr + 'end'); + done(); + }) } - console.log(msgStr + 'end'); - done(); + + await loadContent() + .then(function (params) { + console.log(msgStr + 'loadContent then: ' + JSON.stringify(params)) + }) }) /** * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_011 @@ -1534,125 +2336,247 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) let caseName = 'loadContentTest11'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin'); - windowStage.loadContent('pages/index/index.ets', abilityStorage, (err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'windowStage.loadContent', done); - console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); - } else { - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'windowStage.loadContent end data=' + JSON.stringify(data)); - } - done(); - }); + + function loadContent() { + return new Promise(function (resolve, reject) { + windowStage.loadContent('pages/index/index.ets', abilityStorage, (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'windowStage.loadContent', done); + console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); + } else { + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'windowStage.loadContent end data=' + JSON.stringify(data)); + } + resolve(data) + done(); + }) + }) + } + + await loadContent() + .then(function (params) { + console.log(msgStr + 'loadContent then: ' + JSON.stringify(params)) + }) }) /** * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_012 * @tc.name Test loadContentTest12 * @tc.desc Verify the scenario of loading an existing page */ - it('loadContentTest12', 0, function (done) { + it('loadContentTest12', 0, async function (done) { let caseName = 'loadContentTest12'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin'); - try { - windowStage.loadContent(null, abilityStorage, (err, data) => { - console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); + + function loadContent() { + return new Promise(function (resolve, reject) { try { - expect(false).assertTrue(); - } catch (error) { - console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`) + windowStage.loadContent(null, abilityStorage, (err, data) => { + console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err)); + try { + expect(false).assertTrue(); + } catch (error) { + console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`) + } + resolve(data) + }); + } catch (err) { + console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets) catch err ' + JSON.stringify(err)); + try { + expect(err.code === 401).assertTrue(); + } catch (error) { + console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`) + } } - }); - } catch (err) { - console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets) catch err ' + JSON.stringify(err)); - try { - expect(err.code === 401).assertTrue(); - } catch (error) { - console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`) - } + done(); + }) } - done(); + + await loadContent() + .then(function (params) { + console.log(msgStr + 'loadContent then: ' + JSON.stringify(params)) + }) }) /** * @tc.number SUB_WINDOW_CREATESUBWINDOW_JSAPI_003 * @tc.name Test createSubWindowTest3 * @tc.desc Verify the scenario of creating an auxiliary window */ - it('createSubWindowTest3', 0, function (done) { + it('createSubWindowTest3', 0, async function (done) { let caseName = 'createSubWindowTest3'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin'); - windowStage.createSubWindow('createSubWindowTest3', (err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'windowStage.createSubWindow', done); - console.log(msgStr + 'windowStage.createSubWindow(createSubWindowTest3) err=' + JSON.stringify(err)); - } else { - try { - expect(!!data).assertTrue(); - } catch (error) { - console.info(`windowStage.createSubWindow catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'windowStage.createSubWindow end data=' + JSON.stringify(data)); - } - done(); - }); - }) - /** - * @tc.number SUB_WINDOW_CREATESUBWINDOW_JSAPI_004 - * @tc.name Test createSubWindowTest4 - * @tc.desc Verify the scene of entering illegal values to create an auxiliary window - */ - it('createSubWindowTest4', 0, function (done) { - let caseName = 'createSubWindowTest4'; - let msgStr = 'jsunittest ' + caseName + ' '; - console.log(msgStr + 'begin'); - try { - windowStage.createSubWindow(null, (err, data) => { - console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err)); - try { - expect(false).assertTrue(); - } catch (error) { - console.info(`windowStage.createSubWindow catch error: ${JSON.stringify(error)}`) - } - }); - } catch (err) { - try { - expect(err.code === 401).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'windowStage.createSubWindow(null) catch err=' + JSON.stringify(err)); + let tempWnd = null + + function createSubWindow() { + return new Promise(function (resolve, reject) { + windowStage.createSubWindow('createSubWindowTest3', (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'windowStage.createSubWindow', done); + console.log(msgStr + 'windowStage.createSubWindow(createSubWindowTest3) err=' + JSON.stringify(err)); + } else { + try { + tempWnd = data + expect(!!data).assertTrue(); + } catch (error) { + console.info(`windowStage.createSubWindow catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'windowStage.createSubWindow end data=' + JSON.stringify(data)); + } + resolve(data) + }) + }) } - done(); - }) - /** - * @tc.number SUB_WINDOW_GETSUBWINDOW_JSAPI_002 - * @tc.name Test getSubWindowTest2 - * @tc.desc Verify the scene of obtaining all auxiliary sub windows - */ - it('getSubWindowTest2', 0, async function (done) { - let caseName = 'getSubWindowTest2'; - let msgStr = 'jsunittest ' + caseName + ' '; - console.log(msgStr + 'begin'); - windowStage.getSubWindow((err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'windowStage.getSubWindow', done); - console.log(msgStr + 'windowStage.getSubWindow(null) err=' + JSON.stringify(err)); - } else { - try { - expect(!!data).assertTrue(); - } catch (error) { - console.info(`windowStage.getSubWindow catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'windowStage.getSubWindow end data=' + JSON.stringify(data)); - } - done(); - }); - }) + + function find() { + return new Promise(function (resolve, reject) { + ohosWindow.find('createSubWindowTest3', (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } else { + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function destroy(params) { + return new Promise(function (resolve, reject) { + tempWnd.destroy((err, data) => { + console.log(msgStr + 'tempWnd.destroy err' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.destroy data' + JSON.stringify(data)); + console.log(msgStr + 'tempWnd.destroy !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.destroy', done); + } else { + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function findAgain(params) { + return new Promise(function (resolve, reject) { + ohosWindow.find('createSubWindowTest3', (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + try { + expect(true).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } else { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } + resolve(data) + done(); + }) + }) + } + + await createSubWindow() + .then(function (params) { + console.log(msgStr + 'create then: ' + JSON.stringify(params)) + return find() + }).then(function (params) { + return destroy(params) + }).then(function (params) { + return findAgain(params) + }) + }) + /** + * @tc.number SUB_WINDOW_CREATESUBWINDOW_JSAPI_004 + * @tc.name Test createSubWindowTest4 + * @tc.desc Verify the scene of entering illegal values to create an auxiliary window + */ + it('createSubWindowTest4', 0, async function (done) { + let caseName = 'createSubWindowTest4'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + + function createSubWindow() { + return new Promise(function (resolve, reject) { + try { + windowStage.createSubWindow(null, (err, data) => { + console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err)); + try { + expect(false).assertTrue(); + } catch (error) { + console.info(`windowStage.createSubWindow catch error: ${JSON.stringify(error)}`) + } + resolve(data) + }); + } catch (err) { + try { + expect(err.code === 401).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'windowStage.createSubWindow(null) catch err=' + JSON.stringify(err)); + } + done(); + }) + } + + await createSubWindow() + .then(function (params) { + console.log(msgStr + 'getMainWindow then: ' + JSON.stringify(params)) + }) + }) + /** + * @tc.number SUB_WINDOW_GETSUBWINDOW_JSAPI_002 + * @tc.name Test getSubWindowTest2 + * @tc.desc Verify the scene of obtaining all auxiliary sub windows + */ + it('getSubWindowTest2', 0, async function (done) { + let caseName = 'getSubWindowTest2'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin'); + + function getSubWindow() { + return new Promise(function (resolve, reject) { + windowStage.getSubWindow((err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'windowStage.getSubWindow', done); + console.log(msgStr + 'windowStage.getSubWindow(null) err=' + JSON.stringify(err)); + } else { + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`windowStage.getSubWindow catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'windowStage.getSubWindow end data=' + JSON.stringify(data)); + } + resolve(data) + done(); + }) + }) + } + + await getSubWindow() + .then(function (params) { + console.log(msgStr + 'getMainWindow then: ' + JSON.stringify(params)) + }) + }) /** * @tc.number SUB_WINDOW_SETPRIVACYMODE_JSAPI_002 * @tc.name Test setPrivacyModeTest2 @@ -1663,218 +2587,478 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin ohosWindow =' + JSON.stringify(ohosWindow)); let mainWnd = null; - ohosWindow.create(context, 'setPrivacyModeTest2', ohosWindow.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { - if (err && err.code) { - console.log(msgStr + 'ohosWindow.create fail err:' + JSON.stringify(err)); - try { - expect().assertFail(); - } catch (error) { - console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`) - } - done(); - } else { - try { - expect(data != null).assertTrue(); - } catch (error) { - console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'ohosWindow.create success data' + data); - mainWnd = data; + + function create() { + return new Promise(function (resolve, reject) { + ohosWindow.create(context, 'setPrivacyModeTest2', ohosWindow.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { + if (err && err.code) { + console.log(msgStr + 'ohosWindow.create fail err:' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (error) { + console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`) + } + } else { + try { + expect(data != null).assertTrue(); + } catch (error) { + console.info(`ohosWindow.create catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'ohosWindow.create success data' + data); + mainWnd = data; + resolve(data) + } + }) + }) + } + + function getProperties() { + return new Promise(function (resolve, reject) { + mainWnd.getProperties((err, data) => { + if (err.code != 0) { + console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=false err: ' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (error) { + console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`) + } + done(); + } else { + console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=fasle data:' + JSON.stringify(data)); + try { + expect(!data.isPrivacyMode).assertTrue(); + } catch (error) { + console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function setPrivacyModeTrue() { + return new Promise(function (resolve, reject) { + mainWnd.setPrivacyMode(true, (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done); + console.log(msgStr + 'mainWnd.setPrivacyMode(true) err=' + JSON.stringify(err)); + } else { + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.setPrivacyMode catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'mainWnd.setPrivacyMode true data=' + JSON.stringify(data)); + } + resolve(data) + }) + }) + } + + function getProperties2() { + return new Promise(function (resolve, reject) { + mainWnd.getProperties((err, data) => { + if (err.code != 0) { + console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true fail err: ' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (error) { + console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`) + } + done(); + } else { + console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true callback data:' + JSON.stringify(data)); + try { + expect(data.isPrivacyMode).assertTrue(); + } catch (error) { + console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function setPrivacyModeFalse() { + return new Promise(function (resolve, reject) { + mainWnd.setPrivacyMode(false, (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done); + console.log(msgStr + 'mainWnd.setPrivacyMode(false) err=' + JSON.stringify(err)); + } else { + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`mainWnd.setPrivacyMode catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'mainWnd.setPrivacyMode(false) end data=' + JSON.stringify(data)); + } + resolve(data) + }) + }) + } + + function getProperties3() { + return new Promise(function (resolve, reject) { + mainWnd.getProperties((err, data) => { + if (err.code != 0) { + console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback fail err: ' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (error) { + console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`) + } + done(); + } else { + console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback data:' + JSON.stringify(data)); + try { + expect(!data.isPrivacyMode).assertTrue(); + } catch (error) { + console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function find() { + return new Promise(function (resolve, reject) { + ohosWindow.find('setPrivacyModeTest2', (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } else { + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function destroy(params) { + return new Promise(function (resolve, reject) { + mainWnd.destroy((err, data) => { + console.log(msgStr + 'tempWnd.destroy err' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.destroy data' + JSON.stringify(data)); + console.log(msgStr + 'tempWnd.destroy !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.destroy', done); + } else { + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function findAgain(params) { + return new Promise(function (resolve, reject) { + ohosWindow.find('setPrivacyModeTest2', (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + try { + expect(true).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } else { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } + resolve(data) + done(); + }) + }) + } + + await create() + .then(function (params) { + console.log(msgStr + 'create then: ' + JSON.stringify(params)) + return getProperties() + }) + .then(function (params) { + console.log(msgStr + 'getProperties then: ' + JSON.stringify(params)) + return setPrivacyModeTrue() + }) + .then(function (params) { + console.log(msgStr + 'setPrivacyModeTrue then: ' + JSON.stringify(params)) + return getProperties2() + }) + .then(function (params) { + console.log(msgStr + 'getProperties2 then: ' + JSON.stringify(params)) + return setPrivacyModeFalse() + }) + .then(function (params) { + console.log(msgStr + 'setPrivacyModeFalse then: ' + JSON.stringify(params)) + return getProperties3() + }) + .then(function (params) { + console.log(msgStr + 'getProperties3 then: ' + JSON.stringify(params)) + return find() + }) + .then(function (params) { + console.log(msgStr + 'find then: ' + JSON.stringify(params)) + return destroy(params) + }) + .then(function (params) { + console.log(msgStr + 'destroy then: ' + JSON.stringify(params)) + return findAgain(params) + }) + }) + /** + * @tc.number SUB_WINDOW_SETPRIVACYMODE_JSAPI_003 + * @tc.name Test setPrivacyModeTest3 + * @tc.desc Verify that the auxiliary window is set as the security layer + */ + it('setPrivacyModeTest3', 0, async function (done) { + let caseName = 'setPrivacyModeTest3'; + let msgStr = 'jsunittest ' + caseName + ' '; + console.log(msgStr + 'begin ohosWindow =' + JSON.stringify(ohosWindow)); + let mainWnd = null; + + function createSubWindow() { + return new Promise(function (resolve, reject) { + windowStage.createSubWindow('setPrivacyModeTest3', (err, data) => { + if (err && err.code) { + console.log(msgStr + 'windowStage.createSubWindow fail err:' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + done(); + } else { + try { + expect(data != null).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'windowStage.createSubWindow success data' + data); + mainWnd = data; + } + resolve(data) + }) + }) + } + + function getProperties() { + return new Promise(function (resolve, reject) { + mainWnd.getProperties((err, data) => { + if (err.code != 0) { + console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=false err: ' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + done(); + } else { + console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=fasle data:' + JSON.stringify(data)); + try { + expect(!data.isPrivacyMode).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function setPrivacyModeTrue() { + return new Promise(function (resolve, reject) { + mainWnd.setPrivacyMode(true, (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done); + console.log(msgStr + 'mainWnd.setPrivacyMode(true) err=' + JSON.stringify(err)); + } else { + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'mainWnd.setPrivacyMode true data=' + JSON.stringify(data)); + } + resolve(data) + }) + }) + } + + function getProperties2() { + return new Promise(function (resolve, reject) { + mainWnd.getProperties((err, data) => { + if (err.code != 0) { + console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true fail err: ' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + done(); + } else { + console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true callback data:' + JSON.stringify(data)); + try { + expect(data.isPrivacyMode).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function setPrivacyModeFalse() { + return new Promise(function (resolve, reject) { + mainWnd.setPrivacyMode(false, (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done); + console.log(msgStr + 'mainWnd.setPrivacyMode(false) err=' + JSON.stringify(err)); + } else { + try { + expect(!data).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + console.log(msgStr + 'mainWnd.setPrivacyMode(false) end data=' + JSON.stringify(data)); + } + resolve(data) + }) + }) + } + + function getProperties3() { + return new Promise(function (resolve, reject) { mainWnd.getProperties((err, data) => { if (err.code != 0) { - console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=false err: ' + JSON.stringify(err)); + console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback fail err: ' + JSON.stringify(err)); try { expect().assertFail(); } catch (error) { - console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`) + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) } done(); } else { - console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=fasle data:' + JSON.stringify(data)); + console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback data:' + JSON.stringify(data)); try { expect(!data.isPrivacyMode).assertTrue(); } catch (error) { - console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`) + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) } - mainWnd.setPrivacyMode(true, (err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done); - console.log(msgStr + 'mainWnd.setPrivacyMode(true) err=' + JSON.stringify(err)); - } else { - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`mainWnd.setPrivacyMode catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'mainWnd.setPrivacyMode true data=' + JSON.stringify(data)); - mainWnd.getProperties((err, data) => { - if (err.code != 0) { - console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true fail err: ' + JSON.stringify(err)); - try { - expect().assertFail(); - } catch (error) { - console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`) - } - done(); - } else { - console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true callback data:' + JSON.stringify(data)); - try { - expect(data.isPrivacyMode).assertTrue(); - } catch (error) { - console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`) - } - mainWnd.setPrivacyMode(false, (err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done); - console.log(msgStr + 'mainWnd.setPrivacyMode(false) err=' + JSON.stringify(err)); - } else { - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`mainWnd.setPrivacyMode catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'mainWnd.setPrivacyMode(false) end data=' + JSON.stringify(data)); - mainWnd.getProperties((err, data) => { - if (err.code != 0) { - console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback fail err: ' + JSON.stringify(err)); - try { - expect().assertFail(); - } catch (error) { - console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`) - } - done(); - } else { - console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback data:' + JSON.stringify(data)); - try { - expect(!data.isPrivacyMode).assertTrue(); - } catch (error) { - console.info(`mainWnd.getProperties catch error: ${JSON.stringify(error)}`) - } - } - done(); - }) - } - }); - } - }) - } - }); } + resolve(data) }) - } - }) - }) - /** - * @tc.number SUB_WINDOW_SETPRIVACYMODE_JSAPI_003 - * @tc.name Test setPrivacyModeTest3 - * @tc.desc Verify that the auxiliary window is set as the security layer - */ - it('setPrivacyModeTest3', 0, async function (done) { - let caseName = 'setPrivacyModeTest3'; - let msgStr = 'jsunittest ' + caseName + ' '; - console.log(msgStr + 'begin ohosWindow =' + JSON.stringify(ohosWindow)); - let mainWnd = null; - windowStage.createSubWindow('setPrivacyModeTest3', (err, data) => { - if (err && err.code) { - console.log(msgStr + 'windowStage.createSubWindow fail err:' + JSON.stringify(err)); - try { - expect().assertFail(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - done(); - } else { - try { - expect(data != null).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'windowStage.createSubWindow success data' + data); - mainWnd = data; - mainWnd.getProperties((err, data) => { - if (err.code != 0) { - console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=false err: ' + JSON.stringify(err)); + }) + } + + function find() { + return new Promise(function (resolve, reject) { + ohosWindow.find('setPrivacyModeTest3', (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } else { try { - expect().assertFail(); + expect(!!data).assertTrue(); } catch (error) { console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) } - done(); + } + resolve(data) + }) + }) + } + + function destroy(params) { + return new Promise(function (resolve, reject) { + mainWnd.destroy((err, data) => { + console.log(msgStr + 'tempWnd.destroy err' + JSON.stringify(err)); + console.log(msgStr + 'tempWnd.destroy data' + JSON.stringify(data)); + console.log(msgStr + 'tempWnd.destroy !!data' + !!data); + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.destroy', done); } else { - console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=fasle data:' + JSON.stringify(data)); try { - expect(!data.isPrivacyMode).assertTrue(); + expect(!data).assertTrue(); } catch (error) { console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) } - mainWnd.setPrivacyMode(true, (err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done); - console.log(msgStr + 'mainWnd.setPrivacyMode(true) err=' + JSON.stringify(err)); - } else { - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'mainWnd.setPrivacyMode true data=' + JSON.stringify(data)); - mainWnd.getProperties((err, data) => { - if (err.code != 0) { - console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true fail err: ' + JSON.stringify(err)); - try { - expect().assertFail(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - done(); - } else { - console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true callback data:' + JSON.stringify(data)); - try { - expect(data.isPrivacyMode).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - mainWnd.setPrivacyMode(false, (err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done); - console.log(msgStr + 'mainWnd.setPrivacyMode(false) err=' + JSON.stringify(err)); - } else { - try { - expect(!data).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - console.log(msgStr + 'mainWnd.setPrivacyMode(false) end data=' + JSON.stringify(data)); - mainWnd.getProperties((err, data) => { - if (err.code != 0) { - console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback fail err: ' + JSON.stringify(err)); - try { - expect().assertFail(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - done(); - } else { - console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback data:' + JSON.stringify(data)); - try { - expect(!data.isPrivacyMode).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - } - done(); - }) - } - }); - } - }) - } - }); } + resolve(data) }) - } - }) + }) + } + + function findAgain(params) { + return new Promise(function (resolve, reject) { + ohosWindow.find('setPrivacyModeTest2', (err, data) => { + console.log(msgStr + 'ohosWindow.find err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.find data' + JSON.stringify(data)); + console.log(msgStr + 'ohosWindow.find !!data' + !!data); + if (err && err.code) { + try { + expect(true).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } else { + unexpectedError(err, caseName, 'tempWnd.setWindowType', done); + } + resolve(data) + done(); + }) + }) + } + + await createSubWindow() + .then(function (params) { + console.log(msgStr + 'create then: ' + JSON.stringify(params)) + return getProperties() + }) + .then(function (params) { + console.log(msgStr + 'getProperties then: ' + JSON.stringify(params)) + return setPrivacyModeTrue() + }) + .then(function (params) { + console.log(msgStr + 'setPrivacyModeTrue then: ' + JSON.stringify(params)) + return getProperties2() + }) + .then(function (params) { + console.log(msgStr + 'getProperties2 then: ' + JSON.stringify(params)) + return setPrivacyModeFalse() + }) + .then(function (params) { + console.log(msgStr + 'setPrivacyModeFalse then: ' + JSON.stringify(params)) + return getProperties3() + }) + .then(function (params) { + console.log(msgStr + 'getProperties3 then: ' + JSON.stringify(params)) + return find() + }) + .then(function (params) { + console.log(msgStr + 'find then: ' + JSON.stringify(params)) + return destroy(params) + }) + .then(function (params) { + console.log(msgStr + 'destroy then: ' + JSON.stringify(params)) + return findAgain(params) + }) }) + /** * @tc.number SUB_WINDOW_SETDENSITTYDPI_JSAPI_002 * @tc.name Test setDensityDpiTest2 @@ -1904,9 +3088,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) currentDeviceDefault = data; currentDeviceDefaultDpi = parseInt(currentDeviceDefault.densityDPI) let dpiItem = [-80, 80, 1000, 160, 0, 320, 188.88, 0, 640, 300, currentDeviceDefaultDpi]; - getData(0, dpiItem.length) - - function getData(i, length) { + for (let i = 0; i < dpiItem.length; i++) { screens[0].setDensityDpi(dpiItem[i], (errDpi, dataDpi) => { if (errDpi.code) { console.error('Failed to set DensityDpi. Cause: ' + JSON.stringify(err) + dpiItem[i]); @@ -1925,12 +3107,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) } catch (error) { console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) } - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { - unexpectedError(err, caseName, 'windowStage.getMainWindow', done); - }); - console.log(msgStr + 'windowStage.getMainWindow' + JSON.stringify(mainWin)); - try { - expect(!!mainWin).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + let mainWin = null; + + function getMainWindow() { + return new Promise(function (resolve, reject) { + windowStage.getMainWindow((err, data) => { + console.log(msgStr + 'getMainWindow data:' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(data, caseName, 'windowStage.getMainWindow', done); + } + try { + expect(!!data).assertTrue(); + } catch (error) { + console.info(`ohosWindow.on ${JSON.stringify(error)}`) + } + mainWin = data + resolve(data); + console.log(msgStr + 'await windowStage JSON.stringify(mainWin)===' + JSON.stringify(mainWin)); + }) + }) } + let num = 0 let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE', 'PORTRAIT_INVERTED', 'LANDSCAPE_INVERTED', 'AUTO_ROTATION', 'AUTO_ROTATION_PORTRAIT', 'AUTO_ROTATION_LANDSCAPE', 'AUTO_ROTATION_RESTRICTED', 'AUTO_ROTATION_PORTRAIT_RESTRICTED', 'AUTO_ROTATION_LANDSCAPE_RESTRICTED', 'LOCKED', 'UNSPECIFIED']; - getData(0, orientationItem.length) - async function getData(i, length) { - let orientation = ohosWindow.Orientation[orientationItem[i]] - await mainWin.setPreferredOrientation(orientation, (err, data) => { - if (err && err.code) { - console.log(msgStr + 'window.setPreferredOrientation failed set error' + orientation); - } - num++ - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + if (err && err.code) { + console.log(msgStr + 'window.setPreferredOrientation failed set error' + orientation); + } + num++ + if (++i < orientationItem.length) { + setPreferredOrientation(i) + console.log(msgStr + 'jixuzhixing i: ' + i); + } else { + console.log(msgStr + 'i++ { - if (err && err.code) { - console.log(msgStr + 'mainWin.on(snapshot) err.code:' + JSON.stringify(err.code)); - return; - } - mainWin.off('snapshot', (err, data) => { - if (err && err.code) { - console.log(msgStr + 'mainWin.off(snapshot) err.code:' + JSON.stringify(err.code)); - return; - } - }) - }) }) done(); }) @@ -2060,27 +3244,46 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) * @tc.name Test dialogTargetTouchTest2 * @tc.desc Verify the scenario of opening modal window */ - it('dialogTargetTouchTest2', 0, done => { + it('dialogTargetTouchTest2', 0, async done => { let caseName = 'dialogTargetTouchTest2'; let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin context==' + JSON.stringify(context)); let tempType = ohosWindow.WindowType.TYPE_DIALOG - ohosWindow.create(context, 'dialogTargetTouchTest2', tempType, (err, data) => { - console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); - console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); - if (err && err.code) { - unexpectedError(err, caseName, 'ohosWindow.create', done); - } else { - let dialogTargetTouchTest2Win = data - try { - expect(!!dialogTargetTouchTest2Win).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } + let dialogTargetTouchTest2Win = null + + function create() { + return new Promise(function (resolve, reject) { + ohosWindow.create(context, 'dialogTargetTouchTest2', tempType, (err, data) => { + console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err)); + console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data)); + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.create', done); + } else { + dialogTargetTouchTest2Win = data + try { + expect(!!dialogTargetTouchTest2Win).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + } + resolve(data) + }) + }) + } + + function destroy() { + return new Promise(function (resolve, reject) { dialogTargetTouchTest2Win.destroy(); + resolve(true) done(); - } - }) + }) + } + + await create() + .then(function (params) { + console.log(msgStr + 'create then: ' + JSON.stringify(params)) + return destroy() + }) }) /** * @tc.number SUB_WINDOW_ANIMATIONFORSHOWN_JSAPI_002 @@ -2128,6 +3331,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) context.completeTransition(true) console.info(msgStr + 'complete transition end'); } + tempWnd.destroy(); done(); } }); @@ -2168,27 +3372,57 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) console.log(msgStr + 'begin context==' + JSON.stringify(context)); let wndId = 'showWithAnimationTest2'; let baseType = ohosWindow.WindowType.TYPE_FLOAT; - ohosWindow.create(context, wndId, baseType, (err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done); - } else { - let tempWnd = data; - console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + JSON.stringify(tempWnd)); - try { - expect(!!tempWnd).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } + let tempWnd = null; + + function create() { + return new Promise(function (resolve, reject) { + ohosWindow.create(context, wndId, baseType, (err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done); + } else { + tempWnd = data; + console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + JSON.stringify(tempWnd)); + try { + expect(!!tempWnd).assertTrue(); + } catch (error) { + console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) + } + + } + resolve(data) + }) + }) + } + + function showWithAnimation() { + return new Promise(function (resolve, reject) { tempWnd.showWithAnimation((error, animationData) => { if (error && error.code) { unexpectedError(error, caseName, 'Failed to show the window with animation', done); } else { console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(animationData)); - done(); + resolve(animationData) } }) - } - }) + }) + } + + function destroy() { + return new Promise(function (resolve, reject) { + tempWnd.destroy(); + resolve(true) + done(); + }) + } + + await create() + .then(function (params) { + console.log(msgStr + 'create then: ' + JSON.stringify(params)) + return showWithAnimation() + }).then(function (params) { + console.log(msgStr + 'showWithAnimation then: ' + JSON.stringify(params)) + return destroy() + }) }) /** * @tc.number SUB_WINDOW_HIDEWITHANIMATION_JSAPI_002 @@ -2201,85 +3435,62 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) console.log(msgStr + 'begin context==' + JSON.stringify(context)); let wndId = 'hideWithAnimationTest2'; let baseType = ohosWindow.WindowType.TYPE_FLOAT; - ohosWindow.create(context, wndId, baseType, (creare_err, tempWnd) => { - if (creare_err && creare_err.code) { - unexpectedError(creare_err, caseName, 'ohosWindow.create ' + baseType, done); - } - try { - expect(!!tempWnd).assertTrue(); - } catch (error) { - console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) - } - ohosWindow.find(wndId, (findErr, findWnd) => { - if (findErr && findErr.code) { - unexpectedError(findErr, caseName, 'Failed to hide the window with animation', done); - } else { - findWnd.hideWithAnimation((err, data) => { - if (err && err.code) { - unexpectedError(err, caseName, 'Failed to hide the window with animation', done); - } else { - console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data)); - done(); - } - }) - } - }) - }) - }) - /** - * @tc.number SUB_WINDOW_CREATE_JSAPI_008 - * @tc.name Test createTest8 - * @tc.desc Verify the scenario of creating a window with duplicate IDs - */ - it('createTest8', 0, done => { - let caseName = 'createTest8'; - let msgStr = 'jsunittest ' + caseName + ' '; - console.log(msgStr + 'begin'); - let windowId = 'sameid' - ohosWindow.create(context, windowId, 1, (err, data) => { - console.log(msgStr + 'ohosWindow.create 1 once err: ' + JSON.stringify(err)); - if (err && err.code) { - unexpectedError(err, caseName, 'ohosWindow.create', done); - } - expect(!!data).assertTrue(); - ohosWindow.create(context, windowId, 1, (err, data) => { - console.log(msgStr + 'ohosWindow.create 1 twice err: ' + JSON.stringify(err)); - if (err && err.code) { - console.log(msgStr + 'ohosWindow.create 1 twice data: ' + JSON.stringify(data)); + let tempWnd = null + + function create() { + return new Promise(function (resolve, reject) { + ohosWindow.create(context, wndId, baseType, (creare_err, data) => { + if (creare_err && creare_err.code) { + unexpectedError(creare_err, caseName, 'ohosWindow.create ' + baseType, done); + } try { - expect(err.code).assertEqual(1001) + tempWnd = data + expect(!!tempWnd).assertTrue(); } catch (error) { console.info(`tempWnd.show catch error: ${JSON.stringify(error)}`) } - done(); - } else { - unexpectedError(err, caseName, 'ohosWindow.create', done); - console.log(msgStr + 'ohosWindow.create 1 twice data: ' + JSON.stringify(data)); - } + resolve(data) + }) + }) + } + + function find() { + return new Promise(function (resolve, reject) { + ohosWindow.find(wndId, (findErr, findWnd) => { + if (findErr && findErr.code) { + unexpectedError(findErr, caseName, 'Failed to hide the window with animation', done); + } else { + findWnd.hideWithAnimation((err, data) => { + if (err && err.code) { + unexpectedError(err, caseName, 'Failed to hide the window with animation', done); + } else { + console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data)); + done(); + } + }) + } + resolve(findWnd) + }) + }) + } + + function destroy() { + return new Promise(function (resolve, reject) { + tempWnd.destroy(); + resolve(true) + done(); + }) + } + + await create() + .then(function (params) { + console.log(msgStr + 'create then: ' + JSON.stringify(params)) + return find() + }).then(function (params) { + console.log(msgStr + 'find then: ' + JSON.stringify(params)) + return destroy() }) - }) - }) - /** - * @tc.number SUB_WINDOW_CREATE_JSAPI_004 - * @tc.name Test createTest4 - * @tc.desc Verify the scenario of creating a window with duplicate IDs - */ - it('createTest4', 0, async function (done) { - let caseName = 'createTest4'; - let msgStr = 'jsunittest ' + caseName + ' '; - console.log(msgStr + 'begin'); - let windowId = 'sameids' - let ohosData = await ohosWindow.create(context, windowId, 1).catch((err) => { - console.log(msgStr + 'ohosWindow.create 1 once err: ' + JSON.stringify(err)); - unexpectedError(err, caseName, 'ohosWindow.create', done); - }) - expect(!!ohosData).assertTrue(); - let ohosDataError = await ohosWindow.create(context, windowId, 1).catch((err) => { - console.log(msgStr + 'ohosWindow.create 1 twice err: ' + JSON.stringify(err)); - expect(err.code).assertEqual(1001) - done(); - }) - console.log(msgStr + 'ohosWindow.create 1 twice ohosDataError: ' + JSON.stringify(ohosDataError)); }) - }) + } + ) } diff --git a/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets b/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets index eea62d513e33a66d030a64e6fd7bd4cd09733822..bd275045998cb43b12cf3fdadc0ff35c3a618625 100644 --- a/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets @@ -75,6 +75,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) }) afterEach(async function (done) { windowCount++; + console.log('promise jsunittest afterEach listenerData:' + JSON.stringify(listenerData)); if (listenerData.on) { listenerData.on = false; console.log('jsunittest afterEach listener off, listenerData:' + JSON.stringify(listenerData)); @@ -121,7 +122,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) it('listenerTest1', 0, async function (done) { let caseName = 'listenerTest1'; let msgStr = 'jsunittest ' + caseName + ' '; - let listenerOnFlag = listenerStatus.ready; + let listenerOnFlag = false; console.log(msgStr + 'begin'); let tempWnd = await windowStage.getMainWindow().catch((err) => { unexpectedError(err, caseName, 'windowStage.getMainWindow', done); @@ -129,12 +130,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd); listenerData.on = true; listenerData.typeStr = 'systemAvoidAreaChange'; + tempWnd.on('systemAvoidAreaChange', (avoidAreaData) => { - console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, systemBatData : ' + JSON.stringify(avoidAreaData)); - if (listenerOnFlag === listenerStatus.pending) { - listenerOnFlag = listenerStatus.finished; + console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, avoidAreaData : ' + JSON.stringify(avoidAreaData)); + console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, listenerOnFlag : ' + JSON.stringify(listenerOnFlag)); + if (listenerOnFlag) { expect(!!avoidAreaData).assertTrue(); - done(); } }) expect(!!tempWnd).assertTrue(); @@ -152,11 +153,13 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success'); console.log(msgStr + 'tempWnd.on systemAvoidAreaChange finished'); + listenerOnFlag = true; await sleep(1000); - listenerOnFlag = listenerStatus.pending; await tempWnd.setSystemBarEnable(['status', 'navigation']).catch((err) => { unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); }); + await tempWnd.off('systemAvoidAreaChange'); + done(); console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success'); }) @@ -176,9 +179,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) let listenerOnFlag = listenerStatus.ready; console.log(msgStr + 'begin'); let tempWnd = null; + listenerData.on = true; + listenerData.typeStr = 'windowSizeChange'; try { await ohosWindow.create(context, wndId, baseType).then((data) => { tempWnd = data + newWindowObj = tempWnd console.log(msgStr + 'ohosWindow.create data:' + JSON.stringify(data)); }).catch((err) => { unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done); @@ -197,7 +203,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) expect(!!sizeData).assertTrue(); expect(sizeData.width === resizeValue).assertTrue(); expect(sizeData.height === resizeValue).assertTrue(); - done(); } }) await tempWnd.show().catch((err) => { @@ -218,6 +223,8 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) await tempWnd.resetSize(resizeValue, resizeValue).catch((err) => { unexpectedError(err, caseName, 'tempWnd.resetSize(' + resizeValue + ', ' + resizeValue + ')', done); }); + await tempWnd.destroy(); + done(); console.log(msgStr + 'tempWnd.resetSize(' + resizeValue + ', ' + resizeValue + ') success'); }) /** @@ -276,36 +283,24 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) let wndId = 'listenerTest4'; let baseType = 2; let changedModel = 102; - let listenerOffFlag = listenerStatus.ready; + let listenerOffFlag = false; + listenerData.on = true; + listenerData.typeStr = 'windowSizeChange'; console.log(msgStr + 'begin'); let createWindowObj = { name: wndId, windowType: baseType, ctx: context } console.log(msgStr + 'ohosWindow.create createWindowObj:' + JSON.stringify(createWindowObj)); let tempWnd = null; - try { - await ohosWindow.create(context, wndId, baseType).then((data) => { - console.log(msgStr + 'ohosWindow.create data:' + JSON.stringify(data)); - tempWnd = data - console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + tempWnd); - expect(!!tempWnd).assertTrue(); - listenerData.on = true; - listenerData.typeStr = 'windowSizeChange'; - tempWnd.on('windowSizeChange', (sizeData) => { - console.log(msgStr + 'tempWnd.on windowSizeChange, sizeData : ' + JSON.stringify(sizeData)); - if (listenerOffFlag === listenerStatus.pending) { - listenerOffFlag = listenerStatus.finished; - console.log(msgStr + 'tempWnd.on windowSizeChange, listenerOffFlag === listenerStatus.pending : ' + JSON.stringify(sizeData)); - expect(sizeData.width === 100).assertTrue(); - expect(sizeData.height === 100).assertTrue(); - done(); - } - }) - }).catch((err) => { - unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done); - }); - } catch (err) { - } + await ohosWindow.create(context, wndId, baseType).then((data) => { + console.log(msgStr + 'ohosWindow.create data:' + JSON.stringify(data)); + tempWnd = data + newWindowObj = data + console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + tempWnd); + expect(!!tempWnd).assertTrue(); + }).catch((err) => { + unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done); + }); await tempWnd.show().catch((err) => { unexpectedError(err, caseName, 'tempWnd.show', done); @@ -315,21 +310,36 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) unexpectedError(err, caseName, 'tempWnd.setWindowMode ' + changedModel, done); }); console.log(msgStr + 'tempWnd.setWindowMode ' + changedModel + ' success'); - await tempWnd.resetSize(100, 100).catch((err) => { + await sleep(1000); + await tempWnd.on('windowSizeChange', (sizeData) => { + console.log(msgStr + 'tempWnd.on windowSizeChange, sizeData : ' + JSON.stringify(sizeData)); + if (listenerOffFlag) { + listenerOffFlag = false; + console.log(msgStr + 'tempWnd.on windowSizeChange sizeData: ' + JSON.stringify(sizeData)); + expect(sizeData.width === 100).assertTrue(); + expect(sizeData.height === 100).assertTrue(); + done(); + } else { + console.log(msgStr + 'tempWnd.on windowSizeChange,else listenerOffFlag : ' + listenerOffFlag); + console.log(msgStr + 'tempWnd.on windowSizeChange,else sizeData : ' + JSON.stringify(sizeData)); + if(sizeData.width === 100&&sizeData.height === 100){ + console.log(msgStr + 'tempWnd.on windowSizeChange,else sizeData.width === 100&&sizeData.height === 100'); + done(); + } + } + }) + console.log(msgStr + 'tempWnd.on windowSizeChange finished'); + await tempWnd.resetSize(100, 100).then(() => { + listenerOffFlag = true; + console.log(msgStr + 'listenerOffFlag:' + listenerOffFlag); + }).catch((err) => { unexpectedError(err, caseName, 'tempWnd.resetSize(100, 100)', done); }); console.log(msgStr + 'tempWnd.resetSize(100, 100) success'); - console.log(msgStr + 'tempWnd.on windowSizeChange finished'); - listenerOffFlag = listenerStatus.pending; - await sleep(1000); - tempWnd.off('windowSizeChange'); console.log(msgStr + 'tempWnd.off windowSizeChange finished'); - sleep(1000); - await tempWnd.resetSize(200, 200).catch((err) => { - unexpectedError(err, caseName, 'tempWnd.resetSize(200, 200)', done); - console.log(msgStr + 'tempWnd.resetSize(200, 200) err: ' + JSON.stringify(err)); - }); - console.log(msgStr + 'tempWnd.resetSize(200, 200) success'); + await tempWnd.destroy(); + done(); + console.log(msgStr + 'finished'); }) /** * @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_001 @@ -351,11 +361,9 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) expect(!!tempWnd).assertTrue(); let loopCount1 = systemWindowTypeArr; console.log(msgStr + 'ohosWindow.windowType' + JSON.stringify(loopCount1)) - getData(1, loopCount1.length) - - async function getData(i, length) { + for (let i = 1; i < loopCount1.length; i++) { let tempType = ohosWindow.WindowType[loopCount1[i]]; - console.log(msgStr + 'tempWnd.setWindowType: ' + tempType + ' ,start ,i:'+i); + console.log(msgStr + 'tempWnd.setWindowType: ' + tempType + ' ,start'); tempTypeArr.push(tempType); console.log(msgStr + 'tempTypeArr: ' + JSON.stringify(tempTypeArr)); let windowTypeData = await tempWnd.setWindowType(tempType).catch((err) => { @@ -377,18 +385,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) tempTypeArr.splice(tempTypeArr.findIndex(item => item === prodata.type), 1); console.log(msgStr + '(loopCount1.length - i): ' + (loopCount1.length - i)); console.log(msgStr + '(tempTypeArr.length + 1): ' + (tempTypeArr.length + 1)); - console.log(msgStr + '(loopCount1.length - 1): ' + (loopCount1.length - 1)); if (i == loopCount1.length - 1) { expect((loopCount1.length - i) == (tempTypeArr.length + 1)).assertTrue(); console.log(msgStr + 'tempWnd.getProperties i=' + i + ' , loopCount1.length-1==' + loopCount1.length); + await tempWnd.destroy(); + done(); } - if (++i <= length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + await ohosWindow.create(context, windowId, baseWndType).then( + (data) => { + tempWnd = data + } + ).catch((err) => { unexpectedError(err, caseName, 'ohosWindow.create', done); }) console.log(msgStr + 'ohosWindow.create tempWnd' + JSON.stringify(tempWnd)); console.log(msgStr + 'ohosWindow.create !!tempWnd' + !!tempWnd); if (!!tempWnd) { expect(!!tempWnd).assertTrue(); - let windowTypeData = await tempWnd.setWindowType(changedWndType).catch((err) => { - console.log(msgStr + 'tempWnd.setWindowType err: ' + JSON.stringify(err)); - expectedError(err, caseName, 'tempWnd.setWindowType', done, 1003); + await tempWnd.setWindowType(changedWndType).then(() => { + }).catch((err) => { + console.log(msgStr + 'tempWnd.setWindowType err.code: ' + JSON.stringify(err.code)); + tempWnd.destroy(); + let flag = (err.code == 1003) + console.log(msgStr + 'tempWnd.setWindowType flag: ' + flag); + if (flag) { + expect(true).assertTrue(); + } done(); }) - console.log(msgStr + 'tempWnd.setWindowType windowTypeData' + JSON.stringify(windowTypeData)); - console.log(msgStr + 'tempWnd.setWindowType !windowTypeData' + !windowTypeData); - if (!!windowTypeData) { - expect(false).assertFail(); - } } }) /** @@ -436,6 +443,29 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) let statusFlag = listenerStatus.ready; let navigationFlag = listenerStatus.ready; console.log(msgStr + 'begin'); + listenerData.on = true; + listenerData.typeStr = 'systemBarTintChange'; + ohosWindow.on('systemBarTintChange', async (systemBarData) => { + console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); + if (statusFlag === listenerStatus.pending || navigationFlag === listenerStatus.pending) { + console.log(msgStr + 'systemBarTintChange compare start!'); + expect(!!systemBarData).assertTrue(); + expect(!!systemBarData.regionTint).assertTrue(); + let arrLength = systemBarData.regionTint.length; + for (let i = 0; i < arrLength; i++) { + let tempData = systemBarData.regionTint[i]; + console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable); + if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR && statusFlag === listenerStatus.pending) { + statusFlag = listenerStatus.finished; + expect(tempData.isEnable).assertTrue(); + } else if (tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR && navigationFlag === listenerStatus.pending) { + navigationFlag = listenerStatus.finished; + expect(!tempData.isEnable).assertTrue(); + } + } + } + done(); + }) console.log(msgStr + 'tempWnd.on systemBarTintChange finished'); let tempWnd = await windowStage.getMainWindow().catch((err) => { unexpectedError(err, caseName, 'windowStage.getMainWindow', done); @@ -450,62 +480,18 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done); }); console.log(msgStr + 'tempWnd.setFullScreen(true) success'); + await tempWnd.setSystemBarEnable(['navigation']).catch((err) => { unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([navigation])', done); }); - console.log(msgStr + 'tempWnd.setSystemBarEnable([navigation]) success'); + console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success'); await sleep(1000); statusFlag = listenerStatus.pending; navigationFlag = listenerStatus.pending; - if (statusFlag === listenerStatus.pending || navigationFlag === listenerStatus.pending) { - console.log(msgStr + 'start on !!!!'); - listenerData.on = true; - listenerData.typeStr = 'systemBarTintChange'; - ohosWindow.on('systemBarTintChange', (systemBarData) => { - console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); - console.log(msgStr + 'tempWnd.on , statusFlag : ' + JSON.stringify(statusFlag)); - console.log(msgStr + 'tempWnd.on , listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending)); - console.log(msgStr + 'tempWnd.on , navigationFlag : ' + JSON.stringify(navigationFlag)); - console.log(msgStr + 'tempWnd.on , listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending)); - - setTimeout(() => { - console.log(msgStr + 'tempWnd.on , 3 statusFlag : ' + JSON.stringify(statusFlag)); - console.log(msgStr + 'tempWnd.on , 3 listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending)); - console.log(msgStr + 'tempWnd.on , 3 navigationFlag : ' + JSON.stringify(navigationFlag)); - console.log(msgStr + 'tempWnd.on , 3 listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending)); - - if (statusFlag === listenerStatus.pending || navigationFlag === listenerStatus.pending) { - console.log(msgStr + 'systemBarTintChange compare start!'); - expect(!!systemBarData).assertTrue(); - expect(!!systemBarData.regionTint).assertTrue(); - let arrLength = systemBarData.regionTint.length; - for (let i = 0; i < arrLength; i++) { - let tempData = systemBarData.regionTint[i]; - console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable); - if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR && statusFlag === listenerStatus.pending) { - statusFlag = listenerStatus.finished; - expect(!tempData.isEnable).assertTrue(); - } else if (tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR && navigationFlag === listenerStatus.pending) { - navigationFlag = listenerStatus.finished; - expect(tempData.isEnable).assertTrue(); - } - } - ohosWindow.off('systemBarTintChange'); - } - done(); - }, 3000) - }) - } - - await tempWnd.setSystemBarEnable(['status']).catch((err) => { unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status])', done); }); - console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success'); - console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, statusFlag : ' + JSON.stringify(statusFlag)); - console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending)); - console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, navigationFlag : ' + JSON.stringify(navigationFlag)); - console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending)); + console.log(msgStr + 'tempWnd.setSystemBarEnable([navigation]) success'); }) /** * @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_002 @@ -520,16 +506,14 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'begin'); listenerData.on = true; listenerData.typeStr = 'systemBarTintChange'; - ohosWindow.on('systemBarTintChange', (systemBarData) => { + ohosWindow.on('systemBarTintChange', async (systemBarData) => { console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); if (statusFlag === listenerStatus.pending || navigationFlag === listenerStatus.pending) { console.log(msgStr + 'systemBarTintChange compare start!'); expect(!!systemBarData).assertTrue(); expect(!!systemBarData.regionTint).assertTrue(); let arrLength = systemBarData.regionTint.length; - getData(0, arrLength) - - function getData(i, length) { + for (let i = 0; i < arrLength; i++) { let tempData = systemBarData.regionTint[i]; console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable); if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR && statusFlag === listenerStatus.pending) { @@ -539,12 +523,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) navigationFlag = listenerStatus.finished; expect(tempData.isEnable).assertTrue(); } - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + ohosWindow.on('systemBarTintChange', async (systemBarData) => { console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); if (statusFlag === listenerStatus.pending || navigationFlag === listenerStatus.pending) { console.log(msgStr + 'systemBarTintChange compare start!'); expect(!!systemBarData).assertTrue(); expect(!!systemBarData.regionTint).assertTrue(); let arrLength = systemBarData.regionTint.length; - getData(0, arrLength) - - function getData(i, length) { + for (let i = 0; i < arrLength; i++) { let tempData = systemBarData.regionTint[i]; console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable); if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR && statusFlag === listenerStatus.pending) { @@ -608,12 +584,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) navigationFlag = listenerStatus.finished; expect(tempData.isEnable).assertTrue(); } - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + ohosWindow.on('systemBarTintChange', async (systemBarData) => { console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); if (statusFlag === listenerStatus.pending || navigationFlag === listenerStatus.pending) { console.log(msgStr + 'systemBarTintChange compare start!'); expect(!!systemBarData).assertTrue(); expect(!!systemBarData.regionTint).assertTrue(); let arrLength = systemBarData.regionTint.length; - getData(0, arrLength) - - function getData(i, length) { + for (let i = 0; i < arrLength; i++) { let tempData = systemBarData.regionTint[i]; console.log(msgStr + 'compare, type: ' + tempData.type + ';isEnable: ' + tempData.isEnable); if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR && statusFlag === listenerStatus.pending) { @@ -677,12 +645,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) navigationFlag = listenerStatus.finished; expect(!tempData.isEnable).assertTrue(); } - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + ohosWindow.on('systemBarTintChange', async (systemBarData) => { console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); if (listenerFlag === listenerStatus.pending) { expect(!!systemBarData).assertTrue(); expect(!!systemBarData.regionTint).assertTrue(); let arrLength = systemBarData.regionTint.length; - getData(0, arrLength) - - function getData(i, length) { + for (let i = 0; i < arrLength; i++) { let tempData = systemBarData.regionTint[i]; if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { console.log(msgStr + 'systemBarTintChange compare start!'); @@ -780,12 +740,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor); expect(backgroundIndex === -1).assertTrue(); expect(contentColorIndex === -1).assertTrue(); - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + await tempWnd.setSystemBarProperties(systemBarProperties).then(() => { console.log(msgStr + 'tempWnd.setSystemBarProperties ' + tempColor + ' success'); - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { console.log(msgStr + 'tempWnd.setSystemBarProperties failed, err : ' + JSON.stringify(err)); expect(TRUE_FLAG).assertFail(); @@ -858,15 +804,13 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'begin'); listenerData.on = true; listenerData.typeStr = 'systemBarTintChange'; - ohosWindow.on('systemBarTintChange', (systemBarData) => { + ohosWindow.on('systemBarTintChange', async (systemBarData) => { console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); if (listenerFlag === listenerStatus.pending) { expect(!!systemBarData).assertTrue(); expect(!!systemBarData.regionTint).assertTrue(); let arrLength = systemBarData.regionTint.length; - getData(0, arrLength) - - function getData(i, length) { + for (let i = 0; i < arrLength; i++) { let tempData = systemBarData.regionTint[i]; if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR) { console.log(msgStr + 'systemBarTintChange compare start!'); @@ -895,12 +839,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) expect(backgroundIndex !== -1).assertTrue(); expect(contentColorIndex !== -1).assertTrue(); } - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + await tempWnd.setSystemBarProperties(systemBarProperties).then(() => { console.log(msgStr + 'tempWnd.setSystemBarProperties ' + tempColor + ' success'); - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { console.log(msgStr + 'tempWnd.setSystemBarProperties failed, err : ' + JSON.stringify(err)); expect(TRUE_FLAG).assertFail(); @@ -967,15 +897,13 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'begin'); listenerData.on = true; listenerData.typeStr = 'systemBarTintChange'; - ohosWindow.on('systemBarTintChange', (systemBarData) => { + ohosWindow.on('systemBarTintChange', async (systemBarData) => { console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData)); if (listenerFlag === listenerStatus.pending) { expect(!!systemBarData).assertTrue(); expect(!!systemBarData.regionTint).assertTrue(); let arrLength = systemBarData.regionTint.length; - getData(0, loopCount) - - function getData(i, length) { + for (let i = 0; i < arrLength; i++) { let tempData = systemBarData.regionTint[i]; console.log(msgStr + 'i=' + i + ' , ohosWindow.on for=' + JSON.stringify(tempData)); if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) { @@ -985,12 +913,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor); expect(backgroundIndex === -1).assertTrue(); expect(contentColorIndex === -1).assertTrue(); - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + await tempWnd.setSystemBarProperties(systemBarProperties).then(() => { console.log(msgStr + 'tempWnd.setSystemBarProperties ' + tempColor + ' success'); - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { console.log(msgStr + 'tempWnd.setSystemBarProperties failed, err : ' + JSON.stringify(err)); expect(TRUE_FLAG).assertFail(); @@ -1056,24 +970,22 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'begin'); let loopCount = systemWindowTypeDicArr.length; console.log(msgStr + 'loopCount: ' + loopCount); - getData(0, loopCount) - - async function getData(i, length) { + for (let i = 0; i < loopCount; i++) { let tempType = systemWindowTypeDic[systemWindowTypeDicArr[i]]; let windId = 'createTest1' + i; console.log(msgStr + 'ohosWindow.create ' + tempType + ' start'); - let tempWnd = await ohosWindow.create(context, windId, tempType).catch((err) => { + let tempWnd = null + await ohosWindow.create(context, windId, tempType).then( + (data) => { + tempWnd = data; + } + ).catch((err) => { console.log(msgStr + 'ohosWindow.create ' + tempType + 'catched, err: ' + JSON.stringify(err)); unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done); }); console.log(msgStr + 'ohosWindow.create ' + tempType + 'finished, wnd: ' + tempWnd); expect(!!tempWnd).assertTrue(); - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + ohosData = data; + }).catch((err) => { + console.log(msgStr + 'ohosWindow.create 1 once err: ' + JSON.stringify(err)); + unexpectedError(err, caseName, 'ohosWindow.create', done); + }) + expect(!!ohosData).assertTrue(); + let ohosDataError = await ohosWindow.create(context, windowId, 1).catch((err) => { + console.log(msgStr + 'ohosWindow.create 1 twice err: ' + JSON.stringify(err)); + expect(err.code).assertEqual(1300001) + done(); + }) + await ohosData.destroy(); + console.log(msgStr + 'ohosWindow.create 1 twice ohosDataError: ' + JSON.stringify(ohosDataError)); + }) + /** * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_001 * @tc.name Test loadContentTest1 * @tc.desc Verify the scenario of loading an existing page @@ -1190,6 +1122,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) }); console.log(msgStr + 'tempWnd.loadContent(pages/second/second) load=' + JSON.stringify(load)); expect(!load).assertTrue(); + await tempWnd.destroy(); done(); }) @@ -1221,6 +1154,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'ohosWindow.createWindow catch err:' + JSON.stringify(err)); } console.log(msgStr + 'tempWnd.loadContent start'); + await tempWnd.destroy(); let errFlag = false; let loadContentData = null; try { @@ -1333,6 +1267,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'windowStage.createSubWindow(createSubWindowTest1)=' + JSON.stringify(err)); }); expect(!!subWindow).assertTrue(); + await subWindow.destroy(); console.log(msgStr + 'windowStage.createSubWindow end subWindow=' + JSON.stringify(subWindow)); console.log(msgStr + 'windowStage.createSubWindow end !!subWindow=' + !!subWindow); done(); @@ -1386,8 +1321,11 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) let msgStr = 'jsunittest ' + caseName + ' '; console.log(msgStr + 'begin '); let mainWnd = null; - let windowData = await ohosWindow.create(context, 'setPrivacyModeTest1', ohosWindow.WindowType.TYPE_SYSTEM_ALERT) - .catch((err) => { + let windowData = null + await ohosWindow.create(context, 'setPrivacyModeTest1', ohosWindow.WindowType.TYPE_SYSTEM_ALERT) + .then((data) => { + windowData = data; + }).catch((err) => { unexpectedError(err, caseName, 'ohosWindow.create', done); }) expect(!!windowData).assertTrue(); @@ -1420,6 +1358,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) }) console.log(msgStr + 'mainWnd.getProperties lastPro:' + JSON.stringify(lastPro.isPrivacyMode)); expect(!lastPro.isPrivacyMode).assertTrue(); + await windowData.destroy(); done(); }) /** @@ -1492,10 +1431,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) console.log(msgStr + 'screen.setDensityDpi display.getDefaultDisplay current device' + JSON.stringify(currentDeviceDefault)); let currentDeviceDefaultDpi = parseInt(currentDeviceDefault.densityDPI) let dpiItem = [-80, 80, 1000, 160, 0, 320, 188.88, 0, 640, 300, currentDeviceDefaultDpi]; - getData(0, dpiItem.length) - - async function getData(i, length) { - await sleep(1000); + for (let i = 0; i < dpiItem.length; i++) { await screens[0].setDensityDpi(dpiItem[i]).then(async () => { console.log(msgStr + 'screen.setDensityDpi success set DPI ' + dpiItem[i]); let defaultDpi = null; @@ -1508,12 +1444,6 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) let isEqual = Number(defaultDpi.densityDPI) == dpiItem[i] console.log(msgStr + 'same ? ' + isEqual) expect(isEqual).assertTrue() - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { console.log(msgStr + 'screen.setDensityDpi failed set DPI error' + dpiItem[i]); }); @@ -1539,23 +1469,14 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE', 'PORTRAIT_INVERTED', 'LANDSCAPE_INVERTED', 'AUTO_ROTATION', 'AUTO_ROTATION_PORTRAIT', 'AUTO_ROTATION_LANDSCAPE', 'AUTO_ROTATION_RESTRICTED', 'AUTO_ROTATION_PORTRAIT_RESTRICTED', 'AUTO_ROTATION_LANDSCAPE_RESTRICTED', 'LOCKED', 'UNSPECIFIED']; - getData(0, orientationItem.length) - - async function getData(i, length) { - await sleep(1000); + for (let i = 0; i < orientationItem.length; i++) { let orientation = ohosWindow.Orientation[orientationItem[i]] console.log(msgStr + 'i : ' + i + ' ,orientation : ' + orientation); console.log(msgStr + 'i : ' + i + ' ,ohosWindow.Orientation : ' + JSON.stringify(ohosWindow.Orientation)); await mainWin.setPreferredOrientation(orientation).then(() => { console.log(msgStr + 'success set window.setPreferredOrientation : ' + orientation); - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { console.log(msgStr + 'window.setPreferredOrientation failed set error:' + orientation); }); @@ -1589,10 +1510,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) done(); }) /** -* @tc.number SUB_WINDOW_SNAPSHOT_JSAPI_001 -* @tc.name Test snapshotTest1 -* @tc.desc Scenario of screenshot of verification window -*/ + * @tc.number SUB_WINDOW_SNAPSHOT_JSAPI_001 + * @tc.name Test snapshotTest1 + * @tc.desc Scenario of screenshot of verification window + */ it('snapshotTest1', 0, async function (done) { let caseName = 'snapshotTest1'; let msgStr = 'jsunittest ' + caseName + ' '; @@ -1687,6 +1608,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) context.completeTransition(true) console.info(msgStr + 'complete transition end'); } + await tempWnd.destroy(); done(); }) /** @@ -1738,10 +1660,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) await tempWnd.showWithAnimation().then((data) => { console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); + tempWnd.destroy(); done(); }).catch((err) => { unexpectedError(err, caseName, 'Failed to show the window with animation', done); }) + }) /** * @tc.number SUB_WINDOW_HIDEWITHANIMATION_JSAPI_001 @@ -1767,7 +1691,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done); }); } - catch(err) { + catch (err) { console.log(msgStr + 'ohosWindow.create catch err:' + JSON.stringify(err)); } let findWnd = null; @@ -1781,6 +1705,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage) let promise = findWnd.hideWithAnimation(); promise.then((data) => { console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data)); + tempWnd.destroy(); done(); }).catch((err) => { console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); diff --git a/graphic/windowStage/entry/src/main/ets/test/windowRefactorInterface.test.ets b/graphic/windowStage/entry/src/main/ets/test/windowRefactorInterface.test.ets index 6c8d6bf105e5ea9fba3d2520a8da2e35536cc48d..1aa699202d8ce193f9efd368f247c823e9f19711 100644 --- a/graphic/windowStage/entry/src/main/ets/test/windowRefactorInterface.test.ets +++ b/graphic/windowStage/entry/src/main/ets/test/windowRefactorInterface.test.ets @@ -71,12 +71,15 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit afterAll(function () { }) - function sleep(time) { - return new Promise(resolve => { - setTimeout(() => { + async function sleep(time) { + let timeoutId= null; + let promise = new Promise(resolve => { + timeoutId = setTimeout(() => { resolve('sleep finished'); }, time); }) + let result = await promise; + clearTimeout(timeoutId) } /** @@ -102,9 +105,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.info(`ohosWindow.on catch error: ${JSON.stringify(error)}`) } let arrLength = systemBarData.regionTint.length; - getData(0, arrLength) - - function getData(i, length) { + console.log('setWindowSystemBarPropertiesTest1 arrLength is: '+systemBarData.regionTint.length) + for(let i=0;i { - console.info('setWindowSystemBarPropertiesTest1 success'); + await mainWsync.setWindowSystemBarProperties(systemBarProperties).then(() => { + console.info('setWindowSystemBarPropertiesTest1 success step:'+i); expect(TRUE_FLAG).assertTrue(); - if (++i < length) { - getData(i, length) - console.log(msgStr+'jixuzhixing i: ' + i); - } else { - console.log(msgStr+'i++ { console.info('setWindowSystemBarPropertiesTest1 error : ' + JSON.stringify(err)); expect().assertFail() @@ -258,10 +252,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit }); await sleep(1000); listenerFlag = listenerStatus.pending; - let loopCount = commonNUMBERColorArr.length; - getData(0, loopCount) - - function getData(i, length) { + for(let i =0;i { - console.info('setWindowSystemBarPropertiesTest2 success'); - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + console.info('setWindowSystemBarPropertiesTest2 success step:'+i); expect(TRUE_FLAG).assertTrue(); - done(); + if(i == commonNUMBERColorArr.length-1){ + console.info('setWindowSystemBarPropertiesTest2 finished step:'+i); + done(); + } }).catch(err => { console.info('setWindowSystemBarPropertiesTest2 error : ' + JSON.stringify(err)); expect().assertFail() @@ -343,10 +332,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit }); await sleep(1000); listenerFlag = listenerStatus.pending; - let loopCount = commonKEYColorArr.length; - getData(0, loopCount) - - function getData(i, length) { + for(let i=0;i { - console.info('setWindowSystemBarPropertiesTest3 success'); - if (++i < length) { - getData(i, length) - console.log(msgStr + 'jixuzhixing i: ' + i); - } else { - console.log(msgStr + 'i++ { + console.info('setWindowSystemBarPropertiesTest3 success step:'+i); expect(TRUE_FLAG).assertTrue(); - done(); + if(i == commonKEYColorArr.length-1){ + console.info('setWindowSystemBarPropertiesTest3 finished step:'+i); + done(); + } }).catch(err => { console.info('setWindowSystemBarPropertiesTest3 error : ' + JSON.stringify(err)); expect().assertFail() @@ -428,25 +412,26 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit let config = { name: "alertWindowshow", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context }; - ohosWindow.createWindow(config).then(wnd => { - expect(wnd != null).assertTrue(); - let isWindowShowing = wnd.isWindowShowing(); - expect(!isWindowShowing).assertTrue(); - wnd.showWindow().then(() => { - let isWindowShowing2 = wnd.isWindowShowing(); - expect(isWindowShowing2).assertTrue(); - wnd.destroyWindow(); - done(); - }).catch(err => { - console.error('Failed to show window1. Cause:' + JSON.stringify(err)); - expect().assertFail(); - done(); - }) - }).catch(err => { + let wnd; + wnd = await ohosWindow.createWindow(config).catch(err => { console.error('Failed to create the Windowshow1. Cause:' + JSON.stringify(err)); expect().assertFail(); done(); }) + expect(wnd != null).assertTrue(); + let isWindowShowing = wnd.isWindowShowing(); + expect(!isWindowShowing).assertTrue(); + await wnd.showWindow().then(async () => { + let isWindowShowing2 = wnd.isWindowShowing(); + expect(isWindowShowing2).assertTrue(); + await wnd.destroyWindow(); + done(); + }).catch(async (err) => { + console.error('Failed to show window1. Cause:' + JSON.stringify(err)); + expect().assertFail(); + await wnd.destroyWindow(); + done(); + }) }) /** * @tc.number SUB_WINDOW_setUIContent_JSAPI_001 @@ -457,25 +442,27 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit let config = { name: "alertWindow", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context }; + let win; + let promise; try { - let promise = ohosWindow.createWindow(config); - promise.then(win => { - console.info('Succeeded in creating the window1. Data:' + JSON.stringify(win)); - expect(win != null); - win.setUIContent('pages/second/second').then(() => { - console.info('setUIContent1 . Cause: success'); - expect(TRUE_FLAG).assertTrue(); - done(); - }).catch(err => { - console.error('Failed to setUIContent . Cause:' + JSON.stringify(err)); - expect().assertFail(); - done(); - }); - }).catch((err) => { + promise = ohosWindow.createWindow(config); + win = await promise.catch((err) => { console.error('Failed to create the Window1. Cause:' + JSON.stringify(err)); expect().assertFail(); done(); }); + expect(win != null); + await win.setUIContent('pages/second/second').then(async () => { + console.info('setUIContent1 . Cause: success'); + expect(TRUE_FLAG).assertTrue(); + await win.destroyWindow(); + done(); + }).catch(async (err) => { + console.error('Failed to setUIContent . Cause:' + JSON.stringify(err)); + expect().assertFail(); + await win.destroyWindow(); + done(); + }); } catch (exception) { console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); expect().assertFail(); @@ -491,47 +478,58 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit */ it('setUIContentTestCallBack1', 0, async function (done) { let windowClass = null; + let msgStr='setUIContentTestCallBack1' let config = { name: "alertWindowcallBack", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context }; - try { - let promise = ohosWindow.createWindow(config); - promise.then(win => { - console.info('Succeededcall in creating the window2. Data:' + JSON.stringify(win)); - windowClass = win; - expect(win != null).assertTrue(); - // 设置setUIContent + function createFirstWindow() { + return new Promise((resolve, reject) => { try { - windowClass.setUIContent('pages/second/second', (err) => { - if (err.code) { - console.error('Failed to load the content callback. Cause:' + JSON.stringify(err)); - expect().assertFail(); - done(); - } else { - console.info('Succeeded in loading the content.'); - expect(TRUE_FLAG).assertTrue(); + ohosWindow.createWindow(config, (create_err, create_data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(create_data)); + if (create_err && create_err.code) { + try { + expect().assertFail(); + } catch (err) { + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(err)}`) + } done(); + reject(null) } - }); + resolve(create_data) + }) } catch (exception) { - console.error('Failed callback to load the content. Cause:' + JSON.stringify(exception)); - expect().assertFail(); - done(); + console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); } ; + }) + } + let winData; + winData = await createFirstWindow(); + expect(!!winData).assertTrue(); + try { + winData.setUIContent('pages/second/second', async (err) => { + try{ + if (err.code) { + console.error('Failed to load the content callback. Cause:' + JSON.stringify(err)); + expect().assertFail(); - }).catch((err) => { - console.error('Failedcaa to create the inner Window2. Cause:' + JSON.stringify(err)); - expect().assertFail(); + } else { + console.info('Succeeded in loading the content.'); + expect(TRUE_FLAG).assertTrue(); + } + }catch(err){ + console.log('setUIContentTestCallBack1 assert result catch' + JSON.stringify(err)); + } done(); + await winData.destroyWindow(); }); } catch (exception) { - console.error('Failed to create the window2. Cause: ' + JSON.stringify(exception)); + console.error('Failed callback to load the content. Cause:' + JSON.stringify(exception)); expect().assertFail(); + await winData.destroyWindow(); done(); - } - ; - + }; }) /** @@ -544,43 +542,38 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit let config = { name: "alertWindow2", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context }; + let win; try { - let promise = ohosWindow.createWindow(config); - promise.then(win => { - console.info('Succeeded in creating the window2. Data:' + JSON.stringify(win)); - windowClass = win; - expect(win != null).assertTrue(); - // 设置setUIContent - try { - let promise = windowClass.setUIContent(null); - promise.then(() => { - console.info('Succeeded in loading the content.'); - expect().assertFail(); - done(); - }).catch((err) => { - console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); - expect(err.code).assertEqual(401); - done() - }); - } catch (exception) { - console.error('Failed to load the content. exception: ' + JSON.stringify(exception)); - expect(exception.code).assertEqual(401); - done() - } - ; - - }).catch((err) => { + win = await ohosWindow.createWindow(config).catch((err) => { console.error('Failed to create the inner Window2. Cause:' + JSON.stringify(err)); expect().assertFail(); done(); }); + expect(win != null).assertTrue(); + try { + await win.setUIContent(null).then(async () => { + console.info('Succeeded in loading the content.'); + expect().assertFail(); + await win.destroyWindow(); + done(); + }).catch(async (err) => { + console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); + expect(err.code).assertEqual(401); + await win.destroyWindow(); + done() + }); + } catch (exception) { + console.error('Failed to load the content. exception: ' + JSON.stringify(exception)); + expect(exception.code).assertEqual(401); + await win.destroyWindow(); + done() + } + ; } catch (exception) { console.error('Failed to create the window2. Cause: ' + JSON.stringify(exception)); expect().assertFail(); done(); - } - ; - + }; }) /** @@ -592,26 +585,26 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit let config = { name: "alertWindow3", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context }; + let win; try { - let promise = ohosWindow.createWindow(config); - promise.then(win => { - console.info('Succeeded in creating the window3. Data:' + JSON.stringify(win)); - expect(win != null).assertTrue(); - // 设置setUIContent - win.setUIContent('pages/second/he').then(() => { - console.info('setUIContent3 . Cause: success'); - expect(TRUE_FLAG).assertTrue(); - done(); - }).catch(err => { - console.error('Failed to setUIContent3 . Cause:' + JSON.stringify(err)); - expect().assertFail(); - done(); - }); - }).catch((err) => { + win = await ohosWindow.createWindow(config).catch((err) => { console.error('Failed to create the inner Window3. Cause:' + JSON.stringify(err)); expect().assertFail(); done(); }); + expect(win != null).assertTrue(); + // 设置setUIContent + await win.setUIContent('pages/second/he').then(async () => { + console.info('setUIContent3 . Cause: success'); + expect(TRUE_FLAG).assertTrue(); + await win.destroyWindow(); + done(); + }).catch(async (err) => { + console.error('Failed to setUIContent3 . Cause:' + JSON.stringify(err)); + expect().assertFail(); + await win.destroyWindow(); + done(); + }); } catch (exception) { console.error('Failed to create the window3. Cause: ' + JSON.stringify(exception)); expect().assertFail(); @@ -629,25 +622,22 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.info('windowTest setWindowColorSpace1 begin'); let wnd = windowStage.getMainWindowSync(); expect(wnd != null).assertTrue(); - wnd.setWindowColorSpace(ohosWindow.ColorSpace.WIDE_GAMUT).then(() => { - console.info('windowTest SetWindowColorSpaceTest1 setColorSpace WIDE_GAMUT'); - let windowColorSpace = wnd.getWindowColorSpace(); - expect(windowColorSpace == ohosWindow.ColorSpace.WIDE_GAMUT).assertTrue(); - console.info('windowTest SetWindowColorSpaceTest1 setColorSpace WIDE_GAMUT success'); - wnd.isWindowSupportWideGamut().then(data => { - expect(data).assertTrue(); - done(); - }, (err) => { - console.info('windowTest SetColorSpaceTest1 wnd.isWindowSupportWideGamut failed, err :' + JSON.stringify(err)); - expect().assertFail(); - done(); - }) - }, (err) => { + await wnd.setWindowColorSpace(ohosWindow.ColorSpace.WIDE_GAMUT).catch((err) => { console.info('windowTest SetWindowColorSpaceTest1 wnd.setColorSpace failed, err :' + JSON.stringify(err)); expect().assertFail(); done(); }) - + let windowColorSpace = wnd.getWindowColorSpace(); + expect(windowColorSpace == ohosWindow.ColorSpace.WIDE_GAMUT).assertTrue(); + console.info('windowTest SetWindowColorSpaceTest1 setColorSpace WIDE_GAMUT success'); + await wnd.isWindowSupportWideGamut().then(data => { + expect(data).assertTrue(); + done(); + }, (err) => { + console.info('windowTest SetColorSpaceTest1 wnd.isWindowSupportWideGamut failed, err :' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) }) /** @@ -661,7 +651,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit expect(wnd != null).assertTrue(); try { let promise = wnd.setWindowColorSpace(-5); - promise.then(() => { + await promise.then(() => { console.info('Succeeded in setting window2 colorspace.'); expect().assertFail(); done(); @@ -687,25 +677,47 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit it('setColorSpace_Test_003', 0, async function (done) { console.info('windowTest SetWindowColorSpaceTest3 begin'); let wnd = windowStage.getMainWindowSync(); + let msgStr = 'setColorSpace_Test_003' expect(wnd != null).assertTrue(); - wnd.setColorSpace(ohosWindow.ColorSpace.WIDE_GAMUT, (err) => { - if (err.code != 0) { - console.info('windowTest SetWindowColorSpaceTest3 setColorSpace fail' + JSON.stringify(err)); - expect().assertFail(); - done(); - } else { - let windowColorSpace = wnd.getWindowColorSpace(); - expect(windowColorSpace == ohosWindow.ColorSpace.WIDE_GAMUT).assertTrue(); - wnd.isWindowSupportWideGamut((err, data) => { - if (err.code != 0) { - console.log('windowTest SetWindowColorSpaceTest3 getColorSpace callback fail' + JSON.stringify(err)); - expect().assertFail(); - done(); - } else { - expect(data).assertTrue(); - done(); - } - }) + function setColorSpaceFun() { + return new Promise((resolve, reject) => { + try { + wnd.setColorSpace(ohosWindow.ColorSpace.WIDE_GAMUT, (err,data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(data)); + if (err && err.code) { + try { + expect().assertFail(); + } catch (error) { + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(error)}`) + } + done(); + reject(null) + } + resolve(true) + }) + } catch (exception) { + console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + } + ; + }) + } + let isResultTrue; + isResultTrue = await setColorSpaceFun(); + expect(isResultTrue).assertTrue(); + let windowColorSpace = wnd.getWindowColorSpace(); + expect(windowColorSpace == ohosWindow.ColorSpace.WIDE_GAMUT).assertTrue(); + wnd.isWindowSupportWideGamut((err, data) => { + try{ + if (err.code != 0) { + console.log('windowTest SetWindowColorSpaceTest3 getColorSpace callback fail' + JSON.stringify(err)); + expect().assertFail(); + done(); + } else { + expect(data).assertTrue(); + done(); + } + }catch(exception){ + console.log('assertFail catch' + JSON.stringify(exception)); } }) }) @@ -737,10 +749,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.error('Failed to set the background1 color. Cause: ' + JSON.stringify(exception)); expect().assertFail(); done(); - } - ; - - + }; }) /** @@ -770,10 +779,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.error('Failed to set the background2 color. Cause: ' + JSON.stringify(exception)); expect().assertFail(); done(); - } - ; - - + }; }) /** @@ -854,9 +860,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.error('Failed to set the background5 color. Cause: ' + JSON.stringify(exception)); expect(exception.code).assertEqual(401); done() - } - ; - + }; }) /** @@ -876,8 +880,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.error('Failed to set the background6 color. Cause: ' + JSON.stringify(exception)); expect(exception.code).assertEqual(401); done() - } - ; + }; }) /** @@ -889,34 +892,30 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.info('windowTest setWindowBrightnessTest1 begin'); let wnd = windowStage.getMainWindowSync(); expect(wnd != null).assertTrue(); - wnd.setWindowBrightness(0).then(() => { - console.info('windowTest setWindowBrightnessTest1 setBrightness(0) success '); - let data = wnd.getWindowProperties(); - expect(data.brightness).assertEqual(0); - wnd.setWindowBrightness(0.5).then(() => { - console.info('windowTest setWindowBrightnessTest1 setBrightness(0.5) success '); - let data1 = wnd.getWindowProperties(); - expect(data1.brightness).assertEqual(0.5); - wnd.setWindowBrightness(1).then(() => { - console.info('windowTest setWindowBrightnessTest1 setBrightness(1) success '); - let data2 = wnd.getWindowProperties(); - expect(data2.brightness).assertEqual(1); - done(); - }, (err) => { - console.log('windowTest setWindwoBrightnessTest1 setBrightness failed: err' + JSON.stringify(err)); - expect().assertFail(); - done(); - }) - }, (err) => { - console.log('windowTest setBrightnessTest1 setWindowBrightness failed: err' + JSON.stringify(err)); - expect().assertFail(); - done(); - }) - }, (err) => { + await wnd.setWindowBrightness(0).catch((err) => { console.info('windowTest setWindowBrightnessTest1 setBrightness failed: err' + JSON.stringify(err)); expect().assertFail(); done(); }) + let data = wnd.getWindowProperties(); + expect(data.brightness).assertEqual(0); + await wnd.setWindowBrightness(0.5).catch((err) => { + console.log('windowTest setBrightnessTest1 setWindowBrightness failed: err' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + let data1 = wnd.getWindowProperties(); + expect(data1.brightness).assertEqual(0.5); + await wnd.setWindowBrightness(1).then(() => { + console.info('windowTest setWindowBrightnessTest1 setBrightness(1) success '); + let data2 = wnd.getWindowProperties(); + expect(data2.brightness).assertEqual(1); + done(); + }, (err) => { + console.log('windowTest setWindwoBrightnessTest1 setBrightness failed: err' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) }) /** @@ -928,7 +927,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.info('windowTest setWindowBrightnessTest2 begin'); let wnd = windowStage.getMainWindowSync(); expect(wnd != null).assertTrue(); - wnd.setWindowBrightness(0.564789).then(() => { + await wnd.setWindowBrightness(0.564789).then(() => { console.log('windowTest setBrightnessTest2 setBrightness(0.564789) success '); expect(TRUE_FLAG).assertTrue(); done(); @@ -952,7 +951,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit let brightness = Number.MAX_VALUE; try { let promise = wnd.setWindowBrightness(brightness); - promise.then(() => { + await promise.then(() => { console.info('Succeeded3 in setting the brightness.'); expect().assertFail(); done(); @@ -979,7 +978,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.info('windowTest setWindowBrightnessTest4 begin'); let wnd = windowStage.getMainWindowSync(); expect(wnd != null).assertTrue(); - wnd.setWindowBrightness(Number.MIN_VALUE).then(() => { + await wnd.setWindowBrightness(Number.MIN_VALUE).then(() => { console.info('windowTest setWindowBrightnessTest3 setBrightness(Number.MAX_VALUE) success '); expect(TRUE_FLAG).assertTrue(); done(); @@ -1002,7 +1001,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit let brightness = 1.1; try { let promise = wnd.setWindowBrightness(brightness); - promise.then(() => { + await promise.then(() => { console.info('Succeeded5 in setting the brightness.'); expect().assertFail(); done(); @@ -1020,7 +1019,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit try { let promise = wnd.setWindowBrightness(-0.5); - promise.then(() => { + await promise.then(() => { console.info('Succeeded55 in setting the brightness.'); expect().assertFail(); done(); @@ -1210,8 +1209,35 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit it('setWindowFocusableCallBack_Test_001', 0, async function (done) { console.info('windowTest setFocusableTest1 begin'); let wnd = windowStage.getMainWindowSync(); + let msgStr ='setWindowFocusableCallBack_Test_001' expect(wnd != null).assertTrue(); - wnd.setWindowFocusable(false, (err, data) => { + function setWindowFocusableFun(){ + return new Promise((resolve, reject) => { + try { + wnd.setWindowFocusable(false, (err, data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(data)); + if (err && err.code) { + try { + expect().assertFail(); + } catch (error) { + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(error)}`) + } + done(); + reject(null) + } + resolve(true) + }) + } catch (exception) { + console.error(msgStr + 'Failed to create the window. Cause: ' + JSON.stringify(exception)); + }; + }) + } + let isResultTrue; + isResultTrue = await setWindowFocusableFun() + expect(isResultTrue).assertTrue(); + let data = wnd.getWindowProperties(); + expect(!data.focusable).assertTrue(); + wnd.setWindowFocusable(true, (err, data) => { if (err.code) { console.error('Failed to set the window to be setFocusable. Cause:' + JSON.stringify(err)); try { @@ -1221,31 +1247,13 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit } done(); } else { - let data = wnd.getWindowProperties(); + let data2 = wnd.getWindowProperties(); try { - expect(!data.focusable).assertTrue(); + expect(data2.focusable).assertTrue(); } catch (error) { console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`) } - wnd.setWindowFocusable(true, (err, data) => { - if (err.code) { - console.error('Failed to set the window to be setFocusable. Cause:' + JSON.stringify(err)); - try { - expect().assertFail(); - } catch (error) { - console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`) - } - done(); - } else { - let data2 = wnd.getWindowProperties(); - try { - expect(data2.focusable).assertTrue(); - } catch (error) { - console.info(`wnd.setWindowBrightness catch error: ${JSON.stringify(error)}`) - } - done(); - } - }) + done(); } }) }) @@ -1259,24 +1267,24 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.info('windowTest setWindowFocusableTest1 begin'); let wnd = windowStage.getMainWindowSync(); expect(wnd != null).assertTrue(); - wnd.setWindowFocusable(false).then(() => { + await wnd.setWindowFocusable(false).then(async () => { console.info('windowTest setFocusableTest1 setFocusable(false) success '); let data2 = wnd.getWindowProperties(); expect(!data2.focusable).assertTrue(); - wnd.setWindowFocusable(true).then(() => { - console.info('windowTest setFocusableTest1 setFocusable(true) success '); - expect(TRUE_FLAG).assertTrue(); - done(); - }, err => { - console.info('windowTest setFocusableTest1 setFocusable failed: err' + JSON.stringify(err)); - expect().assertFail(); - done(); - }) }, (err) => { console.log('windowTest setWinFocusableTest1 setFocusable failed: err' + JSON.stringify(err)); expect().assertFail(); done(); }) + await wnd.setWindowFocusable(true).then(() => { + console.info('windowTest setFocusableTest1 setFocusable(true) success '); + expect(TRUE_FLAG).assertTrue(); + done(); + }, err => { + console.info('windowTest setFocusableTest1 setFocusable failed: err' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) }) /** @@ -1290,25 +1298,25 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit expect(wnd != null).assertTrue(); let data = wnd.getWindowProperties(); expect(data.touchable).assertTrue(); - wnd.setWindowTouchable(false).then(() => { + await wnd.setWindowTouchable(false).then(async() => { console.info('windowTest setTouchableTest1 setTouchable(false) success '); let data2 = wnd.getWindowProperties(); expect(!data2.touchable).assertTrue(); - wnd.setWindowTouchable(true).then(() => { - console.info('windowTest setTouchableTest1 setTouchable(true) success '); - let data3 = wnd.getWindowProperties(); - expect(data3.touchable).assertTrue(); - done(); - }, (err) => { - console.info('windowTest setTouchableTest1 setTouchable failed: err' + JSON.stringify(err)); - expect().assertFail(); - done(); - }) }, (err) => { console.log('windowTest setTouchableTest1 setTouchable failed: err' + JSON.stringify(err)); expect().assertFail(); done(); }) + await wnd.setWindowTouchable(true).then(() => { + console.info('windowTest setTouchableTest1 setTouchable(true) success '); + let data3 = wnd.getWindowProperties(); + expect(data3.touchable).assertTrue(); + done(); + }, (err) => { + console.info('windowTest setTouchableTest1 setTouchable failed: err' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) }) /** @@ -1317,35 +1325,48 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit * @tc.desc Set whether the window can be touched or not */ it('setWindowTouchableCallBack_Test_001', 0, async function (done) { + let msgStr ='setWindowTouchableCallBack_Test_001' let wnd = windowStage.getMainWindowSync(); expect(wnd != null).assertTrue(); - wnd.setWindowTouchable(false, (err, data) => { - if (err.code) { - console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); - expect().assertFail(); - done(); - } else { - let data = wnd.getWindowProperties(); - expect(!data.touchable).assertTrue(); - wnd.setWindowTouchable(true, (err, data) => { - if (err.code) { - console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); + function setWindowTouchableFun(){ + return new Promise((resolve, reject) => { + wnd.setWindowTouchable(false, (err, data) => { + console.log(msgStr + 'ohosWindow.createWindow data' + JSON.stringify(data)); + if (err && err.code) { try { expect().assertFail(); - } catch (error) { - console.info(`wnd.setWindowTouchable catch error: ${JSON.stringify(error)}`) - } - done(); - } else { - let data2 = wnd.getWindowProperties(); - try { - expect(data2.touchable).assertTrue(); - } catch (error) { - console.info(`wnd.setWindowTouchable catch error: ${JSON.stringify(error)}`) + } catch (err) { + console.info(msgStr + `ohosWindow.createWindow catch error: ${JSON.stringify(err)}`) } done(); + reject(null) } + resolve(true) }) + }) + } + let isResultTrue; + isResultTrue=await setWindowTouchableFun() + expect(isResultTrue).assertTrue(); + let data = wnd.getWindowProperties(); + expect(!data.touchable).assertTrue(); + wnd.setWindowTouchable(true, (err, data) => { + if (err.code) { + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); + try { + expect().assertFail(); + } catch (error) { + console.info(`wnd.setWindowTouchable catch error: ${JSON.stringify(error)}`) + } + done(); + } else { + let data2 = wnd.getWindowProperties(); + try { + expect(data2.touchable).assertTrue(); + } catch (error) { + console.info(`wnd.setWindowTouchable catch error: ${JSON.stringify(error)}`) + } + done(); } }) }) @@ -1359,9 +1380,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.info('windowTest setWindowKeepScreenOnTest2 begin'); let wnd = windowStage.getMainWindowSync(); expect(wnd != null).assertTrue(); - let data = wnd.getWindowProperties(); - expect(!data.isKeepScreenOn).assertTrue(); - wnd.setWindowKeepScreenOn(true).then(() => { +// let data = wnd.getWindowProperties(); +// expect(!data.isKeepScreenOn).assertTrue(); + await wnd.setWindowKeepScreenOn(true).then(() => { console.info('windowTest setKeepScreenOnTest2 setKeepScreenOn(false) success '); let data2 = wnd.getWindowProperties(); expect(data2.isKeepScreenOn).assertTrue(); @@ -1382,7 +1403,7 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.info('windowTest setWindowKeepScreenOnTest1 begin'); let wnd = windowStage.getMainWindowSync(); expect(wnd != null).assertTrue(); - wnd.setWindowKeepScreenOn(false).then(() => { + await wnd.setWindowKeepScreenOn(false).then(() => { console.info('windowTest setKeepScreenOnTest1 setKeepScreenOn(false) success '); let data2 = wnd.getWindowProperties(); expect(!data2.isKeepScreenOn).assertTrue(); @@ -1434,9 +1455,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.info('windowTest setWindowPrivacyMode begin'); let wnd = windowStage.getMainWindowSync(); expect(wnd != null).assertTrue(); - let data = wnd.getWindowProperties(); - expect(!data.isPrivacyMode).assertTrue(); - wnd.setWindowPrivacyMode(false).then(() => { +// let data = wnd.getWindowProperties(); +// expect(!data.isPrivacyMode).assertTrue(); + await wnd.setWindowPrivacyMode(false).then(() => { console.info('windowTest setWindowPrivacyMode1 success '); let data2 = wnd.getWindowProperties(); expect(!data2.isPrivacyMode).assertTrue(); @@ -1457,9 +1478,9 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit console.info('windowTest setWindowPrivacyMode2 begin'); let wnd = windowStage.getMainWindowSync(); expect(wnd != null).assertTrue(); - let data = wnd.getWindowProperties(); - expect(!data.isPrivacyMode).assertTrue(); - wnd.setWindowPrivacyMode(true).then(() => { +// let data = wnd.getWindowProperties(); +// expect(!data.isPrivacyMode).assertTrue(); + await wnd.setWindowPrivacyMode(true).then(() => { console.info('windowTest setWindowPrivacyMode2 success '); let data2 = wnd.getWindowProperties(); expect(data2.isPrivacyMode).assertTrue(); diff --git a/graphic/windowStage/entry/src/main/module.json b/graphic/windowStage/entry/src/main/module.json index 5782f132123737d8567c3ea6b9128f1dd5a7cb67..696d532c2282c39bfea4beb2449790f1c5af286d 100644 --- a/graphic/windowStage/entry/src/main/module.json +++ b/graphic/windowStage/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/hiviewdfx/hisyseventtest/hisyseventjstest/src/main/js/test/HiSysEventSecond.test.js b/hiviewdfx/hisyseventtest/hisyseventjstest/src/main/js/test/HiSysEventSecond.test.js index 98d9607136131493e7f4a21188844c5859d1a20f..321da6ba84ed2b907568a2e9e25b443513b5992f 100644 --- a/hiviewdfx/hisyseventtest/hisyseventjstest/src/main/js/test/HiSysEventSecond.test.js +++ b/hiviewdfx/hisyseventtest/hisyseventjstest/src/main/js/test/HiSysEventSecond.test.js @@ -539,9 +539,9 @@ describe('hiSysEventJsSecondTest', function () { */ it('testHiSysEventApi42', 3, async function (done) { console.info('testHiSysEventApi42 start') + var watcher = [] try { - var watcher = [] - for (var i = 0; i < 30; i++) { + for (var i = 0; i < 31; i++) { watcher[i] = { rules: [{ domain: "RELIABILITY" + i, @@ -555,19 +555,25 @@ describe('hiSysEventJsSecondTest', function () { } hiSysEvent.addWatcher(watcher[i]) } - setTimeout(() => { - var watcher = [] - for (var i = 0; i < 30; i++) { - hiSysEvent.removeWatcher(watcher[i]) - } - }, 5000) - done() }catch (err) { - console.error(`testHiSysEventApi42 > error code: ${err.code}, error msg: ${err.message}`) + console.error(`testHiSysEventApi42 > addWatcher error code: ${err.code}, error msg: ${err.message}`) expect(err.code == 11200101).assertTrue() - console.info('testHiSysEventApi42 end') + console.info('testHiSysEventApi42 addWatcher end') done() } + setTimeout(() => { + try { + for (var i = 0; i < 31; i++) { + hiSysEvent.removeWatcher(watcher[i]) + } + }catch (err) { + console.error(`testHiSysEventApi42 > remove error code: ${err.code}, error msg: ${err.message}`) + expect(err.code == 11200201).assertTrue() + console.info('testHiSysEventApi42 remove end') + done() + } + }, 5000) + done() }) /** diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/module.json b/inputmethod/InputMethodTest_Stage/entry/src/main/module.json index dc12cdd19e7a76038580daf6d8e88663922cd061..ebfbd6d84affbd1afb81143f66102b24668c9d3b 100644 --- a/inputmethod/InputMethodTest_Stage/entry/src/main/module.json +++ b/inputmethod/InputMethodTest_Stage/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.acts.imeability.test.MainAbility", diff --git a/location/BUILD.gn b/location/BUILD.gn index ac5383466bf5dba009e392f9005f36463924537d..75d63399a33ef4c3b07863b752fd73e05e551572 100644 --- a/location/BUILD.gn +++ b/location/BUILD.gn @@ -15,8 +15,14 @@ import("//build/ohos_var.gni") group("location") { testonly = true if (is_standard_system) { - deps = [ "geolocation_standard:ActslocationJsTest" ] + deps = [ + "geolocation_errorCode:ActslocationErrorCodeTest", + "geolocation_standard:ActslocationJsTest", + ] } else { - deps = [ "geolocation_standard:ActslocationJsTest" ] + deps = [ + "geolocation_errorCode:ActslocationErrorCodeTest", + "geolocation_standard:ActslocationJsTest", + ] } } diff --git a/location/geolocation_errorCode/BUILD.gn b/location/geolocation_errorCode/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8bb99a591a1f0ce382a4346127cf4492b2efd1bc --- /dev/null +++ b/location/geolocation_errorCode/BUILD.gn @@ -0,0 +1,37 @@ +# 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("ActslocationErrorCodeTest") { + hap_profile = "./src/main/config.json" + deps = [ + ":geolocation_js_assets", + ":geolocation_resources", + ] + + # shared_libraries = [ + # "//third_party/giflib:libgif", + # "//third_party/libpng:libpng", + # ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActslocationErrorCodeApiTest" + part_name = "location" + subsystem_name = "location" +} +ohos_js_assets("geolocation_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("geolocation_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/location/geolocation_errorCode/Test.json b/location/geolocation_errorCode/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..1fda4b1775a9d736ea4d6b7cf160e6fe212cb3e5 --- /dev/null +++ b/location/geolocation_errorCode/Test.json @@ -0,0 +1,24 @@ +{ + "description": "Configuration for geolocation js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "600000", + "package": "ohos.acts.location.geolocation.function", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActslocationErrorCodeApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "hilog -Q pidoff" + ] + } + ] +} diff --git a/location/geolocation_errorCode/signature/openharmony_sx.p7b b/location/geolocation_errorCode/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..94290b95b64486edfe5af7b09059da881672d1a1 Binary files /dev/null and b/location/geolocation_errorCode/signature/openharmony_sx.p7b differ diff --git a/location/geolocation_errorCode/src/main/config.json b/location/geolocation_errorCode/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..969cc6f318a10bb1d866fcae76a2cbc6a4757868 --- /dev/null +++ b/location/geolocation_errorCode/src/main/config.json @@ -0,0 +1,131 @@ +{ + "app": { + "bundleName": "ohos.acts.location.geolocation.function", + "vendor": "acts", + "version": { + "code": 1000000, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.location.geolocation.function", + "name": ".MyApplication", + "mainAbility": "ohos.acts.location.geolocation.function.MainAbility", + "deviceType": [ + "tablet", + "default", + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": "ohos.acts.location.geolocation.function.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.LOCATION", + "reason": "need use ohos.permission.LOCATION", + "usedScene": { + "ability": [ + "ohos.acts.location.geolocation.function.MainAbility" + ], + "when": "inuse" + } + }, + { + "name":"ohos.permission.ACCESS_LOCATION", + "reason":"need use ohos.permission.ACCESS_LOCATION", + "usedScene": { + "ability": [ + "ohos.acts.location.geolocation.function.MainAbility" + ], + "when": "inuse" + } + }, + { + "name":"ohos.permission.APPROXIMATELY_LOCATION", + "reason":"need use ohos.permission.APPROXIMATELY_LOCATION", + "usedScene": { + "ability": [ + "ohos.acts.location.geolocation.function.MainAbility" + ], + "when": "inuse" + } + }, + { + "name":"ohos.permission.LOCATION_IN_BACKGROUND", + "reason":"need use ohos.permission.LOCATION_IN_BACKGROUND", + "usedScene": { + "ability": [ + "ohos.acts.location.geolocation.function.MainAbility" + ], + "when": "inuse" + } + }, + { + "name":"ohos.permission.MANAGE_SECURE_SETTINGS", + "reason":"need use ohos.permission.MANAGE_SECURE_SETTINGS", + "usedScene": { + "ability": [ + "ohos.acts.location.geolocation.function.MainAbility" + ], + "when": "inuse" + } + }, + { + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} + diff --git a/graphic/webGL/src/main/js/default/pages/index/index.js b/location/geolocation_errorCode/src/main/js/default/app.js similarity index 65% rename from graphic/webGL/src/main/js/default/pages/index/index.js rename to location/geolocation_errorCode/src/main/js/default/app.js index e8f96c887e681b8ce4700f163f742758330d6582..84f1448f02152e5e1772661d85159776611f8d54 100644 --- a/graphic/webGL/src/main/js/default/pages/index/index.js +++ b/location/geolocation_errorCode/src/main/js/default/app.js @@ -1,41 +1,36 @@ -/* - * 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 {Core,ExpectExtend} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow(){ - global.el = this.$refs.canvas1; - global.el2 = this.$refs.canvas2; - - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id':'extend' - }) - core.addService('expect',expectExtend) - core.init() - const configService = core.getDefaultService('config') - this.timeout = 60000 - configService.setConfig(this) - require('../../test/List.test.js') - core.execute() - - } -} +/* + * 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 {Core, ExpectExtend} from 'deccjsunit/index' + +export default { + onCreate() { + console.info('AceApplication onCreate'); + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + + const configService = core.getDefaultService('config') + configService.setConfig({'timeout': 12000}) + + require('./test/List.test') + core.execute() + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/MainAbility/i18n/en-US.json b/location/geolocation_errorCode/src/main/js/default/i18n/en-US.json similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/MainAbility/i18n/en-US.json rename to location/geolocation_errorCode/src/main/js/default/i18n/en-US.json diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/MainAbility/i18n/zh-CN.json b/location/geolocation_errorCode/src/main/js/default/i18n/zh-CN.json similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/MainAbility/i18n/zh-CN.json rename to location/geolocation_errorCode/src/main/js/default/i18n/zh-CN.json diff --git a/location/geolocation_errorCode/src/main/js/default/pages/index/index.css b/location/geolocation_errorCode/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/location/geolocation_errorCode/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/location/geolocation_errorCode/src/main/js/default/pages/index/index.hml b/location/geolocation_errorCode/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/location/geolocation_errorCode/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/location/geolocation_errorCode/src/main/js/default/pages/index/index.js b/location/geolocation_errorCode/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..3a5f99e66eb0a1ba6f72bb0057da5d9b8b5db5df --- /dev/null +++ b/location/geolocation_errorCode/src/main/js/default/pages/index/index.js @@ -0,0 +1,31 @@ +/* + * 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' + + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, +} \ No newline at end of file diff --git a/location/geolocation_errorCode/src/main/js/default/test/GeocoderErrorTest.test.js b/location/geolocation_errorCode/src/main/js/default/test/GeocoderErrorTest.test.js new file mode 100644 index 0000000000000000000000000000000000000000..7e38ab815af17248938218b8b8c81a5de4a512e8 --- /dev/null +++ b/location/geolocation_errorCode/src/main/js/default/test/GeocoderErrorTest.test.js @@ -0,0 +1,191 @@ +/* + * 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 geolocation from '@ohos.geolocation'; +import geolocationm from '@ohos.geoLocationManager'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import osaccount from '@ohos.account.osAccount' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +async function changedLocationMode(){ + let result1 = geolocationm.isLocationEnabled(); + console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1)); + if(!result1){ + await geolocation.requestEnableLocation().then((result) => { + console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result)); + }).catch((error) => { + console.info("[lbs_js] promise then error." + JSON.stringify(error)); + expect().assertFail(); + }); + } + let result2 = geolocationm.isLocationEnabled(); + console.info('[lbs_js] check LocationSwitchState result: ' + JSON.stringify(result2)); +} + + +async function applyPermission() { + let osAccountManager = osaccount.getAccountManager(); + console.info("=== getAccountManager finish"); + let localId = await osAccountManager.getOsAccountLocalIdFromProcess(); + console.info("LocalId is :" + localId); + let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId); + let atManager = abilityAccessCtrl.createAtManager(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('[permission] case accessTokenID is ' + tokenID); + let permissionName1 = 'ohos.permission.LOCATION'; + let permissionName2 = 'ohos.permission.LOCATION_IN_BACKGROUND'; + await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result)); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err)); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result)); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err)); + }); + } else { + console.info('[permission] case apply permission failed, createAtManager failed'); + } +} + +describe('geolocationTest_GeoErr', function () { + + console.log('#start AccessTokenTests#'); + beforeAll(async function (done) { + console.info('beforeAll case'); + await applyPermission(); + await changedLocationMode(); + done(); + }) + + beforeEach(async function (done) { + console.info('beforeEach case'); + done(); + }) + + + /** + * @tc.number SUB_HSS_LocationSystem_GeoErr_0400 + * @tc.name testGetAddressesFromLocation + * @tc.desc Incorrect input parameters are used to invoke the reverse geocoding service. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_HSS_LocationSystem_GeoErr_0400', 0, async function (done) { + try { + let reverseGeocodeRequest = "1"; + geolocationm.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { + if (err) { + console.info('[lbs_js] getAddressesFromLocation4 callback err is:' + JSON.stringify(err)); + expect(err.code).assertEqual("401"); + return; + } else { + console.info("[lbs_js] getAddressesFromLocation4 callback data is:" + JSON.stringify(data)); + expect(true).assertFalse(); + } + }); + } catch (error) { + console.info("[lbs_js] getAddressesFromLocation4 callback try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1000); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_GeoErr_0500 + * @tc.name testGetAddressesFromLocation + * @tc.desc Incorrect input parameters are used to invoke the reverse geocoding service. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_HSS_LocationSystem_GeoErr_0500', 0, async function (done) { + (async () => { + try { + let reverseGeocodeRequest = "1"; + let result = await geolocationm.getAddressesFromLocation(reverseGeocodeRequest); + console.info("[lbs_js] getAddressesFromLocation5 promise successful:" + JSON.stringify(result)); + } catch(error) { + console.info('[lbs_js] getAddressesFromLocation5 promise err:' + JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + })(); + await sleep(1000); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_GeoErr_0600 + * @tc.name testGetAddressesFromLocationName + * @tc.desc Invoke the geocoding service with incorrect input parameters. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_HSS_LocationSystem_GeoErr_0600', 0, async function (done) { + try { + let geocodeRequest = 1; + geolocationm.getAddressesFromLocationName(geocodeRequest, (err, data) => { + if (err) { + console.info('[lbs_js] getAddressesFromLocationName6 callback err is:' + JSON.stringify(err)); + expect(err.code).assertEqual(401); + return; + } else { + console.info("[lbs_js] getAddressesFromLocationName6 callback data is: " + JSON.stringify(data)); + expect(true).assertFalse(); + } + }); + }catch(error){ + console.info("[lbs_js] getAddressesFromLocationName6 try err." + JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1000); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_GeoErr_0700 + * @tc.name testGetAddressesFromLocationName + * @tc.desc Invoke the geocoding service with incorrect input parameters. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_HSS_LocationSystem_GeoErr_0700', 0, async function (done) { + (async () => { + try { + let geocodeRequest = 1; + let result = await geolocationm.getAddressesFromLocationName(geocodeRequest); + console.info("[lbs_js] getAddressesFromLocationName7 promise successful:" + JSON.stringify(result)); + } catch(error) { + console.info('[lbs_js] getAddressesFromLocationName7 promise err:' + JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + })(); + await sleep(1000); + done(); + }) + + +}) diff --git a/location/geolocation_errorCode/src/main/js/default/test/GetCountryCodeError.test.js b/location/geolocation_errorCode/src/main/js/default/test/GetCountryCodeError.test.js new file mode 100644 index 0000000000000000000000000000000000000000..90dbbd669837efb7a8b032d6ffa805a54efbcf88 --- /dev/null +++ b/location/geolocation_errorCode/src/main/js/default/test/GetCountryCodeError.test.js @@ -0,0 +1,109 @@ +/* + * 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 geolocation from '@ohos.geolocation'; +import geolocationm from '@ohos.geoLocationManager'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import osaccount from '@ohos.account.osAccount' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + console.info('[lbs_js]sleep function'); +} + +async function changedLocationMode(){ + let result1 = geolocationm.isLocationEnabled(); + console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1)); + if(!result1){ + await geolocation.requestEnableLocation().then(async(result) => { + await sleep(3000); + console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result)); + }).catch((error) => { + console.info("[lbs_js] promise then error." + JSON.stringify(error)); + expect().assertFail(); + }); + } + let result2 = geolocationm.isLocationEnabled(); + console.info('[lbs_js] check LocationSwitchState result: ' + JSON.stringify(result2)); +} + +async function applyPermission() { + let osAccountManager = osaccount.getAccountManager(); + console.info("====>testgetuserid get AccountManager finish===="); + let localId = await osAccountManager.getOsAccountLocalIdFromProcess(); + console.info("====>testgetuserid localId obtained by process:" + localId); + let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId); + let atManager = abilityAccessCtrl.createAtManager(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('[permission] case accessTokenID is ' + tokenID); + let permissionName1 = 'ohos.permission.LOCATION'; + let permissionName2 = 'ohos.permission.LOCATION_IN_BACKGROUND'; + await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + } else { + console.info('[permission] case apply permission failed, createAtManager failed'); + } +} + +describe('geolocationTest_counterr', function () { + beforeAll(async function (done) { + console.info('beforeAll case'); + await applyPermission(); + await changedLocationMode(); + done(); + }) + + beforeEach(async function (done) { + console.info('beforeEach case'); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_CountryCodeErr_0100 + * @tc.name Test getCountryCode + * @tc.desc Incorrect input parameter to obtain the country code information. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_CountryCodeErr_0100', 0, async function (done) { + try { + geolocationm.getCountryCode("test",(err,data) => { + if (err) { + console.info('[lbs_js] getCountryCode callback err:' + JSON.stringify(err)); + expect(err.code).assertEqual("401"); + return; + } + console.info("[lbs_js] getCountryCode callback success"+ JSON.stringify(data)); + expect(true).assertFalse(); + }) + } catch (error) { + console.info('[lbs_js] getCountryCode callback try err:' + JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1000); + done(); + }) + +}) diff --git a/location/geolocation_errorCode/src/main/js/default/test/List.test.js b/location/geolocation_errorCode/src/main/js/default/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..5dcc745a464875ce46cb28968d53eba1e15ddf26 --- /dev/null +++ b/location/geolocation_errorCode/src/main/js/default/test/List.test.js @@ -0,0 +1,20 @@ +/* + * 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. + */ + + +require('./GeocoderErrorTest.test.js') +require('./LocationErrorTest.test.js') +require('./GetCountryCodeError.test.js') +require('./ListeningError.test.js') \ No newline at end of file diff --git a/location/geolocation_errorCode/src/main/js/default/test/ListeningError.test.js b/location/geolocation_errorCode/src/main/js/default/test/ListeningError.test.js new file mode 100644 index 0000000000000000000000000000000000000000..9d48ab74f1f8c119431b3ab7e46b5da738c31e40 --- /dev/null +++ b/location/geolocation_errorCode/src/main/js/default/test/ListeningError.test.js @@ -0,0 +1,465 @@ +/* + * 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 geolocation from '@ohos.geolocation'; +import geolocationm from '@ohos.geoLocationManager'; +import wantAgent from '@ohos.wantAgent'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import osaccount from '@ohos.account.osAccount' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +async function changedLocationMode(){ + let result1 = geolocationm.isLocationEnabled(); + console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1)); + if(!result1){ + await geolocation.requestEnableLocation().then(async(result) => { + await sleep(3000); + console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result)); + }).catch((error) => { + console.info("[lbs_js] promise then error." + JSON.stringify(error)); + expect().assertFail(); + }); + } + let result2 = geolocationm.isLocationEnabled(); + console.info('[lbs_js] check LocationSwitchState result: ' + JSON.stringify(result2)); +} + +async function applyPermission() { + let osAccountManager = osaccount.getAccountManager(); + console.info("====>testgetuserid get AccountManager finish===="); + let localId = await osAccountManager.getOsAccountLocalIdFromProcess(); + console.info("====>testgetuserid localId obtained by process:" + localId); + let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId); + let atManager = abilityAccessCtrl.createAtManager(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('[permission] case accessTokenID is ' + tokenID); + let permissionName1 = 'ohos.permission.LOCATION'; + let permissionName2 = 'ohos.permission.LOCATION_IN_BACKGROUND'; + await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + result); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + err); + }); + } else { + console.info('[permission] case apply permission failed, createAtManager failed'); + } +} + + +describe('geolocationTest_6', function () { + beforeAll(async function (done) { + console.info('beforeAll case'); + await applyPermission(); + await changedLocationMode(); + done(); + }) + + beforeEach(async function (done) { + console.info('beforeEach case'); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_CountryCodeErr_0200 + * @tc.name getCountryCode_on_off + * @tc.desc The interception country code is changed. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_CountryCodeErr_0200', 0, function () { + try { + console.info("[lbs_js] SUB_HSS_LocationSystem_CountryCodeErr_0200"); + geolocationm.on('countryCodeChange', 1); + } catch (error) { + console.info("[lbs_js] countryCodeOn2 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + }) + + /** + * @tc.number SUB_HSS_LocationSystem_CountryCodeErr_0300 + * @tc.name getCountryCode_on_off + * @tc.desc The interception country code is changed. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_CountryCodeErr_0300', 0, function () { + try { + console.info("[lbs_js] SUB_HSS_LocationSystem_CountryCodeErr_0300"); + geolocationm.off('countryCodeChange',1); + } catch (error) { + console.info("[lbs_js] countryCodeOff3 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + }) + + + it('SUB_HSS_LocationSystem_CountryCodeErr_0201', 0, async function (done) { + var callback = (code) => { + console.log('countryCodeChange: ' + JSON.stringify(code)); + } + try { + console.info("[lbs_js] SUB_HSS_LocationSystem_CountryCodeErr_0200"); + geolocationm.on('countryCodeChange', 1,callback); + console.info('[lbs_js] countryCodeOn2' +JSON.stringify(callback)); + } catch (error) { + console.info("[lbs_js] countryCodeOn2 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1000); + done(); + }) + + it('SUB_HSS_LocationSystem_CountryCodeErr_0301', 0, async function (done) { + var callback = (code) => { + console.log('countryCodeChange: ' + JSON.stringify(code)); + } + try { + console.info("[lbs_js] SUB_HSS_LocationSystem_CountryCodeErr_0300"); + geolocationm.off('countryCodeChange',1,"test", callback); + console.info('[lbs_js] countryCodeOff3' +JSON.stringify(callback)); + } catch (error) { + console.info("[lbs_js] countryCodeOff3 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1500); + done(); + }) + + + it('SUB_HSS_LocationSystem_BatchingErr_0801', 0, function () { + try { + geolocationm.on('cachedGnssLocationsChange',1); + } catch (error) { + console.info("[lbs_js] cacheOn8 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + }) + + it('SUB_HSS_LocationSystem_BatchingErr_0901', 0, function () { + try { + geolocationm.off('cachedGnssLocationsChange',1); + } catch (error) { + console.info("[lbs_js] cacheOff9 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + }) + + + /** + * @tc.number SUB_HSS_LocationSystem_BatchingErr_0800 + * @tc.name cachedGnssLocationsChange_on_off + * @tc.desc Subscribe to cache GNSS locations update messages. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_BatchingErr_0800', 0, async function (done) { + var cachedLocationsCb = (locations) => { + console.log('[lbs_js] cachedGnssLocationsReporting8:locations:' + JSON.stringify(locations)); + expect(true).assertEqual(locations !=null); + } + var CachedGnssLoactionsRequest = {'reportingPeriodSec': 5, 'wakeUpCacheQueueFull': true}; + try { + geolocationm.on(1,'cachedGnssLocationsChange', CachedGnssLoactionsRequest,cachedLocationsCb); + console.info('[lbs_js] cacheOn8' +JSON.stringify(cachedLocationsCb)); + } catch (error) { + console.info("[lbs_js] cacheOn8 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1000); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_BatchingErr_0900 + * @tc.name cachedGnssLocationsChange_on_off + * @tc.desc Unsubscribe to cache GNSS locations update messages. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_BatchingErr_0900', 0, async function (done) { + var cachedLocationsCb = (locations) => { + console.log('[lbs_js] cachedGnssLocationsReporting9:locations:' + JSON.stringify(locations)); + expect(true).assertEqual(locations !=null); + } + try { + geolocationm.off(1,'cachedGnssLocationsChange',"test",cachedLocationsCb); + console.info('[lbs_js] cacheOff9' +JSON.stringify(cachedLocationsCb)); + } catch (error) { + console.info("[lbs_js] cacheOff9 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1500); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_GnssErr_0100 + * @tc.name satelliteStatusChange_on_off + * @tc.desc Subscribe satellite status changed. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_GnssErr_0100', 0, async function (done) { + var gnssStatusCb = (satelliteStatusInfo) => { + console.info('[lbs_js] gnssStatusChange1: ' + satelliteStatusInfo); + expect(true).assertEqual(satelliteStatusInfo != null); + } + try { + geolocationm.on(1,'satelliteStatusChange',gnssStatusCb); + console.info('[lbs_js] satelliteOn1' +JSON.stringify(gnssStatusCb)); + } catch (error) { + console.info("[lbs_js] satelliteOn1 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1000); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_GnssErr_0400 + * @tc.name satelliteStatusChange_on_off + * @tc.desc Unsubscribe satellite status changed. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_GnssErr_0400', 0, async function (done) { + var gnssStatusCb = (satelliteStatusInfo) => { + console.info('[lbs_js] gnssStatusChange4: ' + satelliteStatusInfo); + expect(true).assertEqual(satelliteStatusInfo != null); + } + try { + geolocationm.off(1,'satelliteStatusChange', "test",gnssStatusCb); + console.info('[lbs_js] satelliteOff4' +JSON.stringify(gnssStatusCb)); + } catch (error) { + console.info("[lbs_js] satelliteOff4 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1500); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_GnssErr_0200 + * @tc.name locationChange_on_off + * @tc.desc Subscribe location changed. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_GnssErr_0200', 0, async function (done) { + let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, + "distanceInterval": 0, "maxAccuracy": 0}; + var locationChange = (location) => { + console.log('[lbs_js] gnsslocationChanger2: data: ' + JSON.stringify(location)); + expect(true).assertEqual(locationChange !=null); + }; + try { + geolocationm.on(1,'locationChange', requestInfo,locationChange); + console.info('[lbs_js] locationChangeOn2' +JSON.stringify(locationChange)); + } catch (error) { + console.info("[lbs_js] locationChangeOn2 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1000); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_GnssErr_0500 + * @tc.name locationChange_on_off + * @tc.desc Unsubscribe location changed. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_GnssErr_0500', 0, async function (done) { + var locationChange = (location) => { + console.log('[lbs_js] gnsslocationChanger5: data: ' + JSON.stringify(location)); + expect(true).assertEqual(locationChange !=null); + }; + try { + geolocationm.off(1,'locationChange',"test",locationChange); + console.info('[lbs_js] locationChangeOff5' +JSON.stringify(locationChange)); + } catch (error) { + console.info("[lbs_js] locationChangeOff5 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1500); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_GnssErr_0300 + * @tc.name nmeaMessage_on_off + * @tc.desc Subscribe nmea message changed. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_GnssErr_0300', 0, async function (done) { + var nmeaCb = (str) => { + console.log('[lbs_js] nmeaMessage: ' + str); + } + try { + geolocationm.on(1,'nmeaMessage',nmeaCb); + console.info('[lbs_js] nmeaMessageOn2' +JSON.stringify(nmeaCb)); + } catch (error) { + console.info("[lbs_js] nmeaMessageOn2 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1000); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_GnssErr_0600 + * @tc.name nmeaMessage_on_off + * @tc.desc Unsubscribe nmea message changed. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_GnssErr_0600', 0, async function (done) { + var nmeaCb = (str) => { + console.log('[lbs_js] nmeaMessage: ' + str); + } + try { + geolocationm.off(1,'nmeaMessage',nmeaCb); + console.info('[lbs_js] nmeaMessageOff6' +JSON.stringify(nmeaCb)); + } catch (error) { + console.info("[lbs_js] nmeaMessageOff6 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1500); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_GeoFenceErr_0100 + * @tc.name gnssFenceStatusChange_on_off + * @tc.desc Add a geofence and subscribe geo fence status changed. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_GeoFenceErr_0100', 0, async function (done) { + let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""}; + let geofenceRequest = {"priority":0x200, "scenario":0x301, "geofence": geofence}; + let want = (wantAgent) => { + console.log('[lbs_js] wantAgent: ' + JSON.stringify(wantAgent)); + }; + try { + geolocationm.on(1,'gnssFenceStatusChange', geofenceRequest, + (want) => { + if(err){ + console.info('[lbs_js] FenceStatusOn1 callback err:' + JSON.stringify(err)); + expect(err.code).assertEqual("401"); + return; + } + console.info("[lbs_js] FenceStatusOn1 callback result:" + JSON.stringify(want)); + expect(true).assertEqual(want !=null); + done(); + }); + } catch (error) { + console.info("[lbs_js] FenceStatusOn1 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1000); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_GeoFenceErr_0200 + * @tc.name gnssFenceStatusChange_on_off + * @tc.desc Remove a geofence and unsubscribe geo fence status changed. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_GeoFenceErr_0200', 0, async function (done) { + let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""}; + let geofenceRequest = {"priority":0x200, "scenario":0x301, "geofence": geofence}; + let want = (wantAgent) => { + console.log('[lbs_js] wantAgent: ' + JSON.stringify(wantAgent)); + }; + try { + geolocationm.off(1,"test",'gnssFenceStatusChange',geofenceRequest, + (want) => { + if(err){ + console.info('[lbs_js] FenceStatusOff2 callback err:' + JSON.stringify(err)); + expect(err.code).assertEqual("401"); + return; + } + console.info("[lbs_js] FenceStatusOff2 callback result:" + JSON.stringify(want)); + expect(true).assertEqual(want !=null); + }); + } catch (error) { + console.info("[lbs_js] FenceStatusOff2 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1500); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_LocSwitchErr_0100 + * @tc.name locationEnabledChange_on_off + * @tc.desc Subscribe location switch changed. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_LocSwitchErr_0100', 0, async function (done) { + var locationServiceState = (state) => { + console.log('[lbs_js] locationServiceState: state: ' + JSON.stringify(state)); + } + try { + geolocationm.on(1,'locationEnabledChange', locationServiceState); + console.info('[lbs_js] nEnabledChangeOn1' +JSON.stringify(locationServiceState)); + } catch (error) { + console.info("[lbs_js] nEnabledChangeOn1 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1000); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_LocSwitchErr_0100 + * @tc.name locationEnabledChange_on_off + * @tc.desc Unsubscribe location switch changed. + * @tc.type Function + * @tc.level since 9 + */ + it('SUB_HSS_LocationSystem_LocSwitchErr_0200', 0, async function (done) { + var locationServiceState = (state) => { + console.log('[lbs_js] locationServiceState: state: ' + JSON.stringify(state)); + } + try { + geolocationm.off(1,'locationEnabledChange',locationServiceState); + console.info('[lbs_js] EnabledChangeOff2' +JSON.stringify(locationServiceState)); + } catch (error) { + console.info("[lbs_js] EnabledChangeOff2 try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1500); + done(); + }) + +}) diff --git a/location/geolocation_errorCode/src/main/js/default/test/LocationErrorTest.test.js b/location/geolocation_errorCode/src/main/js/default/test/LocationErrorTest.test.js new file mode 100644 index 0000000000000000000000000000000000000000..1ffbcbfb8373b94e95917e4067a529f1cf4bb5a3 --- /dev/null +++ b/location/geolocation_errorCode/src/main/js/default/test/LocationErrorTest.test.js @@ -0,0 +1,293 @@ +/* + * 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 geolocation from '@ohos.geolocation'; +import geolocationm from '@ohos.geoLocationManager'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import osaccount from '@ohos.account.osAccount' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +let LocationRequestScenario = {UNSET : 0x300 ,NAVIGATION : 0x301 , + TRAJECTORY_TRACKING : 0x302 ,CAR_HAILING : 0x303, + DAILY_LIFE_SERVICE : 0x304 ,NO_POWER : 0x305} +let LocationRequestPriority = {UNSET : 0x200 ,ACCURACY : 0x201 ,LOW_POWER : 0x202 ,FIRST_FIX :0x203} +let LocationPrivacyType = { + OTHERS : 0, + STARTUP: 1, + CORE_LOCATION : 2 +} + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +async function changedLocationMode(){ + let result1 = geolocationm.isLocationEnabled(); + console.info('[lbs_js] getLocationSwitchState result: ' + JSON.stringify(result1)); + if(!result1){ + await geolocation.requestEnableLocation().then(async(result) => { + await sleep(3000); + console.info('[lbs_js] test requestEnableLocation promise result: ' + JSON.stringify(result)); + }).catch((error) => { + console.info("[lbs_js] promise then error." + JSON.stringify(error)); + expect().assertFail(); + }); + } + let result2 = geolocationm.isLocationEnabled(); + console.info('[lbs_js] check LocationSwitchState result: ' + JSON.stringify(result2)); +} + +async function enableLocationSwitch(){ + function enableLocationSwitchCallback(){ + return new Promise((resolve, reject)=>{ + geolocation.requestEnableLocation((err, data) => { + if (err) { + console.info('[lbs_js] requestEnableLocation callback err is : ' + err ); + }else { + console.info("[lbs_js] requestEnableLocation callback data: " + data); + expect(data).assertTrue(); + } + }); + }) + } + await enableLocationSwitchCallback(); + done(); + +} + + +async function applyPermission() { + let osAccountManager = osaccount.getAccountManager(); + console.info("=== getAccountManager finish"); + let localId = await osAccountManager.getOsAccountLocalIdFromProcess(); + console.info("LocalId is :" + localId); + let appInfo = await bundle.getApplicationInfo('ohos.acts.location.geolocation.function', 0, localId); + let atManager = abilityAccessCtrl.createAtManager(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('[permission] case accessTokenID is ' + tokenID); + let permissionName1 = 'ohos.permission.LOCATION'; + let permissionName2 = 'ohos.permission.LOCATION_IN_BACKGROUND'; + await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result)); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err)); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result)); + }).catch((err) => { + console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err)); + }); + } else { + console.info('[permission] case apply permission failed, createAtManager failed'); + } +} + +describe('geolocationTest_LocErr', function () { + beforeAll(async function (done) { + console.info('beforeAll case'); + await applyPermission(); + await changedLocationMode(); + done(); + }) + + beforeEach(function () { + console.info('beforeEach case'); + }) + afterEach(function () { + }) + + + + /** + * @tc.number SUB_HSS_LocationSystem_SingleLocErr_0100 + * @tc.name Test getCurrentLocation + * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_HSS_LocationSystem_SingleLocErr_0100', 0, async function (done) { + try { + let currentLocationRequest = 1; + geolocationm.getCurrentLocation(currentLocationRequest, (err, result) => { + if (err) { + console.info("[lbs_js] getCurrentLocation1 callback err: " + JSON.stringify(err)); + expect(err.code).assertEqual(401); + return; + } else { + console.info("[lbs_js] getCurrentLocation1 callback result:" + JSON.stringify(result)); + expect(true).assertFalse(); + } + }); + } catch (error) { + console.error('[lbs_js] getCurrentLocation1 callback try err:' + JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(500); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_SingleLocErr_0200 + * @tc.name Test getCurrentLocation + * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_HSS_LocationSystem_SingleLocErr_0200', 0, async function (done) { + (async () => { + try { + let currentLocationRequest = 1; + let result = await geolocationm.getCurrentLocation(currentLocationRequest); + console.info("[wifi_test] getCurrentLocation2 promise:" + JSON.stringify(result)); + } catch(error) { + console.info('[lbs_js] getCurrentLocation2 promise try err:' + JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + })(); + await sleep(600); + done(); + }) + + /** + * @tc.number SUB_HSS_SendCommandErr_0100 + * @tc.name Test sendCommand + * @tc.desc An incorrect extended command is sent to each component of the location service subsystem. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_HSS_SendCommandErr_0100', 0, async function (done) { + let requestInfo = "lbstest"; + try { + geolocationm.sendCommand(requestInfo,(err, result) => { + if (err) { + console.info('sendcommand callback err:' + JSON.stringify(err)); + expect(err.code).assertEqual("401"); + return; + } + console.info('sendcommand callback result:' + JSON.stringify(result)); + }); + } catch (error) { + console.info('sendcommand callback try err:' + JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(1500); + done(); + }) + + /** + * @tc.number SUB_HSS_SendCommandErr_0200 + * @tc.name Test sendCommand + * @tc.desc An incorrect extended command is sent to each component of the location service subsystem. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_HSS_SendCommandErr_0200', 0, async function (done) { + let requestInfo = "test"; + (async () => { + try { + let result = await geolocationm.sendCommand(requestInfo); + console.info("[lbs_js] sendCommand promise:" + JSON.stringify(result)); + } catch(error) { + console.info('[lbs_js] sendCommand promise err:' + JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + })(); + await sleep(1500); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_BatchingErr_0100 + * @tc.name Test getCachedGnssLocationsSize + * @tc.desc An incorrect parameter is used to obtain the number of GNSS cache locations reported at a time. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_HSS_LocationSystem_BatchingErr_0100', 0, async function (done) { + try { + geolocationm.getCachedGnssLocationsSize("test",(err, data) => { + if (err) { + console.info('[lbs_js] getCachedSiz1 callback err is:' + JSON.stringify(err)); + expect(err.code).assertEqual("401"); + return; + } + console.info("[lbs_js] getCachedSiz1 callback data is:" + JSON.stringify(data)); + expect(true).assertFalse(); + }); + } catch (error) { + console.info("[lbs_js] getCachedSiz1 callback try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(2000); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_BatchingErr_0400 + * @tc.name Test flushCachedGnssLocations + * @tc.desc All prepared GNSS locations are returned to the application and the underlying buffers are cleared. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_HSS_LocationSystem_BatchingErr_0400', 0, async function (done) { + try { + geolocationm.flushCachedGnssLocations("test",(err, data) => { + if (err) { + console.info('[lbs_js] flushCachedGnssLocations4 callback err is : ' + JSON.stringify(err)); + expect(err.code).assertEqual("401"); + return; + } + console.info("[lbs_js] flushCachedGnssLocations4 callback data is: " + JSON.stringify(data)); + expect(true).assertFalse(); + }); + } catch (error) { + console.info("[lbs_js] flushCachedGnssLocations4 callback try error:"+ JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + await sleep(2000); + done(); + }) + + /** + * @tc.number SUB_HSS_LocationSystem_BatchingErr_0500 + * @tc.name Test flushCachedGnssLocations + * @tc.desc All prepared GNSS locations are returned to the application and the underlying buffers are cleared. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + it('SUB_HSS_LocationSystem_BatchingErr_0500', 0, async function (done) { + (async () => { + try { + let result = await geolocationm.flushCachedGnssLocations(1); + console.info("[lbs_js] flushCachedGnssLocations5 promise successful :" + JSON.stringify(result)); + } catch(error) { + console.info('[lbs_js] flushCachedGnssLocations5 promise err:' + JSON.stringify(error) +"code"+ error.code +"mes"+ error.message); + expect(error.code).assertEqual("401"); + } + })(); + await sleep(2000); + done(); + }) + +}) diff --git a/location/geolocation_errorCode/src/main/resources/base/element/string.json b/location/geolocation_errorCode/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..14f9c3a9210f78b12caf3b945dc2b2c0f63f7d3d --- /dev/null +++ b/location/geolocation_errorCode/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "OsAccountTest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/location/geolocation_errorCode/src/main/resources/base/media/icon.png b/location/geolocation_errorCode/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/location/geolocation_errorCode/src/main/resources/base/media/icon.png differ diff --git a/multimedia/BUILD.gn b/multimedia/BUILD.gn index beed0932b7f2ba9c658927b67dfb78d98a6c3a51..eaae8a89472325945f911583449161228c919dec 100644 --- a/multimedia/BUILD.gn +++ b/multimedia/BUILD.gn @@ -17,6 +17,7 @@ group("multimedia") { testonly = true if (is_standard_system) { deps = [ + "audio/audio_cpp_standard:ActsOpenslesNdkTest", "audio/audio_js_standard/AudioCapturer:audio_capturer_js_hap", "audio/audio_js_standard/AudioCapturerChangeInfo:audio_capturerchangeInfo_js_hap", "audio/audio_js_standard/AudioEventManagement:audio_eventmanagement_js_hap", diff --git a/multimedia/audio/audio_cpp_standard/BUILD.gn b/multimedia/audio/audio_cpp_standard/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..57545b79d126142b23cd85758bf94b38535b9ffc --- /dev/null +++ b/multimedia/audio/audio_cpp_standard/BUILD.gn @@ -0,0 +1,67 @@ +# Copyright (c) 2023 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") + +pulseaudio_dir = "//third_party/pulseaudio" +opensles_dir = "//third_party/openSLES" +opensles_version = "1.0.1" +module_output_path = "acts/ActsOpenslesNdkTest" +AUDIO_ROOT_DIR = "//foundation/multimedia/audio_framework/" +ohos_moduletest_suite("ActsOpenslesNdkTest") { + module_out_path = module_output_path + sources = [ + "openslesPlayerNdk/ActsOpenslesPlayerNdkTest.cpp", + "openslesRecorderNdk/ActsOpenslesRecoderNdkTest.cpp", + ] + + include_dirs = [ + "opensles/include", + "$opensles_dir/api/$opensles_version", + "$pulseaudio_dir/src", + "$pulseaudio_dir/confgure/src", + "$AUDIO_ROOT_DIR/frameworks/native/opensles", + "$AUDIO_ROOT_DIR/interfaces/inner_api/native/audiocommon/include", + "//third_party/openSLES/api/1.0.1", + ] + + cflags = [ + "-Werror", + "-fno-rtti", + "-fno-exceptions", + "-Wall", + "-fno-common", + "-fstack-protector-strong", + "-Wshadow", + "-FPIC", + "-FS", + "-O2", + "-D_FORTIFY_SOURCE=2", + "-fvisibility=hidden", + "-Wformat=2", + "-Wdate-time", + "", + ] + + deps = [ + "$AUDIO_ROOT_DIR/frameworks/native/opensles", + "//third_party/openSLES:libSLES", + ] + external_deps = [ + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + ] + + part_name = "multimedia_audio_framework" + subsystem_name = "multimedia" +} diff --git a/multimedia/audio/audio_cpp_standard/Test.json b/multimedia/audio/audio_cpp_standard/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..eb6e619c9ba490188b495741c425821cb9478f38 --- /dev/null +++ b/multimedia/audio/audio_cpp_standard/Test.json @@ -0,0 +1,34 @@ +{ + "description": "Config for opensles ndk test cases", + "driver": { + "module-name": "ActsOpenslesNdkTest", + "native-test-timeout": "300000", + "native-test-device-path": "/data/local/tmp", + "runtime-hint": "1s", + "type": "CppTest" + }, + "kits": [ + { + "type": "PushKit", + "pre-push" : [ + "mount -o rw,remount /", + "rm /data/media/*", + "mkdir -p /data/media/", + "mkdir -p /data/local/tmp/" + ], + "push": [ + "ActsOpenslesNdkTest->/data/local/tmp/ActsOpenslesNdkTest", + "./resource/audio/audioDecode/AAC_48000_32_1.aac ->/data/media/" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "hilog -Q pidoff", + "chmod 777 -R /data/local/tmp", + "chmod 777 -R /data/media", + "chmod 777 /data/media/*" + ] + } + ] +} \ No newline at end of file diff --git a/multimedia/audio/audio_cpp_standard/openslesPlayerNdk/ActsOpenslesPlayerNdkTest.cpp b/multimedia/audio/audio_cpp_standard/openslesPlayerNdk/ActsOpenslesPlayerNdkTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..06bc551c5b919dee0310cda0e514c9e85b4f14c4 --- /dev/null +++ b/multimedia/audio/audio_cpp_standard/openslesPlayerNdk/ActsOpenslesPlayerNdkTest.cpp @@ -0,0 +1,495 @@ +/* + * Copyright (c) 2023 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. + */ + +#include "audio_log.h" +#include "audio_info.h" +#include +#include +#include +#include "gtest/gtest.h" + +using namespace std; +using namespace testing::ext; +namespace { +class ActsOpenslesPlayerNdkTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +struct WAV_HEADER { + /* RIFF Chunk Descriptor */ + uint8_t RIFF[4] = {'R', 'I', 'F', 'F'}; // RIFF Header Magic header + uint32_t ChunkSize = 0; // RIFF Chunk Size + uint8_t WAVE[4] = {'W', 'A', 'V', 'E'}; // WAVE Header + /* "fmt" sub-chunk */ + uint8_t fmt[4] = {'f', 'm', 't', ' '}; // FMT header + uint32_t Subchunk1Size = 16; // Size of the fmt chunk + uint16_t AudioFormat = 1; // Audio format 1=PCM + uint16_t NumOfChan = 2; // Number of channels 1=Mono 2=Stereo + uint32_t SamplesPerSec = 44100; // Sampling Frequency in Hz + uint32_t bytesPerSec = 176400; // bytes per second + uint16_t blockAlign = 2; // 2=16-bit mono, 4=16-bit stereo + uint16_t bitsPerSample = 16; // Number of bits per sample + /* "data" sub-chunk */ + uint8_t Subchunk2ID[4] = {'d', 'a', 't', 'a'}; // "data" string + uint32_t Subchunk2Size = 0; // Sampled data length +}; + +using wav_hdr = struct WAV_HEADER; + +void ActsOpenslesPlayerNdkTest::SetUpTestCase() {} +void ActsOpenslesPlayerNdkTest::TearDownTestCase() {} +void ActsOpenslesPlayerNdkTest::SetUp() {} +void ActsOpenslesPlayerNdkTest::TearDown() {} + +static void BuqqerQueueCallback(SLOHBufferQueueItf sBufferQueueItf, void *pContext, SLuint32 size); + +static SLuint32 PlayerStart(SLPlayItf sPlayItf, SLOHBufferQueueItf sBufferQueueItf, FILE *wavFile); + +static SLuint32 PlayerStop(SLPlayItf sPlayItf, SLOHBufferQueueItf sBufferQueueItf); + +static SLresult OpenSlTest(); + +static SLresult OpenSlTestConcurrent(); + +const SLuint32 number = 3; +const char* READPATH1 = "/data/audio/S16LE_2_44100.pcm"; +const char* READPATH2 = "/data/audio/S16LE_2_64000.pcm"; +FILE *wavFile_ = nullptr; +FILE *wavFile1_ = nullptr; +FILE *wavFile2_ = nullptr; +wav_hdr wavHeader_; +wav_hdr wavHeader1_; +wav_hdr wavHeader2_; +SLObjectItf engineObject = nullptr; +SLObjectItf outputMixObject = nullptr; +SLPlayItf playItf; +SLPlayItf playItf1; +SLPlayItf playItf2; +SLVolumeItf volumeItf1; +SLVolumeItf volumeItf2; +SLOHBufferQueueItf bufferQueueItf; +SLOHBufferQueueItf bufferQueueItf1; +SLOHBufferQueueItf bufferQueueItf2; +SLObjectItf pcmPlayerObject = nullptr; +SLObjectItf pcmPlayerObject1 = nullptr; +SLObjectItf pcmPlayerObject2 = nullptr; + +static SLresult OpenSlTest() +{ + AUDIO_INFO_LOG("OpenSlTest enter"); + engineObject = nullptr; + SLEngineItf engineEngine = nullptr; + SLresult result = slCreateEngine(&engineObject, 0, nullptr, 0, nullptr, nullptr); + // get engine object + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTest slCreateEngine result: %{public}lu", result); + return result; + } + result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTest Realize result: %{public}lu", result); + return result; + } + // get engineEngine object + result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTest get engineEngine result: %{public}lu", result); + return result; + } + outputMixObject = nullptr; + result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, nullptr, nullptr); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTest CreateOutputMix result: %{public}lu", result); + return result; + } + result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTest outPut Realize result: %{public}lu", result); + return result; + } + + SLDataLocator_OutputMix slOutputMix = {SL_DATALOCATOR_OUTPUTMIX, outputMixObject}; + SLDataSink slSink = {&slOutputMix, nullptr}; + SLDataLocator_BufferQueue slBufferQueue = { + SL_DATALOCATOR_BUFFERQUEUE, + 0 + }; + SLDataFormat_PCM pcmFormat = { + SL_DATAFORMAT_PCM, + wavHeader_.NumOfChan, + wavHeader_.SamplesPerSec * 1000, + wavHeader_.bitsPerSample, + 0, + 0, + 0 + }; + SLDataSource slSource = {&slBufferQueue, &pcmFormat}; + + result = (*engineEngine)->CreateAudioPlayer(engineEngine, &pcmPlayerObject, + &slSource, &slSink, number, nullptr, nullptr); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTest CreateAudioPlayer result: %{public}lu", result); + return result; + } + result = (*pcmPlayerObject)->Realize(pcmPlayerObject, SL_BOOLEAN_FALSE); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTest CreateAudioPlayer Realize result: %{public}lu", result); + return result; + } + // get bufferQueueItf object + result = (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_PLAY, &playItf); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTest get playItf result: %{public}lu", result); + return result; + } + SLVolumeItf volumeItf; + result = (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_VOLUME, &volumeItf); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTest get volumeItf result: %{public}lu", result); + return result; + } + SLmillibel pLevel = 0; + result = (*volumeItf)->GetVolumeLevel(volumeItf, &pLevel); + result = (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_OH_BUFFERQUEUE, &bufferQueueItf); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTest get bufferQueueItf result: %{public}lu", result); + return result; + } + result = (*bufferQueueItf)->RegisterCallback(bufferQueueItf, BuqqerQueueCallback, wavFile_); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTest RegisterCallback result: %{public}lu", result); + return result; + } + result = PlayerStart(playItf, bufferQueueItf, wavFile_); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTest PlayerStart result: %{public}lu", result); + return result; + } + AUDIO_INFO_LOG("OpenSlTest return result: %{public}lu", result); + return result; +} + +static SLresult OpenSlTestConcurrent() +{ + AUDIO_INFO_LOG("OpenSlTestConcurrent start"); + engineObject = nullptr; + SLEngineItf engineEngine = nullptr; + SLresult result = slCreateEngine(&engineObject, 0, nullptr, 0, nullptr, nullptr); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent slCreateEngine result: %{public}lu", result); + return result; + } + result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent Realize result: %{public}lu", result); + return result; + } + + result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent get engineEngine result: %{public}lu", result); + return result; + } + + outputMixObject = nullptr; + result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, nullptr, nullptr); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent CreateOutputMix result: %{public}lu", result); + return result; + } + result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent outPut Realize result: %{public}lu", result); + return result; + } + + SLDataLocator_OutputMix slOutputMix = {SL_DATALOCATOR_OUTPUTMIX, outputMixObject}; + SLDataSink slSink = {&slOutputMix, nullptr}; + SLDataLocator_BufferQueue slBufferQueue = { + SL_DATALOCATOR_BUFFERQUEUE, + 0 + }; + SLDataFormat_PCM pcmFormat1 = { + SL_DATAFORMAT_PCM, + wavHeader1_.NumOfChan, + wavHeader1_.SamplesPerSec * 1000, + wavHeader1_.bitsPerSample, + 0, + 0, + 0 + }; + SLDataFormat_PCM pcmFormat2 = { + SL_DATAFORMAT_PCM, + wavHeader2_.NumOfChan, + wavHeader2_.SamplesPerSec * 1000, + wavHeader2_.bitsPerSample, + 0, + 0, + 0 + }; + SLDataSource slSource1 = {&slBufferQueue, &pcmFormat1}; + SLDataSource slSource2 = {&slBufferQueue, &pcmFormat2}; + + result = (*engineEngine)->CreateAudioPlayer(engineEngine, &pcmPlayerObject1, &slSource1, + &slSink, number, nullptr, nullptr); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent CreateAudioPlayer pcmPlayerObject1 Realize result: %{public}lu", result); + return result; + } + result = (*pcmPlayerObject1)->Realize(pcmPlayerObject1, SL_BOOLEAN_FALSE); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent outPut Realize pcmPlayerObject1 result: %{public}lu", result); + return result; + } + + result = (*engineEngine)->CreateAudioPlayer(engineEngine, &pcmPlayerObject2, &slSource2, &slSink, + number, nullptr, nullptr); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent CreateAudioPlayer pcmPlayerObject2 result: %{public}lu", result); + return result; + } + result = (*pcmPlayerObject2)->Realize(pcmPlayerObject2, SL_BOOLEAN_FALSE); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent Realize pcmPlayerObject2 result: %{public}lu", result); + return result; + } + + result = (*pcmPlayerObject1)->GetInterface(pcmPlayerObject1, SL_IID_PLAY, &playItf1); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent playItf1 result: %{public}lu", result); + return result; + } + result = (*pcmPlayerObject2)->GetInterface(pcmPlayerObject2, SL_IID_PLAY, &playItf2); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent playItf2 result: %{public}lu", result); + return result; + } + result = (*pcmPlayerObject1)->GetInterface(pcmPlayerObject1, SL_IID_VOLUME, &volumeItf1); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent volumeItf1 result: %{public}lu", result); + return result; + } + + SLmillibel level1 = 0; + (*volumeItf1)->GetMaxVolumeLevel(volumeItf1, &level1); + SLmillibel temp = 2; // SetVolumeLevel level1 + level1 = (SLmillibel) (level1 / temp); + (*volumeItf1)->SetVolumeLevel(volumeItf1, level1); + (*pcmPlayerObject2)->GetInterface(pcmPlayerObject2, SL_IID_VOLUME, &volumeItf2); + SLmillibel level2 = 0; + (*volumeItf2)->GetMaxVolumeLevel(volumeItf2, &level2); + temp = 15; // SetVolumeLevel level2 + level2 = (SLmillibel) (level2 / temp); + (*volumeItf2)->SetVolumeLevel(volumeItf2, level2); + + result = (*pcmPlayerObject1)->GetInterface(pcmPlayerObject1, SL_IID_OH_BUFFERQUEUE, &bufferQueueItf1); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent bufferQueueItf1 result: %{public}lu", result); + return result; + } + result = (*pcmPlayerObject2)->GetInterface(pcmPlayerObject2, SL_IID_OH_BUFFERQUEUE, &bufferQueueItf2); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent bufferQueueItf2 result: %{public}lu", result); + return result; + } + result = (*bufferQueueItf1)->RegisterCallback(bufferQueueItf1, BuqqerQueueCallback, wavFile1_); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent RegisterCallback1 result: %{public}lu", result); + return result; + } + result = (*bufferQueueItf2)->RegisterCallback(bufferQueueItf2, BuqqerQueueCallback, wavFile2_); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent RegisterCallback2 result: %{public}lu", result); + return result; + } + result = PlayerStart(playItf1, bufferQueueItf1, wavFile1_); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent playItf1 PlayerStart result: %{public}lu", result); + return result; + } + result = PlayerStart(playItf2, bufferQueueItf2, wavFile2_); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSlTestConcurrent playItf2 PlayerStart result: %{public}lu", result); + return result; + } + AUDIO_INFO_LOG("OpenSlTestConcurrent return result: %{public}lu", result); + return result; +} + +static void BuqqerQueueCallback(SLOHBufferQueueItf sBufferQueueItf, void *pContext, SLuint32 size) +{ + FILE *wavFile = (FILE *)pContext; + if (!feof(wavFile)) { + SLuint8 *buffer = nullptr; + SLuint32 pSize = 0; + SLresult result = (*bufferQueueItf)->GetBuffer(sBufferQueueItf, &buffer, &pSize); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("BuqqerQueueCallback GetBuffer result: %{public}lu", result); + return ; + } + fread(buffer, 1, size, wavFile); + result = (*bufferQueueItf)->Enqueue(sBufferQueueItf, buffer, size); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("BuqqerQueueCallback Enqueue result: %{public}lu", result); + return ; + } + } + return ; +} + +static SLresult PlayerStart(SLPlayItf sPlayItf, SLOHBufferQueueItf sBufferQueueItf, FILE *wavFile) +{ + AUDIO_INFO_LOG("PlayerStart enter"); + SLresult result = (*playItf)->SetPlayState(sPlayItf, SL_PLAYSTATE_PLAYING); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("PlayerStart SetPlayState result: %{public}lu", result); + return result; + } + if (!feof(wavFile)) { + SLuint8* buffer = nullptr; + SLuint32 pSize = 0; + result = (*bufferQueueItf)->GetBuffer(sBufferQueueItf, &buffer, &pSize); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("PlayerStart GetBuffer result: %{public}lu", result); + return result; + } + fread(buffer, 1, pSize, wavFile); + result = (*bufferQueueItf)->Enqueue(sBufferQueueItf, buffer, pSize); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("PlayerStart Enqueue result: %{public}lu", result); + return result; + } + } + AUDIO_INFO_LOG("PlayerStart return result: %{public}lu", result); + return result; +} + +static SLresult PlayerStop(SLPlayItf sPlayItf, SLOHBufferQueueItf sBufferQueueItf) +{ + AUDIO_INFO_LOG("PlayerStop enetr"); + + SLresult result = (*playItf)->SetPlayState(sPlayItf, SL_PLAYSTATE_STOPPED); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("PlayerStop SetPlayState result: %{public}lu", result); + return result; + } + AUDIO_INFO_LOG("PlayerStop return result: %{public}lu", result); + return result; +} +} + +/** + * @tc.number : SUB_MULTIMEDIA_AUDIO_OPENSELES_PALYER_FUNCTION_0100 + * @tc.name : Pcm gemischte Wiedergabe + * @tc.desc : Basic function test + */ +HWTEST_F(ActsOpenslesPlayerNdkTest, SUB_MULTIMEDIA_AUDIO_OPENSELES_PALYER_FUNCTION_0100, TestSize.Level1) +{ + size_t headerSize = sizeof(wav_hdr); + char path[PATH_MAX + 1] = {0x00}; + if ((strlen(READPATH1) > PATH_MAX) || (realpath(READPATH1, path) == nullptr)) { + AUDIO_ERR_LOG("Invalid path"); + return ; + } + wavFile1_ = fopen(path, "rb"); + if (wavFile1_ == nullptr) { + AUDIO_INFO_LOG("AudioRendererTest: Unable to open wave file"); + return ; + } + fread(&wavHeader1_, 1, headerSize, wavFile1_); + + headerSize = sizeof(wav_hdr); + if ((strlen(READPATH2) > PATH_MAX) || (realpath(READPATH2, path) == nullptr)) { + AUDIO_ERR_LOG("Invalid path"); + return ; + } + wavFile2_ = fopen(path, "rb"); + if (wavFile2_ == nullptr) { + AUDIO_INFO_LOG("AudioRendererTest: Unable to open wave file"); + return ; + } + fread(&wavHeader2_, 1, headerSize, wavFile2_); + SLresult result = OpenSlTestConcurrent(); + ASSERT_EQ(SL_RESULT_SUCCESS, result); + while (!feof(wavFile1_) || !feof(wavFile2_)) { + sleep(1); + } + result = PlayerStop(playItf1, bufferQueueItf1); + ASSERT_EQ(SL_RESULT_SUCCESS, result); + + result = PlayerStop(playItf2, bufferQueueItf2); + ASSERT_EQ(SL_RESULT_SUCCESS, result); + (*pcmPlayerObject1)->Destroy(pcmPlayerObject1); + (*pcmPlayerObject2)->Destroy(pcmPlayerObject2); + (*engineObject)->Destroy(engineObject); + (*outputMixObject)->Destroy(outputMixObject); +} + +/** + * @tc.number : SUB_MULTIMEDIA_AUDIO_OPENSELES_PALYER_FUNCTION_0200 + * @tc.name : Pcm spielt weiter + * @tc.desc : Basic function test + */ +HWTEST_F(ActsOpenslesPlayerNdkTest, SUB_MULTIMEDIA_AUDIO_OPENSELES_PALYER_FUNCTION_0200, TestSize.Level1) +{ + size_t headerSize = sizeof(wav_hdr); + char path[PATH_MAX + 1] = {0x00}; + if ((strlen(READPATH1) > PATH_MAX) || (realpath(READPATH1, path) == nullptr)) { + AUDIO_ERR_LOG("Invalid path"); + return ; + } + wavFile_ = fopen(path, "rb"); + if (wavFile_ == nullptr) { + AUDIO_INFO_LOG("AudioRendererTest: Unable to open wave file"); + return ; + } + fread(&wavHeader_, 1, headerSize, wavFile_); + + SLresult result = OpenSlTest(); + ASSERT_EQ(SL_RESULT_SUCCESS, result); + + while (!feof(wavFile_)) { + sleep(1); + } + result = PlayerStop(playItf, bufferQueueItf); + ASSERT_EQ(SL_RESULT_SUCCESS, result); + (*pcmPlayerObject)->Destroy(pcmPlayerObject); + + char path2[PATH_MAX + 1] = {0x00}; + if ((strlen(READPATH2) > PATH_MAX) || (realpath(READPATH2, path2) == nullptr)) { + AUDIO_ERR_LOG("Invalid path"); + return ; + } + wavFile_ = fopen(path2, "rb"); + if (wavFile_ == nullptr) { + AUDIO_INFO_LOG("AudioRendererTest: Unable to open wave file"); + return ; + } + fread(&wavHeader_, 1, headerSize, wavFile_); + + result = OpenSlTest(); + ASSERT_EQ(SL_RESULT_SUCCESS, result); + + while (!feof(wavFile_)) { + sleep(1); + } + result = PlayerStop(playItf, bufferQueueItf); + ASSERT_EQ(SL_RESULT_SUCCESS, result); + (*pcmPlayerObject)->Destroy(pcmPlayerObject); +} \ No newline at end of file diff --git a/multimedia/audio/audio_cpp_standard/openslesRecorderNdk/ActsOpenslesRecoderNdkTest.cpp b/multimedia/audio/audio_cpp_standard/openslesRecorderNdk/ActsOpenslesRecoderNdkTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fa926966b140c464f8405d54a362466c880b5266 --- /dev/null +++ b/multimedia/audio/audio_cpp_standard/openslesRecorderNdk/ActsOpenslesRecoderNdkTest.cpp @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2023 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "audio_info.h" +#include "audio_log.h" +#include "gtest/gtest.h" + +using namespace std; +using namespace testing::ext; + +namespace { +class ActsOpenslesRecoderNdkTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void ActsOpenslesRecoderNdkTest::SetUpTestCase() {} +void ActsOpenslesRecoderNdkTest::TearDownTestCase() {} +void ActsOpenslesRecoderNdkTest::SetUp() {} +void ActsOpenslesRecoderNdkTest::TearDown() {} + +static void BufferQueueCallback(SLOHBufferQueueItf sBufferQueueItf, void *pContext, SLuint32 size); + +static SLresult CaptureStart(SLRecordItf sRecordItf, SLOHBufferQueueItf sBufferQueueItf, FILE *wavFile); + +static SLresult CapturePause(SLRecordItf sRecordItf); + +static SLresult CaptureStop(SLRecordItf sRecordItf); + +static SLresult OpenSLESCaptureTest(); + +FILE *wavFile_ = nullptr; +SLObjectItf engineObject = nullptr; +SLRecordItf recordItf; +SLOHBufferQueueItf bufferQueueItf; +SLObjectItf pcmCapturerObject = nullptr; + +static SLresult OpenSLESCaptureTest() +{ + AUDIO_INFO_LOG("Enter OpenSLESCaptureTest"); + engineObject = nullptr; + SLEngineItf engineItf = nullptr; + + SLresult result = slCreateEngine(&engineObject, 0, nullptr, 0, nullptr, nullptr); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSLESCaptureTest slCreateEngine result: %{public}lu", result); + return result; + } + result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSLESCaptureTest Realize result: %{public}lu", result); + return result; + } + result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineItf); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSLESCaptureTest get engineItf result: %{public}lu", result); + return result; + } + + SLDataLocator_IODevice io_device = { + SL_DATALOCATOR_IODEVICE, + SL_IODEVICE_AUDIOINPUT, + SL_DEFAULTDEVICEID_AUDIOINPUT, + NULL + }; + + SLDataSource audioSource = { + &io_device, + NULL + }; + + SLDataLocator_BufferQueue buffer_queue = { + SL_DATALOCATOR_BUFFERQUEUE, + 3 + }; + + SLDataFormat_PCM format_pcm = { + SL_DATAFORMAT_PCM, + OHOS::AudioStandard::AudioChannel::MONO, + OHOS::AudioStandard::AudioSamplingRate::SAMPLE_RATE_44100, + SL_PCMSAMPLEFORMAT_FIXED_16, + 0, + 0, + 0 + }; + SLDataSink audioSink = { + &buffer_queue, + &format_pcm + }; + + result = (*engineItf)->CreateAudioRecorder(engineItf, &pcmCapturerObject, + &audioSource, &audioSink, 0, nullptr, nullptr); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSLESCaptureTest CreateAudioRecorder result: %{public}lu", result); + return result; + } + result = (*pcmCapturerObject)->Realize(pcmCapturerObject, SL_BOOLEAN_FALSE); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSLESCaptureTest Realize result: %{public}lu", result); + return result; + } + result = (*pcmCapturerObject)->GetInterface(pcmCapturerObject, SL_IID_RECORD, &recordItf); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSLESCaptureTest get recordItf result: %{public}lu", result); + return result; + } + result = (*pcmCapturerObject)->GetInterface(pcmCapturerObject, SL_IID_OH_BUFFERQUEUE, &bufferQueueItf); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSLESCaptureTest get bufferQueueItf result: %{public}lu", result); + return result; + } + result = (*bufferQueueItf)->RegisterCallback(bufferQueueItf, BufferQueueCallback, wavFile_); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("OpenSLESCaptureTest RegisterCallback result: %{public}lu", result); + return result; + } + AUDIO_INFO_LOG("OpenSLESCaptureTest end"); + return result; +} + +static void BufferQueueCallback(SLOHBufferQueueItf sBufferQueueItf, void *pContext, SLuint32 size) +{ + AUDIO_INFO_LOG("Enter BufferQueueCallback"); + FILE *wavFile = (FILE *)pContext; + if (wavFile != nullptr) { + SLuint8 *buffer = nullptr; + SLuint32 pSize = 0; + SLresult result = (*bufferQueueItf)->GetBuffer(sBufferQueueItf, &buffer, &pSize); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("BufferQueueCallback GetBuffer result: %{public}lu", result); + return ; + } + if (buffer != nullptr) { + AUDIO_INFO_LOG("BufferQueueCallback, length, pSize:%{public}lu, size: %{public}lu.", + pSize, size); + fwrite(buffer, 1, pSize, wavFile); + result = (*bufferQueueItf)->Enqueue(sBufferQueueItf, buffer, size); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("BufferQueueCallback Enqueue result: %{public}lu", result); + return ; + } + } else { + AUDIO_INFO_LOG("BufferQueueCallback, buffer is null or pSize: %{public}lu, size: %{public}lu.", + pSize, size); + } + } + AUDIO_INFO_LOG("BufferQueueCallback end"); + return; +} + +static SLresult CaptureStart(SLRecordItf sRecordItf, SLOHBufferQueueItf sBufferQueueItf, FILE *wavFile) +{ + AUDIO_INFO_LOG("Enter CaptureStart"); + SLresult result = (*recordItf)->SetRecordState(sRecordItf, SL_RECORDSTATE_RECORDING); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("CaptureStart SetRecordState result: %{public}lu", result); + return result; + } + if (wavFile != nullptr) { + SLuint8* buffer = nullptr; + SLuint32 pSize = 0; + result = (*bufferQueueItf)->GetBuffer(sBufferQueueItf, &buffer, &pSize); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("CaptureStart GetBuffer result: %{public}lu", result); + return result; + } + if (buffer != nullptr) { + AUDIO_INFO_LOG("CaptureStart, enqueue buffer length: %{public}lu.", pSize); + fwrite(buffer, 1, pSize, wavFile); + result = (*bufferQueueItf)->Enqueue(sBufferQueueItf, buffer, pSize); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("CaptureStart Enqueue result: %{public}lu", result); + return result; + } + } else { + AUDIO_INFO_LOG("CaptureStart, buffer is null or pSize: %{public}lu.", pSize); + } + } + AUDIO_INFO_LOG("CaptureStart return result: %{public}lu", result); + return result; +} + +static SLresult CapturePause(SLRecordItf sRecordItf) +{ + AUDIO_INFO_LOG("Enter CapturePause"); + SLresult result = (*recordItf)->SetRecordState(sRecordItf, SL_RECORDSTATE_PAUSED); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("CapturePause SetRecordState result: %{public}lu", result); + return result; + } + AUDIO_INFO_LOG("CapturePause return result: %{public}lu", result); + return result; +} + +static SLresult CaptureStop(SLRecordItf sRecordItf) +{ + AUDIO_INFO_LOG("Enter CaptureStop"); + fflush(wavFile_); + SLresult result = (*recordItf)->SetRecordState(sRecordItf, SL_RECORDSTATE_STOPPED); + if (SL_RESULT_SUCCESS != result) { + AUDIO_INFO_LOG("CapturePause SetRecordState result: %{public}lu", result); + return result; + } + (*pcmCapturerObject)->Destroy(pcmCapturerObject); + fclose(wavFile_); + wavFile_ = nullptr; + AUDIO_INFO_LOG("CaptureStop return result: %{public}lu", result); + return result; +} +} + +/** + * @tc.number : SUB_MULTIMEDIA_AUDIO_OPENSELES_RECODER_FUNCTION_0100 + * @tc.name : stop at end of stream + * @tc.desc : Basic function test + */ +HWTEST_F(ActsOpenslesRecoderNdkTest, SUB_MULTIMEDIA_AUDIO_OPENSELES_RECODER_FUNCTION_0100, TestSize.Level1) +{ + string filePath = "/data/test.pcm"; + wavFile_ = fopen(filePath.c_str(), "wb"); + if (wavFile_ == nullptr) { + AUDIO_INFO_LOG("OpenSL ES capture: Unable to open file"); + return ; + } + SLresult result = OpenSLESCaptureTest(); + ASSERT_EQ(SL_RESULT_SUCCESS, result); + result = CaptureStart(recordItf, bufferQueueItf, wavFile_); + ASSERT_EQ(SL_RESULT_SUCCESS, result); + result = CapturePause(recordItf); + ASSERT_EQ(SL_RESULT_SUCCESS, result); + result = CaptureStop(recordItf); + ASSERT_EQ(SL_RESULT_SUCCESS, result); +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/Test.json b/multimedia/audio/audio_js_standard/AudioCapturer/Test.json index 57064b4d909257ba3a676c63f121b470096f4662..f17c906ad59e8502f0f4b010c0fcf400b69119db 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/Test.json +++ b/multimedia/audio/audio_js_standard/AudioCapturer/Test.json @@ -3,6 +3,7 @@ "driver": { "type": "OHJSUnitTest", "test-timeout": "1500000", + "testcase-timeout": "50000", "bundle-name": "ohos.acts.multimedia.audio.audiocapturer", "package-name": "ohos.acts.multimedia.audio.audiocapturer", "shell-timeout": "60000" diff --git a/multimedia/audio/audio_js_standard/audioInterruptRender/entry/src/main/config.json b/multimedia/audio/audio_js_standard/audioInterruptRender/entry/src/main/config.json index 698db8a4c4b79bd9296745620d5fa4922e078f25..2e75ae93a306cf8e60ec28f0f5b52fca5b756751 100644 --- a/multimedia/audio/audio_js_standard/audioInterruptRender/entry/src/main/config.json +++ b/multimedia/audio/audio_js_standard/audioInterruptRender/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 9 } }, diff --git a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/config.json b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/config.json index 3f2518f3ea3aa67a80b36aaf8cb0bd105b3f31eb..ef3c10156dd5769b37c71abc29ae139f1db600d3 100644 --- a/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/config.json +++ b/multimedia/image/image_js_standard/imagePixelMapNDK/entry/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "releaseType": "Release", "target": 9 } diff --git a/multimedia/media/media_js_standard/MediaTestBase.js b/multimedia/media/media_js_standard/MediaTestBase.js index 0d2cf22d0dfd8239eae96a3549e6ac9992d79d5b..b3e21d99848db343a64d2779acafbbf0fd3953df 100644 --- a/multimedia/media/media_js_standard/MediaTestBase.js +++ b/multimedia/media/media_js_standard/MediaTestBase.js @@ -20,7 +20,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary' import fileio from '@ohos.fileio' import featureAbility from '@ohos.ability.featureAbility' import { UiDriver, BY, PointerMatrix } from '@ohos.uitest' - +const CODECMIMEVALUE = ['video/avc', 'audio/mp4a-latm', 'audio/mpeg'] const context = featureAbility.getContext(); export async function getPermission(permissionNames) { @@ -58,7 +58,17 @@ export async function getFileDescriptor(fileName) { }); return fileDescriptor; } - +export async function getStageFileDescriptor(fileName) { + let fileDescriptor = undefined; + let mgr = globalThis.abilityContext.resourceManager + await mgr.getRawFileDescriptor(fileName).then(value => { + fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length}; + console.log('case getRawFileDescriptor success fileName: ' + fileName); + }).catch(error => { + console.log('case getRawFileDescriptor err: ' + error); + }); + return fileDescriptor; +} export async function closeFileDescriptor(fileName) { await resourceManager.getResourceManager().then(async (mgr) => { await mgr.closeRawFileDescriptor(fileName).then(()=> { @@ -145,6 +155,16 @@ export function checkDescription(actualDescription, descriptionKey, descriptionV } } +export function checkOldDescription(actualDescription, descriptionKey, descriptionValue) { + for (let i = 0; i < descriptionKey.length; i++) { + let property = actualDescription[descriptionKey[i]]; + console.info('case key is '+ descriptionKey[i]); + console.info('case actual value is '+ property); + console.info('case hope value is '+ descriptionValue[i]); + expect(property).assertEqual(descriptionValue[i]); + } +} + export function printDescription(obj) { let description = ""; for(let i in obj) { diff --git a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js index d4269db05b96e9f6b3535119c02018fe5a8c55ce..b9e6de7b0dcc00efeb83c9491fa8d6b02480b67b 100644 --- a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js +++ b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js @@ -157,7 +157,7 @@ describe('PlayerLocalTestAudioFUNC', function () { console.info('case getTrackDescription called!!'); if (typeof (arrayList) != 'undefined') { for (let i = 0; i < arrayList.length; i++) { - mediaTestBase.checkDescription(arrayList[i], descriptionKey[i], descriptionValue[i]); + mediaTestBase.checkOldDescription(arrayList[i], descriptionKey[i], descriptionValue[i]); } } else { console.info('case getTrackDescription is failed'); @@ -171,7 +171,7 @@ describe('PlayerLocalTestAudioFUNC', function () { audioPlayer.getTrackDescription((err, arrayList) => { if (typeof (err) == 'undefined') { for (let i = 0; i < arrayList.length; i++) { - mediaTestBase.checkDescription(arrayList[i], descriptionKey[i], descriptionValue[i]); + mediaTestBase.checkOldDescription(arrayList[i], descriptionKey[i], descriptionValue[i]); } nextStep(mySteps, done); } else { diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/MainAbility/pages/index/index.ets b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/MainAbility/pages/index/index.ets index 2da1ed7b463f8c46284582fe3a36c2af94b3d5a3..4ac93347da054844963bd54fc81ac249164d183d 100644 --- a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/MainAbility/pages/index/index.ets +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -12,11 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import file from '@system.file'; -import { Core, ExpectExtend, InstrumentLog, ReportExtend } from "deccjsunit/index" +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' import testsuite from "../../../test/List.test.ets" -import featureAbility from "@ohos.ability.featureAbility" -import { UiDriver, BY } from '@ohos.uitest' var mXComponentController: XComponentController = new XComponentController() var surfaceId: any @@ -26,7 +24,7 @@ var surfaceId: any struct Index { aboutToAppear() { console.info("start run testcase!!!!"); -} + } build() { Flex() { XComponent({ @@ -41,23 +39,10 @@ struct Index { surfaceId = mXComponentController.getXComponentSurfaceId() globalThis.value = surfaceId console.info('CameraModuleTest: XComponent onLoad surfaceId: ' + globalThis.value) - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite() - core.execute() - console.info('core.execute()---->') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) }) .width('1920px') .height('1080px') diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHlsFuncTest.test.js b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHlsFuncTest.test.js index 843c07d09a8a4fac42c199c93045ec76e7941c83..ca6cb1b7ccbbc94fdc5a9521cc6c0a4b592e0f8f 100644 --- a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHlsFuncTest.test.js +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHlsFuncTest.test.js @@ -15,7 +15,7 @@ import media from '@ohos.multimedia.media' import * as mediaTestBase from '../../../../../../MediaTestBase'; import * as AVPlayerTestBase from '../../../../../../AVPlayerTestBase.js'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; export default function AVPlayerHlsFuncTest() { describe('AVPlayerHlsFuncTest', function () { diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpCompatibilityTest.test.ets b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpCompatibilityTest.test.ets index a21579719628499480eaa2c7ca82698c21e25959..65d3b573c6766d94cae3a8cdbc174b33ef94f4ee 100644 --- a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpCompatibilityTest.test.ets +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpCompatibilityTest.test.ets @@ -15,7 +15,7 @@ import {testAVPlayerFun} from '../../../../../../AVPlayerTestBase.js'; import * as mediaTestBase from '../../../../../../MediaTestBase'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; export default function AVPlayerHttpCompatibilityTest() { describe('AVPlayerHttpCompatibilityTest', function () { diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpSeekTest.test.ets b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpSeekTest.test.ets index 4ef610c57900c654e32a40cdc1a32c27f15f7678..6dbf9008a08db781c8083597d6247bc7c45c3c79 100644 --- a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpSeekTest.test.ets +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerHttpSeekTest.test.ets @@ -15,7 +15,7 @@ import {testAVPlayerSeek} from '../../../../../../AVPlayerTestBase.js'; import * as mediaTestBase from '../../../../../../MediaTestBase'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; export default function AVPlayerHttpSeekTest() { describe('AVPlayerHttpSeekTest', function () { diff --git a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerLocalTest.test.js b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerLocalTest.test.js index 6c241633c9ae26907040013d60c73c85d7c0ea0e..8ec9d5634e9a81d5665da1af4f833667c8a773cb 100644 --- a/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerLocalTest.test.js +++ b/multimedia/media/media_js_standard/avPlayer/entry/src/main/ets/test/AVPlayerLocalTest.test.js @@ -17,7 +17,7 @@ import * as mediaTestBase from '../../../../../../MediaTestBase'; import media from '@ohos.multimedia.media' import audio from '@ohos.multimedia.audio'; import { testAVPlayerFun, AV_PLAYER_STATE, setSource } from '../../../../../../AVPlayerTestBase.js'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; export default function AVPlayerLocalTest() { describe('AVPlayerLocalTest', function () { @@ -40,13 +40,13 @@ export default function AVPlayerLocalTest() { beforeAll(async function() { console.info('beforeAll case'); - await mediaTestBase.getFileDescriptor(VIDEO_SOURCE).then((res) => { + await mediaTestBase.getStageFileDescriptor(VIDEO_SOURCE).then((res) => { fileDescriptor = res; }); - await mediaTestBase.getFileDescriptor(AUDIO_SOURCE).then((res) => { + await mediaTestBase.getStageFileDescriptor(AUDIO_SOURCE).then((res) => { fileDescriptor2 = res; }); - await mediaTestBase.getFileDescriptor(VIDEO_NOAUDIO).then((res) => { + await mediaTestBase.getStageFileDescriptor(VIDEO_NOAUDIO).then((res) => { fileDescriptor3 = res; }); }) diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js index 99eaba12e88df2ad2c35e234198a8593ae5e7d1a..6aa39c4679da8ced8b669e0ee3e024fcf2888edb 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js @@ -47,7 +47,7 @@ describe('VideoPlayerAPICallbackTest', function () { const SPEED_VALUE = 1; const NEXT_FRAME_TIME = 8333; const PREV_FRAME_TIME = 4166; - const DELTA_TIME = 100; + const DELTA_TIME = 300; let surfaceID = ''; let fileDescriptor = null; const pagePath1 = 'pages/surfaceTest/surfaceTest'; diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js index 3cb42707e805861adab57c0f2c477089f6e7cbc9..3e60d2a52148139bceaa2f7d5c45a68e265ca294 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js @@ -21,6 +21,7 @@ export default function VideoPlayerFuncCallbackTest() { describe('VideoPlayerFuncCallbackTest', function () { const VIDEO_SOURCE = 'H264_AAC.mp4'; const PLAY_TIME = 3000; + const PLAY_TIME_1S = 1000; const SEEK_TIME = 5000; const WIDTH_VALUE = 720; const HEIGHT_VALUE = 480; @@ -48,7 +49,7 @@ describe('VideoPlayerFuncCallbackTest', function () { const DELTA_TIME = 1000; const NEXT_FRAME_TIME = 8333; const PREV_FRAME_TIME = 4166; - const DELTA_SEEK_TIME = 100; + const DELTA_SEEK_TIME = 300; let surfaceID = ''; let fdHead = 'fd://'; let fileDescriptor = null; @@ -74,7 +75,7 @@ describe('VideoPlayerFuncCallbackTest', function () { beforeEach(async function() { await mediaTestBase.toNewPage(pagePath1, pagePath2, pageId); pageId = (pageId + 1) % 2; - await mediaTestBase.msleepAsync(1000).then( + await mediaTestBase.msleepAsync(PLAY_TIME_1S).then( () => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); surfaceID = globalThis.value; console.info('case new surfaceID is ' + surfaceID); @@ -243,7 +244,7 @@ describe('VideoPlayerFuncCallbackTest', function () { videoPlayer.getTrackDescription((err, arrlist) => { if (err == null) { for (let i = 0; i < arrlist.length; i++) { - mediaTestBase.checkDescription(arrlist[i], descriptionKey[i], descriptionValue[i]); + mediaTestBase.checkOldDescription(arrlist[i], descriptionKey[i], descriptionValue[i]); } toNextStep(videoPlayer, steps, done); } else if ((err != null) && (steps[0] == ERROR_EVENT)) { @@ -429,19 +430,19 @@ describe('VideoPlayerFuncCallbackTest', function () { if (videoPlayer.state == 'playing') { switch (speedValue) { case media.PlaybackSpeed.SPEED_FORWARD_0_75_X: - expect(Math.abs(endTime - startTime - (0.75 * 1000))).assertLess(DELTA_TIME * 0.75); + expect(Math.abs(endTime - startTime - (0.75 * PLAY_TIME_1S))).assertLess(DELTA_TIME * 0.75); break; case media.PlaybackSpeed.SPEED_FORWARD_1_00_X: - expect(Math.abs(endTime - startTime - (1000))).assertLess(DELTA_TIME); + expect(Math.abs(endTime - startTime - (PLAY_TIME_1S))).assertLess(DELTA_TIME); break; case media.PlaybackSpeed.SPEED_FORWARD_1_25_X: - expect(Math.abs(endTime - startTime - (1.25 * 1000))).assertLess(DELTA_TIME * 1.25); + expect(Math.abs(endTime - startTime - (1.25 * PLAY_TIME_1S))).assertLess(DELTA_TIME * 1.25); break; case media.PlaybackSpeed.SPEED_FORWARD_1_75_X: - expect(Math.abs(endTime - startTime - (1.75 * 1000))).assertLess(DELTA_TIME * 1.75); + expect(Math.abs(endTime - startTime - (1.75 * PLAY_TIME_1S))).assertLess(DELTA_TIME * 1.75); break; case media.PlaybackSpeed.SPEED_FORWARD_2_00_X: - expect(Math.abs(endTime - startTime - (2 * 1000))).assertLess(DELTA_TIME * 2); + expect(Math.abs(endTime - startTime - (2 * PLAY_TIME_1S))).assertLess(DELTA_TIME * 2); break; } } else { @@ -456,7 +457,7 @@ describe('VideoPlayerFuncCallbackTest', function () { let startTime = videoPlayer.currentTime; videoPlayer.setSpeed(speedValue, (err, speedMode) => { if (err == null) { - mediaTestBase.msleep(1000); + mediaTestBase.msleep(PLAY_TIME_1S); expect(speedValue).assertEqual(speedMode); console.info('case setSpeed success and speedMode is '+ speedMode); checkSpeedTime(videoPlayer, speedValue, startTime); diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js index 0f627552deefc9c571a21aeef18c800d32b072a3..2173b80017d531ebbabce0824902d28dfa696f8a 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js @@ -23,6 +23,7 @@ describe('VideoPlayerFuncPromiseTest', function () { const VIDEO_SOURCE = 'H264_AAC.mp4'; const AUDIO_SOURCE = '01.mp3'; const PLAY_TIME = 2000; + const PLAY_TIME_1S = 1000; const SEEK_TIME = 5000; const WIDTH_VALUE = 720; const HEIGHT_VALUE = 480; @@ -30,7 +31,7 @@ describe('VideoPlayerFuncPromiseTest', function () { const DELTA_TIME = 1500; const NEXT_FRAME_TIME = 8333; const PREV_FRAME_TIME = 4166; - const DELTA_SEEK_TIME = 100; + const DELTA_SEEK_TIME = 300; let surfaceID = ''; let fdHead = 'fd://'; let fileDescriptor = null; @@ -54,7 +55,7 @@ describe('VideoPlayerFuncPromiseTest', function () { beforeEach(async function() { await mediaTestBase.toNewPage(pagePath1, pagePath2, pageId); pageId = (pageId + 1) % 2; - await mediaTestBase.msleepAsync(1000).then( + await mediaTestBase.msleepAsync(PLAY_TIME_1S).then( () => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); surfaceID = globalThis.value; console.info('case new surfaceID is ' + surfaceID); @@ -89,23 +90,23 @@ describe('VideoPlayerFuncPromiseTest', function () { switch (speedValue) { case media.PlaybackSpeed.SPEED_FORWARD_0_75_X: console.error('checkSpeedTime time is :' + (newTime - startTime)); - expect(Math.abs(newTime - startTime - (0.75 * 1000))).assertLess(DELTA_TIME * 0.75); + expect(Math.abs(newTime - startTime - (0.75 * PLAY_TIME_1S))).assertLess(DELTA_TIME * 0.75); break; case media.PlaybackSpeed.SPEED_FORWARD_1_00_X: console.error('checkSpeedTime time is :' + (newTime - startTime)); - expect(Math.abs(newTime - startTime - (1000))).assertLess(DELTA_TIME); + expect(Math.abs(newTime - startTime - (PLAY_TIME_1S))).assertLess(DELTA_TIME); break; case media.PlaybackSpeed.SPEED_FORWARD_1_25_X: console.error('checkSpeedTime time is :' + (newTime - startTime)); - expect(Math.abs(newTime - startTime - (1.25 * 1000))).assertLess(DELTA_TIME * 1.25); + expect(Math.abs(newTime - startTime - (1.25 * PLAY_TIME_1S))).assertLess(DELTA_TIME * 1.25); break; case media.PlaybackSpeed.SPEED_FORWARD_1_75_X: console.error('checkSpeedTime time is :' + (newTime - startTime)); - expect(Math.abs(newTime - startTime - (1.75 * 1000))).assertLess(DELTA_TIME * 1.75); + expect(Math.abs(newTime - startTime - (1.75 * PLAY_TIME_1S))).assertLess(DELTA_TIME * 1.75); break; case media.PlaybackSpeed.SPEED_FORWARD_2_00_X: console.error('checkSpeedTime time is :' + (newTime - startTime)); - expect(Math.abs(newTime - startTime - (2 * 1000))).assertLess(DELTA_TIME * 2); + expect(Math.abs(newTime - startTime - (2 * PLAY_TIME_1S))).assertLess(DELTA_TIME * 2); break; } } else { @@ -240,17 +241,17 @@ describe('VideoPlayerFuncPromiseTest', function () { let startTime = videoPlayer.currentTime; await videoPlayer.play().then(() => { console.info('case play called!!'); - mediaTestBase.msleep(1000); + mediaTestBase.msleep(PLAY_TIME_1S); expect(videoPlayer.state).assertEqual('playing'); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); let endTime = videoPlayer.currentTime; - expect(Math.abs(endTime - startTime - PLAY_TIME)).assertLess(DELTA_TIME); + expect(Math.abs(endTime - startTime - PLAY_TIME_1S)).assertLess(DELTA_TIME); startTime = videoPlayer.currentTime; await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_0_75_X).then((speedMode) => { expect(videoPlayer.state).assertEqual('playing'); expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_0_75_X); - mediaTestBase.msleep(1000); + mediaTestBase.msleep(PLAY_TIME_1S); checkSpeedTime(videoPlayer, media.PlaybackSpeed.SPEED_FORWARD_0_75_X, startTime); console.info('case setSpeed called and speedMode is ' + speedMode); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); @@ -259,7 +260,7 @@ describe('VideoPlayerFuncPromiseTest', function () { await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_00_X).then((speedMode) => { expect(videoPlayer.state).assertEqual('playing'); expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_1_00_X); - mediaTestBase.msleep(1000); + mediaTestBase.msleep(PLAY_TIME_1S); checkSpeedTime(videoPlayer, media.PlaybackSpeed.SPEED_FORWARD_1_00_X, startTime); console.info('case setSpeed called and speedMode is ' + speedMode); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); @@ -268,7 +269,7 @@ describe('VideoPlayerFuncPromiseTest', function () { await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_25_X).then((speedMode) => { expect(videoPlayer.state).assertEqual('playing'); expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_1_25_X); - mediaTestBase.msleep(1000); + mediaTestBase.msleep(PLAY_TIME_1S); checkSpeedTime(videoPlayer, media.PlaybackSpeed.SPEED_FORWARD_1_25_X, startTime); console.info('case setSpeed called and speedMode is ' + speedMode); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); @@ -277,7 +278,7 @@ describe('VideoPlayerFuncPromiseTest', function () { await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_75_X).then((speedMode) => { expect(videoPlayer.state).assertEqual('playing'); expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_1_75_X); - mediaTestBase.msleep(1000); + mediaTestBase.msleep(PLAY_TIME_1S); checkSpeedTime(videoPlayer, media.PlaybackSpeed.SPEED_FORWARD_1_75_X, startTime); console.info('case setSpeed called and speedMode is ' + speedMode); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); @@ -286,7 +287,7 @@ describe('VideoPlayerFuncPromiseTest', function () { await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_2_00_X).then((speedMode) => { expect(videoPlayer.state).assertEqual('playing'); expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_2_00_X); - mediaTestBase.msleep(1000); + mediaTestBase.msleep(PLAY_TIME_1S); checkSpeedTime(videoPlayer, media.PlaybackSpeed.SPEED_FORWARD_2_00_X, startTime); console.info('case setSpeed called and speedMode is ' + speedMode); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); @@ -516,7 +517,7 @@ describe('VideoPlayerFuncPromiseTest', function () { }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); for (let i = 0; i < arrayDescription.length; i++) { - mediaTestBase.checkDescription(arrayDescription[i], descriptionKey[i], descriptionValue[i]); + mediaTestBase.checkOldDescription(arrayDescription[i], descriptionKey[i], descriptionValue[i]); } await videoPlayer.release().then(() => { @@ -1112,11 +1113,11 @@ describe('VideoPlayerFuncPromiseTest', function () { await videoPlayer.play().then(() => { expect(videoPlayer.loop).assertEqual(true); console.info('case play called!!'); - mediaTestBase.msleep(1000); + mediaTestBase.msleep(PLAY_TIME_1S); expect(videoPlayer.state).assertEqual('playing'); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); let endTime = videoPlayer.currentTime; - checkTime(1000, (endTime - startTime), DELTA_TIME); + checkTime(PLAY_TIME_1S, (endTime - startTime), DELTA_TIME); expect(videoPlayer.loop).assertEqual(true); startTime = videoPlayer.currentTime; @@ -1194,11 +1195,11 @@ describe('VideoPlayerFuncPromiseTest', function () { await videoPlayer.play().then(() => { expect(videoPlayer.loop).assertEqual(true); console.info('case play called!!'); - mediaTestBase.msleep(1000); + mediaTestBase.msleep(PLAY_TIME_1S); expect(videoPlayer.state).assertEqual('playing'); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); let endTime = videoPlayer.currentTime; - checkTime(1000, (endTime - startTime), DELTA_TIME); + checkTime(PLAY_TIME_1S, (endTime - startTime), DELTA_TIME); expect(videoPlayer.loop).assertEqual(true); startTime = videoPlayer.currentTime; diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/module.json index 025062ffed12b44b32db7f5f35356c9040ed9c5c..ae85be81420cdc610470d412c6f8982d69240c80 100644 --- a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_album/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", diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/module.json index 025062ffed12b44b32db7f5f35356c9040ed9c5c..ae85be81420cdc610470d412c6f8982d69240c80 100644 --- a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_base/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", diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/module.json index 025062ffed12b44b32db7f5f35356c9040ed9c5c..ae85be81420cdc610470d412c6f8982d69240c80 100644 --- a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_favorite/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", diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/module.json index 025062ffed12b44b32db7f5f35356c9040ed9c5c..ae85be81420cdc610470d412c6f8982d69240c80 100644 --- a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_file/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", diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/module.json index 025062ffed12b44b32db7f5f35356c9040ed9c5c..ae85be81420cdc610470d412c6f8982d69240c80 100644 --- a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/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", diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/module.json index 025062ffed12b44b32db7f5f35356c9040ed9c5c..ae85be81420cdc610470d412c6f8982d69240c80 100644 --- a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_fileKey/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", diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/module.json index 025062ffed12b44b32db7f5f35356c9040ed9c5c..ae85be81420cdc610470d412c6f8982d69240c80 100644 --- a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_fileResult/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", diff --git a/multimedia/medialibrary/mediaLibrary_getExifNoLocation/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_getExifNoLocation/entry/src/main/module.json index f89c932e2fbbc8bb0928aeed336630c27113e1ff..bb3ed6d009d188486e4ef5ea9c11ed6df3563028 100644 --- a/multimedia/medialibrary/mediaLibrary_getExifNoLocation/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_getExifNoLocation/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", diff --git a/multimedia/medialibrary/mediaLibrary_getExiflocation/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_getExiflocation/entry/src/main/module.json index 3edbbf74edbb92acf113b6ed13f1edf80d0aa5b7..176efbcb94094c9431d05151bb0630d865e2c7c8 100644 --- a/multimedia/medialibrary/mediaLibrary_getExiflocation/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_getExiflocation/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", diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/module.json index 025062ffed12b44b32db7f5f35356c9040ed9c5c..ae85be81420cdc610470d412c6f8982d69240c80 100644 --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/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", diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/module.json index 025062ffed12b44b32db7f5f35356c9040ed9c5c..ae85be81420cdc610470d412c6f8982d69240c80 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/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", diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/module.json index 025062ffed12b44b32db7f5f35356c9040ed9c5c..ae85be81420cdc610470d412c6f8982d69240c80 100644 --- a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_trash/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", diff --git a/multimodalinput/input_js_standard/src/main/js/MainAbility/app.js b/multimodalinput/input_js_standard/src/main/js/MainAbility/app.js index 1f429acbb22073515107201fccb9dc1f5f8e9cc1..d5368753735f4d2af3adb65e44ae6d6f9db1d751 100644 --- a/multimodalinput/input_js_standard/src/main/js/MainAbility/app.js +++ b/multimodalinput/input_js_standard/src/main/js/MainAbility/app.js @@ -15,7 +15,7 @@ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import { Hypium } from '@ohos/hypium' -import testsuite from '../test/ListMultimodalinput.test' +import testsuite from '../test/List.test' export default { onCreate() { diff --git a/multimodalinput/input_js_standard/src/main/js/test/InputDevice.test.js b/multimodalinput/input_js_standard/src/main/js/test/InputDevice.test.js index dec8f6ec3baa6b05d5b6d9684de94ac99755a7fb..eff8ac2badf920065beed85017785641016c09bc 100644 --- a/multimodalinput/input_js_standard/src/main/js/test/InputDevice.test.js +++ b/multimodalinput/input_js_standard/src/main/js/test/InputDevice.test.js @@ -15,8 +15,8 @@ import inputDevice from '@ohos.multimodalInput.inputDevice'; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' -export default function MultimodalInput_Device_test() { - describe('MultimodalInput_Device_test', function () { +export default function InputDevice_test() { + describe('InputDevice_test', function () { const errCode = { COMMON_PARAMETER_CODE: 401 @@ -30,8 +30,8 @@ export default function MultimodalInput_Device_test() { } // 参数正确,返回一个数组 - it("InputDevice_getDeviceIds_test-01", 0, async function (done) { - console.info(`InputDevice_getDeviceIds_test-01 enter`); + it("InputDevice_getDeviceIds_test_01", 0, async function (done) { + console.info(`InputDevice_getDeviceIds_test_01 enter`); try { inputDevice.getDeviceIds((err, data) => { if (err) { @@ -39,53 +39,53 @@ export default function MultimodalInput_Device_test() { } else { expect(data).assertInstanceOf('Array'); } - console.info(`InputDevice_getDeviceIds_test-01 exit`); + console.info(`InputDevice_getDeviceIds_test_01 exit`); done(); }) } catch (error) { - console.info(`InputDevice_getDeviceIds_test-01 error`); + console.info(`InputDevice_getDeviceIds_test_01 error`); expect(false).assertTrue(); done(); } }) // 参数正确,判断一种或多种设备 - it("InputDevice_getDeviceIds_test-02", 0, async function (done) { - console.info(`InputDevice_getDeviceIds_test-02 enter`); + it("InputDevice_getDeviceIds_test_02", 0, async function (done) { + console.info(`InputDevice_getDeviceIds_test_02 enter`); try { inputDevice.getDeviceIds((err, data) => { - console.info(`InputDevice_getDeviceIds_test-02 err:${JSON.stringify(err)}`); - console.info(`InputDevice_getDeviceIds_test-02 data:${JSON.stringify(data)}`); + console.info(`InputDevice_getDeviceIds_test_02 err:${JSON.stringify(err)}`); + console.info(`InputDevice_getDeviceIds_test_02 data:${JSON.stringify(data)}`); if (err) { expect(false).assertTrue(); } else { expect(data.length > 0).assertTrue(); } - console.info(`InputDevice_getDeviceIds_test-02 exit`); + console.info(`InputDevice_getDeviceIds_test_02 exit`); done(); }) } catch (error) { - console.info(`InputDevice_getDeviceIds_test-02 error`); + console.info(`InputDevice_getDeviceIds_test_02 error`); expect(false).assertTrue(); done(); } }) // 参数类型错误 - it("InputDevice_getDeviceIds_test-03", 0, async function (done) { - console.info(`InputDevice_getDeviceIds_test-03 enter`); + it("InputDevice_getDeviceIds_test_03", 0, async function (done) { + console.info(`InputDevice_getDeviceIds_test_03 enter`); try { inputDevice.getDeviceIds(-1); } catch (error) { expect(error.message).assertEqual("GetDeviceIds: \"The first parameter type is wrong\""); } - console.info(`InputDevice_getDeviceIds_test-03 exit`); + console.info(`InputDevice_getDeviceIds_test_03 exit`); done(); }) // 参数数量错误 - it("InputDevice_getDeviceIds_test-04", 0, async function (done) { - console.info(`InputDevice_getDeviceIds_test-04 enter`); + it("InputDevice_getDeviceIds_test_04", 0, async function (done) { + console.info(`InputDevice_getDeviceIds_test_04 enter`); try { inputDevice.getDeviceIds(-1, (err, data) => { console.info(data); @@ -93,25 +93,25 @@ export default function MultimodalInput_Device_test() { } catch (error) { expect(error.message).assertEqual("GetDeviceIds: \"too many parameters\""); } - console.info(`InputDevice_getDeviceIds_test-04 exit`); + console.info(`InputDevice_getDeviceIds_test_04 exit`); done(); }) // 无效的设备id - it("InputDevice_getDevice_test-01", 0, async function (done) { - console.info(`InputDevice_getDevice_test-01 enter`); + it("InputDevice_getDevice_test_01", 0, async function (done) { + console.info(`InputDevice_getDevice_test_01 enter`); try { inputDevice.getDevice(-1, (err, data) => { if (err) { expect(false).assertTrue(); - console.info(`InputDevice_getDevice_test-01 ${JSON.stringify(err)}`); + console.info(`InputDevice_getDevice_test_01 ${JSON.stringify(err)}`); } else { expect(JSON.stringify(data) !== "{}").assertTrue(); } - console.info(`InputDevice_getDevice_test-01 exit`); + console.info(`InputDevice_getDevice_test_01 exit`); }) } catch (error) { - console.info(`InputDevice_getDevice_test-01 error`); + console.info(`InputDevice_getDevice_test_01 error`); expect(false).assertTrue(); } finally { done(); @@ -119,21 +119,21 @@ export default function MultimodalInput_Device_test() { }) // 参数正常,返回值正常 - it("InputDevice_getDevice_test-02", 0, async function (done) { - console.info(`InputDevice_getDevice_test-02 enter`); + it("InputDevice_getDevice_test_02", 0, async function (done) { + console.info(`InputDevice_getDevice_test_02 enter`); try { inputDevice.getDeviceIds(async (err, data) => { - console.info(`InputDevice_getDeviceIds_test-02 err:${JSON.stringify(err)}`); - console.info(`InputDevice_getDeviceIds_test-02 data:${JSON.stringify(data)}`); + console.info(`InputDevice_getDeviceIds_test_02 err:${JSON.stringify(err)}`); + console.info(`InputDevice_getDeviceIds_test_02 data:${JSON.stringify(data)}`); if (err) { expect(false).assertTrue(); } else { for (let i = 0; i < data.length; i++) { - console.info(`InputDevice_getDevice_test-02 for`); + console.info(`InputDevice_getDevice_test_02 for`); await getDevicePromise(data[i]) } function getDevicePromise(data) { - console.info(`InputDevice_getDevice_test-02 getDevicePromise`) + console.info(`InputDevice_getDevice_test_02 getDevicePromise`) return new Promise((resolve, reject) => { inputDevice.getDevice(data, (err, res) => { console.info(`getDevice:data =${JSON.stringify(data)}`); @@ -150,7 +150,7 @@ export default function MultimodalInput_Device_test() { expect(res.phys).assertInstanceOf('String'); expect(res.uniq).assertInstanceOf('String'); expect(res).assertInstanceOf('Object'); - console.info(`InputDevice_getDevice_test-02 getDevice expect res`); + console.info(`InputDevice_getDevice_test_02 getDevice expect res`); for (let j = 0; j < res.axisRanges.length; j++) { expect(res.axisRanges[j].source == 'keyboard' || res.axisRanges[j].source == 'mouse' || res.axisRanges[j].source == 'touchpad' || res.axisRanges[j].source == 'touchscreen' @@ -172,19 +172,19 @@ export default function MultimodalInput_Device_test() { }) } } - console.info(`InputDevice_getDevice_test-02 exit`); + console.info(`InputDevice_getDevice_test_02 exit`); done(); }); } catch (error) { - console.info(`InputDevice_getDevice_test-02 error`); + console.info(`InputDevice_getDevice_test_02 error`); expect(false).assertTrue(); done(); } }) // 参数正常,返回值正常 - it("InputDevice_supportKeys_test-01", 0, async function (done) { - console.info(`InputDevice_supportKeys_test-01 enter`); + it("InputDevice_supportKeys_test_01", 0, async function (done) { + console.info(`InputDevice_supportKeys_test_01 enter`); try { inputDevice.getDeviceIds((err, data) => { if (err) { @@ -196,19 +196,19 @@ export default function MultimodalInput_Device_test() { }); } } - console.info(`InputDevice_supportKeys_test-01 exit`); + console.info(`InputDevice_supportKeys_test_01 exit`); done(); }); } catch (error) { - console.info(`InputDevice_supportKeys_test-01 error`); + console.info(`InputDevice_supportKeys_test_01 error`); expect(false).assertTrue(); done(); } }) // 第二个参数异常 - it("InputDevice_supportKeys_test-02", 0, async function (done) { - console.info(`InputDevice_supportKeys_test-02 enter`); + it("InputDevice_supportKeys_test_02", 0, async function (done) { + console.info(`InputDevice_supportKeys_test_02 enter`); try { inputDevice.supportKeys(0, 2022, (err, res) => { console.info(res); @@ -216,13 +216,13 @@ export default function MultimodalInput_Device_test() { } catch (error) { expect(error.message).assertEqual("Parameter error. The type of keys must be array."); } - console.info(`InputDevice_supportKeys_test-02 exit`); + console.info(`InputDevice_supportKeys_test_02 exit`); done(); }) // 参数正常 - it("InputDevice_getKeyboardType_test-01", 0, async function (done) { - console.info(`InputDevice_getKeyboardType_test-01 enter`); + it("InputDevice_getKeyboardType_test_01", 0, async function (done) { + console.info(`InputDevice_getKeyboardType_test_01 enter`); try { inputDevice.getDeviceIds((err, data) => { if (err) { @@ -234,31 +234,31 @@ export default function MultimodalInput_Device_test() { }); } } - console.info(`InputDevice_getKeyboardType_test-01 exit`); + console.info(`InputDevice_getKeyboardType_test_01 exit`); done(); }); } catch (error) { - console.info(`InputDevice_getKeyboardType_test-01 error`); + console.info(`InputDevice_getKeyboardType_test_01 error`); expect(false).assertTrue(); done(); } }) //参数异常 - it("InputDevice_getKeyboardType_test-02", 0, async function (done) { - console.info(`InputDevice_getKeyboardType_test-02 enter`); + it("InputDevice_getKeyboardType_test_02", 0, async function (done) { + console.info(`InputDevice_getKeyboardType_test_02 enter`); try { inputDevice.getKeyboardType(-1); } catch (error) { expect(error.message).assertEqual("Invalid input device id"); } - console.info(`InputDevice_getKeyboardType_test-02 exit`); + console.info(`InputDevice_getKeyboardType_test_02 exit`); done(); }); // 参数正常 - it("InputDevice_getKeyboardType_test-03", 0, async function (done) { - console.info(`InputDevice_getKeyboardType_test-03 enter`); + it("InputDevice_getKeyboardType_test_03", 0, async function (done) { + console.info(`InputDevice_getKeyboardType_test_03 enter`); try { inputDevice.getDeviceIds((err, data) => { if (err) { @@ -268,16 +268,16 @@ export default function MultimodalInput_Device_test() { inputDevice.getKeyboardType(data[i]).then((res) => { expect(res).assertInstanceOf('Number'); }).catch((err) => { - console.info(`InputDevice_getKeyboardType_test-03 failed, err=${JSON.stringify(err)}`); + console.info(`InputDevice_getKeyboardType_test_03 failed, err=${JSON.stringify(err)}`); expect(false).assertTrue(); }); } } - console.info(`InputDevice_getKeyboardType_test-03 exit`); + console.info(`InputDevice_getKeyboardType_test_03 exit`); done(); }); } catch (error) { - console.info(`InputDevice_getKeyboardType_test-03 error`); + console.info(`InputDevice_getKeyboardType_test_03 error`); expect(false).assertTrue(); done(); } @@ -461,7 +461,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_GetDeviceList_test * @tc.desc inputdevice interface getDeviceList test */ - it("InputDevice_getDeviceList_test-01", 0, async function (done) { + it("InputDevice_getDeviceList_test_01", 0, async function (done) { console.info(`InputDevice_getDeviceList_async_test enter`); try { inputDevice.getDeviceList((err, data) => { @@ -485,7 +485,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_GetDeviceList_test * @tc.desc inputdevice interface getDeviceList test */ - it("InputDevice_getDeviceList_test-02", 0, async function (done) { + it("InputDevice_getDeviceList_test_02", 0, async function (done) { console.info(`InputDevice_getDeviceList_promise_test enter`); try { inputDevice.getDeviceList().then(data => { @@ -505,7 +505,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_GetDeviceInfo_test * @tc.desc inputdevice interface getDeviceInfo test */ - it("InputDevice_getDeviceInfo_test-01", 0, async function (done) { + it("InputDevice_getDeviceInfo_test_01", 0, async function (done) { console.info(`InputDevice_getDeviceInfo_async_test enter`); try { await inputDevice.getDeviceList().then((data) => { @@ -557,12 +557,12 @@ export default function MultimodalInput_Device_test() { done() }) } catch (err) { - console.info(`InputDevice_getDeviceInfo_test-01 inputDevice.getDeviceInfo ${JSON.stringify(err)}`); + console.info(`InputDevice_getDeviceInfo_test_01 inputDevice.getDeviceInfo ${JSON.stringify(err)}`); expect(false).assertTrue(); } }) } catch (err) { - console.info(`InputDevice_getDeviceInfo_test-01 inputDevice.getDeviceList ${JSON.stringify(err)}`); + console.info(`InputDevice_getDeviceInfo_test_01 inputDevice.getDeviceList ${JSON.stringify(err)}`); expect(false).assertTrue(); } console.info(`InputDevice_getDeviceInfo_async_test exit`); @@ -573,7 +573,7 @@ export default function MultimodalInput_Device_test() { * @tc.name MultimodalInputDevice_GetDeviceInfo_test * @tc.desc inputdevice interface getDeviceInfo test */ - it("InputDevice_getDeviceInfo_test-02", 0, async function (done) { + it("InputDevice_getDeviceInfo_test_02", 0, async function (done) { console.info(`InputDevice_getDeviceInfo_promise_test enter`); try { inputDevice.getDeviceList().then((data) => { diff --git a/multimodalinput/input_js_standard/src/main/js/test/ListMultimodalinput.test.js b/multimodalinput/input_js_standard/src/main/js/test/List.test.js similarity index 79% rename from multimodalinput/input_js_standard/src/main/js/test/ListMultimodalinput.test.js rename to multimodalinput/input_js_standard/src/main/js/test/List.test.js index 7082976f6366c6ed516935b04cd78ad026b273fe..c5d033574a5535c3d4621c0f643decca0aa1af3d 100644 --- a/multimodalinput/input_js_standard/src/main/js/test/ListMultimodalinput.test.js +++ b/multimodalinput/input_js_standard/src/main/js/test/List.test.js @@ -13,11 +13,11 @@ * limitations under the License. */ -import MultimodalInput_Device_test from './InputDevice.test.js' +import InputDevice_test from './InputDevice.test.js' import MultimodalInput_KeyCode_test from './MultimodalInput_KeyCode.test.js' -import MultimodalInput_Pointer_test from './Pointer.test.js' +import Pointer_test from './Pointer.test.js' export default function testsuite() { - MultimodalInput_Device_test() + InputDevice_test() MultimodalInput_KeyCode_test() - MultimodalInput_Pointer_test() + Pointer_test() } \ No newline at end of file diff --git a/multimodalinput/input_js_standard/src/main/js/test/Pointer.test.js b/multimodalinput/input_js_standard/src/main/js/test/Pointer.test.js index 425b11c096ad1767359848cf0593a577c575b79e..15297b7b31d9c04bba9ec0310e098b9173cbde8c 100644 --- a/multimodalinput/input_js_standard/src/main/js/test/Pointer.test.js +++ b/multimodalinput/input_js_standard/src/main/js/test/Pointer.test.js @@ -16,8 +16,8 @@ import pointer from '@ohos.multimodalInput.pointer' import window from '@ohos.window' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' -export default function MultimodalInput_Pointer_test() { - describe('MultimodalInput_Pointer_test', function () { +export default function Pointer_test() { + describe('Pointer_test', function () { const errCode = { COMMON_PARAMETER_CODE: 401 diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/test/MultimodalInputEventType.test.ets b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/test/MultimodalInputEventType.test.ets index 2f507f2decb3a9b55255ea015355dc1dac470678..7209221644a5b6a911d651d29580109880a0af7a 100644 --- a/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/test/MultimodalInputEventType.test.ets +++ b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/test/MultimodalInputEventType.test.ets @@ -24,7 +24,7 @@ import { Touch, TouchEvent } from '@ohos.multimodalInput.touchEvent' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level } from '@ohos/hypium' export default function MultimodalInputEventTypeTest() { - describe('MultimodalInput_test', function () { + describe('MultimodalInputEventTypeTest', function () { it('MultimodalInput_KeyEventTypeTest_0010', 0, function () { console.info(`MultimodalInput_KeyEventTypeTest_0010 enter`); diff --git a/notification/ans_standard/BUILD.gn b/notification/ans_standard/BUILD.gn index 0bacff17c8e5768dca1136ca242107ae85a12695..894b5bc2ab0d2073a9b48d36836ff997a9823b0f 100644 --- a/notification/ans_standard/BUILD.gn +++ b/notification/ans_standard/BUILD.gn @@ -16,6 +16,7 @@ group("ans_standard") { testonly = true if (is_standard_system) { deps = [ + "actsNotificationBadgeTest:ActsNotificationBadgeTest", "actsNotificationDistributedTest:ActsNotificationDistributedTest", "actsNotificationManagerSlotTest:ActsNotificationManagerSlotTest", "actsNotificationPublishTest:ActsNotificationPublishTest", diff --git a/notification/ans_standard/actsNotificationBadgeTest/AppScope/app.json b/notification/ans_standard/actsNotificationBadgeTest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..e2242a3311055a9d07436a2e24b848d0ba0a9784 --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.badge", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/notification/ans_standard/actsNotificationBadgeTest/AppScope/resources/base/element/string.json b/notification/ans_standard/actsNotificationBadgeTest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d1f12ea9692aa14d5e6e140d74baa9b04c25352 --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"LifecycleTest" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationBadgeTest/AppScope/resources/base/media/app_icon.png b/notification/ans_standard/actsNotificationBadgeTest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/notification/ans_standard/actsNotificationBadgeTest/AppScope/resources/base/media/app_icon.png differ diff --git a/notification/ans_standard/actsNotificationBadgeTest/BUILD.gn b/notification/ans_standard/actsNotificationBadgeTest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9112c8a95fca8a8cc327495b9bf9fbe65e166e9b --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright (c) 2023 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("ActsNotificationBadgeTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":badgetest_js_assets", + ":badgetest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsNotificationBadgeTest" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_app_scope("badgetest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("badgetest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("badgetest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":badgetest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/notification/ans_standard/actsNotificationBadgeTest/Test.json b/notification/ans_standard/actsNotificationBadgeTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..76a3c5caaa8338790e622d426fc3f191a7c1f02b --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/Test.json @@ -0,0 +1,27 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "com.example.badge", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [ + { + "test-file-name": [ + "ActsNotificationBadgeTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type":"ShellKit", + "run-command":[ + "anm setting -e com.example.badge:0:1" + ], + "cleanup-apps":true + } + ] +} diff --git a/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/Application/AbilityStage.ts b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..308e590c00c7ce4bc6ad3fedf2af7dd74356dc68 --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2023 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 AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageContext = this.context; + } +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/MainAbility/MainAbility.ts b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d394176330a9cc8c42bf2aa3569dd936e15c5ae --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 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 Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.applicationContext = this.context.getApplicationContext(); + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context; + windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility_pages", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets new file mode 100644 index 0000000000000000000000000000000000000000..04e81577e55c00db79128beb6078e787f37b8ef0 --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets @@ -0,0 +1,47 @@ +// @ts-nocheck +/* + * Copyright (c) 2023 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 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 { + @State message: string = 'MainAbility' + + 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() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c0791be265c576261587c221147ca791524f735 --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2023 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 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.example.badge.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/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/test/ActsNotificationBadgeTest.test.ets b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/test/ActsNotificationBadgeTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b971cc18fe3366407cd49c52835ea90ec3bc127c --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/test/ActsNotificationBadgeTest.test.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2023 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import notificationManager from '@ohos.notificationManager' + +export default function ActsNotificationBadgeTest() { +describe('SUB_NOTIFICATION_ANS_BADGE_TEST', function () { + let TAG = 'SUB_NOTIFICATION_ANS_MANAGER_BADGE_test ===>' + console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_BADGE_test START') + /* + * @tc.number: SUB_NOTIFICATION_ANS_MANAGER_BADGE_test_0100 + * @tc.name: setBadgeNumber() + * @tc.desc: verify the callback function of setBadgeNumber + */ + it('SUB_NOTIFICATION_ANS_MANAGER_BADGE_test_0100', 0, async function (done) { + try { + notificationManager.setBadgeNumber(10, (err) => { + if (err) { + console.log(`SUB_NOTIFICATION_ANS_MANAGER_BADGE_test_0100 failed, error code: ${err.code}, message: ${err.message}`) + expect(false).assertTrue() + done() + } else { + console.log("SUB_NOTIFICATION_ANS_MANAGER_BADGE_test_0100 success") + expect(true).assertTrue() + done(); + } + }) + } catch (err) { + console.log(`SUB_NOTIFICATION_ANS_MANAGER_BADGE_test_0100 failed, catch error code: ${err.code}, message: ${err.message}`) + expect(false).assertTrue() + done() + } + }) + + /* + * @tc.number: SUB_NOTIFICATION_ANS_MANAGER_BADGE_test_0200 + * @tc.name: setBadgeNumber() + * @tc.desc: verify the promise function of setBadgeNumber + */ + it('SUB_NOTIFICATION_ANS_MANAGER_BADGE_test_0200', 0, async function (done) { + try { + await notificationManager.setBadgeNumber(10).then(() => { + console.log("SUB_NOTIFICATION_ANS_MANAGER_BADGE_test_0200 success") + expect(true).assertTrue() + done(); + }).catch((err) => { + console.log(`SUB_NOTIFICATION_ANS_MANAGER_BADGE_test_0200 failed, error code: ${err.code}, message: ${err.message}`) + expect(false).assertTrue() + done() + }) + } catch (err) { + console.log(`SUB_NOTIFICATION_ANS_MANAGER_BADGE_test_0200 failed, catch error code: ${err.code}, message: ${err.message}`) + expect(false).assertTrue() + done() + } + }) +}) +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/test/List.test.ets b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4e82aeb3c64b224acc61816ef1b2ce4f553b68e2 --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023 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 ActsNotificationBadgeTest from './ActsNotificationBadgeTest.test' + +export default function List() { + ActsNotificationBadgeTest() +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/module.json b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..61c06ab8423bad8fde5d88f2c5a0a8e72e4db82a --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/module.json @@ -0,0 +1,41 @@ +{ + "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, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.example.badge.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } + } diff --git a/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/element/color.json b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/element/string.json b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4af975ee904d5089633c604a63f3f9bcc3885a3f --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,36 @@ +{ + "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": "ActsLifecycleMultihapTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} diff --git a/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/media/icon.png b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/media/icon.png differ diff --git a/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/profile/form_config.json b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/profile/form_config.json new file mode 100644 index 0000000000000000000000000000000000000000..146fbe1c6da88e46886838ba746afb29e69cc190 --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/profile/form_config.json @@ -0,0 +1,23 @@ +{ + "forms": [ + { + "isDefault": true, + "src": "./js/widget/pages/index/index", + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "widget", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/profile/main_pages.json b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..81691245bb98976d7d8966dd406a9abd5140ef39 --- /dev/null +++ b/notification/ans_standard/actsNotificationBadgeTest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "MainAbility/pages/MainAbility_pages" + ] +} \ No newline at end of file diff --git a/notification/ans_standard/actsNotificationBadgeTest/signature/openharmony_sx.p7b b/notification/ans_standard/actsNotificationBadgeTest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..0928cd15d6618220f1c428451beb90f9a8321ed0 Binary files /dev/null and b/notification/ans_standard/actsNotificationBadgeTest/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/actsNotificationManagerSlotTest/src/main/js/test/ActsNotificationManagerSlotTest.js b/notification/ans_standard/actsNotificationManagerSlotTest/src/main/js/test/ActsNotificationManagerSlotTest.js index e1725afd0b25ce0fcabc3b155a7a952cbebc940c..1b2d7038496c633597bf0661b6beee71be4b27f9 100644 --- a/notification/ans_standard/actsNotificationManagerSlotTest/src/main/js/test/ActsNotificationManagerSlotTest.js +++ b/notification/ans_standard/actsNotificationManagerSlotTest/src/main/js/test/ActsNotificationManagerSlotTest.js @@ -20,6 +20,10 @@ export default function ActsNotificationManagerSlotTest() { let TAG = 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST ===>' console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST START') + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)) + } + afterEach(async function (done) { console.info(`${TAG} afterEach START`) try { @@ -1356,73 +1360,50 @@ export default function ActsNotificationManagerSlotTest() { */ it('SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4700', 0, async function (done) { console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4700 START') - try { - await notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION, (err) => { - if (err) { - console.info(`${TAG} addSlot SOCIAL_COMMUNICATION err: ${err}, errMes: ${err.message}`) - expect(false).assertTrue() - done() - } else { - console.info(`${TAG} addSlot SOCIAL_COMMUNICATION success`) - expect(true).assertTrue() - } - }) - } catch (err) { - console.info(`${TAG} addSlot SOCIAL_COMMUNICATION errCode: ${err}, errMes: ${err.message}`) + + await notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION).then(() => { + console.info(`${TAG} addSlot SOCIAL_COMMUNICATION success`) + expect(true).assertTrue() + }).catch((err) => { + console.info(`${TAG} addSlot SOCIAL_COMMUNICATION err: ${err}, errMes: ${err.message}`) expect(false).assertTrue() done() - } + }) - try { - await notificationManager.addSlot(notificationManager.SlotType.SERVICE_INFORMATION, (err) => { - if (err) { - console.info(`${TAG} addSlot SERVICE_INFORMATION err: ${err}, errMes: ${err.message}`) - expect(false).assertTrue() - done() - } else { - console.info(`${TAG} addSlot SERVICE_INFORMATION success`) - expect(true).assertTrue() - } - }) - } catch (err) { - console.info(`${TAG} addSlot SERVICE_INFORMATION errCode: ${err}, errMes: ${err.message}`) + await sleep(1000) + + await notificationManager.addSlot(notificationManager.SlotType.SERVICE_INFORMATION).then(() => { + console.info(`${TAG} addSlot SERVICE_INFORMATION success`) + expect(true).assertTrue() + }).catch((err) => { + console.info(`${TAG} addSlot SERVICE_INFORMATION err: ${err}, errMes: ${err.message}`) expect(false).assertTrue() done() - } + }) - try { - await notificationManager.addSlot(notificationManager.SlotType.CONTENT_INFORMATION, (err) => { - if (err) { - console.info(`${TAG} addSlot CONTENT_INFORMATION err: ${err}, errMes: ${err.message}`) - expect(false).assertTrue() - done() - } else { - console.info(`${TAG} addSlot CONTENT_INFORMATION success`) - expect(true).assertTrue() - } - }) - } catch (err) { - console.info(`${TAG} addSlot CONTENT_INFORMATION errCode: ${err}, errMes: ${err.message}`) + await sleep(1000) + + await notificationManager.addSlot(notificationManager.SlotType.CONTENT_INFORMATION).then(() => { + console.info(`${TAG} addSlot CONTENT_INFORMATION success`) + expect(true).assertTrue() + }).catch((err) => { + console.info(`${TAG} addSlot CONTENT_INFORMATION err: ${err}, errMes: ${err.message}`) expect(false).assertTrue() done() - } + }) - try { - await notificationManager.addSlot(notificationManager.SlotType.OTHER_TYPES, (err) => { - if (err) { - console.info(`${TAG} addSlot OTHER_TYPES err: ${err}, errMes: ${err.message}`) - expect(false).assertTrue() - done() - } else { - console.info(`${TAG} addSlot OTHER_TYPES success`) - expect(true).assertTrue() - } - }) - } catch (err) { - console.info(`${TAG} addSlot OTHER_TYPES errCode: ${err}, errMes: ${err.message}`) + await sleep(1000) + + await notificationManager.addSlot(notificationManager.SlotType.OTHER_TYPES).then(() => { + console.info(`${TAG} addSlot OTHER_TYPES success`) + expect(true).assertTrue() + }).catch((err) => { + console.info(`${TAG} addSlot OTHER_TYPES err: ${err}, errMes: ${err.message}`) expect(false).assertTrue() done() - } + }) + + await sleep(1000) try { await notificationManager.getSlots((err, NotificationSlot) => { @@ -1432,10 +1413,18 @@ export default function ActsNotificationManagerSlotTest() { done() } else { console.info(`${TAG} getSlots AsyncCallback success:` + JSON.stringify(NotificationSlot)) - expect(NotificationSlot[0].type).assertEqual(1) - expect(NotificationSlot[1].type).assertEqual(2) - expect(NotificationSlot[2].type).assertEqual(3) - expect(NotificationSlot[3].type).assertEqual(65535) + for (let i = 0; i < NotificationSlot.length; i++) { + console.info(`${TAG} NotificationSlot[${i}].type:` + JSON.stringify(NotificationSlot[i].type)) + if (NotificationSlot[i].type == 1) { + expect(NotificationSlot[i].type).assertEqual(1) + } else if (NotificationSlot[i].type == 2) { + expect(NotificationSlot[i].type).assertEqual(2) + } else if (NotificationSlot[i].type == 3) { + expect(NotificationSlot[i].type).assertEqual(3) + } else { + expect(NotificationSlot[i].type).assertEqual(65535) + } + } done() } }) @@ -1456,80 +1445,64 @@ export default function ActsNotificationManagerSlotTest() { it('SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4800', 0, async function (done) { console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4800 START') - try { - await notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION, (err) => { - if (err) { - console.info(`${TAG} addSlot SOCIAL_COMMUNICATION err: ${err}, errMes: ${err.message}`) - expect(false).assertTrue() - done() - } else { - console.info(`${TAG} addSlot SOCIAL_COMMUNICATION success`) - expect(true).assertTrue() - } - }) - } catch (err) { - console.info(`${TAG} addSlot SOCIAL_COMMUNICATION errCode: ${err}, errMes: ${err.message}`) + await notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION).then(() => { + console.info(`${TAG} addSlot SOCIAL_COMMUNICATION success`) + expect(true).assertTrue() + }).catch((err) => { + console.info(`${TAG} addSlot SOCIAL_COMMUNICATION err: ${err}, errMes: ${err.message}`) expect(false).assertTrue() done() - } + }) - try { - await notificationManager.addSlot(notificationManager.SlotType.SERVICE_INFORMATION, (err) => { - if (err) { - console.info(`${TAG} addSlot SERVICE_INFORMATION err: ${err}, errMes: ${err.message}`) - expect(false).assertTrue() - done() - } else { - console.info(`${TAG} addSlot SERVICE_INFORMATION success`) - expect(true).assertTrue() - } - }) - } catch (err) { - console.info(`${TAG} addSlot SERVICE_INFORMATION errCode: ${err}, errMes: ${err.message}`) + await sleep(1000) + + await notificationManager.addSlot(notificationManager.SlotType.SERVICE_INFORMATION).then(() => { + console.info(`${TAG} addSlot SERVICE_INFORMATION success`) + expect(true).assertTrue() + }).catch((err) => { + console.info(`${TAG} addSlot SERVICE_INFORMATION err: ${err}, errMes: ${err.message}`) expect(false).assertTrue() done() - } + }) - try { - await notificationManager.addSlot(notificationManager.SlotType.CONTENT_INFORMATION, (err) => { - if (err) { - console.info(`${TAG} addSlot CONTENT_INFORMATION err: ${err}, errMes: ${err.message}`) - expect(false).assertTrue() - done() - } else { - console.info(`${TAG} addSlot CONTENT_INFORMATION success`) - expect(true).assertTrue() - } - }) - } catch (err) { - console.info(`${TAG} addSlot CONTENT_INFORMATION errCode: ${err}, errMes: ${err.message}`) + await sleep(1000) + + await notificationManager.addSlot(notificationManager.SlotType.CONTENT_INFORMATION).then(() => { + console.info(`${TAG} addSlot CONTENT_INFORMATION success`) + expect(true).assertTrue() + }).catch((err) => { + console.info(`${TAG} addSlot CONTENT_INFORMATION err: ${err}, errMes: ${err.message}`) expect(false).assertTrue() done() - } + }) - try { - await notificationManager.addSlot(notificationManager.SlotType.OTHER_TYPES, (err) => { - if (err) { - console.info(`${TAG} addSlot OTHER_TYPES err: ${err}, errMes: ${err.message}`) - expect(false).assertTrue() - done() - } else { - console.info(`${TAG} addSlot OTHER_TYPES success`) - expect(true).assertTrue() - } - }) - } catch (err) { - console.info(`${TAG} addSlot OTHER_TYPES errCode: ${err}, errMes: ${err.message}`) + await sleep(1000) + + await notificationManager.addSlot(notificationManager.SlotType.OTHER_TYPES).then(() => { + console.info(`${TAG} addSlot OTHER_TYPES success`) + expect(true).assertTrue() + }).catch((err) => { + console.info(`${TAG} addSlot OTHER_TYPES err: ${err}, errMes: ${err.message}`) expect(false).assertTrue() done() - } + }) + + await sleep(1000) await notificationManager.getSlots().then((NotificationSlot) => { console.info(`${TAG} getSlots Promise success:` + JSON.stringify(NotificationSlot)) - expect(NotificationSlot[0].type).assertEqual(1) - expect(NotificationSlot[1].type).assertEqual(2) - expect(NotificationSlot[2].type).assertEqual(3) - expect(NotificationSlot[3].type).assertEqual(65535) + for (let i = 0; i < NotificationSlot.length; i++) { + console.info(`${TAG} NotificationSlot[${i}].type:` + JSON.stringify(NotificationSlot[i].type)) + if (NotificationSlot[i].type == 1) { + expect(NotificationSlot[i].type).assertEqual(1) + } else if (NotificationSlot[i].type == 2) { + expect(NotificationSlot[i].type).assertEqual(2) + } else if (NotificationSlot[i].type == 3) { + expect(NotificationSlot[i].type).assertEqual(3) + } else { + expect(NotificationSlot[i].type).assertEqual(65535) + } + } done() }).catch((err) => { console.info(`${TAG} getSlots Promise err: ${err}, errMes: ${err.message}`) diff --git a/notification/ans_standard/actsNotificationSecondaryDirectoryTest/entry/src/main/module.json b/notification/ans_standard/actsNotificationSecondaryDirectoryTest/entry/src/main/module.json index 927e3dbb2fcdf10619f4cbc404ea4be7a9e82ffc..db6c7ac155b5151bd24152f93712328a9b746135 100644 --- a/notification/ans_standard/actsNotificationSecondaryDirectoryTest/entry/src/main/module.json +++ b/notification/ans_standard/actsNotificationSecondaryDirectoryTest/entry/src/main/module.json @@ -14,6 +14,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "com.example.secondaryDirectory.MainAbility", diff --git a/notification/ans_standard/actsNotificationSlotTest/src/main/js/test/ActsNotificationSlotTest.js b/notification/ans_standard/actsNotificationSlotTest/src/main/js/test/ActsNotificationSlotTest.js index a472e47ba386421f3e4d0cf71bef66654cc85baf..5d01d296e820aec610f2c2ee4b567494f9243371 100644 --- a/notification/ans_standard/actsNotificationSlotTest/src/main/js/test/ActsNotificationSlotTest.js +++ b/notification/ans_standard/actsNotificationSlotTest/src/main/js/test/ActsNotificationSlotTest.js @@ -20,6 +20,10 @@ export default function ActsNotificationSlotTest() { let TAG = 'SUB_NOTIFICATION_ANS_SLOT_TEST ===>' console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST START') + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)) + } + afterEach(async function (done) { console.info(`${TAG} afterEach START`) await notification.removeAllSlots((err) => { @@ -1220,6 +1224,8 @@ export default function ActsNotificationSlotTest() { } }) + await sleep(1000) + await notification.addSlot(notification.SlotType.SERVICE_INFORMATION, (err) => { if (err.code) { console.info(`${TAG} addSlot SERVICE_INFORMATION err: + ${err.code}`) @@ -1231,6 +1237,8 @@ export default function ActsNotificationSlotTest() { } }) + await sleep(1000) + await notification.addSlot(notification.SlotType.CONTENT_INFORMATION, (err) => { if (err.code) { console.info(`${TAG} addSlot CONTENT_INFORMATION err: + ${err.code}`) @@ -1242,6 +1250,8 @@ export default function ActsNotificationSlotTest() { } }) + await sleep(1000) + await notification.addSlot(notification.SlotType.OTHER_TYPES, (err) => { if (err.code) { console.info(`${TAG} addSlot OTHER_TYPES err: + ${err.code}`) @@ -1253,6 +1263,8 @@ export default function ActsNotificationSlotTest() { } }) + await sleep(1000) + await notification.getSlots((err, NotificationSlot) => { if (err.code) { console.info(`${TAG} getSlots AsyncCallback err: + ${err.code}`) @@ -1260,10 +1272,18 @@ export default function ActsNotificationSlotTest() { done() } else { console.info(`${TAG} getSlots AsyncCallback success:` + JSON.stringify(NotificationSlot)) - expect(NotificationSlot[0].type).assertEqual(1) - expect(NotificationSlot[1].type).assertEqual(2) - expect(NotificationSlot[2].type).assertEqual(3) - expect(NotificationSlot[3].type).assertEqual(65535) + for (let i = 0; i < NotificationSlot.length; i++) { + console.info(`${TAG} NotificationSlot[${i}].type:` + JSON.stringify(NotificationSlot[i].type)) + if (NotificationSlot[i].type == 1) { + expect(NotificationSlot[i].type).assertEqual(1) + } else if (NotificationSlot[i].type == 2) { + expect(NotificationSlot[i].type).assertEqual(2) + } else if (NotificationSlot[i].type == 3) { + expect(NotificationSlot[i].type).assertEqual(3) + } else { + expect(NotificationSlot[i].type).assertEqual(65535) + } + } done() } }) @@ -1290,6 +1310,8 @@ export default function ActsNotificationSlotTest() { } }) + await sleep(1000) + await notification.addSlot(notification.SlotType.SERVICE_INFORMATION, (err) => { if (err.code) { console.info(`${TAG} addSlot SERVICE_INFORMATION err: + ${err.code}`) @@ -1301,6 +1323,8 @@ export default function ActsNotificationSlotTest() { } }) + await sleep(1000) + await notification.addSlot(notification.SlotType.CONTENT_INFORMATION, (err) => { if (err.code) { console.info(`${TAG} addSlot CONTENT_INFORMATION err: + ${err.code}`) @@ -1312,6 +1336,8 @@ export default function ActsNotificationSlotTest() { } }) + await sleep(1000) + await notification.addSlot(notification.SlotType.OTHER_TYPES, (err) => { if (err.code) { console.info(`${TAG} addSlot OTHER_TYPES err: + ${err.code}`) @@ -1323,12 +1349,22 @@ export default function ActsNotificationSlotTest() { } }) + await sleep(1000) + await notification.getSlots().then((NotificationSlot) => { console.info(`${TAG} getSlots Promise success:` + JSON.stringify(NotificationSlot)) - expect(NotificationSlot[0].type).assertEqual(1) - expect(NotificationSlot[1].type).assertEqual(2) - expect(NotificationSlot[2].type).assertEqual(3) - expect(NotificationSlot[3].type).assertEqual(65535) + for (let i = 0; i < NotificationSlot.length; i++) { + console.info(`${TAG} NotificationSlot[${i}].type:` + JSON.stringify(NotificationSlot[i].type)) + if (NotificationSlot[i].type == 1) { + expect(NotificationSlot[i].type).assertEqual(1) + } else if (NotificationSlot[i].type == 2) { + expect(NotificationSlot[i].type).assertEqual(2) + } else if (NotificationSlot[i].type == 3) { + expect(NotificationSlot[i].type).assertEqual(3) + } else { + expect(NotificationSlot[i].type).assertEqual(65535) + } + } done() }).catch((err) => { console.info(`${TAG} getSlots Promise err: + ${err.code}`) diff --git a/request/RequestTest_Stage/entry/src/main/module.json b/request/RequestTest_Stage/entry/src/main/module.json index 743f3372048b1f37cfdd356c3142611c96ff1acc..6a33270fffbaffa702e19b230b25c412e7b84bad 100644 --- a/request/RequestTest_Stage/entry/src/main/module.json +++ b/request/RequestTest_Stage/entry/src/main/module.json @@ -6,13 +6,19 @@ "description": "$string:entry_desc", "mainElement": "MainAbility", "deviceTypes": [ - "tablet", - "default", + "tablet", + "default", "phone" ], "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/resourceschedule/resourceschedule_standard/reminderagent/src/main/js/test/ReminderAgentJs.test.js b/resourceschedule/resourceschedule_standard/reminderagent/src/main/js/test/ReminderAgentJs.test.js index 3c0e380d541f3ff7ec0eb0e713b7040927ce0ea5..76a392b4baee964fce97e067a413ed9d32184b09 100644 --- a/resourceschedule/resourceschedule_standard/reminderagent/src/main/js/test/ReminderAgentJs.test.js +++ b/resourceschedule/resourceschedule_standard/reminderagent/src/main/js/test/ReminderAgentJs.test.js @@ -371,26 +371,16 @@ export default function ReminderAgentTest() { * @tc.name testAddNotificationSlotNorFun_012 * @tc.desc Adds a reminder notification slot with the promise function and null mySlot. */ - it('testAddNotificationSlotNorFun_012', 0, async function (done) { - console.info('----------------------testAddNotificationSlotNorFun_012---------------------------'); - let mySlot = null; - try { - reminderAgent.addNotificationSlot(mySlot, function (err) { - if (err == undefined) { - console.info('testAddNotificationSlotNorFun_012 execute success'); - } else { - console.info('testAddNotificationSlotNorFun_012 execute failed'); - } - }).catch(function (err) { - console.info("testAddNotificationSlotNorFun_012 execute catch" + err.code); - }) - } catch (error) { - console.info("testAddNotificationSlotNorFun_012 execute try - catch" + error.code); - let i = 0; - expect(0).assertEqual(i); - done(); - } - }) + it('testAddNotificationSlotNorFun_012', 0, async function (done) { + console.info('----------------------testAddNotificationSlotNorFun_012---------------------------'); + let mySlot = null; + + reminderAgent.addNotificationSlot(mySlot, function (err) { + console.info("testAddNotificationSlotNorFun_012 null slot is invalid parameter " + err.code); + expect(err.code).assertEqual(401); + done(); + }) + }) /** * @tc.number SUB_RESOURCESCHEDULE_REMINDER_AGENT_XTS_013 @@ -434,20 +424,22 @@ export default function ReminderAgentTest() { type: 4 } function reminderCallback(err, data) { - if (err) { - expect(true).assertTrue(); - } else { - expect(false).assertTrue(); - } - setTimeout(() => { - done(); - }, 500); + if (err.code == 0) { + console.info('testAddNotificationSlotNorFun_014 add slot success'); + expect(err.code).assertEqual(0); + done(); + } else { + console.info('testAddNotificationSlotNorFun_014 slot type 4 is invalid value err code is:' + err.code); + expect(err.code).assertEqual(401); + done(); + } } reminderAgent.addNotificationSlot(mySlot0, reminderCallback); reminderAgent.addNotificationSlot(mySlot1, reminderCallback); reminderAgent.addNotificationSlot(mySlot2, reminderCallback); reminderAgent.addNotificationSlot(mySlot3, reminderCallback); reminderAgent.addNotificationSlot(mySlot4, reminderCallback); + }) /** @@ -2589,7 +2581,7 @@ export default function ReminderAgentTest() { expect(button).assertEqual(1); done(); }) - + /** * @tc.number SUB_RESOURCESCHEDULE_REMINDER_AGENT_XTS_0100 * @tc.name testNotificationSlotType_0100 @@ -2682,13 +2674,13 @@ export default function ReminderAgentTest() { type: 1 } reminderAgent.addNotificationSlot(tarRemoveSlot.type, (err, data) => { - console.info('addNotificationSlot 106 err code:' + err.code) - }); - reminderAgent.removeNotificationSlot(tarRemoveSlot.type, (err, data) => { - console.info('err code 106 is :' + err.code) - expect(err.code).assertEqual(0); - done(); - }); + console.info('addNotificationSlot 106 err code:' + err.code); + reminderAgent.removeNotificationSlot(tarRemoveSlot.type, (err, data) => { + console.info('err code 106 is :' + err.code) + expect(err.code).assertEqual(0); + done(); + }) + }) }) /** @@ -2722,12 +2714,15 @@ export default function ReminderAgentTest() { reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, triggerTimeInSeconds: 3 } - reminderAgent.publishReminder(timer).then((reminderId) => { }); - reminderAgent.getValidReminders().then((reminders) => { - console.info('reminders length is :' + reminders.length) - expect(reminders.length).assertLarger(0) - done() - }); + reminderAgent.cancelAllReminders().then(() => { + reminderAgent.publishReminder(timer).then((reminderId) => { + reminderAgent.getValidReminders().then((reminders) => { + console.info('reminders length is :' + reminders.length) + expect(reminders.length).assertLarger(0) + done(); + }) + }) + }) }) /** @@ -2741,13 +2736,15 @@ export default function ReminderAgentTest() { reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, triggerTimeInSeconds: 3 } - reminderAgent.cancelAllReminders().then(() => { }) - reminderAgent.publishReminder(timer).then((reminderId) => { }); - reminderAgent.getValidReminders((err, reminders) => { - console.info('reminder length 109 is :' + reminders.length) - expect(reminders.length).assertEqual(0); - done() - }); + reminderAgent.cancelAllReminders().then(() => { + reminderAgent.publishReminder(timer).then((reminderId) => { + reminderAgent.getValidReminders((err, reminders) => { + console.info('reminder length 109 is :' + reminders.length) + expect(reminders.length).assertLarger(0); + done() + }) + }) + }) }) /** @@ -2762,14 +2759,11 @@ export default function ReminderAgentTest() { hour: 21, minute: 14 } - reminderAgent.cancelAllReminders().then((err,data) => { - console.info('err.code 0110 is :' + err.code) - }); reminderAgent.publishReminder(alarm).then((reminderId) => { console.info("promise the testPublishReminderNorAlarmFun_0110 remiderId =" + reminderId); expect(reminderId).assertLarger(0); done() - }); + }) }) /** @@ -2788,7 +2782,7 @@ export default function ReminderAgentTest() { console.info("callback the testPublishReminderNorAlarmFun_0111 remiderId =" + reminderId); expect(reminderId).assertLarger(0); done(); - }); + }) }) /** diff --git a/security/BUILD.gn b/security/BUILD.gn index d6f7e11697120c1a8a117230a7e993d38d10495e..ee3da331fbb0a1ff42e7992a17c04c7a7110157a 100644 --- a/security/BUILD.gn +++ b/security/BUILD.gn @@ -18,9 +18,9 @@ group("security") { if (is_standard_system) { deps = [ "access_token/AccessTokenTest_Normal_js:ActsAccessTokenApiJSNormalTest", + "certificate_framework/js_api_test_one:ActsCertificateFrameworkJSNormalTest", "cipher/datacipher:datacipher", "cryptoFramework/js_api_test_one:ActsCryptoFrameworkJSNormalTest", - "cryptoFramework/js_api_test_two:ActsCryptoFrameworkJSNormalTwoTest", "huks_napi_BasicTest:ActsHuksNAPITest", "security_huks_basic", "security_huks_reformed_test", diff --git a/security/access_token/AccessTokenTest_Normal_js/src/main/config.json b/security/access_token/AccessTokenTest_Normal_js/src/main/config.json index 5e7272826e789a8d1448052bcea862967d3e69ff..98158d36e26a87b2ae99e4a391f44b1e6a48dc03 100644 --- a/security/access_token/AccessTokenTest_Normal_js/src/main/config.json +++ b/security/access_token/AccessTokenTest_Normal_js/src/main/config.json @@ -17,8 +17,8 @@ "package": "ohos.acts.security.access_token.normal", "name": ".entry", "deviceType": [ - "tablet", - "default", + "tablet", + "default", "phone" ], "distro": { @@ -26,34 +26,9 @@ "moduleName": "entry", "moduleType": "entry" }, - "definePermissions": [ - { - "name": "ohos.permission.ALPHA", - "grantMode": "user_grant", - "availableLevel": "system_basic", - "provisionEnable": true, - "distributedSceneEnable": true, - "label": "ALPHA label", - "description": "ALPHA description" - }, - { - "name": "ohos.permission.BETA", - "grantMode": "system_grant", - "availableLevel": "system_basic", - "provisionEnable": true, - "distributedSceneEnable": true, - "label": "BETA label", - "description": "BETA description" - } - ], "reqPermissions": [ { - "name": "ohos.permission.ALPHA", - "reason": "use ohos.permission.ALPHA" - }, - { - "name": "ohos.permission.BETA", - "reason": "use ohos.permission.BETA" + "name": "ohos.permission.DISTRIBUTED_DATASYNC" }, { "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", diff --git a/security/access_token/AccessTokenTest_Normal_js/src/main/js/test/AccessToken.test.js b/security/access_token/AccessTokenTest_Normal_js/src/main/js/test/AccessToken.test.js index 4fcd8e979357bf68cbac4f3d6a92ddd627895eaa..17742630cc8af034f594a1676a7ae16a30babb3b 100644 --- a/security/access_token/AccessTokenTest_Normal_js/src/main/js/test/AccessToken.test.js +++ b/security/access_token/AccessTokenTest_Normal_js/src/main/js/test/AccessToken.test.js @@ -35,8 +35,8 @@ const TIMEOUT = 5000; const ERR_PARAM_INVALID = 12100001; const DEFAULT_PERMISSION_FALG = 0; -var permissionNameUser = "ohos.permission.ALPHA"; -var permissionNameSystem = "ohos.permission.BETA"; +var permissionNameUser = "ohos.permission.DISTRIBUTED_DATASYNC"; +var permissionNameSystem = "ohos.permission.GET_BUNDLE_INFO"; var tokenID = undefined; export default function AccessTokenTest() { describe('AccessTokenTest', function () { diff --git a/security/cryptoFramework/js_api_test_two/BUILD.gn b/security/certificate_framework/js_api_test_one/BUILD.gn similarity index 90% rename from security/cryptoFramework/js_api_test_two/BUILD.gn rename to security/certificate_framework/js_api_test_one/BUILD.gn index 89c1cd59dd0656d326b71bd737122fd004414071..c4bd78f9ab290d85f575a1d6af3d9eff1556f364 100644 --- a/security/cryptoFramework/js_api_test_two/BUILD.gn +++ b/security/certificate_framework/js_api_test_one/BUILD.gn @@ -13,14 +13,14 @@ import("//test/xts/tools/build/suite.gni") -ohos_js_hap_suite("ActsCryptoFrameworkJSNormalTwoTest") { +ohos_js_hap_suite("ActsCertificateFrameworkJSNormalTest") { hap_profile = "./src/main/config.json" deps = [ ":hjs_demo_js_assets", ":hjs_demo_resources", ] certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsCryptoFrameworkJSNormalTwoTest" + hap_name = "ActsCertificateFrameworkJSNormalTest" subsystem_name = "security" part_name = "crypto_framework" } diff --git a/security/cryptoFramework/js_api_test_two/Test.json b/security/certificate_framework/js_api_test_one/Test.json similarity index 63% rename from security/cryptoFramework/js_api_test_two/Test.json rename to security/certificate_framework/js_api_test_one/Test.json index f6d21ed1a87f817a001aaa3395b4f72e1fc0bff7..35271e3fa09bb226b3ecba9364791d623e638c3e 100644 --- a/security/cryptoFramework/js_api_test_two/Test.json +++ b/security/certificate_framework/js_api_test_one/Test.json @@ -5,12 +5,12 @@ "test-timeout": "900000", "shell-timeout": "900000", "testcase-timeout": "60000", - "bundle-name": "com.openharmony.cryptoFramework2", - "package-name": "com.openharmony.cryptoFramework2" + "bundle-name": "com.openharmony.certificateframework", + "package-name": "com.openharmony.certificateframework" }, "kits": [ { - "test-file-name": ["ActsCryptoFrameworkJSNormalTwoTest.hap"], + "test-file-name": ["ActsCertificateFrameworkJSNormalTest.hap"], "type": "AppInstallKit", "cleanup-apps": true }, @@ -21,7 +21,7 @@ { "type": "PushKit", "push": [ - "ActsCryptoFrameworkJSNormalTwoTest.hap->/data/test/ActsCryptoFrameworkJSNormalTwoTest.hap" + "ActsCertificateFrameworkJSNormalTest.hap->/data/test/ActsCertificateFrameworkJSNormalTest.hap" ] }, { diff --git a/security/cryptoFramework/js_api_test_two/signature/openharmony_sx.p7b b/security/certificate_framework/js_api_test_one/signature/openharmony_sx.p7b similarity index 86% rename from security/cryptoFramework/js_api_test_two/signature/openharmony_sx.p7b rename to security/certificate_framework/js_api_test_one/signature/openharmony_sx.p7b index 36abac301ab0eea93cbf9d3cd61b75060ce74c51..3781c426c56a13cf8054adc975a2d5e29cba77a0 100644 Binary files a/security/cryptoFramework/js_api_test_two/signature/openharmony_sx.p7b and b/security/certificate_framework/js_api_test_one/signature/openharmony_sx.p7b differ diff --git a/security/cryptoFramework/js_api_test_two/src/main/config.json b/security/certificate_framework/js_api_test_one/src/main/config.json similarity index 90% rename from security/cryptoFramework/js_api_test_two/src/main/config.json rename to security/certificate_framework/js_api_test_one/src/main/config.json index c585893881fd0d244b5d955e568529e3135e6047..ec36b83cefce00d61be072f6097b59d2340eb3a2 100644 --- a/security/cryptoFramework/js_api_test_two/src/main/config.json +++ b/security/certificate_framework/js_api_test_one/src/main/config.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.openharmony.cryptoFramework2", + "bundleName": "com.openharmony.certificateframework", "vendor": "acts", "version": { "code": 12, @@ -14,7 +14,7 @@ }, "deviceConfig": {}, "module": { - "package": "com.openharmony.cryptoFramework2", + "package": "com.openharmony.certificateframework", "name": ".entry", "mainAbility": ".MainAbility", "deviceType": ["default", "tablet", "tv", "wearable", "phone"], diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/MainAbility/app.js b/security/certificate_framework/js_api_test_one/src/main/js/MainAbility/app.js similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/MainAbility/app.js rename to security/certificate_framework/js_api_test_one/src/main/js/MainAbility/app.js diff --git a/security/certificate_framework/js_api_test_one/src/main/js/MainAbility/i18n/en-US.json b/security/certificate_framework/js_api_test_one/src/main/js/MainAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/security/certificate_framework/js_api_test_one/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/security/certificate_framework/js_api_test_one/src/main/js/MainAbility/i18n/zh-CN.json b/security/certificate_framework/js_api_test_one/src/main/js/MainAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/security/certificate_framework/js_api_test_one/src/main/js/MainAbility/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/MainAbility/pages/index/index.css b/security/certificate_framework/js_api_test_one/src/main/js/MainAbility/pages/index/index.css similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/MainAbility/pages/index/index.css rename to security/certificate_framework/js_api_test_one/src/main/js/MainAbility/pages/index/index.css diff --git a/security/certificate_framework/js_api_test_one/src/main/js/MainAbility/pages/index/index.hml b/security/certificate_framework/js_api_test_one/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/security/certificate_framework/js_api_test_one/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/MainAbility/pages/index/index.js b/security/certificate_framework/js_api_test_one/src/main/js/MainAbility/pages/index/index.js similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/MainAbility/pages/index/index.js rename to security/certificate_framework/js_api_test_one/src/main/js/MainAbility/pages/index/index.js diff --git a/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/app.js b/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 --- /dev/null +++ b/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * 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' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/i18n/en-US.json b/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb24b374b1d919ca8eac0638f361692b603a900 --- /dev/null +++ b/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/i18n/zh-CN.json b/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..c804e32c0c3103929baca5617cdac70be11fdba1 --- /dev/null +++ b/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/pages/index/index.css b/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..b1bcd43387ba131cc1d30975ff7508a6f8084a4b --- /dev/null +++ b/security/certificate_framework/js_api_test_one/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/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/pages/index/index.hml b/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f629c71a9be857db6cdf94149652a191b9b272ea --- /dev/null +++ b/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/pages/index/index.js b/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..88b083a7f6b979019d6a2c5ad20b19c5fd43286b --- /dev/null +++ b/security/certificate_framework/js_api_test_one/src/main/js/TestAbility/pages/index/index.js @@ -0,0 +1,26 @@ +/* + * 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'); + } +} + + + diff --git a/security/certificate_framework/js_api_test_one/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/security/certificate_framework/js_api_test_one/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa8620ca77d381f20b65a903b833e6e3378c97 --- /dev/null +++ b/security/certificate_framework/js_api_test_one/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/security/cryptoFramework/js_api_test_two/src/main/js/test/Certificate.test.js b/security/certificate_framework/js_api_test_one/src/main/js/test/Certificate.test.js similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/test/Certificate.test.js rename to security/certificate_framework/js_api_test_one/src/main/js/test/Certificate.test.js diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/test/CertificateCrl.test.js b/security/certificate_framework/js_api_test_one/src/main/js/test/CertificateCrl.test.js similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/test/CertificateCrl.test.js rename to security/certificate_framework/js_api_test_one/src/main/js/test/CertificateCrl.test.js diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/test/List.test.js b/security/certificate_framework/js_api_test_one/src/main/js/test/List.test.js similarity index 90% rename from security/cryptoFramework/js_api_test_two/src/main/js/test/List.test.js rename to security/certificate_framework/js_api_test_one/src/main/js/test/List.test.js index 830530f9fcf17b7dac1f5a43472f32b6ae8c222f..55b4e70f2eb48cec2dab88b82087675897d0a449 100644 --- a/security/cryptoFramework/js_api_test_two/src/main/js/test/List.test.js +++ b/security/certificate_framework/js_api_test_one/src/main/js/test/List.test.js @@ -13,12 +13,10 @@ * limitations under the License. */ -import SecurityRandomJsunit from "./SecurityRandom.test"; import CertificateJsunit from "./Certificate.test"; import CertificateCrlJsunit from "./CertificateCrl.test"; export default function testsuite() { - SecurityRandomJsunit(); CertificateJsunit(); CertificateCrlJsunit(); } diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/test/utils/certificate/publicCertificateCallback.js b/security/certificate_framework/js_api_test_one/src/main/js/test/utils/certificate/publicCertificateCallback.js similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/test/utils/certificate/publicCertificateCallback.js rename to security/certificate_framework/js_api_test_one/src/main/js/test/utils/certificate/publicCertificateCallback.js diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/test/utils/certificate/publicCertificatePromise.js b/security/certificate_framework/js_api_test_one/src/main/js/test/utils/certificate/publicCertificatePromise.js similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/test/utils/certificate/publicCertificatePromise.js rename to security/certificate_framework/js_api_test_one/src/main/js/test/utils/certificate/publicCertificatePromise.js diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/test/utils/common/publicDoString.js b/security/certificate_framework/js_api_test_one/src/main/js/test/utils/common/publicDoString.js similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/test/utils/common/publicDoString.js rename to security/certificate_framework/js_api_test_one/src/main/js/test/utils/common/publicDoString.js diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/test/utils/common/publicParam.js b/security/certificate_framework/js_api_test_one/src/main/js/test/utils/common/publicParam.js similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/test/utils/common/publicParam.js rename to security/certificate_framework/js_api_test_one/src/main/js/test/utils/common/publicParam.js diff --git a/security/cryptoFramework/js_api_test_two/src/main/resources/base/element/string.json b/security/certificate_framework/js_api_test_one/src/main/resources/base/element/string.json similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/resources/base/element/string.json rename to security/certificate_framework/js_api_test_one/src/main/resources/base/element/string.json diff --git a/security/certificate_framework/js_api_test_one/src/main/resources/base/media/icon.png b/security/certificate_framework/js_api_test_one/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/security/certificate_framework/js_api_test_one/src/main/resources/base/media/icon.png differ diff --git a/security/cryptoFramework/js_api_test_one/src/main/js/test/AsymmetricCryptography.test.js b/security/cryptoFramework/js_api_test_one/src/main/js/test/AsymmetricCryptography.test.js index 762159978ce5c1d8851f045096b0d3cf3d837f9b..0f81b62ffa63090b93578019f7c8551eb051798c 100644 --- a/security/cryptoFramework/js_api_test_one/src/main/js/test/AsymmetricCryptography.test.js +++ b/security/cryptoFramework/js_api_test_one/src/main/js/test/AsymmetricCryptography.test.js @@ -982,7 +982,7 @@ export default function AsymmetricCryptographyJsunit() { 0, async function (done) { await asyPromise - .signAndVerifyNormalProcess("ECC512", "ECC512|SHA384") + .signAndVerifyNormalProcess("ECC521", "ECC521|SHA384") .then((data) => { expect(data == null).assertTrue(); }) @@ -1227,7 +1227,7 @@ export default function AsymmetricCryptographyJsunit() { /** * @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDH_0400 - * @tc.name Test ECC512 SignVerify ECDH + * @tc.name Test ECC521 SignVerify ECDH * @tc.desc Use the Callback Style of Interface */ it( @@ -1235,7 +1235,7 @@ export default function AsymmetricCryptographyJsunit() { 0, async function (done) { await asyCallback - .keyAgreementProcess("ECC512") + .keyAgreementProcess("ECC521") .then((data) => { expect(data == null).assertTrue(); }) @@ -1322,7 +1322,7 @@ export default function AsymmetricCryptographyJsunit() { 0, async function (done) { await asyCallback - .keyAgreementProcessFail("RSA3072", "ECC512") + .keyAgreementProcessFail("RSA3072", "ECC521") .then((data) => { expect(data == "Error: An exception occurs.").assertTrue(); }) diff --git a/security/cryptoFramework/js_api_test_one/src/main/js/test/List.test.js b/security/cryptoFramework/js_api_test_one/src/main/js/test/List.test.js index 1bbe4a625ce4894ecd45bf1af09d13f4d9a4780d..628efc6671cdfd8b5c1cd1f66b31a6924222c7e9 100644 --- a/security/cryptoFramework/js_api_test_one/src/main/js/test/List.test.js +++ b/security/cryptoFramework/js_api_test_one/src/main/js/test/List.test.js @@ -16,9 +16,11 @@ import SymmetricCryptographyJsunit from "./SymmetricCryptography.test"; import AsymmetricCryptographyJsunit from "./AsymmetricCryptography.test"; import DigestAlgorithmJsunit from "./DigestAlgorithm.test"; +import SecurityRandomJsunit from "./SecurityRandom.test"; export default function testsuite() { SymmetricCryptographyJsunit(); AsymmetricCryptographyJsunit(); DigestAlgorithmJsunit(); + SecurityRandomJsunit(); } diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/test/SecurityRandom.test.js b/security/cryptoFramework/js_api_test_one/src/main/js/test/SecurityRandom.test.js similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/test/SecurityRandom.test.js rename to security/cryptoFramework/js_api_test_one/src/main/js/test/SecurityRandom.test.js diff --git a/security/cryptoFramework/js_api_test_one/src/main/js/test/utils/common/publicDoString.js b/security/cryptoFramework/js_api_test_one/src/main/js/test/utils/common/publicDoString.js index 64853226a6312821cdcc385434e887516d5058f8..42c118c5d2f34cf70708d14d3f846ac236a98c90 100644 --- a/security/cryptoFramework/js_api_test_one/src/main/js/test/utils/common/publicDoString.js +++ b/security/cryptoFramework/js_api_test_one/src/main/js/test/utils/common/publicDoString.js @@ -67,7 +67,7 @@ function genIvParamsSpec(n) { var dataBlob = { data: dataIv }; var ivParamSpec = { iv: dataBlob, - algoName: "IvParamsSpec", + algName: "IvParamsSpec", }; return ivParamSpec; } @@ -86,7 +86,7 @@ function genGcmParamsSpec() { iv: ivBlob, aad: aadBlob, authTag: tagBlob, - algoName: "GcmParamsSpec", + algName: "GcmParamsSpec", }; return gcmParamsSpec; } @@ -105,7 +105,7 @@ function genCcmParamsSpec() { iv: ivBlob, aad: aadBlob, authTag: tagBlob, - algoName: "CcmParamsSpec", + algName: "CcmParamsSpec", }; return ccmParamsSpec; } diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/test/utils/securityrandom/publicSecurityRandomCallback.js b/security/cryptoFramework/js_api_test_one/src/main/js/test/utils/securityrandom/publicSecurityRandomCallback.js similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/test/utils/securityrandom/publicSecurityRandomCallback.js rename to security/cryptoFramework/js_api_test_one/src/main/js/test/utils/securityrandom/publicSecurityRandomCallback.js diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/test/utils/securityrandom/publicSecurityRandomCommon.js b/security/cryptoFramework/js_api_test_one/src/main/js/test/utils/securityrandom/publicSecurityRandomCommon.js similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/test/utils/securityrandom/publicSecurityRandomCommon.js rename to security/cryptoFramework/js_api_test_one/src/main/js/test/utils/securityrandom/publicSecurityRandomCommon.js diff --git a/security/cryptoFramework/js_api_test_two/src/main/js/test/utils/securityrandom/publicSecurityRandomPromise.js b/security/cryptoFramework/js_api_test_one/src/main/js/test/utils/securityrandom/publicSecurityRandomPromise.js similarity index 100% rename from security/cryptoFramework/js_api_test_two/src/main/js/test/utils/securityrandom/publicSecurityRandomPromise.js rename to security/cryptoFramework/js_api_test_one/src/main/js/test/utils/securityrandom/publicSecurityRandomPromise.js diff --git a/storage/storagefileiov9jstest/src/main/js/test/List.test.js b/storage/storagefileiov9jstest/src/main/js/test/List.test.js old mode 100755 new mode 100644 index f20e32b321ec3880839c8ac4ac58d68d47d896dd..dcc021d68b67c9f179ceedf6bf032c875618a7fb --- a/storage/storagefileiov9jstest/src/main/js/test/List.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/List.test.js @@ -15,7 +15,7 @@ import fileIOFdatasync from './members/fdatasync.test.js' import fileIOFsync from './members/fsync.test.js' -import fileIOListfile from './members/listfile.test.js' +import fileIOListfile from './members/listFile.test.js' import fileIOLstat from './members/lstat.test.js' import fileIOOpen from './members/open.test.js' import fileIORead from './members/read.test.js' diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/listfile.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/listFile.test.js old mode 100755 new mode 100644 similarity index 86% rename from storage/storagefileiov9jstest/src/main/js/test/members/listfile.test.js rename to storage/storagefileiov9jstest/src/main/js/test/members/listFile.test.js index 78f68a79a2f92071f62b98a7649a82540c594215..4278940ebbb4163df4064f7edddf326279ab5057 --- a/storage/storagefileiov9jstest/src/main/js/test/members/listfile.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/listFile.test.js @@ -53,7 +53,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_SYNC_0100 * @tc.name fileIO_test_listfile_sync_001 - * @tc.desc Test listFileSync()interfaces. + * @tc.desc Test listFileSync() interfaces. * Do not have prop filter.Filter files by quantity only. * @tc.size MEDIUM * @tc.type Function @@ -86,7 +86,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_SYNC_0200 * @tc.name fileIO_test_listfile_sync_002 - * @tc.desc Test listFileSync()interfaces. + * @tc.desc Test listFileSync() interfaces. * Do not have prop listNum. * @tc.size MEDIUM * @tc.type Function @@ -125,7 +125,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_SYNC_0300 * @tc.name fileIO_test_listfile_sync_003 - * @tc.desc Test listFileSync()interfaces. + * @tc.desc Test listFileSync() interfaces. * Do not have prop suffix. Not filter files by suffix. * @tc.size MEDIUM * @tc.type Function @@ -164,15 +164,15 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_SYNC_0400 * @tc.name fileIO_test_listfile_sync_004 - * @tc.desc Test listFileSync()interfaces. + * @tc.desc Test listFileSync() interfaces. * Scanfile.Retain six files in the three-level directory. * @tc.size MEDIUM * @tc.type Function * @tc.level Level 0 * @tc.require */ - it('fileio_test_listfile_sync_004', 0, async function () { - let dpath = await nextFileName('fileio_test_listfile_sync_004'); + it('fileIO_test_listfile_sync_004', 0, async function () { + let dpath = await nextFileName('fileIO_test_listfile_sync_004'); let fpath1 = dpath + '/listfile_sync_004.txt'; let fpath2 = dpath + '/listfile_sync_004.doc'; let fpath3 = dpath + '/listfile_sync_004.png'; @@ -214,7 +214,7 @@ export default function fileIOListfile() { expect(dirents.length == 6).assertTrue(); fileIO.rmdirSync(dpath); } catch (err) { - console.log('fileio_test_listfile_sync_004 has failed for ' + err.message + ', code:' + err.code); + console.log('fileIO_test_listfile_sync_004 has failed for ' + err.message + ', code:' + err.code); expect(false).assertTrue(); } }); @@ -222,7 +222,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_SYNC_0500 * @tc.name fileIO_test_listfile_sync_005 - * @tc.desc Test listFileSync()interfaces. + * @tc.desc Test listFileSync() interfaces. * Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained. * @tc.size MEDIUM * @tc.type Function @@ -244,14 +244,14 @@ export default function fileIOListfile() { try { let time = new Date().getTime() / 1000; let dirents = fileIO.listFileSync(dpath, { - listNum: 3, - recursion: false, - filter:{ - suffix: [".txt"], - displayName: ["*listfile*", "*time*"], - fileSizeOver: 4, - lastModifiedAfter: time - 3 - } + listNum: 3, + recursion: false, + filter:{ + suffix: [".txt"], + displayName: ["*listfile*", "*time*"], + fileSizeOver: 4, + lastModifiedAfter: time - 3 + } }); expect(dirents.length == 2).assertTrue(); fileIO.rmdirSync(dpath); @@ -264,7 +264,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_SYNC_0600 * @tc.name fileIO_test_listfile_sync_006 - * @tc.desc Test listFileSync()interfaces. + * @tc.desc Test listFileSync() interfaces. * Invalid file suffix name format. * @tc.size MEDIUM * @tc.type Function @@ -284,27 +284,27 @@ export default function fileIOListfile() { try { let time = new Date().getTime() / 1000; fileIO.listFileSync(dpath, { - listNum: 3, - recursion: false, - filter:{ - suffix: ["%.txt%"], - displayName: ["*listfile*"], - fileSizeOver: 0, - lastModifiedAfter: time -3 - } + listNum: 3, + recursion: false, + filter:{ + suffix: ["%.txt%"], + displayName: ["*listfile*"], + fileSizeOver: 0, + lastModifiedAfter: time -3 + } }); expect(false).assertTrue(); } catch (err) { fileIO.rmdirSync(dpath); console.log('fileIO_test_listfile_sync_006 has failed for ' + err.message + ', code:' + err.code); - expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue; + expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue(); } }); /** * @tc.number SUB_DF_FILEIO_LISTFILE_SYNC_0700 * @tc.name fileIO_test_listfile_sync_007 - * @tc.desc Test listFileSync()interfaces. + * @tc.desc Test listFileSync() interfaces. * Filter out all files because the size of all files less than 12. * @tc.size MEDIUM * @tc.type Function @@ -344,8 +344,8 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_SYNC_0800 * @tc.name fileIO_test_listfile_sync_008 - * @tc.desc Test listFileSync()interfaces. - * listNUm is 0.Traverse all files. + * @tc.desc Test listFileSync() interfaces. + * listNum is 0.Traverse all files. * @tc.size MEDIUM * @tc.type Function * @tc.level Level 0 @@ -386,7 +386,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_SYNC_0900 * @tc.name fileIO_test_listfile_sync_009 - * @tc.desc Test listFileSync()interfaces. + * @tc.desc Test listFileSync() interfaces. * Missing all arguments. * @tc.size MEDIUM * @tc.type Function @@ -400,14 +400,14 @@ export default function fileIOListfile() { expect(false).assertTrue(); } catch (err) { console.log('fileIO_test_listfile_sync_009 has failed for ' + err.message + ', code:' + err.code); - expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue; + expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue(); } }); /** * @tc.number SUB_DF_FILEIO_LISTFILE_SYNC_1000 * @tc.name fileIO_test_listfile_sync_010 - * @tc.desc Test listFileSync()interfaces. + * @tc.desc Test listFileSync() interfaces. * Invalid option args. * @tc.size MEDIUM * @tc.type Function @@ -430,13 +430,13 @@ export default function fileIOListfile() { } catch (err) { fileIO.rmdirSync(dpath); console.log('fileIO_test_listfile_sync_010 has failed for ' + err.message + ', code:' + err.code); - expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue; + expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue(); } }); /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_0000 * @tc.name fileIO_test_listfile_async_000 - * @tc.desc Test listFile() interface. return in Callback mode. + * @tc.desc Test listFile() interface. Callback. * Only path, do not filter file. * @tc.size MEDIUM * @tc.type Function @@ -455,15 +455,15 @@ export default function fileIOListfile() { try { fileIO.listFile(dpath, (err, dirents) => { - if (err) { - console.log('fileIO_test_listfile_async_000 err package ' + JSON.stringify(err)); - expect(false).assertTrue(); - } - expect(dirents.length == 3).assertTrue(); - fileIO.rmdirSync(dpath); + if (err) { + console.log('fileIO_test_listfile_async_000 err package ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(dirents.length == 3).assertTrue(); + fileIO.rmdirSync(dpath); }); } catch (e) { - console.info('fileio_test_listfile_async_000 has failed for ' + e.message + ', code:' + e.code); + console.info('fileIO_test_listfile_async_000 has failed for ' + e.message + ', code:' + e.code); expect(false).assertTrue(); } }); @@ -471,7 +471,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_0100 * @tc.name fileIO_test_listfile_async_001 - * @tc.desc Test listFile() interface. return in Promise mode. + * @tc.desc Test listFile() interface. Promise. * Only path, do not filter file. * @tc.size MEDIUM * @tc.type Function @@ -502,7 +502,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_0200 * @tc.name fileIO_test_listfile_async_002 - * @tc.desc Test listFile()interfaces.return in Callback mode. + * @tc.desc Test listFile() interfaces. Callback. * Do not have prop filter.Filter files by quantity only. * @tc.size MEDIUM * @tc.type Function @@ -521,12 +521,12 @@ export default function fileIOListfile() { try { fileIO.listFile(dpath, { - listNum: 2, - recursion: false - }, (err, dirents) => { + listNum: 2, + recursion: false + }, (err, dirents) => { if (err) { - console.log('fileIO_test_listfile_async_002 err package ' + JSON.stringify(err)); - expect(false).assertTrue(); + console.log('fileIO_test_listfile_async_002 err package ' + JSON.stringify(err)); + expect(false).assertTrue(); } expect(dirents.length == 2).assertTrue(); fileIO.rmdirSync(dpath); @@ -540,7 +540,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_0300 * @tc.name fileIO_test_listfile_async_003 - * @tc.desc Test listFile() interfaces.return in Promise mode. + * @tc.desc Test listFile() interfaces. Promise. * Do not have prop filter.Filter files by quantity only. * @tc.size MEDIUM * @tc.type Function @@ -574,7 +574,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_0400 * @tc.name fileIO_test_listfile_async_004 - * @tc.desc Test listFile() interface. return in Callback mode. + * @tc.desc Test listFile() interface. Callback. * Do not have prop listNum. * @tc.size MEDIUM * @tc.type Function @@ -594,17 +594,17 @@ export default function fileIOListfile() { try { let time = new Date().getTime() / 1000; fileIO.listFile(dpath, { - recursion: false, - filter:{ - suffix: [".txt", ".doc", ".png"], - displayName: ["*listfile*"], - fileSizeOver: 0, - lastModifiedAfter: time - 3 - } - }, (err, dirents) => { + recursion: false, + filter:{ + suffix: [".txt", ".doc", ".png"], + displayName: ["*listfile*"], + fileSizeOver: 0, + lastModifiedAfter: time - 3 + } + }, (err, dirents) => { if (err) { - console.log('fileIO_test_listfile_async_004 err package ' + JSON.stringify(err)); - expect(false).assertTrue(); + console.log('fileIO_test_listfile_async_004 err package ' + JSON.stringify(err)); + expect(false).assertTrue(); } expect(dirents.length == 3).assertTrue(); fileIO.rmdirSync(dpath); @@ -618,7 +618,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_0500 * @tc.name fileIO_test_listfile_async_005 - * @tc.desc Test listFile() interface. return in Promise mode. + * @tc.desc Test listFile() interface. Promise. * Do not have prop listNum. * @tc.size MEDIUM * @tc.type Function @@ -658,7 +658,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_0600 * @tc.name fileIO_test_listfile_async_006 - * @tc.desc Test listFile() interface. return in Callback mode. + * @tc.desc Test listFile() interface. Callback. * Do not have prop suffix. Not filter files by suffix. * @tc.size MEDIUM * @tc.type Function @@ -678,14 +678,14 @@ export default function fileIOListfile() { try { let time = new Date().getTime() / 1000; fileIO.listFile(dpath, { - listNum: 4, - recursion: false, - filter:{ - displayName: ["*listfile*"], - fileSizeOver: 5, - lastModifiedAfter: time - 3 - } - }, (err, dirents) => { + listNum: 4, + recursion: false, + filter:{ + displayName: ["*listfile*"], + fileSizeOver: 5, + lastModifiedAfter: time - 3 + } + }, (err, dirents) => { if (err) { console.log('fileIO_test_listfile_async_006 err package ' + JSON.stringify(err)); expect(false).assertTrue(); @@ -702,7 +702,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_0700 * @tc.name fileIO_test_listfile_async_007 - * @tc.desc Test listFile() interface. return in Promise mode. + * @tc.desc Test listFile() interface. Promise. * Do not have prop suffix. Not filter files by suffix. * @tc.size MEDIUM * @tc.type Function @@ -742,7 +742,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_0800 * @tc.name fileIO_test_listfile_async_008 - * @tc.desc Test listFile()interfaces.return in Callback mode. + * @tc.desc Test listFile() interfaces. Callback. * Scanfile.Retain six files in the three-level directory. * @tc.size MEDIUM * @tc.type Function @@ -780,22 +780,22 @@ export default function fileIOListfile() { try { let time = new Date().getTime() / 1000; fileIO.listFile(dpath, { - listNum: 6, - recursion: true, - filter:{ - suffix: [".txt", ".doc"], - displayName: ["*listfile*", "*first*", "*akasd*", "*tdd*", "*makef*"], - fileSizeOver: 0, - lastModifiedAfter: time - 3 - } - }, (err, dirents) => { - if (err) { - console.log('fileIO_test_listfile_async_008 err package ' + JSON.stringify(err)); - expect(false).assertTrue(); - } - expect(dirents.length == 6).assertTrue(); - fileIO.rmdirSync(dpath); - }); + listNum: 6, + recursion: true, + filter:{ + suffix: [".txt", ".doc"], + displayName: ["*listfile*", "*first*", "*akasd*", "*tdd*", "*makef*"], + fileSizeOver: 0, + lastModifiedAfter: time - 3 + } + }, (err, dirents) => { + if (err) { + console.log('fileIO_test_listfile_async_008 err package ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(dirents.length == 6).assertTrue(); + fileIO.rmdirSync(dpath); + }); } catch (e) { console.log('fileIO_test_listfile_async_008 has failed for ' + e.message + ', code:' + e.code); expect(false).assertTrue(); @@ -805,7 +805,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_0900 * @tc.name fileIO_test_listfile_async_009 - * @tc.desc Test listFile()interfaces.return in Promise mode. + * @tc.desc Test listFile() interfaces. Promise. * Scanfile.Retain six files in the three-level directory. * @tc.size MEDIUM * @tc.type Function @@ -864,7 +864,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_1000 * @tc.name fileIO_test_listfile_async_010 - * @tc.desc Test listFile()interfaces.return in Callback mode. + * @tc.desc Test listFile() interfaces. Callback. * Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained. * @tc.size MEDIUM * @tc.type Function @@ -886,18 +886,18 @@ export default function fileIOListfile() { try { let time = new Date().getTime() / 1000; fileIO.listFile(dpath, { - listNum: 3, - recursion: false, - filter:{ - suffix: [".txt"], - displayName: ["*listfile*", "*time*"], - fileSizeOver: 4, - lastModifiedAfter: time - 3 - } + listNum: 3, + recursion: false, + filter:{ + suffix: [".txt"], + displayName: ["*listfile*", "*time*"], + fileSizeOver: 4, + lastModifiedAfter: time - 3 + } }, (err, dirents) => { if (err) { - console.log('fileIO_test_listfile_async_010 err package ' + JSON.stringify(err)); - expect(false).assertTrue(); + console.log('fileIO_test_listfile_async_010 err package ' + JSON.stringify(err)); + expect(false).assertTrue(); } expect(dirents.length == 2).assertTrue(); fileIO.rmdirSync(dpath); @@ -911,7 +911,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_1100 * @tc.name fileIO_test_listfile_async_011 - * @tc.desc Test listFile()interfaces.return in Promise mode. + * @tc.desc Test listFile() interfaces. Promise. * Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained. * @tc.size MEDIUM * @tc.type Function @@ -954,7 +954,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_1200 * @tc.name fileIO_test_listfile_async_012 - * @tc.desc Test listFile()interfaces.return in Callback mode. + * @tc.desc Test listFile() interfaces. Callback. * Invalid file suffix name format. * @tc.size MEDIUM * @tc.type Function @@ -976,32 +976,28 @@ export default function fileIOListfile() { try { let time = new Date().getTime() / 1000; fileIO.listFile(dpath, { - listNum: 3, - recursion: false, - filter:{ - suffix: ["%.txt%"], - displayName: ["*listfile*"], - fileSizeOver: 0, - lastModifiedAfter: time -3 - } - }, (err) => { - if (err) { - console.log('fileIO_test_listfile_async_012 err package ' + JSON.stringify(err)); - expect(false).assertTrue(); + listNum: 3, + recursion: false, + filter:{ + suffix: ["%.txt%"], + displayName: ["*listfile*"], + fileSizeOver: 0, + lastModifiedAfter: time -3 } - expect(false).assertTrue(); + }, (err) => { + expect(false).assertTrue(); }); } catch (e) { fileIO.rmdirSync(dpath); console.log('fileIO_test_listfile_async_012 has failed for ' + e.message + ', code:' + e.code); - expect(e.code == 13900020 && e.message == 'Invalid argunment').assertTrue; + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); } }); /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_1300 * @tc.name fileIO_test_listfile_async_013 - * @tc.desc Test listFile()interfaces.return in Promise mode. + * @tc.desc Test listFile() interfaces. Promise. * Invalid file suffix name format. * @tc.size MEDIUM * @tc.type Function @@ -1027,16 +1023,16 @@ export default function fileIOListfile() { recursion: false, filter:{ suffix: ["%.txt%"], - displayName: ["*listfile_async_013*"], + displayName: ["*listfile*"], fileSizeOver: 0, lastModifiedAfter: time -3 } - }); + }); expect(false).assertTrue(); } catch (err) { fileIO.rmdirSync(dpath); console.log('fileIO_test_listfile_async_013 has failed for ' + err.message + ', code:' + err.code); - expect(err.code == 13900020 && err.message == 'Invalid argunment').assertTrue; + expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue(); done(); } }); @@ -1044,7 +1040,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_1400 * @tc.name fileIO_test_listfile_async_014 - * @tc.desc Test listFile()interfaces.return in Callback mode. + * @tc.desc Test listFile() interfaces. Callback. * Filter out all files because the size of all files less than 12. * @tc.size MEDIUM * @tc.type Function @@ -1064,21 +1060,21 @@ export default function fileIOListfile() { try { let time = new Date().getTime() / 1000; fileIO.listFile(dpath, { - listNum: 3, - recursion: false, - filter:{ - suffix: [".txt"], - displayName: ["*listfile*"], - fileSizeOver: 12, - lastModifiedAfter: time - 3 - } - }, (err, dirents) => { - if (err) { + listNum: 3, + recursion: false, + filter:{ + suffix: [".txt"], + displayName: ["*listfile*"], + fileSizeOver: 12, + lastModifiedAfter: time - 3 + } + }, (err, dirents) => { + if (err) { console.log('fileIO_test_listfile_async_014 err package ' + JSON.stringify(err)); expect(false).assertTrue(); - } - expect(dirents.length == 0).assertTrue(); - fileIO.rmdirSync(dpath); + } + expect(dirents.length == 0).assertTrue(); + fileIO.rmdirSync(dpath); }); } catch (e) { console.log('fileIO_test_listfile_async_014 has failed for ' + e.message + ', code:' + e.code); @@ -1089,7 +1085,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_1500 * @tc.name fileIO_test_listfile_async_015 - * @tc.desc Test listFile()interfaces.return in Promise mode. + * @tc.desc Test listFile() interfaces. Promise. * Filter out all files because the size of all files less than 12. * @tc.size MEDIUM * @tc.type Function @@ -1130,8 +1126,8 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_1600 * @tc.name fileIO_test_listfile_async_016 - * @tc.desc Test listFile()interfaces.return in Callback mode. - * listNUm is 0.Traverse all files. + * @tc.desc Test listFile() interfaces. Callback. + * listNum is 0.Traverse all files. * @tc.size MEDIUM * @tc.type Function * @tc.level Level 0 @@ -1152,22 +1148,22 @@ export default function fileIOListfile() { try { let time = new Date().getTime() / 1000; fileIO.listFile(dpath, { - listNum: 0, - recursion: false, - filter:{ - suffix: [".txt"], - displayName: ["*listfile*", "*trespass*"], - fileSizeOver: 5, - lastModifiedAfter: time - 3 - } - }, (err, dirents) => { - if (err) { + listNum: 0, + recursion: false, + filter:{ + suffix: [".txt"], + displayName: ["*listfile*", "*trespass*"], + fileSizeOver: 5, + lastModifiedAfter: time - 3 + } + }, (err, dirents) => { + if (err) { console.log('fileIO_test_listfile_async_016 err package ' + JSON.stringify(err)); expect(false).assertTrue(); - } - expect(dirents.length == 2).assertTrue(); - fileIO.rmdirSync(dpath); - }); + } + expect(dirents.length == 2).assertTrue(); + fileIO.rmdirSync(dpath); + }); } catch (err) { console.log('fileIO_test_listfile_async_016 has failed for ' + err.message + ', code:' + err.code); expect(false).assertTrue(); @@ -1177,8 +1173,8 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_1700 * @tc.name fileIO_test_listfile_async_017 - * @tc.desc Test listFile()interfaces.return in Promise mode. - * listNUm is 0.Traverse all files. + * @tc.desc Test listFile() interfaces. Promise. + * listNum is 0.Traverse all files. * @tc.size MEDIUM * @tc.type Function * @tc.level Level 0 @@ -1220,7 +1216,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_1800 * @tc.name fileIO_test_listfile_async_018 - * @tc.desc Test listFile()interfaces.return in Promise mode. + * @tc.desc Test listFile() interfaces. Promise. * Missing all arguments. * @tc.size MEDIUM * @tc.type Function @@ -1234,7 +1230,7 @@ export default function fileIOListfile() { expect(false).assertTrue(); } catch (err) { console.log('fileIO_test_listfile_async_018 has failed for ' + err.message + ', code:' + err.code); - expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue; + expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue(); done(); } }); @@ -1242,7 +1238,7 @@ export default function fileIOListfile() { /** * @tc.number SUB_DF_FILEIO_LISTFILE_ASYNC_1900 * @tc.name fileIO_test_listfile_async_019 - * @tc.desc Test listFile()interfaces.return in Promise mode. + * @tc.desc Test listFile() interfaces. Promise. * Invalid option args. * @tc.size MEDIUM * @tc.type Function @@ -1265,7 +1261,7 @@ export default function fileIOListfile() { } catch (err) { fileIO.rmdirSync(dpath); console.log('fileIO_test_listfile_async_019 has failed for ' + err.message + ', code:' + err.code); - expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue; + expect(err.code == 13900020 && err.message == 'Invalid argument').assertTrue(); done(); } }); diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/lstat.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/lstat.test.js new file mode 100644 index 0000000000000000000000000000000000000000..c1e055596a2e0df1a1ab1d03ae82d73a664f42c0 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/test/members/lstat.test.js @@ -0,0 +1,1707 @@ +/* + * Copyright (C) 2023 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 { + fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBoolean, isBigInt, + describe, it, expect, +} from '../Common'; + +export default function fileIOLstat() { +describe('fileIO_fs_lstat', function () { + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_SYNC_0000 + * @tc.name fileIO_lstat_sync_000 + * @tc.desc Test lstatSync() interface. + * Enter the path parameter to get the file stat. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_sync_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_sync_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(stat !== null).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_sync_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_SYNC_0100 + * @tc.name fileIO_lstat_sync_001 + * @tc.desc Test lstatSync() interface. + * The path point to nothing, no such file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_sync_001', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_sync_001'); + + try { + fileIO.lstatSync(fpath); + expect(false).assertTrue(); + } catch (e) { + console.log('fileIO_lstat_sync_001 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_SYNC_0200 + * @tc.name fileIO_lstat_sync_002 + * @tc.desc Test lstatSync() interface. + * Missing parameters. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_sync_002', 0, async function () { + + try { + fileIO.lstatSync(); + expect(false).assertTrue(); + } catch (e) { + console.log('fileIO_lstat_sync_002 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + } + }); + /** + * @tc.number SUB_DF_FILEIO_LSTAT_INO_0000 + * @tc.name fileIO_lstat_ino_000 + * @tc.desc Test the ino member of class Stat. + * Enter the path parameter to get stat.ino of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_ino_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_ino_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + try { + let stat = fileIO.lstatSync(fpath); + expect(isBigInt(stat.ino)).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_ino_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_MODE_0000 + * @tc.name fileIO_lstat_mode_000 + * @tc.desc Test the mode member of class Stat. + * Enter the path parameter to get stat.mode of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_mode_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_mode_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(isIntNum(stat.mode)).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_mode_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_UID_0000 + * @tc.name fileIO_lstat_uid_000 + * @tc.desc Test the uid member of class Stat. + * Enter the path parameter to get stat.uid of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_uid_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_uid_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(isIntNum(stat.uid)).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_uid_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_GID_0000 + * @tc.name fileIO_lstat_gid_000 + * @tc.desc Test the gid member of class Stat. + * Enter the path parameter to get stat.gid of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_gid_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_gid_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(isIntNum(stat.gid)).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_gid_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_SIZE_0000 + * @tc.name fileIO_lstat_size_000 + * @tc.desc Test the size member of class Stat. + * Enter the path parameter to get stat.size of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_size_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_size_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(isIntNum(stat.size)).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_size_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ATIME_0000 + * @tc.name fileIO_lstat_atime_000 + * @tc.desc Test the atime member of class Stat. + * Enter the path or parameter to get stat.atime of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_atime_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_atime_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(isIntNum(stat.atime)).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_atime_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_MTIME_0000 + * @tc.name fileIO_lstat_mtime_000 + * @tc.desc Test the mtime member of class Stat. + * Enter the path parameter to get stat.mtime of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_mtime_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_mtime_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(isIntNum(stat.mtime)).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_mtime_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_CTIME_0000 + * @tc.name fileIO_lstat_ctime_000 + * @tc.desc Test the ctime member of class Stat. + * Enter the path parameter to get stat.ctime of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_ctime_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_ctime_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(isIntNum(stat.ctime)).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_ctime_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_BLOCK_DEVICE_0000 + * @tc.name fileIO_lstat_is_block_device_000 + * @tc.desc Test Lstat.isBlockDevice() interface. + * This interface shall not treat a normal file as a block special device. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_is_block_device_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_is_block_device_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(stat.isBlockDevice() === false).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_is_block_device_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_BLOCK_DEVICE_0100 + * @tc.name fileIO_test_lstat_is_block_device_001 + * @tc.desc Test Lstat.isBlockDevice() interface. + * This interface does not require parameters. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_test_lstat_is_block_device_001', 0, async function () { + let fpath = await nextFileName('fileIO_test_lstat_is_block_device_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstatSync(fpath).isBlockDevice(-1); + expect(false).assertTrue(); + } catch (e) { + fileIO.unlinkSync(fpath); + console.info('fileIO_test_lstat_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_CHARACTER_DEVICE_0000 + * @tc.name fileIO_lstat_is_character_device_000 + * @tc.desc Test Lstat.isCharacterDevice() interface. + * This interface shall not treat a normal file as a character special device. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_is_character_device_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_is_character_device_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(stat.isCharacterDevice() === false).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_is_character_device_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_CHARACTER_DEVICE_0100 + * @tc.name fileIO_lstat_is_character_device_001 + * @tc.desc Test Lstat.isCharacterDevice() interface. + * This interface does not require parameters. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_test_lstat_is_character_device_001', 0, async function () { + let fpath = await nextFileName('fileIO_test_lstat_is_character_device_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstatSync(fpath).isCharacterDevice(-1); + expect(false).assertTrue(); + } catch (e) { + fileIO.unlinkSync(fpath); + console.log('fileIO_test_lstat_is_character_device_001 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_DIRECTORY_0000 + * @tc.name fileIO_lstat_is_directory_000 + * @tc.desc Test Lstat.isDirectory() interface. + * This interface shall not treat a normal file as a directory. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_is_directory_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_is_directory_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(stat.isDirectory() === false).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_is_directory_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_DIRECTORY_0100 + * @tc.name fileIO_lstat_is_directory_001 + * @tc.desc Test Lstat.isDirectory() interface. + * This interface shall treat a directory as a directory. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_is_directory_001', 0, async function () { + let dpath = await nextFileName('fileIO_lstat_is_directory_001') + 'd'; + + try { + fileIO.mkdirSync(dpath); + let stat = fileIO.lstatSync(dpath); + expect(stat.isDirectory() === true).assertTrue(); + fileIO.rmdirSync(dpath); + } catch (e) { + console.log('fileIO_lstat_is_directory_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_DIRECTORY_0200 + * @tc.name fileIO_lstat_is_directory_002 + * @tc.desc Test Lstat.isDirectory() interface. + * This interface does not require parameters. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_is_directory_002', 0, async function () { + let dpath = await nextFileName('fileIO_lstat_is_directory_002') + 'd'; + + try { + fileIO.mkdirSync(dpath); + fileIO.lstatSync(dpath).isDirectory(-1); + expect(false).assertTrue(); + } catch (e) { + fileIO.rmdirSync(dpath); + console.log('fileIO_lstat_is_directory_002 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_FIFO_0000 + * @tc.name fileIO_lstat_is_fifo_000 + * @tc.desc Test Lstat.isFIFO() interface. + * This interface shall not treat a normal file as a FIFO. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_is_fifo_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_is_fifo_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(stat.isFIFO() === false).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_is_fifo_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_FIFO_0100 + * @tc.name fileIO_lstat_is_fifo_001 + * @tc.desc Test Lstat.isFIFO() interface. + * This interface does not require parameters. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_test_lstat_is_fifo_002', 0, async function () { + let fpath = await nextFileName('fileIO_test_lstat_is_fifo_002'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstatSync(fpath).isFIFO(-1); + expect(false).assertTrue(); + } catch (e) { + fileIO.unlinkSync(fpath); + console.log('fileIO_test_lstat_is_fifo_002 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_FILE_0000 + * @tc.name fileIO_lstat_is_file_000 + * @tc.desc Test Lstat.isFile() interface. + * This interface shall treat a normal file as a normal file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_is_file_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_is_file_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(stat.isFile() === true).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_is_file_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_FILE_0100 + * @tc.name fileIO_lstat_is_file_001 + * @tc.desc Test Lstat.isFile() interface. + * This interface shall not treat a directory as a normal file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_is_file_001', 0, async function () { + let dpath = await nextFileName('fileIO_lstat_is_file_001'); + + try { + fileIO.mkdirSync(dpath); + let stat = fileIO.lstatSync(dpath); + expect(stat.isFile() === false).assertTrue(); + fileIO.rmdirSync(dpath); + } catch (e) { + console.log('fileIO_lstat_is_file_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_FILE_0200 + * @tc.name fileIO_test_lstat_is_file_002 + * @tc.desc Test Lstat.isFile() interface. + * This interface does not require parameters. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_test_lstat_is_file_002', 0, async function () { + let dpath = await nextFileName('fileIO_test_lstat_is_file_002'); + + try { + fileIO.mkdirSync(dpath); + fileIO.lstatSync(dpath).isFile(-1); + expect(false).assertTrue(); + } catch (e) { + fileIO.rmdirSync(dpath); + console.log('fileIO_test_lstat_is_file_002 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_SOCKET_0000 + * @tc.name fileIO_lstat_is_socket_000 + * @tc.desc Test Lstat.isSocket() interface. + * This interface shall not treat a file as a socket. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_is_socket_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_is_socket_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(stat.isSocket() === false).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_lstat_is_socket_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_SOCKET_0100 + * @tc.name fileIO_lstat_is_socket_001 + * @tc.desc Test Lstat.isSocket() interface. + * This interface does not require parameters. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_is_socket_001', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_is_socket_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstatSync(fpath).isSocket(-1); + expect(false).assertTrue(); + } catch (e) { + fileIO.unlinkSync(fpath); + console.log('fileIO_lstat_is_socket_001 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_SYMBOLIC_LINK_0000 + * @tc.name fileIO_lstat_is_symbolic_link_000 + * @tc.desc Test Lstat.isSymbolicLink() interface. + * This interface shall not treat a normal file as a symbolic link. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_is_symbolic_link_000', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_is_symbolic_link_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(stat.isSymbolicLink() === false).assertTrue(); + } catch (e) { + fileIO.unlinkSync(fpath); + console.log('fileIO_lstat_is_symbolic_link_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_IS_SYMBOLIC_LINK_0100 + * @tc.name fileIO_lstat_is_symbolic_link_001 + * @tc.desc Test Lstat.isSymbolicLink() interface. + * This interface does not require parameters. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_is_symbolic_link_001', 0, async function () { + let fpath = await nextFileName('fileIO_lstat_is_symbolic_link_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstatSync(fpath).isSymbolicLink(-1); + expect(false).assertTrue(); + } catch (e) { + fileIO.unlinkSync(fpath); + console.log('fileIO_lstat_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_0000 + * @tc.name fileIO_lstat_async_000 + * @tc.desc Test lstat() interface. Promise.then().catch() + * Enter the path parameter to get the file stat. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath).then((stat) => { + expect(stat !== null).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }).catch((err) => { + console.log('fileIO_lstat_async_000 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + }); + } catch (e) { + console.log('fileIO_lstat_async_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_0100 + * @tc.name fileIO_lstat_async_001 + * @tc.desc Test lstat() interface. Callback. + * Enter the path or parameter to get the file stat. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err) => { + if(err) { + console.log('fileIO_lstat_async_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_0200 + * @tc.name fileIO_lstat_async_002 + * @tc.desc Test lstat() interface. Promise. + * Enter the path or parameter to get the file stat. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_002', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_002'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(stat !== null).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_002 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_0300 + * @tc.name fileIO_lstat_async_003 + * @tc.desc Test lstat() interface. + * The path point to nothing, no such file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_003', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_003'); + + try { + fileIO.lstat(fpath, (err) => { + if (err) { + console.log('fileIO_lstat_async_003 error package: {' + err.message + ', code: ' + err.code + '}'); + expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue(); + done(); + } + }); + } catch (e) { + console.log('fileIO_lstat_async_003 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_0400 + * @tc.name fileIO_lstat_async_004 + * @tc.desc Test lstat() interface. Promise. + * The path point to nothing, no such file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_004', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_004'); + + try { + await fileIO.lstat(fpath); + expect(false).assertTrue(); + } catch (e) { + console.log('fileIO_lstat_async_004 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue(); + done(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_INO_0000 + * @tc.name fileIO_lstat_async_ino_000 + * @tc.desc Test the ino member of class Stat. Promise. + * Enter the path parameter to get stat.ino of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_ino_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_ino_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(isBigInt(stat.ino)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_ino_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_INO_0100 + * @tc.name fileIO_lstat_async_ino_001 + * @tc.desc Test the ino member of class Stat. Callback. + * Enter the path parameter to get stat.ino of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_ino_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_ino_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if(err) { + console.log('fileIO_lstat_async_ino_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(isBigInt(stat.ino)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_ino_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_MODE_0000 + * @tc.name fileIO_lstat_async_mode_000 + * @tc.desc Test the mode member of class Stat. Promise. + * Enter the path or parameter to get stat.mode of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_mode_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_mode_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(isIntNum(stat.mode)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_mode_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_MODE_0100 + * @tc.name fileIO_lstat_async_mode_001 + * @tc.desc Test the mode member of class Stat. Callback. + * Enter the path or parameter to get stat.mode of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_mode_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_mode_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if(err) { + console.log('fileIO_lstat_async_mode_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(isIntNum(stat.mode)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_mode_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_UID_0000 + * @tc.name fileIO_lstat_async_uid_000 + * @tc.desc Test the uid member of class Stat. Promise. + * Enter the path parameter to get stat.uid of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_uid_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_uid_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(isIntNum(stat.uid)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_uid_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_UID_0100 + * @tc.name fileIO_lstat_async_uid_001 + * @tc.desc Test the uid member of class Stat. Callback. + * Enter the path parameter to get stat.uid of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_uid_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_uid_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if(err) { + console.log('fileIO_lstat_async_uid_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(isIntNum(stat.uid)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_uid_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_GID_0000 + * @tc.name fileIO_lstat_async_gid_000 + * @tc.desc Test the gid member of class Stat. Promise. + * Enter the path parameter to get stat.gid of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_gid_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_gid_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(isIntNum(stat.gid)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_gid_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_GID_0100 + * @tc.name fileIO_lstat_async_gid_001 + * @tc.desc Test the gid member of class Stat. Callback. + * Enter the path parameter to get stat.gid of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_gid_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_gid_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if (err) { + console.log('fileIO_lstat_async_gid_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(isIntNum(stat.gid)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_gid_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_SIZE_0000 + * @tc.name fileIO_lstat_async_size_000 + * @tc.desc Test the size member of class Stat. Promise. + * Enter the path parameter to get stat.size of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_size_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_size_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(isIntNum(stat.size)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_size_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_SIZE_0100 + * @tc.name fileIO_lstat_async_size_001 + * @tc.desc Test the size member of class Stat. Callback. + * Enter the path parameter to get stat.size of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_size_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_size_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if (err) { + console.log('fileIO_lstat_async_size_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(isIntNum(stat.size)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_size_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_ATIME_0000 + * @tc.name fileIO_lstat_async_atime_000 + * @tc.desc Test the atime member of class Stat. Promise. + * Enter the path parameter to get stat.atime of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_atime_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_atime_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(isIntNum(stat.atime)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_atime_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_ATIME_0100 + * @tc.name fileIO_lstat_async_atime_001 + * @tc.desc Test the atime member of class Stat. Callback. + * Enter the path or fd parameter to get stat.atime of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_atime_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_atime_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if (err) { + console.log('fileIO_lstat_async_atime_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(isIntNum(stat.atime)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_atime_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_MTIME_0000 + * @tc.name fileIO_lstat_async_mtime_000 + * @tc.desc Test the mtime member of class Stat. Promise. + * Enter the path or fd parameter to get stat.mtime of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_mtime_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_mtime_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(isIntNum(stat.mtime)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_mtime_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_MTIME_0100 + * @tc.name fileIO_lstat_async_mtime_001 + * @tc.desc Test the mtime member of class Stat. Callback. + * Enter the path or fd parameter to get stat.mtime of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_mtime_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_mtime_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if (err) { + console.log('fileIO_lstat_async_mtime_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(isIntNum(stat.mtime)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_mtime_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_CTIME_0000 + * @tc.name fileIO_lstat_async_ctime_000 + * @tc.desc Test the ctime member of class Stat. Promise. + * Enter the path or fd parameter to get stat.ctime of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_ctime_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_ctime_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(isIntNum(stat.ctime)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_ctime_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_CTIME_0100 + * @tc.name fileIO_lstat_async_ctime_001 + * @tc.desc Test the ctime member of class Stat. Callback. + * Enter the path or fd parameter to get stat.ctime of the file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_ctime_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_ctime_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if (err) { + console.log('fileIO_lstat_async_ctime_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(isIntNum(stat.ctime)).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_ctime_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_BLOCK_DEVICE_0000 + * @tc.name fileIO_lstat_async_is_block_device_000 + * @tc.desc Test the isBlockDevice() method of class Stat. Promise. + * This interface shall not treat a normal file as a block special device. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_block_device_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_is_block_device_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(stat.isBlockDevice() === false).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_is_block_device_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_BLOCK_DEVICE_0010 + * @tc.name fileIO_lstat_async_is_block_device_001 + * @tc.desc Test the isBlockDevice() method of class Stat. Callback. + * This interface shall not treat a normal file as a block special device. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_block_device_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_is_block_device_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if (err) { + console.log('fileIO_lstat_async_is_block_device_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(stat.isBlockDevice() === false).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_CHARACTER_DEVICE_0000 + * @tc.name fileIO_lstat_async_is_character_device_000 + * @tc.desc Test the isCharacterDevice() method of class Stat. Promise. + * This interface shall not treat a normal file as a character special device. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_character_device_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_is_character_device_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(stat.isCharacterDevice() === false).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_is_character_device_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_CHARACTER_DEVICE_0010 + * @tc.name fileIO_lstat_async_is_character_device_001 + * @tc.desc Test the isCharacterDevice() method of class Stat. Callback. + * This interface shall not treat a normal file as a character special device. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_character_device_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_is_character_device_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if (err) { + console.log('fileIO_lstat_async_is_character_device_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(stat.isCharacterDevice() === false).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_is_character_device_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_DIRECTORY_0000 + * @tc.name fileIO_lstat_async_is_directory_000 + * @tc.desc Test the isDirectory() method of class Stat. Promise. + * This interface shall not treat a normal file as a directory. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_directory_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_is_directory_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(stat.isDirectory() === false).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_is_directory_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_DIRECTORY_0010 + * @tc.name fileIO_lstat_async_is_directory_001 + * @tc.desc Test the isDirectory() method of class Stat. Promise. + * This interface shall not treat a directory as a directory. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_directory_001', 0, async function (done) { + let dpath = await nextFileName('fileIO_lstat_async_is_directory_001') + 'd'; + + + try { + fileIO.mkdirSync(dpath); + let stat = await fileIO.lstat(dpath); + expect(stat.isDirectory() === true).assertTrue(); + fileIO.rmdirSync(dpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_is_directory_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_DIRECTORY_0020 + * @tc.name fileIO_lstat_async_is_directory_002 + * @tc.desc Test the isDirectory() method of class Stat. Callback. + * This interface shall not treat a directory as a directory. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_directory_002', 0, async function (done) { + let dpath = await nextFileName('fileIO_lstat_async_is_directory_002') + 'd'; + + try { + fileIO.mkdirSync(dpath); + fileIO.lstat(dpath, (err, stat) => { + if (err) { + console.log('fileIO_lstat_async_is_directory_002 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(stat.isDirectory() === true).assertTrue(); + fileIO.rmdirSync(dpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_is_directory_002 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_FIFO_0000 + * @tc.name fileIO_lstat_async_is_fifo_000 + * @tc.desc Test the isFIFO() method of class Stat. Promise. + * This interface shall not treat a normal file as a FIFO. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_fifo_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_is_fifo_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(stat.isFIFO() === false).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_is_fifo_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_FIFO_0010 + * @tc.name fileIO_lstat_async_is_fifo_001 + * @tc.desc Test the isFIFO() method of class Stat. Callback. + * This interface shall not treat a normal file as a FIFO. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_fifo_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_is_fifo_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if (err) { + console.log('fileIO_lstat_async_is_character_device_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(stat.isFIFO() === false).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_is_fifo_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_FILE_0000 + * @tc.name fileIO_lstat_async_is_file_000 + * @tc.desc Test the isFile() method of class Stat. Promise. + * This interface shall treat a normal file as a normal file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_file_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_is_file_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(stat.isFile() === true).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_is_file_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_FILE_0010 + * @tc.name fileIO_lstat_async_is_file_001 + * @tc.desc Test the isFile() method of class Stat. Callback. + * This interface shall treat a normal file as a normal file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_file_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_is_file_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if (err) { + console.log('fileIO_lstat_async_is_file_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(stat.isFile() === true).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_is_file_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_FILE_0020 + * @tc.name fileIO_lstat_async_is_file_002 + * @tc.desc Test the isFile() method of class Stat. Promise. + * This interface shall not treat a directory as a normal file. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_file_002', 0, async function (done) { + let dpath = await nextFileName('fileIO_lstat_async_is_file_002'); + + try { + fileIO.mkdirSync(dpath); + let stat = await fileIO.lstat(dpath); + expect(stat.isFile() === false).assertTrue(); + fileIO.rmdirSync(dpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_is_file_002 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_SOCKET_0000 + * @tc.name fileIO_lstat_async_is_socket_000 + * @tc.desc Test the isSocket() method of class Stat. Promise. + * This interface shall not treat a file as a socket. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_socket_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_is_socket_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(stat.isSocket() === false).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_is_socket_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_SOCKET_0010 + * @tc.name fileIO_lstat_async_is_socket_001 + * @tc.desc Test the isSocket() method of class Stat. Callback. + * This interface shall not treat a file as a socket. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_socket_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_is_socket_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if (err) { + console.log('fileIO_lstat_async_is_socket_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(stat.isSocket() === false).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_is_socket_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_SYMBOLIC_LINK_0000 + * @tc.name fileIO_lstat_async_is_symbolic_link_000 + * @tc.desc Test the isSymbolicLink() method of class Stat. Promise. + * This interface shall not treat a normal file as a symbolic link. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_symbolic_link_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_is_symbolic_link_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = await fileIO.lstat(fpath); + expect(stat.isSymbolicLink() === false).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + } catch (e) { + console.log('fileIO_lstat_async_is_symbolic_link_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_LSTAT_ASYNC_IS_SYMBOLIC_LINK_0100 + * @tc.name fileIO_lstat_async_is_symbolic_link_001 + * @tc.desc Test the isSymbolicLink() method of class Stat. Callback. + * This interface shall not treat a normal file as a symbolic link. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_lstat_async_is_symbolic_link_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_lstat_async_is_symbolic_link_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.lstat(fpath, (err, stat) => { + if (err) { + console.log('fileIO_lstat_async_is_symbolic_link_001 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(stat.isSymbolicLink() === false).assertTrue(); + fileIO.unlinkSync(fpath); + done(); + }); + } catch (e) { + console.log('fileIO_lstat_async_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_APPEND_FILE_SYNC_0010 + * @tc.name fileIO_test_append_file_sync_000 + * @tc.desc Test lstat.lstatSync() interface. + * Modify the file, view the file status changes by path. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_test_append_file_sync_000', 0, async function () { + let fpath = await nextFileName('fileIO_test_append_file_sync_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + let stat = fileIO.lstatSync(fpath); + expect(isIntNum(stat.size)).assertTrue(); + + let file = fileIO.openSync(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE); + expect(isIntNum(file.fd)).assertTrue(); + + expect(fileIO.writeSync(file.fd, FILE_CONTENT) == FILE_CONTENT.length).assertTrue(); + fileIO.closeSync(file.fd); + + stat = fileIO.lstatSync(fpath); + expect(stat.size == FILE_CONTENT.length * 2).assertTrue(); + fileIO.unlinkSync(fpath); + } catch (e) { + console.log('fileIO_test_append_file_sync_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); +}) +} diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/symlink.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/symlink.test.js new file mode 100644 index 0000000000000000000000000000000000000000..91b7d43f4606cf9fb7cbfb0e04712bdd6b0bb270 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/test/members/symlink.test.js @@ -0,0 +1,184 @@ +/* + * Copyright (C) 2023 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 { + fileIO, FILE_CONTENT, prepareFile, nextFileName, describe, it, expect, +} from '../Common'; + +export default function fileIOSymlink() { +describe('fileIO_fs_symlink', function () { + + /** + * @tc.number SUB_DF_FILEIO_SYMLINK_SYNC_0000 + * @tc.name fileIO_test_symlink_sync_000 + * @tc.desc Test symlinkSync() interfaces. + * Create a symbolic link to verify normal function. + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_test_symlink_sync_000', 0, async function () { + let fpath = await nextFileName('fileIO_test_symlink_sync_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.symlinkSync(fpath, fpath + 'link0'); + expect(fileIO.accessSync(fpath + 'link0')).assertTrue(); + fileIO.unlinkSync(fpath); + fileIO.unlinkSync(fpath + 'link0'); + } catch (e) { + console.log('fileIO_test_symlink_sync_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_SYMLINK_SYNC_0100 + * @tc.name fileIO_test_symlink_sync_001 + * @tc.desc Test symlinkSync() interfaces. + * Missing parameter. + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_test_symlink_sync_001', 0, async function () { + let fpath = await nextFileName('fileIO_test_symlink_sync_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.symlinkSync(fpath); + expect(false).assertTrue(); + } catch (e) { + fileIO.unlinkSync(fpath); + console.log('fileIO_test_symlink_sync_001 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_SYMLINK_ASYNC_0000 + * @tc.name fileIO_test_symlink_async_000 + * @tc.desc Test SymlinkAsync interfaces. Promise.then().catch() + * Create a symbolic link to verify normal function. + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_test_symlink_async_000', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_symlink_async_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.symlink(fpath, fpath + 'link3').then(() => { + expect(fileIO.accessSync(fpath + 'link3')).assertTrue(); + fileIO.unlinkSync(fpath); + fileIO.unlinkSync(fpath + 'link3'); + }).catch((err) => { + console.log('fileIO_test_symlink_async_000 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + }) + done(); + } catch (e) { + console.log('fileIO_test_symlink_async_000 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_SYMLINK_ASYNC_0100 + * @tc.name fileIO_test_symlink_async_001 + * @tc.desc Test SymlinkAsync interfaces. await Promise. + * Create a symbolic link to verify normal function. + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_test_symlink_async_001', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_symlink_async_001'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + await fileIO.symlink(fpath, fpath + 'link4'); + expect(fileIO.accessSync(fpath + 'link4')).assertTrue(); + fileIO.unlinkSync(fpath); + fileIO.unlinkSync(fpath + 'link4'); + done(); + } catch (e) { + console.log('fileIO_test_symlink_async_001 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_SYMLINK_ASYNC_0200 + * @tc.name fileIO_test_symlink_async_002 + * @tc.desc Test SymlinkAsync interfaces. Promise. + * Create a symbolic link to verify normal function. + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_test_symlink_async_002', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_symlink_async_002'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + fileIO.symlink(fpath, fpath + 'link5', (err) => { + if (err) { + console.log('fileIO_test_symlink_async_002 error package: ' + JSON.stringify(err)); + expect(false).assertTrue(); + } + expect(fileIO.accessSync(fpath + 'link5')).assertTrue(); + fileIO.unlinkSync(fpath); + fileIO.unlinkSync(fpath + 'link5'); + done(); + }); + } catch (e) { + console.log('fileIO_test_symlink_async_002 has failed for ' + e.message + ', code: ' + e.code); + expect(false).assertTrue(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_SYMLINK_ASYNC_0300 + * @tc.name fileIO_test_symlink_async_003 + * @tc.desc Test SymlinkAsync interfaces. Promise. + * Missing parameter. + * @tc.size MEDIUM + * @tc.type Functoin + * @tc.level Level 0 + * @tc.require + */ + it('fileIO_test_symlink_async_003', 0, async function (done) { + let fpath = await nextFileName('fileIO_test_symlink_async_003'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + + try { + await fileIO.symlink(fpath); + expect(false).assertTrue(); + } catch (e) { + fileIO.unlinkSync(fpath); + console.log('fileIO_test_symlink_async_003 has failed for ' + e.message + ', code: ' + e.code); + expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue(); + done(); + } + }); +}); +} diff --git a/storage/storagefileurijstest/src/main/config.json b/storage/storagefileurijstest/src/main/config.json index 6a331a256b917c161029dd9ca548fca3112e2d39..3c1bbd664eb08bcca3329c7fe14405e78e38d7ed 100644 --- a/storage/storagefileurijstest/src/main/config.json +++ b/storage/storagefileurijstest/src/main/config.json @@ -7,7 +7,7 @@ "name": "1.0.0" }, "apiVersion": { - "compatible": 9, + "compatible": 8, "target": 9 } }, diff --git a/storage/storagestatisticsjstest/entry/src/main/module.json b/storage/storagestatisticsjstest/entry/src/main/module.json index 49d0ed610d976ae0019b242d6a14acd890ecfb83..0607249ff55b8cec3eb5cf3f099b76f2aa4c49ba 100644 --- a/storage/storagestatisticsjstest/entry/src/main/module.json +++ b/storage/storagestatisticsjstest/entry/src/main/module.json @@ -16,6 +16,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "com.example.statistics.MainAbility", diff --git a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/ConvertOptionsJsunit.test.ets b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/ConvertOptionsJsunit.test.ets deleted file mode 100644 index 922d96c5c90581c1b78ae1c3d6662da5440dd6e0..0000000000000000000000000000000000000000 --- a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/ConvertOptionsJsunit.test.ets +++ /dev/null @@ -1,1898 +0,0 @@ -/** - * Copyright (c) 2021-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 { describe, expect, it } from '@ohos/hypium'; -import convertxml from '@ohos.convertxml'; - -export default function convertOptionsJsunit() { - describe('XmlTest_radio_1', function () { - console.log("************* settings Test start*************"); - it('Telephony_convertxml_ConvertXML_0100', 0, async function (done) { - var xml = - '' + - '' + - ' Happy ' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: true, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_0200', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreDeclaration: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_0300', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreDeclaration: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_0400', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreAttributes: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_0500', 0, async function (done) { - var xml = - '' + - '' + - ' ' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreComment: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_0600', 0, async function (done) { - var xml = - '' + - '' + - ' ]]>' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreCDATA: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_0700', 0, async function (done) { - var xml = - '' + - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreDoctype: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_0800', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreText: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title"},' + - '{"_type":"element",' + - '"_name":"todo"},' + - '{"_type":"element",' + - '"_name":"todo"}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_0900', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "123", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"123":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_1000', 0, async function (done) { - var xml = - '' + - '' + - ' ' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "123", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"123":"there",' + - '"_type":"instruction",' + - '"_name":"go"},' + - '{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_1100', 0, async function (done) { - var xml = - '' + - '' + - ' ' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "123", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"123":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"123":{"importance":"high",' + - '"logged":"true"},' + - '"_type":"element",' + - '"_name":"note",' + - '"_elements":[{"_type":"instruction",' + - '"_name":"go",' + - '"_instruction":"there"},' + - '{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_1200', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "123", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"123":"Happy",' + - '"_type":"text"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"123":"Work",' + - '"_type":"text"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"123":"Play",' + - '"_type":"text"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_1300', 0, async function (done) { - var xml = - '' + - '' + - ' ' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "123", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"123":"1 is < 2",' + - '"_type":"cdata"},' + - '{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_1400', 0, async function (done) { - var xml = - '' + - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"doctype","doctype":"foo"},' + - '{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - console.info("Telephony_convertxml_ConvertXML_1400 result1 :"+result1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_1500', 0, async function (done) { - var xml = - '' + - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "123", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"123":"note",' + - '"_type":"comment"},' + - '{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_1600', 0, async function (done) { - var xml = - '' + - '' + - ' ' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "123", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"a",' + - '"_elements":[{"_type":"element",' + - '"_name":"b"}]},' + - '{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_1700', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "123", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"123":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"123":"element",' + - '"_name":"title",' + - '"_elements":[{"123":"text",' + - '"_text":"Happy"}]},' + - '{"123":"element",' + - '"_name":"todo",' + - '"_elements":[{"123":"text",' + - '"_text":"Work"}]},' + - '{"123":"element",' + - '"_name":"todo",' + - '"_elements":[{"123":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_1800', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "123", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"123":"note",' + - '"_type":"element",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"123":"title",' + - '"_type":"element",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"123":"todo",' + - '"_type":"element",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"123":"todo",' + - '"_type":"element",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_1900', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "123" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"123":[{"123":[{"123":[{"_type":"text",' + - '"_text":"Happy"}],' + - '"_type":"element",' + - '"_name":"title"},' + - '{"123":[{"_type":"text",' + - '"_text":"Work"}],' + - '"_type":"element",' + - '"_name":"todo"},' + - '{"123":[{"_type":"text",' + - '"_text":"Play"}],' + - '"_type":"element",' + - '"_name":"todo"}],' + - '"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"}}],' + - '"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}}}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_2000', 0, async function (done) { - var xml = - '' + - '' + - ' Happy ' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: true, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_2100', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreDeclaration: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_2200', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreDeclaration: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_2300', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreAttributes: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_2400', 0, async function (done) { - var xml = - '' + - '' + - ' ' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreComment: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_2500', 0, async function (done) { - var xml = - '' + - '' + - ' ]]>' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreCDATA: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_2600', 0, async function (done) { - var xml = - '' + - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreDoctype: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_2700', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreText: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title"},' + - '{"_type":"element",' + - '"_name":"todo"},' + - '{"_type":"element",' + - '"_name":"todo"}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_2800', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "456", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"456":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_2900', 0, async function (done) { - var xml = - '' + - '' + - ' ' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "456", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"456":"there",' + - '"_type":"instruction",' + - '"_name":"go"},' + - '{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_3000', 0, async function (done) { - var xml = - '' + - '' + - ' ' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "456", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"456":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"456":{"importance":"high",' + - '"logged":"true"},' + - '"_type":"element",' + - '"_name":"note",' + - '"_elements":[{"_type":"instruction",' + - '"_name":"go",' + - '"_instruction":"there"},' + - '{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_3100', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "456", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"456":"Happy",' + - '"_type":"text"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"456":"Work",' + - '"_type":"text"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"456":"Play",' + - '"_type":"text"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_3200', 0, async function (done) { - var xml = - '' + - '' + - ' ' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "456", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"456":"1 is < 2",' + - '"_type":"cdata"},' + - '{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_3300', 0, async function (done) { - var xml = - '' + - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "doctype_next", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"doctype","doctype_next":"foo"},' + - '{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_3400', 0, async function (done) { - var xml = - '' + - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "456", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"456":"note",' + - '"_type":"comment"},' + - '{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_3500', 0, async function (done) { - var xml = - '' + - '' + - ' ' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "456", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"_type":"element",' + - '"_name":"a",' + - '"_elements":[{"_type":"element",' + - '"_name":"b"}]},' + - '{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_3600', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "123", - nameKey: "_name", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"123":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"123":"element",' + - '"_name":"title",' + - '"_elements":[{"123":"text",' + - '"_text":"Happy"}]},' + - '{"123":"element",' + - '"_name":"todo",' + - '"_elements":[{"123":"text",' + - '"_text":"Work"}]},' + - '{"123":"element",' + - '"_name":"todo",' + - '"_elements":[{"123":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_3700', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "123", - elementsKey: "_elements" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"123":"note",' + - '"_type":"element",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[{"123":"title",' + - '"_type":"element",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"123":"todo",' + - '"_type":"element",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"123":"todo",' + - '"_type":"element",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - it('Telephony_convertxml_ConvertXML_3800', 0, async function (done) { - var xml = - '' + - '' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "123" - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"123":[{"123":[{"123":[{"_type":"text",' + - '"_text":"Happy"}],' + - '"_type":"element",' + - '"_name":"title"},' + - '{"123":[{"_type":"text",' + - '"_text":"Work"}],' + - '"_type":"element",' + - '"_name":"todo"},' + - '{"123":[{"_type":"text",' + - '"_text":"Play"}],' + - '"_type":"element",' + - '"_name":"todo"}],' + - '"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"}}],' + - '"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}}}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - - /** - * @tc.name: Telephony_convertxml_ConvertXML_3900 - * @tc.desc: To convert XML text to JavaScript object. - * @tc.require: AR000GFB5B - */ - it('Telephony_convertxml_ConvertXML_3900', 0, function (done) { - var xml = - '' + - '' + - ' ' + - ' Happy' + - ' Work' + - ' Play' + - ''; - var conv = new convertxml.ConvertXML(); - let options = { - trim: false, - declarationKey: "_declaration", - instructionKey: "_instruction", - attributesKey: "_attributes", - textKey: "_text", - cdataKey: "_cdata", - doctypeKey: "_doctype", - commentKey: "_comment", - parentKey: "_parent", - typeKey: "_type", - nameKey: "_name", - elementsKey: "_elements", - ignoreInstruction: true - }; - var result1 = JSON.stringify(conv.convert(xml, options)); - var str1 = '{"_declaration":{"_attributes":{"version":"1.0",' + - '"encoding":"utf-8"}},' + - '"_elements":[{"_type":"element",' + - '"_name":"note",' + - '"_attributes":{"importance":"high",' + - '"logged":"true"},' + - '"_elements":[' + - '{"_type":"element",' + - '"_name":"title",' + - '"_elements":[{"_type":"text",' + - '"_text":"Happy"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Work"}]},' + - '{"_type":"element",' + - '"_name":"todo",' + - '"_elements":[{"_type":"text",' + - '"_text":"Play"}]}]}]}'; - expect(result1).assertEqual(str1); - expect(JSON.stringify(conv.convertToJSObject(xml, options))).assertEqual(str1); - done(); - }) - }) -} \ No newline at end of file diff --git a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/List.test.ets b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/List.test.ets index f4d64fdf5a41b2fa737afcb9827023660a1ee982..4866c3abc42a1c896cee179d7173785a28c959d6 100644 --- a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/List.test.ets +++ b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/List.test.ets @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -13,7 +13,7 @@ * limitations under the License. */ -import convertOptionsJsunit from './ConvertOptionsJsunit.test'; + import radioJsunit from './RadioJsunit.test'; import radioSecondJsunit from './RadioSecondJsunit.test'; import smsUiJsunit from './SmsMmsJsunit.test'; @@ -23,7 +23,6 @@ import dataJsunit from './DataJsunit.test'; export default function testsuite() { dataJsunit(); smsUiJsunit(); - convertOptionsJsunit(); radioJsunit(); radioSecondJsunit(); callJsunit(); diff --git a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioJsunit.test.ets b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioJsunit.test.ets index 130df9950be94ba1924bfe82a83f96197cefeb74..612c156791782436b978e8425a0302cd10c3f5b9 100644 --- a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioJsunit.test.ets +++ b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioJsunit.test.ets @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -64,17 +64,41 @@ export default function radioJsunit() { * @tc.desc Function test */ it('Telephony_NetworkSearch_isNrSupported_Promise_0400', 0, async function (done) { + let CaseName = "Telephony_NetworkSearch_isNrSupported_Promise_0400 "; try { let result = radio.isNrSupported(); - console.log("Result: " + result); + console.info("Result: " + result); let result0 = radio.isNrSupported(SLOT_0); - console.log("Result0: " + result0); + console.info("Result0: " + result0); + console.info(CaseName + "is complete!"); done(); } catch (err) { - console.log("Telephony_NetworkSearch_isNrSupported_Promise_0400 err" + JSON.stringify(err)); + console.info(CaseName + "err " + JSON.stringify(err)); expect(false).assertTrue(); done(); } }); + + /** + * @tc.number Telephony_NetworkSearch_isNRSupported_Async_0100 + * @tc.name Test The function isNRSupported(soltId) + * @tc.desc Function test + */ + it('Telephony_NetworkSearch_isNRSupported_Async_0100', 0, async function (done) { + let CaseName = "Telephony_NetworkSearch_isNRSupported_Async_0100 "; + try { + let result = radio.isNRSupported(); + console.info("Result: " + result); + let result0 = radio.isNRSupported(SLOT_0); + console.info("Result0: " + result0); + console.info(CaseName + "is complete!"); + done(); + } catch (err) { + console.info(CaseName + "err " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + } + }); + }) } diff --git a/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets b/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets index 8bf85c4e907b7bf62b84ecc9fdbcf132da95d890..d01fd887c163f3b5e858ae8568aa1f37b78ce8b0 100755 --- a/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets +++ b/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets @@ -1156,39 +1156,6 @@ export default function wallpaperJSUnit() { console.info('------------------testSetImageCallBack102 end----------------------'); }) - /* - * @tc.number testSetImageCallBack103 - * @tc.name Test setImage() to removes a wallpaper of the specified type and restores the default one. - * @tc.desc Function test - * @tc.level 0 - */ - it('testSetImageCallBack103', 0, async function (done) { - console.info('------------------testSetImageCallBack103 start----------------------'); - wallpaper.getImage(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((pixelMap) => { - wallpaper.setImage(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { - try{ - if (error) { - console.error(`testSetImageCallBack103 failed to setImage because: ` + JSON.stringify(error)); - expect().assertFail(); - done(); - } - console.log(`testSetImageCallBack103 success to setImage.`); - expect(true).assertTrue(); - done(); - }catch(err){ - console.info('testSetImageCallBack103 catch err : ' + JSON.stringify(err)); - expect().assertFail(); - done(); - } - }); - }).catch((error) => { - console.error(`testSetImageCallBack103 failed to createPixelMap because: ` + JSON.stringify(error)); - expect().assertFail(); - done() - }); - console.info('------------------testSetImageCallBack103 end----------------------'); - }) - /* * @tc.number testSetImagePromise101 * @tc.name Test setImage() to removes a wallpaper of the specified type and restores the default one. @@ -1229,38 +1196,5 @@ export default function wallpaperJSUnit() { }); console.info('------------------testSetImagePromise102 end----------------------'); }) - - /* - * @tc.number testSetImagePromise103 - * @tc.name Test setImage() to removes a wallpaper of the specified type and restores the default one. - * @tc.desc Function test - * @tc.level 0 - */ - it('testSetImagePromise103', 0, async function (done) { - console.info('------------------testSetImagePromise103 start----------------------'); - try{ - wallpaper.getPixelMap(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((pixelMap) => { - wallpaper.setImage(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { - console.log(`testSetImagePromise103 success to setImage.`); - expect(true).assertTrue(); - done() - }).catch(err => { - console.error(`testSetImagePromise103 failed to setImage because: ` + JSON.stringify(err)); - expect().assertFail(); - done() - }); - }).catch((error) => { - console.error(`testSetImagePromise103 failed to createPixelMap because: ` + JSON.stringify(error)); - expect().assertFail(); - done() - }); - }catch(err){ - console.info('testSetImagePromise103 catch err : ' + JSON.stringify(err)); - expect().assertFail(); - done(); - } - console.info('------------------testSetImagePromise103 end----------------------'); - }); - }); }; diff --git a/time/dateTimeTest/entry/src/main/module.json b/time/dateTimeTest/entry/src/main/module.json index 711e97430bd972e5bf6de8989c2822988cc72b0a..f68134834bc24b6743e9fe8ed848a2741e58fae8 100644 --- a/time/dateTimeTest/entry/src/main/module.json +++ b/time/dateTimeTest/entry/src/main/module.json @@ -13,6 +13,12 @@ "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/time/timeTest/entry/src/main/ets/test/List.test.ets b/time/timeTest/entry/src/main/ets/test/List.test.ets index 547578579527402967edc7d1673159093c4cc743..c7910c1747476814eb7569b1ea9bca8eaa6f323c 100644 --- a/time/timeTest/entry/src/main/ets/test/List.test.ets +++ b/time/timeTest/entry/src/main/ets/test/List.test.ets @@ -13,9 +13,7 @@ * limitations under the License. */ import systemTimeJsunit from './systemTimeTest'; -import systemTimerJsunit from './systemTimer.test'; export default function testsuite() { - systemTimerJsunit(); systemTimeJsunit(); } \ No newline at end of file diff --git a/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets b/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets index 91a674722003c5a82128df80b80f011a51267996..2983a27d0c4df09f1d5277748ad3ab235fd8edc6 100644 --- a/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets +++ b/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets @@ -306,28 +306,6 @@ export default function systemTimeJsunit() { }; }); - /** - * @tc.number SUB_systemTime_setDate_JS_API_0100 - * @tc.name Test systemTime.setDate Invalid value - * @tc.desc Test systemTime_setDate API functionality. - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_systemTime_setDate_JS_API_0100', 0, async function (done) { - console.info("====>SUB_systemTime_setDate_JS_API_0100 start"); - let data = new Date("October 13, 2020 11:13:00"); - systemTime.setDate(data).then(data => { - console.info("====>SUB_systemTime_setDate_JS_API_0100 data " + data); - expect().assertFail(); - done(); - }).catch(error => { - console.info("====>SUB_systemTime_setDate_JS_API_0100 error " + error); - expect(true).assertTrue(); - done(); - }); - }); - /** * @tc.number SUB_systemTime_setDate_JS_API_0200 * @tc.name Test systemTime.setDate Invalid value @@ -349,35 +327,6 @@ export default function systemTimeJsunit() { }); }); - /** - * @tc.number SUB_systemTime_setDate_JS_API_0300 - * @tc.name Test systemTime.setDate Invalid value - * @tc.desc Test systemTime_setDate API functionality. - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_systemTime_setDate_JS_API_0300', 0, async function (done) { - console.info("====>SUB_systemTime_setDate_JS_API_0300 start"); - let data = new Date("October 13, 2020 11:13:00"); - systemTime.setDate(data, (error, data) => { - try { - if(error){ - console.info("====>SUB_systemTime_setDate_JS_API_0300 error " + error); - expect(true).assertTrue(); - done(); - }else{ - console.info("====>SUB_systemTime_setDate_JS_API_0300 data " + data); - expect().assertFail(); - done(); - } - } catch (error) { - console.info("====>SUB_systemTime_setDate_JS_API_0300 catch error " + error); - done(); - } - }); - }); - /** * @tc.number SUB_systemTime_setDate_JS_API_0400 * @tc.name Test systemTime.setDate true value @@ -388,8 +337,8 @@ export default function systemTimeJsunit() { */ it('SUB_systemTime_setDate_JS_API_0400', 0, async function (done) { console.info("====>SUB_systemTime_setDate_JS_API_0400 start"); - let data = new Date("Tue Oct 13 2020 11:13:00 GMT+0800"); - systemTime.setDate(data, (error, data) => { + let date = new Date("Tue Oct 13 2020 11:13:00 GMT+0800"); + systemTime.setDate(date, (error, data) => { try { if(error){ console.info("====>SUB_systemTime_setDate_JS_API_0400 setDate fail: " + JSON.stringify(error)); @@ -426,8 +375,8 @@ export default function systemTimeJsunit() { */ it('SUB_systemTime_setDate_JS_API_0500', 0, async function (done) { console.info("====>SUB_systemTime_setDate_JS_API_0500 start"); - let data = new Date("Tue Oct 13 2020 11:13:00 GMT+0800"); - await systemTime.setDate(data).then( () => { + let date = new Date("Tue Oct 13 2020 11:13:00 GMT+0800"); + await systemTime.setDate(date).then( () => { console.info("====>SUB_systemTime_setDate_JS_API_0500 successful "); systemTime.getDate().then(async data => { try { diff --git a/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets b/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets deleted file mode 100644 index 8ffb16a032620ff129d9430baa6efa21b6661f62..0000000000000000000000000000000000000000 --- a/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets +++ /dev/null @@ -1,788 +0,0 @@ -/* - * 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 WantAgent from '@ohos.wantAgent'; -import systemTimer from "@ohos.systemTimer"; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; - -export default function systemTimerTest() { - describe('systemTimerTest', function () { - console.info('====>systemTimer Test start'); - //wantAgent对象 - var wantAgent; - - //WantAgentInfo对象 - let wantAgentInfo = { - wants: [ - { - bundleName: "com.acts.time.test", - abilityName: "MainAbility" - } - ], - operationType: WantAgent.OperationType.START_SERVICE, - requestCode: 0, - wantAgentFlags: [WantAgent.WantAgentFlags.ONE_TIME_FLAG] - } - - let interval_time = 5000; - - /** - * beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed. - */ - beforeAll(function () { - console.info('====>beforeAll: Prerequisites are executed.'); - WantAgent.getWantAgent(wantAgentInfo) - .then((data) => { - if (data != undefined || data != null) { - console.info('====>beforeAll: success to get wantAgent: ' + typeof (data)); - wantAgent = data; - } - }) - .catch(error => { - console.error('beforeAll: failed to get wantAgent!'); - }); - }); - - /** - * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed. - */ - beforeEach(function () { - console.info('====>beforeEach: Prerequisites is executed.'); - }); - - /** - * afterEach: Test case-level clearance conditions, which are executed after each test case is executed. - */ - afterEach(function () { - console.info('====>afterEach: Test case-level clearance conditions is executed.'); - }); - - /** - * afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed. - */ - afterAll(function () { - console.info('====>afterAll: Test suite-level cleanup condition is executed.'); - }); - - /** - * @tc.number SUB_time_systemTimer_createTimer_0000 - * @tc.name SUB_time_systemTimer_createTimer_0000 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Callback) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_time_systemTimer_createTimer_0000', 0, async function (done) { - console.info('====>SUB_time_systemTimer_createTimer_0000 start.'); - let options = { - type: systemTimer.TIMER_TYPE_REALTIME, - repeat: false - }; - console.info('====>SUB_time_systemTimer_createTimer_0000 create timer.'); - systemTimer.createTimer(options, async (err, timerID) => { - try { - if (err) { - console.info('====>SUB_time_systemTimer_createTimer_0000 create fail: ' + err); - expect().assertTrue(); - done(); - } - console.info('====>SUB_time_systemTimer_createTimer_0000 timerID: ' + timerID); - expect(Number.isInteger(timerID)).assertTrue(); - await systemTimer.destroyTimer(timerID) - done(); - } catch (error) { - console.info('====>SUB_time_systemTimer_createTimer_0000 catch err ' + error); - done(); - }; - }); - console.info('====>SUB_time_systemTimer_createTimer_0000 end.'); - }); - - /** - * @tc.number SUB_time_systemTimer_createTimer_0001 - * @tc.name SUB_time_systemTimer_createTimer_0001 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_IDLE, repeat = true (callback) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_time_systemTimer_createTimer_0001', 0, async function (done) { - console.info('====>SUB_time_systemTimer_createTimer_0001 start.'); - let options = { - type: systemTimer.TIMER_TYPE_IDLE, - repeat: false - }; - console.info('====>SUB_time_systemTimer_createTimer_0001 create timer.'); - systemTimer.createTimer(options, async (err, timerID) => { - try { - if (err) { - console.info('====>SUB_time_systemTimer_createTimer_0001 create fail: ' + err); - expect().assertTrue(); - done(); - } - console.info('====>SUB_time_systemTimer_createTimer_0001 timerID: ' + timerID); - expect(Number.isInteger(timerID)).assertTrue(); - await systemTimer.destroyTimer(timerID) - done(); - } catch (error) { - console.info('====>SUB_time_systemTimer_createTimer_0001 catch err ' + error); - done(); - }; - }); - console.info('====>SUB_time_systemTimer_createTimer_0001 end.'); - }); - - /** - * @tc.number SUB_time_systemTimer_createTimer_0002 - * @tc.name SUB_time_systemTimer_createTimer_0002 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_WAKEUP, repeat = true, interval (Callback) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 2 - */ - it('SUB_time_systemTimer_createTimer_0002', 2, async function (done) { - console.info("====>SUB_time_systemTimer_createTimer_0002 start"); - WantAgent.getBundleName(wantAgent, (err, data) => { - console.info('====>SUB_time_systemTimer_createTimer_0002 BundleName: ' + data); - }) - let options = { - type: systemTimer.TIMER_TYPE_WAKEUP, - repeat: true, - wantAgent: wantAgent, - interval: interval_time - }; - console.info('====>SUB_time_systemTimer_createTimer_0002 create timer.'); - systemTimer.createTimer(options, async (err, timerID) => { - try { - if (err) { - console.info('====>SUB_time_systemTimer_createTimer_0002 create fail: ' + err); - expect().assertTrue(); - done(); - } - console.info('====>SUB_time_systemTimer_createTimer_0002 timerID: ' + timerID); - expect(Number.isInteger(timerID)).assertTrue(); - await systemTimer.destroyTimer(timerID) - done(); - } catch (error) { - console.info('====>SUB_time_systemTimer_createTimer_0002 catch err ' + error); - done(); - }; - }); - console.info('====>SUB_time_systemTimer_createTimer_0002 end.'); - }); - - /** - * @tc.number SUB_time_systemTimer_createTimer_0003 - * @tc.name SUB_time_systemTimer_createTimer_0003 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_EXACT, repeat = false (Callback) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 2 - */ - it('SUB_time_systemTimer_createTimer_0003', 2, async function (done) { - console.info("====>SUB_time_systemTimer_createTimer_0003 start"); - let options = { - type: systemTimer.TIMER_TYPE_EXACT, - repeat: false - }; - console.info('====>SUB_time_systemTimer_createTimer_0003 create timer.'); - systemTimer.createTimer(options, async (err, timerID) => { - try { - if (err) { - console.info('====>SUB_time_systemTimer_createTimer_0003 create fail: ' + err); - expect().assertTrue(); - done(); - } - console.info('====>SUB_time_systemTimer_createTimer_0003 timerID: ' + timerID); - expect(Number.isInteger(timerID)).assertTrue(); - await systemTimer.destroyTimer(timerID) - done(); - } catch (error) { - console.info('====>SUB_time_systemTimer_createTimer_0003 catch err ' + error); - done(); - }; - }); - console.info('====>SUB_time_systemTimer_createTimer_0003 end.'); - }); - - /** - * @tc.number SUB_time_systemTimer_createTimer_0004 - * @tc.name SUB_time_systemTimer_createTimer_0004 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false, wantAgent(callback) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 2 - */ - it('SUB_time_systemTimer_createTimer_0004', 2, async function (done) { - console.info("====>SUB_time_systemTimer_createTimer_0004 start"); - WantAgent.getBundleName(wantAgent, (err, data) => { - console.info("====>SUB_time_systemTimer_createTimer_0004 BundleName: " + data); - }); - let options = { - type: systemTimer.TIMER_TYPE_REALTIME, - repeat: true, - wantAgent: wantAgent, - interval: interval_time - }; - console.info('====>SUB_time_systemTimer_createTimer_0004 create timer.'); - systemTimer.createTimer(options, async (err, timerID) => { - try { - if (err) { - console.info('====>SUB_time_systemTimer_createTimer_0004 create fail: ' + err); - expect().assertTrue(); - done(); - } - console.info('====>SUB_time_systemTimer_createTimer_0004 timerID: ' + timerID); - expect(Number.isInteger(timerID)).assertTrue(); - await systemTimer.destroyTimer(timerID) - done(); - } catch (error) { - console.info('====>SUB_time_systemTimer_createTimer_0004 catch err ' + error); - done(); - }; - }); - console.info('====>SUB_time_systemTimer_createTimer_0004 end.'); - }); - - /** - * @tc.number SUB_time_systemTimer_createTimer_0005 - * @tc.name SUB_time_systemTimer_createTimer_0005 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Callback) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_time_systemTimer_createTimer_0005', 0, async function (done) { - console.info('====>SUB_time_systemTimer_createTimer_0005 start.'); - let options = { - type: systemTimer.TIMER_TYPE_REALTIME, - repeat: false - }; - let globalTimerID; - await systemTimer.createTimer(options).then((timerID) => { - console.info('====>SUB_time_systemTimer_createTimer_0005 timerID: ' + timerID); - globalTimerID = timerID; - expect(Number.isInteger(timerID)).assertTrue(); - }).catch(err => { - console.info('====>SUB_time_systemTimer_createTimer_0005 createTimer fail: ' + err); - expect().assertTrue(); - done(); - }); - console.info('====>SUB_time_systemTimer_createTimer_0005 end.'); - await systemTimer.destroyTimer(globalTimerID) - done(); - }); - - /** - * @tc.number SUB_time_systemTimer_createTimer_0006 - * @tc.name SUB_time_systemTimer_createTimer_0006 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_IDLE, repeat = true (callback) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_time_systemTimer_createTimer_0006', 0, async function (done) { - console.info('====>SUB_time_systemTimer_createTimer_0006 start.'); - let options = { - type: systemTimer.TIMER_TYPE_IDLE, - repeat: false - }; - let globalTimerID; - await systemTimer.createTimer(options).then((timerID) => { - console.info('====>SUB_time_systemTimer_createTimer_0006 timerID: ' + timerID); - globalTimerID = timerID; - expect(Number.isInteger(timerID)).assertTrue(); - }).catch(err => { - console.info('====>SUB_time_systemTimer_createTimer_0006 createTimer fail: ' + err); - expect().assertTrue(); - done(); - }); - console.info('====>SUB_time_systemTimer_createTimer_0006 end.'); - await systemTimer.destroyTimer(globalTimerID) - done(); - }); - - /** - * @tc.number SUB_time_systemTimer_createTimer_0007 - * @tc.name SUB_time_systemTimer_createTimer_0007 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_WAKEUP, repeat = true, interval (Callback) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 2 - */ - it('SUB_time_systemTimer_createTimer_0007', 2, async function (done) { - console.info("====>SUB_time_systemTimer_createTimer_0007 start"); - WantAgent.getBundleName(wantAgent, (err, data) => { - console.info('====>SUB_time_systemTimer_createTimer_0007 BundleName: ' + data); - }) - let options = { - type: systemTimer.TIMER_TYPE_WAKEUP, - repeat: true, - wantAgent: wantAgent, - interval: interval_time - }; - let globalTimerID; - await systemTimer.createTimer(options).then((timerID) => { - console.info('====>SUB_time_systemTimer_createTimer_0007 timerID: ' + timerID); - globalTimerID = timerID; - expect(Number.isInteger(timerID)).assertTrue(); - }).catch(err => { - console.info('====>SUB_time_systemTimer_createTimer_0007 createTimer fail: ' + err); - expect().assertTrue(); - done(); - }); - console.info('====>SUB_time_systemTimer_createTimer_0007 end.'); - await systemTimer.destroyTimer(globalTimerID) - done(); - }); - - /** - * @tc.number SUB_time_systemTimer_createTimer_0008 - * @tc.name SUB_time_systemTimer_createTimer_0008 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_EXACT, repeat = false (Callback) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 2 - */ - it('SUB_time_systemTimer_createTimer_0008', 2, async function (done) { - console.info("====>SUB_time_systemTimer_createTimer_0008 start"); - let options = { - type: systemTimer.TIMER_TYPE_EXACT, - repeat: false - }; - let globalTimerID; - await systemTimer.createTimer(options).then((timerID) => { - console.info('====>SUB_time_systemTimer_createTimer_0008 timerID: ' + timerID); - globalTimerID = timerID; - expect(Number.isInteger(timerID)).assertTrue(); - }).catch(err => { - console.info('====>SUB_time_systemTimer_createTimer_0008 createTimer fail: ' + err); - expect().assertTrue(); - done(); - }); - console.info('====>SUB_time_systemTimer_createTimer_0008 end.'); - await systemTimer.destroyTimer(globalTimerID) - done(); - }); - - /** - * @tc.number SUB_time_systemTimer_createTimer_0009 - * @tc.name SUB_time_systemTimer_createTimer_0009 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false, wantAgent(callback) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 2 - */ - it('SUB_time_systemTimer_createTimer_0009', 2, async function (done) { - console.info("====>SUB_time_systemTimer_createTimer_0009 start"); - WantAgent.getBundleName(wantAgent, (err, data) => { - console.info("====>SUB_time_systemTimer_createTimer_0009 BundleName: " + data); - }); - let options = { - type: systemTimer.TIMER_TYPE_REALTIME, - repeat: true, - wantAgent: wantAgent, - interval: interval_time - }; - let globalTimerID; - await systemTimer.createTimer(options).then((timerID) => { - console.info('====>SUB_time_systemTimer_createTimer_0009 timerID: ' + timerID); - globalTimerID = timerID; - expect(Number.isInteger(timerID)).assertTrue(); - }).catch(err => { - console.info('====>SUB_time_systemTimer_createTimer_0009 createTimer fail: ' + err); - expect().assertTrue(); - done(); - }); - console.info('====>SUB_time_systemTimer_createTimer_0009 end.'); - await systemTimer.destroyTimer(globalTimerID) - done(); - }); - - /** - * @tc.number SUB_time_systemTimer_startTimer_0001 - * @tc.name SUB_time_systemTimer_startTimer_0001 - * @tc.desc Test startTimer() interfaces, normal call(callback) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_time_systemTimer_startTimer_0001', 0, async function (done) { - console.info("====>SUB_time_systemTimer_startTimer_0001 start"); - let triggerTime = new Date().getTime() + interval_time * 1.2; - let options = { - type: systemTimer.TIMER_TYPE_EXACT, - repeat: false - }; - let globalTimerID; - await systemTimer.createTimer(options).then((timerID) => { - console.info('====>SUB_time_systemTimer_createTimer_0009 timerID: ' + timerID); - globalTimerID = timerID; - }).catch(err => { - console.info('====>SUB_time_systemTimer_createTimer_0009 createTimer fail: ' + err); - }); - systemTimer.startTimer(globalTimerID, triggerTime, async (err, data) => { - try { - if (err) { - console.info('====>SUB_time_systemTimer_startTimer_0001 wrong since ' + err.code); - expect().assertTrue(); - done(); - } - console.info("====>SUB_time_systemTimer_startTimer_0001 success to start timerID: " + globalTimerID); - expect(true).assertTrue(); - await systemTimer.destroyTimer(globalTimerID) - done(); - } catch (e) { - console.info('====>SUB_time_systemTimer_startTimer_0001 has failed for ' + e); - done(); - }; - }); - console.info("====>SUB_time_systemTimer_startTimer_0001 end"); - }); - - /** - * @tc.number SUB_time_systemTimer_stopTimer_0001 - * @tc.name SUB_time_systemTimer_stopTimer_0001 - * @tc.desc Test startTimer() interfaces, normal call(callback) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_time_systemTimer_stopTimer_0001', 0, async function (done) { - console.info("====>SUB_time_systemTimer_stopTimer_0001 start"); - let options = { - type: systemTimer.TIMER_TYPE_REALTIME, - repeat: false - }; - let globalTimerID; - await systemTimer.createTimer(options).then((timerID) => { - console.info('====>SUB_time_systemTimer_createTimer_0009 timerID: ' + timerID); - globalTimerID = timerID; - }).catch(err => { - console.info('====>SUB_time_systemTimer_createTimer_0009 createTimer fail: ' + err); - }); - systemTimer.stopTimer(globalTimerID, async (err, data) => { - try { - if (err) { - console.info("====>SUB_time_systemTimer_stopTimer_0001 stop fail timerID: " + globalTimerID); - expect().assertTrue(); - done(); - }; - console.info("====>SUB_time_systemTimer_stopTimer_0001 success to stop timerID: " + globalTimerID); - expect(true).assertTrue(); - await systemTimer.destroyTimer(globalTimerID) - done(); - } catch (e) { - console.info('====>SUB_time_systemTimer_stopTimer_0001 has failed for ' + e); - done(); - }; - }); - console.info("====>SUB_time_systemTimer_stopTimer_0001 end"); - }); - - /** - * @tc.number SUB_time_systemTimer_destroyTimer_0001 - * @tc.name SUB_time_systemTimer_destroyTimer_0001 - * @tc.desc Test startTimer() interfaces, normal call(callback) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_time_systemTimer_destroyTimer_0001', 0, async function (done) { - console.info("====>SUB_time_systemTimer_destroyTimer_0001 start"); - let options = { - type: systemTimer.TIMER_TYPE_WAKEUP, - repeat: true - }; - let globalTimerID; - await systemTimer.createTimer(options).then((timerID) => { - console.info('====>SUB_time_systemTimer_createTimer_0009 timerID: ' + timerID); - globalTimerID = timerID; - }).catch(err => { - console.info('====>SUB_time_systemTimer_createTimer_0009 createTimer fail: ' + err); - }); - systemTimer.destroyTimer(globalTimerID, function (err, data) { - try { - if (err) { - console.info("====>SUB_time_systemTimer_destroyTimer_0001 destroy timer, timerID: " + globalTimerID) - expect().assertTrue(); - done(); - }; - console.info("====>SUB_time_systemTimer_destroyTimer_0001 success to destroy timerID: " + globalTimerID); - expect(true).assertTrue(); - done(); - } catch (e) { - console.info('====>SUB_time_systemTimer_destroyTimer_0001 has failed for ' + e); - done(); - }; - }); - console.info("====>SUB_time_systemTimer_destroyTimer_0001 end"); - }); - - /** - * @tc.number SUB_time_systemTimer_createTimerPromise_0001 - * @tc.name SUB_time_systemTimer_createTimerPromise_0001 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = false (Promise) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_time_systemTimer_createTimerPromise_0001', 0, async function (done) { - console.info('====>SUB_time_systemTimer_createTimerPromise_0001 start.'); - let options = { - type: systemTimer.TIMER_TYPE_REALTIME, - repeat: false - }; - let globalTimerID; - console.info('====>SUB_time_systemTimer_createTimerPromise_0001 create timer.'); - await systemTimer.createTimer(options).then((timerID) => { - console.info('====>SUB_time_systemTimer_createTimerPromise_0001 timerID:' + timerID); - globalTimerID = timerID; - expect(Number.isInteger(timerID)).assertTrue(); - }).catch(error => { - console.info('====>SUB_time_systemTimer_createTimerPromise_0001 failed to create timer: ' + error); - expect().assertTrue(); - done(); - }); - await systemTimer.destroyTimer(globalTimerID) - done(); - }); - - /** - * @tc.number SUB_time_systemTimer_startTimer_0002 - * @tc.name SUB_time_systemTimer_startTimer_0002 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = true (Promise) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_time_systemTimer_startTimer_0002', 0, async function (done) { - console.info('====>SUB_time_systemTimer_startTimer_0002 start.'); - let options = { - type: systemTimer.TIMER_TYPE_IDLE, - repeat: true - }; - let globalTimerID; - await systemTimer.createTimer(options).then((timerID) => { - console.info('====>SUB_time_systemTimer_createTimer_0009 timerID: ' + timerID); - globalTimerID = timerID; - }).catch(err => { - console.info('====>SUB_time_systemTimer_createTimer_0009 createTimer fail: ' + err); - }); - let triggerTime = new Date().getTime() + interval_time * 2; - await systemTimer.startTimer(globalTimerID, triggerTime).then(() => { - console.info('====>SUB_time_systemTimer_startTimer_0002 timerID:' + globalTimerID); - expect(true).assertTrue(); - }).catch((err) => { - console.info('====>SUB_time_systemTimer_startTimer_0002 failed to start timer: ' + err); - expect().assertTrue(); - done(); - }); - console.info('====>SUB_time_systemTimer_startTimer_0002 end.'); - await systemTimer.destroyTimer(globalTimerID) - done(); - }); - - /** - * @tc.number SUB_time_systemTimer_stopTimer_0002 - * @tc.name SUB_time_systemTimer_stopTimer_0002 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = true (Promise) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_time_systemTimer_stopTimer_0002', 0, async function (done) { - console.info('====>SUB_time_systemTimer_stopTimer_0002 start.'); - let options = { - type: systemTimer.TIMER_TYPE_EXACT, - repeat: false - }; - let globalTimerID; - await systemTimer.createTimer(options).then((timerID) => { - console.info('====>SUB_time_systemTimer_createTimer_0009 timerID: ' + timerID); - globalTimerID = timerID; - }).catch(err => { - console.info('====>SUB_time_systemTimer_createTimer_0009 createTimer fail: ' + err); - }); - await systemTimer.stopTimer(globalTimerID).then(() => { - console.info('====>SUB_time_systemTimer_stopTimer_0002 timerID:' + globalTimerID); - expect(true).assertTrue(); - }).catch((err) => { - console.info('====>SUB_time_systemTimer_stopTimer_0002 failed to stop timer:' + err); - expect().assertTrue(); - done(); - }); - console.info('====>SUB_time_systemTimer_stopTimer_0002 end.'); - await systemTimer.destroyTimer(globalTimerID) - done(); - }); - - /** - * @tc.number SUB_time_systemTimer_destroyTimer_0002 - * @tc.name SUB_time_systemTimer_destroyTimer_0002 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_REALTIME, repeat = true (Promise) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_time_systemTimer_destroyTimer_0002', 0, async function (done) { - console.info('====>SUB_time_systemTimer_destroyTimer_0002 start.'); - let options = { - type: systemTimer.TIMER_TYPE_REALTIME, - repeat: false - }; - let globalTimerID; - await systemTimer.createTimer(options).then((timerID) => { - console.info('====>SUB_time_systemTimer_createTimer_0009 timerID: ' + timerID); - globalTimerID = timerID; - }).catch(err => { - console.info('====>SUB_time_systemTimer_createTimer_0009 createTimer fail: ' + err); - }); - await systemTimer.destroyTimer(globalTimerID).then(() => { - console.info('====>SUB_time_systemTimer_destroyTimer_0002 timerID:' + globalTimerID); - expect(true).assertTrue(); - done(); - }).catch((err ) => { - console.info('====>SUB_time_systemTimer_destroyTimer_0002 failed to destroy timer:' + err); - expect().assertTrue(); - done(); - }); - console.info('====>SUB_time_systemTimer_destroyTimer_0002 end.'); - }); - - /** - * @tc.number SUB_time_systemTimer_ALL_Promise_0008 - * @tc.name SUB_time_systemTimer_ALL_Promise_0008 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_WAKEUP, repeat = false (Promise) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_time_systemTimer_ALL_Promise_0008', 0, async function (done) { - console.info('====>SUB_time_systemTimer_ALL_Promise_0008 start.'); - let options = { - type: systemTimer.TIMER_TYPE_WAKEUP, - repeat: false - }; - try { - console.info('====>SUB_time_systemTimer_ALL_Promise_0008 create timer.'); - systemTimer.createTimer(options) - .then((timerID) => { - console.info('====>SUB_time_systemTimer_ALL_Promise_0008 timerID:' + timerID); - try { - expect(Number.isInteger(timerID)).assertTrue(); - let triggerTime = new Date().getTime() + interval_time * 1.2; - systemTimer.startTimer(timerID, triggerTime) - .then(() => { - console.info('====>SUB_time_systemTimer_ALL_Promise_0008 start timerID: ' + timerID); - try { - systemTimer.stopTimer(timerID) - .then(() => { - systemTimer.destroyTimer(timerID, async (err, data) => { - console.info('====>SUB_time_systemTimer_ALL_Promise_0008 destroyTimer: ' + timerID); - done(); - }); - }) - .catch(() => { - // 捕获stopTimer业务逻辑错误 - console.info('====>SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.'); - expect().assertTrue(); - done(); - }) - } catch (err) { - // 捕获stopTimer参数错误 - console.info('====>SUB_time_systemTimer_ALL_Promise_0008 stopTimer with wrong arg: ' + err); - expect().assertTrue(); - done(); - } - }) - .catch(() => { - // 捕获startTimer业务逻辑错误 - console.info('====>SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.'); - expect().assertTrue(); - done(); - }); - } catch (err) { - // 捕获参数错误 - console.info('====>SUB_time_systemTimer_ALL_Promise_0008 startTimer with wrong arg: ' + err); - expect().assertTrue(); - done(); - } - }) - .catch(() => { - // 捕获业务逻辑错误 - console.info('====>SUB_time_systemTimer_ALL_Promise_0008 failed to create timer.'); - expect().assertTrue(); - done(); - }); - } catch (err) { - // 捕获参数错误 - console.info('====>SUB_time_systemTimer_ALL_Promise_0008 createTimer with wrong arg: ' + err); - expect().assertTrue(); - done(); - } - }); - - /** - * @tc.number SUB_time_systemTimer_ALL_Callback_0009 - * @tc.name SUB_time_systemTimer_ALL_Callback_0009 - * @tc.desc Test createTimer() interfaces, type = TIMER_TYPE_WAKEUP, repeat = false (Promise) - * @tc.size MEDIUM - * @tc.type Function - * @tc.level Level 0 - */ - it('SUB_time_systemTimer_ALL_Callback_0009', 0, async function (done) { - console.info('====>SUB_time_systemTimer_ALL_Callback_0009 start.'); - let options = { - type: systemTimer.TIMER_TYPE_WAKEUP, - repeat: false - }; - try { - console.info('====>SUB_time_systemTimer_ALL_Callback_0009 create timer.'); - systemTimer.createTimer(options) - .then((timerID) => { - console.info('====>SUB_time_systemTimer_ALL_Callback_0009 timerID:' + timerID); - try { - expect(Number.isInteger(timerID)).assertTrue(); - let triggerTime = new Date().getTime() + interval_time * 1.2; - systemTimer.startTimer(timerID, triggerTime, () => { - console.info('====>SUB_time_systemTimer_ALL_Callback_0009 start timerID: ' + timerID); - try { - systemTimer.stopTimer(timerID, () => { - systemTimer.destroyTimer(timerID, function (err, data) { - console.info('====>SUB_time_systemTimer_ALL_Callback_0009 destroyTimer: ' + timerID); - done(); - }); - }) - } catch (err) { - console.info('====>SUB_time_systemTimer_ALL_Callback_0009 stopTimer with wrong arg: ' + err); - expect().assertTrue(); - done(); - } - }) - } catch (err) { - console.info('====>SUB_time_systemTimer_ALL_Callback_0009 startTimer with wrong arg: ' + err); - expect().assertTrue(); - done(); - } - }) - } catch (err) { - console.info('====>SUB_time_systemTimer_ALL_Callback_0009 createTimer with wrong arg: ' + err); - expect().assertTrue(); - done(); - }; - }); - }); -} \ No newline at end of file diff --git a/time/timeTest/entry/src/main/module.json b/time/timeTest/entry/src/main/module.json index 16ad63bfdcf4303a3c09eaeff7615ea44b1c2786..6fe24d93bf4c7dc4fe6e1c9aead29de800b99d0f 100644 --- a/time/timeTest/entry/src/main/module.json +++ b/time/timeTest/entry/src/main/module.json @@ -6,13 +6,19 @@ "description": "$string:entry_desc", "mainElement": "MainAbility", "deviceTypes": [ - "tablet", - "default", + "tablet", + "default", "phone" ], "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js b/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js index d8cc170728d6bd1960a928da82c347fbea802794..2808b63d8e8aad5f8f73954f4b0c69a6247dbf4d 100644 --- a/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js +++ b/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js @@ -328,7 +328,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { /** * @tc.number: SUB_USB_JS_0750 * @tc.name: setConfiguration - * @tc.desc: Negative test: Set Device Configuration + * @tc.desc: Negative test: Set Device Configuration, USBConfig id error */ it('SUB_USB_JS_0750', 0, function () { console.info('usb SUB_USB_JS_0750 begin'); @@ -648,6 +648,19 @@ describe('UsbDevicePipeJsFunctionsTest', function () { callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0620 ClearFeature') }) + function callControlTransferEx(pip, controlParam, timeout, caseName) { + usb.controlTransfer(pip, controlParam, timeout).then(data => { + console.info('usb controlTransfer ret data : ' + data + ' ' + caseName); + expect(false).assertTrue(); + console.info('usb' + caseName + ': FAILED'); + }).catch(error => { + console.info('usb controlTransfer error : ' + JSON.stringify(error)); + console.info('usb' + caseName + ': FAILED'); + expect(false).assertTrue(); + }); + CheckEmptyUtils.sleep(3000); + } + /** * @tc.number: SUB_USB_JS_1140 * @tc.name: controlTransfer @@ -666,9 +679,13 @@ describe('UsbDevicePipeJsFunctionsTest', function () { return } try { - var maskCode = usb.controlTransfer("invalid"); - console.info('usb 1140 case controlTransfer return: ' + maskCode); - expect(false).assertTrue(); + usb.controlTransfer("invalid").then(data => { + console.info('usb 1140 case controlTransfer ret data : ' + data); + expect(false).assertTrue(); + }).catch(error => { + console.info('usb 1140 case controlTransfer error : ' + JSON.stringify(error)); + expect(false).assertTrue(); + }); } catch (err) { console.info('usb 1140 catch err code: ' + err.code + ' message: ' + err.message); expect(err.code).assertEqual(401); @@ -694,9 +711,13 @@ describe('UsbDevicePipeJsFunctionsTest', function () { return } try { - var maskCode = usb.controlTransfer(); - console.info('usb 1300 case controlTransfer return: ' + maskCode); - expect(false).assertTrue(); + usb.controlTransfer().then(data => { + console.info('usb 1300 case controlTransfer ret data : ' + data); + expect(false).assertTrue(); + }).catch(error => { + console.info('usb 1300 case controlTransfer error : ' + JSON.stringify(error)); + expect(false).assertTrue(); + }); } catch (err) { console.info('usb 1300 catch err code: ' + err.code + ' message: ' + err.message); expect(err.code).assertEqual(401); @@ -716,7 +737,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { expect(false).assertFalse(); return } - var testParam = getTransferTestParam() + var testParam = getTransferTestParam(); if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) { expect(false).assertTrue(); return @@ -726,14 +747,41 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var controlParam = getTransferParam(255, usb.USB_REQUEST_TARGET_OTHER, (usb.USB_REQUEST_DIR_TO_DEVICE) | (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0); try { - var maskCode = usb.controlTransfer(testParamPip, controlParam, timeout); - console.info('usb 1440 case controlTransfer return: ' + maskCode); - expect(false).assertTrue(); + callControlTransferEx(testParamPip, controlParam, timeout, 'SUB_USB_JS_1440 ClearFeature'); } catch (err) { console.info('usb 1440 catch err code: ' + err.code + ' message: ' + err.message); expect(err.code).assertEqual(401); console.info('usb SUB_USB_JS_1440 : PASS'); } }) + + /** + * @tc.number: SUB_USB_JS_1560 + * @tc.name: controlTransfer + * @tc.desc: Negative test: control transfer, + * parameter contrlparam type error(The controlParam should have the data property) + */ + it('SUB_USB_JS_1560', 0, function () { + console.info('usb SUB_USB_JS_1560 begin'); + if (portCurrentMode == 1) { + console.info('usb 1560 case get_device port is device') + expect(false).assertFalse(); + return + } + var testParam = getTransferTestParam() + if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) { + expect(false).assertTrue(); + return + } + var controlParam = "invalid"; + var timeout = 5000; + try { + callControlTransferEx(testParam.pip, controlParam, timeout, 'SUB_USB_JS_1560 ClearFeature'); + } catch (err) { + console.info('usb 1560 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1560 : PASS'); + } + }) }) } diff --git a/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunitEx.test.js b/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunitEx.test.js index 01f2a772387297ccec41fac68ff1680a85ece1d6..c3ce499cd7159b3c2d41f4dcbbbb4348b919eadd 100644 --- a/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunitEx.test.js +++ b/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunitEx.test.js @@ -273,9 +273,15 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { expect(testParam.isClaimed).assertEqual(0); try { - var maskCode = usb.bulkTransfer("invalid"); - console.info('usb 1100 case bulkTransfer return: ' + maskCode); - expect(false).assertTrue(); + usb.bulkTransfer(testParam.pip).then(data => { + console.info('usb case SUB_USB_JS_1100 ret: ' + data); + expect(false).assertTrue(); + console.info('usb case SUB_USB_JS_1100 : FAILED'); + }).catch(error => { + console.info('usb SUB_USB_JS_1100 write error : ' + JSON.stringify(error)); + expect(false).assertTrue(); + console.info('usb case SUB_USB_JS_1100 : FAILED'); + }); } catch (err) { console.info('usb 1100 catch err code: ' + err.code + ' message: ' + err.message); expect(err.code).assertEqual(401); @@ -283,6 +289,44 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } }) + /** + * @tc.number: SUB_USB_JS_1480 + * @tc.name: bulkTransfer + * @tc.desc: Negative test: bulk transfer, parameter number exception, input two parameter + */ + it('SUB_USB_JS_1480', 0, function () { + console.info('usb SUB_USB_JS_1480 begin'); + if (portCurrentMode == 1) { + console.info('usb case get_device port is device') + expect(false).assertFalse(); + return + } + var testParam = getTransferTestParam() + if (testParam.interface == null || testParam.inEndpoint == null) { + expect(false).assertTrue(); + return + } + + testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true); + expect(testParam.isClaimed).assertEqual(0); + + try { + usb.bulkTransfer(testParam.pip, testParam.outEndpoint).then(data => { + console.info('usb case SUB_USB_JS_1480 ret: ' + data); + expect(false).assertTrue(); + console.info('usb case SUB_USB_JS_1480 : FAILED'); + }).catch(error => { + console.info('usb 1480 write error : ' + JSON.stringify(error)); + expect(false).assertTrue(); + console.info('usb case SUB_USB_JS_1480 : FAILED'); + }); + } catch (err) { + console.info('usb 1480 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1480 : PASS'); + } + }) + /** * @tc.number: SUB_USB_JS_1310 * @tc.name: bulkTransfer @@ -300,12 +344,19 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { expect(false).assertTrue(); return } + try { - var maskCode = usb.bulkTransfer(); - console.info('usb 1310 case bulkTransfer return: ' + maskCode); - expect(false).assertTrue(); + usb.bulkTransfer().then(data => { + console.info('usb case SUB_USB_JS_1310 ret: ' + data); + expect(false).assertTrue(); + console.info('usb case SUB_USB_JS_1310 : FAILED'); + }).catch(error => { + console.info('usb 1310 write error : ' + JSON.stringify(error)); + expect(false).assertTrue(); + console.info('usb case SUB_USB_JS_1310 : FAILED'); + }); } catch (err) { - console.info('usb 1310 catch err code: ' + err.code + ' message: ' + err.message); + console.info('usb 1480 catch err code: ' + err.code + ' message: ' + err.message); expect(err.code).assertEqual(401); console.info('usb SUB_USB_JS_1310 : PASS'); } @@ -338,9 +389,15 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { tmpTestParam.pip = "invalid"; var tmpUint8Array = new Uint8Array(testParam.maxInSize); try { - var maskCode = usb.bulkTransfer(tmpTestParam.pip, tmpTestParam.inEndpoint, tmpUint8Array, 5000); - console.info('usb 1420 case bulkTransfer return: ' + maskCode); - expect(false).assertTrue(); + usb.bulkTransfer(tmpTestParam.pip, tmpTestParam.inEndpoint, tmpUint8Array, 5000).then(data => { + console.info('usb case SUB_USB_JS_1420 ret: ' + data); + expect(false).assertTrue(); + console.info('usb case SUB_USB_JS_1420 : FAILED'); + }).catch(error => { + console.info('usb 1420 write error : ' + JSON.stringify(error)); + expect(false).assertTrue(); + console.info('usb case SUB_USB_JS_1420 : FAILED'); + }); } catch (err) { console.info('usb 1420 catch err code: ' + err.code + ' message: ' + err.message); expect(err.code).assertEqual(401); @@ -348,6 +405,49 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } }) + /** + * @tc.number: SUB_USB_JS_1490 + * @tc.name: bulkTransfer + * @tc.desc: Negative test: bulk transfer, parameter endpoint type error + */ + it('SUB_USB_JS_1490', 0, function () { + console.info('usb SUB_USB_JS_1490 begin'); + if (portCurrentMode == 1) { + console.info('usb case get_device port is device'); + expect(false).assertFalse(); + return + } + var testParam = getTransferTestParam() + if (testParam.interface == null || testParam.inEndpoint == null) { + console.info('usb case testParam_interface and testParam_inEndpoint is null'); + expect(false).assertTrue(); + return + } + + testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true); + expect(testParam.isClaimed).assertEqual(0); + + console.info('usb case readData begin'); + var tmpTestParam = testParam; + tmpTestParam.inEndpoint = "invalid"; + var tmpUint8Array = new Uint8Array(testParam.maxInSize); + try { + usb.bulkTransfer(tmpTestParam.pip, tmpTestParam.inEndpoint, tmpUint8Array, 5000).then(data => { + console.info('usb case SUB_USB_JS_1490 ret: ' + data); + expect(false).assertTrue(); + console.info('usb case SUB_USB_JS_1490 : FAILED'); + }).catch(error => { + console.info('usb 1490 write error : ' + JSON.stringify(error)); + expect(false).assertTrue(); + console.info('usb case SUB_USB_JS_1490 : FAILED'); + }); + } catch (err) { + console.info('usb 1490 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1490 : PASS'); + } + }) + /** * @tc.number: SUB_USB_JS_0430 * @tc.name: claimInterface @@ -653,6 +753,73 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } }) + /** + * @tc.number: SUB_USB_JS_1510 + * @tc.name: claimInterface + * @tc.desc: Negative test: Get interface, parameter iface type error + */ + it('SUB_USB_JS_1510', 0, function () { + console.info('usb SUB_USB_JS_1510 begin'); + if (portCurrentMode == 1) { + console.info('usb case get_device port is device') + expect(false).assertFalse(); + return + } + if (gDeviceList.length == 0) { + console.info('usb case get_device_list is null') + expect(false).assertTrue(); + return + } + + var TmpInterface = "invalid"; + try { + var maskCode = usb.claimInterface(gPipe, TmpInterface); + console.info('usb 1510 case claimInterface return: ' + maskCode); + expect(false).assertTrue(); + } catch (err) { + console.info('usb 1510 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1510 : PASS'); + } + }) + + /** + * @tc.number: SUB_USB_JS_1520 + * @tc.name: claimInterface + * @tc.desc: Negative test: Get interface, parameter force type error + */ + it('SUB_USB_JS_1520', 0, function () { + console.info('usb SUB_USB_JS_1520 begin'); + if (portCurrentMode == 1) { + console.info('usb case get_device port is device') + expect(false).assertFalse(); + return + } + if (gDeviceList.length == 0) { + console.info('usb case get_device_list is null') + expect(false).assertTrue(); + return + } + + try { + for (var j = 0; j < gDeviceList[0].configs.length; j++) { + if (gDeviceList[0].configs[j].interfaces.length == 0) { + console.info('usb case SUB_USB_JS_1520 current device.configs.interfaces.length = 0'); + } + for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { + var TmpInterface = gDeviceList[0].configs[j].interfaces[k]; + var maskCode = usb.claimInterface(gPipe, TmpInterface, "invalid"); + console.info('usb 1520 case claimInterface return: ' + maskCode); + expect(false).assertTrue(); + } + } + } catch (err) { + console.info('usb 1520 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1520 : PASS'); + } + }) + /** * @tc.number: SUB_USB_JS_0280 * @tc.name: releaseInterface @@ -954,6 +1121,31 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } }) + /** + * @tc.number: SUB_USB_JS_1580 + * @tc.name: releaseInterface + * @tc.desc: Negative test: release Interface, parameter iface type error + */ + it('SUB_USB_JS_1580', 0, function () { + console.info('usb SUB_USB_JS_1580 begin'); + if (portCurrentMode == 1) { + console.info('usb 1580 case get_device port is device') + expect(false).assertFalse(); + return + } + + var TmpInterface = "invalid"; + try { + var maskCode = usb.releaseInterface(gPipe, TmpInterface); + console.info('usb 1580 case releaseInterface return: ' + maskCode); + expect(false).assertTrue(); + } catch (err) { + console.info('usb 1580 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1580 : PASS'); + } + }) + /** * @tc.number: SUB_USB_JS_0820 * @tc.name: setInterface @@ -1090,6 +1282,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { console.info('usb case get_device port is device') expect(false).assertFalse(); return + } if (gDeviceList.length == 0) { console.info('usb case get_device_list is null') @@ -1174,10 +1367,40 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } }) + /** + * @tc.number: SUB_USB_JS_1550 + * @tc.name: setInterface + * @tc.desc: Negative test: Set device interface, parameter iface type error + */ + it('SUB_USB_JS_1550', 0, function () { + console.info('usb SUB_USB_JS_1550 begin'); + if (portCurrentMode == 1) { + console.info('usb case 1550 get_device port is device') + expect(false).assertFalse(); + return + } + if (gDeviceList.length == 0) { + console.info('usb case 1550 get_device_list is null') + expect(false).assertTrue(); + return + } + + var TmpInterface = "invalid"; + try { + var maskCode = usb.setInterface(gPipe, TmpInterface); + console.info('usb 1550 case setInterface return: ' + maskCode); + expect(false).assertTrue(); + } catch (err) { + console.info('usb 1550 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1550 : PASS'); + } + }) + /** * @tc.number: SUB_USB_JS_0760 * @tc.name: setConfiguration - * @tc.desc: Negative test: Set Device Configuration, USBConfig name error + * @tc.desc: Negative test: Set Device Configuration, USBConfig name error */ it('SUB_USB_JS_0760', 0, function () { console.info('usb SUB_USB_JS_0760 begin'); @@ -1206,7 +1429,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { /** * @tc.number: SUB_USB_JS_0770 * @tc.name: setConfiguration - * @tc.desc: Negative test: Set Device Configuration, USBConfig name error + * @tc.desc: Negative test: Set Device Configuration, USBConfig name, id error */ it('SUB_USB_JS_0770', 0, function () { console.info('usb SUB_USB_JS_0770 begin'); @@ -1236,7 +1459,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { /** * @tc.number: SUB_USB_JS_0780 * @tc.name: setConfiguration - * @tc.desc: Negative test: Set Device Configuration, USBConfig attributes error + * @tc.desc: Negative test: Set Device Configuration, USBConfig attributes error */ it('SUB_USB_JS_0780', 0, function () { console.info('usb SUB_USB_JS_0780 begin'); @@ -1370,15 +1593,10 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { try { for (var j = 0; j < gDeviceList[0].configs.length; j++) { - if (gDeviceList[0].configs[j].interfaces.length == 0) { - console.info('usb case SUB_USB_JS_1470 current device.configs.interfaces.length = 0'); - } - for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { - var TmpInterface = gDeviceList[0].configs[j].interfaces[k]; - var maskCode = usb.setConfiguration(testParamPip, TmpInterface); - console.info('usb 1470 case setConfiguration return: ' + maskCode); - expect(false).assertTrue(); - } + var TmpConfig = gDeviceList[0].configs[j]; + var maskCode = usb.setConfiguration(testParamPip, TmpConfig); + console.info('usb 1470 case setConfiguration return: ' + maskCode); + expect(false).assertTrue(); } } catch (err) { console.info('usb 1470 catch err code: ' + err.code + ' message: ' + err.message); @@ -1386,5 +1604,36 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { console.info('usb SUB_USB_JS_1470 : PASS'); } }) + + /** + * @tc.number: SUB_USB_JS_1540 + * @tc.name: setConfiguration + * @tc.desc: Negative test: Set Device Configuration, parameter pipe type error + */ + it('SUB_USB_JS_1540', 0, function () { + console.info('usb SUB_USB_JS_1540 begin'); + if (portCurrentMode == 1) { + console.info('usb case get_device port is device') + expect(false).assertFalse(); + return + } + if (gDeviceList.length == 0) { + console.info('usb case get_device_list is null') + expect(false).assertTrue(); + return + } + + var TmpConfig = "invalid"; + + try { + var maskCode = usb.setConfiguration(gPipe, TmpConfig); + console.info('usb 1540 case setConfiguration return: ' + maskCode); + expect(false).assertTrue(); + } catch (err) { + console.info('usb 1540 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1540 : PASS'); + } + }) }) } diff --git a/usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js b/usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js index cc01812ea64ce51dc491a49c00326cbc09ccab23..d434b7b67533d5c58980c47408958b43217f5877 100644 --- a/usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js +++ b/usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js @@ -223,7 +223,7 @@ describe('UsbPortJsFunctionsTestEx', function () { /** * @tc.number: SUB_USB_JS_1410 * @tc.name: setPortRoles - * @tc.desc: Negative test: parameter type exception + * @tc.desc: Negative test: parameter portId type exception */ it('SUB_USB_JS_1410', 0, function () { console.info('usb SUB_USB_JS_1410 begin'); @@ -277,6 +277,68 @@ describe('UsbPortJsFunctionsTestEx', function () { } }) + /** + * @tc.number: SUB_USB_JS_1590 + * @tc.name: setPortRoles + * @tc.desc: Negative test: parameter number exception, parameter powerRole type exception + */ + it('SUB_USB_JS_1590', 0, function () { + console.info('usb SUB_USB_JS_1590 begin'); + var portId = gPort.id; + var powerRole = "invalid"; + var dataRole = usb.DEVICE; + try { + var maskCode = usb.setPortRoles(portId, powerRole, dataRole); + console.info('usb 1590 case setPortRoles return: ' + maskCode); + expect(false).assertTrue(); + } catch (err) { + console.info('usb 1590 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1590 : PASS'); + } + }) + + /** + * @tc.number: SUB_USB_JS_1600 + * @tc.name: setPortRoles + * @tc.desc: Negative test: parameter number exception, parameter dataRole type exception + */ + it('SUB_USB_JS_1600', 0, function () { + console.info('usb SUB_USB_JS_1600 begin'); + var portId = gPort.id; + var powerRole = usb.SINK; + var dataRole = "invalid"; + try { + var maskCode = usb.setPortRoles(portId, powerRole, dataRole); + console.info('usb 1600 case setPortRoles return: ' + maskCode); + expect(false).assertTrue(); + } catch (err) { + console.info('usb 1600 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1600 : PASS'); + } + }) + + /** + * @tc.number: SUB_USB_JS_1610 + * @tc.name: setPortRoles + * @tc.desc: Negative test: parameter number exception, input two parameter + */ + it('SUB_USB_JS_1610', 0, function () { + console.info('usb SUB_USB_JS_1610 begin'); + var portId = gPort.id; + var powerRole = usb.SINK; + try { + var maskCode = usb.setPortRoles(portId, powerRole); + console.info('usb 1610 case setPortRoles return: ' + maskCode); + expect(false).assertTrue(); + } catch (err) { + console.info('usb 1610 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1610 : PASS'); + } + }) + /** * @tc.number: SUB_USB_JS_1200 * @tc.name: getPorts diff --git a/validator/acts_validator/src/main/module.json b/validator/acts_validator/src/main/module.json index 5ca5f44142e170f192c22e68ea838cf1a1694771..79d2731336367720c7419989db471a37d7404b89 100644 --- a/validator/acts_validator/src/main/module.json +++ b/validator/acts_validator/src/main/module.json @@ -13,6 +13,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "MainAbility", diff --git a/wukong/actswukongtest/entry/src/main/module.json b/wukong/actswukongtest/entry/src/main/module.json index 7d42336bf1f3032babde9287a9e91ea77d9ab92b..cc72d0d90dc03873738fb32e69eb1aea3948503e 100644 --- a/wukong/actswukongtest/entry/src/main/module.json +++ b/wukong/actswukongtest/entry/src/main/module.json @@ -15,6 +15,12 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], "abilities": [ { "name": "com.example.ActsWukongTest.MainAbility",