diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 53d8db6d17ff7d0eee037bc1c1d3354156b11729..8ae868099038e97b31ca2780556465e5d319b45c 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -17,5 +17,7 @@ group("unittest") { "file_share_native:file_share_test", "file_uri_native:file_uri_test", "remote_file_share:remote_file_share_test", + "resource/bundle_dependencies/fileShareA:filesharea", + "resource/bundle_dependencies/fileShareB:fileshareb", ] } diff --git a/test/unittest/file_share_native/BUILD.gn b/test/unittest/file_share_native/BUILD.gn index 8ee4cb0d5cacf73bf1ecaa330948f23a19f49a95..17dd4d7a474b7332874c3398b31085406e07b88e 100644 --- a/test/unittest/file_share_native/BUILD.gn +++ b/test/unittest/file_share_native/BUILD.gn @@ -15,6 +15,7 @@ import("//build/test.gni") ohos_unittest("file_share_test") { module_out_path = "filemanagement/app_file_service" + resource_config_file = "../resource/ohos_test.xml" sources = [ "file_share_test.cpp" ] external_deps = [ diff --git a/test/unittest/file_share_native/file_share_test.cpp b/test/unittest/file_share_native/file_share_test.cpp index 143f07eb6d61e406699dadc472aaca02bd5ef36d..5d1c7042575a7d5a11d86bcc61eff692ac308b85 100644 --- a/test/unittest/file_share_native/file_share_test.cpp +++ b/test/unittest/file_share_native/file_share_test.cpp @@ -55,16 +55,15 @@ namespace { { GTEST_LOG_(INFO) << "FileShareTest-begin File_share_CreateShareFile_0000"; - int32_t uid = -1; - uid = OHOS::IPCSkeleton::GetCallingUid(); + int32_t uid = 100; - string bundleNameA = "com.ohos.settingsdata"; + string bundleNameA = "com.example.filesharea"; string fileStr = "/data/app/el2/" + to_string(uid) + "/base/" + bundleNameA + "/files/test.txt"; int32_t fd = open(fileStr.c_str(), O_RDWR | O_CREAT); ASSERT_TRUE(fd != -1) << "FileShareTest Create File Failed!"; string uri = "file://" + bundleNameA + "/data/storage/el2/base/files/test.txt"; - string bundleNameB = "com.ohos.systemui"; + string bundleNameB = "com.example.fileshareb"; uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); int32_t flag = 3; @@ -85,16 +84,15 @@ namespace { { GTEST_LOG_(INFO) << "FileShareTest-begin File_share_CreateShareFile_0001"; - int32_t uid = -1; - uid = OHOS::IPCSkeleton::GetCallingUid(); + int32_t uid = 100; - string bundleNameA = "com.ohos.settingsdata"; + string bundleNameA = "com.example.filesharea"; string fileStr = "/data/app/el2/" + to_string(uid) + "/base/" + bundleNameA + "/files/test.txt"; int32_t fd = open(fileStr.c_str(), O_RDWR | O_CREAT); ASSERT_TRUE(fd != -1) << "FileShareTest Create File Failed!"; string uri = "file://" + bundleNameA + "/data/test/el2/base/files/test.txt"; - string bundleNameB = "com.ohos.systemui"; + string bundleNameB = "com.example.fileshareb"; uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); int32_t flag = 3; @@ -114,10 +112,9 @@ namespace { HWTEST_F(FileShareTest, File_share_CreateShareFile_0002, testing::ext::TestSize.Level1) { GTEST_LOG_(INFO) << "FileShareTest-begin File_share_CreateShareFile_0002"; - int32_t uid = -1; - uid = OHOS::IPCSkeleton::GetCallingUid(); + int32_t uid = 100; - string bundleNameA = "com.ohos.settingsdata"; + string bundleNameA = "com.example.filesharea"; string fileStr = "/data/app/el2/" + to_string(uid) + "/base/" + bundleNameA + "/files/test.txt"; int32_t fd = open(fileStr.c_str(), O_RDWR | O_CREAT); ASSERT_TRUE(fd != -1) << "FileShareTest Create File Failed!"; @@ -141,16 +138,15 @@ namespace { HWTEST_F(FileShareTest, File_share_CreateShareFile_0003, testing::ext::TestSize.Level1) { GTEST_LOG_(INFO) << "FileShareTest-begin File_share_CreateShareFile_0003"; - int32_t uid = -1; - uid = OHOS::IPCSkeleton::GetCallingUid(); + int32_t uid = 100; - string bundleNameA = "com.ohos.settingsdata"; + string bundleNameA = "com.example.filesharea"; string fileStr = "/data/app/el2/" + to_string(uid) + "/base/" + bundleNameA + "/files/test.txt"; int32_t fd = open(fileStr.c_str(), O_RDWR | O_CREAT); ASSERT_TRUE(fd != -1) << "FileShareTest Create File Failed!"; string uri = ""; - string bundleNameB = "com.ohos.systemui"; + string bundleNameB = "com.example.fileshareb"; uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); int32_t flag = 3; @@ -170,16 +166,15 @@ namespace { HWTEST_F(FileShareTest, File_share_CreateShareFile_0004, testing::ext::TestSize.Level1) { GTEST_LOG_(INFO) << "FileShareTest-begin File_share_CreateShareFile_0004"; - int32_t uid = -1; - uid = OHOS::IPCSkeleton::GetCallingUid(); + int32_t uid = 100; - string bundleNameA = "com.ohos.settingsdata"; + string bundleNameA = "com.example.filesharea"; string fileStr = "/data/app/el2/" + to_string(uid) + "/base/" + bundleNameA + "/files/test.txt"; int32_t fd = open(fileStr.c_str(), O_RDWR | O_CREAT); ASSERT_TRUE(fd != -1) << "FileShareTest Create File Failed!"; string uri = ""; - string bundleNameB = "com.ohos.systemui"; + string bundleNameB = "com.example.fileshareb"; uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); int32_t flag = 4; @@ -199,13 +194,12 @@ namespace { HWTEST_F(FileShareTest, File_share_DeleteShareFile_0005, testing::ext::TestSize.Level1) { GTEST_LOG_(INFO) << "FileShareTest-begin File_share_DeleteShareFile_0005"; - int32_t uid = -1; - uid = OHOS::IPCSkeleton::GetCallingUid(); + int32_t uid = 100; - string bundleNameB = "com.ohos.systemui"; + string bundleNameB = "com.example.fileshareb"; uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); vector sharePathList; - string bundleNameA = "com.ohos.settingsdata"; + string bundleNameA = "com.example.filesharea"; string uri = "file://" + bundleNameA + "/data/storage/el2/base/files/test.txt"; sharePathList.push_back(uri); int32_t ret = DeleteShareFile(tokenId, sharePathList); @@ -226,7 +220,7 @@ namespace { GTEST_LOG_(INFO) << "FileShareTest-begin File_share_DeleteShareFile_0006"; uint32_t tokenId = 104; vector sharePathList; - string bundleNameA = "com.ohos.settingsdata"; + string bundleNameA = "com.example.filesharea"; string uri = "file://" + bundleNameA + "/data/storage/el2/base/files/test.txt"; sharePathList.push_back(uri); int32_t ret = DeleteShareFile(tokenId, sharePathList); @@ -245,16 +239,15 @@ namespace { HWTEST_F(FileShareTest, File_share_DeleteShareFile_0007, testing::ext::TestSize.Level1) { GTEST_LOG_(INFO) << "FileShareTest-begin File_share_DeleteShareFile_0007"; - int32_t uid = -1; - uid = OHOS::IPCSkeleton::GetCallingUid(); + int32_t uid = 100; - string bundleNameA = "com.ohos.settingsdata"; + string bundleNameA = "com.example.filesharea"; string fileStr = "/data/app/el2/" + to_string(uid) + "/base/" + bundleNameA + "/files/test.txt"; int32_t fd = open(fileStr.c_str(), O_RDWR | O_CREAT); ASSERT_TRUE(fd != -1) << "FileShareTest Create File Failed!"; string uri = "file://" + bundleNameA + "/data/storage/el2/base/files/test.txt"; - string bundleNameB = "com.ohos.systemui"; + string bundleNameB = "com.example.fileshareb"; uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); int32_t flag = 3; diff --git a/test/unittest/resource/bundle_dependencies/fileShareA/AppScope/app.json b/test/unittest/resource/bundle_dependencies/fileShareA/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..7e27d9d8f37d29a9f60d42c02c3315de183f0b15 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareA/AppScope/app.json @@ -0,0 +1,15 @@ +{ + "app": { + "bundleName": "com.example.filesharea", + "debug": true, + "icon": "$media:app_icon", + "iconId": 16777217, + "label": "$string:app_name", + "labelId": 16777216, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0" + } +} diff --git a/test/unittest/resource/bundle_dependencies/fileShareA/AppScope/resources/base/element/string.json b/test/unittest/resource/bundle_dependencies/fileShareA/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..98a3285a7262d706b9e78b54c51e06ae949e97db --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareA/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "filesharea" + } + ] +} diff --git a/test/unittest/resource/bundle_dependencies/fileShareA/AppScope/resources/base/media/app_icon.png b/test/unittest/resource/bundle_dependencies/fileShareA/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/test/unittest/resource/bundle_dependencies/fileShareA/AppScope/resources/base/media/app_icon.png differ diff --git a/test/unittest/resource/bundle_dependencies/fileShareA/BUILD.gn b/test/unittest/resource/bundle_dependencies/fileShareA/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..742f27f3b39cbd1047fc18c42c79173e0fa0acbd --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareA/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("//build/ohos.gni") + +ohos_hap("filesharea") { + hap_profile = "entry/src/main/module.json" + hap_name = "filesharea" + subsystem_name = "filemanagement" + part_name = "app_file_service" + final_hap_path = "$root_out_dir/tests/unittest/filemanagement/app_file_service/resource/${hap_name}.hap" + testonly = true + deps = [ + ":fileShareA_ets_assets", + ":fileShareA_ets_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" +} + +ohos_app_scope("fileShareA_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("fileShareA_ets_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("fileShareA_ets_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":fileShareA_app_profile" ] + hap_profile = "entry/src/main/module.json" +} \ No newline at end of file diff --git a/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/ets/Application/MyAbilityStage.ts b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/ets/Application/MyAbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..3dcdaefc7db6ded2e027ec85e3d6309de0314e94 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/ets/Application/MyAbilityStage.ts @@ -0,0 +1,25 @@ +/* + * 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'; +import hilog from '@ohos.hilog'; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'AbilityStage onCreate'); + } +} \ No newline at end of file diff --git a/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/ets/entryability/EntryAbility.ts b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/ets/entryability/EntryAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b5b72a3776f5d28b778138bbeeb7b62faf699d4 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/ets/entryability/EntryAbility.ts @@ -0,0 +1,66 @@ +/* + * 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 UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import Window from '@ohos.window' + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); + } + + onDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: Window.WindowStage) { + // Main window is created, set main page for this ability + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/ets/pages/Index.ets b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e7dbe4860852e071fadd87c1790bf382dfb69814 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,31 @@ +/* + * 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. + */ + +@Entry +@Component +struct Index { + @State message: string = 'hello world' + + build() { + Column() { + Row() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold).width('100%') + }.width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/module.json b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..744de4947a3779088b8c551e3bef74beda2255e8 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntrance": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/resources/base/element/color.json b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..d66f9a7d4ac61fb8d215239ab3620b7bcd77bf33 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/resources/base/element/string.json b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1bdc8c87dbdd03cd40983baa7fdfd49e85297542 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "filesharea" + } + ] +} \ No newline at end of file diff --git a/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/resources/base/media/icon.png b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/resources/base/media/icon.png differ diff --git a/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/resources/base/profile/main_pages.json b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareA/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/test/unittest/resource/bundle_dependencies/fileShareA/signature/openharmony_sx.p7b b/test/unittest/resource/bundle_dependencies/fileShareA/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..070df0c40f6f5cadedecdf8e58ecc6c98a24ac6f Binary files /dev/null and b/test/unittest/resource/bundle_dependencies/fileShareA/signature/openharmony_sx.p7b differ diff --git a/test/unittest/resource/bundle_dependencies/fileShareB/AppScope/app.json b/test/unittest/resource/bundle_dependencies/fileShareB/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..4cc67aadb46dde2b4417e4ffd6dfea723be05c21 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareB/AppScope/app.json @@ -0,0 +1,15 @@ +{ + "app": { + "bundleName": "com.example.fileshareb", + "debug": true, + "icon": "$media:app_icon", + "iconId": 16777217, + "label": "$string:app_name", + "labelId": 16777216, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0" + } +} diff --git a/test/unittest/resource/bundle_dependencies/fileShareB/AppScope/resources/base/element/string.json b/test/unittest/resource/bundle_dependencies/fileShareB/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b0f1f1b4e40d6fd829e6d9695dcaf7629f5825e4 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareB/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "fileshareb" + } + ] +} diff --git a/test/unittest/resource/bundle_dependencies/fileShareB/AppScope/resources/base/media/app_icon.png b/test/unittest/resource/bundle_dependencies/fileShareB/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/test/unittest/resource/bundle_dependencies/fileShareB/AppScope/resources/base/media/app_icon.png differ diff --git a/test/unittest/resource/bundle_dependencies/fileShareB/BUILD.gn b/test/unittest/resource/bundle_dependencies/fileShareB/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..7109a036f406e8274345424b9142dec156a8daf8 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareB/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("//build/ohos.gni") + +ohos_hap("fileshareb") { + hap_profile = "entry/src/main/module.json" + hap_name = "fileshareb" + subsystem_name = "filemanagement" + part_name = "app_file_service" + final_hap_path = "$root_out_dir/tests/unittest/filemanagement/app_file_service/resource/${hap_name}.hap" + testonly = true + deps = [ + ":fileShareB_ets_assets", + ":fileShareB_ets_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" +} + +ohos_js_assets("fileShareB_ets_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_app_scope("fileShareB_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_resources("fileShareB_ets_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":fileShareB_app_profile" ] + hap_profile = "entry/src/main/module.json" +} \ No newline at end of file diff --git a/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/ets/Application/MyAbilityStage.ts b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/ets/Application/MyAbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..3dcdaefc7db6ded2e027ec85e3d6309de0314e94 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/ets/Application/MyAbilityStage.ts @@ -0,0 +1,25 @@ +/* + * 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'; +import hilog from '@ohos.hilog'; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'AbilityStage onCreate'); + } +} \ No newline at end of file diff --git a/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/ets/entryability/EntryAbility.ts b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/ets/entryability/EntryAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b5b72a3776f5d28b778138bbeeb7b62faf699d4 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/ets/entryability/EntryAbility.ts @@ -0,0 +1,66 @@ +/* + * 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 UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import Window from '@ohos.window' + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); + } + + onDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: Window.WindowStage) { + // Main window is created, set main page for this ability + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/ets/pages/Index.ets b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e7dbe4860852e071fadd87c1790bf382dfb69814 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,31 @@ +/* + * 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. + */ + +@Entry +@Component +struct Index { + @State message: string = 'hello world' + + build() { + Column() { + Row() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold).width('100%') + }.width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/module.json b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..744de4947a3779088b8c551e3bef74beda2255e8 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntrance": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/resources/base/element/color.json b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..d66f9a7d4ac61fb8d215239ab3620b7bcd77bf33 --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/resources/base/element/string.json b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c88a4bf99d7d948e1b6ea72d9baf9fa38e9dffcf --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "fileshareb" + } + ] +} \ No newline at end of file diff --git a/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/resources/base/media/icon.png b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/resources/base/media/icon.png differ diff --git a/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/resources/base/profile/main_pages.json b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/test/unittest/resource/bundle_dependencies/fileShareB/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/test/unittest/resource/bundle_dependencies/fileShareB/signature/openharmony_sx.p7b b/test/unittest/resource/bundle_dependencies/fileShareB/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..5f33c87f0ba7ef7e07f50da23d7d5bdcabc31802 Binary files /dev/null and b/test/unittest/resource/bundle_dependencies/fileShareB/signature/openharmony_sx.p7b differ diff --git a/test/unittest/resource/ohos_test.xml b/test/unittest/resource/ohos_test.xml index 966c8ea6fe8417224b00e767934a6637eddf5157..fd097f19c8799e1f9baedbbf486b0a44b92f97f5 100644 --- a/test/unittest/resource/ohos_test.xml +++ b/test/unittest/resource/ohos_test.xml @@ -19,4 +19,16 @@