添加测试用例,增加ConnectExtension的返回值

Signed-off-by: dubj <dubingjian@huawei.com>
Change-Id: I7d039a1349ef50d3f48cb1cffc81c26177154d3e
This commit is contained in:
dubj
2022-05-09 20:49:36 +08:00
parent d4bde943fc
commit 5228df1cfe
6 changed files with 195 additions and 14 deletions
+2 -1
View File
@@ -105,7 +105,8 @@
],
"test": [
"//foundation/windowmanager/wm:test",
"//foundation/windowmanager/dm:test"
"//foundation/windowmanager/dm:test",
"//foundation/windowmanager/extension:test"
]
}
}
+17
View File
@@ -0,0 +1,17 @@
# Copyright (c) 2022-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.
group("test") {
testonly = true
deps = [ "test/systemtest:systemtest" ]
}
@@ -39,7 +39,7 @@ public:
const sptr<IRemoteObject>& remoteObject, int resultCode) override;
void OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int resultCode) override;
void ConnectExtension(const AppExecFwk::ElementName& element, const Rect& rect,
int ConnectExtension(const AppExecFwk::ElementName& element, const Rect& rect,
uint32_t uid, const sptr<IWindowExtensionCallback>& callback);
void DisconnectExtension();
void Show() const;
@@ -96,8 +96,9 @@ void WindowExtensionConnection::Impl::WindowExtensionClientRecipient::OnRemoteDi
}
WLOGFI("Remote died");
}
void WindowExtensionConnection::Impl::ConnectExtension(const AppExecFwk::ElementName& element, const Rect& rect,
uint32_t uid, const sptr<IWindowExtensionCallback>& callback)
int WindowExtensionConnection::Impl::ConnectExtension(const AppExecFwk::ElementName& element,
const Rect& rect, uint32_t uid, const sptr<IWindowExtensionCallback>& callback)
{
AAFwk::Want want;
want.SetElement(element);
@@ -107,13 +108,12 @@ void WindowExtensionConnection::Impl::ConnectExtension(const AppExecFwk::Element
want.SetParam(RECT_FORM_KEY_WIDTH, static_cast<int>(rect.width_));
want.SetParam(RECT_FORM_KEY_HEIGHT, static_cast<int>(rect.height_));
if (AAFwk::AbilityManagerClient::GetInstance()->ConnectAbility(
want, this, nullptr, 100) != ERR_OK) { // 100 default userId
WLOGFE("ConnectAbility failed!");
return;
auto ret = AAFwk::AbilityManagerClient::GetInstance()->ConnectAbility(want, this, nullptr, 100);
if (ret == ERR_OK) { // 100 default userId
componentCallback_ = callback;
}
WLOGFI("Connection extension end");
componentCallback_ = callback;
WLOGFI("Connection extension end ret = %{public}d", ret);
return ret;
}
void WindowExtensionConnection::Impl::Show() const
@@ -195,10 +195,10 @@ void WindowExtensionConnection::Impl::OnAbilityDisconnectDone(const AppExecFwk::
}
// WindowExtensionConnection
void WindowExtensionConnection::ConnectExtension(const AppExecFwk::ElementName& element, const Rect& rect,
uint32_t uid, const sptr<IWindowExtensionCallback>& callback) const
int WindowExtensionConnection::ConnectExtension(const AppExecFwk::ElementName& element,
const Rect& rect, uint32_t uid, const sptr<IWindowExtensionCallback>& callback) const
{
pImpl_->ConnectExtension(element, rect, uid, callback);
return pImpl_->ConnectExtension(element, rect, uid, callback);
}
void WindowExtensionConnection::Show() const
+61
View File
@@ -0,0 +1,61 @@
# Copyright (c) 2022-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")
module_out_path = "window_manager/extension"
group("systemtest") {
testonly = true
deps = [ ":window_extension_connection_test" ]
}
config("we_systemtest_common_public_config") {
include_dirs = [
"//foundation/windowmanager/extension/extension_connection/include",
"//foundation/windowmanager/interfaces/innerkits/extension",
"//foundation/windowmanager/interfaces/innerkits/wm",
"//third_party/googletest/googlemock/include",
]
cflags = [
"-Wall",
"-Werror",
"-g3",
"-Dprivate=public",
"-Dprotected=public",
]
}
## SystemTest window_extension_connection_test {{{
ohos_systemtest("window_extension_connection_test") {
module_out_path = module_out_path
sources = [ "extension_connection_test.cpp" ]
public_configs = [ ":we_systemtest_common_public_config" ]
public_deps = [
"//foundation/windowmanager/extension/extension_connection:libwindow_extension_client",
"//third_party/googletest:gmock",
"//third_party/googletest:gtest_main",
]
external_deps = [
"ability_base:want",
"input:libmmi-client",
"utils_base:utils",
]
}
## SystemTest window_extension_connection_test }}}
@@ -0,0 +1,102 @@
/*
* Copyright (c) 2022-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 <gtest/gtest.h>
#include "window_extension_connection.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
class ExtensionCallback : public Rosen::IWindowExtensionCallback {
public:
ExtensionCallback() = default;
~ExtensionCallback() = default;
void OnWindowReady(const std::shared_ptr<Rosen::RSSurfaceNode>& rsSurfaceNode) override;
void OnExtensionDisconnected() override;
void OnKeyEvent(const std::shared_ptr<MMI::KeyEvent>& event) override;
void OnPointerEvent(const std::shared_ptr<MMI::PointerEvent>& event) override;
void OnBackPress() override;
bool isWindowReady_ = false;
};
void ExtensionCallback::OnWindowReady(const std::shared_ptr<Rosen::RSSurfaceNode>& rsSurfaceNode)
{
isWindowReady_ = true;
}
void ExtensionCallback::OnExtensionDisconnected()
{
}
void ExtensionCallback::OnKeyEvent(const std::shared_ptr<MMI::KeyEvent>& event)
{
}
void ExtensionCallback::OnPointerEvent(const std::shared_ptr<MMI::PointerEvent>& event)
{
}
void ExtensionCallback::OnBackPress()
{
}
class ExtensionConnectionTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
virtual void SetUp() override;
virtual void TearDown() override;
};
void ExtensionConnectionTest::SetUpTestCase()
{
}
void ExtensionConnectionTest::TearDownTestCase()
{
}
void ExtensionConnectionTest::SetUp()
{
}
void ExtensionConnectionTest::TearDown()
{
}
namespace {
/**
* @tc.name: WindowExtensionConnection01
* @tc.desc: connect window extension
* @tc.type: FUNC
*/
HWTEST_F(ExtensionConnectionTest, WindowExtensionConnection01, Function | SmallTest | Level2)
{
sptr<WindowExtensionConnection> connection = new(std::nothrow)WindowExtensionConnection();
if (connection == nullptr) {
return;
}
AppExecFwk::ElementName element;
element.SetBundleName("com.test.windowextension");
element.SetAbilityName("WindowExtAbility");
Rosen::Rect rect {100, 100, 60, 60};
ASSERT_TRUE(connection->ConnectExtension(element, rect, 100, nullptr) != ERR_OK);
}
}
} // Rosen
} // OHOS
@@ -49,7 +49,7 @@ class WindowExtensionConnection : public RefBase {
public:
WindowExtensionConnection();
~WindowExtensionConnection();
void ConnectExtension(const AppExecFwk::ElementName& element, const Rect& rect,
int ConnectExtension(const AppExecFwk::ElementName& element, const Rect& rect,
uint32_t uid, const sptr<IWindowExtensionCallback>& callback) const;
void DisconnectExtension() const;
void Show() const;