Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
d2c326e6
E
engine
项目概览
qq_34031325
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d2c326e6
编写于
2月 09, 2021
作者:
T
Tong Mu
提交者:
GitHub
2月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Windows] Fix crash of TextInputPlugin on empty model (#24293)
上级
2e10a974
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
78 addition
and
1 deletion
+78
-1
ci/licenses_golden/licenses_flutter
ci/licenses_golden/licenses_flutter
+1
-0
shell/platform/windows/BUILD.gn
shell/platform/windows/BUILD.gn
+1
-0
shell/platform/windows/key_event_handler_unittests.cc
shell/platform/windows/key_event_handler_unittests.cc
+4
-1
shell/platform/windows/text_input_plugin.cc
shell/platform/windows/text_input_plugin.cc
+9
-0
shell/platform/windows/text_input_plugin_unittest.cc
shell/platform/windows/text_input_plugin_unittest.cc
+63
-0
未找到文件。
ci/licenses_golden/licenses_flutter
浏览文件 @
d2c326e6
...
@@ -1516,6 +1516,7 @@ FILE: ../../../flutter/shell/platform/windows/text_input_manager_win32.h
...
@@ -1516,6 +1516,7 @@ FILE: ../../../flutter/shell/platform/windows/text_input_manager_win32.h
FILE: ../../../flutter/shell/platform/windows/text_input_plugin.cc
FILE: ../../../flutter/shell/platform/windows/text_input_plugin.cc
FILE: ../../../flutter/shell/platform/windows/text_input_plugin.h
FILE: ../../../flutter/shell/platform/windows/text_input_plugin.h
FILE: ../../../flutter/shell/platform/windows/text_input_plugin_delegate.h
FILE: ../../../flutter/shell/platform/windows/text_input_plugin_delegate.h
FILE: ../../../flutter/shell/platform/windows/text_input_plugin_unittest.cc
FILE: ../../../flutter/shell/platform/windows/win32_dpi_utils.cc
FILE: ../../../flutter/shell/platform/windows/win32_dpi_utils.cc
FILE: ../../../flutter/shell/platform/windows/win32_dpi_utils.h
FILE: ../../../flutter/shell/platform/windows/win32_dpi_utils.h
FILE: ../../../flutter/shell/platform/windows/win32_dpi_utils_unittests.cc
FILE: ../../../flutter/shell/platform/windows/win32_dpi_utils_unittests.cc
...
...
shell/platform/windows/BUILD.gn
浏览文件 @
d2c326e6
...
@@ -199,6 +199,7 @@ executable("flutter_windows_unittests") {
...
@@ -199,6 +199,7 @@ executable("flutter_windows_unittests") {
"testing/mock_window_binding_handler.h",
"testing/mock_window_binding_handler.h",
"testing/win32_flutter_window_test.cc",
"testing/win32_flutter_window_test.cc",
"testing/win32_flutter_window_test.h",
"testing/win32_flutter_window_test.h",
"text_input_plugin_unittest.cc",
"win32_dpi_utils_unittests.cc",
"win32_dpi_utils_unittests.cc",
"win32_flutter_window_unittests.cc",
"win32_flutter_window_unittests.cc",
"win32_window_proc_delegate_manager_unittests.cc",
"win32_window_proc_delegate_manager_unittests.cc",
...
...
shell/platform/windows/key_event_handler_unittests.cc
浏览文件 @
d2c326e6
...
@@ -15,11 +15,12 @@
...
@@ -15,11 +15,12 @@
namespace
flutter
{
namespace
flutter
{
namespace
testing
{
namespace
testing
{
namespace
{
static
constexpr
char
kScanCodeKey
[]
=
"scanCode"
;
static
constexpr
char
kScanCodeKey
[]
=
"scanCode"
;
static
constexpr
int
kHandledScanCode
=
20
;
static
constexpr
int
kHandledScanCode
=
20
;
static
constexpr
int
kUnhandledScanCode
=
21
;
static
constexpr
int
kUnhandledScanCode
=
21
;
std
::
unique_ptr
<
std
::
vector
<
uint8_t
>>
CreateResponse
(
bool
handled
)
{
st
atic
st
d
::
unique_ptr
<
std
::
vector
<
uint8_t
>>
CreateResponse
(
bool
handled
)
{
auto
response_doc
=
auto
response_doc
=
std
::
make_unique
<
rapidjson
::
Document
>
(
rapidjson
::
kObjectType
);
std
::
make_unique
<
rapidjson
::
Document
>
(
rapidjson
::
kObjectType
);
auto
&
allocator
=
response_doc
->
GetAllocator
();
auto
&
allocator
=
response_doc
->
GetAllocator
();
...
@@ -27,6 +28,8 @@ std::unique_ptr<std::vector<uint8_t>> CreateResponse(bool handled) {
...
@@ -27,6 +28,8 @@ std::unique_ptr<std::vector<uint8_t>> CreateResponse(bool handled) {
return
JsonMessageCodec
::
GetInstance
().
EncodeMessage
(
*
response_doc
);
return
JsonMessageCodec
::
GetInstance
().
EncodeMessage
(
*
response_doc
);
}
}
}
// namespace
TEST
(
KeyEventHandlerTest
,
KeyboardHookHandling
)
{
TEST
(
KeyEventHandlerTest
,
KeyboardHookHandling
)
{
auto
handled_message
=
CreateResponse
(
true
);
auto
handled_message
=
CreateResponse
(
true
);
auto
unhandled_message
=
CreateResponse
(
false
);
auto
unhandled_message
=
CreateResponse
(
false
);
...
...
shell/platform/windows/text_input_plugin.cc
浏览文件 @
d2c326e6
...
@@ -103,11 +103,17 @@ TextInputPlugin::TextInputPlugin(flutter::BinaryMessenger* messenger,
...
@@ -103,11 +103,17 @@ TextInputPlugin::TextInputPlugin(flutter::BinaryMessenger* messenger,
TextInputPlugin
::~
TextInputPlugin
()
=
default
;
TextInputPlugin
::~
TextInputPlugin
()
=
default
;
void
TextInputPlugin
::
ComposeBeginHook
()
{
void
TextInputPlugin
::
ComposeBeginHook
()
{
if
(
active_model_
==
nullptr
)
{
return
;
}
active_model_
->
BeginComposing
();
active_model_
->
BeginComposing
();
SendStateUpdate
(
*
active_model_
);
SendStateUpdate
(
*
active_model_
);
}
}
void
TextInputPlugin
::
ComposeEndHook
()
{
void
TextInputPlugin
::
ComposeEndHook
()
{
if
(
active_model_
==
nullptr
)
{
return
;
}
active_model_
->
CommitComposing
();
active_model_
->
CommitComposing
();
active_model_
->
EndComposing
();
active_model_
->
EndComposing
();
SendStateUpdate
(
*
active_model_
);
SendStateUpdate
(
*
active_model_
);
...
@@ -115,6 +121,9 @@ void TextInputPlugin::ComposeEndHook() {
...
@@ -115,6 +121,9 @@ void TextInputPlugin::ComposeEndHook() {
void
TextInputPlugin
::
ComposeChangeHook
(
const
std
::
u16string
&
text
,
void
TextInputPlugin
::
ComposeChangeHook
(
const
std
::
u16string
&
text
,
int
cursor_pos
)
{
int
cursor_pos
)
{
if
(
active_model_
==
nullptr
)
{
return
;
}
active_model_
->
AddText
(
text
);
active_model_
->
AddText
(
text
);
cursor_pos
+=
active_model_
->
composing_range
().
base
();
cursor_pos
+=
active_model_
->
composing_range
().
base
();
active_model_
->
UpdateComposingText
(
text
);
active_model_
->
UpdateComposingText
(
text
);
...
...
shell/platform/windows/text_input_plugin_unittest.cc
0 → 100644
浏览文件 @
d2c326e6
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/platform/windows/text_input_plugin.h"
#include <rapidjson/document.h>
#include <memory>
#include "flutter/shell/platform/common/json_message_codec.h"
#include "flutter/shell/platform/windows/flutter_windows_view.h"
#include "flutter/shell/platform/windows/testing/test_binary_messenger.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace
flutter
{
namespace
testing
{
namespace
{
static
constexpr
char
kScanCodeKey
[]
=
"scanCode"
;
static
constexpr
int
kHandledScanCode
=
20
;
static
constexpr
int
kUnhandledScanCode
=
21
;
static
std
::
unique_ptr
<
std
::
vector
<
uint8_t
>>
CreateResponse
(
bool
handled
)
{
auto
response_doc
=
std
::
make_unique
<
rapidjson
::
Document
>
(
rapidjson
::
kObjectType
);
auto
&
allocator
=
response_doc
->
GetAllocator
();
response_doc
->
AddMember
(
"handled"
,
handled
,
allocator
);
return
JsonMessageCodec
::
GetInstance
().
EncodeMessage
(
*
response_doc
);
}
class
EmptyTextInputPluginDelegate
:
public
TextInputPluginDelegate
{
public:
// Notifies delegate that the cursor position has changed.
void
OnCursorRectUpdated
(
const
Rect
&
rect
)
{}
};
}
// namespace
TEST
(
TextInputPluginTest
,
TextMethodsWorksWithEmptyModel
)
{
auto
handled_message
=
CreateResponse
(
true
);
auto
unhandled_message
=
CreateResponse
(
false
);
int
received_scancode
=
0
;
TestBinaryMessenger
messenger
(
[
&
received_scancode
,
&
handled_message
,
&
unhandled_message
](
const
std
::
string
&
channel
,
const
uint8_t
*
message
,
size_t
message_size
,
BinaryReply
reply
)
{});
EmptyTextInputPluginDelegate
delegate
;
int
redispatch_scancode
=
0
;
TextInputPlugin
handler
(
&
messenger
,
&
delegate
);
handler
.
KeyboardHook
(
nullptr
,
VK_RETURN
,
100
,
WM_KEYDOWN
,
'\n'
,
false
);
handler
.
ComposeBeginHook
();
std
::
u16string
text
;
text
.
push_back
(
'\n'
);
handler
.
ComposeChangeHook
(
text
,
1
);
handler
.
ComposeEndHook
();
// Passes if it did not crash
}
}
// namespace testing
}
// namespace flutter
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录