mirror of
https://gitee.com/openharmony/filemanagement_user_file_service
synced 2024-11-26 17:10:55 +00:00
commit
576a0f148c
@ -32,7 +32,6 @@ ohos_unittest("medialibrary_file_access_test") {
|
||||
include_dirs = [
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
|
||||
"${user_file_service_path}/interfaces/inner_api/file_access/include",
|
||||
"//third_party/googletest/googlemock/include/gmock",
|
||||
"${access_token_path}/frameworks/accesstoken:accesstoken_communication_adapter_cxx/",
|
||||
]
|
||||
|
||||
@ -42,7 +41,6 @@ ohos_unittest("medialibrary_file_access_test") {
|
||||
"${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
|
||||
"${ability_runtime_path}/frameworks/native/appkit:app_context",
|
||||
"${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
|
||||
"//third_party/googletest:gmock_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
@ -57,6 +55,8 @@ ohos_unittest("medialibrary_file_access_test") {
|
||||
"access_token:libnativetoken",
|
||||
"access_token:libtoken_setproc",
|
||||
"c_utils:utils",
|
||||
"googletest:gmock_main",
|
||||
"googletest:gtest_main",
|
||||
"ipc:ipc_core",
|
||||
"ipc:rpc",
|
||||
"samgr:samgr_proxy",
|
||||
@ -84,7 +84,6 @@ ohos_unittest("external_file_access_basic_test") {
|
||||
|
||||
include_dirs = [
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
|
||||
"//third_party/googletest/googlemock/include/gmock",
|
||||
"${user_file_service_path}/interfaces/inner_api/file_access/include",
|
||||
"${user_file_service_path}/services/native/file_access_service/include",
|
||||
]
|
||||
@ -96,7 +95,6 @@ ohos_unittest("external_file_access_basic_test") {
|
||||
"${ability_runtime_path}/frameworks/native/appkit:app_context",
|
||||
"${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
|
||||
"${user_file_service_path}/services:file_access_service",
|
||||
"//third_party/googletest:gmock_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
@ -112,6 +110,8 @@ ohos_unittest("external_file_access_basic_test") {
|
||||
"access_token:libtoken_setproc",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"googletest:gmock_main",
|
||||
"googletest:gtest_main",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:rpc",
|
||||
@ -139,7 +139,6 @@ ohos_unittest("external_file_access_management_test") {
|
||||
|
||||
include_dirs = [
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
|
||||
"//third_party/googletest/googlemock/include/gmock",
|
||||
"${user_file_service_path}/interfaces/inner_api/file_access/include",
|
||||
"${user_file_service_path}/services/native/file_access_service/include",
|
||||
]
|
||||
@ -151,7 +150,6 @@ ohos_unittest("external_file_access_management_test") {
|
||||
"${ability_runtime_path}/frameworks/native/appkit:app_context",
|
||||
"${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
|
||||
"${user_file_service_path}/services:file_access_service",
|
||||
"//third_party/googletest:gmock_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
@ -167,6 +165,8 @@ ohos_unittest("external_file_access_management_test") {
|
||||
"access_token:libtoken_setproc",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"googletest:gmock_main",
|
||||
"googletest:gtest_main",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:rpc",
|
||||
@ -190,7 +190,6 @@ ohos_unittest("external_file_access_notify_test") {
|
||||
|
||||
include_dirs = [
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
|
||||
"//third_party/googletest/googlemock/include/gmock",
|
||||
"${user_file_service_path}/interfaces/inner_api/file_access/include",
|
||||
"${user_file_service_path}/services/native/file_access_service/include",
|
||||
]
|
||||
@ -202,7 +201,6 @@ ohos_unittest("external_file_access_notify_test") {
|
||||
"${ability_runtime_path}/frameworks/native/appkit:app_context",
|
||||
"${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
|
||||
"${user_file_service_path}/services:file_access_service",
|
||||
"//third_party/googletest:gmock_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
@ -218,6 +216,8 @@ ohos_unittest("external_file_access_notify_test") {
|
||||
"access_token:libtoken_setproc",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"googletest:gmock_main",
|
||||
"googletest:gtest_main",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:rpc",
|
||||
@ -239,7 +239,6 @@ ohos_unittest("abnormal_file_access_test") {
|
||||
|
||||
include_dirs = [
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context",
|
||||
"//third_party/googletest/googlemock/include/gmock",
|
||||
"${user_file_service_path}/interfaces/inner_api/file_access/include",
|
||||
]
|
||||
|
||||
@ -249,7 +248,6 @@ ohos_unittest("abnormal_file_access_test") {
|
||||
"${ability_runtime_path}/frameworks/native/ability/native:abilitykit_native",
|
||||
"${ability_runtime_path}/frameworks/native/appkit:app_context",
|
||||
"${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
|
||||
"//third_party/googletest:gmock_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
@ -265,6 +263,8 @@ ohos_unittest("abnormal_file_access_test") {
|
||||
"access_token:libtoken_setproc",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"googletest:gmock_main",
|
||||
"googletest:gtest_main",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"samgr:samgr_proxy",
|
||||
@ -289,7 +289,6 @@ ohos_unittest("file_access_ext_stub_impl_test") {
|
||||
"${user_file_service_path}/interfaces/inner_api/file_access/include",
|
||||
"${user_file_service_path}/interfaces/kits/js/src/common",
|
||||
"${user_file_service_path}/utils",
|
||||
"//third_party/googletest/googlemock/include/gmock",
|
||||
"mock",
|
||||
]
|
||||
|
||||
@ -298,8 +297,6 @@ ohos_unittest("file_access_ext_stub_impl_test") {
|
||||
"file_access_ext_stub_impl_test.cpp",
|
||||
]
|
||||
|
||||
deps = [ "//third_party/googletest:gmock_main" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:app_context",
|
||||
@ -307,6 +304,8 @@ ohos_unittest("file_access_ext_stub_impl_test") {
|
||||
"ability_runtime:napi_common",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"googletest:gmock_main",
|
||||
"googletest:gtest_main",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
@ -333,7 +332,6 @@ ohos_unittest("file_access_service_proxy_test") {
|
||||
"${user_file_service_path}/services/native/file_access_service/include",
|
||||
"${user_file_service_path}/interfaces/kits/js/src/common",
|
||||
"${user_file_service_path}/utils",
|
||||
"//third_party/googletest/googlemock/include/gmock",
|
||||
"mock",
|
||||
]
|
||||
|
||||
@ -344,17 +342,14 @@ ohos_unittest("file_access_service_proxy_test") {
|
||||
"mock/service_registry_mock.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:ability_manager",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"googletest:gmock_main",
|
||||
"googletest:gtest_main",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"image_framework:image",
|
||||
@ -388,7 +383,6 @@ ohos_unittest("js_file_access_ext_ability_test") {
|
||||
"${user_file_service_path}/interfaces/kits/js/src/common",
|
||||
"${user_file_service_path}/services/native/file_access_service/include",
|
||||
"${user_file_service_path}/utils",
|
||||
"//third_party/googletest/googlemock/include/gmock",
|
||||
"mock",
|
||||
]
|
||||
|
||||
@ -399,11 +393,7 @@ ohos_unittest("js_file_access_ext_ability_test") {
|
||||
"mock/js_native_api_mock.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit",
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
deps = [ "${user_file_service_path}/interfaces/inner_api/file_access:file_access_extension_ability_kit" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
@ -415,6 +405,8 @@ ohos_unittest("js_file_access_ext_ability_test") {
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"googletest:gmock_main",
|
||||
"googletest:gtest_main",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"init:libbegetutil",
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "file_access_service_mock.h"
|
||||
#include "if_system_ability_manager_mock.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "message_parcel_mock.h"
|
||||
|
||||
int32_t OHOS::SystemAbilityLoadCallbackStub::OnRemoteRequest(unsigned int, OHOS::MessageParcel&, OHOS::MessageParcel&,
|
||||
OHOS::MessageOption&)
|
||||
@ -53,25 +54,50 @@ public:
|
||||
MOCK_METHOD0(AsObject, sptr<IRemoteObject>());
|
||||
};
|
||||
|
||||
class AbilityConnectionMock : public OHOS::AAFwk::IAbilityConnection {
|
||||
public:
|
||||
AbilityConnectionMock() = default;
|
||||
~AbilityConnectionMock() = default;
|
||||
public:
|
||||
void OnAbilityConnectDone(const AppExecFwk::ElementName&, const sptr<IRemoteObject>&, int) override {}
|
||||
void OnAbilityDisconnectDone(const AppExecFwk::ElementName&, int) override {}
|
||||
MOCK_METHOD0(AsObject, sptr<IRemoteObject>());
|
||||
};
|
||||
|
||||
class TestObject : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.FileAccessFwk.TestObject");
|
||||
};
|
||||
|
||||
class RemoteObjectMock : public IRemoteStub<TestObject> {
|
||||
public:
|
||||
RemoteObjectMock() = default;
|
||||
~RemoteObjectMock() = default;
|
||||
};
|
||||
|
||||
class FileAccessServiceProxyTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void)
|
||||
{
|
||||
Assistant::ins_ = insMoc;
|
||||
MessageParcelMock::messageParcel = msg;
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = sptr<ISystemAbilityManager>(samgr.get());
|
||||
}
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
insMoc = nullptr;
|
||||
msg = nullptr;
|
||||
samgr = nullptr;
|
||||
impl = nullptr;
|
||||
Assistant::ins_ = nullptr;
|
||||
MessageParcelMock::messageParcel = nullptr;
|
||||
SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
|
||||
}
|
||||
void SetUp() {}
|
||||
void TearDown() {}
|
||||
public:
|
||||
static inline shared_ptr<AssistantMock> insMoc = make_shared<AssistantMock>();
|
||||
static inline shared_ptr<MessageParcelMock> msg = make_shared<MessageParcelMock>();
|
||||
static inline sptr<FileAccessServiceMock> impl = sptr<FileAccessServiceMock>(new FileAccessServiceMock());
|
||||
static inline shared_ptr<ISystemAbilityManagerMock> samgr = make_shared<ISystemAbilityManagerMock>();
|
||||
};
|
||||
@ -170,33 +196,51 @@ HWTEST_F(FileAccessServiceProxyTest, file_access_service_proxy_OnChange_0000, te
|
||||
try {
|
||||
shared_ptr<FileAccessServiceProxy> proxy = make_shared<FileAccessServiceProxy>(impl);
|
||||
|
||||
Uri uri("");
|
||||
NotifyType notifyType = NotifyType::NOTIFY_ADD;
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(false));
|
||||
auto result = proxy->OnChange(uri, notifyType);
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(false));
|
||||
auto result = proxy->OnChange(Uri(""), NotifyType::NOTIFY_ADD);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(false));
|
||||
result = proxy->OnChange(uri, notifyType);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(false));
|
||||
result = proxy->OnChange(Uri(""), NotifyType::NOTIFY_ADD);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
|
||||
result = proxy->OnChange(uri, notifyType);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteInt32(_)).WillOnce(Return(false));
|
||||
result = proxy->OnChange(Uri(""), NotifyType::NOTIFY_ADD);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteInt32(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(E_URIS));
|
||||
result = proxy->OnChange(uri, notifyType);
|
||||
result = proxy->OnChange(Uri(""), NotifyType::NOTIFY_ADD);
|
||||
EXPECT_EQ(result, E_URIS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true))
|
||||
.WillOnce(Return(false));
|
||||
EXPECT_CALL(*insMoc, Int()).WillOnce(Return(ERR_OK));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteInt32(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
result = proxy->OnChange(uri, notifyType);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true))
|
||||
.WillOnce(Return(true));
|
||||
EXPECT_CALL(*insMoc, Int()).WillOnce(Return(E_IPCS));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
result = proxy->OnChange(uri, notifyType);
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(Return(false));
|
||||
result = proxy->OnChange(Uri(""), NotifyType::NOTIFY_ADD);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteInt32(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(Return(true));
|
||||
result = proxy->OnChange(Uri(""), NotifyType::NOTIFY_ADD);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteInt32(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(DoAll(SetArgReferee<0>(ERR_OK), Return(true)));
|
||||
result = proxy->OnChange(Uri(""), NotifyType::NOTIFY_ADD);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
} catch (...) {
|
||||
GTEST_LOG_(ERROR) << "FileAccessServiceProxyTest occurs an exception.";
|
||||
}
|
||||
@ -222,48 +266,148 @@ HWTEST_F(FileAccessServiceProxyTest, file_access_service_proxy_RegisterNotify_00
|
||||
bool notifyForDescendants = false;
|
||||
shared_ptr<ConnectExtensionInfo> info = nullptr;
|
||||
sptr<IFileAccessObserverMock> observer = sptr<IFileAccessObserverMock>(new IFileAccessObserverMock());
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(false));
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(false));
|
||||
auto result = proxy->RegisterNotify(uri, notifyForDescendants, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(false));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(false));
|
||||
result = proxy->RegisterNotify(uri, notifyForDescendants, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
|
||||
|
||||
sptr<IFileAccessObserver> obs = nullptr;
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
result = proxy->RegisterNotify(uri, notifyForDescendants, obs, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*observer, AsObject()).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(false));
|
||||
result = proxy->RegisterNotify(uri, notifyForDescendants, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true))
|
||||
.WillOnce(Return(false));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*observer, AsObject()).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(false));
|
||||
result = proxy->RegisterNotify(uri, notifyForDescendants, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true))
|
||||
.WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*observer, AsObject()).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(E_URIS));
|
||||
shared_ptr<ConnectExtensionInfo> info2 = make_shared<ConnectExtensionInfo>();
|
||||
result = proxy->RegisterNotify(uri, notifyForDescendants, observer, info2);
|
||||
EXPECT_EQ(result, E_URIS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true))
|
||||
.WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*insMoc, Int()).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*observer, AsObject()).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
result = proxy->RegisterNotify(uri, notifyForDescendants, observer, info2);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true))
|
||||
.WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*insMoc, Int()).WillOnce(Return(E_IPCS));
|
||||
EXPECT_CALL(*observer, AsObject()).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
result = proxy->RegisterNotify(uri, notifyForDescendants, observer, info2);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(true));
|
||||
result = proxy->RegisterNotify(uri, notifyForDescendants, observer, info);
|
||||
EXPECT_EQ(result, E_GETINFO);
|
||||
} catch (...) {
|
||||
GTEST_LOG_(ERROR) << "FileAccessServiceProxyTest occurs an exception.";
|
||||
}
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-end file_access_service_proxy_RegisterNotify_0000";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: user_file_service_file_access_service_proxy_RegisterNotify_0100
|
||||
* @tc.name: file_access_service_proxy_RegisterNotify_0100
|
||||
* @tc.desc: Test function of RegisterNotify interface for ERROR.
|
||||
* @tc.size: MEDIUM
|
||||
* @tc.type: FUNC
|
||||
* @tc.level Level 3
|
||||
* @tc.require: issuesI8Y05B
|
||||
*/
|
||||
HWTEST_F(FileAccessServiceProxyTest, file_access_service_proxy_RegisterNotify_0100, testing::ext::TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-begin file_access_service_proxy_RegisterNotify_0100";
|
||||
try {
|
||||
shared_ptr<FileAccessServiceProxy> proxy = make_shared<FileAccessServiceProxy>(impl);
|
||||
|
||||
Uri uri("");
|
||||
bool notifyForDescendants = false;
|
||||
shared_ptr<ConnectExtensionInfo> info = make_shared<ConnectExtensionInfo>();
|
||||
sptr<IFileAccessObserverMock> observer = sptr<IFileAccessObserverMock>(new IFileAccessObserverMock());
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true)).WillOnce(Return(false));
|
||||
EXPECT_CALL(*observer, AsObject()).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(true));
|
||||
auto result = proxy->RegisterNotify(uri, notifyForDescendants, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*observer, AsObject()).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true))
|
||||
.WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(E_URIS));
|
||||
result = proxy->RegisterNotify(uri, notifyForDescendants, observer, info);
|
||||
EXPECT_EQ(result, E_URIS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*observer, AsObject()).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true))
|
||||
.WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(Return(false));
|
||||
result = proxy->RegisterNotify(uri, notifyForDescendants, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
} catch (...) {
|
||||
GTEST_LOG_(ERROR) << "FileAccessServiceProxyTest occurs an exception.";
|
||||
}
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-end file_access_service_proxy_RegisterNotify_0100";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: user_file_service_file_access_service_proxy_RegisterNotify_0200
|
||||
* @tc.name: file_access_service_proxy_RegisterNotify_0200
|
||||
* @tc.desc: Test function of RegisterNotify interface for ERROR.
|
||||
* @tc.size: MEDIUM
|
||||
* @tc.type: FUNC
|
||||
* @tc.level Level 3
|
||||
* @tc.require: issuesI8Y05B
|
||||
*/
|
||||
HWTEST_F(FileAccessServiceProxyTest, file_access_service_proxy_RegisterNotify_0200, testing::ext::TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-begin file_access_service_proxy_RegisterNotify_0100";
|
||||
try {
|
||||
shared_ptr<FileAccessServiceProxy> proxy = make_shared<FileAccessServiceProxy>(impl);
|
||||
|
||||
Uri uri("");
|
||||
bool notifyForDescendants = false;
|
||||
shared_ptr<ConnectExtensionInfo> info = make_shared<ConnectExtensionInfo>();
|
||||
sptr<IFileAccessObserverMock> observer = sptr<IFileAccessObserverMock>(new IFileAccessObserverMock());
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*observer, AsObject()).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true))
|
||||
.WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(Return(true));
|
||||
auto result = proxy->RegisterNotify(uri, notifyForDescendants, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*observer, AsObject()).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true))
|
||||
.WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(DoAll(SetArgReferee<0>(ERR_OK), Return(true)));
|
||||
result = proxy->RegisterNotify(uri, notifyForDescendants, observer, info);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
} catch (...) {
|
||||
GTEST_LOG_(ERROR) << "FileAccessServiceProxyTest occurs an exception.";
|
||||
}
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-end file_access_service_proxy_RegisterNotify_0200";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: user_file_service_file_access_service_proxy_UnregisterNotifyInternal_0000
|
||||
* @tc.name: file_access_service_proxy_UnregisterNotifyInternal_0000
|
||||
@ -284,16 +428,21 @@ HWTEST_F(FileAccessServiceProxyTest, file_access_service_proxy_UnregisterNotifyI
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(E_URIS));
|
||||
auto result = proxy->UnregisterNotifyInternal(data);
|
||||
EXPECT_EQ(result, E_URIS);
|
||||
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(false));
|
||||
EXPECT_CALL(*insMoc, Int()).WillOnce(Return(ERR_OK));
|
||||
result = proxy->UnregisterNotifyInternal(data);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true));
|
||||
EXPECT_CALL(*insMoc, Int()).WillOnce(Return(E_IPCS));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(Return(false));
|
||||
result = proxy->UnregisterNotifyInternal(data);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(Return(true));
|
||||
result = proxy->UnregisterNotifyInternal(data);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(DoAll(SetArgReferee<0>(ERR_OK), Return(true)));
|
||||
result = proxy->UnregisterNotifyInternal(data);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
} catch (...) {
|
||||
GTEST_LOG_(ERROR) << "FileAccessServiceProxyTest occurs an exception.";
|
||||
}
|
||||
@ -318,33 +467,299 @@ HWTEST_F(FileAccessServiceProxyTest, file_access_service_proxy_UnregisterNotify_
|
||||
Uri uri("");
|
||||
sptr<IFileAccessObserverMock> observer = nullptr;
|
||||
shared_ptr<ConnectExtensionInfo> info = nullptr;
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(false));
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(false));
|
||||
auto result = proxy->UnregisterNotify(uri, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(false));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(false));
|
||||
result = proxy->UnregisterNotify(uri, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(false));
|
||||
result = proxy->UnregisterNotify(uri, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(true));
|
||||
result = proxy->UnregisterNotify(uri, observer, info);
|
||||
EXPECT_EQ(result, E_GETINFO);
|
||||
|
||||
observer = sptr<IFileAccessObserverMock>(new IFileAccessObserverMock());
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(false));
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(false));
|
||||
result = proxy->UnregisterNotify(uri, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true))
|
||||
.WillOnce(Return(false));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*observer, AsObject()).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(false));
|
||||
result = proxy->UnregisterNotify(uri, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true))
|
||||
.WillOnce(Return(false));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*observer, AsObject()).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
result = proxy->UnregisterNotify(uri, observer, info);
|
||||
EXPECT_EQ(result, E_GETINFO);
|
||||
} catch (...) {
|
||||
GTEST_LOG_(ERROR) << "FileAccessServiceProxyTest occurs an exception.";
|
||||
}
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-end file_access_service_proxy_UnregisterNotify_0000";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: user_file_service_file_access_service_proxy_ConnectFileExtAbility_0000
|
||||
* @tc.name: file_access_service_proxy_ConnectFileExtAbility_0000
|
||||
* @tc.desc: Test function of ConnectFileExtAbility interface for ERROR.
|
||||
* @tc.size: MEDIUM
|
||||
* @tc.type: FUNC
|
||||
* @tc.level Level 3
|
||||
* @tc.require: issuesI8Y05B
|
||||
*/
|
||||
HWTEST_F(FileAccessServiceProxyTest, file_access_service_proxy_ConnectFileExtAbility_0000,
|
||||
testing::ext::TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-begin file_access_service_proxy_ConnectFileExtAbility_0000";
|
||||
try {
|
||||
shared_ptr<FileAccessServiceProxy> proxy = make_shared<FileAccessServiceProxy>(impl);
|
||||
AAFwk::Want want;
|
||||
sptr<AbilityConnectionMock> connection = nullptr;
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(false));
|
||||
auto result = proxy->ConnectFileExtAbility(want, connection);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(false));
|
||||
result = proxy->ConnectFileExtAbility(want, connection);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
result = proxy->ConnectFileExtAbility(want, connection);
|
||||
EXPECT_EQ(result, E_GETINFO);
|
||||
|
||||
connection = sptr<AbilityConnectionMock>(new AbilityConnectionMock());
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*connection, AsObject()).WillOnce(Return(nullptr));
|
||||
result = proxy->ConnectFileExtAbility(want, connection);
|
||||
EXPECT_EQ(result, E_GETINFO);
|
||||
|
||||
auto obj = sptr(new (std::nothrow) RemoteObjectMock());
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*connection, AsObject()).WillOnce(Return(obj)).WillOnce(Return(obj));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(false));
|
||||
result = proxy->ConnectFileExtAbility(want, connection);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
} catch (...) {
|
||||
GTEST_LOG_(ERROR) << "FileAccessServiceProxyTest occurs an exception.";
|
||||
}
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-end file_access_service_proxy_ConnectFileExtAbility_0000";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: user_file_service_file_access_service_proxy_ConnectFileExtAbility_0100
|
||||
* @tc.name: file_access_service_proxy_ConnectFileExtAbility_0100
|
||||
* @tc.desc: Test function of ConnectFileExtAbility interface for ERROR.
|
||||
* @tc.size: MEDIUM
|
||||
* @tc.type: FUNC
|
||||
* @tc.level Level 3
|
||||
* @tc.require: issuesI8Y05B
|
||||
*/
|
||||
HWTEST_F(FileAccessServiceProxyTest, file_access_service_proxy_ConnectFileExtAbility_0100,
|
||||
testing::ext::TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-begin file_access_service_proxy_ConnectFileExtAbility_0000";
|
||||
try {
|
||||
shared_ptr<FileAccessServiceProxy> proxy = make_shared<FileAccessServiceProxy>(impl);
|
||||
AAFwk::Want want;
|
||||
sptr<AbilityConnectionMock> connection = sptr<AbilityConnectionMock>(new AbilityConnectionMock());
|
||||
auto obj = sptr(new (std::nothrow) RemoteObjectMock());
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*connection, AsObject()).WillOnce(Return(obj)).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(E_IPCS));
|
||||
auto result = proxy->ConnectFileExtAbility(want, connection);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*connection, AsObject()).WillOnce(Return(obj)).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(DoAll(Return(false)));
|
||||
result = proxy->ConnectFileExtAbility(want, connection);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*connection, AsObject()).WillOnce(Return(obj)).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(DoAll(SetArgReferee<0>(E_IPCS), Return(true)));
|
||||
result = proxy->ConnectFileExtAbility(want, connection);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*connection, AsObject()).WillOnce(Return(obj)).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(DoAll(SetArgReferee<0>(ERR_OK), Return(true)));
|
||||
result = proxy->ConnectFileExtAbility(want, connection);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
} catch (...) {
|
||||
GTEST_LOG_(ERROR) << "FileAccessServiceProxyTest occurs an exception.";
|
||||
}
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-end file_access_service_proxy_ConnectFileExtAbility_0100";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: user_file_service_file_access_service_proxy_DisConnectFileExtAbility_0000
|
||||
* @tc.name: file_access_service_proxy_DisConnectFileExtAbility_0000
|
||||
* @tc.desc: Test function of DisConnectFileExtAbility interface for ERROR.
|
||||
* @tc.size: MEDIUM
|
||||
* @tc.type: FUNC
|
||||
* @tc.level Level 3
|
||||
* @tc.require: issuesI8Y05B
|
||||
*/
|
||||
HWTEST_F(FileAccessServiceProxyTest, file_access_service_proxy_DisConnectFileExtAbility_0000,
|
||||
testing::ext::TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-begin file_access_service_proxy_DisConnectFileExtAbility_0000";
|
||||
try {
|
||||
shared_ptr<FileAccessServiceProxy> proxy = make_shared<FileAccessServiceProxy>(impl);
|
||||
sptr<AbilityConnectionMock> connection = nullptr;
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(false));
|
||||
auto result = proxy->DisConnectFileExtAbility(connection);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
result = proxy->DisConnectFileExtAbility(connection);
|
||||
EXPECT_EQ(result, E_GETINFO);
|
||||
|
||||
connection = sptr<AbilityConnectionMock>(new AbilityConnectionMock());
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*connection, AsObject()).WillOnce(Return(nullptr));
|
||||
result = proxy->DisConnectFileExtAbility(connection);
|
||||
EXPECT_EQ(result, E_GETINFO);
|
||||
|
||||
auto obj = sptr(new (std::nothrow) RemoteObjectMock());
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*connection, AsObject()).WillOnce(Return(obj)).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(false));
|
||||
result = proxy->DisConnectFileExtAbility(connection);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*connection, AsObject()).WillOnce(Return(obj)).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(E_IPCS));
|
||||
result = proxy->DisConnectFileExtAbility(connection);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
} catch (...) {
|
||||
GTEST_LOG_(ERROR) << "FileAccessServiceProxyTest occurs an exception.";
|
||||
}
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-end file_access_service_proxy_DisConnectFileExtAbility_0000";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: user_file_service_file_access_service_proxy_DisConnectFileExtAbility_0100
|
||||
* @tc.name: file_access_service_proxy_DisConnectFileExtAbility_0100
|
||||
* @tc.desc: Test function of DisConnectFileExtAbility interface for ERROR.
|
||||
* @tc.size: MEDIUM
|
||||
* @tc.type: FUNC
|
||||
* @tc.level Level 3
|
||||
* @tc.require: issuesI8Y05B
|
||||
*/
|
||||
HWTEST_F(FileAccessServiceProxyTest, file_access_service_proxy_DisConnectFileExtAbility_0100,
|
||||
testing::ext::TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-begin file_access_service_proxy_DisConnectFileExtAbility_0100";
|
||||
try {
|
||||
shared_ptr<FileAccessServiceProxy> proxy = make_shared<FileAccessServiceProxy>(impl);
|
||||
sptr<AbilityConnectionMock> connection = sptr<AbilityConnectionMock>(new AbilityConnectionMock());
|
||||
auto obj = sptr(new (std::nothrow) RemoteObjectMock());
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*connection, AsObject()).WillOnce(Return(obj)).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(DoAll(Return(false)));
|
||||
auto result = proxy->DisConnectFileExtAbility(connection);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*connection, AsObject()).WillOnce(Return(obj)).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(DoAll(SetArgReferee<0>(E_IPCS), Return(true)));
|
||||
result = proxy->DisConnectFileExtAbility(connection);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*connection, AsObject()).WillOnce(Return(obj)).WillOnce(Return(nullptr));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(DoAll(SetArgReferee<0>(ERR_OK), Return(true)));
|
||||
result = proxy->DisConnectFileExtAbility(connection);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
} catch (...) {
|
||||
GTEST_LOG_(ERROR) << "FileAccessServiceProxyTest occurs an exception.";
|
||||
}
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-end file_access_service_proxy_DisConnectFileExtAbility_0100";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: user_file_service_file_access_service_proxy_UnregisterNotify_0100
|
||||
* @tc.name: file_access_service_proxy_UnregisterNotify_0100
|
||||
* @tc.desc: Test function of UnregisterNotify interface for ERROR.
|
||||
* @tc.size: MEDIUM
|
||||
* @tc.type: FUNC
|
||||
* @tc.level Level 3
|
||||
* @tc.require: issuesI8Y05B
|
||||
*/
|
||||
HWTEST_F(FileAccessServiceProxyTest, file_access_service_proxy_UnregisterNotify_0100,
|
||||
testing::ext::TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-begin file_access_service_proxy_UnregisterNotify_0100";
|
||||
try {
|
||||
Uri uri("");
|
||||
sptr<IFileAccessObserverMock> observer = nullptr;
|
||||
shared_ptr<FileAccessServiceProxy> proxy = make_shared<FileAccessServiceProxy>(impl);
|
||||
shared_ptr<ConnectExtensionInfo> info = make_shared<ConnectExtensionInfo>();
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true)).WillOnce(Return(false));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(true));
|
||||
auto result = proxy->UnregisterNotify(uri, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteBool(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(E_IPCS));
|
||||
result = proxy->UnregisterNotify(uri, observer, info);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
} catch (...) {
|
||||
GTEST_LOG_(ERROR) << "FileAccessServiceProxyTest occurs an exception.";
|
||||
}
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-end file_access_service_proxy_UnregisterNotify_0000";
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-end file_access_service_proxy_UnregisterNotify_0100";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -361,39 +776,52 @@ HWTEST_F(FileAccessServiceProxyTest, file_access_service_proxy_GetExensionProxy_
|
||||
GTEST_LOG_(INFO) << "FileAccessServiceProxyTest-begin file_access_service_proxy_GetExensionProxy_0000";
|
||||
try {
|
||||
shared_ptr<FileAccessServiceProxy> proxy = make_shared<FileAccessServiceProxy>(impl);
|
||||
|
||||
shared_ptr<ConnectExtensionInfo> info = nullptr;
|
||||
sptr<IFileAccessExtBase> extensionProxy = nullptr;
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(false));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(false));
|
||||
auto result = proxy->GetExtensionProxy(info, extensionProxy);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
result = proxy->GetExtensionProxy(info, extensionProxy);
|
||||
EXPECT_EQ(result, E_GETINFO);
|
||||
|
||||
info = make_shared<ConnectExtensionInfo>();
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(false));
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(false));
|
||||
result = proxy->GetExtensionProxy(info, extensionProxy);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(E_URIS));
|
||||
result = proxy->GetExtensionProxy(info, extensionProxy);
|
||||
EXPECT_EQ(result, E_URIS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true))
|
||||
.WillOnce(Return(false));
|
||||
EXPECT_CALL(*insMoc, Int()).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
result = proxy->GetExtensionProxy(info, extensionProxy);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true))
|
||||
.WillOnce(Return(true));
|
||||
EXPECT_CALL(*insMoc, Int()).WillOnce(Return(E_IPCS));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(Return(false));
|
||||
result = proxy->GetExtensionProxy(info, extensionProxy);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
EXPECT_CALL(*insMoc, Bool()).WillOnce(Return(true)).WillOnce(Return(true)).WillOnce(Return(true))
|
||||
.WillOnce(Return(true));
|
||||
EXPECT_CALL(*insMoc, Int()).WillOnce(Return(ERR_OK));
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(Return(true));
|
||||
result = proxy->GetExtensionProxy(info, extensionProxy);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
|
||||
EXPECT_CALL(*msg, WriteInterfaceToken(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteParcelable(_)).WillOnce(Return(true));
|
||||
EXPECT_CALL(*msg, WriteRemoteObject(An<const sptr<IRemoteObject>&>())).WillOnce(Return(true));
|
||||
EXPECT_CALL(*impl, SendRequest(_, _, _, _)).WillOnce(Return(ERR_OK));
|
||||
EXPECT_CALL(*msg, ReadInt32(_)).WillOnce(DoAll(SetArgReferee<0>(ERR_OK), Return(true)));
|
||||
EXPECT_CALL(*msg, ReadRemoteObject()).WillOnce(Return(nullptr));
|
||||
result = proxy->GetExtensionProxy(info, extensionProxy);
|
||||
EXPECT_EQ(result, E_IPCS);
|
||||
} catch (...) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@ -12,10 +12,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "assistant.h"
|
||||
#include "message_parcel.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "iremote_broker.h"
|
||||
#include "message_parcel_mock.h"
|
||||
|
||||
namespace OHOS {
|
||||
using namespace OHOS::FileAccessFwk;
|
||||
@ -31,42 +29,91 @@ Parcelable::Parcelable(bool asRemote)
|
||||
|
||||
bool MessageParcel::WriteInterfaceToken(std::u16string name)
|
||||
{
|
||||
return Assistant::ins_->Bool();
|
||||
return UMessageParcel::messageParcel->WriteInterfaceToken(name);
|
||||
}
|
||||
|
||||
std::u16string MessageParcel::ReadInterfaceToken()
|
||||
{
|
||||
return UMessageParcel::messageParcel->ReadInterfaceToken();
|
||||
}
|
||||
|
||||
bool Parcel::WriteParcelable(const Parcelable *object)
|
||||
{
|
||||
return Assistant::ins_->Bool();
|
||||
return UMessageParcel::messageParcel->WriteParcelable(object);
|
||||
}
|
||||
|
||||
bool Parcel::WriteInt32(int32_t value)
|
||||
{
|
||||
return Assistant::ins_->Bool();
|
||||
return UMessageParcel::messageParcel->WriteInt32(value);
|
||||
}
|
||||
|
||||
int32_t Parcel::ReadInt32()
|
||||
{
|
||||
return Assistant::ins_->Bool();
|
||||
return UMessageParcel::messageParcel->ReadInt32();
|
||||
}
|
||||
|
||||
bool Parcel::ReadInt32(int32_t &value)
|
||||
{
|
||||
value = Assistant::ins_->Int();
|
||||
return Assistant::ins_->Bool();
|
||||
return UMessageParcel::messageParcel->ReadInt32(value);
|
||||
}
|
||||
|
||||
bool Parcel::WriteRemoteObject(const Parcelable *object)
|
||||
{
|
||||
return Assistant::ins_->Bool();
|
||||
return UMessageParcel::messageParcel->WriteRemoteObject(object);
|
||||
}
|
||||
|
||||
bool MessageParcel::WriteRemoteObject(const sptr<IRemoteObject> &object)
|
||||
{
|
||||
return Assistant::ins_->Bool();
|
||||
return UMessageParcel::messageParcel->WriteRemoteObject(object);
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> MessageParcel::ReadRemoteObject()
|
||||
{
|
||||
return UMessageParcel::messageParcel->ReadRemoteObject();
|
||||
}
|
||||
|
||||
bool Parcel::ReadBool()
|
||||
{
|
||||
return UMessageParcel::messageParcel->ReadBool();
|
||||
}
|
||||
|
||||
bool Parcel::ReadBool(bool &value)
|
||||
{
|
||||
return UMessageParcel::messageParcel->ReadBool(value);
|
||||
}
|
||||
|
||||
bool Parcel::WriteBool(bool value)
|
||||
{
|
||||
return Assistant::ins_->Bool();
|
||||
return UMessageParcel::messageParcel->WriteBool(value);
|
||||
}
|
||||
|
||||
bool Parcel::WriteString(const std::string &value)
|
||||
{
|
||||
return UMessageParcel::messageParcel->WriteString(value);
|
||||
}
|
||||
|
||||
bool Parcel::ReadString(std::string &value)
|
||||
{
|
||||
return UMessageParcel::messageParcel->ReadString(value);
|
||||
}
|
||||
|
||||
bool Parcel::ReadStringVector(std::vector<std::string> *value)
|
||||
{
|
||||
return UMessageParcel::messageParcel->ReadStringVector(value);
|
||||
}
|
||||
|
||||
bool MessageParcel::WriteFileDescriptor(int fd)
|
||||
{
|
||||
return UMessageParcel::messageParcel->WriteFileDescriptor(fd);
|
||||
}
|
||||
|
||||
int MessageParcel::ReadFileDescriptor()
|
||||
{
|
||||
return UMessageParcel::messageParcel->ReadFileDescriptor();
|
||||
}
|
||||
|
||||
bool Parcel::ReadUint32(uint32_t &value)
|
||||
{
|
||||
return UMessageParcel::messageParcel->ReadUint32(value);
|
||||
}
|
||||
} // namespace OHOS
|
74
test/unittest/mock/message_parcel_mock.h
Normal file
74
test/unittest/mock/message_parcel_mock.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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_FILEMGMT_UFS_MESSAGE_PARCEL_MOCK_H
|
||||
#define OHOS_FILEMGMT_UFS_MESSAGE_PARCEL_MOCK_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
#include "message_parcel.h"
|
||||
#include "iremote_broker.h"
|
||||
|
||||
namespace OHOS::FileAccessFwk {
|
||||
class UMessageParcel {
|
||||
public:
|
||||
virtual ~UMessageParcel() = default;
|
||||
public:
|
||||
virtual bool WriteInterfaceToken(std::u16string name) = 0;
|
||||
virtual std::u16string ReadInterfaceToken() = 0;
|
||||
virtual bool WriteParcelable(const Parcelable *object) = 0;
|
||||
virtual bool WriteInt32(int32_t value) = 0;
|
||||
virtual int32_t ReadInt32() = 0;
|
||||
virtual bool ReadInt32(int32_t &value) = 0;
|
||||
virtual bool WriteRemoteObject(const Parcelable *object) = 0;
|
||||
virtual bool WriteRemoteObject(const sptr<IRemoteObject> &object) = 0;
|
||||
virtual sptr<IRemoteObject> ReadRemoteObject() = 0;
|
||||
virtual bool ReadBool();
|
||||
virtual bool ReadBool(bool &value) = 0;
|
||||
virtual bool WriteBool(bool value) = 0;
|
||||
virtual bool WriteString(const std::string &value) = 0;
|
||||
virtual bool WriteFileDescriptor(int fd) = 0;
|
||||
virtual bool ReadString(std::string &value) = 0;
|
||||
virtual int ReadFileDescriptor() = 0;
|
||||
virtual bool ReadStringVector(std::vector<std::string> *value) = 0;
|
||||
virtual bool ReadUint32(uint32_t &value) = 0;
|
||||
public:
|
||||
static inline std::shared_ptr<UMessageParcel> messageParcel = nullptr;
|
||||
};
|
||||
|
||||
class MessageParcelMock : public UMessageParcel {
|
||||
public:
|
||||
MOCK_METHOD1(WriteInterfaceToken, bool(std::u16string name));
|
||||
MOCK_METHOD0(ReadInterfaceToken, std::u16string());
|
||||
MOCK_METHOD1(WriteParcelable, bool(const Parcelable *object));
|
||||
MOCK_METHOD1(WriteInt32, bool(int32_t value));
|
||||
MOCK_METHOD0(ReadInt32, int32_t());
|
||||
MOCK_METHOD1(ReadInt32, bool(int32_t &value));
|
||||
MOCK_METHOD1(WriteRemoteObject, bool(const Parcelable *object));
|
||||
MOCK_METHOD1(WriteRemoteObject, bool(const sptr<IRemoteObject> &object));
|
||||
MOCK_METHOD0(ReadRemoteObject, sptr<IRemoteObject>());
|
||||
MOCK_METHOD0(ReadBool, bool());
|
||||
MOCK_METHOD1(ReadBool, bool(bool &value));
|
||||
MOCK_METHOD1(WriteBool, bool(bool value));
|
||||
MOCK_METHOD1(WriteString, bool(const std::string &value));
|
||||
MOCK_METHOD1(WriteFileDescriptor, bool(int fd));
|
||||
MOCK_METHOD1(ReadString, bool(std::string &value));
|
||||
MOCK_METHOD0(ReadFileDescriptor, int());
|
||||
MOCK_METHOD1(ReadStringVector, bool(std::vector<std::string> *value));
|
||||
MOCK_METHOD1(ReadUint32, bool(uint32_t &value));
|
||||
};
|
||||
} // namespace OHOS::FileAccessFwk
|
||||
#endif // OHOS_FILEMGMT_UFS_MESSAGE_PARCEL_MOCK_H
|
Loading…
Reference in New Issue
Block a user