From 5245ccff478d0554fc8712af7d8fa2c6d8887010 Mon Sep 17 00:00:00 2001 From: liqiang Date: Mon, 22 May 2023 17:04:54 +0800 Subject: [PATCH] IssueNo: Description:remove unused functions Sig: SIG_ApplicationFramework Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: liqiang Change-Id: I9f2054492740e10c9511842104622a2e1e520281 --- frameworks/native/ability/native/BUILD.gn | 8 - frameworks/native/ability/native/ability.cpp | 2 - .../native/ability/native/ability_impl.cpp | 8 +- .../connect_callback_proxy.cpp | 69 -- .../connect_callback_stub.cpp | 74 -- .../continuation_connector.cpp | 272 ------ .../continuation_device_callback_proxy.cpp | 57 -- .../continuation_register_manager.cpp | 122 --- .../continuation_register_manager_proxy.cpp | 301 ------- .../remote_register_service_proxy.cpp | 167 ---- .../remote_register_service_stub.cpp | 136 --- .../native/appkit/app/context_container.cpp | 124 +-- frameworks/native/appkit/app/context_deal.cpp | 190 +--- .../native/appkit/app/ohos_application.cpp | 134 +-- .../kits/native/ability/native/ability.h | 2 - .../connect_callback_proxy.h | 52 -- .../connect_callback_stub.h | 48 - .../continuation_connector.h | 154 ---- .../continuation_device_callback_proxy.h | 55 -- .../continuation_register_manager.h | 81 -- .../continuation_register_manager_proxy.h | 172 ---- .../continuation_request.h | 32 - .../remote_register_service_proxy.h | 69 -- .../remote_register_service_stub.h | 45 - interfaces/kits/native/appkit/app/context.h | 94 +- .../native/appkit/app/context_container.h | 98 +-- .../kits/native/appkit/app/context_deal.h | 112 +-- .../abilitycontext_fuzzer.cpp | 13 +- .../include/mock_application.cpp | 1 - .../DemoAbility/demo_ability_test.cpp | 1 - .../ability_test/ability_context_test.cpp | 117 +-- test/moduletest/mock/include/mock_context.h | 12 - test/unittest/BUILD.gn | 1 - test/unittest/continuation_test/BUILD.gn | 29 - .../connect_callback_proxy_test/BUILD.gn | 63 -- .../connect_callback_proxy_test.cpp | 160 ---- .../connect_callback_stub_test/BUILD.gn | 63 -- .../connect_callback_stub_test.cpp | 207 ----- .../continuation_connector_test/BUILD.gn | 75 -- .../continuation_connector_test.cpp | 832 ------------------ .../BUILD.gn | 70 -- ...ontinuation_device_callback_proxy_test.cpp | 140 --- .../BUILD.gn | 109 --- ...ntinuation_register_manager_proxy_test.cpp | 675 -------------- .../BUILD.gn | 109 --- .../continuation_register_manager_test.cpp | 339 ------- .../BUILD.gn | 68 -- .../remote_register_service_proxy_test.cpp | 540 ------------ .../BUILD.gn | 68 -- .../remote_register_service_stub_test.cpp | 429 --------- .../ability_context_interface1_test.cpp | 321 ------- .../ability_context_test.cpp | 18 - .../context_container_test.cpp | 558 +----------- .../context_deal_interface1_test.cpp | 294 ------- .../context_deal_test.cpp | 251 +----- 55 files changed, 35 insertions(+), 8206 deletions(-) delete mode 100644 frameworks/native/ability/native/continuation/remote_register_service/connect_callback_proxy.cpp delete mode 100644 frameworks/native/ability/native/continuation/remote_register_service/connect_callback_stub.cpp delete mode 100644 frameworks/native/ability/native/continuation/remote_register_service/continuation_connector.cpp delete mode 100644 frameworks/native/ability/native/continuation/remote_register_service/continuation_device_callback_proxy.cpp delete mode 100644 frameworks/native/ability/native/continuation/remote_register_service/continuation_register_manager.cpp delete mode 100644 frameworks/native/ability/native/continuation/remote_register_service/continuation_register_manager_proxy.cpp delete mode 100644 frameworks/native/ability/native/continuation/remote_register_service/remote_register_service_proxy.cpp delete mode 100644 frameworks/native/ability/native/continuation/remote_register_service/remote_register_service_stub.cpp delete mode 100644 interfaces/kits/native/ability/native/continuation/remote_register_service/connect_callback_proxy.h delete mode 100644 interfaces/kits/native/ability/native/continuation/remote_register_service/connect_callback_stub.h delete mode 100644 interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_connector.h delete mode 100644 interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_device_callback_proxy.h delete mode 100644 interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_register_manager.h delete mode 100644 interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_register_manager_proxy.h delete mode 100644 interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_request.h delete mode 100644 interfaces/kits/native/ability/native/continuation/remote_register_service/remote_register_service_proxy.h delete mode 100644 interfaces/kits/native/ability/native/continuation/remote_register_service/remote_register_service_stub.h delete mode 100644 test/unittest/continuation_test/BUILD.gn delete mode 100644 test/unittest/continuation_test/remote_register_service_test/connect_callback_proxy_test/BUILD.gn delete mode 100644 test/unittest/continuation_test/remote_register_service_test/connect_callback_proxy_test/connect_callback_proxy_test.cpp delete mode 100644 test/unittest/continuation_test/remote_register_service_test/connect_callback_stub_test/BUILD.gn delete mode 100644 test/unittest/continuation_test/remote_register_service_test/connect_callback_stub_test/connect_callback_stub_test.cpp delete mode 100644 test/unittest/continuation_test/remote_register_service_test/continuation_connector_test/BUILD.gn delete mode 100644 test/unittest/continuation_test/remote_register_service_test/continuation_connector_test/continuation_connector_test.cpp delete mode 100644 test/unittest/continuation_test/remote_register_service_test/continuation_device_callback_proxy_test/BUILD.gn delete mode 100644 test/unittest/continuation_test/remote_register_service_test/continuation_device_callback_proxy_test/continuation_device_callback_proxy_test.cpp delete mode 100644 test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_proxy_test/BUILD.gn delete mode 100644 test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_proxy_test/continuation_register_manager_proxy_test.cpp delete mode 100644 test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_test/BUILD.gn delete mode 100644 test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_test/continuation_register_manager_test.cpp delete mode 100644 test/unittest/continuation_test/remote_register_service_test/remote_register_service_proxy_test/BUILD.gn delete mode 100644 test/unittest/continuation_test/remote_register_service_test/remote_register_service_proxy_test/remote_register_service_proxy_test.cpp delete mode 100644 test/unittest/continuation_test/remote_register_service_test/remote_register_service_stub_test/BUILD.gn delete mode 100644 test/unittest/continuation_test/remote_register_service_test/remote_register_service_stub_test/remote_register_service_stub_test.cpp diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index ed7e09be46b..501ba4bb088 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -538,14 +538,6 @@ ohos_shared_library("continuation_ipc") { "${ability_runtime_native_path}/ability/native/continuation/distributed/reverse_continuation_scheduler_replica.cpp", "${ability_runtime_native_path}/ability/native/continuation/distributed/reverse_continuation_scheduler_replica_proxy.cpp", "${ability_runtime_native_path}/ability/native/continuation/distributed/reverse_continuation_scheduler_replica_stub.cpp", - "${ability_runtime_native_path}/ability/native/continuation/remote_register_service/connect_callback_proxy.cpp", - "${ability_runtime_native_path}/ability/native/continuation/remote_register_service/connect_callback_stub.cpp", - "${ability_runtime_native_path}/ability/native/continuation/remote_register_service/continuation_connector.cpp", - "${ability_runtime_native_path}/ability/native/continuation/remote_register_service/continuation_device_callback_proxy.cpp", - "${ability_runtime_native_path}/ability/native/continuation/remote_register_service/continuation_register_manager.cpp", - "${ability_runtime_native_path}/ability/native/continuation/remote_register_service/continuation_register_manager_proxy.cpp", - "${ability_runtime_native_path}/ability/native/continuation/remote_register_service/remote_register_service_proxy.cpp", - "${ability_runtime_native_path}/ability/native/continuation/remote_register_service/remote_register_service_stub.cpp", ] configs = [ ":ability_config" ] diff --git a/frameworks/native/ability/native/ability.cpp b/frameworks/native/ability/native/ability.cpp index 8e6d4db8e87..df94ea9993c 100644 --- a/frameworks/native/ability/native/ability.cpp +++ b/frameworks/native/ability/native/ability.cpp @@ -25,8 +25,6 @@ #include "configuration_convertor.h" #include "connection_manager.h" #include "continuation_manager.h" -#include "continuation_register_manager.h" -#include "continuation_register_manager_proxy.h" #include "data_ability_operation.h" #include "data_ability_predicates.h" #include "data_ability_result.h" diff --git a/frameworks/native/ability/native/ability_impl.cpp b/frameworks/native/ability/native/ability_impl.cpp index 7809e317f65..a9f2651effa 100644 --- a/frameworks/native/ability/native/ability_impl.cpp +++ b/frameworks/native/ability/native/ability_impl.cpp @@ -573,14 +573,14 @@ void AbilityImpl::AfterFocused() void AbilityImpl::AfterFocusedCommon(bool isFocused) { - auto task = [abilityImpl = weak_from_this(), focuseMode = isFocused]() { + auto task = [abilityImpl = weak_from_this(), focusMode = isFocused]() { auto impl = abilityImpl.lock(); if (impl == nullptr) { return; } if (!impl->ability_ || !impl->ability_->GetAbilityInfo()) { - HILOG_WARN("AbilityImpl::%{public}s failed", focuseMode ? "AfterFocused" : "AfterUnFocused"); + HILOG_WARN("AbilityImpl::%{public}s failed", focusMode ? "AfterFocused" : "AfterUnFocused"); return; } HILOG_INFO("isStageBasedModel: %{public}d", impl->ability_->GetAbilityInfo()->isStageBasedModel); @@ -595,7 +595,7 @@ void AbilityImpl::AfterFocusedCommon(bool isFocused) return; } auto& jsAbility = static_cast(*(impl->ability_)); - if (focuseMode) { + if (focusMode) { applicationContext->DispatchWindowStageFocus(jsAbility.GetJsAbility(), jsAbility.GetJsWindowStage()); } else { applicationContext->DispatchWindowStageUnfocus(jsAbility.GetJsAbility(), jsAbility.GetJsWindowStage()); @@ -608,7 +608,7 @@ void AbilityImpl::AfterFocusedCommon(bool isFocused) return; } auto info = impl->ability_->GetLifeCycleStateInfo(); - if (focuseMode) { + if (focusMode) { info.state = AbilityLifeCycleState::ABILITY_STATE_ACTIVE; } else { info.state = AbilityLifeCycleState::ABILITY_STATE_INACTIVE; diff --git a/frameworks/native/ability/native/continuation/remote_register_service/connect_callback_proxy.cpp b/frameworks/native/ability/native/continuation/remote_register_service/connect_callback_proxy.cpp deleted file mode 100644 index 3f70e3bdc18..00000000000 --- a/frameworks/native/ability/native/continuation/remote_register_service/connect_callback_proxy.cpp +++ /dev/null @@ -1,69 +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. - */ -#include "connect_callback_proxy.h" - -#include "extra_params.h" -#include "hilog_wrapper.h" -#include "string_ex.h" - -namespace OHOS { -namespace AppExecFwk { -/** - * @brief Remote device sends connection request. - * @param deviceId indicators id of connection device. - * @param deviceType indicators type of connection device. - * @return none - */ -void ConnectCallbackProxy::Connect(const string &deviceId, const string &deviceType) -{ - HILOG_INFO("%{public}s called begin", __func__); - MessageParcel data; - if (!data.WriteInterfaceToken(IConnectCallback::GetDescriptor()) || !data.WriteString(deviceId) || - !data.WriteString(deviceType)) { - HILOG_ERROR("%{public}s params is wrong", __func__); - return; - } - RemoteRequest(data, COMMAND_CONNECT); - HILOG_INFO("%{public}s called end", __func__); -} -/** - * @brief Remote device sends disconnection request. - * @param deviceId indicators id of disconnection device. - * @return none - */ -void ConnectCallbackProxy::Disconnect(const string &deviceId) -{ - HILOG_INFO("%{public}s called begin", __func__); - MessageParcel data; - if (!data.WriteInterfaceToken(IConnectCallback::GetDescriptor()) || !data.WriteString(deviceId)) { - HILOG_ERROR("%{public}s params is wrong", __func__); - return; - } - RemoteRequest(data, COMMAND_DISCONNECT); - HILOG_INFO("%{public}s called end", __func__); -} -void ConnectCallbackProxy::RemoteRequest(MessageParcel &data, int commandDisconnect) -{ - HILOG_INFO("%{public}s called begin", __func__); - MessageParcel reply; - MessageOption option; - if (Remote() == nullptr) { - return; - } - Remote()->SendRequest(commandDisconnect, data, reply, option); - HILOG_INFO("%{public}s called begin", __func__); -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/frameworks/native/ability/native/continuation/remote_register_service/connect_callback_stub.cpp b/frameworks/native/ability/native/continuation/remote_register_service/connect_callback_stub.cpp deleted file mode 100644 index a2e89a0ee01..00000000000 --- a/frameworks/native/ability/native/continuation/remote_register_service/connect_callback_stub.cpp +++ /dev/null @@ -1,74 +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. - */ -#include "connect_callback_stub.h" - -#include "ipc_types.h" -#include "hilog_wrapper.h" -#include "string_ex.h" - -namespace OHOS { -namespace AppExecFwk { -ConnectCallbackStub::ConnectCallbackStub() -{ - memberFuncMap_[COMMAND_CONNECT] = &ConnectCallbackStub::ConnectInner; - memberFuncMap_[COMMAND_DISCONNECT] = &ConnectCallbackStub::DisconnectInner; -} - -int ConnectCallbackStub::ConnectInner(MessageParcel &data, MessageParcel &reply) -{ - HILOG_INFO("%{public}s called begin", __func__); - string deviceId = Str16ToStr8(data.ReadString16()); - string deviceType = Str16ToStr8(data.ReadString16()); - Connect(deviceId, deviceType); - HILOG_INFO("%{public}s called end", __func__); - return OHOS::ERR_NONE; -} - -int ConnectCallbackStub::DisconnectInner(MessageParcel &data, MessageParcel &reply) -{ - HILOG_INFO("%{public}s called begin", __func__); - string deviceId = Str16ToStr8(data.ReadString16()); - Disconnect(deviceId); - HILOG_INFO("%{public}s called end", __func__); - return OHOS::ERR_NONE; -} -/** - * @brief Remote device sends connection or disconnection request. - * @param Code indicators code of the connection or disconnection request function. - * @param data indicators receives the message object. - * @param reply indicators reply the message object. - * @return none - */ -int ConnectCallbackStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - HILOG_INFO("%{public}s called", __func__); - std::u16string token = data.ReadInterfaceToken(); - if (token.compare(IConnectCallback::GetDescriptor()) != 0) { - HILOG_ERROR("%{public}s Descriptor is wrong", __func__); - return OHOS::ERR_INVALID_REPLY; - } - auto localFuncIt = memberFuncMap_.find(code); - if (localFuncIt != memberFuncMap_.end()) { - auto memberFunc = localFuncIt->second; - if (memberFunc != nullptr) { - return (this->*memberFunc)(data, reply); - } - } - HILOG_INFO("ConnectCallbackStub::OnRemoteRequest, default case, need check."); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/frameworks/native/ability/native/continuation/remote_register_service/continuation_connector.cpp b/frameworks/native/ability/native/continuation/remote_register_service/continuation_connector.cpp deleted file mode 100644 index 1728be837b4..00000000000 --- a/frameworks/native/ability/native/continuation/remote_register_service/continuation_connector.cpp +++ /dev/null @@ -1,272 +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. - */ - -#include "continuation_connector.h" - -#include "continuation_device_callback_proxy.h" -#include "hilog_wrapper.h" -#include "remote_register_service_proxy.h" - -namespace OHOS { -namespace AppExecFwk { -sptr ContinuationConnector::instance_ = nullptr; -std::mutex ContinuationConnector::mutex_; -const std::string ContinuationConnector::CONNECTOR_DEVICE_ID(""); -const std::string ContinuationConnector::CONNECTOR_BUNDLE_NAME("com.ohos.controlcenter"); -const std::string ContinuationConnector::CONNECTOR_ABILITY_NAME( - "com.ohos.controlcenter.fatransfer.service.FeatureAbilityRegisterService"); - -ContinuationConnector::ContinuationConnector(const std::weak_ptr &context) : context_(context) -{} - -/** - * @brief get singleton of Class ContinuationConnector - * - * @param context: the running context for appcontext - * - * @return The singleton of ContinuationConnector - */ -sptr ContinuationConnector::GetInstance(const std::weak_ptr &context) -{ - if (instance_ == nullptr) { - std::lock_guard lock(mutex_); - if (instance_ == nullptr) { - instance_ = sptr(new (std::nothrow) ContinuationConnector(context)); - } - } - return instance_; -} - -/** - * @brief This method is called back to receive the connection result after an ability calls the - * Ability#connectAbility(Want, IAbilityConnection) method to connect it to a Service ability. - * - * @param element: Indicates information about the connected Service ability. - * @param remote: Indicates the remote proxy object of the Service ability. - * @param resultCode: Indicates the connection result code. The value 0 indicates a successful connection, and any other - * value indicates a connection failure. - */ -void ContinuationConnector::OnAbilityConnectDone( - const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) -{ - HILOG_INFO("%{public}s called begin", __func__); - if (remoteObject == nullptr) { - HILOG_ERROR("ContinuationConnector::OnAbilityConnectDone failed, remote is nullptr"); - return; - } - remoteRegisterService_ = iface_cast(remoteObject); - if (remoteRegisterService_ == nullptr) { - HILOG_ERROR("ContinuationConnector::OnAbilityConnectDone failed, remoteRegisterService_ is nullptr"); - return; - } - isConnected_.store(true); - { - std::lock_guard lock(mutex_); - for (auto &iter : continuationRequestList_) { - iter->Execute(); - } - continuationRequestList_.clear(); - } - HILOG_INFO("%{public}s called end", __func__); -} - -/** - * @brief This method is called back to receive the disconnection result after the connected Service ability crashes or - * is killed. If the Service ability exits unexpectedly, all its connections are disconnected, and each ability - * previously connected to it will call onAbilityDisconnectDone. - * - * @param element: Indicates information about the disconnected Service ability. - * @param resultCode: Indicates the disconnection result code. The value 0 indicates a successful disconnection, and any - * other value indicates a disconnection failure. - */ -void ContinuationConnector::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) -{ - HILOG_INFO("%{public}s called begin", __func__); - remoteRegisterService_ = nullptr; - isConnected_.store(false); - HILOG_INFO("%{public}s called end", __func__); -} - -/** - * @brief bind remote ability of RemoteRegisterService. - * - * @param request: request for continuation. - */ -void ContinuationConnector::BindRemoteRegisterAbility(const std::shared_ptr &request) -{ - HILOG_INFO("%{public}s called begin", __func__); - std::shared_ptr tmpcontext = context_.lock(); - if (tmpcontext == nullptr) { - HILOG_ERROR("ContinuationConnector::BindRemoteRegisterAbility failed, context_.lock is nullptr"); - return; - } - if (request == nullptr) { - HILOG_ERROR("ContinuationConnector::BindRemoteRegisterAbility failed, request is nullptr"); - return; - } - if (IsAbilityConnected()) { - HILOG_INFO("ContinuationConnector::BindRemoteRegisterAbility, remote register bounded"); - request->Execute(); - return; - } - - { - std::lock_guard lock(mutex_); - continuationRequestList_.push_back(request); - } - BindRemoteRegisterAbility(); - HILOG_INFO("%{public}s called end", __func__); -} - -/** - * @brief unbind remote ability of RemoteRegisterService. - */ -void ContinuationConnector::UnbindRemoteRegisterAbility() -{ - HILOG_INFO("%{public}s called begin", __func__); - std::shared_ptr tmpcontext = context_.lock(); - if (tmpcontext == nullptr) { - HILOG_ERROR("ContinuationConnector::UnbindRemoteRegisterAbility failed, context_.lock is nullptr"); - return; - } - - tmpcontext->DisconnectAbility(this); - isConnected_.store(false); - remoteRegisterService_ = nullptr; - HILOG_INFO("%{public}s called end", __func__); -} - -/** - * @brief check whether connected to remote register service. - * - * @return bool true if connected, otherwise false. - */ -bool ContinuationConnector::IsAbilityConnected() -{ - return isConnected_.load(); -} - -/** - * @brief unregister to control center continuation register service. - * - * @param token token from register return value. - * - * @return bool result of unregister. - */ -bool ContinuationConnector::Unregister(int token) -{ - HILOG_INFO("%{public}s called begin", __func__); - if (remoteRegisterService_ == nullptr) { - HILOG_ERROR("ContinuationConnector::Unregister failed, remoteRegisterService_ is nullptr"); - return false; - } - - HILOG_INFO("%{public}s called end", __func__); - return remoteRegisterService_->Unregister(token); -} - -/** - * @brief notify continuation status to control center continuation register service. - * - * @param token token from register. - * @param deviceId device id. - * @param status device status. - * - * @return bool result of updateConnectStatus. - */ -bool ContinuationConnector::UpdateConnectStatus(int token, const std::string &deviceId, int status) -{ - HILOG_INFO("%{public}s called begin", __func__); - if (remoteRegisterService_ == nullptr) { - HILOG_ERROR("ContinuationConnector::UpdateConnectStatus failed, remoteRegisterService_ is nullptr"); - return false; - } - - HILOG_INFO("%{public}s called end", __func__); - return remoteRegisterService_->UpdateConnectStatus(token, deviceId, status); -} - -/** - * @brief notify control center continuation register service to show device list. - * - * @param token token from register - * @param parameter filter with supported device list. - * @return bool result of showDeviceList. - */ -bool ContinuationConnector::ShowDeviceList(int token, const AppExecFwk::ExtraParams ¶meter) -{ - HILOG_INFO("%{public}s called begin", __func__); - if (remoteRegisterService_ == nullptr) { - HILOG_ERROR("ContinuationConnector::ShowDeviceList failed, remoteRegisterService_ is nullptr"); - return false; - } - HILOG_INFO("%{public}s called end", __func__); - return remoteRegisterService_->ShowDeviceList(token, parameter); -} - -/** - * @brief register to control center continuation register service. - * - * @param context ability context. - * @param bundleName bundle name of ability. - * @param parameter filter with supported device list. - * @param callback callback for device connect and disconnect. - * - * @return int token. - */ -int ContinuationConnector::Register(std::weak_ptr &context, std::string bundleName, - const AppExecFwk::ExtraParams ¶meter, std::shared_ptr &callback) -{ - HILOG_INFO("%{public}s called begin", __func__); - std::shared_ptr pcontext = context.lock(); - if (pcontext == nullptr) { - HILOG_ERROR("ContinuationConnector::Register failed, pcontext is nullptr"); - return -1; - } - if (remoteRegisterService_ == nullptr) { - HILOG_ERROR("ContinuationConnector::Register failed, remoteRegisterService_ is nullptr"); - return -1; - } - sptr token = pcontext->GetToken(); - if (token == nullptr) { - HILOG_ERROR("ContinuationConnector::Register failed, token is nullptr"); - return -1; - } - - sptr callBackSptr(new (std::nothrow) ContinuationDeviceCallbackProxy(callback)); - - HILOG_INFO("%{public}s called end", __func__); - return remoteRegisterService_->Register(bundleName, token, parameter, callBackSptr); -} - -/** - * @brief bind remote ability of RemoteRegisterService. - */ -void ContinuationConnector::BindRemoteRegisterAbility() -{ - HILOG_INFO("%{public}s called begin", __func__); - std::shared_ptr tmpcontext = context_.lock(); - if (tmpcontext == nullptr) { - HILOG_ERROR("ContinuationConnector::BindRemoteRegisterAbility failed, context_.lock is nullptr"); - return; - } - Want want; - want.SetElementName(CONNECTOR_DEVICE_ID, CONNECTOR_BUNDLE_NAME, CONNECTOR_ABILITY_NAME); - want.AddFlags(Want::FLAG_NOT_OHOS_COMPONENT); - tmpcontext->ConnectAbility(want, this); - HILOG_INFO("%{public}s called end", __func__); -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/frameworks/native/ability/native/continuation/remote_register_service/continuation_device_callback_proxy.cpp b/frameworks/native/ability/native/continuation/remote_register_service/continuation_device_callback_proxy.cpp deleted file mode 100644 index e5e90400dec..00000000000 --- a/frameworks/native/ability/native/continuation/remote_register_service/continuation_device_callback_proxy.cpp +++ /dev/null @@ -1,57 +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. - */ -#include "continuation_device_callback_proxy.h" -#include "hilog_wrapper.h" -namespace OHOS { -namespace AppExecFwk { -/** - * A constructor used to create a {@link ohos.aafwk.ability.continuation.ContinuationDeviceCallbackProxy} instance. - */ -ContinuationDeviceCallbackProxy::ContinuationDeviceCallbackProxy(std::shared_ptr &callback) -{ - callback_ = std::weak_ptr(callback); -} -/** - * A destructor used to release a {@link ohos.aafwk.ability.continuation.ContinuationDeviceCallbackProxy} instance. - */ -ContinuationDeviceCallbackProxy::~ContinuationDeviceCallbackProxy() -{} -void ContinuationDeviceCallbackProxy::Connect(const std::string &deviceId, const std::string &deviceType) -{ - HILOG_INFO("%{public}s called begin", __func__); - std::shared_ptr callback = nullptr; - callback = callback_.lock(); - if (callback == nullptr) { - HILOG_ERROR("%{public}s callback is null", __func__); - return; - } - callback->OnDeviceConnectDone(deviceId, deviceType); - HILOG_INFO("%{public}s called end", __func__); -} - -void ContinuationDeviceCallbackProxy::Disconnect(const std::string &deviceId) -{ - HILOG_INFO("%{public}s called begin", __func__); - std::shared_ptr callback = nullptr; - callback = callback_.lock(); - if (callback == nullptr) { - HILOG_ERROR("%{public}s callback is null", __func__); - return; - } - callback->OnDeviceDisconnectDone(deviceId); - HILOG_INFO("%{public}s called end", __func__); -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/frameworks/native/ability/native/continuation/remote_register_service/continuation_register_manager.cpp b/frameworks/native/ability/native/continuation/remote_register_service/continuation_register_manager.cpp deleted file mode 100644 index 7c63b4512bc..00000000000 --- a/frameworks/native/ability/native/continuation/remote_register_service/continuation_register_manager.cpp +++ /dev/null @@ -1,122 +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. - */ -#include "continuation_register_manager.h" - -#include "continuation_device_callback_interface.h" -#include "continuation_register_manager_proxy.h" -#include "extra_params.h" -#include "hilog_wrapper.h" -#include "request_callback.h" - -namespace OHOS { -namespace AppExecFwk { -void ContinuationRegisterManager::Init( - const std::shared_ptr &continuationRegisterManagerProxy) -{ - continuationRegisterManagerProxy_ = continuationRegisterManagerProxy; -} - -/** - * register to controlcenter continuation register service. - * - * @param bundleName bundlename of ability. - * @param parameter filter with supported device list. - * @param callback callback for device connect and disconnect. - * @param requestCallback callback for this request, -1 means failed, otherwise is register token. - */ -void ContinuationRegisterManager::Register(const std::string &bundleName, const ExtraParams ¶meter, - const std::shared_ptr &deviceCallback, - const std::shared_ptr &requestCallback) -{ - HILOG_INFO("%{public}s called begin", __func__); - if (continuationRegisterManagerProxy_ != nullptr) { - continuationRegisterManagerProxy_->Register(bundleName, parameter, deviceCallback, requestCallback); - HILOG_INFO("%{public}s called end", __func__); - } else { - HILOG_ERROR("%{public}s, ContinuationRegisterManagerProxy is null", __func__); - } -} - -/** - * unregister to controlcenter continuation register service. - * - * @param token token from register return value. - * @param requestCallback callback for this request, -1 means failed, otherwise succeeded. - */ -void ContinuationRegisterManager::Unregister(int token, const std::shared_ptr &requestCallback) -{ - HILOG_INFO("%{public}s called begin", __func__); - if (continuationRegisterManagerProxy_ != nullptr) { - continuationRegisterManagerProxy_->Unregister(token, requestCallback); - HILOG_INFO("%{public}s called end", __func__); - } else { - HILOG_ERROR("%{public}s, ContinuationRegisterManagerProxy is null", __func__); - } -} - -/** - * notify continuation status to controlcenter continuation register service. - * - * @param token token from register. - * @param deviceId deviceid. - * @param status device status. - * @param requestCallback callback for this request, -1 means failed, otherwise successed. - */ -void ContinuationRegisterManager::UpdateConnectStatus( - int token, const std::string &deviceId, int status, const std::shared_ptr &requestCallback) -{ - HILOG_INFO("%{public}s called begin", __func__); - if (continuationRegisterManagerProxy_ != nullptr) { - continuationRegisterManagerProxy_->UpdateConnectStatus(token, deviceId, status, requestCallback); - HILOG_INFO("%{public}s called end", __func__); - } else { - HILOG_ERROR("%{public}s, ContinuationRegisterManagerProxy is null", __func__); - } -} - -/** - * notify controlcenter continuation register service to show device list. - * - * @param token token from register - * @param parameter filter with supported device list. - * @param requestCallback callback for this request, -1 means failed, otherwise successed. - */ -void ContinuationRegisterManager::ShowDeviceList( - int token, const ExtraParams ¶meter, const std::shared_ptr &requestCallback) -{ - HILOG_INFO("%{public}s called begin", __func__); - if (continuationRegisterManagerProxy_ != nullptr) { - continuationRegisterManagerProxy_->ShowDeviceList(token, parameter, requestCallback); - HILOG_INFO("%{public}s called end", __func__); - } else { - HILOG_ERROR("%{public}s, ContinuationRegisterManagerProxy is null", __func__); - } -} - -/** - * disconnect to controlcenter continuation register service. - */ -void ContinuationRegisterManager::Disconnect(void) -{ - HILOG_INFO("%{public}s called begin", __func__); - if (continuationRegisterManagerProxy_ != nullptr) { - continuationRegisterManagerProxy_->Disconnect(); - HILOG_INFO("%{public}s called end", __func__); - } else { - HILOG_ERROR("%{public}s, ContinuationRegisterManagerProxy is null", __func__); - } -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/frameworks/native/ability/native/continuation/remote_register_service/continuation_register_manager_proxy.cpp b/frameworks/native/ability/native/continuation/remote_register_service/continuation_register_manager_proxy.cpp deleted file mode 100644 index 1ebca166982..00000000000 --- a/frameworks/native/ability/native/continuation/remote_register_service/continuation_register_manager_proxy.cpp +++ /dev/null @@ -1,301 +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. - */ -#include "continuation_register_manager_proxy.h" - -#include "context.h" -#include "continuation_connector.h" -#include "continuation_device_callback_interface.h" -#include "continuation_request.h" -#include "hilog_wrapper.h" -#include "request_callback.h" - -namespace OHOS { -namespace AppExecFwk { -ContinuationRequestRegister::ContinuationRequestRegister(const std::string &bundleName, const ExtraParams ¶meter, - const std::shared_ptr &deviceCallback) -{ - parameter_ = parameter; - deviceCallback_ = deviceCallback; - bundleName_ = bundleName; -} - -void ContinuationRequestRegister::Execute(void) -{ - if (continuatinConnector_ == nullptr) { - HILOG_ERROR("%{public}s called, continuatinConnector is null", __func__); - return; - } - - int ret = continuatinConnector_->Register(context_, bundleName_, parameter_, deviceCallback_); - if (requestCallback_ != nullptr) { - requestCallback_->OnResult(ret); - HILOG_INFO("%{public}s called, ret=%{public}d", __func__, ret); - } else { - HILOG_ERROR("%{public}s called, requestCallback is null", __func__); - } -} - -ContinuationRequestUnRegister::ContinuationRequestUnRegister(int token) -{ - token_ = token; -} - -void ContinuationRequestUnRegister::Execute(void) -{ - if (continuatinConnector_ == nullptr) { - HILOG_ERROR("%{public}s called, continuatinConnector is null", __func__); - return; - } - - bool ret = continuatinConnector_->Unregister(token_); - if (requestCallback_ != nullptr) { - requestCallback_->OnResult(ret ? 0 : -1); - HILOG_INFO("%{public}s called, ret=%{public}d", __func__, (ret ? 0 : -1)); - } else { - HILOG_ERROR("%{public}s called, requestCallback is null", __func__); - } -} - -ContinuationRequestUpdateConnectStatus::ContinuationRequestUpdateConnectStatus( - int token, const std::string &deviceId, int status) -{ - token_ = token; - deviceId_ = deviceId; - status_ = status; -} - -void ContinuationRequestUpdateConnectStatus::Execute(void) -{ - if (continuatinConnector_ == nullptr) { - HILOG_ERROR("%{public}s called, continuatinConnector is null", __func__); - return; - } - - bool ret = continuatinConnector_->UpdateConnectStatus(token_, deviceId_, status_); - if (requestCallback_ != nullptr) { - requestCallback_->OnResult(ret ? 0 : -1); - HILOG_INFO("%{public}s called, ret=%{public}d", __func__, (ret ? 0 : -1)); - } else { - HILOG_ERROR("%{public}s called, requestCallback is null", __func__); - } -} - -ContinuationRequestShowDeviceList::ContinuationRequestShowDeviceList(int token, const ExtraParams ¶meter) -{ - token_ = token; - parameter_ = parameter; -} - -void ContinuationRequestShowDeviceList::Execute(void) -{ - if (continuatinConnector_ == nullptr) { - HILOG_ERROR("%{public}s called, continuatinConnector is null", __func__); - return; - } - - bool ret = continuatinConnector_->ShowDeviceList(token_, parameter_); - if (requestCallback_ != nullptr) { - requestCallback_->OnResult(ret ? 0 : -1); - HILOG_INFO("%{public}s called, ret=%{public}d", __func__, (ret ? 0 : -1)); - } else { - HILOG_ERROR("%{public}s called, requestCallback is null", __func__); - } -} - -ContinuationRegisterManagerProxy::ContinuationRegisterManagerProxy(const std::weak_ptr &context) -{ - context_ = context; - std::shared_ptr ctx = context_.lock(); - if (ctx != nullptr) { - applicationContext_ = std::weak_ptr(ctx->GetApplicationContext()); - } -} - -ContinuationRegisterManagerProxy::~ContinuationRegisterManagerProxy() -{} - -/** - * Registers an ability to be migrated with the Device+ control center and obtains the registration token assigned - * to the ability. - * - * @param bundleName Indicates the bundle name of the application whose ability is to be migrated. - * @param parameter Indicates the {@link ExtraParams} object containing the extra parameters used to filter - * the list of available devices. This parameter can be null. - * @param deviceCallback Indicates the callback to be invoked when the connection state of the selected device - * changes. - * @param requestCallback Indicates the callback to be invoked when the Device+ service is connected. - */ -void ContinuationRegisterManagerProxy::Register(const std::string &bundleName, const ExtraParams ¶meter, - const std::shared_ptr &deviceCallback, - const std::shared_ptr &requestCallback) -{ - HILOG_INFO("%{public}s called", __func__); - - if (context_.lock() == nullptr || applicationContext_.lock() == nullptr) { - HILOG_ERROR("%{public}s context or applicationContext is null", __func__); - return; - } - - ContinuationRequestRegister *pContinuationRequestRegister = - new (std::nothrow) ContinuationRequestRegister(bundleName, parameter, deviceCallback); - if (pContinuationRequestRegister != nullptr) { - pContinuationRequestRegister->SetContext(context_); - pContinuationRequestRegister->SetContinuationConnector(continuatinConnector_); - pContinuationRequestRegister->SetRequestCallback(requestCallback); - - std::shared_ptr request(pContinuationRequestRegister); - - SendRequest(applicationContext_, request); - } else { - HILOG_ERROR("%{public}s Create ContinuationRequestRegister failed", __func__); - } -} - -/** - * Unregisters a specified ability from the Device+ control center based on the token obtained during ability - * registration. - * - * @param token Indicates the registration token of the ability. - * @param requestCallback Indicates the callback to be invoked when the Device+ service is connected. - * This parameter can be null. - */ -void ContinuationRegisterManagerProxy::Unregister(int token, const std::shared_ptr &requestCallback) -{ - HILOG_INFO("%{public}s called", __func__); - - if (applicationContext_.lock() == nullptr) { - HILOG_INFO("%{public}s Context is null", __func__); - return; - } - - ContinuationRequestUnRegister *pContinuationRequestUnRegister = - new (std::nothrow) ContinuationRequestUnRegister(token); - if (pContinuationRequestUnRegister != nullptr) { - pContinuationRequestUnRegister->SetContinuationConnector(continuatinConnector_); - pContinuationRequestUnRegister->SetRequestCallback(requestCallback); - - std::shared_ptr request(pContinuationRequestUnRegister); - - SendRequest(applicationContext_, request); - } else { - HILOG_ERROR("%{public}s Create ContinuationRequestUnRegister failed", __func__); - } -} - -/** - * Updates the connection state of the device where the specified ability is successfully migrated. - * - * @param token Indicates the registration token of the ability. - * @param deviceId Indicates the ID of the device whose connection state is to be updated. - * @param status Indicates the connection state to update, which can be {@link DeviceConnectState#FAILURE}, - * {@link DeviceConnectState#IDLE}, {@link DeviceConnectState#CONNECTING}, {@link DeviceConnectState#CONNECTED}, - * or {@link DeviceConnectState#DIS_CONNECTING}. - * @param requestCallback Indicates the callback to be invoked when the Device+ service is connected. - * This parameter can be null. - */ -void ContinuationRegisterManagerProxy::UpdateConnectStatus( - int token, const std::string &deviceId, int status, const std::shared_ptr &requestCallback) -{ - HILOG_INFO("%{public}s called", __func__); - - if (applicationContext_.lock() == nullptr) { - HILOG_INFO("%{public}s Context is null", __func__); - return; - } - - ContinuationRequestUpdateConnectStatus *pContinuationRequestUpdateConnectStatus = - new (std::nothrow) ContinuationRequestUpdateConnectStatus(token, deviceId, status); - - if (pContinuationRequestUpdateConnectStatus != nullptr) { - pContinuationRequestUpdateConnectStatus->SetContinuationConnector(continuatinConnector_); - pContinuationRequestUpdateConnectStatus->SetRequestCallback(requestCallback); - - std::shared_ptr request(pContinuationRequestUpdateConnectStatus); - - SendRequest(applicationContext_, request); - } else { - HILOG_ERROR("%{public}s Create ContinuationRequestUpdateConnectStatus failed", __func__); - } -} - -/** - * Shows the list of devices that can be selected for ability migration on the distributed network. - * - * @param token Indicates the registration token of the ability. - * @param parameter Indicates the {@link ExtraParams} object containing the extra parameters used to filter - * the list of available devices. This parameter can be null. - * @param requestCallback Indicates the callback to be invoked when the Device+ service is connected. - * This parameter can be null. - */ -void ContinuationRegisterManagerProxy::ShowDeviceList( - int token, const ExtraParams ¶meter, const std::shared_ptr &requestCallback) -{ - HILOG_INFO("%{public}s called begin", __func__); - - if (applicationContext_.lock() == nullptr) { - HILOG_INFO("%{public}s Context is null", __func__); - return; - } - - ContinuationRequestShowDeviceList *pContinuationRequestShowDeviceList = - new (std::nothrow) ContinuationRequestShowDeviceList(token, parameter); - if (pContinuationRequestShowDeviceList != nullptr) { - pContinuationRequestShowDeviceList->SetContinuationConnector(continuatinConnector_); - pContinuationRequestShowDeviceList->SetRequestCallback(requestCallback); - - std::shared_ptr request(pContinuationRequestShowDeviceList); - - SendRequest(applicationContext_, request); - HILOG_INFO("%{public}s called end", __func__); - } else { - HILOG_ERROR("%{public}s Create ContinuationRequestShowDeviceList failed", __func__); - } -} - -/** - * Disconnects from the Device+ control center. - */ -void ContinuationRegisterManagerProxy::Disconnect(void) -{ - HILOG_INFO("%{public}s called begin", __func__); - - if (continuatinConnector_ != nullptr && continuatinConnector_->IsAbilityConnected()) { - continuatinConnector_->UnbindRemoteRegisterAbility(); - } - HILOG_INFO("%{public}s called end", __func__); -} - -void ContinuationRegisterManagerProxy::SendRequest( - const std::weak_ptr &context, const std::shared_ptr &request) -{ - HILOG_INFO("%{public}s called begin", __func__); - if (request == nullptr) { - HILOG_ERROR("%{public}s called, request is null", __func__); - return; - } - - if (continuatinConnector_ == nullptr) { - continuatinConnector_ = ContinuationConnector::GetInstance(context); - } - - if (!continuatinConnector_->IsAbilityConnected()) { - continuatinConnector_->BindRemoteRegisterAbility(request); - } else { - request->Execute(); - } - HILOG_INFO("%{public}s called end", __func__); -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/frameworks/native/ability/native/continuation/remote_register_service/remote_register_service_proxy.cpp b/frameworks/native/ability/native/continuation/remote_register_service/remote_register_service_proxy.cpp deleted file mode 100644 index 23b95aeb1c7..00000000000 --- a/frameworks/native/ability/native/continuation/remote_register_service/remote_register_service_proxy.cpp +++ /dev/null @@ -1,167 +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. - */ -#include "remote_register_service_proxy.h" -#include "hilog_wrapper.h" - -namespace OHOS { -namespace AppExecFwk { -/** - * register to controlcenter continuation register service. - * - * @param bundleName bundlename of ability. - * @param extras filter with supported device list. - * @param callback callback for device connect and disconnect. - */ -int RemoteRegisterServiceProxy::Register(const std::string &bundleName, const sptr &token, - const ExtraParams &extras, const sptr &callback) -{ - HILOG_INFO("%{public}s called", __func__); - - if (bundleName.empty() || token == nullptr || callback == nullptr) { - HILOG_ERROR("%{public}s param invalid", __func__); - return ERR_INVALID_DATA; - } - - auto remote = Remote(); - if (remote == nullptr) { - HILOG_ERROR("%{public}s remote is null", __func__); - return ERR_NULL_OBJECT; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor()) || !data.WriteString(bundleName) || - !data.WriteRemoteObject(token) || !data.WriteInt32(1) || !extras.Marshalling(data) || - !data.WriteRemoteObject(callback->AsObject())) { - HILOG_ERROR("%{public}s Failed to write transfer data.", __func__); - return IPC_INVOKER_WRITE_TRANS_ERR; - } - - MessageParcel reply; - MessageOption option; - int result = remote->SendRequest(COMMAND_REGISTER, data, reply, option); - if (result == ERR_NONE) { - HILOG_INFO("%{public}s SendRequest ok", __func__); - return reply.ReadInt32(); - } else { - HILOG_ERROR("%{public}s SendRequest error, result=%{public}d", __func__, result); - return IPC_INVOKER_TRANSLATE_ERR; - } -} - -/** - * unregister to controlcenter continuation register service. - * - * @param registerToken token from register return value. - */ -bool RemoteRegisterServiceProxy::Unregister(int registerToken) -{ - HILOG_INFO("%{public}s called", __func__); - - auto remote = Remote(); - if (remote == nullptr) { - HILOG_ERROR("%{public}s remote is null", __func__); - return false; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor()) || !data.WriteInt32(registerToken)) { - HILOG_ERROR("%{public}s Failed to write transfer data.", __func__); - return false; - } - - MessageParcel reply; - MessageOption option; - int32_t result = remote->SendRequest(COMMAND_UNREGISTER, data, reply, option); - if (result == ERR_NONE) { - HILOG_INFO("%{public}s SendRequest ok", __func__); - return reply.ReadInt32() == ERR_NONE; - } else { - HILOG_ERROR("%{public}s SendRequest error, result=%{public}d", __func__, result); - return false; - } -} - -/** - * notify continuation status to controlcenter continuation register service. - * - * @param registerToken token from register. - * @param deviceId deviceid. - * @param status device status. - */ -bool RemoteRegisterServiceProxy::UpdateConnectStatus(int registerToken, const std::string &deviceId, int status) -{ - HILOG_INFO("%{public}s called", __func__); - - auto remote = Remote(); - if (remote == nullptr) { - HILOG_ERROR("%{public}s remote is null", __func__); - return false; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor()) || !data.WriteInt32(registerToken) || - !data.WriteString(deviceId) || !data.WriteInt32(status)) { - HILOG_ERROR("%{public}s Failed to write transfer data.", __func__); - return false; - } - - MessageParcel reply; - MessageOption option; - int32_t result = remote->SendRequest(COMMAND_UPDATE_CONNECT_STATUS, data, reply, option); - if (result == ERR_NONE) { - HILOG_INFO("%{public}s SendRequest ok", __func__); - return reply.ReadInt32() == ERR_NONE; - } else { - HILOG_ERROR("%{public}s SendRequest error, result=%{public}d", __func__, result); - return false; - } -} - -/** - * notify controlcenter continuation register service to show device list. - * - * @param registerToken token from register - * @param extras filter with supported device list. - */ -bool RemoteRegisterServiceProxy::ShowDeviceList(int registerToken, const ExtraParams &extras) -{ - HILOG_INFO("%{public}s called", __func__); - - auto remote = Remote(); - if (remote == nullptr) { - HILOG_ERROR("%{public}s remote is null", __func__); - return false; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor()) || !data.WriteInt32(registerToken) || - !data.WriteInt32(1) || !extras.Marshalling(data)) { - HILOG_ERROR("%{public}s Failed to write transfer data.", __func__); - return false; - } - - MessageParcel reply; - MessageOption option; - int32_t result = remote->SendRequest(COMMAND_SHOW_DEVICE_LIST, data, reply, option); - if (result == ERR_NONE) { - HILOG_INFO("%{public}s SendRequest ok", __func__); - return reply.ReadInt32() == ERR_NONE; - } else { - HILOG_ERROR("%{public}s SendRequest error, result=%{public}d", __func__, result); - return false; - } -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/frameworks/native/ability/native/continuation/remote_register_service/remote_register_service_stub.cpp b/frameworks/native/ability/native/continuation/remote_register_service/remote_register_service_stub.cpp deleted file mode 100644 index ca667893726..00000000000 --- a/frameworks/native/ability/native/continuation/remote_register_service/remote_register_service_stub.cpp +++ /dev/null @@ -1,136 +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. - */ -#include "remote_register_service_stub.h" -#include "hilog_wrapper.h" - -namespace OHOS { -namespace AppExecFwk { -RemoteRegisterServiceStub::RemoteRegisterServiceStub() -{ - requestFuncMap_[COMMAND_REGISTER] = &RemoteRegisterServiceStub::RegisterInner; - requestFuncMap_[COMMAND_UNREGISTER] = &RemoteRegisterServiceStub::UnregisterInner; - requestFuncMap_[COMMAND_UPDATE_CONNECT_STATUS] = &RemoteRegisterServiceStub::UpdateConnectStatusInner; - requestFuncMap_[COMMAND_SHOW_DEVICE_LIST] = &RemoteRegisterServiceStub::ShowDeviceListInner; -} - -RemoteRegisterServiceStub::~RemoteRegisterServiceStub() -{ - requestFuncMap_.clear(); -} - -int RemoteRegisterServiceStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - HILOG_INFO("%{public}s called, cmd=%{public}d, flags=%{public}d", __func__, code, option.GetFlags()); - - std::u16string descriptor = IRemoteRegisterService::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - HILOG_INFO("%{public}s local descriptor is not equal to remote", __func__); - return ERR_INVALID_STATE; - } - - auto itFunc = requestFuncMap_.find(code); - if (itFunc != requestFuncMap_.end()) { - auto requestFunc = itFunc->second; - if (requestFunc != nullptr) { - return (this->*requestFunc)(data, reply); - } - } - - HILOG_INFO("%{public}s Not found cmd, need check.", __func__); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} - -int RemoteRegisterServiceStub::RegisterInner(MessageParcel &data, MessageParcel &reply) -{ - HILOG_INFO("%{public}s called begin", __func__); - std::string bundleName = data.ReadString(); - sptr token = data.ReadRemoteObject(); - ExtraParams *pExtras = nullptr; - int32_t extraId = data.ReadInt32(); - if (extraId != 0) { - pExtras = ExtraParams::Unmarshalling(data); - } - if (pExtras == nullptr) { - reply.WriteInt32(ERR_INVALID_DATA); - HILOG_ERROR("%{public}s Failed to read ExtraParams.", __func__); - return ERR_INVALID_DATA; - } - - sptr object = data.ReadRemoteObject(); - if (object == nullptr) { - delete pExtras; - pExtras = nullptr; - reply.WriteInt32(ERR_NULL_OBJECT); - HILOG_ERROR("%{public}s Failed to read IConnectCallback.", __func__); - return ERR_NULL_OBJECT; - } - - sptr callback = iface_cast(object); - int result = Register(bundleName, token, *pExtras, callback); - delete pExtras; - pExtras = nullptr; - reply.WriteInt32(result); - HILOG_INFO("%{public}s called end", __func__); - return NO_ERROR; -} - -int RemoteRegisterServiceStub::UnregisterInner(MessageParcel &data, MessageParcel &reply) -{ - HILOG_INFO("%{public}s called begin", __func__); - int registerToken = data.ReadInt32(); - bool result = Unregister(registerToken); - reply.WriteInt32(result ? ERR_NONE : IPC_STUB_ERR); - HILOG_INFO("%{public}s called end", __func__); - return NO_ERROR; -} - -int RemoteRegisterServiceStub::UpdateConnectStatusInner(MessageParcel &data, MessageParcel &reply) -{ - HILOG_INFO("%{public}s called begin", __func__); - int registerToken = data.ReadInt32(registerToken); - std::string deviceId = data.ReadString(); - int status = data.ReadInt32(); - bool result = UpdateConnectStatus(registerToken, deviceId, status); - reply.WriteInt32(result ? ERR_NONE : IPC_STUB_ERR); - HILOG_INFO("%{public}s called end", __func__); - return NO_ERROR; -} - -int RemoteRegisterServiceStub::ShowDeviceListInner(MessageParcel &data, MessageParcel &reply) -{ - HILOG_INFO("%{public}s called begin", __func__); - int registerToken = data.ReadInt32(); - ExtraParams *pExtras = nullptr; - int32_t extraId = data.ReadInt32(); - if (extraId != 0) { - pExtras = ExtraParams::Unmarshalling(data); - } - if (pExtras == nullptr) { - reply.WriteInt32(ERR_INVALID_DATA); - HILOG_ERROR("%{public}s Failed to read ExtraParams.", __func__); - return ERR_INVALID_DATA; - } - - bool result = ShowDeviceList(registerToken, *pExtras); - delete pExtras; - pExtras = nullptr; - reply.WriteInt32(result ? ERR_NONE : IPC_STUB_ERR); - HILOG_INFO("%{public}s called end", __func__); - return NO_ERROR; -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/frameworks/native/appkit/app/context_container.cpp b/frameworks/native/appkit/app/context_container.cpp index 4e515a82956..25b83756255 100644 --- a/frameworks/native/appkit/app/context_container.cpp +++ b/frameworks/native/appkit/app/context_container.cpp @@ -180,16 +180,6 @@ std::string ContextContainer::GetBundleName() const } } -std::string ContextContainer::GetBundleResourcePath() -{ - if (baseContext_ != nullptr) { - return baseContext_->GetBundleResourcePath(); - } else { - HILOG_ERROR("ContextContainer::GetBundleResourcePath baseContext_ is nullptr"); - return ""; - } -} - sptr ContextContainer::GetAbilityManager() { if (baseContext_ != nullptr) { @@ -210,15 +200,6 @@ std::string ContextContainer::GetAppType() } } -void ContextContainer::SetPattern(int patternId) -{ - if (baseContext_ != nullptr) { - baseContext_->SetPattern(patternId); - } else { - HILOG_ERROR("ContextContainer::SetPattern baseContext_ is nullptr"); - } -} - std::shared_ptr ContextContainer::GetHapModuleInfo() { if (baseContext_ != nullptr) { @@ -234,7 +215,7 @@ std::string ContextContainer::GetProcessName() return (processInfo_ != nullptr) ? processInfo_->GetProcessName() : ""; } -std::shared_ptr ContextContainer::CreateBundleContext(std::string bundleName, int flag, int accountId) +std::shared_ptr ContextContainer::CreateBundleContext(std::string bundleName, int accountId) { if (bundleName.empty()) { HILOG_ERROR("ContextContainer::CreateBundleContext bundleName is empty"); @@ -268,7 +249,8 @@ std::shared_ptr ContextContainer::CreateBundleContext(std::string bundl } std::shared_ptr appContext = std::make_shared(); - std::shared_ptr deal = std::make_shared(true); + std::shared_ptr deal = std::make_shared(); + deal->SetSystemAppFlag(true); // init resourceManager. InitResourceManager(bundleInfo, deal); @@ -334,86 +316,6 @@ void ContextContainer::SetUriString(const std::string &uri) uriString_ = uri; } -std::string ContextContainer::GetString(int resId) -{ - if (baseContext_ != nullptr) { - std::string ret = baseContext_->GetString(resId); - return ret; - } else { - HILOG_ERROR("ContextContainer::GetString baseContext_ is nullptr"); - return ""; - } -} - -std::vector ContextContainer::GetStringArray(int resId) -{ - if (baseContext_ != nullptr) { - return baseContext_->GetStringArray(resId); - } else { - HILOG_ERROR("ContextContainer::GetStringArray baseContext_ is nullptr"); - return std::vector(); - } -} - -std::vector ContextContainer::GetIntArray(int resId) -{ - if (baseContext_ != nullptr) { - return baseContext_->GetIntArray(resId); - } else { - HILOG_ERROR("ContextContainer::GetIntArray baseContext_ is nullptr"); - return std::vector(); - } -} - -std::map ContextContainer::GetTheme() -{ - if (baseContext_ != nullptr) { - return baseContext_->GetTheme(); - } else { - HILOG_ERROR("ContextContainer::GetTheme baseContext_ is nullptr"); - return std::map(); - } -} - -void ContextContainer::SetTheme(int themeId) -{ - if (baseContext_ != nullptr) { - baseContext_->SetTheme(themeId); - } else { - HILOG_ERROR("ContextContainer::SetTheme baseContext_ is nullptr"); - } -} - -std::map ContextContainer::GetPattern() -{ - if (baseContext_ != nullptr) { - return baseContext_->GetPattern(); - } else { - HILOG_ERROR("ContextContainer::GetPattern baseContext_ is nullptr"); - return std::map(); - } -} - -int ContextContainer::GetColor(int resId) -{ - if (baseContext_ != nullptr) { - return baseContext_->GetColor(resId); - } else { - HILOG_ERROR("ContextContainer::GetColor baseContext_ is nullptr"); - return INVALID_RESOURCE_VALUE; - } -} - -int ContextContainer::GetThemeId() -{ - if (baseContext_ != nullptr) { - return baseContext_->GetThemeId(); - } else { - HILOG_ERROR("ContextContainer::GetThemeId baseContext_ is nullptr"); - return -1; - } -} - int ContextContainer::GetDisplayOrientation() { if (baseContext_ != nullptr) { @@ -434,26 +336,6 @@ std::string ContextContainer::GetPreferencesDir() } } -void ContextContainer::SetColorMode(int mode) -{ - if (baseContext_ == nullptr) { - HILOG_ERROR("ContextContainer::SetColorMode baseContext_ is nullptr"); - return; - } - - baseContext_->SetColorMode(mode); -} - -int ContextContainer::GetColorMode() -{ - if (baseContext_ == nullptr) { - HILOG_ERROR("ContextContainer::GetColorMode baseContext_ is nullptr"); - return -1; - } - - return baseContext_->GetColorMode(); -} - int ContextContainer::GetMissionId() { return lifeCycleStateInfo_.missionId; diff --git a/frameworks/native/appkit/app/context_deal.cpp b/frameworks/native/appkit/app/context_deal.cpp index 6f74e0d4809..a740d54f725 100644 --- a/frameworks/native/appkit/app/context_deal.cpp +++ b/frameworks/native/appkit/app/context_deal.cpp @@ -36,7 +36,6 @@ using namespace OHOS::AbilityBase::Constants; const std::string ContextDeal::CONTEXT_DEAL_FILE_SEPARATOR("/"); const std::string ContextDeal::CONTEXT_DEAL_Files("files"); -const int64_t ContextDeal::CONTEXT_CREATE_BY_SYSTEM_APP(0x00000001); const std::string ContextDeal::CONTEXT_DATA_STORAGE("/data/storage/"); const std::string ContextDeal::CONTEXT_DEAL_DATA_APP("/data/app/"); const std::string ContextDeal::CONTEXT_DEAL_BASE("base"); @@ -44,9 +43,6 @@ const std::string ContextDeal::CONTEXT_DEAL_DATABASE("database"); const std::string ContextDeal::CONTEXT_DEAL_PREFERENCES("preferences"); const std::string ContextDeal::CONTEXT_DEAL_DATA("data"); -ContextDeal::ContextDeal(bool isCreateBySystemApp) : isCreateBySystemApp_(isCreateBySystemApp) -{} - std::shared_ptr ContextDeal::GetApplicationInfo() const { return applicationInfo_; @@ -144,7 +140,7 @@ std::shared_ptr ContextDeal::GetResourceManag std::string ContextDeal::GetDatabaseDir() { std::string dir; - if (IsCreateBySystemApp()) { + if (isCreateBySystemApp_) { dir = CONTEXT_DEAL_DATA_APP + currArea_ + CONTEXT_DEAL_FILE_SEPARATOR + std::to_string(GetCurrentAccountId()) + CONTEXT_DEAL_FILE_SEPARATOR + CONTEXT_DEAL_DATABASE + CONTEXT_DEAL_FILE_SEPARATOR + GetBundleName(); } else { @@ -191,22 +187,6 @@ std::string ContextDeal::GetBundleName() const return (applicationInfo_ != nullptr) ? applicationInfo_->bundleName : ""; } -std::string ContextDeal::GetBundleResourcePath() -{ - if (abilityInfo_ == nullptr) { - return ""; - } - - std::string dir; - if (isCreateBySystemApp_) { - dir = std::regex_replace(abilityInfo_->resourcePath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES); - } else { - std::regex pattern(std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR) + abilityInfo_->bundleName); - dir = std::regex_replace(abilityInfo_->resourcePath, pattern, LOCAL_CODE_PATH); - } - return dir; -} - sptr ContextDeal::GetAbilityManager() { auto remoteObject = OHOS::DelayedSingleton::GetInstance()->GetSystemAbility(ABILITY_MGR_SERVICE_ID); @@ -229,11 +209,6 @@ std::string ContextDeal::GetAppType() return retString; } -bool ContextDeal::IsCreateBySystemApp() const -{ - return (static_cast(flags_) & static_cast(CONTEXT_CREATE_BY_SYSTEM_APP)) == 1; -} - int ContextDeal::GetCurrentAccountId() const { int userId = 0; @@ -253,19 +228,9 @@ void ContextDeal::CreateDirIfNotExist(const std::string &dirPath) const } } -void ContextDeal::SetPattern(int patternId) +void ContextDeal::SetSystemAppFlag(bool isCreateBySystemApp) { - if (resourceManager_ != nullptr) { - if (!pattern_.empty()) { - pattern_.clear(); - } - OHOS::Global::Resource::RState errval = resourceManager_->GetPatternById(patternId, pattern_); - if (errval != OHOS::Global::Resource::RState::SUCCESS) { - HILOG_ERROR("SetPattern GetPatternById(patternId:%d) retval is %u", patternId, errval); - } - } else { - HILOG_ERROR("SetPattern resourceManager_ is nullptr"); - } + isCreateBySystemApp_ = isCreateBySystemApp; } std::shared_ptr ContextDeal::GetHapModuleInfo() @@ -286,125 +251,6 @@ void ContextDeal::initResourceManager(const std::shared_ptrGetStringById(resId, ret); - if (errval == OHOS::Global::Resource::RState::SUCCESS) { - return ret; - } else { - HILOG_ERROR("GetString GetStringById(resId:%d) retval is %u", resId, errval); - return ""; - } -} - -std::vector ContextDeal::GetStringArray(int resId) -{ - if (resourceManager_ == nullptr) { - HILOG_ERROR("GetStringArray resourceManager_ is nullptr"); - return std::vector(); - } - - std::vector retv; - OHOS::Global::Resource::RState errval = resourceManager_->GetStringArrayById(resId, retv); - if (errval == OHOS::Global::Resource::RState::SUCCESS) { - return retv; - } else { - HILOG_ERROR("GetStringArray GetStringArrayById(resId:%d) retval is %u", resId, errval); - return std::vector(); - } -} - -std::vector ContextDeal::GetIntArray(int resId) -{ - if (resourceManager_ == nullptr) { - HILOG_ERROR("GetIntArray resourceManager_ is nullptr"); - return std::vector(); - } - - std::vector retv; - OHOS::Global::Resource::RState errval = resourceManager_->GetIntArrayById(resId, retv); - if (errval == OHOS::Global::Resource::RState::SUCCESS) { - return retv; - } else { - HILOG_ERROR("GetIntArray GetIntArrayById(resId:%d) retval is %u", resId, errval); - return std::vector(); - } -} - -std::map ContextDeal::GetTheme() -{ - if (theme_.empty()) { - SetTheme(GetThemeId()); - } - return theme_; -} - -void ContextDeal::SetTheme(int themeId) -{ - if (resourceManager_ == nullptr) { - HILOG_ERROR("SetTheme resourceManager_ is nullptr"); - return; - } - - auto hapModInfo = GetHapModuleInfo(); - if (hapModInfo == nullptr) { - HILOG_ERROR("SetTheme hapModInfo is nullptr"); - return; - } - - if (!theme_.empty()) { - theme_.clear(); - } - OHOS::Global::Resource::RState errval = resourceManager_->GetThemeById(themeId, theme_); - if (errval != OHOS::Global::Resource::RState::SUCCESS) { - HILOG_ERROR("SetTheme GetThemeById(themeId:%d) retval is %u", themeId, errval); - } -} - -std::map ContextDeal::GetPattern() -{ - if (!pattern_.empty()) { - return pattern_; - } else { - HILOG_ERROR("GetPattern pattern_ is empty"); - return std::map(); - } -} - -int ContextDeal::GetColor(int resId) -{ - if (resourceManager_ == nullptr) { - HILOG_ERROR("GetColor resourceManager_ is nullptr"); - return INVALID_RESOURCE_VALUE; - } - - uint32_t ret = INVALID_RESOURCE_VALUE; - OHOS::Global::Resource::RState errval = resourceManager_->GetColorById(resId, ret); - if (errval == OHOS::Global::Resource::RState::SUCCESS) { - return ret; - } else { - HILOG_ERROR("GetColor GetColorById(resId:%d) retval is %u", resId, errval); - return INVALID_RESOURCE_VALUE; - } -} - -int ContextDeal::GetThemeId() -{ - auto hapModInfo = GetHapModuleInfo(); - if (hapModInfo != nullptr) { - return -1; - } else { - HILOG_ERROR("GetThemeId hapModInfo is nullptr"); - return -1; - } -} - int ContextDeal::GetDisplayOrientation() { if (abilityInfo_ != nullptr) { @@ -424,34 +270,6 @@ std::string ContextDeal::GetPreferencesDir() return dir; } -void ContextDeal::SetColorMode(int mode) -{ - auto hapModInfo = GetHapModuleInfo(); - if (hapModInfo == nullptr) { - HILOG_ERROR("SetColorMode hapModInfo is nullptr"); - return; - } - - if (mode == static_cast(ModuleColorMode::DARK)) { - hapModInfo->colorMode = ModuleColorMode::DARK; - } else if (mode == static_cast(ModuleColorMode::LIGHT)) { - hapModInfo->colorMode = ModuleColorMode::LIGHT; - } else { // default use AUTO - hapModInfo->colorMode = ModuleColorMode::AUTO; - } -} - -int ContextDeal::GetColorMode() -{ - auto hapModInfo = GetHapModuleInfo(); - if (hapModInfo == nullptr) { - HILOG_ERROR("GetColorMode hapModInfo is nullptr"); - return -1; - } - return static_cast(hapModInfo->colorMode); -} - - bool ContextDeal::HapModuleInfoRequestInit() { sptr ptr = GetBundleManager(); @@ -476,7 +294,7 @@ bool ContextDeal::HapModuleInfoRequestInit() std::string ContextDeal::GetBaseDir() const { std::string baseDir; - if (IsCreateBySystemApp()) { + if (isCreateBySystemApp_) { baseDir = CONTEXT_DEAL_DATA_APP + currArea_ + CONTEXT_DEAL_FILE_SEPARATOR + std::to_string(GetCurrentAccountId()) + CONTEXT_DEAL_FILE_SEPARATOR + CONTEXT_DEAL_BASE + CONTEXT_DEAL_FILE_SEPARATOR + GetBundleName(); diff --git a/frameworks/native/appkit/app/ohos_application.cpp b/frameworks/native/appkit/app/ohos_application.cpp index 9943c3a0168..f13f2c04a79 100644 --- a/frameworks/native/appkit/app/ohos_application.cpp +++ b/frameworks/native/appkit/app/ohos_application.cpp @@ -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 @@ -45,14 +45,6 @@ OHOSApplication::~OHOSApplication() HILOG_INFO("OHOSApplication::OHOSApplication call destructor."); } -/** - * - * @brief Called when Ability#onSaveAbilityState(PacMap) was called on an ability. - * - * @param outState Indicates the PacMap object passed to Ability#onSaveAbilityState(PacMap) - * for storing user data and states. This parameter cannot be null. - */ - void OHOSApplication::DispatchAbilitySavedState(const PacMap &outState) { HILOG_DEBUG("OHOSApplication::dispatchAbilitySavedState: called"); @@ -63,11 +55,6 @@ void OHOSApplication::DispatchAbilitySavedState(const PacMap &outState) } } -/** - * - * @brief Will be called the application foregrounds - * - */ void OHOSApplication::OnForeground() { HILOG_DEBUG("NotifyApplicationState::OnForeground begin"); @@ -79,11 +66,6 @@ void OHOSApplication::OnForeground() HILOG_DEBUG("NotifyApplicationState::OnForeground end"); } -/** - * - * @brief Will be called the application backgrounds - * - */ void OHOSApplication::OnBackground() { HILOG_DEBUG("NotifyApplicationState::OnBackground begin"); @@ -139,11 +121,6 @@ void OHOSApplication::DumpApplication() } } -/** - * @brief Set Runtime - * - * @param runtime Runtime instance. - */ void OHOSApplication::SetRuntime(std::unique_ptr&& runtime) { HILOG_DEBUG("OHOSApplication::SetRuntime begin"); @@ -155,11 +132,6 @@ void OHOSApplication::SetRuntime(std::unique_ptr&& runt HILOG_DEBUG("OHOSApplication::SetRuntime end"); } -/** - * @brief Set ApplicationContext - * - * @param abilityRuntimeContext ApplicationContext instance. - */ void OHOSApplication::SetApplicationContext( const std::shared_ptr &abilityRuntimeContext) { @@ -171,12 +143,6 @@ void OHOSApplication::SetApplicationContext( abilityRuntimeContext_ = abilityRuntimeContext; } -/** - * - * @brief Set the abilityRecordMgr to the OHOSApplication. - * - * @param abilityRecordMgr - */ void OHOSApplication::SetAbilityRecordMgr(const std::shared_ptr &abilityRecordMgr) { HILOG_DEBUG("OHOSApplication::SetAbilityRecordMgr"); @@ -187,12 +153,6 @@ void OHOSApplication::SetAbilityRecordMgr(const std::shared_ptr &callBack) { HILOG_DEBUG("OHOSApplication::RegisterAbilityLifecycleCallbacks: called"); @@ -205,12 +165,6 @@ void OHOSApplication::RegisterAbilityLifecycleCallbacks(const std::shared_ptr &callBack) { HILOG_DEBUG("OHOSApplication::UnregisterAbilityLifecycleCallbacks: called"); @@ -223,12 +177,6 @@ void OHOSApplication::UnregisterAbilityLifecycleCallbacks(const std::shared_ptr< abilityLifecycleCallbacks_.remove(callBack); } -/** - * - * Will be called when the given ability calls Ability->onStart - * - * @param Ability Indicates the ability object that calls the onStart() method. - */ void OHOSApplication::OnAbilityStart(const std::shared_ptr &ability) { if (ability == nullptr) { @@ -244,12 +192,6 @@ void OHOSApplication::OnAbilityStart(const std::shared_ptr &ability) } } -/** - * - * Will be called when the given ability calls Ability->onInactive - * - * @param Ability Indicates the Ability object that calls the onInactive() method. - */ void OHOSApplication::OnAbilityInactive(const std::shared_ptr &ability) { if (ability == nullptr) { @@ -265,12 +207,6 @@ void OHOSApplication::OnAbilityInactive(const std::shared_ptr &ability) } } -/** - * - * Will be called when the given ability calls Ability->onBackground - * - * @param Ability Indicates the Ability object that calls the onBackground() method. - */ void OHOSApplication::OnAbilityBackground(const std::shared_ptr &ability) { if (ability == nullptr) { @@ -286,12 +222,6 @@ void OHOSApplication::OnAbilityBackground(const std::shared_ptr &abilit } } -/** - * - * Will be called when the given ability calls Ability->onForeground - * - * @param Ability Indicates the Ability object that calls the onForeground() method. - */ void OHOSApplication::OnAbilityForeground(const std::shared_ptr &ability) { if (ability == nullptr) { @@ -307,12 +237,6 @@ void OHOSApplication::OnAbilityForeground(const std::shared_ptr &abilit } } -/** - * - * Will be called when the given ability calls Ability->onActive - * - * @param Ability Indicates the Ability object that calls the onActive() method. - */ void OHOSApplication::OnAbilityActive(const std::shared_ptr &ability) { if (ability == nullptr) { @@ -328,12 +252,6 @@ void OHOSApplication::OnAbilityActive(const std::shared_ptr &ability) } } -/** - * - * Will be called when the given ability calls Ability->onStop - * - * @param Ability Indicates the Ability object that calls the onStop() method. - */ void OHOSApplication::OnAbilityStop(const std::shared_ptr &ability) { if (ability == nullptr) { @@ -349,12 +267,6 @@ void OHOSApplication::OnAbilityStop(const std::shared_ptr &ability) } } -/** - * - * @brief Register ElementsCallback with OHOSApplication - * - * @param callBack callBack when the system configuration of the device changes. - */ void OHOSApplication::RegisterElementsCallbacks(const std::shared_ptr &callback) { HILOG_DEBUG("OHOSApplication::RegisterElementsCallbacks: called"); @@ -367,12 +279,6 @@ void OHOSApplication::RegisterElementsCallbacks(const std::shared_ptr &callback) { HILOG_DEBUG("OHOSApplication::UnregisterElementsCallbacks: called"); @@ -385,12 +291,6 @@ void OHOSApplication::UnregisterElementsCallbacks(const std::shared_ptrDispatchConfigurationUpdated(config); } -/** - * - * @brief Called when the system has determined to trim the memory, for example, - * when the ability is running in the background and there is no enough memory for - * running as many background processes as possible. - * - * @param level Indicates the memory trim level, which shows the current memory usage status. - */ void OHOSApplication::OnMemoryLevel(int level) { HILOG_DEBUG("OHOSApplication::OnMemoryLevel: called"); @@ -479,33 +371,16 @@ void OHOSApplication::OnMemoryLevel(int level) abilityRuntimeContext_->DispatchMemoryLevel(level); } -/** - * - * @brief Will be called the application starts - * - */ void OHOSApplication::OnStart() { HILOG_DEBUG("OnStart called."); } -/** - * - * @brief Will be called the application ends - * - */ void OHOSApplication::OnTerminate() { HILOG_DEBUG("OHOSApplication::OnTerminate: called"); } -/** - * - * @brief Called when an ability calls Ability#onSaveAbilityState(PacMap). - * You can implement your own logic in this method. - * @param outState IIndicates the {@link PacMap} object passed to the onSaveAbilityState() callback. - * - */ void OHOSApplication::OnAbilitySaveState(const PacMap &outState) { DispatchAbilitySavedState(outState); @@ -565,13 +440,6 @@ std::shared_ptr OHOSApplication::AddAbilityStage( return abilityStage->GetContext(); } -/** - * - * @brief update the application info after new module installed. - * - * @param appInfo The latest application info obtained from bms for update abilityRuntimeContext. - * - */ void OHOSApplication::UpdateApplicationInfoInstalled(const AppExecFwk::ApplicationInfo &appInfo) { HILOG_DEBUG("OHOSApplication::UpdateApplicationInfoInstalled"); diff --git a/interfaces/kits/native/ability/native/ability.h b/interfaces/kits/native/ability/native/ability.h index b497eb1e740..2f7ced3eccb 100644 --- a/interfaces/kits/native/ability/native/ability.h +++ b/interfaces/kits/native/ability/native/ability.h @@ -78,7 +78,6 @@ class AbilityWindow; class ILifeCycle; class ContinuationManager; class AbilityRecovery; -class ContinuationRegisterManager; class Ability : public IAbilityEvent, public ILifeCycle, public AbilityContext, @@ -1285,7 +1284,6 @@ private: std::shared_ptr continuationHandler_ = nullptr; std::shared_ptr continuationManager_ = nullptr; - std::shared_ptr continuationRegisterManager_ = nullptr; std::shared_ptr handler_ = nullptr; std::shared_ptr lifecycle_ = nullptr; std::shared_ptr abilityLifecycleExecutor_ = nullptr; diff --git a/interfaces/kits/native/ability/native/continuation/remote_register_service/connect_callback_proxy.h b/interfaces/kits/native/ability/native/continuation/remote_register_service/connect_callback_proxy.h deleted file mode 100644 index 98b16b19c16..00000000000 --- a/interfaces/kits/native/ability/native/continuation/remote_register_service/connect_callback_proxy.h +++ /dev/null @@ -1,52 +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. - */ -#ifndef OHOS_ABILITY_RUNTIME_CONNECT_CALLBACK_PROXY_H -#define OHOS_ABILITY_RUNTIME_CONNECT_CALLBACK_PROXY_H -#include -#include "connect_callback_interface.h" -#include "iremote_proxy.h" - -using string = std::string; -using IRemoteObject = OHOS::IRemoteObject; - -namespace OHOS { -namespace AppExecFwk { -/** - * interface for device connect callback. - */ -class ConnectCallbackProxy : public IRemoteProxy { -public: - explicit ConnectCallbackProxy(const sptr &object) : IRemoteProxy(object) {}; - virtual ~ConnectCallbackProxy() = default; - /** - * @brief Remote device sends connection request. - * @param deviceId indicators id of connection device. - * @param deviceType indicators type of connection device. - * @return none - */ - virtual void Connect(const string &deviceId, const string &deviceType) override; - /** - * @brief Remote device sends disconnection request. - * @param deviceId indicators id of disconnection device. - * @return none - */ - virtual void Disconnect(const string &deviceId) override; - -private: - void RemoteRequest(MessageParcel &data, int commandDisconnect); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_CONNECT_CALLBACK_PROXY_H diff --git a/interfaces/kits/native/ability/native/continuation/remote_register_service/connect_callback_stub.h b/interfaces/kits/native/ability/native/continuation/remote_register_service/connect_callback_stub.h deleted file mode 100644 index e2affc27ae0..00000000000 --- a/interfaces/kits/native/ability/native/continuation/remote_register_service/connect_callback_stub.h +++ /dev/null @@ -1,48 +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. - */ -#ifndef OHOS_ABILITY_RUNTIME_CONNECT_CALLBACK_STUB_H -#define OHOS_ABILITY_RUNTIME_CONNECT_CALLBACK_STUB_H -#include -#include -#include "connect_callback_interface.h" -#include "iremote_stub.h" - -using string = std::string; - -namespace OHOS { -namespace AppExecFwk { -class ConnectCallbackStub : public IRemoteStub { -public: - ConnectCallbackStub(); - virtual ~ConnectCallbackStub() = default; - /** - * @brief Remote device sends connection or disconnection request. - * @param Code indicators code of the connection or disconnection request function. - * @param data indicators receives the message object. - * @param reply indicators reply the message object. - * @return none - */ - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - int ConnectInner(MessageParcel &data, MessageParcel &reply); - int DisconnectInner(MessageParcel &data, MessageParcel &reply); - using ConnectCallbackFunc = int (ConnectCallbackStub::*)(MessageParcel &data, MessageParcel &reply); - std::map memberFuncMap_; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_CONNECT_CALLBACK_STUB_H diff --git a/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_connector.h b/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_connector.h deleted file mode 100644 index d0e41e34f0e..00000000000 --- a/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_connector.h +++ /dev/null @@ -1,154 +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. - */ - -#ifndef OHOS_ABILITY_RUNTIME_CONTINUATION_CONNECTOR_H -#define OHOS_ABILITY_RUNTIME_CONTINUATION_CONNECTOR_H - -#include -#include -#include -#include -#include - -#include "iremote_broker.h" -#include "element_name.h" -#include "refbase.h" -#include "context.h" -#include "extra_params.h" -#include "continuation_request.h" -#include "ability_connect_callback_stub.h" -#include "continuation/kits/continuation_device_callback_interface.h" -#include "continuation/remote_register_service_interface.h" - -namespace OHOS { -namespace AppExecFwk { -class ContinuationConnector : public AAFwk::AbilityConnectionStub { -public: - explicit ContinuationConnector(const std::weak_ptr &context); - virtual ~ContinuationConnector() = default; - - /** - * @brief get singleton of Class ContinuationConnector - * - * @param context: the running context for appcontext - * - * @return The singleton of ContinuationConnector - */ - static sptr GetInstance(const std::weak_ptr &context); - - /** - * @brief This method is called back to receive the connection result after an ability calls the - * Ability#connectAbility(Want, IAbilityConnection) method to connect it to a Service ability. - * - * @param element: Indicates information about the connected Service ability. - * @param remote: Indicates the remote proxy object of the Service ability. - * @param resultCode: Indicates the connection result code. The value 0 indicates a successful connection, and any - * other value indicates a connection failure. - */ - void OnAbilityConnectDone( - const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) override; - - /** - * @brief This method is called back to receive the disconnection result after the connected Service ability crashes - * or is killed. If the Service ability exits unexpectedly, all its connections are disconnected, and each ability - * previously connected to it will call onAbilityDisconnectDone. - * - * @param element: Indicates information about the disconnected Service ability. - * @param resultCode: Indicates the disconnection result code. The value 0 indicates a successful disconnection, and - * any other value indicates a disconnection failure. - */ - void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override; - - /** - * @brief bind remote ability of RemoteRegisterService. - * - * @param request: request for continuation. - */ - void BindRemoteRegisterAbility(const std::shared_ptr &request); - - /** - * @brief unbind remote ability of RemoteRegisterService. - */ - void UnbindRemoteRegisterAbility(); - - /** - * @brief check whether connected to remote register service. - * - * @return bool true if connected, otherwise false. - */ - bool IsAbilityConnected(); - - /** - * @brief unregister to control center continuation register service. - * - * @param token token from register return value. - * - * @return bool result of unregister. - */ - bool Unregister(int token); - - /** - * @brief notify continuation status to control center continuation register service. - * - * @param token token from register. - * @param deviceId device id. - * @param status device status. - * - * @return bool result of updateConnectStatus. - */ - bool UpdateConnectStatus(int token, const std::string &deviceId, int status); - - /** - * @brief notify control center continuation register service to show device list. - * - * @param token token from register - * @param parameter filter with supported device list. - * @return bool result of showDeviceList. - */ - bool ShowDeviceList(int token, const AppExecFwk::ExtraParams ¶meter); - - /** - * @brief register to control center continuation register service. - * - * @param context ability context. - * @param bundleName bundle name of ability. - * @param parameter filter with supported device list. - * @param callback callback for device connect and disconnect. - * - * @return int token. - */ - int Register(std::weak_ptr &context, const std::string bundleName, - const AppExecFwk::ExtraParams ¶meter, std::shared_ptr &callback); - -private: - /** - * @brief bind remote ability of RemoteRegisterService. - */ - inline void BindRemoteRegisterAbility(); - -private: - static const std::string CONNECTOR_DEVICE_ID; - static const std::string CONNECTOR_ABILITY_NAME; - static const std::string CONNECTOR_BUNDLE_NAME; - static sptr instance_; - static std::mutex mutex_; - std::weak_ptr context_; - std::vector> continuationRequestList_; - std::atomic isConnected_ = {false}; - sptr remoteRegisterService_; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_CONTINUATION_CONNECTOR_H diff --git a/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_device_callback_proxy.h b/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_device_callback_proxy.h deleted file mode 100644 index 587611b6f8a..00000000000 --- a/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_device_callback_proxy.h +++ /dev/null @@ -1,55 +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. - */ -#ifndef OHOS_ABILITY_RUNTIME_CONTINUATION_DEVICE_CALLBACK_PROXY_H -#define OHOS_ABILITY_RUNTIME_CONTINUATION_DEVICE_CALLBACK_PROXY_H -#include -#include "connect_callback_stub.h" -#include "continuation_device_callback_interface.h" - -namespace OHOS { -namespace AppExecFwk { -class ContinuationDeviceCallbackProxy : public ConnectCallbackStub { -public: - /** - * A constructor used to create a {@link ohos.aafwk.ability.continuation.ContinuationDeviceCallbackProxy} instance. - */ - explicit ContinuationDeviceCallbackProxy(std::shared_ptr &callback); - /** - * A destructor used to release a {@link ohos.aafwk.ability.continuation.ContinuationDeviceCallbackProxy} instance. - */ - virtual ~ContinuationDeviceCallbackProxy(); - - /** - * @brief After the connection of continuationdevice is completed, call back the function. - * @param deviceId indicates the continuation device ID. - * @param deviceType indicators he continuation device deviceType. - * @return none. - */ - virtual void Connect(const std::string &deviceId, const std::string &deviceType) override; - - /** - * @brief When the continuationdevice is disconnected, call back the function. - * @param deviceId indicates the continuation device ID. - * @param deviceType indicators he continuation device deviceType. - * @return none. - */ - virtual void Disconnect(const std::string &deviceId) override; - -private: - std::weak_ptr callback_; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif diff --git a/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_register_manager.h b/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_register_manager.h deleted file mode 100644 index 061940f5330..00000000000 --- a/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_register_manager.h +++ /dev/null @@ -1,81 +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. - */ -#ifndef OHOS_ABILITY_RUNTIME_CONTINUATION_REGISTER_MANAGER_H -#define OHOS_ABILITY_RUNTIME_CONTINUATION_REGISTER_MANAGER_H - -#include -#include "continuation_register_manager_interface.h" - -namespace OHOS { -namespace AppExecFwk { -class ContinuationRegisterManagerProxy; -class ContinuationRegisterManager : public IContinuationRegisterManager { -public: - ContinuationRegisterManager() = default; - virtual ~ContinuationRegisterManager() = default; - - void Init(const std::shared_ptr &continuationRegisterManagerProxy); - /** - * register to controlcenter continuation register service. - * - * @param bundleName bundlename of ability. - * @param parameter filter with supported device list. - * @param callback callback for device connect and disconnect. - * @param requestCallback callback for this request, -1 means failed, otherwise is register token. - */ - virtual void Register(const std::string &bundleName, const ExtraParams ¶meter, - const std::shared_ptr &deviceCallback, - const std::shared_ptr &requestCallback) override; - - /** - * unregister to controlcenter continuation register service. - * - * @param token token from register return value. - * @param requestCallback callback for this request, -1 means failed, otherwise succeeded. - */ - virtual void Unregister(int token, const std::shared_ptr &requestCallback) override; - - /** - * notify continuation status to controlcenter continuation register service. - * - * @param token token from register. - * @param deviceId deviceid. - * @param status device status. - * @param requestCallback callback for this request, -1 means failed, otherwise successed. - */ - virtual void UpdateConnectStatus(int token, const std::string &deviceId, int status, - const std::shared_ptr &requestCallback) override; - - /** - * notify controlcenter continuation register service to show device list. - * - * @param token token from register - * @param parameter filter with supported device list. - * @param requestCallback callback for this request, -1 means failed, otherwise successed. - */ - virtual void ShowDeviceList( - int token, const ExtraParams ¶meter, const std::shared_ptr &requestCallback) override; - - /** - * disconnect to controlcenter continuation register service. - */ - virtual void Disconnect(void) override; - -private: - std::shared_ptr continuationRegisterManagerProxy_ = nullptr; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_CONTINUATION_REGISTER_MANAGER_H diff --git a/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_register_manager_proxy.h b/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_register_manager_proxy.h deleted file mode 100644 index 8edd7ce614a..00000000000 --- a/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_register_manager_proxy.h +++ /dev/null @@ -1,172 +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. - */ -#ifndef OHOS_ABILITY_RUNTIME_CONTINUATION_REGISTER_MANAGER_PROXY_H -#define OHOS_ABILITY_RUNTIME_CONTINUATION_REGISTER_MANAGER_PROXY_H - -#include -#include "continuation_register_manager_interface.h" -#include "continuation_request.h" -#include "continuation_connector.h" - -namespace OHOS { -namespace AppExecFwk { -class ContinuationConnector; -class Context; -class IContinuationDeviceCallback; -class RequestCallback; - -class ContinuationRequestBase : public ContinuationRequest { -public: - ContinuationRequestBase() = default; - virtual ~ContinuationRequestBase() = default; - - void SetContext(const std::weak_ptr &context) - { - context_ = context; - } - - void SetContinuationConnector(const sptr &continuatinConnector) - { - continuatinConnector_ = continuatinConnector; - } - - void SetRequestCallback(const std::shared_ptr &requestCallback) - { - requestCallback_ = requestCallback; - } - -protected: - std::weak_ptr context_; - sptr continuatinConnector_; - std::shared_ptr requestCallback_ = nullptr; -}; - -class ContinuationRequestRegister : public ContinuationRequestBase { -public: - ContinuationRequestRegister(const std::string &bundleName, const ExtraParams ¶meter, - const std::shared_ptr &deviceCallback); - virtual ~ContinuationRequestRegister() = default; - virtual void Execute() override; - -private: - ExtraParams parameter_; - std::shared_ptr deviceCallback_ = nullptr; - std::string bundleName_ = ""; -}; - -class ContinuationRequestUnRegister : public ContinuationRequestBase { -public: - explicit ContinuationRequestUnRegister(int token); - virtual ~ContinuationRequestUnRegister() = default; - virtual void Execute() override; - -private: - int token_ = 0; -}; - -class ContinuationRequestUpdateConnectStatus : public ContinuationRequestBase { -public: - ContinuationRequestUpdateConnectStatus(int token, const std::string &deviceId, int status); - virtual ~ContinuationRequestUpdateConnectStatus() = default; - virtual void Execute() override; - -private: - int token_ = 0; - std::string deviceId_ = ""; - int status_; -}; - -class ContinuationRequestShowDeviceList : public ContinuationRequestBase { -public: - ContinuationRequestShowDeviceList(int token, const ExtraParams ¶meter); - virtual ~ContinuationRequestShowDeviceList() = default; - virtual void Execute() override; - -private: - int token_ = 0; - ExtraParams parameter_; -}; - -class ContinuationRegisterManagerProxy : public IContinuationRegisterManager { -public: - explicit ContinuationRegisterManagerProxy(const std::weak_ptr &context); - virtual ~ContinuationRegisterManagerProxy(); - - /** - * Registers an ability to be migrated with the Device+ control center and obtains the registration token assigned - * to the ability. - * - * @param bundleName Indicates the bundle name of the application whose ability is to be migrated. - * @param parameter Indicates the {@link ExtraParams} object containing the extra parameters used to filter - * the list of available devices. This parameter can be null. - * @param deviceCallback Indicates the callback to be invoked when the connection state of the selected device - * changes. - * @param requestCallback Indicates the callback to be invoked when the Device+ service is connected. - */ - virtual void Register(const std::string &bundleName, const ExtraParams ¶meter, - const std::shared_ptr &deviceCallback, - const std::shared_ptr &requestCallback) override; - - /** - * Unregisters a specified ability from the Device+ control center based on the token obtained during ability - * registration. - * - * @param token Indicates the registration token of the ability. - * @param requestCallback Indicates the callback to be invoked when the Device+ service is connected. - * This parameter can be null. - */ - virtual void Unregister(int token, const std::shared_ptr &requestCallback) override; - - /** - * Updates the connection state of the device where the specified ability is successfully migrated. - * - * @param token Indicates the registration token of the ability. - * @param deviceId Indicates the ID of the device whose connection state is to be updated. - * @param status Indicates the connection state to update, which can be {@link DeviceConnectState#FAILURE}, - * {@link DeviceConnectState#IDLE}, {@link DeviceConnectState#CONNECTING}, {@link DeviceConnectState#CONNECTED}, - * or {@link DeviceConnectState#DIS_CONNECTING}. - * @param requestCallback Indicates the callback to be invoked when the Device+ service is connected. - * This parameter can be null. - */ - virtual void UpdateConnectStatus(int token, const std::string &deviceId, int status, - const std::shared_ptr &requestCallback) override; - - /** - * Shows the list of devices that can be selected for ability migration on the distributed network. - * - * @param token Indicates the registration token of the ability. - * @param parameter Indicates the {@link ExtraParams} object containing the extra parameters used to filter - * the list of available devices. This parameter can be null. - * @param requestCallback Indicates the callback to be invoked when the Device+ service is connected. - * This parameter can be null. - */ - virtual void ShowDeviceList( - int token, const ExtraParams ¶meter, const std::shared_ptr &requestCallback) override; - - /** - * Disconnects from the Device+ control center. - */ - virtual void Disconnect(void) override; - -private: - std::weak_ptr context_; - std::weak_ptr applicationContext_; - sptr continuatinConnector_; - - void SendRequest(const std::weak_ptr &context, const std::shared_ptr &request); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_CONTINUATION_REGISTER_MANAGER_PROXY_H diff --git a/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_request.h b/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_request.h deleted file mode 100644 index a66f310041a..00000000000 --- a/interfaces/kits/native/ability/native/continuation/remote_register_service/continuation_request.h +++ /dev/null @@ -1,32 +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. - */ -#ifndef OHOS_ABILITY_RUNTIME_CONTINUATION_REQUEST_H -#define OHOS_ABILITY_RUNTIME_CONTINUATION_REQUEST_H -namespace OHOS { -namespace AppExecFwk { -class ContinuationRequest { -public: - ContinuationRequest() = default; - virtual ~ContinuationRequest() = default; - /** - * @brief Pending request will be execute when connected ability. - * @param none - * @return none - */ - virtual void Execute() = 0; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_CONTINUATION_REQUEST_H diff --git a/interfaces/kits/native/ability/native/continuation/remote_register_service/remote_register_service_proxy.h b/interfaces/kits/native/ability/native/continuation/remote_register_service/remote_register_service_proxy.h deleted file mode 100644 index 0490bc02ec3..00000000000 --- a/interfaces/kits/native/ability/native/continuation/remote_register_service/remote_register_service_proxy.h +++ /dev/null @@ -1,69 +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. - */ - -#ifndef OHOS_ABILITY_RUNTIME_REMOTE_REGISTER_SERVICE_PROXY_H -#define OHOS_ABILITY_RUNTIME_REMOTE_REGISTER_SERVICE_PROXY_H - -#include "remote_register_service_interface.h" -#include -#include -#include "message_parcel.h" -#include "iremote_proxy.h" - -namespace OHOS { -namespace AppExecFwk { -class RemoteRegisterServiceProxy : public IRemoteProxy { -public: - explicit RemoteRegisterServiceProxy(const sptr &impl) : IRemoteProxy(impl) - {} - virtual ~RemoteRegisterServiceProxy() = default; - - /** - * register to controlcenter continuation register service. - * - * @param bundleName bundlename of ability. - * @param extras filter with supported device list. - * @param callback callback for device connect and disconnect. - */ - virtual int Register(const std::string &bundleName, const sptr &token, const ExtraParams &extras, - const sptr &callback) override; - - /** - * unregister to controlcenter continuation register service. - * - * @param registerToken token from register return value. - */ - virtual bool Unregister(int registerToken) override; - - /** - * notify continuation status to controlcenter continuation register service. - * - * @param registerToken token from register. - * @param deviceId deviceid. - * @param status device status. - */ - virtual bool UpdateConnectStatus(int registerToken, const std::string &deviceId, int status) override; - - /** - * notify controlcenter continuation register service to show device list. - * - * @param registerToken token from register - * @param extras filter with supported device list. - */ - virtual bool ShowDeviceList(int registerToken, const ExtraParams &extras) override; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_REMOTE_REGISTER_SERVICE_PROXY_H diff --git a/interfaces/kits/native/ability/native/continuation/remote_register_service/remote_register_service_stub.h b/interfaces/kits/native/ability/native/continuation/remote_register_service/remote_register_service_stub.h deleted file mode 100644 index 44aee57faf7..00000000000 --- a/interfaces/kits/native/ability/native/continuation/remote_register_service/remote_register_service_stub.h +++ /dev/null @@ -1,45 +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. - */ - -#ifndef OHOS_ABILITY_RUNTIME_REMOTE_REGISTER_SERVICE_STUB_H -#define OHOS_ABILITY_RUNTIME_REMOTE_REGISTER_SERVICE_STUB_H - -#include "remote_register_service_interface.h" -#include -#include -#include -#include "message_parcel.h" - -namespace OHOS { -namespace AppExecFwk { -class RemoteRegisterServiceStub : public IRemoteStub { -public: - RemoteRegisterServiceStub(); - virtual ~RemoteRegisterServiceStub(); - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - int RegisterInner(MessageParcel &data, MessageParcel &reply); - int UnregisterInner(MessageParcel &data, MessageParcel &reply); - int UpdateConnectStatusInner(MessageParcel &data, MessageParcel &reply); - int ShowDeviceListInner(MessageParcel &data, MessageParcel &reply); - - using RequestRegisterFuncType = int (RemoteRegisterServiceStub::*)(MessageParcel &data, MessageParcel &reply); - std::map requestFuncMap_; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_REMOTE_REGISTER_SERVICE_STUB_H diff --git a/interfaces/kits/native/appkit/app/context.h b/interfaces/kits/native/appkit/app/context.h index 0a3791c188c..94c445f86ef 100644 --- a/interfaces/kits/native/appkit/app/context.h +++ b/interfaces/kits/native/appkit/app/context.h @@ -52,7 +52,7 @@ using PermissionRequestTask = std::function& #define OHOS_REQUEST_PERMISSION_VALUE 1 -constexpr int INVALID_RESOURCE_VALUE = -1; // GetColor() Failed return Value +constexpr int INVALID_RESOURCE_VALUE = -1; constexpr int DEFAULT_ACCOUNT_ID = -1; class DataAbilityHelperImpl; @@ -218,13 +218,6 @@ public: */ virtual std::string GetBundleName() const = 0; - /** - * @brief Obtains the path of the OHOS Ability Package (HAP} containing this ability. - * - * @return Returns the path of the HAP containing this ability. - */ - virtual std::string GetBundleResourcePath() = 0; - /** * @brief Starts a new ability. * An ability using the AbilityInfo.AbilityType.SERVICE or AbilityInfo.AbilityType.PAGE template uses this method @@ -303,13 +296,6 @@ public: return 0; } - /** - * @brief Sets the pattern of this Context based on the specified pattern ID. - * - * @param patternId Indicates the resource ID of the pattern to set. - */ - virtual void SetPattern(int patternId) = 0; - /** * @brief Obtains the Context object of this ability. * @@ -397,70 +383,6 @@ public: */ virtual Uri GetCaller() = 0; - /** - * @brief Get the string of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the string to get. - * - * @return Returns the string of this Context. - */ - virtual std::string GetString(int resId) = 0; - - /** - * @brief Get the string array of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the string array to get. - * - * @return Returns the string array of this Context. - */ - virtual std::vector GetStringArray(int resId) = 0; - - /** - * @brief Get the integer array of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the integer array to get. - * - * @return Returns the integer array of this Context. - */ - virtual std::vector GetIntArray(int resId) = 0; - - /** - * @brief Obtains the theme of this Context. - * - * @return theme Returns the theme of this Context. - */ - virtual std::map GetTheme() = 0; - - /** - * @brief Sets the theme of this Context based on the specified theme ID. - * - * @param themeId Indicates the resource ID of the theme to set. - */ - virtual void SetTheme(int themeId) = 0; - - /** - * @brief Obtains the pattern of this Context. - * - * @return getPattern in interface Context - */ - virtual std::map GetPattern() = 0; - - /** - * @brief Get the color of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the color to get. - * - * @return Returns the color value of this Context. - */ - virtual int GetColor(int resId) = 0; - - /** - * @brief Obtains the theme id of this Context. - * - * @return int Returns the theme id of this Context. - */ - virtual int GetThemeId() = 0; - /** * @brief * Destroys this Service ability if the number of times it has been started equals the number represented by the @@ -493,20 +415,6 @@ public: */ virtual std::string GetPreferencesDir() = 0; - /** - * @brief Set color mode - * - * @param the value of color mode. - */ - virtual void SetColorMode(int mode) = 0; - - /** - * @brief Obtains color mode. - * - * @return Returns the color mode value. - */ - virtual int GetColorMode() = 0; - /** * @brief Obtains the unique ID of the mission containing this ability. * diff --git a/interfaces/kits/native/appkit/app/context_container.h b/interfaces/kits/native/appkit/app/context_container.h index 403d5b6d1c6..fad4e7b813e 100644 --- a/interfaces/kits/native/appkit/app/context_container.h +++ b/interfaces/kits/native/appkit/app/context_container.h @@ -149,13 +149,6 @@ public: */ std::string GetBundleName() const override; - /** - * @brief Obtains the path of the OHOS Ability Package (HAP} containing this ability. - * - * @return Returns the path of the HAP containing this ability. - */ - std::string GetBundleResourcePath() override; - /** * @brief Obtains an ability manager. * The ability manager provides information about running processes and memory usage of an application. @@ -174,13 +167,6 @@ public: */ std::string GetAppType() override; - /** - * @brief Sets the pattern of this Context based on the specified pattern ID. - * - * @param patternId Indicates the resource ID of the pattern to set. - */ - void SetPattern(int patternId) override; - /** * @brief Obtains the HapModuleInfo object of the application. * @@ -199,15 +185,11 @@ public: * @brief Creates a Context object for an application with the given bundle name. * * @param bundleName Indicates the bundle name of the application. - * @param flag Indicates the flag for creating a Context object. It can be 0, any of - * the following values, or any combination of the following values: CONTEXT_IGNORE_SECURITY, - * CONTEXT_INCLUDE_CODE, and CONTEXT_RESTRICTED. The value 0 indicates that there is no restriction - * on creating contexts for applications. * @param accountId Indicates the account id. * * @return Returns a Context object created for the specified application. */ - std::shared_ptr CreateBundleContext(std::string bundleName, int flag, int accountId = DEFAULT_ACCOUNT_ID); + std::shared_ptr CreateBundleContext(std::string bundleName, int accountId = DEFAULT_ACCOUNT_ID); /** * @brief Obtains information about the caller of this ability. @@ -230,70 +212,6 @@ public: */ void InitResourceManager(BundleInfo &bundleInfo, std::shared_ptr &deal); - /** - * @brief Get the string of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the string to get. - * - * @return Returns the string of this Context. - */ - std::string GetString(int resId) override; - - /** - * @brief Get the string array of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the string array to get. - * - * @return Returns the string array of this Context. - */ - std::vector GetStringArray(int resId) override; - - /** - * @brief Get the integer array of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the integer array to get. - * - * @return Returns the integer array of this Context. - */ - std::vector GetIntArray(int resId) override; - - /** - * @brief Obtains the theme of this Context. - * - * @return theme Returns the theme of this Context. - */ - std::map GetTheme() override; - - /** - * @brief Sets the theme of this Context based on the specified theme ID. - * - * @param themeId Indicates the resource ID of the theme to set. - */ - void SetTheme(int themeId) override; - - /** - * @brief Obtains the pattern of this Context. - * - * @return getPattern in interface Context - */ - std::map GetPattern() override; - - /** - * @brief Get the color of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the color to get. - * - * @return Returns the color value of this Context. - */ - int GetColor(int resId) override; - - /** - * @brief Obtains the theme id of this Context. - * - * @return int Returns the theme id of this Context. - */ - int GetThemeId() override; - /** * @brief Obtains the current display orientation of this ability. * @@ -309,20 +227,6 @@ public: */ std::string GetPreferencesDir() override; - /** - * @brief Set color mode - * - * @param the value of color mode. - */ - void SetColorMode(int mode) override; - - /** - * @brief Obtains color mode. - * - * @return Returns the color mode value. - */ - int GetColorMode() override; - /** * @brief Obtains the unique ID of the mission containing this ability. * diff --git a/interfaces/kits/native/appkit/app/context_deal.h b/interfaces/kits/native/appkit/app/context_deal.h index 150f7b882b9..e856e89b087 100644 --- a/interfaces/kits/native/appkit/app/context_deal.h +++ b/interfaces/kits/native/appkit/app/context_deal.h @@ -24,7 +24,6 @@ namespace AppExecFwk { class ContextDeal : public std::enable_shared_from_this { public: ContextDeal() = default; - explicit ContextDeal(bool isCreateBySystemApp); virtual ~ContextDeal() = default; /** @@ -157,13 +156,6 @@ public: */ std::string GetBundleName() const; - /** - * @brief Obtains the path of the OHOS Ability Package (HAP} containing this ability. - * - * @return Returns the path of the HAP containing this ability. - */ - std::string GetBundleResourcePath(); - /** * @brief Obtains an ability manager. * The ability manager provides information about running processes and memory usage of an application. @@ -182,13 +174,6 @@ public: */ std::string GetAppType(); - /** - * @brief Sets the pattern of this Context based on the specified pattern ID. - * - * @param patternId Indicates the resource ID of the pattern to set. - */ - void SetPattern(int patternId); - /** * @brief Obtains the HapModuleInfo object of the application. * @@ -196,13 +181,6 @@ public: */ std::shared_ptr GetHapModuleInfo(); - /** - * @brief Obtains the name of the current process. - * - * @return Returns the current process name. - */ - std::string GetProcessName(); - /** * @brief init the ResourceManager for ContextDeal. * @@ -211,70 +189,6 @@ public: */ void initResourceManager(const std::shared_ptr &resourceManager); - /** - * @brief Get the string of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the string to get. - * - * @return Returns the string of this Context. - */ - std::string GetString(int resId); - - /** - * @brief Get the string array of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the string array to get. - * - * @return Returns the string array of this Context. - */ - std::vector GetStringArray(int resId); - - /** - * @brief Get the integer array of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the integer array to get. - * - * @return Returns the integer array of this Context. - */ - std::vector GetIntArray(int resId); - - /** - * @brief Obtains the theme of this Context. - * - * @return theme Returns the theme of this Context. - */ - std::map GetTheme(); - - /** - * @brief Sets the theme of this Context based on the specified theme ID. - * - * @param themeId Indicates the resource ID of the theme to set. - */ - void SetTheme(int themeId); - - /** - * @brief Obtains the pattern of this Context. - * - * @return getPattern in interface Context - */ - std::map GetPattern(); - - /** - * @brief Get the color of this Context based on the specified resource ID. - * - * @param resId Indicates the resource ID of the color to get. - * - * @return Returns the color value of this Context. - */ - int GetColor(int resId); - - /** - * @brief Obtains the theme id of this Context. - * - * @return int Returns the theme id of this Context. - */ - int GetThemeId(); - /** * @brief Obtains the current display orientation of this ability. * @@ -290,27 +204,15 @@ public: */ std::string GetPreferencesDir(); - /** - * @brief Set color mode - * - * @param the value of color mode. - */ - void SetColorMode(int mode); - - /** - * @brief Obtains color mode. - * - * @return Returns the color mode value. - */ - int GetColorMode(); - /** * @brief Obtains the application base directory on the device's internal storage. * * @return Returns the application base directory. */ std::string GetBaseDir() const; -public: + + void SetSystemAppFlag(bool isCreateBySystemApp); + static const int64_t CONTEXT_CREATE_BY_SYSTEM_APP; static const std::string CONTEXT_DEAL_FILE_SEPARATOR; static const std::string CONTEXT_DEAL_Files; @@ -321,13 +223,9 @@ public: static const std::string CONTEXT_DEAL_DATABASE; static const std::string CONTEXT_DEAL_PREFERENCES; static const std::string CONTEXT_DEAL_DATA; - int flags_ = 0x00000000; - -protected: - bool HapModuleInfoRequestInit(); private: - bool IsCreateBySystemApp() const; + bool HapModuleInfoRequestInit(); int GetCurrentAccountId() const; void CreateDirIfNotExist(const std::string& dirPath) const; @@ -337,8 +235,6 @@ private: std::shared_ptr abilityContext_ = nullptr; std::shared_ptr resourceManager_ = nullptr; std::string path_ = ""; - std::map pattern_; - std::map theme_; std::shared_ptr hapModuleInfoLocal_ = nullptr; bool isCreateBySystemApp_ = false; std::string currArea_ = "el2"; diff --git a/test/fuzztest/abilitycontext_fuzzer/abilitycontext_fuzzer.cpp b/test/fuzztest/abilitycontext_fuzzer/abilitycontext_fuzzer.cpp index a318734857b..21b859ea740 100644 --- a/test/fuzztest/abilitycontext_fuzzer/abilitycontext_fuzzer.cpp +++ b/test/fuzztest/abilitycontext_fuzzer/abilitycontext_fuzzer.cpp @@ -76,9 +76,8 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) int mode = static_cast(GetU32Data(data)); abilityContext.GetDir(name, mode); std::string bundleName(data, size); - int flag = static_cast(GetU32Data(data)); int accountId = static_cast(GetU32Data(data)); - abilityContext.CreateBundleContext(bundleName, flag, accountId); + abilityContext.CreateBundleContext(bundleName, accountId); std::string permission(data, size); int pid = static_cast(GetU32Data(data)); int uid = static_cast(GetU32Data(data)); @@ -99,21 +98,11 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) std::string url(data, size); Uri uri = Uri(url); abilityContext.UnauthUriPermission(permission, uri, uid); - int patternId = static_cast(GetU32Data(data)); - abilityContext.SetPattern(patternId); BundleInfo bundleInfo; std::shared_ptr deal = nullptr; abilityContext.InitResourceManager(bundleInfo, deal); - int resId = static_cast(GetU32Data(data)); - abilityContext.GetString(resId); - abilityContext.GetStringArray(resId); - abilityContext.GetIntArray(resId); - int themeId = static_cast(GetU32Data(data)); - abilityContext.SetTheme(themeId); - abilityContext.GetColor(resId); int startId = static_cast(GetU32Data(data)); abilityContext.TerminateAbilityResult(startId); - abilityContext.SetColorMode(mode); std::vector wants; abilityContext.StartAbilities(wants); return (abilityContext.DisconnectAbility(conn) == 0); diff --git a/test/mock/frameworks_kits_appkit_test/include/mock_application.cpp b/test/mock/frameworks_kits_appkit_test/include/mock_application.cpp index 9119f17903f..3ae05e84aa1 100644 --- a/test/mock/frameworks_kits_appkit_test/include/mock_application.cpp +++ b/test/mock/frameworks_kits_appkit_test/include/mock_application.cpp @@ -91,7 +91,6 @@ void MockApplication::OnStart() EXPECT_STREQ("MockTestApplication", GetApplicationInfo()->name.c_str()); EXPECT_STREQ("", GetBundleCodePath().c_str()); - EXPECT_STREQ("", GetBundleResourcePath().c_str()); EXPECT_EQ(nullptr, GetContext()); EXPECT_EQ(nullptr, GetAbilityInfo()); EXPECT_STREQ("/hos/lib/dataDir", GetApplicationContext()->GetDir("test", 1).c_str()); diff --git a/test/mock/frameworks_kits_test/DemoAbility/demo_ability_test.cpp b/test/mock/frameworks_kits_test/DemoAbility/demo_ability_test.cpp index 02a81a0cb10..4bd73f6af4b 100644 --- a/test/mock/frameworks_kits_test/DemoAbility/demo_ability_test.cpp +++ b/test/mock/frameworks_kits_test/DemoAbility/demo_ability_test.cpp @@ -93,7 +93,6 @@ void DemoAbility::OnSaveAbilityState(PacMap& outState) EXPECT_STREQ(GetDataDir().c_str(), std::string("dataDir").c_str()); EXPECT_STREQ(GetBundleCodePath().c_str(), std::string("codePath").c_str()); EXPECT_STREQ(GetBundleName().c_str(), std::string("bundleName").c_str()); - EXPECT_STREQ(GetBundleResourcePath().c_str(), std::string("resourcePath").c_str()); EXPECT_STREQ(GetAppType().c_str(), std::string("system").c_str()); EXPECT_NE(GetBundleManager(), nullptr); diff --git a/test/moduletest/ability_test/ability_context_test.cpp b/test/moduletest/ability_test/ability_context_test.cpp index f855be50f7d..98f22020a2f 100644 --- a/test/moduletest/ability_test/ability_context_test.cpp +++ b/test/moduletest/ability_test/ability_context_test.cpp @@ -444,17 +444,6 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_GetBundleName_0100, Function EXPECT_TRUE(result.empty()); } -/** - * @tc.number: AaFwk_Ability_Context_GetBundleResourcePath_0100 - * @tc.name: GetBundleResourcePath - * @tc.desc: Verify that function GetBundleResourcePath. - */ -HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_GetBundleResourcePath_0100, Function | MediumTest | Level1) -{ - auto result = context_->GetBundleResourcePath(); - EXPECT_TRUE(result.empty()); -} - /** * @tc.number: AaFwk_Ability_Context_GetApplicationContext_0100 * @tc.name: GetApplicationContext @@ -573,9 +562,8 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_GetAbilityInfoType_0200, Func HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_CreateBundleContext_0100, Function | MediumTest | Level1) { std::string bundleName; - int32_t flag = 1; int32_t accountId = 1; - auto result = context_->CreateBundleContext(bundleName, flag, accountId); + auto result = context_->CreateBundleContext(bundleName, accountId); EXPECT_TRUE(result == nullptr); } @@ -783,87 +771,6 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_InitResourceManager_0100, Fun EXPECT_TRUE(deal == nullptr); } -/** - * @tc.number: AaFwk_Ability_Context_GetString_0100 - * @tc.name: GetString - * @tc.desc: Verify that function GetString. - */ -HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_GetString_0100, Function | MediumTest | Level1) -{ - int32_t resId = 1; - auto result = context_->GetString(resId); - EXPECT_EQ(result, ""); -} - -/** - * @tc.number: AaFwk_Ability_Context_GetStringArray_0100 - * @tc.name: GetStringArray - * @tc.desc: Verify that function GetStringArray. - */ -HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_GetStringArray_0100, Function | MediumTest | Level1) -{ - int32_t resId = 1; - auto result = context_->GetStringArray(resId); - EXPECT_TRUE(result.empty()); -} - -/** - * @tc.number: AaFwk_Ability_Context_GetIntArray_0100 - * @tc.name: GetIntArray - * @tc.desc: Verify that function GetIntArray. - */ -HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_GetIntArray_0100, Function | MediumTest | Level1) -{ - int32_t resId = 1; - auto result = context_->GetIntArray(resId); - EXPECT_TRUE(result.empty()); -} - -/** - * @tc.number: AaFwk_Ability_Context_GetTheme_0100 - * @tc.name: GetTheme - * @tc.desc: Verify that function GetTheme. - */ -HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_GetTheme_0100, Function | MediumTest | Level1) -{ - auto result = context_->GetTheme(); - EXPECT_TRUE(result.empty()); -} - -/** - * @tc.number: AaFwk_Ability_Context_GetPattern_0100 - * @tc.name: GetPattern - * @tc.desc: Verify that function GetPattern. - */ -HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_GetPattern_0100, Function | MediumTest | Level1) -{ - auto result = context_->GetPattern(); - EXPECT_TRUE(result.empty()); -} - -/** - * @tc.number: AaFwk_Ability_Context_GetColor_0100 - * @tc.name: GetColor - * @tc.desc: Verify that function GetColor. - */ -HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_GetColor_0100, Function | MediumTest | Level1) -{ - int32_t resId = 1; - auto result = context_->GetColor(resId); - EXPECT_EQ(result, INVALID_RESOURCE_VALUE); -} - -/** - * @tc.number: AaFwk_Ability_Context_GetThemeId_0100 - * @tc.name: GetThemeId - * @tc.desc: Verify that function GetThemeId. - */ -HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_GetThemeId_0100, Function | MediumTest | Level1) -{ - auto result = context_->GetThemeId(); - EXPECT_EQ(result, -1); -} - /** * @tc.number: AaFwk_Ability_Context_TerminateAbilityResult_0100 * @tc.name: TerminateAbilityResult @@ -898,28 +805,6 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_GetPreferencesDir_0100, Funct EXPECT_EQ(result, ""); } -/** - * @tc.number: AaFwk_Ability_Context_SetColorMode_0100 - * @tc.name: SetColorMode and GetColorMode - * @tc.desc: Verify that function SetColorMode and GetColorMode. - */ -HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_SetColorMode_0100, Function | MediumTest | Level1) -{ - std::shared_ptr application = std::make_shared(); - sptr abilityToken = sptr(new AbilityThread()); - std::shared_ptr abilityInfo = std::make_shared(); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); - AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); - std::shared_ptr deal = std::make_shared(); - deal->SetAbilityInfo(abilityInfo); - context_->AttachBaseContext(deal); - int32_t mode = 1; - context_->SetColorMode(mode); - auto result = context_->GetColorMode(); - EXPECT_EQ(result, 1); - EXPECT_TRUE(context_->baseContext_ != nullptr); -} - /** * @tc.number: AaFwk_Ability_Context_GetMissionId_0100 * @tc.name: GetMissionId diff --git a/test/moduletest/mock/include/mock_context.h b/test/moduletest/mock/include/mock_context.h index 1a8bca14571..91ba196a9c2 100644 --- a/test/moduletest/mock/include/mock_context.h +++ b/test/moduletest/mock/include/mock_context.h @@ -45,7 +45,6 @@ public: virtual int VerifyCallingPermission(const std::string& permission) = 0; virtual int VerifySelfPermission(const std::string& permission) = 0; virtual std::string GetBundleName() = 0; - virtual std::string GetBundleResourcePath() = 0; virtual void StartAbility(const AAFwk::Want& want, int requestCode) = 0; virtual void UnauthUriPermission(const std::string& permission, const Uri& uri, int uid) = 0; virtual sptr GetAbilityManager() = 0; @@ -55,7 +54,6 @@ public: virtual bool CanRequestPermission(const std::string& permission) = 0; virtual int VerifyCallingOrSelfPermission(const std::string& permission) = 0; virtual int VerifyPermission(const std::string& permission, int pid, int uid) = 0; - virtual void SetPattern(int patternId) = 0; virtual std::shared_ptr GetAbilityPackageContext() = 0; virtual std::shared_ptr GetHapModuleInfo() = 0; virtual std::string GetProcessName() = 0; @@ -66,19 +64,9 @@ public: virtual bool ConnectAbility(const Want& want, const sptr& conn) = 0; virtual void DisconnectAbility(const sptr& conn) = 0; virtual Uri GetCaller() = 0; - virtual std::string GetString(int resId) = 0; - virtual std::vector GetStringArray(int resId) = 0; - virtual std::vector GetIntArray(int resId) = 0; - virtual std::map GetTheme() = 0; - virtual void SetTheme(int themeId) = 0; - virtual std::map GetPattern() = 0; - virtual int GetColor(int resId) = 0; - virtual int GetThemeId() = 0; virtual bool TerminateAbilityResult(int startId) = 0; virtual int GetDisplayOrientation() = 0; virtual std::string GetPreferencesDir() = 0; - virtual void SetColorMode(int mode) = 0; - virtual int GetColorMode() = 0; virtual int GetMissionId() = 0; virtual void StartAbilities(const std::vector& wants) = 0; friend DataAbilityHelper; diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 69dacb670f1..6f5e9e7fa8e 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -341,7 +341,6 @@ group("unittest") { "connection_record_test:unittest", "connection_state_item_test:unittest", "connection_state_manager_test:unittest", - "continuation_test:unittest", "data_ability_manager_test:unittest", "data_ability_observer_proxy_test:unittest", "data_ability_observer_stub_test:unittest", diff --git a/test/unittest/continuation_test/BUILD.gn b/test/unittest/continuation_test/BUILD.gn deleted file mode 100644 index f1eb586e6c9..00000000000 --- a/test/unittest/continuation_test/BUILD.gn +++ /dev/null @@ -1,29 +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("//build/test.gni") -import("//foundation/ability/ability_runtime/ability_runtime.gni") - -group("unittest") { - testonly = true - deps = [ - "remote_register_service_test/connect_callback_proxy_test:unittest", - "remote_register_service_test/connect_callback_stub_test:unittest", - "remote_register_service_test/continuation_connector_test:unittest", - "remote_register_service_test/continuation_device_callback_proxy_test:unittest", - "remote_register_service_test/continuation_register_manager_proxy_test:unittest", - "remote_register_service_test/continuation_register_manager_test:unittest", - "remote_register_service_test/remote_register_service_proxy_test:unittest", - "remote_register_service_test/remote_register_service_stub_test:unittest", - ] -} diff --git a/test/unittest/continuation_test/remote_register_service_test/connect_callback_proxy_test/BUILD.gn b/test/unittest/continuation_test/remote_register_service_test/connect_callback_proxy_test/BUILD.gn deleted file mode 100644 index a1bc2499ada..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/connect_callback_proxy_test/BUILD.gn +++ /dev/null @@ -1,63 +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("//build/test.gni") -import("//foundation/ability/ability_runtime/ability_runtime.gni") - -module_output_path = "ability_runtime/abilitymgr" - -config("coverage_flags") { - if (ability_runtime_feature_coverage) { - cflags = [ "--coverage" ] - ldflags = [ "--coverage" ] - } -} - -ohos_unittest("connect_callback_proxy_test") { - module_out_path = module_output_path - - include_dirs = [ - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/remote_register_service", - "${ability_runtime_innerkits_path}/ability_manager/include/continuation", - "${ability_runtime_services_path}/common/include", - ] - - sources = [ "connect_callback_proxy_test.cpp" ] - - configs = [ ":coverage_flags" ] - cflags = [] - if (target_cpu == "arm") { - cflags += [ "-DBINDER_IPC_32BIT" ] - } - deps = [ - "${ability_runtime_native_path}/ability/native:continuation_ipc", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "ability_base:want", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - ] - - if (background_task_mgr_continuous_task_enable) { - external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] - } -} - -group("unittest") { - testonly = true - deps = [ ":connect_callback_proxy_test" ] -} diff --git a/test/unittest/continuation_test/remote_register_service_test/connect_callback_proxy_test/connect_callback_proxy_test.cpp b/test/unittest/continuation_test/remote_register_service_test/connect_callback_proxy_test/connect_callback_proxy_test.cpp deleted file mode 100644 index ada9b2f2622..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/connect_callback_proxy_test/connect_callback_proxy_test.cpp +++ /dev/null @@ -1,160 +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. - */ - -#include -#include -#include - -#define private public -#define protected public -#include "message_parcel.h" -#include "connect_callback_proxy.h" -#include "connect_callback_stub.h" -#undef private -#undef protected - -using namespace testing::ext; -using namespace testing; -using namespace std::chrono; - -namespace OHOS { -namespace AppExecFwk { -class ConnectCallbackProxyTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); -}; - -void ConnectCallbackProxyTest::SetUpTestCase(void) -{} - -void ConnectCallbackProxyTest::TearDownTestCase(void) -{} - -void ConnectCallbackProxyTest::SetUp(void) -{} - -void ConnectCallbackProxyTest::TearDown(void) -{} - -class MockConnectCallback : public ConnectCallbackStub { -public: - MockConnectCallback() {}; - ~MockConnectCallback() {}; - - int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override - { - GTEST_LOG_(INFO) << "MockRegisterService::SendRequest called. return value " << returnCode_; - reply.WriteInt32(ERR_NONE); - flag = true; - return returnCode_; - } - - void Connect(const string &deviceId, const string &deviceType) override - { - GTEST_LOG_(INFO) << "MockRegisterService::Connect called."; - return; - } - - void Disconnect(const string &deviceId) override - { - GTEST_LOG_(INFO) << "MockRegisterService::Connect called."; - return; - } - - int32_t returnCode_ = ERR_NONE; - bool flag = false; -}; - -/** - * @tc.number: AppExecFwk_ConnectCallbackProxy_Connect_001 - * @tc.name: Connect - * @tc.desc: Pass in normal parameters, and the test program executes correctly without abnormal exit - */ -HWTEST_F(ConnectCallbackProxyTest, AppExecFwk_ConnectCallbackProxy_Connect_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackProxy_Connect_001 start."; - sptr object = new (std::nothrow) MockConnectCallback(); - sptr testProxy = new (std::nothrow) ConnectCallbackProxy(object); - EXPECT_TRUE(testProxy != nullptr); - EXPECT_TRUE(testProxy->remoteObject_ != nullptr); - std::string deviceId = "7001005458323933328a592135733900"; - std::string deviceType = "rk3568"; - EXPECT_FALSE(object->flag); - testProxy->Connect(deviceId, deviceType); - EXPECT_TRUE(object->flag); - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackProxy_Connect_001 end."; -} - -/** - * @tc.number: AppExecFwk_ConnectCallbackProxy_Disconnect_001 - * @tc.name: Disconnect - * @tc.desc: Pass in normal parameters, and the test program executes correctly without abnormal exit - */ -HWTEST_F(ConnectCallbackProxyTest, AppExecFwk_ConnectCallbackProxy_Disconnect_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackProxy_Disconnect_001 start."; - sptr object = new (std::nothrow) MockConnectCallback(); - sptr testProxy = new (std::nothrow) ConnectCallbackProxy(object); - EXPECT_TRUE(testProxy != nullptr); - EXPECT_TRUE(testProxy->remoteObject_ != nullptr); - std::string deviceId = "7001005458323933328a592135733900"; - EXPECT_FALSE(object->flag); - testProxy->Disconnect(deviceId); - EXPECT_TRUE(object->flag); - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackProxy_Disconnect_001 end."; -} - -/** - * @tc.number: AppExecFwk_ConnectCallbackProxy_RemoteRequest_001 - * @tc.name: RemoteRequest - * @tc.desc: Pass in normal parameters, and the test program executes correctly without abnormal exit - */ -HWTEST_F(ConnectCallbackProxyTest, AppExecFwk_ConnectCallbackProxy_RemoteRequest_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackProxy_RemoteRequest_001 start."; - sptr object = new (std::nothrow) MockConnectCallback(); - sptr testProxy = new (std::nothrow) ConnectCallbackProxy(object); - EXPECT_TRUE(testProxy != nullptr); - EXPECT_TRUE(testProxy->remoteObject_ != nullptr); - int commandDisconnect = 1; - MessageParcel data = {}; - EXPECT_FALSE(object->flag); - testProxy->RemoteRequest(data, commandDisconnect); - EXPECT_TRUE(object->flag); - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackProxy_RemoteRequest_001 end."; -} - -/** - * @tc.number: AppExecFwk_ConnectCallbackProxy_RemoteRequest_002 - * @tc.name: RemoteRequest - * @tc.desc: The incoming Remote() is nullptr, and the test program executes as expected without exiting abnormally - */ -HWTEST_F(ConnectCallbackProxyTest, AppExecFwk_ConnectCallbackProxy_RemoteRequest_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackProxy_RemoteRequest_002 start."; - sptr object = nullptr; - sptr testProxy = new (std::nothrow) ConnectCallbackProxy(object); - EXPECT_TRUE(testProxy != nullptr); - int commandDisconnect = 1; - MessageParcel data = {}; - testProxy->RemoteRequest(data, commandDisconnect); - EXPECT_TRUE(testProxy->remoteObject_ == nullptr); - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackProxy_RemoteRequest_002 end."; -} -} // namespace AppExecFwk -} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/continuation_test/remote_register_service_test/connect_callback_stub_test/BUILD.gn b/test/unittest/continuation_test/remote_register_service_test/connect_callback_stub_test/BUILD.gn deleted file mode 100644 index 0110dbc852b..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/connect_callback_stub_test/BUILD.gn +++ /dev/null @@ -1,63 +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("//build/test.gni") -import("//foundation/ability/ability_runtime/ability_runtime.gni") - -module_output_path = "ability_runtime/abilitymgr" - -config("coverage_flags") { - if (ability_runtime_feature_coverage) { - cflags = [ "--coverage" ] - ldflags = [ "--coverage" ] - } -} - -ohos_unittest("connect_callback_stub_test") { - module_out_path = module_output_path - - include_dirs = [ - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/remote_register_service", - "${ability_runtime_innerkits_path}/ability_manager/include/continuation", - "${ability_runtime_services_path}/common/include", - ] - - sources = [ "connect_callback_stub_test.cpp" ] - - configs = [ ":coverage_flags" ] - cflags = [] - if (target_cpu == "arm") { - cflags += [ "-DBINDER_IPC_32BIT" ] - } - deps = [ - "${ability_runtime_native_path}/ability/native:continuation_ipc", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "ability_base:want", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - ] - - if (background_task_mgr_continuous_task_enable) { - external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] - } -} - -group("unittest") { - testonly = true - deps = [ ":connect_callback_stub_test" ] -} diff --git a/test/unittest/continuation_test/remote_register_service_test/connect_callback_stub_test/connect_callback_stub_test.cpp b/test/unittest/continuation_test/remote_register_service_test/connect_callback_stub_test/connect_callback_stub_test.cpp deleted file mode 100644 index 30060629d01..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/connect_callback_stub_test/connect_callback_stub_test.cpp +++ /dev/null @@ -1,207 +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. - */ - -#include -#include -#include - -#define private public -#define protected public -#include "connect_callback_proxy.h" -#include "connect_callback_stub.h" -#undef private -#undef protected - -using namespace testing::ext; -using namespace testing; -using namespace std::chrono; - -namespace OHOS { -namespace AppExecFwk { -class ConnectCallbackStubTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); -}; - -void ConnectCallbackStubTest::SetUpTestCase(void) -{} - -void ConnectCallbackStubTest::TearDownTestCase(void) -{} - -void ConnectCallbackStubTest::SetUp(void) -{} - -void ConnectCallbackStubTest::TearDown(void) -{} - -class MockConnectCallback : public ConnectCallbackStub { -public: - MockConnectCallback() {}; - ~MockConnectCallback() {}; - - sptr AsObject() override - { - if (!asObject_) { - return nullptr; - } - return this; - }; - - void Connect(const string &deviceId, const string &deviceType) override - { - return; - } - void Disconnect(const string &deviceId) override - { - return; - } - - int32_t returnCode_ = ERR_NONE; - bool asObject_ = true; -}; - -/** - * @tc.number: AppExecFwk_ConnectCallbackStub_ConnectInner_001 - * @tc.name: ConnectInner - * @tc.desc: Pass in normal parameters, and the test program executes correctly without abnormal exit - */ -HWTEST_F(ConnectCallbackStubTest, AppExecFwk_ConnectCallbackStub_ConnectInner_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_ConnectInner_001 start."; - sptr object = new (std::nothrow) MockConnectCallback(); - EXPECT_TRUE(object != nullptr); - MessageParcel data = {}; - MessageParcel reply = {}; - EXPECT_EQ(object->ConnectInner(data, reply), OHOS::ERR_NONE); - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_ConnectInner_001 end."; -} - -/** - * @tc.number: AppExecFwk_ConnectCallbackStub_DisconnectInner_001 - * @tc.name: DisconnectInner - * @tc.desc: Pass in normal parameters, and the test program executes correctly without abnormal exit - */ -HWTEST_F(ConnectCallbackStubTest, AppExecFwk_ConnectCallbackStub_DisconnectInner_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_DisconnectInner_001 start."; - sptr object = new (std::nothrow) MockConnectCallback(); - EXPECT_TRUE(object != nullptr); - MessageParcel data = {}; - MessageParcel reply = {}; - EXPECT_EQ(object->DisconnectInner(data, reply), OHOS::ERR_NONE); - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_DisconnectInner_001 end."; -} - -/** - * @tc.number: AppExecFwk_ConnectCallbackStub_OnRemoteRequest_001 - * @tc.name: OnRemoteRequest - * @tc.desc: Pass in normal parameters, and the test program executes correctly without abnormal exit - */ -HWTEST_F(ConnectCallbackStubTest, AppExecFwk_ConnectCallbackStub_OnRemoteRequest_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_OnRemoteRequest_001 start."; - sptr object = new (std::nothrow) MockConnectCallback(); - EXPECT_TRUE(object != nullptr); - MessageParcel data; - MessageParcel reply; - MessageOption option; - EXPECT_TRUE(data.WriteInterfaceToken(u"ohos.appexecfwk.iconnectcallback")); - EXPECT_EQ(object->OnRemoteRequest(MockConnectCallback::COMMAND_CONNECT, data, reply, option), OHOS::ERR_NONE); - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_OnRemoteRequest_001 end."; -} - -/** - * @tc.number: AppExecFwk_ConnectCallbackStub_OnRemoteRequest_002 - * @tc.name: OnRemoteRequest - * @tc.desc: Pass in normal parameters, and the test program executes correctly without abnormal exit - */ -HWTEST_F(ConnectCallbackStubTest, AppExecFwk_ConnectCallbackStub_OnRemoteRequest_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_OnRemoteRequest_002 start."; - sptr object = new (std::nothrow) MockConnectCallback(); - EXPECT_TRUE(object != nullptr); - MessageParcel data; - MessageParcel reply; - MessageOption option; - EXPECT_TRUE(data.WriteInterfaceToken(u"ohos.appexecfwk.iconnectcallback")); - EXPECT_EQ(object->OnRemoteRequest(MockConnectCallback::COMMAND_DISCONNECT, data, reply, option), OHOS::ERR_NONE); - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_OnRemoteRequest_002 end."; -} - -/** - * @tc.number: AppExecFwk_ConnectCallbackStub_OnRemoteRequest_003 - * @tc.name: OnRemoteRequest - * @tc.desc: The passed in parameter toukenString is an abnormal value. The test program executes as - * expected and does not exit abnormally - */ -HWTEST_F(ConnectCallbackStubTest, AppExecFwk_ConnectCallbackStub_OnRemoteRequest_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_OnRemoteRequest_003 start."; - sptr object = new (std::nothrow) MockConnectCallback(); - EXPECT_TRUE(object != nullptr); - MessageParcel data; - MessageParcel reply; - MessageOption option; - EXPECT_TRUE(data.WriteInterfaceToken(u"123")); - EXPECT_EQ(object->OnRemoteRequest(MockConnectCallback::COMMAND_CONNECT, data, reply, option), - OHOS::ERR_INVALID_REPLY); - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_OnRemoteRequest_003 end."; -} - -/** - * @tc.number: AppExecFwk_ConnectCallbackStub_OnRemoteRequest_004 - * @tc.name: OnRemoteRequest - * @tc.desc: The input parameter code is an abnormal value, and the test program executes as expected - * without exiting abnormally - */ -HWTEST_F(ConnectCallbackStubTest, AppExecFwk_ConnectCallbackStub_OnRemoteRequest_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_OnRemoteRequest_004 start."; - sptr object = new (std::nothrow) MockConnectCallback(); - EXPECT_TRUE(object != nullptr); - MessageParcel data; - MessageParcel reply; - MessageOption option; - EXPECT_TRUE(data.WriteInterfaceToken(u"ohos.appexecfwk.iconnectcallback")); - EXPECT_EQ(object->OnRemoteRequest(MockConnectCallback::COMMAND_DISCONNECT + 66, data, reply, option), - OHOS::IPC_STUB_UNKNOW_TRANS_ERR); - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_OnRemoteRequest_004 end."; -} - -/** - * @tc.number: AppExecFwk_ConnectCallbackStub_OnRemoteRequest_005 - * @tc.name: OnRemoteRequest - * @tc.desc: The input parameter code is null ptr, and the test program executes as expected without exception - */ -HWTEST_F(ConnectCallbackStubTest, AppExecFwk_ConnectCallbackStub_OnRemoteRequest_005, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_OnRemoteRequest_005 start."; - sptr object = new (std::nothrow) MockConnectCallback(); - EXPECT_TRUE(object != nullptr); - MessageParcel data = {}; - MessageParcel reply = {}; - MessageOption option = {}; - EXPECT_TRUE(data.WriteInterfaceToken(u"ohos.appexecfwk.iconnectcallback")); - object->memberFuncMap_[MockConnectCallback::COMMAND_DISCONNECT + 1] = nullptr; - EXPECT_EQ(object->OnRemoteRequest(MockConnectCallback::COMMAND_DISCONNECT + 1, data, reply, option), - IPC_STUB_UNKNOW_TRANS_ERR); - GTEST_LOG_(INFO) << "AppExecFwk_ConnectCallbackStub_OnRemoteRequest_005 end."; -} -} // namespace AppExecFwk -} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/continuation_test/remote_register_service_test/continuation_connector_test/BUILD.gn b/test/unittest/continuation_test/remote_register_service_test/continuation_connector_test/BUILD.gn deleted file mode 100644 index a92ce0e2ca3..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/continuation_connector_test/BUILD.gn +++ /dev/null @@ -1,75 +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("//build/test.gni") -import("//foundation/ability/ability_runtime/ability_runtime.gni") - -module_output_path = "ability_runtime/abilitymgr" - -remote_register_path = "${ability_runtime_path}/frameworks/native/ability/native/continuation/remote_register_service" - -config("coverage_flags") { - if (ability_runtime_feature_coverage) { - cflags = [ "--coverage" ] - ldflags = [ "--coverage" ] - } -} - -ohos_unittest("continuation_connector_test") { - module_out_path = module_output_path - - include_dirs = [ - "${ability_runtime_path}/interfaces/kits/native/ability/native", - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/remote_register_service", - "${ability_runtime_innerkits_path}/ability_manager/include/continuation", - "${ability_runtime_services_path}/common/include", - ] - - sources = [ - "${remote_register_path}/connect_callback_stub.cpp", - "${remote_register_path}/continuation_connector.cpp", - "${remote_register_path}/continuation_device_callback_proxy.cpp", - "${remote_register_path}/remote_register_service_stub.cpp", - "continuation_connector_test.cpp", - ] - - configs = [ ":coverage_flags" ] - cflags = [] - if (target_cpu == "arm") { - cflags += [ "-DBINDER_IPC_32BIT" ] - } - deps = [ - "${ability_runtime_native_path}/ability/native:abilitykit_native", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "ability_base:want", - "ability_runtime:ability_manager", - "c_utils:utils", - "common_event_service:cesfwk_innerkits", - "eventhandler:libeventhandler", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - ] - - if (background_task_mgr_continuous_task_enable) { - external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] - } -} - -group("unittest") { - testonly = true - deps = [ ":continuation_connector_test" ] -} diff --git a/test/unittest/continuation_test/remote_register_service_test/continuation_connector_test/continuation_connector_test.cpp b/test/unittest/continuation_test/remote_register_service_test/continuation_connector_test/continuation_connector_test.cpp deleted file mode 100644 index db57047e33c..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/continuation_connector_test/continuation_connector_test.cpp +++ /dev/null @@ -1,832 +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. - */ - -#include -#include -#include - -#define private public -#define protected public -#include "ability.h" -#include "continuation_connector.h" -#include "remote_register_service_stub.h" -#undef private -#undef protected - -using namespace testing::ext; -using namespace testing; -using namespace std::chrono; - -namespace OHOS { -namespace AppExecFwk { -class ContinuationConnectorTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); -}; - -void ContinuationConnectorTest::SetUpTestCase(void) -{} -void ContinuationConnectorTest::TearDownTestCase(void) -{} - -void ContinuationConnectorTest::SetUp(void) -{} - -void ContinuationConnectorTest::TearDown(void) -{} - -class MockRegisterService : public RemoteRegisterServiceStub { -public: - MockRegisterService() {}; - virtual ~MockRegisterService() {}; - - int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override - { - GTEST_LOG_(INFO) << "MockRegisterService::SendRequest called. return value " << returnCode_; - reply.WriteInt32(ERR_NONE); - return returnCode_; - } - - int Register(const std::string &bundleName, const sptr &token, const ExtraParams &extras, - const sptr &callback) override - { - return register_; - }; - bool Unregister(int registerToken) override - { - return unregister_; - }; - bool UpdateConnectStatus(int registerToken, const std::string &deviceId, int status) override - { - return updateConnectStatus_; - }; - bool ShowDeviceList(int registerToken, const ExtraParams &extras) override - { - return showDeviceList_; - }; - - sptr AsInterface() override - { - if (!asInterface_) { - return nullptr; - } - - return this; - } - - int32_t returnCode_ = ERR_NONE; - int32_t register_ = ERR_NONE; - bool unregister_ = true; - bool updateConnectStatus_ = true; - bool showDeviceList_ = true; - bool asInterface_ = true; -}; - -class MockRequest : public ContinuationRequest { -public: - MockRequest() {}; - virtual ~MockRequest() {}; - - void Execute() override - { - flag = true; - }; - - bool flag = false; -}; - -class MockContext : public Ability { -public: - MockContext() {}; - virtual ~MockContext() {}; - - ErrCode DisconnectAbility(const sptr &conn) override - { - GTEST_LOG_(INFO) << "Mock DisconnectAbility called."; - return ERR_OK; - } - - bool ConnectAbility(const Want &want, const sptr &conn) override - { - GTEST_LOG_(INFO) << "Mock ConnectAbility called."; - return true; - } -}; - -/* -* @tc.number: AppExecFwk_ContinuationConnector_GetInstance_001 -* @tc.name: GetInstance -* @tc.desc: Verify function GetInstance normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_GetInstance_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_GetInstance_001 start."; - std::shared_ptr ability = std::make_shared(); - EXPECT_TRUE(ability != nullptr); - EXPECT_TRUE(ContinuationConnector::instance_ == nullptr); - EXPECT_TRUE(ContinuationConnector::GetInstance(ability) != nullptr); - EXPECT_TRUE(ContinuationConnector::instance_ != nullptr); - ContinuationConnector::instance_.clear(); - ContinuationConnector::instance_ = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_GetInstance_001 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_GetInstance_002 -* @tc.name: GetInstance -* @tc.desc: Verify function GetInstance normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_GetInstance_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_GetInstance_002 start."; - std::shared_ptr ability = std::make_shared(); - EXPECT_TRUE(ability != nullptr); - EXPECT_TRUE(ContinuationConnector::GetInstance(ability) != nullptr); - EXPECT_TRUE(ContinuationConnector::instance_ != nullptr); - EXPECT_TRUE(ContinuationConnector::GetInstance(ability) != nullptr); - EXPECT_TRUE(ContinuationConnector::instance_ != nullptr); - ContinuationConnector::instance_.clear(); - ContinuationConnector::instance_ = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_GetInstance_002 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_OnAbilityConnectDone_001 -* @tc.name: OnAbilityConnectDone -* @tc.desc: Verify function OnAbilityConnectDone normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_OnAbilityConnectDone_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_OnAbilityConnectDone_001 start."; - std::shared_ptr ability = std::make_shared(); - EXPECT_TRUE(ability != nullptr); - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - auto mockRequest = std::make_shared(); - EXPECT_TRUE(mockRequest != nullptr); - EXPECT_FALSE(mockRequest->flag); - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - testConnector->continuationRequestList_.push_back(mockRequest); - AppExecFwk::ElementName element; - constexpr int32_t registerToken = 0; - testConnector->OnAbilityConnectDone(element, object, registerToken); - EXPECT_TRUE(mockRequest->flag); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_OnAbilityConnectDone_001 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_OnAbilityConnectDone_002 -* @tc.name: OnAbilityConnectDone -* @tc.desc: Verify function OnAbilityConnectDone abnormal branch, parameter object is nullptr -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_OnAbilityConnectDone_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_OnAbilityConnectDone_002 start."; - std::shared_ptr ability = std::make_shared(); - EXPECT_TRUE(ability != nullptr); - sptr object = nullptr; - EXPECT_TRUE(object == nullptr); - auto mockRequest = std::make_shared(); - EXPECT_TRUE(mockRequest != nullptr); - EXPECT_FALSE(mockRequest->flag); - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - testConnector->continuationRequestList_.push_back(mockRequest); - AppExecFwk::ElementName element; - constexpr int32_t registerToken = 0; - testConnector->OnAbilityConnectDone(element, object, registerToken); - EXPECT_FALSE(mockRequest->flag); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_OnAbilityConnectDone_002 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_OnAbilityConnectDone_003 -* @tc.name: OnAbilityConnectDone -* @tc.desc: Verify function OnAbilityConnectDone abnormal branch, conversion registerService is nullptr -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_OnAbilityConnectDone_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_OnAbilityConnectDone_003 start."; - std::shared_ptr ability = std::make_shared(); - EXPECT_TRUE(ability != nullptr); - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - auto mockRequest = std::make_shared(); - EXPECT_TRUE(mockRequest != nullptr); - EXPECT_FALSE(mockRequest->flag); - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - testConnector->continuationRequestList_.push_back(mockRequest); - AppExecFwk::ElementName element; - constexpr int32_t registerToken = 0; - object->asInterface_ = false; - testConnector->OnAbilityConnectDone(element, object, registerToken); - EXPECT_FALSE(mockRequest->flag); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_OnAbilityConnectDone_003 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_OnAbilityConnectDone_004 -* @tc.name: OnAbilityConnectDone -* @tc.desc: Verify function OnAbilityConnectDone normal branch, member variable requestList is empty -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_OnAbilityConnectDone_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_OnAbilityConnectDone_004 start."; - std::shared_ptr ability = std::make_shared(); - EXPECT_TRUE(ability != nullptr); - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - AppExecFwk::ElementName element; - constexpr int32_t registerToken = 0; - EXPECT_TRUE(testConnector->continuationRequestList_.size() == 0); - testConnector->OnAbilityConnectDone(element, object, registerToken); - EXPECT_TRUE(testConnector->continuationRequestList_.size() == 0); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_OnAbilityConnectDone_004 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_OnAbilityDisconnectDone_001 -* @tc.name: OnAbilityDisconnectDone -* @tc.desc: Verify function OnAbilityDisconnectDone normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_OnAbilityDisconnectDone_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_OnAbilityDisconnectDone_001 start."; - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - AppExecFwk::ElementName element; - constexpr int32_t registerToken = 0; - EXPECT_TRUE(testConnector->remoteRegisterService_ == nullptr); - testConnector->OnAbilityDisconnectDone(element, registerToken); - EXPECT_TRUE(testConnector->remoteRegisterService_ == nullptr); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_OnAbilityDisconnectDone_001 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_OnAbilityDisconnectDone_002 -* @tc.name: OnAbilityDisconnectDone -* @tc.desc: Verify function OnAbilityDisconnectDone normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_OnAbilityDisconnectDone_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_OnAbilityDisconnectDone_002 start."; - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - AppExecFwk::ElementName element; - constexpr int32_t registerToken = 0; - testConnector->remoteRegisterService_ = object; - EXPECT_TRUE(testConnector->remoteRegisterService_ != nullptr); - testConnector->OnAbilityDisconnectDone(element, registerToken); - EXPECT_TRUE(testConnector->remoteRegisterService_ == nullptr); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_OnAbilityDisconnectDone_002 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_001 -* @tc.name: BindRemoteRegisterAbility -* @tc.desc: Verify function BindRemoteRegisterAbility normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_001 start."; - auto mockRequest = std::make_shared(); - EXPECT_TRUE(mockRequest != nullptr); - std::shared_ptr context = std::make_shared(); - EXPECT_TRUE(context != nullptr); - sptr testConnector = new (std::nothrow) ContinuationConnector(context); - EXPECT_TRUE(testConnector != nullptr); - testConnector->isConnected_.store(false); - EXPECT_FALSE(testConnector->isConnected_.load()); - testConnector->BindRemoteRegisterAbility(mockRequest); - EXPECT_TRUE(testConnector->continuationRequestList_.size() == 1); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_001 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_002 -* @tc.name: BindRemoteRegisterAbility -* @tc.desc: Verify function BindRemoteRegisterAbility abnormal branch, member variable context_ is nullptr -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_002 start."; - auto mockRequest = std::make_shared(); - EXPECT_TRUE(mockRequest != nullptr); - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - testConnector->BindRemoteRegisterAbility(mockRequest); - EXPECT_TRUE(testConnector->continuationRequestList_.size() == 0); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_002 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_003 -* @tc.name: BindRemoteRegisterAbility -* @tc.desc: Verify function BindRemoteRegisterAbility abnormal branch, parameter request is nullptr -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_003 start."; - std::shared_ptr ability = std::make_shared(); - EXPECT_TRUE(ability != nullptr); - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - testConnector->BindRemoteRegisterAbility(nullptr); - EXPECT_TRUE(testConnector->continuationRequestList_.size() == 0); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_003 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_004 -* @tc.name: BindRemoteRegisterAbility -* @tc.desc: Verify function BindRemoteRegisterAbility normal branch, member variable isConnected is true -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_004 start."; - auto mockRequest = std::make_shared(); - EXPECT_TRUE(mockRequest != nullptr); - EXPECT_FALSE(mockRequest->flag); - std::shared_ptr ability = std::make_shared(); - EXPECT_TRUE(ability != nullptr); - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - testConnector->isConnected_.store(true); - EXPECT_TRUE(testConnector->isConnected_.load()); - testConnector->BindRemoteRegisterAbility(mockRequest); - EXPECT_TRUE(testConnector->continuationRequestList_.size() == 0); - EXPECT_TRUE(mockRequest->flag); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_BindRemoteRegisterAbility_004 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_UnbindRemoteRegisterAbility_001 -* @tc.name: UnbindRemoteRegisterAbility -* @tc.desc: Verify function UnbindRemoteRegisterAbility normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_UnbindRemoteRegisterAbility_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_UnbindRemoteRegisterAbility_001 start."; - std::shared_ptr context = std::make_shared(); - EXPECT_TRUE(context != nullptr); - sptr testConnector = new (std::nothrow) ContinuationConnector(context); - EXPECT_TRUE(testConnector != nullptr); - testConnector->isConnected_.store(true); - EXPECT_TRUE(testConnector->isConnected_.load()); - testConnector->UnbindRemoteRegisterAbility(); - EXPECT_FALSE(testConnector->isConnected_.load()); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_UnbindRemoteRegisterAbility_001 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_UnbindRemoteRegisterAbility_002 -* @tc.name: UnbindRemoteRegisterAbility -* @tc.desc: Verify function UnbindRemoteRegisterAbility abnormal branch, member varable context_ is nullptr -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_UnbindRemoteRegisterAbility_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_UnbindRemoteRegisterAbility_002 start."; - std::shared_ptr context = nullptr; - EXPECT_TRUE(context == nullptr); - sptr testConnector = new (std::nothrow) ContinuationConnector(context); - EXPECT_TRUE(testConnector != nullptr); - testConnector->isConnected_.store(true); - EXPECT_TRUE(testConnector->isConnected_.load()); - testConnector->UnbindRemoteRegisterAbility(); - EXPECT_TRUE(testConnector->isConnected_.load()); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_UnbindRemoteRegisterAbility_002 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_IsAbilityConnected_001 -* @tc.name: IsAbilityConnected -* @tc.desc: Verify function IsAbilityConnected normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_IsAbilityConnected_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_IsAbilityConnected_001 start."; - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - testConnector->isConnected_.store(true); - EXPECT_TRUE(testConnector->IsAbilityConnected()); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_IsAbilityConnected_001 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_IsAbilityConnected_002 -* @tc.name: IsAbilityConnected -* @tc.desc: Verify function IsAbilityConnected normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_IsAbilityConnected_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_IsAbilityConnected_002 start."; - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - testConnector->isConnected_.store(false); - EXPECT_FALSE(testConnector->IsAbilityConnected()); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_IsAbilityConnected_002 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_Unregister_001 -* @tc.name: Unregister -* @tc.desc: Verify function Unregister normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_Unregister_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Unregister_001 start."; - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - constexpr int32_t registerToken = 100; - object->unregister_ = true; - testConnector->remoteRegisterService_ = object; - EXPECT_TRUE(testConnector->remoteRegisterService_ != nullptr); - EXPECT_TRUE(testConnector->Unregister(registerToken)); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Unregister_001 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_Unregister_002 -* @tc.name: Unregister -* @tc.desc: Verify function Unregister normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_Unregister_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Unregister_002 start."; - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - constexpr int32_t registerToken = 100; - object->unregister_ = false; - testConnector->remoteRegisterService_ = object; - EXPECT_TRUE(testConnector->remoteRegisterService_ != nullptr); - EXPECT_FALSE(testConnector->Unregister(registerToken)); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Unregister_002 end."; -} - -/* - * Feature: AbilityManager - * Function: ContinuationConnector - * SubFunction: Unregister - * FunctionPoints: The parameter of function Unregister. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Unregister abnormal branch - */ -/* -* @tc.number: AppExecFwk_ContinuationConnector_Unregister_002 -* @tc.name: Unregister -* @tc.desc: Verify function Unregister abnormal branch, member variable remoteRegisterService_ is nullptr -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_Unregister_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Unregister_003 start."; - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - constexpr int32_t registerToken = 100; - EXPECT_TRUE(testConnector->remoteRegisterService_ == nullptr); - EXPECT_FALSE(testConnector->Unregister(registerToken)); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Unregister_003 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_UpdateConnectStatus_001 -* @tc.name: UpdateConnectStatus -* @tc.desc: Verify function UpdateConnectStatus normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_UpdateConnectStatus_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_UpdateConnectStatus_001 start."; - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - constexpr int32_t registerToken = 100; - constexpr int32_t stage = 1; - const std::string deviceId = "7001005458323933328a592135733900"; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - object->updateConnectStatus_ = true; - testConnector->remoteRegisterService_ = object; - EXPECT_TRUE(testConnector->remoteRegisterService_ != nullptr); - EXPECT_TRUE(testConnector->UpdateConnectStatus(registerToken, deviceId, stage)); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_UpdateConnectStatus_001 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_UpdateConnectStatus_002 -* @tc.name: UpdateConnectStatus -* @tc.desc: Verify function UpdateConnectStatus normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_UpdateConnectStatus_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_UpdateConnectStatus_002 start."; - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - constexpr int32_t registerToken = 100; - constexpr int32_t stage = 1; - const std::string deviceId = "7001005458323933328a592135733900"; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - object->updateConnectStatus_ = false; - testConnector->remoteRegisterService_ = object; - EXPECT_TRUE(testConnector->remoteRegisterService_ != nullptr); - EXPECT_FALSE(testConnector->UpdateConnectStatus(registerToken, deviceId, stage)); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_UpdateConnectStatus_002 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_UpdateConnectStatus_002 -* @tc.name: UpdateConnectStatus -* @tc.desc: Verify function UpdateConnectStatus abnormal branch, member variable remoteRegisterService_ is nullptr -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_UpdateConnectStatus_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_UpdateConnectStatus_003 start."; - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - constexpr int32_t registerToken = 100; - constexpr int32_t stage = 1; - const std::string deviceId = "7001005458323933328a592135733900"; - EXPECT_TRUE(testConnector->remoteRegisterService_ == nullptr); - EXPECT_FALSE(testConnector->UpdateConnectStatus(registerToken, deviceId, stage)); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_UpdateConnectStatus_003 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_ShowDeviceList_001 -* @tc.name: ShowDeviceList -* @tc.desc: Verify function ShowDeviceList normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_ShowDeviceList_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_ShowDeviceList_001 start."; - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - constexpr int32_t registerToken = 100; - const ExtraParams extra = {}; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - object->showDeviceList_ = true; - testConnector->remoteRegisterService_ = object; - EXPECT_TRUE(testConnector->remoteRegisterService_ != nullptr); - EXPECT_TRUE(testConnector->ShowDeviceList(registerToken, extra)); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_ShowDeviceList_001 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_ShowDeviceList_002 -* @tc.name: ShowDeviceList -* @tc.desc: Verify function ShowDeviceList normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_ShowDeviceList_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_ShowDeviceList_002 start."; - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - constexpr int32_t registerToken = 100; - const ExtraParams extra = {}; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - object->showDeviceList_ = false; - testConnector->remoteRegisterService_ = object; - EXPECT_TRUE(testConnector->remoteRegisterService_ != nullptr); - EXPECT_FALSE(testConnector->ShowDeviceList(registerToken, extra)); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_ShowDeviceList_002 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_ShowDeviceList_003 -* @tc.name: ShowDeviceList -* @tc.desc: Verify function ShowDeviceList abnormal branch, member variable remoteRegisterService_ is nullptr -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_ShowDeviceList_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_ShowDeviceList_003 start."; - std::shared_ptr ability = nullptr; - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - constexpr int32_t registerToken = 100; - const ExtraParams extra = {}; - EXPECT_TRUE(testConnector->remoteRegisterService_ == nullptr); - EXPECT_FALSE(testConnector->ShowDeviceList(registerToken, extra)); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_ShowDeviceList_003 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_Register_001 -* @tc.name: Register -* @tc.desc: Verify function Register normal branch -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_Register_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Register_001 start."; - std::shared_ptr ability = std::make_shared(); - EXPECT_TRUE(ability != nullptr); - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - const std::string bundleName = "ABC"; - const ExtraParams extra = {}; - std::shared_ptr callback = nullptr; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - ability->token_ = object; - testConnector->remoteRegisterService_ = object; - EXPECT_TRUE(testConnector->remoteRegisterService_ != nullptr); - std::weak_ptr context = ability; - EXPECT_EQ(testConnector->Register(context, bundleName, extra, callback), ERR_NONE); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Register_001 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_Register_002 -* @tc.name: Register -* @tc.desc: Verify function Register abnormal branch, interface Register return error code -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_Register_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Register_002 start."; - std::shared_ptr ability = std::make_shared(); - EXPECT_TRUE(ability != nullptr); - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - const std::string bundleName = "ABC"; - const ExtraParams extra = {}; - std::shared_ptr callback = nullptr; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - ability->token_ = object; - object->register_ = ERR_NONE - 1; - testConnector->remoteRegisterService_ = object; - EXPECT_TRUE(testConnector->remoteRegisterService_ != nullptr); - std::weak_ptr context = ability; - EXPECT_EQ(testConnector->Register(context, bundleName, extra, callback), ERR_NONE - 1); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Register_002 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_Register_003 -* @tc.name: Register -* @tc.desc: Verify function Register abnormal branch, parameter context is nullptr -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_Register_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Register_003 start."; - std::shared_ptr ability = nullptr; - EXPECT_TRUE(ability == nullptr); - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - const std::string bundleName = "ABC"; - const ExtraParams extra = {}; - std::shared_ptr callback = nullptr; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - testConnector->remoteRegisterService_ = object; - EXPECT_TRUE(testConnector->remoteRegisterService_ != nullptr); - std::weak_ptr context = ability; - EXPECT_EQ(testConnector->Register(context, bundleName, extra, callback), -1); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Register_003 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_Register_004 -* @tc.name: Register -* @tc.desc: Verify function Register abnormal branch, member variable remoteRegisterService_ is nullptr -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_Register_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Register_004 start."; - std::shared_ptr ability = std::make_shared(); - EXPECT_TRUE(ability != nullptr); - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - const std::string bundleName = "ABC"; - const ExtraParams extra = {}; - std::shared_ptr callback = nullptr; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - ability->token_ = object; - EXPECT_TRUE(ability->token_ != nullptr); - testConnector->remoteRegisterService_ = nullptr; - EXPECT_TRUE(testConnector->remoteRegisterService_ == nullptr); - std::weak_ptr context = ability; - EXPECT_EQ(testConnector->Register(context, bundleName, extra, callback), -1); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Register_004 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationConnector_Register_005 -* @tc.name: Register -* @tc.desc: Verify function Register abnormal branch, obtained token is nullptr -*/ -HWTEST_F(ContinuationConnectorTest, AppExecFwk_ContinuationConnector_Register_005, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Register_005 start."; - std::shared_ptr ability = std::make_shared(); - EXPECT_TRUE(ability != nullptr); - sptr testConnector = new (std::nothrow) ContinuationConnector(ability); - EXPECT_TRUE(testConnector != nullptr); - const std::string bundleName = "ABC"; - const ExtraParams extra = {}; - std::shared_ptr callback = nullptr; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - EXPECT_TRUE(ability->token_ == nullptr); - testConnector->remoteRegisterService_ = object; - EXPECT_TRUE(testConnector->remoteRegisterService_ != nullptr); - std::weak_ptr context = ability; - EXPECT_EQ(testConnector->Register(context, bundleName, extra, callback), -1); - testConnector.clear(); - testConnector = nullptr; - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationConnector_Register_005 end."; -} -} // namespace AppExecFwk -} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/continuation_test/remote_register_service_test/continuation_device_callback_proxy_test/BUILD.gn b/test/unittest/continuation_test/remote_register_service_test/continuation_device_callback_proxy_test/BUILD.gn deleted file mode 100644 index f5d7edd26c0..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/continuation_device_callback_proxy_test/BUILD.gn +++ /dev/null @@ -1,70 +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("//build/test.gni") -import("//foundation/ability/ability_runtime/ability_runtime.gni") - -module_output_path = "ability_runtime/abilitymgr" - -remote_register_path = "${ability_runtime_path}/frameworks/native/ability/native/continuation/remote_register_service" - -config("coverage_flags") { - if (ability_runtime_feature_coverage) { - cflags = [ "--coverage" ] - ldflags = [ "--coverage" ] - } -} - -ohos_unittest("continuation_device_callback_proxy_test") { - module_out_path = module_output_path - - include_dirs = [ - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/remote_register_service", - "${ability_runtime_path}/test/unittest/continuation_test/common_mock", - "${ability_runtime_innerkits_path}/ability_manager/include/continuation", - "${ability_runtime_services_path}/common/include", - ] - - sources = [ - "${remote_register_path}/continuation_device_callback_proxy.cpp", - "continuation_device_callback_proxy_test.cpp", - ] - - configs = [ ":coverage_flags" ] - cflags = [] - if (target_cpu == "arm") { - cflags += [ "-DBINDER_IPC_32BIT" ] - } - deps = [ - "${ability_runtime_native_path}/ability/native:continuation_ipc", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "ability_base:want", - "ability_runtime:ability_manager", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - ] - - if (background_task_mgr_continuous_task_enable) { - external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] - } -} - -group("unittest") { - testonly = true - deps = [ ":continuation_device_callback_proxy_test" ] -} diff --git a/test/unittest/continuation_test/remote_register_service_test/continuation_device_callback_proxy_test/continuation_device_callback_proxy_test.cpp b/test/unittest/continuation_test/remote_register_service_test/continuation_device_callback_proxy_test/continuation_device_callback_proxy_test.cpp deleted file mode 100644 index f8984142cc8..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/continuation_device_callback_proxy_test/continuation_device_callback_proxy_test.cpp +++ /dev/null @@ -1,140 +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. - */ - -#include -#include -#include - -#define private public -#define protected public -#include "continuation_device_callback_proxy.h" -#undef private -#undef protected - -using namespace testing::ext; -using namespace testing; -using namespace std::chrono; - -namespace OHOS { -namespace AppExecFwk { -class ContinuationDeviceCallbackProxyTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); -}; - -void ContinuationDeviceCallbackProxyTest::SetUpTestCase(void) -{ -} - -void ContinuationDeviceCallbackProxyTest::TearDownTestCase(void) -{ -} - -void ContinuationDeviceCallbackProxyTest::SetUp(void) -{ -} - -void ContinuationDeviceCallbackProxyTest::TearDown(void) -{ -} - -class MoclCallback : public IContinuationDeviceCallback { -public: - MoclCallback() {}; - virtual ~MoclCallback() {}; - virtual void OnDeviceConnectDone(const std::string &deviceId, const std::string &deviceType) {}; - virtual void OnDeviceDisconnectDone(const std::string &deviceId) {}; -}; - -/* -* @tc.number: AppExecFwk_ContinuationDeviceCallbackProxy_Connect_001 -* @tc.name: Connect -* @tc.desc: Verify function Connect pointer callback normal -*/ -HWTEST_F(ContinuationDeviceCallbackProxyTest, AppExecFwk_ContinuationDeviceCallbackProxy_Connect_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationDeviceCallbackProxy_Connect_001 start."; - std::shared_ptr callback = std::make_shared(); - std::shared_ptr connectCallback = callback; - sptr continuationDeviceCallbackProxy = new (std::nothrow) - ContinuationDeviceCallbackProxy(connectCallback); - EXPECT_TRUE(continuationDeviceCallbackProxy != nullptr); - const std::string deviceId = "7001005458323933328a592135733900"; - const std::string deviceType = "rk3568"; - continuationDeviceCallbackProxy->Connect(deviceId, deviceType); - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationDeviceCallbackProxy_Connect_001 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationDeviceCallbackProxy_Connect_002 -* @tc.name: Connect -* @tc.desc: Verify function Connect pointer callback empty -*/ -HWTEST_F(ContinuationDeviceCallbackProxyTest, AppExecFwk_ContinuationDeviceCallbackProxy_Connect_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationDeviceCallbackProxy_Connect_002 start."; - std::shared_ptr callback = nullptr; - std::shared_ptr connectCallback = callback; - sptr continuationDeviceCallbackProxy = new (std::nothrow) - ContinuationDeviceCallbackProxy(connectCallback); - EXPECT_FALSE(continuationDeviceCallbackProxy == nullptr); - const std::string deviceId = "7001005458323933328a592135733900"; - const std::string deviceType = "rk3568"; - continuationDeviceCallbackProxy->Connect(deviceId, deviceType); - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationDeviceCallbackProxy_Connect_002 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationDeviceCallbackProxy_Disconnect_001 -* @tc.name: Disconnect -* @tc.desc: Verify function Disconnect pointer callback normal -*/ -HWTEST_F( - ContinuationDeviceCallbackProxyTest, AppExecFwk_ContinuationDeviceCallbackProxy_Disconnect_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationDeviceCallbackProxy_Disconnect_001 start."; - std::shared_ptr callback = std::make_shared(); - std::shared_ptr connectCallback = callback; - sptr continuationDeviceCallbackProxy = new (std::nothrow) - ContinuationDeviceCallbackProxy(connectCallback); - EXPECT_TRUE(continuationDeviceCallbackProxy != nullptr); - const std::string deviceId = "7001005458323933328a592135733900"; - continuationDeviceCallbackProxy->Disconnect(deviceId); - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationDeviceCallbackProxy_Disconnect_001 end."; -} - -/* -* @tc.number: AppExecFwk_ContinuationDeviceCallbackProxy_Disconnect_002 -* @tc.name: Disconnect -* @tc.desc: Verify function Disconnect pointer callback empty -*/ -HWTEST_F( - ContinuationDeviceCallbackProxyTest, AppExecFwk_ContinuationDeviceCallbackProxy_Disconnect_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationDeviceCallbackProxy_Disconnect_002 start."; - std::shared_ptr callback = nullptr; - std::shared_ptr connectCallback = callback; - sptr continuationDeviceCallbackProxy = new (std::nothrow) - ContinuationDeviceCallbackProxy(connectCallback); - EXPECT_FALSE(continuationDeviceCallbackProxy == nullptr); - const std::string deviceId = "7001005458323933328a592135733900"; - continuationDeviceCallbackProxy->Disconnect(deviceId); - GTEST_LOG_(INFO) << "AppExecFwk_ContinuationDeviceCallbackProxy_Disconnect_002 end."; -} -} // namespace AppExecFwk -} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_proxy_test/BUILD.gn b/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_proxy_test/BUILD.gn deleted file mode 100644 index a9f1fa74bc1..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_proxy_test/BUILD.gn +++ /dev/null @@ -1,109 +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("//build/test.gni") -import("//foundation/ability/ability_runtime/ability_runtime.gni") - -module_output_path = "ability_runtime/abilitymgr" - -remote_register_path = "${ability_runtime_path}/frameworks/native/ability/native/continuation/remote_register_service" - -config("coverage_flags") { - if (ability_runtime_feature_coverage) { - cflags = [ "--coverage" ] - ldflags = [ "--coverage" ] - } -} - -config("ability_config") { - visibility = [ ":*" ] - include_dirs = [ - "${ability_runtime_path}/interfaces/kits/native/ability/native", - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/distributed", - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/kits", - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/remote_register_service", - "${ability_runtime_path}/interfaces/kits/native/ability/native/distributed_ability_runtime", - "${ability_runtime_path}/interfaces/kits/native/appkit/app", - "${ability_runtime_innerkits_path}/app_manager/include/appmgr", - "${ability_runtime_innerkits_path}/uri/include", - "${ability_runtime_services_path}/abilitymgr/include", - "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/app", - "${ability_runtime_path}/interfaces/kits/native/appkit/app", - "${form_fwk_path}/interfaces/kits/native/include", - "${ability_runtime_path}/interfaces/kits/native/appkit/app", - "//third_party/node/src", - "${ability_runtime_innerkits_path}/ability_manager/include/continuation", - "${ability_runtime_path}/interfaces/kits/native/appkit/app/task", - "${ability_runtime_napi_path}/inner/napi_common", - "${ability_runtime_napi_path}/featureAbility", - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/kits", - ] - - cflags = [] - if (target_cpu == "arm") { - cflags += [ "-DBINDER_IPC_32BIT" ] - } - defines = [ "AMS_LOG_TAG = \"Ability\"" ] - if (target_cpu == "arm64") { - defines += [ "_ARM64_" ] - } - - if (ability_runtime_graphics) { - include_dirs += [ "${form_fwk_path}/interfaces/inner_api/include" ] - defines += [ "SUPPORT_GRAPHICS" ] - } -} - -ohos_unittest("continuation_register_manager_proxy_test") { - module_out_path = module_output_path - - sources = [ - "${remote_register_path}/continuation_register_manager_proxy.cpp", - "continuation_register_manager_proxy_test.cpp", - ] - - configs = [ - ":ability_config", - ":coverage_flags", - ] - cflags = [] - if (target_cpu == "arm") { - cflags += [ "-DBINDER_IPC_32BIT" ] - } - deps = [ - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", - "${ability_runtime_native_path}/ability/native:abilitykit_native", - "${ability_runtime_native_path}/ability/native:continuation_ipc", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "ability_base:want", - "ability_runtime:ability_manager", - "c_utils:utils", - "common_event_service:cesfwk_innerkits", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "resource_management:global_resmgr", - ] - - if (background_task_mgr_continuous_task_enable) { - external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] - } -} - -group("unittest") { - testonly = true - deps = [ ":continuation_register_manager_proxy_test" ] -} diff --git a/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_proxy_test/continuation_register_manager_proxy_test.cpp b/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_proxy_test/continuation_register_manager_proxy_test.cpp deleted file mode 100644 index ce2b74edcbf..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_proxy_test/continuation_register_manager_proxy_test.cpp +++ /dev/null @@ -1,675 +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. - */ - -#include -#include -#include - -#define private public -#define protected public -#include "continuation_register_manager_proxy.h" -#include "continuation_register_manager.h" -#include "connect_callback_stub.h" -#include "continuation_connector.h" -#undef private -#undef protected -#include "bundle_mgr_interface.h" -#include "ability_manager_interface.h" -#include "iability_controller.h" -#include "pixel_map.h" -#include "ability_info.h" -#include "ability.h" -#include "request_callback.h" - -using namespace testing::ext; -using namespace testing; -using namespace std::chrono; - -namespace OHOS { -namespace AppExecFwk { -class ContinuationRegisterManagerProxyTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); -}; - -void ContinuationRegisterManagerProxyTest::SetUpTestCase(void) -{} - -void ContinuationRegisterManagerProxyTest::TearDownTestCase(void) -{} - -void ContinuationRegisterManagerProxyTest::SetUp(void) -{} - -void ContinuationRegisterManagerProxyTest::TearDown(void) -{} - -class MoclConnectCallback : public RequestCallback { -public: - MoclConnectCallback() {}; - virtual ~MoclConnectCallback() {}; - - void OnResult(int result) override - { - onresult_ = true; - }; - - bool onresult_ = false; -}; - -class MoclRequest : public ContinuationRequest { -public: - MoclRequest() {}; - virtual ~MoclRequest() {}; - - void Execute() override - { - execute_ = true; - }; - - bool execute_ = false; -}; - -class MockRequestCallback : public RequestCallback { -public: - MockRequestCallback() {}; - virtual ~MockRequestCallback() {}; - - virtual void OnResult(int result) - { - onResult_ = true; - }; - - bool onResult_ = false; -}; - -/* - * @tc.number : ContinuationRegisterManagerProxy_Execute_001 - * @tc.name : Register_Execute - * @tc.desc : Verify that the Execute interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_Execute_001, TestSize.Level1) -{ - const std::string bundleName = ""; - ExtraParams parameter; - std::shared_ptr deviceCallback = nullptr; - auto pContinuationRequestRegister = - std::make_shared(bundleName, parameter, deviceCallback); - std::shared_ptr requestCallback = std::make_shared(); - pContinuationRequestRegister->SetContinuationConnector(nullptr); - pContinuationRequestRegister->SetRequestCallback(requestCallback); - EXPECT_TRUE(!requestCallback->onresult_); - pContinuationRequestRegister->Execute(); - EXPECT_TRUE(!requestCallback->onresult_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_Execute_002 - * @tc.name : Register_Execute - * @tc.desc : Verify that the Execute interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_Execute_002, TestSize.Level1) -{ - const std::string bundleName = ""; - ExtraParams parameter; - std::shared_ptr context; - sptr continuatinConnector = new (std::nothrow) ContinuationConnector(context); - std::shared_ptr deviceCallback = nullptr; - auto pContinuationRequestRegister = - std::make_shared(bundleName, parameter, deviceCallback); - pContinuationRequestRegister->SetContinuationConnector(continuatinConnector); - std::shared_ptr requestCallback = std::make_shared(); - pContinuationRequestRegister->SetRequestCallback(nullptr); - EXPECT_TRUE(!requestCallback->onresult_); - pContinuationRequestRegister->Execute(); - EXPECT_TRUE(!requestCallback->onresult_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_Execute_003 - * @tc.name : Register_Execute - * @tc.desc : Verify that the Execute interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_Execute_003, TestSize.Level1) -{ - const std::string bundleName = ""; - ExtraParams parameter; - std::shared_ptr context; - sptr continuatinConnector = new (std::nothrow) ContinuationConnector(context); - std::shared_ptr requestCallback = std::make_shared(); - std::shared_ptr deviceCallback = nullptr; - auto pContinuationRequestRegister = - std::make_shared(bundleName, parameter, deviceCallback); - pContinuationRequestRegister->SetContinuationConnector(continuatinConnector); - pContinuationRequestRegister->SetRequestCallback(requestCallback); - EXPECT_TRUE(!requestCallback->onresult_); - pContinuationRequestRegister->Execute(); - EXPECT_TRUE(requestCallback->onresult_); -} - -/* - * @tc.number : ContinuationRequestUnRegister_Execute_001 - * @tc.name : UnRegister_Execute - * @tc.desc : Verify that the Execute interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRequestUnRegister_Execute_001, TestSize.Level1) -{ - constexpr int32_t token = 0; - auto pContinuationRequestUnRegister = std::make_shared(token); - std::shared_ptr requestCallback = std::make_shared(); - pContinuationRequestUnRegister->SetContinuationConnector(nullptr); - pContinuationRequestUnRegister->SetRequestCallback(requestCallback); - EXPECT_TRUE(!requestCallback->onresult_); - pContinuationRequestUnRegister->Execute(); - EXPECT_TRUE(!requestCallback->onresult_); -} - -/* - * @tc.number : ContinuationRequestUnRegister_Execute_002 - * @tc.name : UnRegister_Execute - * @tc.desc : Verify that the Execute interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRequestUnRegister_Execute_002, TestSize.Level1) -{ - constexpr int32_t token = 0; - std::shared_ptr context; - sptr continuatinConnector = new (std::nothrow) ContinuationConnector(context); - auto pContinuationRequestUnRegister = std::make_shared(token); - pContinuationRequestUnRegister->SetContinuationConnector(continuatinConnector); - std::shared_ptr requestCallback = std::make_shared(); - pContinuationRequestUnRegister->SetRequestCallback(nullptr); - EXPECT_TRUE(!requestCallback->onresult_); - pContinuationRequestUnRegister->Execute(); - EXPECT_TRUE(!requestCallback->onresult_); -} - -/* - * @tc.number : ContinuationRequestUnRegister_Execute_003 - * @tc.name : UnRegister_Execute - * @tc.desc : Verify that the Execute interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRequestUnRegister_Execute_003, TestSize.Level1) -{ - constexpr int32_t token = 0; - std::shared_ptr context; - sptr continuatinConnector = new (std::nothrow) ContinuationConnector(context); - auto pContinuationRequestUnRegister = std::make_shared(token); - std::shared_ptr requestCallback = std::make_shared(); - pContinuationRequestUnRegister->SetContinuationConnector(continuatinConnector); - pContinuationRequestUnRegister->SetRequestCallback(requestCallback); - EXPECT_TRUE(!requestCallback->onresult_); - pContinuationRequestUnRegister->Execute(); - EXPECT_TRUE(requestCallback->onresult_); -} - -/* - * @tc.number : ContinuationRequestUpdateConnectStatus_Execute_001 - * @tc.name : UpdateConnectStatus_Execute - * @tc.desc : Verify that the Execute interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRequestUpdateConnectStatus_Execute_001, TestSize.Level1) -{ - constexpr int32_t token = 0; - const std::string deviceId = ""; - constexpr int32_t status = 0; - auto pContinuationRequestUpdateConnectStatus = - std::make_shared(token, deviceId, status); - pContinuationRequestUpdateConnectStatus->SetContinuationConnector(nullptr); - std::shared_ptr requestCallback = std::make_shared(); - pContinuationRequestUpdateConnectStatus->SetRequestCallback(requestCallback); - EXPECT_TRUE(!requestCallback->onresult_); - pContinuationRequestUpdateConnectStatus->Execute(); - EXPECT_TRUE(!requestCallback->onresult_); -} - -/* - * @tc.number : ContinuationRequestUpdateConnectStatus_Execute_002 - * @tc.name : UpdateConnectStatus_Execute - * @tc.desc : Verify that the Execute interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRequestUpdateConnectStatus_Execute_002, TestSize.Level1) -{ - constexpr int32_t token = 0; - const std::string deviceId = ""; - constexpr int32_t status = 0; - std::shared_ptr context; - sptr continuatinConnector = new (std::nothrow) ContinuationConnector(context); - auto pContinuationRequestUpdateConnectStatus = - std::make_shared(token, deviceId, status); - pContinuationRequestUpdateConnectStatus->SetContinuationConnector(continuatinConnector); - std::shared_ptr requestCallback = std::make_shared(); - pContinuationRequestUpdateConnectStatus->SetRequestCallback(nullptr); - EXPECT_TRUE(!requestCallback->onresult_); - pContinuationRequestUpdateConnectStatus->Execute(); - EXPECT_TRUE(!requestCallback->onresult_); -} - -/* - * @tc.number : ContinuationRequestUpdateConnectStatus_Execute_003 - * @tc.name : UpdateConnectStatus_Execute - * @tc.desc : Verify that the Execute interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRequestUpdateConnectStatus_Execute_003, TestSize.Level1) -{ - constexpr int32_t token = 0; - const std::string deviceId = ""; - constexpr int32_t status = 0; - std::shared_ptr context; - sptr continuatinConnector = new (std::nothrow) ContinuationConnector(context); - auto pContinuationRequestUpdateConnectStatus = - std::make_shared(token, deviceId, status); - std::shared_ptr requestCallback = std::make_shared(); - pContinuationRequestUpdateConnectStatus->SetContinuationConnector(continuatinConnector); - pContinuationRequestUpdateConnectStatus->SetRequestCallback(requestCallback); - EXPECT_TRUE(!requestCallback->onresult_); - pContinuationRequestUpdateConnectStatus->Execute(); - EXPECT_TRUE(requestCallback->onresult_); -} - -/* - * @tc.number : ContinuationRequestShowDeviceList_Execute_001 - * @tc.name : ShowDeviceList_Execute - * @tc.desc : Verify that the Execute interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRequestShowDeviceList_Execute_001, TestSize.Level1) -{ - constexpr int32_t token = 0; - ExtraParams parameter; - auto pContinuationRequestShowDeviceList = std::make_shared(token, parameter); - std::shared_ptr requestCallback = std::make_shared(); - pContinuationRequestShowDeviceList->SetContinuationConnector(nullptr); - pContinuationRequestShowDeviceList->SetRequestCallback(requestCallback); - EXPECT_TRUE(!requestCallback->onresult_); - pContinuationRequestShowDeviceList->Execute(); - EXPECT_TRUE(!requestCallback->onresult_); -} - -/* - * @tc.number : ContinuationRequestShowDeviceList_Execute_002 - * @tc.name : ShowDeviceList_Execute - * @tc.desc : Verify that the Execute interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRequestShowDeviceList_Execute_002, TestSize.Level1) -{ - constexpr int32_t token = 0; - ExtraParams parameter; - std::shared_ptr context; - sptr continuatinConnector = new (std::nothrow) ContinuationConnector(context); - std::shared_ptr requestCallback = std::make_shared(); - auto pContinuationRequestShowDeviceList = - std::make_shared(token, parameter); - pContinuationRequestShowDeviceList->SetContinuationConnector(continuatinConnector); - pContinuationRequestShowDeviceList->SetRequestCallback(nullptr); - EXPECT_TRUE(!requestCallback->onresult_); - pContinuationRequestShowDeviceList->Execute(); - EXPECT_TRUE(!requestCallback->onresult_); -} - -/* - * @tc.number : ContinuationRequestShowDeviceList_Execute_003 - * @tc.name : ShowDeviceList_Execute - * @tc.desc : Verify that the Execute interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRequestShowDeviceList_Execute_003, TestSize.Level1) -{ - constexpr int32_t token = 0; - ExtraParams parameter; - std::shared_ptr context; - sptr continuatinConnector = new (std::nothrow) ContinuationConnector(context); - auto pContinuationRequestShowDeviceList = - std::make_shared(token, parameter); - std::shared_ptr requestCallback = std::make_shared(); - pContinuationRequestShowDeviceList->SetContinuationConnector(continuatinConnector); - pContinuationRequestShowDeviceList->SetRequestCallback(requestCallback); - EXPECT_TRUE(!requestCallback->onresult_); - pContinuationRequestShowDeviceList->Execute(); - EXPECT_TRUE(requestCallback->onresult_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_Constructor_001 - * @tc.name : Constructor - * @tc.desc : Verify that the Constructor is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_Constructor_001, TestSize.Level1) -{ - std::weak_ptr context ; - auto continuatinConnector = std::make_shared(context); - std::shared_ptr applicationContext = continuatinConnector->applicationContext_.lock(); - EXPECT_TRUE(applicationContext == nullptr); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_Register_001 - * @tc.name : Register - * @tc.desc : Verify that the Register interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_Register_001, TestSize.Level1) -{ - const std::string bundleName = ""; - ExtraParams parameter; - std::shared_ptr deviceCallback; - std::shared_ptr requestCallback = std::make_shared(); - std::shared_ptr context; - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->context_.lock() = nullptr; - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManagerProxy->Register(bundleName, parameter, deviceCallback, requestCallback); - EXPECT_FALSE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_Register_002 - * @tc.name : Register - * @tc.desc : Verify that the Register interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_Register_002, TestSize.Level1) -{ - const std::string bundleName = ""; - ExtraParams parameter; - std::shared_ptr deviceCallback; - std::shared_ptr requestCallback = std::make_shared(); - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->context_ = context; - continuationRegisterManagerProxy->applicationContext_.lock() = nullptr; - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManagerProxy->Register(bundleName, parameter, deviceCallback, requestCallback); - EXPECT_FALSE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_Register_003 - * @tc.name : Register - * @tc.desc : Verify that the Register interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_Register_003, TestSize.Level1) -{ - const std::string bundleName = ""; - ExtraParams parameter; - std::shared_ptr deviceCallback; - std::shared_ptr requestCallback = std::make_shared(); - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->context_ = context; - continuationRegisterManagerProxy->applicationContext_ = context; - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManagerProxy->Register(bundleName, parameter, deviceCallback, requestCallback); - EXPECT_TRUE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_Unregister_001 - * @tc.name : Unregister - * @tc.desc : Verify that the Unregister interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_Unregister_001, TestSize.Level1) -{ - constexpr int32_t token = 0; - std::shared_ptr requestCallback = std::make_shared(); - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - std::weak_ptr applicationContext; - continuationRegisterManagerProxy->applicationContext_ = applicationContext; - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManagerProxy->Unregister(token, requestCallback); - EXPECT_FALSE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_Unregister_002 - * @tc.name : Unregister - * @tc.desc : Verify that the Unregister interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_Unregister_002, TestSize.Level1) -{ - constexpr int32_t token = 0; - std::shared_ptr requestCallback = std::make_shared(); - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->applicationContext_ = context; - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManagerProxy->Unregister(token, requestCallback); - EXPECT_TRUE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_UpdateConnect_001 - * @tc.name : UpdateConnectStatus - * @tc.desc : Verify that the UpdateConnectStatus interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_UpdateConnect_001, TestSize.Level1) -{ - constexpr int32_t token = 0; - const std::string deviceId = ""; - constexpr int32_t status = 0; - std::shared_ptr requestCallback = std::make_shared(); - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - std::weak_ptr applicationContext; - continuationRegisterManagerProxy->applicationContext_ = applicationContext; - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManagerProxy->UpdateConnectStatus(token, deviceId, status, requestCallback); - EXPECT_FALSE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_UpdateConnect_002 - * @tc.name : UpdateConnectStatus - * @tc.desc : Verify that the UpdateConnectStatus interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_UpdateConnect_002, TestSize.Level1) -{ - constexpr int32_t token = 0; - const std::string deviceId = ""; - constexpr int32_t status = 0; - std::shared_ptr requestCallback = std::make_shared(); - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->applicationContext_ = context; - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManagerProxy->UpdateConnectStatus(token, deviceId, status, requestCallback); - EXPECT_TRUE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_ShowDeviceList_001 - * @tc.name : ShowDeviceList - * @tc.desc : Verify that the ShowDeviceList interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_ShowDeviceList_001, TestSize.Level1) -{ - constexpr int32_t token = 0; - ExtraParams parameter; - std::shared_ptr requestCallback = std::make_shared(); - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - std::weak_ptr applicationContext; - continuationRegisterManagerProxy->applicationContext_ = applicationContext; - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManagerProxy->ShowDeviceList(token, parameter, requestCallback); - EXPECT_FALSE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_ShowDeviceList_002 - * @tc.name : ShowDeviceList - * @tc.desc : Verify that the ShowDeviceList interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_ShowDeviceList_002, TestSize.Level1) -{ - constexpr int32_t token = 0; - ExtraParams parameter; - std::shared_ptr requestCallback = std::make_shared(); - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->applicationContext_ = context; - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManagerProxy->ShowDeviceList(token, parameter, requestCallback); - EXPECT_TRUE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_Disconnect_001 - * @tc.name : Disconnect - * @tc.desc : Verify that the Disconnect interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_Disconnect_001, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->continuatinConnector_ = nullptr; - - continuationRegisterManagerProxy->Disconnect(); - EXPECT_TRUE(true); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_Disconnect_002 - * @tc.name : Disconnect - * @tc.desc : Verify that the Disconnect interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_Disconnect_002, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - - EXPECT_FALSE(continuationRegisterManagerProxy->continuatinConnector_->isConnected_.load()); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(false); - - continuationRegisterManagerProxy->Disconnect(); - EXPECT_FALSE(continuationRegisterManagerProxy->continuatinConnector_->isConnected_.load()); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_Disconnect_003 - * @tc.name : Disconnect - * @tc.desc : Verify that the Disconnect interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_Disconnect_003, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - EXPECT_TRUE(continuationRegisterManagerProxy->continuatinConnector_ != nullptr); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - EXPECT_TRUE(continuationRegisterManagerProxy->continuatinConnector_->isConnected_.load()); - - continuationRegisterManagerProxy->Disconnect(); - EXPECT_FALSE(continuationRegisterManagerProxy->continuatinConnector_->isConnected_.load()); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_SendRequest_001 - * @tc.name : SendRequest - * @tc.desc : Verify that the SendRequest interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_SendRequest_001, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - std::shared_ptr request = std::make_shared(); - continuationRegisterManagerProxy->SendRequest(context, nullptr); - - EXPECT_TRUE(!request->execute_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_SendRequest_002 - * @tc.name : SendRequest - * @tc.desc : Verify that the SendRequest interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_SendRequest_002, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - std::shared_ptr request = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->continuatinConnector_ = nullptr; - EXPECT_TRUE(continuationRegisterManagerProxy->continuatinConnector_ == nullptr); - continuationRegisterManagerProxy->SendRequest(context, request); - - EXPECT_TRUE(continuationRegisterManagerProxy->continuatinConnector_ != nullptr); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_SendRequest_003 - * @tc.name : SendRequest - * @tc.desc : Verify that the SendRequest interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_SendRequest_003, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - std::shared_ptr request = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - EXPECT_TRUE(continuationRegisterManagerProxy->continuatinConnector_ != nullptr); - EXPECT_FALSE(continuationRegisterManagerProxy->continuatinConnector_->isConnected_.load()); - continuationRegisterManagerProxy->SendRequest(context, request); - - EXPECT_TRUE(!request->execute_); -} - -/* - * @tc.number : ContinuationRegisterManagerProxy_SendRequest_004 - * @tc.name : SendRequest - * @tc.desc : Verify that the SendRequest interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerProxyTest, ContinuationRegisterManagerProxy_SendRequest_004, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - std::shared_ptr request = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - EXPECT_TRUE(continuationRegisterManagerProxy->continuatinConnector_ != nullptr); - EXPECT_FALSE(continuationRegisterManagerProxy->continuatinConnector_->isConnected_.load()); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - EXPECT_TRUE(continuationRegisterManagerProxy->continuatinConnector_->isConnected_.load()); - EXPECT_TRUE(!request->execute_); - continuationRegisterManagerProxy->SendRequest(context, request); - EXPECT_TRUE(request->execute_); -} -} // namespace AppExecFwk -} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_test/BUILD.gn b/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_test/BUILD.gn deleted file mode 100644 index 826ed0c41b2..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_test/BUILD.gn +++ /dev/null @@ -1,109 +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("//build/test.gni") -import("//foundation/ability/ability_runtime/ability_runtime.gni") - -module_output_path = "ability_runtime/abilitymgr" - -remote_register_path = "${ability_runtime_path}/frameworks/native/ability/native/continuation/remote_register_service" - -config("coverage_flags") { - if (ability_runtime_feature_coverage) { - cflags = [ "--coverage" ] - ldflags = [ "--coverage" ] - } -} - -config("ability_config") { - visibility = [ ":*" ] - include_dirs = [ - "${ability_runtime_path}/interfaces/kits/native/ability/native", - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/distributed", - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/kits", - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/remote_register_service", - "${ability_runtime_path}/interfaces/kits/native/ability/native/distributed_ability_runtime", - "${ability_runtime_path}/interfaces/kits/native/appkit/app", - "${ability_runtime_innerkits_path}/app_manager/include/appmgr", - "${ability_runtime_innerkits_path}/uri/include", - "${ability_runtime_services_path}/abilitymgr/include", - "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/app", - "${ability_runtime_path}/interfaces/kits/native/appkit/app", - "${form_fwk_path}/interfaces/kits/native/include", - "${ability_runtime_path}/interfaces/kits/native/appkit/app", - "//third_party/node/src", - "${ability_runtime_innerkits_path}/ability_manager/include/continuation", - "${ability_runtime_path}/interfaces/kits/native/appkit/app/task", - "${ability_runtime_napi_path}/inner/napi_common", - "${ability_runtime_napi_path}/featureAbility", - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/kits", - ] - - cflags = [] - if (target_cpu == "arm") { - cflags += [ "-DBINDER_IPC_32BIT" ] - } - defines = [ "AMS_LOG_TAG = \"Ability\"" ] - if (target_cpu == "arm64") { - defines += [ "_ARM64_" ] - } - - if (ability_runtime_graphics) { - include_dirs += [ "${form_fwk_path}/interfaces/inner_api/include" ] - defines += [ "SUPPORT_GRAPHICS" ] - } -} - -ohos_unittest("continuation_register_manager_test") { - module_out_path = module_output_path - - sources = [ - "${remote_register_path}/continuation_register_manager.cpp", - "continuation_register_manager_test.cpp", - ] - - configs = [ - ":ability_config", - ":coverage_flags", - ] - cflags = [] - if (target_cpu == "arm") { - cflags += [ "-DBINDER_IPC_32BIT" ] - } - deps = [ - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", - "${ability_runtime_native_path}/ability/native:abilitykit_native", - "${ability_runtime_native_path}/ability/native:continuation_ipc", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "ability_base:want", - "ability_runtime:ability_manager", - "c_utils:utils", - "common_event_service:cesfwk_innerkits", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "resource_management:global_resmgr", - ] - - if (background_task_mgr_continuous_task_enable) { - external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] - } -} - -group("unittest") { - testonly = true - deps = [ ":continuation_register_manager_test" ] -} diff --git a/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_test/continuation_register_manager_test.cpp b/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_test/continuation_register_manager_test.cpp deleted file mode 100644 index 309573d9327..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/continuation_register_manager_test/continuation_register_manager_test.cpp +++ /dev/null @@ -1,339 +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. - */ - -#include -#include -#include - -#define private public -#define protected public -#include "continuation_register_manager_proxy.h" -#include "continuation_register_manager.h" -#include "connect_callback_stub.h" -#include "continuation_connector.h" -#undef private -#undef protected -#include "bundle_mgr_interface.h" -#include "ability_manager_interface.h" -#include "iability_controller.h" -#include "pixel_map.h" -#include "ability_info.h" -#include "ability.h" -#include "request_callback.h" - -using namespace testing::ext; -using namespace testing; -using namespace std::chrono; - -namespace OHOS { -namespace AppExecFwk { -class ContinuationRegisterManagerTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); -}; - -void ContinuationRegisterManagerTest::SetUpTestCase(void) -{} -void ContinuationRegisterManagerTest::TearDownTestCase(void) -{} - -void ContinuationRegisterManagerTest::SetUp(void) -{} - -void ContinuationRegisterManagerTest::TearDown(void) -{} - -class MockRequestCallback : public RequestCallback { -public: - MockRequestCallback() {}; - virtual ~MockRequestCallback() {}; - - virtual void OnResult(int result) - { - onResult_ = true; - }; - - bool onResult_ = false; -}; - -/* - * @tc.number : ContinuationRegisterManager_Register_001 - * @tc.name : Register - * @tc.desc : Verify that the Register interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerTest, ContinuationRegisterManager_Register_001, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManager = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - const std::string bundleName = ""; - ExtraParams parameter; - std::shared_ptr deviceCallback; - std::shared_ptr requestCallback = std::make_shared(); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->context_ = context; - continuationRegisterManagerProxy->applicationContext_ = context; - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - continuationRegisterManager->Init(continuationRegisterManagerProxy); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManager->Register(bundleName, parameter, deviceCallback, requestCallback); - EXPECT_TRUE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManager_Register_002 - * @tc.name : Register - * @tc.desc : Verify that the Register interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerTest, ContinuationRegisterManager_Register_002, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManager = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - const std::string bundleName = ""; - ExtraParams parameter; - std::shared_ptr deviceCallback; - std::shared_ptr requestCallback = std::make_shared(); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->context_ = context; - continuationRegisterManagerProxy->applicationContext_ = context; - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - continuationRegisterManager->Init(nullptr); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManager->Register(bundleName, parameter, deviceCallback, requestCallback); - EXPECT_FALSE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManager_Unregister_001 - * @tc.name : Unregister - * @tc.desc : Verify that the Unregister interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerTest, ContinuationRegisterManager_Unregister_001, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManager = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - constexpr int32_t token = 0; - std::shared_ptr requestCallback = std::make_shared(); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->context_ = context; - continuationRegisterManagerProxy->applicationContext_ = context; - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - continuationRegisterManager->Init(continuationRegisterManagerProxy); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManager->Unregister(token, requestCallback); - EXPECT_TRUE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManager_Unregister_002 - * @tc.name : Unregister - * @tc.desc : Verify that the Unregister interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerTest, ContinuationRegisterManager_Unregister_002, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManager = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - constexpr int32_t token = 0; - std::shared_ptr requestCallback = std::make_shared(); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->context_ = context; - continuationRegisterManagerProxy->applicationContext_ = context; - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - continuationRegisterManager->Init(nullptr); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManager->Unregister(token, requestCallback); - EXPECT_FALSE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManager_UpdateConnectStatus_001 - * @tc.name : UpdateConnectStatus - * @tc.desc : Verify that the UpdateConnectStatus interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerTest, ContinuationRegisterManager_UpdateConnectStatus_001, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManager = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - constexpr int32_t token = 0; - const std::string deviceId = ""; - constexpr int32_t status = 0; - std::shared_ptr requestCallback = std::make_shared(); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->context_ = context; - continuationRegisterManagerProxy->applicationContext_ = context; - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - continuationRegisterManager->Init(continuationRegisterManagerProxy); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManager->UpdateConnectStatus(token, deviceId, status, requestCallback); - EXPECT_TRUE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManager_UpdateConnectStatus_002 - * @tc.name : UpdateConnectStatus - * @tc.desc : Verify that the UpdateConnectStatus interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerTest, ContinuationRegisterManager_UpdateConnectStatus_002, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManager = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - constexpr int32_t token = 0; - const std::string deviceId = ""; - constexpr int32_t status = 0; - std::shared_ptr requestCallback = std::make_shared(); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->context_ = context; - continuationRegisterManagerProxy->applicationContext_ = context; - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - continuationRegisterManager->Init(nullptr); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManager->UpdateConnectStatus(token, deviceId, status, requestCallback); - EXPECT_FALSE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManager_ShowDeviceList_001 - * @tc.name : ShowDeviceList - * @tc.desc : Verify that the ShowDeviceList interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerTest, ContinuationRegisterManager_ShowDeviceList_001, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManager = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - constexpr int32_t token = 0; - ExtraParams parameter; - std::shared_ptr requestCallback = std::make_shared(); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->context_ = context; - continuationRegisterManagerProxy->applicationContext_ = context; - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - continuationRegisterManager->Init(continuationRegisterManagerProxy); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManager->ShowDeviceList(token, parameter, requestCallback); - EXPECT_TRUE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManager_ShowDeviceList_002 - * @tc.name : ShowDeviceList - * @tc.desc : Verify that the ShowDeviceList interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerTest, ContinuationRegisterManager_ShowDeviceList_002, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManager = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - constexpr int32_t token = 0; - ExtraParams parameter; - std::shared_ptr requestCallback = std::make_shared(); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManagerProxy->context_ = context; - continuationRegisterManagerProxy->applicationContext_ = context; - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - continuationRegisterManager->Init(nullptr); - - EXPECT_FALSE(requestCallback->onResult_); - continuationRegisterManager->ShowDeviceList(token, parameter, requestCallback); - EXPECT_FALSE(requestCallback->onResult_); -} - -/* - * @tc.number : ContinuationRegisterManager_Disconnect_001 - * @tc.name : Disconnect - * @tc.desc : Verify that the Disconnect interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerTest, ContinuationRegisterManager_Disconnect_001, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManager = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - continuationRegisterManager->Init(continuationRegisterManagerProxy); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(true); - - EXPECT_TRUE(continuationRegisterManagerProxy->continuatinConnector_->isConnected_.load()); - continuationRegisterManager->Disconnect(); - EXPECT_FALSE(continuationRegisterManagerProxy->continuatinConnector_->isConnected_.load()); -} - -/* - * @tc.number : ContinuationRegisterManager_Disconnect_002 - * @tc.name : Disconnect - * @tc.desc : Verify that the Disconnect interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerTest, ContinuationRegisterManager_Disconnect_002, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManager = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->continuatinConnector_ = nullptr; - continuationRegisterManager->Init(continuationRegisterManagerProxy); - - continuationRegisterManager->Disconnect(); - EXPECT_TRUE(true); -} - -/* - * @tc.number : ContinuationRegisterManager_Disconnect_003 - * @tc.name : Disconnect - * @tc.desc : Verify that the Disconnect interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerTest, ContinuationRegisterManager_Disconnect_003, TestSize.Level1) -{ - std::shared_ptr context = std::make_shared(); - auto continuationRegisterManager = std::make_shared(); - auto continuationRegisterManagerProxy = std::make_shared(context); - continuationRegisterManagerProxy->continuatinConnector_ = new (std::nothrow) ContinuationConnector(context); - - EXPECT_FALSE(continuationRegisterManagerProxy->continuatinConnector_->isConnected_.load()); - continuationRegisterManagerProxy->continuatinConnector_->isConnected_.store(false); - continuationRegisterManager->Init(continuationRegisterManagerProxy); - - continuationRegisterManager->Disconnect(); - EXPECT_FALSE(continuationRegisterManagerProxy->continuatinConnector_->isConnected_.load()); -} - -/* - * @tc.number : ContinuationRegisterManager_Disconnect_004 - * @tc.name : Disconnect - * @tc.desc : Verify that the Disconnect interface is called normally - */ -HWTEST_F(ContinuationRegisterManagerTest, ContinuationRegisterManager_Disconnect_004, TestSize.Level1) -{ - auto continuationRegisterManager = std::make_shared(); - std::shared_ptr continuationRegisterManagerProxy; - continuationRegisterManager->Init(continuationRegisterManagerProxy); - - continuationRegisterManager->Disconnect(); - EXPECT_TRUE(true); -} -} // namespace AppExecFwk -} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/continuation_test/remote_register_service_test/remote_register_service_proxy_test/BUILD.gn b/test/unittest/continuation_test/remote_register_service_test/remote_register_service_proxy_test/BUILD.gn deleted file mode 100644 index 5a926a687a5..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/remote_register_service_proxy_test/BUILD.gn +++ /dev/null @@ -1,68 +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("//build/test.gni") -import("//foundation/ability/ability_runtime/ability_runtime.gni") - -module_output_path = "ability_runtime/abilitymgr" - -remote_register_path = "${ability_runtime_path}/frameworks/native/ability/native/continuation/remote_register_service" - -config("coverage_flags") { - if (ability_runtime_feature_coverage) { - cflags = [ "--coverage" ] - ldflags = [ "--coverage" ] - } -} - -ohos_unittest("remote_register_service_proxy_test") { - module_out_path = module_output_path - - include_dirs = [ - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/remote_register_service", - "${ability_runtime_innerkits_path}/ability_manager/include/continuation", - "${ability_runtime_services_path}/common/include", - ] - - sources = [ - "${remote_register_path}/remote_register_service_proxy.cpp", - "remote_register_service_proxy_test.cpp", - ] - - configs = [ ":coverage_flags" ] - cflags = [] - if (target_cpu == "arm") { - cflags += [ "-DBINDER_IPC_32BIT" ] - } - deps = [ - "${ability_runtime_native_path}/ability/native:continuation_ipc", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "ability_base:want", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - ] - - if (background_task_mgr_continuous_task_enable) { - external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] - } -} - -group("unittest") { - testonly = true - deps = [ ":remote_register_service_proxy_test" ] -} diff --git a/test/unittest/continuation_test/remote_register_service_test/remote_register_service_proxy_test/remote_register_service_proxy_test.cpp b/test/unittest/continuation_test/remote_register_service_test/remote_register_service_proxy_test/remote_register_service_proxy_test.cpp deleted file mode 100644 index 029c424eb43..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/remote_register_service_proxy_test/remote_register_service_proxy_test.cpp +++ /dev/null @@ -1,540 +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. - */ - -#include -#include -#include - -#define private public -#define protected public -#include "remote_register_service_proxy.h" -#include "remote_register_service_stub.h" -#include "connect_callback_stub.h" -#undef private -#undef protected - -using namespace testing::ext; -using namespace testing; -using namespace std::chrono; - -namespace OHOS { -namespace AppExecFwk { -class RemoteRegisterServiceProxyTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - -protected: - -}; - -void RemoteRegisterServiceProxyTest::SetUpTestCase(void) -{} -void RemoteRegisterServiceProxyTest::TearDownTestCase(void) -{} - -void RemoteRegisterServiceProxyTest::SetUp(void) -{} - -void RemoteRegisterServiceProxyTest::TearDown(void) -{} - -class MockRegisterService : public RemoteRegisterServiceStub { -public: - MockRegisterService() {}; - ~MockRegisterService() {}; - - int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override - { - GTEST_LOG_(INFO) << "MockRegisterService::SendRequest called. return value " << returnCode_; - reply.WriteInt32(ERR_NONE); - return returnCode_; - } - - int Register(const std::string &bundleName, const sptr &token, const ExtraParams &extras, - const sptr &callback) override - { - return 0; - }; - bool Unregister(int registerToken) override - { - return true; - }; - bool UpdateConnectStatus(int registerToken, const std::string &deviceId, int status) override - { - return true; - }; - bool ShowDeviceList(int registerToken, const ExtraParams &extras) override - { - return true; - }; - - int32_t returnCode_ = ERR_NONE; -}; - -class MoclConnectCallback : public ConnectCallbackStub { -public: - MoclConnectCallback() {}; - ~MoclConnectCallback() {}; - - sptr AsObject() override - { - if (!asObject_) { - return nullptr; - } - - return this; - }; - - virtual void Connect(const string &deviceId, const string &deviceType) override {}; - virtual void Disconnect(const string &deviceId) override {}; - - bool asObject_ = true; -}; - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: Register - * FunctionPoints: The parameter of function Register. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Register parameter bundleName token extras callback - */ -HWTEST_F(RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_Register_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_001 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - std::string bundleName = "ABC"; - sptr token = object; - ExtraParams extras = {}; - sptr callback = new (std::nothrow) MoclConnectCallback(); - EXPECT_EQ(testProxy->Register(bundleName, token, extras, callback), ERR_NONE); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_001 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: Register - * FunctionPoints: The parameter of function Register. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Register parameter bundlename empty - */ -HWTEST_F(RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_Register_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_002 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - std::string bundleName = ""; - sptr token = object; - ExtraParams extras = {}; - sptr callback = new (std::nothrow) MoclConnectCallback(); - EXPECT_EQ(testProxy->Register(bundleName, token, extras, callback), ERR_INVALID_DATA); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_002 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: Register - * FunctionPoints: The parameter of function Register. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Register Object is empty - */ -HWTEST_F(RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_Register_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_003 start."; - sptr object = nullptr; - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - std::string bundleName = "ABC"; - sptr token = new (std::nothrow) MockRegisterService(); - ExtraParams extras = {}; - sptr callback = new (std::nothrow) MoclConnectCallback(); - EXPECT_EQ(testProxy->Register(bundleName, token, extras, callback), ERR_NULL_OBJECT); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_003 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: Register - * FunctionPoints: The parameter of function Register. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Register parameter callback->AsObject is empty - */ -HWTEST_F(RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_Register_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_004 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - std::string bundleName = "ABC"; - sptr token = object; - ExtraParams extras = {}; - sptr callback = new (std::nothrow) MoclConnectCallback(); - callback->asObject_ = false; - EXPECT_EQ(testProxy->Register(bundleName, token, extras, callback), IPC_INVOKER_WRITE_TRANS_ERR); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_004 end."; -} -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: Register - * FunctionPoints: The parameter of function Register. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Register ipc error - */ -HWTEST_F(RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_Register_005, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_005 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - std::string bundleName = "ABC"; - sptr token = object; - ExtraParams extras = {}; - sptr callback = new (std::nothrow) MoclConnectCallback(); - object->returnCode_ = ERR_NONE - 1; - EXPECT_EQ(testProxy->Register(bundleName, token, extras, callback), IPC_INVOKER_TRANSLATE_ERR); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_005 end."; -} - - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: Register - * FunctionPoints: The parameter of function Register. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Register parameter token is empty - */ -HWTEST_F(RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_Register_006, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_006 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - std::string bundleName = "abc"; - sptr token = nullptr; - ExtraParams extras = {}; - sptr callback = new (std::nothrow) MoclConnectCallback(); - EXPECT_EQ(testProxy->Register(bundleName, token, extras, callback), ERR_INVALID_DATA); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_006 end."; -} - - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: Register - * FunctionPoints: The parameter of function Register. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Register parameter callback is empty - */ -HWTEST_F(RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_Register_007, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_007 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - std::string bundleName = "abc"; - sptr token = object; - ExtraParams extras = {}; - sptr callback = nullptr; - EXPECT_EQ(testProxy->Register(bundleName, token, extras, callback), ERR_INVALID_DATA); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Register_007 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: Unregister - * FunctionPoints: The parameter of function Unregister. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Unregister parameter registerToken is 0 - */ -HWTEST_F(RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_Unregister_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Unregister_001 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - constexpr int32_t registerToken = 0; - EXPECT_TRUE(testProxy->Unregister(registerToken)); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Unregister_001 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: Unregister - * FunctionPoints: The parameter of function Unregister. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Unregister parameter object is nullptr - */ -HWTEST_F(RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_Unregister_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Unregister_002 start."; - sptr object = nullptr; - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - constexpr int32_t registerToken = 0; - EXPECT_FALSE(testProxy->Unregister(registerToken)); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Unregister_002 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: Unregister - * FunctionPoints: The parameter of function Unregister. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Unregister parameter registerToken is 100 - */ -HWTEST_F(RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_Unregister_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Unregister_003 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - constexpr int32_t registerToken = 100; - EXPECT_TRUE(testProxy->Unregister(registerToken)); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Unregister_003 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: Unregister - * FunctionPoints: The parameter of function Unregister. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Unregister ipc error - */ -HWTEST_F(RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_Unregister_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Unregister_004 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - constexpr int32_t registerToken = 0; - object->returnCode_ = ERR_NONE - 1; - EXPECT_FALSE(testProxy->Unregister(registerToken)); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_Unregister_004 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: UpdateConnectStatus - * FunctionPoints: The parameter of function UpdateConnectStatus. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function UpdateConnectStatus parameter registerToken status deviceId - */ -HWTEST_F( - RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_001 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - constexpr int32_t registerToken = 0; - constexpr int32_t status = 0; - const std::string deviceId = "7001005458323933328a592135733900"; - EXPECT_TRUE(testProxy->UpdateConnectStatus(registerToken, deviceId, status)); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_001 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: UpdateConnectStatus - * FunctionPoints: The parameter of function UpdateConnectStatus. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function UpdateConnectStatus object is nullptr - */ -HWTEST_F( - RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_002 start."; - sptr object = nullptr; - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - constexpr int32_t registerToken = 0; - constexpr int32_t status = 0; - const std::string deviceId = "7001005458323933328a592135733900"; - EXPECT_FALSE(testProxy->UpdateConnectStatus(registerToken, deviceId, status)); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_002 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: UpdateConnectStatus - * FunctionPoints: The parameter of function UpdateConnectStatus. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function UpdateConnectStatus parameter registerToken is 100 status is 1 - */ -HWTEST_F( - RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_003 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - constexpr int32_t registerToken = 100; - constexpr int32_t status = 1; - const std::string deviceId = "7001005458323933328a592135733900"; - EXPECT_TRUE(testProxy->UpdateConnectStatus(registerToken, deviceId, status)); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_003 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: UpdateConnectStatus - * FunctionPoints: The parameter of function UpdateConnectStatus. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function UpdateConnectStatus ipc error - */ -HWTEST_F( - RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_004 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - constexpr int32_t registerToken = 0; - constexpr int32_t status = 0; - const std::string deviceId = "7001005458323933328a592135733900"; - object->returnCode_ = ERR_NONE - 1; - EXPECT_FALSE(testProxy->UpdateConnectStatus(registerToken, deviceId, status)); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_004 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: UpdateConnectStatus - * FunctionPoints: The parameter of function UpdateConnectStatus. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function UpdateConnectStatus registerToken is 100 ipc error - */ -HWTEST_F( - RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_005, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_005 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - constexpr int32_t registerToken = 100; - constexpr int32_t status = 1; - const std::string deviceId = "7001005458323933328a592135733900"; - object->returnCode_ = ERR_NONE - 1; - EXPECT_FALSE(testProxy->UpdateConnectStatus(registerToken, deviceId, status)); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_UpdateConnectStatus_005 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: ShowDeviceList - * FunctionPoints: The parameter of function ShowDeviceList. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function ShowDeviceList registerToken extras - */ -HWTEST_F( - RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_ShowDeviceList_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_ShowDeviceList_001 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - constexpr int32_t registerToken = 0; - ExtraParams extras = {}; - EXPECT_TRUE(testProxy->ShowDeviceList(registerToken, extras)); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_ShowDeviceList_001 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: ShowDeviceList - * FunctionPoints: The parameter of function ShowDeviceList. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function ShowDeviceList object is nullptr - */ -HWTEST_F( - RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_ShowDeviceList_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_ShowDeviceList_002 start."; - sptr object = nullptr; - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - constexpr int32_t registerToken = 0; - ExtraParams extras = {}; - EXPECT_FALSE(testProxy->ShowDeviceList(registerToken, extras)); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_ShowDeviceList_002 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: ShowDeviceList - * FunctionPoints: The parameter of function ShowDeviceList. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Register parameter registerToken is 100 - */ -HWTEST_F( - RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_ShowDeviceList_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_ShowDeviceList_003 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - constexpr int32_t registerToken = 100; - ExtraParams extras = {}; - EXPECT_TRUE(testProxy->ShowDeviceList(registerToken, extras)); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_ShowDeviceList_003 end."; -} - -/* - * Feature: AbilityRuntime - * Function: RemoteRegisterServiceProxy - * SubFunction: ShowDeviceList - * FunctionPoints: The parameter of function ShowDeviceList. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function Register ipc error - */ -HWTEST_F( - RemoteRegisterServiceProxyTest, AppExecFwk_RemoteRegisterServiceProxy_ShowDeviceList_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_ShowDeviceList_004 start."; - sptr object = new (std::nothrow) MockRegisterService(); - sptr testProxy = new (std::nothrow) RemoteRegisterServiceProxy(object); - EXPECT_TRUE(testProxy != nullptr); - constexpr int32_t registerToken = 0; - ExtraParams extras = {}; - object->returnCode_ = ERR_NONE - 1; - EXPECT_FALSE(testProxy->ShowDeviceList(registerToken, extras)); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceProxy_ShowDeviceList_004 end."; -} -} // namespace AppExecFwk -} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/continuation_test/remote_register_service_test/remote_register_service_stub_test/BUILD.gn b/test/unittest/continuation_test/remote_register_service_test/remote_register_service_stub_test/BUILD.gn deleted file mode 100644 index 858ce37ce80..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/remote_register_service_stub_test/BUILD.gn +++ /dev/null @@ -1,68 +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("//build/test.gni") -import("//foundation/ability/ability_runtime/ability_runtime.gni") - -module_output_path = "ability_runtime/abilitymgr" - -remote_register_path = "${ability_runtime_path}/frameworks/native/ability/native/continuation/remote_register_service" - -config("coverage_flags") { - if (ability_runtime_feature_coverage) { - cflags = [ "--coverage" ] - ldflags = [ "--coverage" ] - } -} - -ohos_unittest("remote_register_service_stub_test") { - module_out_path = module_output_path - - include_dirs = [ - "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/remote_register_service", - "${ability_runtime_innerkits_path}/ability_manager/include/continuation", - "${ability_runtime_services_path}/common/include", - ] - - sources = [ - "${remote_register_path}/remote_register_service_stub.cpp", - "remote_register_service_stub_test.cpp", - ] - - configs = [ ":coverage_flags" ] - cflags = [] - if (target_cpu == "arm") { - cflags += [ "-DBINDER_IPC_32BIT" ] - } - deps = [ - "${ability_runtime_native_path}/ability/native:continuation_ipc", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "ability_base:want", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - ] - - if (background_task_mgr_continuous_task_enable) { - external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] - } -} - -group("unittest") { - testonly = true - deps = [ ":remote_register_service_stub_test" ] -} diff --git a/test/unittest/continuation_test/remote_register_service_test/remote_register_service_stub_test/remote_register_service_stub_test.cpp b/test/unittest/continuation_test/remote_register_service_test/remote_register_service_stub_test/remote_register_service_stub_test.cpp deleted file mode 100644 index 38c5c9d3e06..00000000000 --- a/test/unittest/continuation_test/remote_register_service_test/remote_register_service_stub_test/remote_register_service_stub_test.cpp +++ /dev/null @@ -1,429 +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. - */ - -#include -#include -#include - -#define private public -#define protected public -#include "remote_register_service_stub.h" -#include "connect_callback_stub.h" -#undef private -#undef protected - -using namespace testing::ext; -using namespace testing; -using namespace std::chrono; - -namespace OHOS { -namespace AppExecFwk { -class RemoteRegisterServiceStubTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - -protected: - -}; - -void RemoteRegisterServiceStubTest::SetUpTestCase(void) -{} -void RemoteRegisterServiceStubTest::TearDownTestCase(void) -{} - -void RemoteRegisterServiceStubTest::SetUp(void) -{} - -void RemoteRegisterServiceStubTest::TearDown(void) -{} - -class MockRegisterService : public RemoteRegisterServiceStub { -public: - MockRegisterService() : RemoteRegisterServiceStub() {}; - ~MockRegisterService() {}; - - int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override - { - GTEST_LOG_(INFO) << "MockRegisterService::SendRequest called. return value " << returnCode_; - reply.WriteInt32(ERR_NONE); - return returnCode_; - } - - int Register(const std::string &bundleName, const sptr &token, const ExtraParams &extras, - const sptr &callback) override - { - return 0; - }; - bool Unregister(int registerToken) override - { - return true; - }; - bool UpdateConnectStatus(int registerToken, const std::string &deviceId, int status) override - { - return true; - }; - bool ShowDeviceList(int registerToken, const ExtraParams &extras) override - { - return true; - }; - - int32_t returnCode_ = ERR_NONE; - int32_t register_ = ERR_NONE; - bool unregister_ = true; - bool updateConnectStatus_ = true; - bool showDeviceList_ = true; -}; - -class MoclConnectCallback : public ConnectCallbackStub { -public: - MoclConnectCallback() {}; - ~MoclConnectCallback() {}; - - sptr AsObject() override - { - if (!asObject_) { - return nullptr; - } - - return this; - }; - - virtual void Connect(const string &deviceId, const string &deviceType) override {}; - virtual void Disconnect(const string &deviceId) override {}; - - bool asObject_ = true; -}; - -/* - * Feature: AbilityManager - * Function: RemoteRegisterServiceStub - * SubFunction: OnRemoteRequest - * FunctionPoints: The parameter of function OnRemoteRequest. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function OnRemoteRequest register parameter data - */ -HWTEST_F(RemoteRegisterServiceStubTest, AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_001, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_001 start."; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - std::string bundleName = "ABC"; - sptr token = object; - ExtraParams extras = {}; - sptr callback = new (std::nothrow) MoclConnectCallback(); - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - EXPECT_TRUE(data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor())); - EXPECT_TRUE(data.WriteString(bundleName)); - EXPECT_TRUE(data.WriteRemoteObject(token)); - EXPECT_TRUE(data.WriteInt32(1)); - EXPECT_TRUE(extras.Marshalling(data)); - EXPECT_TRUE(data.WriteRemoteObject(callback->AsObject())); - - EXPECT_EQ(object->OnRemoteRequest(MockRegisterService::COMMAND_REGISTER, data, reply, option), NO_ERROR); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_001 end."; -} - -/* - * Feature: AbilityManager - * Function: RemoteRegisterServiceStub - * SubFunction: OnRemoteRequest - * FunctionPoints: The parameter of function OnRemoteRequest. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function OnRemoteRequest unregister parameter data - */ -HWTEST_F(RemoteRegisterServiceStubTest, AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_002, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_002 start."; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - - constexpr int32_t registerToken = 0; - MessageParcel data; - MessageParcel reply; - MessageOption option; - - EXPECT_TRUE(data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor())); - EXPECT_TRUE(data.WriteInt32(registerToken)); - - EXPECT_EQ(object->OnRemoteRequest(MockRegisterService::COMMAND_UNREGISTER, data, reply, option), NO_ERROR); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_002 end."; -} - - -/* - * Feature: AbilityManager - * Function: RemoteRegisterServiceStub - * SubFunction: OnRemoteRequest - * FunctionPoints: The parameter of function OnRemoteRequest. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function OnRemoteRequest update connect status parameter data - */ -HWTEST_F(RemoteRegisterServiceStubTest, AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_003, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_003 start."; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - - constexpr int32_t registerToken = 0; - constexpr int32_t status = 0; - const std::string deviceId = "7001005458323933328a592135733900"; - MessageParcel data; - MessageParcel reply; - MessageOption option; - - EXPECT_TRUE(data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor())); - EXPECT_TRUE(data.WriteInt32(registerToken)); - EXPECT_TRUE(data.WriteString(deviceId)); - EXPECT_TRUE(data.WriteInt32(status)); - - EXPECT_EQ( - object->OnRemoteRequest(MockRegisterService::COMMAND_UPDATE_CONNECT_STATUS, data, reply, option), NO_ERROR); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_003 end."; -} - -/* - * Feature: AbilityManager - * Function: RemoteRegisterServiceStub - * SubFunction: OnRemoteRequest - * FunctionPoints: The parameter of function OnRemoteRequest. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function OnRemoteRequest show device list parameter data - */ -HWTEST_F(RemoteRegisterServiceStubTest, AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_004 start."; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - - constexpr int32_t registerToken = 0; - ExtraParams extras = {}; - MessageParcel data; - MessageParcel reply; - MessageOption option; - - EXPECT_TRUE(data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor())); - EXPECT_TRUE(data.WriteInt32(registerToken)); - EXPECT_TRUE(data.WriteInt32(1)); - - EXPECT_EQ(object->OnRemoteRequest(MockRegisterService::COMMAND_SHOW_DEVICE_LIST, data, reply, option), NO_ERROR); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_004 end."; -} - -/* - * Feature: AbilityManager - * Function: RemoteRegisterServiceStub - * SubFunction: OnRemoteRequest - * FunctionPoints: The parameter of function OnRemoteRequest. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function OnRemoteRequest parameter error touken string - */ -HWTEST_F(RemoteRegisterServiceStubTest, AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_005, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_005 start."; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - std::string bundleName = "ABC"; - sptr token = object; - ExtraParams extras = {}; - sptr callback = new (std::nothrow) MoclConnectCallback(); - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - EXPECT_TRUE(data.WriteInterfaceToken(u"123")); - - EXPECT_EQ( - object->OnRemoteRequest( - MockRegisterService::COMMAND_SHOW_DEVICE_LIST, data, reply, option), ERR_INVALID_STATE); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_005 end."; -} - -/* - * Feature: AbilityManager - * Function: RemoteRegisterServiceStub - * SubFunction: OnRemoteRequest - * FunctionPoints: The parameter of function OnRemoteRequest. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function OnRemoteRequest parameter error cmd - */ -HWTEST_F(RemoteRegisterServiceStubTest, AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_006, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_006 start."; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - EXPECT_TRUE(data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor())); - - EXPECT_EQ( - object->OnRemoteRequest( - MockRegisterService::COMMAND_SHOW_DEVICE_LIST + 66, data, reply, option), IPC_STUB_UNKNOW_TRANS_ERR); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_006 end."; -} - -/* - * Feature: AbilityManager - * Function: RemoteRegisterServiceStub - * SubFunction: OnRemoteRequest - * FunctionPoints: The parameter of function OnRemoteRequest. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function OnRemoteRequest parameter emptry funciton cmd - */ -HWTEST_F(RemoteRegisterServiceStubTest, AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_007, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_007 start."; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - EXPECT_TRUE(data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor())); - - object->requestFuncMap_[MockRegisterService::COMMAND_SHOW_DEVICE_LIST + 1] = nullptr; - - EXPECT_EQ( - object->OnRemoteRequest( - MockRegisterService::COMMAND_SHOW_DEVICE_LIST + 1, data, reply, option), IPC_STUB_UNKNOW_TRANS_ERR); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_007 end."; -} - -/* - * Feature: AbilityManager - * Function: RemoteRegisterServiceStub - * SubFunction: OnRemoteRequest - * FunctionPoints: The parameter of function OnRemoteRequest. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function OnRemoteRequest register token nullptr parameter data - */ -HWTEST_F(RemoteRegisterServiceStubTest, AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_008, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_008 start."; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - std::string bundleName = "ABC"; - sptr token = object; - ExtraParams extras = {}; - sptr callback = new (std::nothrow) MoclConnectCallback(); - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - EXPECT_TRUE(data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor())); - EXPECT_TRUE(data.WriteString(bundleName)); - EXPECT_TRUE(data.WriteRemoteObject(token)); - EXPECT_TRUE(data.WriteInt32(0)); - EXPECT_TRUE(extras.Marshalling(data)); - EXPECT_TRUE(data.WriteRemoteObject(callback->AsObject())); - - EXPECT_EQ(object->OnRemoteRequest(MockRegisterService::COMMAND_REGISTER, data, reply, option), ERR_INVALID_DATA); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_008 end."; -} - -/* - * Feature: AbilityManager - * Function: RemoteRegisterServiceStub - * SubFunction: OnRemoteRequest - * FunctionPoints: The parameter of function OnRemoteRequest. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function OnRemoteRequest register callback nullptr parameter data - */ -HWTEST_F(RemoteRegisterServiceStubTest, AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_009, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_009 start."; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - std::string bundleName = "ABC"; - sptr token = object; - ExtraParams extras = {}; - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - EXPECT_TRUE(data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor())); - EXPECT_TRUE(data.WriteString(bundleName)); - EXPECT_TRUE(data.WriteRemoteObject(token)); - EXPECT_TRUE(data.WriteInt32(1)); - EXPECT_TRUE(extras.Marshalling(data)); - - EXPECT_EQ(object->OnRemoteRequest(MockRegisterService::COMMAND_REGISTER, data, reply, option), ERR_NULL_OBJECT); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_009 end."; -} - -/* - * Feature: AbilityManager - * Function: RemoteRegisterServiceStub - * SubFunction: OnRemoteRequest - * FunctionPoints: The parameter of function OnRemoteRequest. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify function OnRemoteRequest show device list extras nullptr parameter data - */ -HWTEST_F(RemoteRegisterServiceStubTest, AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_010, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_010 start."; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - constexpr int32_t registerToken = 100; - ExtraParams extras = {}; - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - EXPECT_TRUE(data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor())); - EXPECT_TRUE(data.WriteInt32(registerToken)); - EXPECT_TRUE(data.WriteInt32(0)); - EXPECT_TRUE(extras.Marshalling(data)); - - EXPECT_EQ( - object->OnRemoteRequest( - MockRegisterService::COMMAND_SHOW_DEVICE_LIST, data, reply, option), ERR_INVALID_DATA); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_010 end."; -} - -/* - * Feature: AbilityManager - * Function: RemoteRegisterServiceStub - * SubFunction: OnRemoteRequest - * FunctionPoints: The parameter of function OnRemoteRequest. - * EnvConditions: Can run ohos test framework - * CaseDescription: Verify construct destructor function of RemoteRegisterServiceStub - */ -HWTEST_F(RemoteRegisterServiceStubTest, AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_011, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_011 start."; - sptr object = new (std::nothrow) MockRegisterService(); - EXPECT_TRUE(object != nullptr); - object.clear(); - object = nullptr; - EXPECT_TRUE(object == nullptr); - GTEST_LOG_(INFO) << "AppExecFwk_RemoteRegisterServiceStub_OnRemoteRequest_011 end."; -} -} // namespace AppExecFwk -} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/frameworks_kits_ability_native_test/ability_context_interface1_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ability_context_interface1_test.cpp index 28797058906..3fa739d98f8 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ability_context_interface1_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ability_context_interface1_test.cpp @@ -97,113 +97,6 @@ HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_TerminateAbilityResul GTEST_LOG_(INFO) << "AaFwk_AbilityContext_TerminateAbilityResult_0300 end"; } -/** - * @tc.number: AaFwk_AbilityContext_SetColorMode_0100 - * @tc.name: SetColorMode - * @tc.desc: Test the attachbasecontext call to verify that the return value of SetColorMode is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_SetColorMode_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_SetColorMode_0100 start"; - std::shared_ptr abilityContext = std::make_shared(); - std::shared_ptr contextDeal = std::make_shared(); - abilityContext->AttachBaseContext(contextDeal); - int testValue = 1; - abilityContext->SetColorMode(testValue); - EXPECT_EQ(testValue, abilityContext->GetColorMode()); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_SetColorMode_0100 end"; -} - -/** - * @tc.number: AaFwk_AbilityContext_SetColorMode_0200 - * @tc.name: SetColorMode - * @tc.desc: Test the attachbasecontext call to verify that the return value of SetColorMode is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_SetColorMode_0200, Function | MediumTest | Level3) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_SetColorMode_0200 start"; - std::shared_ptr abilityContext = std::make_shared(); - int testValue = 0; - abilityContext->SetColorMode(testValue); - EXPECT_GT(testValue, abilityContext->GetColorMode()); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_SetColorMode_0200 end"; -} - -/** - * @tc.number: AaFwk_AbilityContext_GetColorMode_0100 - * @tc.name: GetColorMode - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetColorMode is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetColorMode_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetColorMode_0100 start"; - std::shared_ptr abilityContext = std::make_shared(); - std::shared_ptr contextDeal = std::make_shared(); - abilityContext->AttachBaseContext(contextDeal); - int testValue = 1; - abilityContext->SetColorMode(testValue); - EXPECT_EQ(testValue, abilityContext->GetColorMode()); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetColorMode_0100 end"; -} - -/** - * @tc.number: AaFwk_AbilityContext_GetColorMode_0200 - * @tc.name: GetColorMode - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetColorMode is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetColorMode_0200, Function | MediumTest | Level3) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetColorMode_0200 start"; - std::shared_ptr abilityContext = std::make_shared(); - int testValue = 0; - abilityContext->SetColorMode(testValue); - EXPECT_GT(testValue, abilityContext->GetColorMode()); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetColorMode_0200 end"; -} - -/** - * @tc.number: AaFwk_AbilityContext_SetTheme_0100 - * @tc.name: SetTheme - * @tc.desc: Test the attachbasecontext call to verify that the return value of SetTheme is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_SetTheme_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_SetTheme_0100 start"; - int testValue = 1; - std::map testList = { - {"Pattern1", "PatternA"}, {"Pattern2", "PatternB"}, {"Pattern3", "PatternC"} }; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - std::shared_ptr abilityContext = std::make_shared(); - ASSERT_NE(abilityContext, nullptr); - resourceManager->SetThemeById(testValue, testList); - contextDeal->initResourceManager(resourceManager); - abilityContext->AttachBaseContext(contextDeal); - abilityContext->SetTheme(testValue); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_SetTheme_0100 end"; -} - -/** - * @tc.number: AaFwk_AbilityContext_SetTheme_0200 - * @tc.name: SetTheme - * @tc.desc: Test the attachbasecontext call to verify that the return value of SetTheme is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_SetTheme_0200, Function | MediumTest | Level3) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_SetTheme_0200 start"; - int testValue = 2; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - std::shared_ptr abilityContext = std::make_shared(); - ASSERT_NE(abilityContext, nullptr); - abilityContext->SetTheme(testValue); - abilityContext->AttachBaseContext(contextDeal); - abilityContext->SetTheme(testValue); - contextDeal->initResourceManager(resourceManager); - abilityContext->SetTheme(testValue); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_SetTheme_0200 end"; -} - /** * @tc.number: AaFwk_AbilityContext_StartAbilities_0100 * @tc.name: StartAbilities @@ -246,70 +139,6 @@ HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetPreferencesDir_010 GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetPreferencesDir_0100 end"; } -/** - * @tc.number: AaFwk_AbilityContext_GetPattern_0100 - * @tc.name: GetPattern - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetPattern is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetPattern_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetPattern_0100 start"; - int testValue = 0; - std::map testList = { - {"Pattern1", "PatternA"}, {"Pattern2", "PatternB"}, {"Pattern3", "PatternC"} }; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - std::shared_ptr abilityContext = std::make_shared(); - resourceManager->SetPatternById(testValue, testList); - contextDeal->initResourceManager(resourceManager); - abilityContext->AttachBaseContext(contextDeal); - abilityContext->SetPattern(testValue); - std::map retVal = abilityContext->GetPattern(); - EXPECT_TRUE((retVal == testList)); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetPattern_0100 end"; -} - -/** - * @tc.number: AaFwk_AbilityContext_GetTheme_0100 - * @tc.name: GetTheme - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetTheme is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetTheme_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetTheme_0100 start"; - int testValue = 0; - std::map testList = { {"Theme1", "ThemeA"}, {"Theme2", "ThemeB"}, {"Theme3", "ThemeC"} }; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - std::shared_ptr abilityContext = std::make_shared(); - ASSERT_NE(abilityContext, nullptr); - resourceManager->SetThemeById(testValue, testList); - contextDeal->initResourceManager(resourceManager); - abilityContext->AttachBaseContext(contextDeal); - std::map retVal = abilityContext->GetTheme(); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetTheme_0100 end"; -} - -/** - * @tc.number: AaFwk_AbilityContext_GetString_ById_0100 - * @tc.name: GetString - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetString is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetString_ById_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetString_ById_0100 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - std::shared_ptr abilityContext = std::make_shared(); - int testCount = 0; - std::string testValue = "GetString test"; - resourceManager->SetStringById(testCount, testValue); - contextDeal->initResourceManager(resourceManager); - abilityContext->AttachBaseContext(contextDeal); - EXPECT_STREQ(testValue.c_str(), abilityContext->GetString(testCount).c_str()); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetString_ById_0100 end"; -} - /** * @tc.number: AaFwk_AbilityContext_GetString_ByIdAndFormat_0100 * @tc.name: GetString @@ -326,132 +155,6 @@ HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetString_ByIdAndForm GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetString_ByIdAndFormat_0100 end"; } -/** - * @tc.number: AaFwk_AbilityContext_GetStringArray_0100 - * @tc.name: GetStringArray - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetStringArray is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetStringArray_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetStringArray_0100 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - std::shared_ptr abilityContext = std::make_shared(); - int testCount = 0; - std::vector testValue = { "123", "456", "789" }; - resourceManager->SetStringArrayById(testCount, testValue); - contextDeal->initResourceManager(resourceManager); - abilityContext->AttachBaseContext(contextDeal); - std::vector retVal = abilityContext->GetStringArray(testCount); - EXPECT_TRUE((retVal == testValue)); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetStringArray_0100 end"; -} - -/** - * @tc.number: AaFwk_AbilityContext_GetStringArray_0200 - * @tc.name: GetStringArray - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetStringArray is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetStringArray_0200, Function | MediumTest | Level3) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetStringArray_0200 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - std::shared_ptr abilityContext = std::make_shared(); - int testCount = 0; - std::vector testValue = { "123", "456", "789" }; - resourceManager->SetStringArrayById(testCount + 1, testValue); - contextDeal->initResourceManager(resourceManager); - abilityContext->AttachBaseContext(contextDeal); - std::vector retVal = abilityContext->GetStringArray(testCount); - EXPECT_FALSE((retVal == testValue)); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetStringArray_0200 end"; -} - -/** - * @tc.number: AaFwk_AbilityContext_GetIntArray_0100 - * @tc.name: GetIntArray - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetIntArray is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetIntArray_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetIntArray_0100 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - std::shared_ptr abilityContext = std::make_shared(); - int testCount = 0; - std::vector testValue = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; - resourceManager->SetIntArrayById(testCount, testValue); - contextDeal->initResourceManager(resourceManager); - abilityContext->AttachBaseContext(contextDeal); - std::vector retVal = abilityContext->GetIntArray(testCount); - EXPECT_TRUE((retVal == testValue)); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetIntArray_0100 end"; -} - -/** - * @tc.number: AaFwk_AbilityContext_GetIntArray_0200 - * @tc.name: GetIntArray - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetIntArray is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetIntArray_0200, Function | MediumTest | Level3) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetIntArray_0200 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - std::shared_ptr abilityContext = std::make_shared(); - int testCount = 0; - std::vector testValue = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; - resourceManager->SetIntArrayById(testCount + 1, testValue); - contextDeal->initResourceManager(resourceManager); - abilityContext->AttachBaseContext(contextDeal); - std::vector retVal = abilityContext->GetIntArray(testCount); - EXPECT_FALSE((retVal == testValue)); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetIntArray_0200 end"; -} - -/** - * @tc.number: AaFwk_AbilityContext_GetColor_0100 - * @tc.name: GetColor - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetColor is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetColor_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetColor_0100 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - std::shared_ptr abilityContext = std::make_shared(); - int testCount = 0; - uint32_t testValue = 1; - const int testVal = static_cast(testValue); - resourceManager->SetColorById(testCount, testValue); - contextDeal->initResourceManager(resourceManager); - abilityContext->AttachBaseContext(contextDeal); - EXPECT_EQ(testVal, abilityContext->GetColor(testCount)); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetColor_0100 end"; -} - -/** - * @tc.number: AaFwk_AbilityContext_GetColor_0200 - * @tc.name: GetColor - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetColor is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetColor_0200, Function | MediumTest | Level3) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetColor_0200 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - std::shared_ptr abilityContext = std::make_shared(); - int testCount = 0; - uint32_t testValue = 1; - const int testVal = static_cast(testValue); - resourceManager->SetColorById(testCount + 1, testValue); - contextDeal->initResourceManager(resourceManager); - abilityContext->AttachBaseContext(contextDeal); - EXPECT_NE(testVal, abilityContext->GetColor(testCount)); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetColor_0200 end"; -} - /** * @tc.number: AaFwk_AbilityContext_GetThemeId_0100 * @tc.name: GetThemeId @@ -486,30 +189,6 @@ HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetDisplayOrientation GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetDisplayOrientation_0100 end"; } -/** - * @tc.number: AaFwk_AbilityContext_SetPattern_0100 - * @tc.name: SetPattern - * @tc.desc: Test the attachbasecontext call to verify that the return value of SetPattern is correct. - */ -HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_SetPattern_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_SetPattern_0100 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - std::shared_ptr abilityContext = std::make_shared(); - int testCount = 0; - std::map testList = { {"123", "abc"}, {"456", "def"} }; - resourceManager->SetPatternById(testCount, testList); - contextDeal->initResourceManager(resourceManager); - abilityContext->AttachBaseContext(contextDeal); - abilityContext->SetPattern(testCount); - std::map retVal; - EXPECT_FALSE((retVal == testList)); - retVal = abilityContext->GetPattern(); - EXPECT_TRUE((retVal == testList)); - GTEST_LOG_(INFO) << "AaFwk_AbilityContext_SetPattern_0100 end"; -} - /** * @tc.number: AaFwk_AbilityContext_TerminateAbility_0100 * @tc.name: TerminateAbility diff --git a/test/unittest/frameworks_kits_ability_native_test/ability_context_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ability_context_test.cpp index 6afb298fe46..1a5e4c515bb 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ability_context_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ability_context_test.cpp @@ -246,24 +246,6 @@ HWTEST_F(AbilityContextTest, AaFwk_AbilityContext_GetBundleName_0100, Function | EXPECT_STREQ(name.c_str(), context_->GetBundleName().c_str()); } -/** - * @tc.number: AaFwk_AbilityContext_GetBundleResourcePath_0100 - * @tc.name: GetBundleResourcePath - * @tc.desc: Test the attachbasecontext call to verify whether the return value of getbundleresourcepath is correct. - */ -HWTEST_F(AbilityContextTest, AaFwk_AbilityContext_GetBundleResourcePath_0100, Function | MediumTest | Level1) -{ - std::shared_ptr abilityInfo = std::make_shared(); - std::string resourcePath = "hello"; - abilityInfo->resourcePath = resourcePath; - - std::shared_ptr deal = std::make_shared(); - deal->SetAbilityInfo(abilityInfo); - - context_->AttachBaseContext(deal); - EXPECT_STREQ(resourcePath.c_str(), context_->GetBundleResourcePath().c_str()); -} - /** * @tc.number: AaFwk_AbilityContext_GetApplicationContext_0100 * @tc.name: GetApplicationContext diff --git a/test/unittest/frameworks_kits_appkit_native_test/context_container_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/context_container_test.cpp index 7dbe6c76491..d104654c716 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/context_container_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/context_container_test.cpp @@ -182,35 +182,6 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetApplicationInfo_02 EXPECT_EQ(info, nullptr); } -/** - * @tc.number: AppExecFwk_ContextContainer_GetBundleResourcePath_0100 - * @tc.name: GetBundleResourcePath - * @tc.desc: Test whether AttachBaseContext is called normally, - * and verify whether the return value of GetBundleResourcePath is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetBundleResourcePath_0100, Function | MediumTest | Level1) -{ - std::shared_ptr info = std::make_shared(); - std::string resourcePath = "ResourcePath"; - info->resourcePath = resourcePath; - contextDeal_->SetAbilityInfo(info); - context_->AttachBaseContext(contextDeal_); - - EXPECT_STREQ(context_->GetBundleResourcePath().c_str(), resourcePath.c_str()); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetBundleResourcePath_0200 - * @tc.name: GetBundleResourcePath - * @tc.desc: Test GetBundleResourcePath exception status. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetBundleResourcePath_0200, Function | MediumTest | Level3) -{ - std::string path = context_->GetBundleResourcePath(); - std::string empty = ""; - EXPECT_STREQ(context_->GetBundleResourcePath().c_str(), empty.c_str()); -} - /** * @tc.number: AppExecFwk_ContextContainer_GetAppType_0100 * @tc.name: GetAppType @@ -530,7 +501,8 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetProcessName_0200, */ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_InitResourceManager_0100, Function | MediumTest | Level3) { - std::shared_ptr appContext = std::make_shared(true); + std::shared_ptr appContext = std::make_shared(); + appContext->SetSystemAppFlag(true); AppExecFwk::BundleInfo bundleInfo; context_->InitResourceManager(bundleInfo, appContext); EXPECT_TRUE(appContext->GetResourceManager() != nullptr); @@ -704,32 +676,6 @@ HWTEST_F(ContextContainerTest, VerifyPermission_0200, Function | MediumTest | Le EXPECT_EQ(context_->VerifyPermission(permission, pid, uid), AppExecFwk::Constants::PERMISSION_NOT_GRANTED); } -/** - * @tc.number: SetPattern_0100 - * @tc.name: SetPattern - * @tc.desc: SetPattern - */ -HWTEST_F(ContextContainerTest, SetPattern_0100, Function | MediumTest | Level1) -{ - ASSERT_NE(context_, nullptr); - context_->AttachBaseContext(contextDeal_); - int patternId = 0; - context_->SetPattern(patternId); -} - -/** - * @tc.number: SetPattern_0200 - * @tc.name: SetPattern - * @tc.desc: SetPattern - */ -HWTEST_F(ContextContainerTest, SetPattern_0200, Function | MediumTest | Level1) -{ - ASSERT_NE(context_, nullptr); - context_->AttachBaseContext(nullptr); - int patternId = 0; - context_->SetPattern(patternId); -} - /** * @tc.number: GetAbilityPackageContext_0100 * @tc.name: GetAbilityPackageContext @@ -791,9 +737,8 @@ HWTEST_F(ContextContainerTest, CreateBundleContext_0100, Function | MediumTest | { context_->AttachBaseContext(contextDeal_); std::string bundleName = "test_bundle"; - int flag = 0; int accountId = 0; - EXPECT_EQ(context_->CreateBundleContext(bundleName, flag, accountId), nullptr); + EXPECT_EQ(context_->CreateBundleContext(bundleName, accountId), nullptr); } /** @@ -805,9 +750,8 @@ HWTEST_F(ContextContainerTest, CreateBundleContext_0200, Function | MediumTest | { context_->AttachBaseContext(contextDeal_); std::string bundleName = ""; - int flag = 0; int accountId = 0; - EXPECT_EQ(context_->CreateBundleContext(bundleName, flag, accountId), nullptr); + EXPECT_EQ(context_->CreateBundleContext(bundleName, accountId), nullptr); } /** @@ -819,165 +763,8 @@ HWTEST_F(ContextContainerTest, CreateBundleContext_0300, Function | MediumTest | { context_->AttachBaseContext(nullptr); std::string bundleName = "test_bundle"; - int flag = 0; int accountId = 0; - EXPECT_EQ(context_->CreateBundleContext(bundleName, flag, accountId), nullptr); -} - -/** - * @tc.number: GetString_0100 - * @tc.name: GetString - * @tc.desc: GetString - */ -HWTEST_F(ContextContainerTest, GetString_0100, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(contextDeal_); - EXPECT_EQ(context_->GetString(1), ""); -} - -/** - * @tc.number: GetString_0200 - * @tc.name: GetString - * @tc.desc: GetString - */ -HWTEST_F(ContextContainerTest, GetString_0200, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(nullptr); - EXPECT_EQ(context_->GetString(1), ""); -} - -/** - * @tc.number: GetStringArray_0100 - * @tc.name: GetStringArray - * @tc.desc: GetStringArray - */ -HWTEST_F(ContextContainerTest, GetStringArray_0100, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(contextDeal_); - EXPECT_EQ(context_->GetStringArray(1).size(), 0); -} - -/** - * @tc.number: GetStringArray_0200 - * @tc.name: GetStringArray - * @tc.desc: GetStringArray - */ -HWTEST_F(ContextContainerTest, GetStringArray_0200, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(nullptr); - EXPECT_EQ(context_->GetStringArray(1).size(), 0); -} - -/** - * @tc.number: GetIntArray_0100 - * @tc.name: GetIntArray - * @tc.desc: GetIntArray - */ -HWTEST_F(ContextContainerTest, GetIntArray_0100, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(contextDeal_); - EXPECT_EQ(context_->GetIntArray(1).size(), 0); -} - -/** - * @tc.number: GetIntArray_0200 - * @tc.name: GetIntArray - * @tc.desc: GetIntArray - */ -HWTEST_F(ContextContainerTest, GetIntArray_0200, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(nullptr); - EXPECT_EQ(context_->GetIntArray(1).size(), 0); -} - -/** - * @tc.number: GetTheme_0100 - * @tc.name: GetTheme - * @tc.desc: GetTheme - */ -HWTEST_F(ContextContainerTest, GetTheme_0100, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(contextDeal_); - EXPECT_EQ(context_->GetTheme().size(), 0); -} - -/** - * @tc.number: GetTheme_0200 - * @tc.name: GetTheme - * @tc.desc: GetTheme - */ -HWTEST_F(ContextContainerTest, GetTheme_0200, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(nullptr); - EXPECT_EQ(context_->GetTheme().size(), 0); -} - -/** - * @tc.number: SetTheme_0100 - * @tc.name: SetTheme - * @tc.desc: SetTheme - */ -HWTEST_F(ContextContainerTest, SetTheme_0100, Function | MediumTest | Level1) -{ - ASSERT_NE(context_, nullptr); - context_->AttachBaseContext(contextDeal_); - context_->SetTheme(1); -} - -/** - * @tc.number: SetTheme_0200 - * @tc.name: SetTheme - * @tc.desc: SetTheme - */ -HWTEST_F(ContextContainerTest, SetTheme_0200, Function | MediumTest | Level1) -{ - ASSERT_NE(context_, nullptr); - context_->AttachBaseContext(nullptr); - context_->SetTheme(1); -} - -/** - * @tc.number: GetPattern_0100 - * @tc.name: GetPattern - * @tc.desc: GetPattern - */ -HWTEST_F(ContextContainerTest, GetPattern_0100, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(contextDeal_); - EXPECT_EQ(context_->GetPattern().size(), 0); -} - -/** - * @tc.number: GetPattern_0200 - * @tc.name: GetPattern - * @tc.desc: GetPattern - */ -HWTEST_F(ContextContainerTest, GetPattern_0200, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(nullptr); - EXPECT_EQ(context_->GetPattern().size(), 0); -} - -/** - * @tc.number: GetColor_0100 - * @tc.name: GetColor - * @tc.desc: GetColor - */ -HWTEST_F(ContextContainerTest, GetColor_0100, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(contextDeal_); - EXPECT_EQ(context_->GetColor(1), -1); -} - -/** - * @tc.number: GetThemeId_0100 - * @tc.name: GetThemeId - * @tc.desc: GetThemeId - */ -HWTEST_F(ContextContainerTest, GetThemeId_0100, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(contextDeal_); - EXPECT_EQ(context_->GetThemeId(), -1); + EXPECT_EQ(context_->CreateBundleContext(bundleName, accountId), nullptr); } /** @@ -1024,52 +811,6 @@ HWTEST_F(ContextContainerTest, GetPreferencesDir_0200, Function | MediumTest | L EXPECT_EQ(context_->GetPreferencesDir(), ""); } -/** - * @tc.number: SetColorMode_0100 - * @tc.name: SetColorMode - * @tc.desc: SetColorMode - */ -HWTEST_F(ContextContainerTest, SetColorMode_0100, Function | MediumTest | Level1) -{ - ASSERT_NE(context_, nullptr); - context_->AttachBaseContext(contextDeal_); - context_->SetColorMode(1); -} - -/** - * @tc.number: SetColorMode_0200 - * @tc.name: SetColorMode - * @tc.desc: SetColorMode - */ -HWTEST_F(ContextContainerTest, SetColorMode_0200, Function | MediumTest | Level1) -{ - ASSERT_NE(context_, nullptr); - context_->AttachBaseContext(nullptr); - context_->SetColorMode(1); -} - -/** - * @tc.number: GetColorMode_0100 - * @tc.name: GetColorMode - * @tc.desc: GetColorMode - */ -HWTEST_F(ContextContainerTest, GetColorMode_0100, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(contextDeal_); - EXPECT_EQ(context_->GetColorMode(), -1); -} - -/** - * @tc.number: GetColorMode_0200 - * @tc.name: GetColorMode - * @tc.desc: GetColorMode - */ -HWTEST_F(ContextContainerTest, GetColorMode_0200, Function | MediumTest | Level1) -{ - context_->AttachBaseContext(nullptr); - EXPECT_EQ(context_->GetColorMode(), -1); -} - /** * @tc.number: GetMissionId_0100 * @tc.name: GetMissionId @@ -1322,257 +1063,6 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetCaller_0200, Funct EXPECT_EQ(context_->GetCaller(), uri); } -/** - * @tc.number: AppExecFwk_ContextContainer_GetString_0100 - * @tc.name: Get String - * @tc.desc: Test Get String When baseContext is not null, - * and verify whether the return value of Get String is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetString_0100, Function | MediumTest | Level1) -{ - std::shared_ptr ability = std::make_shared(); - std::shared_ptr context(ability); - contextDeal_->SetContext(context); - context_->AttachBaseContext(contextDeal_); - - EXPECT_EQ(context_->GetString(0), ""); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetString_0200 - * @tc.name: Get String - * @tc.desc: Test Get String When baseContext is null. - * and verify whether the return value of Get String is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetString_0200, Function | MediumTest | Level3) -{ - EXPECT_EQ(context_->GetString(0), ""); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetStringArray_0100 - * @tc.name: Get String Array - * @tc.desc: Test Get String Array When baseContext is not null, - * and verify whether the return value of Get String Array is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetStringArray_0100, Function | MediumTest | Level1) -{ - std::shared_ptr ability = std::make_shared(); - std::shared_ptr context(ability); - contextDeal_->SetContext(context); - context_->AttachBaseContext(contextDeal_); - - std::vector ret = context_->GetStringArray(0); - EXPECT_EQ(ret.size(), 0); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetStringArray_0200 - * @tc.name: Get String Array - * @tc.desc: Test Get String Array When baseContext is null. - * and verify whether the return value of Get String Array is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetStringArray_0200, Function | MediumTest | Level3) -{ - std::vector ret = context_->GetStringArray(0); - EXPECT_EQ(ret.size(), 0); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetIntArray_0100 - * @tc.name: Get Int Array - * @tc.desc: Test Get Int Array When baseContext is not null, - * and verify whether the return value of Get Int Array is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetIntArray_0100, Function | MediumTest | Level1) -{ - std::shared_ptr ability = std::make_shared(); - std::shared_ptr context(ability); - contextDeal_->SetContext(context); - context_->AttachBaseContext(contextDeal_); - - std::vector ret = context_->GetIntArray(0); - EXPECT_EQ(ret.size(), 0); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetIntArray_0200 - * @tc.name: Get Int Array - * @tc.desc: Test Get Int Array When baseContext is null. - * and verify whether the return value of Get Int Array is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetIntArray_0200, Function | MediumTest | Level3) -{ - std::vector ret = context_->GetIntArray(0); - EXPECT_EQ(ret.size(), 0); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetTheme_0100 - * @tc.name: Get Theme - * @tc.desc: Test Get Theme When baseContext is not null, - * and verify whether the return value of Get Theme is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetTheme_0100, Function | MediumTest | Level1) -{ - std::shared_ptr ability = std::make_shared(); - std::shared_ptr context(ability); - contextDeal_->SetContext(context); - context_->AttachBaseContext(contextDeal_); - std::map ret = context_->GetTheme(); - EXPECT_EQ(ret.size(), 0); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetTheme_0200 - * @tc.name: Get Theme - * @tc.desc: Test Get Theme When baseContext is null. - * and verify whether the return value of Get Theme is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetTheme_0200, Function | MediumTest | Level3) -{ - std::map ret = context_->GetTheme(); - EXPECT_EQ(ret.size(), 0); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_SetTheme_0100 - * @tc.name: Set Theme - * @tc.desc: Test Set Theme When baseContext is not null, - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_SetTheme_0100, Function | MediumTest | Level1) -{ - std::shared_ptr ability = std::make_shared(); - std::shared_ptr context(ability); - ASSERT_NE(context, nullptr); - contextDeal_->SetContext(context); - context_->AttachBaseContext(contextDeal_); - context_->SetTheme(0); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_SetTheme_0200 - * @tc.name: Set Theme - * @tc.desc: Test Set Theme When baseContext is null. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_SetTheme_0200, Function | MediumTest | Level3) -{ - ASSERT_NE(context_, nullptr); - context_->SetTheme(0); -} - -/** - * @tc.number: AppExecFwk_ContextContainerGetPattern_0100 - * @tc.name: Get Pattern - * @tc.desc: Test Get Pattern When baseContext is not null, - * and verify whether the return value of Get Pattern is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetPattern_0100, Function | MediumTest | Level1) -{ - std::shared_ptr ability = std::make_shared(); - std::shared_ptr context(ability); - contextDeal_->SetContext(context); - context_->AttachBaseContext(contextDeal_); - - std::map ret = context_->GetPattern(); - EXPECT_EQ(ret.size(), 0); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetPattern_0200 - * @tc.name: Get Pattern - * @tc.desc: Test Get Pattern When baseContext is null. - * and verify whether the return value of Get Pattern is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetPattern_0200, Function | MediumTest | Level3) -{ - std::map ret = context_->GetPattern(); - EXPECT_EQ(ret.size(), 0); -} - -/** - * @tc.number: AppExecFwk_ContextContainerSetPattern_0100 - * @tc.name: Set Pattern - * @tc.desc: Test Get Pattern When baseContext is not null, - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_SetPattern_0100, Function | MediumTest | Level1) -{ - std::shared_ptr ability = std::make_shared(); - std::shared_ptr context(ability); - ASSERT_NE(context, nullptr); - contextDeal_->SetContext(context); - context_->AttachBaseContext(contextDeal_); - - context_->SetPattern(0); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_SetPattern_0200 - * @tc.name: Set Pattern - * @tc.desc: Test Set Pattern When baseContext is null. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_SetPattern_0200, Function | MediumTest | Level3) -{ - ASSERT_NE(context_, nullptr); - context_->SetPattern(0); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetColor_0100 - * @tc.name: Get Color - * @tc.desc: Test Get Color When baseContext is not null, - * and verify whether the return value of Get Color is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetColor_0100, Function | MediumTest | Level1) -{ - std::shared_ptr ability = std::make_shared(); - std::shared_ptr context(ability); - ASSERT_NE(context, nullptr); - contextDeal_->SetContext(context); - context_->AttachBaseContext(contextDeal_); - - EXPECT_EQ(context_->GetColor(0), -1); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetColor_0200 - * @tc.name: Get Color - * @tc.desc: Test Get Color When baseContext is null. - * and verify whether the return value of Get Color is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetColor_0200, Function | MediumTest | Level3) -{ - EXPECT_EQ(context_->GetColor(0), -1); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetThemeId_0100 - * @tc.name: Get Theme Id - * @tc.desc: Test Get Theme Id When baseContext is not null, - * and verify whether the return value of Get Theme Id is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetThemeId_0100, Function | MediumTest | Level1) -{ - std::shared_ptr ability = std::make_shared(); - std::shared_ptr context(ability); - ASSERT_NE(context, nullptr); - contextDeal_->SetContext(context); - context_->AttachBaseContext(contextDeal_); - - EXPECT_EQ(context_->GetThemeId(), -1); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetThemeId_0200 - * @tc.name: Get Theme Id - * @tc.desc: Test Get Theme Id When baseContext is null. - * and verify whether the return value of Get Theme Id is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetThemeId_0200, Function | MediumTest | Level3) -{ - EXPECT_EQ(context_->GetThemeId(), -1); -} - /** * @tc.number: AppExecFwk_ContextContainer_GetDisplayOrientation_0100 * @tc.name: Get Display Orientation @@ -1629,36 +1119,6 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetPreferencesDir_020 EXPECT_EQ(context_->GetPreferencesDir(), ""); } -/** - * @tc.number: AppExecFwk_ContextContainer_GetColorMode_0100 - * @tc.name: Get Color Mode - * @tc.desc: Test Get Color Mode When baseContext is not null, - * and verify whether the return value of Get Color Mode is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetColorMode_0100, Function | MediumTest | Level1) -{ - std::shared_ptr ability = std::make_shared(); - std::shared_ptr context(ability); - contextDeal_->SetContext(context); - contextDeal_->hapModuleInfoLocal_ = std::make_shared(); - context_->AttachBaseContext(contextDeal_); - - context_->SetColorMode(static_cast(ModuleColorMode::DARK)); - EXPECT_EQ(context_->GetColorMode(), static_cast(ModuleColorMode::DARK)); -} - -/** - * @tc.number: AppExecFwk_ContextContainer_GetColorMode_0200 - * @tc.name: Get Color Mode - * @tc.desc: Test Get Color Mode When baseContext is null. - * and verify whether the return value of Get Color Mode is correct. - */ -HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetColorMode_0200, Function | MediumTest | Level3) -{ - context_->SetColorMode(-1); - EXPECT_EQ(context_->GetColorMode(), -1); -} - /** * @tc.number: AppExecFwk_ContextContainer_GetMissionId_0100 * @tc.name: Get Mission Id @@ -1761,7 +1221,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_CreateBundleContext_0 contextDeal_->SetApplicationContext(context); context_->AttachBaseContext(contextDeal_); - EXPECT_NE(context_->CreateBundleContext("BundleName", 0, 0), nullptr); + EXPECT_NE(context_->CreateBundleContext("BundleName", 0), nullptr); } /** @@ -1776,7 +1236,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_CreateBundleContext_0 contextDeal_->SetContext(context); context_->AttachBaseContext(contextDeal_); - EXPECT_EQ(context_->CreateBundleContext("bundlename", 0, 0), nullptr); + EXPECT_EQ(context_->CreateBundleContext("bundlename", 0), nullptr); } /** @@ -1791,7 +1251,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_CreateBundleContext_0 contextDeal_->SetContext(context); context_->AttachBaseContext(contextDeal_); - EXPECT_EQ(context_->CreateBundleContext("bundlename", 0, DEFAULT_ACCOUNT_ID), nullptr); + EXPECT_EQ(context_->CreateBundleContext("bundlename", DEFAULT_ACCOUNT_ID), nullptr); } /** @@ -1801,7 +1261,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_CreateBundleContext_0 */ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_CreateBundleContext_0400, Function | MediumTest | Level3) { - EXPECT_EQ(context_->CreateBundleContext("", 0, 0), nullptr); + EXPECT_EQ(context_->CreateBundleContext("", 0), nullptr); } } // namespace AppExecFwk diff --git a/test/unittest/frameworks_kits_appkit_native_test/context_deal_interface1_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/context_deal_interface1_test.cpp index fd64b3648f3..8e9997189c8 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/context_deal_interface1_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/context_deal_interface1_test.cpp @@ -51,105 +51,6 @@ void ContextDealInterfaceTest::SetUp() void ContextDealInterfaceTest::TearDown() {} -/** - * @tc.number: AppExecFwk_ContextDeal_SetColorMode_0100 - * @tc.name: SetColorMode - * @tc.desc: Test the attachbasecontext call to verify that the return value of SetColorMode is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_SetColorMode_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_SetColorMode_0100 start"; - std::shared_ptr abilityInfo = std::make_shared(); - std::shared_ptr contextDeal = std::make_shared(); - int testValue = static_cast(OHOS::AppExecFwk::ModuleColorMode::DARK); - contextDeal->SetAbilityInfo(abilityInfo); - contextDeal->SetColorMode(testValue); - EXPECT_EQ(testValue, contextDeal->GetColorMode()); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_SetColorMode_0100 end"; -} - -/** - * @tc.number: AppExecFwk_ContextDeal_SetColorMode_0200 - * @tc.name: SetColorMode - * @tc.desc: Test the attachbasecontext call to verify that the return value of SetColorMode is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_SetColorMode_0200, Function | MediumTest | Level3) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_SetColorMode_0200 start"; - std::shared_ptr contextDeal = std::make_shared(); - int testValue = static_cast(OHOS::AppExecFwk::ModuleColorMode::DARK); - contextDeal->SetColorMode(testValue); - EXPECT_GT(testValue, contextDeal->GetColorMode()); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_SetColorMode_0200 end"; -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetColorMode_0100 - * @tc.name: GetColorMode - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetColorMode is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetColorMode_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetColorMode_0100 start"; - std::shared_ptr abilityInfo = std::make_shared(); - std::shared_ptr contextDeal = std::make_shared(); - int testValue = static_cast(OHOS::AppExecFwk::ModuleColorMode::DARK); - contextDeal->SetAbilityInfo(abilityInfo); - contextDeal->SetColorMode(testValue); - EXPECT_EQ(testValue, contextDeal->GetColorMode()); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetColorMode_0100 end"; -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetColorMode_0200 - * @tc.name: GetColorMode - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetColorMode is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetColorMode_0200, Function | MediumTest | Level3) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetColorMode_0200 start"; - std::shared_ptr contextDeal = std::make_shared(); - int testValue = static_cast(OHOS::AppExecFwk::ModuleColorMode::DARK); - contextDeal->SetColorMode(testValue); - EXPECT_GT(testValue, contextDeal->GetColorMode()); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetColorMode_0200 end"; -} - -/** - * @tc.number: AppExecFwk_ContextDeal_SetTheme_0100 - * @tc.name: SetTheme - * @tc.desc: Test the attachbasecontext call to verify that the return value of SetTheme is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_SetTheme_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_SetTheme_0100 start"; - int testValue = 1; - std::map testList = { - {"Pattern1", "PatternA"}, {"Pattern2", "PatternB"}, {"Pattern3", "PatternC"} }; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - ASSERT_NE(contextDeal, nullptr); - resourceManager->SetThemeById(testValue, testList); - contextDeal->initResourceManager(resourceManager); - contextDeal->SetTheme(testValue); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_SetTheme_0100 end"; -} - -/** - * @tc.number: AppExecFwk_ContextDeal_SetTheme_0200 - * @tc.name: SetTheme - * @tc.desc: Test the attachbasecontext call to verify that the return value of SetTheme is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_SetTheme_0200, Function | MediumTest | Level3) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_SetTheme_0200 start"; - int testValue = 1; - std::shared_ptr contextDeal = std::make_shared(); - ASSERT_NE(contextDeal, nullptr); - contextDeal->SetTheme(testValue); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_SetTheme_0200 end"; -} - /** * @tc.number: AppExecFwk_ContextDeal_GetPreferencesDir_0100 * @tc.name: GetPreferencesDir @@ -212,179 +113,6 @@ HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetPreferencesDir_0200 GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetPreferencesDir_0200 end"; } -/** - * @tc.number: AppExecFwk_ContextDeal_GetPattern_0100 - * @tc.name: GetPattern - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetPattern is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetPattern_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetPattern_0100 start"; - int testValue = 0; - std::map testList = { - {"Pattern1", "PatternA"}, {"Pattern2", "PatternB"}, {"Pattern3", "PatternC"} }; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - resourceManager->SetPatternById(testValue, testList); - contextDeal->initResourceManager(resourceManager); - contextDeal->SetPattern(testValue); - std::map retVal = contextDeal->GetPattern(); - EXPECT_TRUE((retVal == testList)); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetPattern_0100 end"; -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetTheme_0100 - * @tc.name: GetTheme - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetTheme is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetTheme_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetTheme_0100 start"; - int testValue = 0; - std::map testList = { {"Theme1", "ThemeA"}, {"Theme2", "ThemeB"}, {"Theme3", "ThemeC"} }; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - ASSERT_NE(contextDeal, nullptr); - resourceManager->SetThemeById(testValue, testList); - contextDeal->initResourceManager(resourceManager); - std::map retVal = contextDeal->GetTheme(); - - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetTheme_0100 end"; -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetString_ById_0100 - * @tc.name: GetString - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetString is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetString_ById_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetString_ById_0100 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - int testCount = 0; - std::string testValue = "GetString test"; - resourceManager->SetStringById(testCount, testValue); - contextDeal->initResourceManager(resourceManager); - EXPECT_STREQ(testValue.c_str(), contextDeal->GetString(testCount).c_str()); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetString_ById_0100 end"; -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetStringArray_0100 - * @tc.name: GetStringArray - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetStringArray is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetStringArray_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetStringArray_0100 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - int testCount = 0; - std::vector testValue = { "123", "456", "789" }; - resourceManager->SetStringArrayById(testCount, testValue); - contextDeal->initResourceManager(resourceManager); - std::vector retVal = contextDeal->GetStringArray(testCount); - EXPECT_TRUE((retVal == testValue)); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetStringArray_0100 end"; -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetStringArray_0200 - * @tc.name: GetStringArray - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetStringArray is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetStringArray_0200, Function | MediumTest | Level3) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetStringArray_0200 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - int testCount = 0; - std::vector testValue = { "123", "456", "789" }; - resourceManager->SetStringArrayById(testCount + 1, testValue); - contextDeal->initResourceManager(resourceManager); - std::vector retVal = contextDeal->GetStringArray(testCount); - EXPECT_FALSE((retVal == testValue)); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetStringArray_0200 end"; -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetIntArray_0100 - * @tc.name: GetIntArray - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetIntArray is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetIntArray_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetIntArray_0100 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - int testCount = 0; - std::vector testValue = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; - resourceManager->SetIntArrayById(testCount, testValue); - contextDeal->initResourceManager(resourceManager); - std::vector retVal = contextDeal->GetIntArray(testCount); - EXPECT_TRUE((retVal == testValue)); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetIntArray_0100 end"; -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetIntArray_0200 - * @tc.name: GetIntArray - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetIntArray is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetIntArray_0200, Function | MediumTest | Level3) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetIntArray_0200 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - int testCount = 0; - std::vector testValue = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; - resourceManager->SetIntArrayById(testCount + 1, testValue); - contextDeal->initResourceManager(resourceManager); - std::vector retVal = contextDeal->GetIntArray(testCount); - EXPECT_FALSE((retVal == testValue)); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetIntArray_0200 end"; -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetColor_0100 - * @tc.name: GetColor - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetColor is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetColor_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetColor_0100 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - int testCount = 0; - uint32_t testValue = 1; - const int testVal = static_cast(testValue); - resourceManager->SetColorById(testCount, testValue); - contextDeal->initResourceManager(resourceManager); - EXPECT_EQ(testVal, contextDeal->GetColor(testCount)); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetColor_0100 end"; -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetColor_0200 - * @tc.name: GetColor - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetColor is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetColor_0200, Function | MediumTest | Level3) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetColor_0200 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - int testCount = 0; - uint32_t testValue = 1; - const int testVal = static_cast(testValue); - resourceManager->SetColorById(testCount + 1, testValue); - contextDeal->initResourceManager(resourceManager); - EXPECT_NE(testVal, contextDeal->GetColor(testCount)); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetColor_0200 end"; -} - /** * @tc.number: AppExecFwk_ContextDeal_GetDisplayOrientation_0100 * @tc.name: GetDisplayOrientation @@ -401,27 +129,5 @@ HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetDisplayOrientation_ EXPECT_EQ(testValue, contextDeal->GetDisplayOrientation()); GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetDisplayOrientation_0100 end"; } - -/** - * @tc.number: AppExecFwk_ContextDeal_SetPattern_0100 - * @tc.name: SetPattern - * @tc.desc: Test the attachbasecontext call to verify that the return value of SetPattern is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_SetPattern_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_SetPattern_0100 start"; - std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); - std::shared_ptr contextDeal = std::make_shared(); - int testCount = 0; - std::map testList = { {"123", "abc"}, {"456", "def"} }; - resourceManager->SetPatternById(testCount, testList); - contextDeal->initResourceManager(resourceManager); - contextDeal->SetPattern(testCount); - std::map retVal; - EXPECT_FALSE((retVal == testList)); - retVal = contextDeal->GetPattern(); - EXPECT_TRUE((retVal == testList)); - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_SetPattern_0100 end"; -} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/frameworks_kits_appkit_native_test/context_deal_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/context_deal_test.cpp index c45e7945b39..ec4914c7c95 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/context_deal_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/context_deal_test.cpp @@ -151,37 +151,6 @@ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetApplicationInfo_0100, Functi EXPECT_STREQ(context_->GetApplicationInfo()->bundleName.c_str(), bundleName.c_str()); } -/** - * @tc.number: AppExecFwk_ContextDeal_GetBundleResourcePath_0100 - * @tc.name: GetBundleResourcePath - * @tc.desc: Verify that the GetBundleResourcePath return value is correct. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetBundleResourcePath_0100, Function | MediumTest | Level1) -{ - std::shared_ptr info = std::make_shared(); - std::string resourcePath = "ResourcePath"; - info->resourcePath = resourcePath; - context_->SetAbilityInfo(info); - - EXPECT_STREQ(context_->GetBundleResourcePath().c_str(), resourcePath.c_str()); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetBundleResourcePath_0200 - * @tc.name: GetBundleResourcePath - * @tc.desc: Verify that the GetBundleResourcePath return value is correct. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetBundleResourcePath_0200, Function | MediumTest | Level1) -{ - std::shared_ptr info = std::make_shared(); - std::string resourcePath = "/data/app/el1/bundle/public"; - info->resourcePath = resourcePath; - context_->isCreateBySystemApp_ = true; - context_->SetAbilityInfo(info); - - EXPECT_STREQ(context_->GetBundleResourcePath().c_str(), Constants::LOCAL_BUNDLES); -} - /** * @tc.number: AppExecFwk_ContextDeal_GetAbilityManager_0100 * @tc.name: GetAbilityManager @@ -218,7 +187,7 @@ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetDatabaseDir_0200, Function | std::shared_ptr info = std::make_shared(); std::string dir = "dataBaseDir"; info->dataBaseDir = dir; - context_->flags_ = ContextDeal::CONTEXT_CREATE_BY_SYSTEM_APP; + context_->SetSystemAppFlag(true); context_->SetApplicationInfo(info); EXPECT_STREQ(context_->GetDatabaseDir().c_str(), "/data/app/el2/0/database/"); @@ -440,8 +409,8 @@ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetHapModuleInfo_0200, Function */ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_IsCreateBySystemApp_0100, Function | MediumTest | Level1) { - context_->flags_ = 0; - EXPECT_FALSE(context_->IsCreateBySystemApp()); + context_->SetSystemAppFlag(false); + EXPECT_FALSE(context_->isCreateBySystemApp_); } /** @@ -451,8 +420,8 @@ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_IsCreateBySystemApp_0100, Funct */ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_IsCreateBySystemApp_0200, Function | MediumTest | Level1) { - context_->flags_ = ContextDeal::CONTEXT_CREATE_BY_SYSTEM_APP; - EXPECT_TRUE(context_->IsCreateBySystemApp()); + context_->SetSystemAppFlag(true); + EXPECT_TRUE(context_->isCreateBySystemApp_); } /** @@ -472,59 +441,10 @@ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetBaseDir_0100, Function | Med */ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetBaseDir_0200, Function | MediumTest | Level1) { - context_->flags_ = ContextDeal::CONTEXT_CREATE_BY_SYSTEM_APP; + context_->SetSystemAppFlag(true); EXPECT_FALSE(context_->GetBaseDir().empty()); } -/** - * @tc.number: AppExecFwk_ContextDeal_GetColorMode_0100 - * @tc.name: GetColorMode - * @tc.desc: Verify that the GetColorMode return value is AUTO. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetColorMode_0100, Function | MediumTest | Level1) -{ - EXPECT_EQ(context_->GetColorMode(), static_cast(AppExecFwk::ModuleColorMode::AUTO)); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetColorMode_0200 - * @tc.name: GetColorMode - * @tc.desc: Verify that the GetColorMode return value is not DARK. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetColorMode_0200, Function | MediumTest | Level1) -{ - context_->hapModuleInfoLocal_ = std::make_shared(); - context_->hapModuleInfoLocal_->colorMode = AppExecFwk::ModuleColorMode::DARK; - EXPECT_EQ(context_->GetColorMode(), static_cast(AppExecFwk::ModuleColorMode::DARK)); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_SetColorMode_0100 - * @tc.name: SetColorMode - * @tc.desc: Verify that the SetColorMode return value is not DARK. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_SetColorMode_0100, Function | MediumTest | Level1) -{ - context_->SetColorMode(static_cast(AppExecFwk::ModuleColorMode::DARK)); - EXPECT_NE(context_->GetColorMode(), static_cast(AppExecFwk::ModuleColorMode::DARK)); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_SetColorMode_0200 - * @tc.name: SetColorMode - * @tc.desc: Verify that the SetColorMode return value is correct. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_SetColorMode_0200, Function | MediumTest | Level1) -{ - context_->hapModuleInfoLocal_ = std::make_shared(); - context_->SetColorMode(static_cast(AppExecFwk::ModuleColorMode::DARK)); - EXPECT_EQ(context_->GetColorMode(), static_cast(AppExecFwk::ModuleColorMode::DARK)); - context_->SetColorMode(static_cast(AppExecFwk::ModuleColorMode::LIGHT)); - EXPECT_EQ(context_->GetColorMode(), static_cast(AppExecFwk::ModuleColorMode::LIGHT)); - context_->SetColorMode(static_cast(AppExecFwk::ModuleColorMode::AUTO)); - EXPECT_EQ(context_->GetColorMode(), static_cast(AppExecFwk::ModuleColorMode::AUTO)); -} - /** * @tc.number: AppExecFwk_ContextDeal_GetDisplayOrientation_0100 * @tc.name: GetDisplayOrientation @@ -538,50 +458,6 @@ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetDisplayOrientation_0100, Fun EXPECT_EQ(context_->GetDisplayOrientation(), static_cast(DisplayOrientation::LANDSCAPE)); } -/** - * @tc.number: AppExecFwk_ContextDeal_GetDisplayOrientation_0200 - * @tc.name: GetDisplayOrientation - * @tc.desc: Verify that the GetDisplayOrientation return value is -1. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetDisplayOrientation_0200, Function | MediumTest | Level1) -{ - context_->hapModuleInfoLocal_ = std::make_shared(); - EXPECT_EQ(context_->GetThemeId(), -1); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetThemeId_0200 - * @tc.name: GetThemeId - * @tc.desc: Verify that the GetThemeId return value is -1. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetThemeId_0200, Function | MediumTest | Level1) -{ - EXPECT_EQ(context_->GetThemeId(), -1); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetTheme_0100 - * @tc.name: GetTheme - * @tc.desc: Verify that the GetTheme return value is empty. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetTheme_0100, Function | MediumTest | Level1) -{ - auto resulft = context_->GetTheme(); - EXPECT_TRUE(resulft.empty()); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetTheme_0200 - * @tc.name: GetTheme - * @tc.desc: Verify that the GetTheme return value is not empty. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetTheme_0200, Function | MediumTest | Level1) -{ - context_->theme_.emplace("TestKey", "TestValue"); - auto resulft = context_->GetTheme(); - EXPECT_FALSE(resulft.empty()); -} - /** * @tc.number: AppExecFwk_ContextDeal_GetCurrentAccountId_0100 * @tc.name: GetCurrentAccountId @@ -618,121 +494,6 @@ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_initResourceManager_0100, Funct context_->initResourceManager(resMgr); } -/** - * @tc.number: AppExecFwk_ContextDeal_SetPattern_0100 - * @tc.name: SetPattern - * @tc.desc: Verify that the SetPattern execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_SetPattern_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - constexpr int32_t patternId = 0; - context_->SetPattern(patternId); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_SetPattern_0200 - * @tc.name: SetPattern - * @tc.desc: Verify that the SetPattern execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_SetPattern_0200, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - const std::shared_ptr resMgr(Global::Resource::CreateResourceManager()); - context_->initResourceManager(resMgr); - constexpr int32_t patternId = 0; - context_->SetPattern(patternId); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetString_0100 - * @tc.name: GetString - * @tc.desc: Verify that the GetString execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetString_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - constexpr int32_t resId = 0; - - EXPECT_TRUE(context_->GetString(resId) == std::string("")); - - const std::shared_ptr resMgr(Global::Resource::CreateResourceManager()); - context_->initResourceManager(resMgr); - EXPECT_TRUE(context_->GetString(resId) == std::string("")); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetStringArray_0100 - * @tc.name: GetStringArray - * @tc.desc: Verify that the GetStringArray execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetStringArray_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - constexpr int32_t resId = 0; - - auto resArray1 = context_->GetStringArray(resId); - EXPECT_TRUE(resArray1.empty()); - - const std::shared_ptr resMgr(Global::Resource::CreateResourceManager()); - context_->initResourceManager(resMgr); - auto resArray2 = context_->GetStringArray(resId); - EXPECT_TRUE(resArray2.empty()); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetIntArray_0100 - * @tc.name: GetIntArray - * @tc.desc: Verify that the GetIntArray execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetIntArray_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - constexpr int32_t resId = 0; - - auto resArray1 = context_->GetIntArray(resId); - EXPECT_TRUE(resArray1.empty()); - - const std::shared_ptr resMgr(Global::Resource::CreateResourceManager()); - context_->initResourceManager(resMgr); - auto resArray2 = context_->GetIntArray(resId); - EXPECT_TRUE(resArray2.empty()); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_SetTheme_0100 - * @tc.name: SetTheme - * @tc.desc: Verify that the SetTheme execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_SetTheme_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - constexpr int32_t themeId = 0; - - context_->SetTheme(themeId); - - const std::shared_ptr resMgr(Global::Resource::CreateResourceManager()); - context_->initResourceManager(resMgr); - context_->SetTheme(themeId); -} - -/** - * @tc.number: AppExecFwk_ContextDeal_GetPattern_0100 - * @tc.name: GetPattern - * @tc.desc: Verify that the GetPattern execute normally. - */ -HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetPattern_0100, Function | MediumTest | Level1) -{ - EXPECT_TRUE(context_ != nullptr); - - auto resMap1 = context_->GetPattern(); - EXPECT_TRUE(resMap1.empty()); - - context_->pattern_.emplace("abc", "ABC"); - auto resMap2 = context_->GetPattern(); - EXPECT_FALSE(resMap2.empty()); -} - /** * @tc.number: AppExecFwk_ContextDeal_GetPreferencesDir_0100 * @tc.name: GetPreferencesDir -- Gitee