6 #include <rapidjson/document.h>
10 #include "flutter/fml/macros.h"
14 #include "flutter/shell/platform/windows/testing/engine_modifier.h"
15 #include "flutter/shell/platform/windows/testing/flutter_windows_engine_builder.h"
16 #include "flutter/shell/platform/windows/testing/mock_window_binding_handler.h"
17 #include "flutter/shell/platform/windows/testing/test_binary_messenger.h"
18 #include "flutter/shell/platform/windows/testing/windows_test.h"
19 #include "gmock/gmock.h"
20 #include "gtest/gtest.h"
27 : text_input_plugin(text_input_plugin) {}
30 text_input_plugin->view_id_ = view_id;
35 bool HasActiveModel() {
return text_input_plugin->active_model_ !=
nullptr; }
38 return text_input_plugin->active_model_.get();
50 using ::testing::Return;
52 static constexpr
char kScanCodeKey[] =
"scanCode";
53 static constexpr
int kHandledScanCode = 20;
54 static constexpr
int kUnhandledScanCode = 21;
56 static constexpr
int kDefaultClientId = 42;
58 static constexpr
char kChannelName[] =
"flutter/textinput";
60 static constexpr
char kViewId[] =
"viewId";
64 static constexpr
char kTextKey[] =
"text";
72 "TextInputClient.updateEditingState";
74 static std::unique_ptr<std::vector<uint8_t>> CreateResponse(
bool handled) {
76 std::make_unique<rapidjson::Document>(rapidjson::kObjectType);
77 auto& allocator = response_doc->GetAllocator();
78 response_doc->AddMember(
"handled", handled, allocator);
82 static std::unique_ptr<rapidjson::Document> EncodedClientConfig(
83 std::string type_name,
84 std::string input_action) {
85 auto arguments = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
86 auto& allocator = arguments->GetAllocator();
87 arguments->PushBack(kDefaultClientId, allocator);
89 rapidjson::Value config(rapidjson::kObjectType);
90 config.AddMember(
"inputAction", input_action, allocator);
92 config.AddMember(
kViewId, 456, allocator);
93 rapidjson::Value type_info(rapidjson::kObjectType);
94 type_info.AddMember(
"name", type_name, allocator);
95 config.AddMember(
"inputType", type_info, allocator);
96 arguments->PushBack(config, allocator);
101 static std::unique_ptr<rapidjson::Document> EncodedEditingState(
103 TextRange selection) {
104 auto model = std::make_unique<TextInputModel>();
105 model->SetText(
text);
106 model->SetSelection(selection);
108 auto arguments = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
109 auto& allocator = arguments->GetAllocator();
110 arguments->PushBack(kDefaultClientId, allocator);
112 rapidjson::Value editing_state(rapidjson::kObjectType);
120 model->composing() ? model->composing_range().base() : -1;
121 int composing_extent =
122 model->composing() ? model->composing_range().extent() : -1;
126 rapidjson::Value(model->GetText(), allocator).Move(),
128 arguments->PushBack(editing_state, allocator);
133 class MockFlutterWindowsView :
public FlutterWindowsView {
136 std::unique_ptr<WindowBindingHandler> window)
144 MOCK_METHOD(
void, OnCursorRectUpdated, (
const Rect&), (
override));
145 MOCK_METHOD(
void, OnResetImeComposing, (), (
override));
148 FML_DISALLOW_COPY_AND_ASSIGN(MockFlutterWindowsView);
160 MockFlutterWindowsView*
view() {
return view_.get(); }
161 MockWindowBindingHandler*
window() {
return window_; }
164 FlutterWindowsEngineBuilder builder{GetContext()};
166 engine_ = builder.Build();
170 FlutterWindowsEngineBuilder builder{GetContext()};
172 auto window = std::make_unique<MockWindowBindingHandler>();
175 EXPECT_CALL(*window_, SetView).Times(1);
176 EXPECT_CALL(*
window, GetWindowHandle).WillRepeatedly(Return(
nullptr));
178 engine_ = builder.Build();
179 view_ = std::make_unique<MockFlutterWindowsView>(engine_.get(),
182 EngineModifier modifier{engine_.get()};
183 modifier.SetViewById(view_.get(), 456);
187 EXPECT_NE(engine_,
nullptr);
188 auto window = std::make_unique<MockWindowBindingHandler>();
189 EXPECT_CALL(*
window, SetView).Times(1);
190 EXPECT_CALL(*
window, GetWindowHandle).WillRepeatedly(Return(
nullptr));
191 auto view = std::make_unique<MockFlutterWindowsView>(engine_.get(),
194 EngineModifier modifier{engine_.get()};
195 modifier.SetViewById(view_.get(), view_id);
200 std::unique_ptr<FlutterWindowsEngine> engine_;
201 std::unique_ptr<MockFlutterWindowsView> view_;
202 MockWindowBindingHandler* window_;
210 auto handled_message = CreateResponse(
true);
211 auto unhandled_message = CreateResponse(
false);
212 int received_scancode = 0;
214 TestBinaryMessenger messenger(
215 [&received_scancode, &handled_message, &unhandled_message](
216 const std::string& channel,
const uint8_t*
message,
219 int redispatch_scancode = 0;
222 handler.
KeyboardHook(VK_RETURN, 100, WM_KEYDOWN,
'\n',
false,
false);
225 text.push_back(
'\n');
235 TestBinaryMessenger messenger([](
const std::string& channel,
236 const uint8_t*
message,
size_t message_size,
238 BinaryReply reply_handler = [](
const uint8_t* reply,
size_t reply_size) {};
244 EXPECT_CALL(*view(), OnResetImeComposing());
247 auto message = codec.EncodeMethodCall({
"TextInput.clearClient",
nullptr});
249 message->size(), reply_handler);
256 TestBinaryMessenger messenger([](
const std::string& channel,
257 const uint8_t*
message,
size_t message_size,
261 BinaryReply reply_handler = [&reply](
const uint8_t* reply_bytes,
263 reply = std::string(
reinterpret_cast<const char*
>(reply_bytes), reply_size);
269 auto message = codec.EncodeMethodCall({
"TextInput.clearClient",
nullptr});
271 message->size(), reply_handler);
275 "[\"Internal Consistency Error\",\"Text input is not available because "
276 "view with view_id=0 cannot be found\",null]");
284 bool sent_message =
false;
285 TestBinaryMessenger messenger(
286 [&sent_message](
const std::string& channel,
const uint8_t*
message,
289 BinaryReply reply_handler = [](
const uint8_t* reply,
size_t reply_size) {};
296 auto arguments = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
297 auto& allocator = arguments->GetAllocator();
298 arguments->PushBack(kDefaultClientId, allocator);
299 rapidjson::Value config(rapidjson::kObjectType);
300 config.AddMember(
"inputAction",
"done", allocator);
301 config.AddMember(
"inputType",
"text", allocator);
303 config.AddMember(
kViewId, 456, allocator);
304 arguments->PushBack(config, allocator);
306 codec.EncodeMethodCall({
"TextInput.setClient", std::move(arguments)});
307 messenger.SimulateEngineMessage(
"flutter/textinput",
message->data(),
308 message->size(), reply_handler);
311 sent_message =
false;
313 EXPECT_TRUE(sent_message);
316 sent_message =
false;
318 EXPECT_TRUE(sent_message);
328 sent_message =
false;
330 EXPECT_FALSE(sent_message);
333 sent_message =
false;
335 EXPECT_TRUE(sent_message);
342 std::vector<std::string> messages;
344 TestBinaryMessenger messenger(
345 [&messages](
const std::string& channel,
const uint8_t*
message,
347 std::string last_message(
reinterpret_cast<const char*
>(
message),
349 messages.push_back(last_message);
351 BinaryReply reply_handler = [](
const uint8_t* reply,
size_t reply_size) {};
358 auto set_client_arguments =
359 EncodedClientConfig(
"TextInputType.multiline",
"TextInputAction.newline");
360 auto message = codec.EncodeMethodCall(
361 {
"TextInput.setClient", std::move(set_client_arguments)});
362 messenger.SimulateEngineMessage(
"flutter/textinput",
message->data(),
363 message->size(), reply_handler);
366 handler.
KeyboardHook(VK_RETURN, 100, WM_KEYDOWN,
'\n',
false,
false);
370 EXPECT_EQ(messages.size(), 2);
373 auto encoded_arguments = EncodedEditingState(
"\n",
TextRange(1));
374 auto update_state_message = codec.EncodeMethodCall(
377 EXPECT_TRUE(std::equal(update_state_message->begin(),
378 update_state_message->end(),
379 messages.front().begin()));
382 auto arguments = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
383 auto& allocator = arguments->GetAllocator();
384 arguments->PushBack(kDefaultClientId, allocator);
386 rapidjson::Value(
"TextInputAction.newline", allocator).Move(), allocator);
387 auto invoke_action_message = codec.EncodeMethodCall(
388 {
"TextInputClient.performAction", std::move(arguments)});
390 EXPECT_TRUE(std::equal(invoke_action_message->begin(),
391 invoke_action_message->end(),
392 messages.back().begin()));
399 std::vector<std::vector<uint8_t>> messages;
401 TestBinaryMessenger messenger(
402 [&messages](
const std::string& channel,
const uint8_t*
message,
404 int length =
static_cast<int>(message_size);
405 std::vector<uint8_t> last_message(length);
406 memcpy(&last_message[0], &
message[0], length *
sizeof(uint8_t));
407 messages.push_back(last_message);
409 BinaryReply reply_handler = [](
const uint8_t* reply,
size_t reply_size) {};
416 auto set_client_arguments =
417 EncodedClientConfig(
"TextInputType.multiline",
"TextInputAction.send");
418 auto message = codec.EncodeMethodCall(
419 {
"TextInput.setClient", std::move(set_client_arguments)});
420 messenger.SimulateEngineMessage(
"flutter/textinput",
message->data(),
421 message->size(), reply_handler);
424 handler.
KeyboardHook(VK_RETURN, 100, WM_KEYDOWN,
'\n',
false,
false);
427 EXPECT_EQ(messages.size(), 1);
430 auto arguments = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
431 auto& allocator = arguments->GetAllocator();
432 arguments->PushBack(kDefaultClientId, allocator);
434 rapidjson::Value(
"TextInputAction.send", allocator).Move(), allocator);
435 auto invoke_action_message = codec.EncodeMethodCall(
436 {
"TextInputClient.performAction", std::move(arguments)});
438 EXPECT_TRUE(std::equal(invoke_action_message->begin(),
439 invoke_action_message->end(),
440 messages.front().begin()));
446 TestBinaryMessenger messenger([](
const std::string& channel,
447 const uint8_t*
message,
size_t message_size,
452 auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
453 auto& allocator = args->GetAllocator();
454 args->PushBack(123, allocator);
456 rapidjson::Value client_config(rapidjson::kObjectType);
458 args->PushBack(client_config, allocator);
463 BinaryReply reply_handler = [&reply](
const uint8_t* reply_bytes,
465 reply = std::string(
reinterpret_cast<const char*
>(reply_bytes), reply_size);
468 EXPECT_TRUE(messenger.SimulateEngineMessage(
kChannelName, encoded->data(),
469 encoded->size(), reply_handler));
472 "[\"Bad Arguments\",\"Could not set client, view ID is null.\",null]");
478 TestBinaryMessenger messenger([](
const std::string& channel,
479 const uint8_t*
message,
size_t message_size,
484 auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
485 auto& allocator = args->GetAllocator();
486 args->PushBack(123, allocator);
488 rapidjson::Value client_config(rapidjson::kObjectType);
489 client_config.AddMember(
kViewId,
"Not an integer", allocator);
491 args->PushBack(client_config, allocator);
496 BinaryReply reply_handler = [&reply](
const uint8_t* reply_bytes,
498 reply = std::string(
reinterpret_cast<const char*
>(reply_bytes), reply_size);
501 EXPECT_TRUE(messenger.SimulateEngineMessage(
kChannelName, encoded->data(),
502 encoded->size(), reply_handler));
505 "[\"Bad Arguments\",\"Could not set client, view ID is null.\",null]");
511 TestBinaryMessenger messenger(
512 [](
const std::string&,
const uint8_t*,
size_t,
BinaryReply) {});
513 BinaryReply reply_handler = [](
const uint8_t*, size_t) {};
519 auto set_client_message = codec.EncodeMethodCall(
521 EncodedClientConfig(
"TextInputType.text",
"TextInputAction.done")});
522 EXPECT_TRUE(messenger.SimulateEngineMessage(
523 kChannelName, set_client_message->data(), set_client_message->size(),
529 std::make_unique<rapidjson::Document>(rapidjson::kObjectType);
530 auto& allocator = editing_state->GetAllocator();
531 editing_state->AddMember(
kTextKey,
"abcd", allocator);
536 auto set_editing_state_message = codec.EncodeMethodCall(
538 EXPECT_TRUE(messenger.SimulateEngineMessage(
540 set_editing_state_message->size(), reply_handler));
549 auto handled_message = CreateResponse(
true);
550 auto unhandled_message = CreateResponse(
false);
551 int received_scancode = 0;
553 TestBinaryMessenger messenger(
554 [&received_scancode, &handled_message, &unhandled_message](
555 const std::string& channel,
const uint8_t*
message,
558 int redispatch_scancode = 0;
561 auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
562 auto& allocator = args->GetAllocator();
563 args->PushBack(123, allocator);
565 rapidjson::Value client_config(rapidjson::kObjectType);
567 client_config.AddMember(
kViewId, 456, allocator);
569 args->PushBack(client_config, allocator);
573 EXPECT_TRUE(messenger.SimulateEngineMessage(
575 [](
const uint8_t* reply,
size_t reply_size) {}));
577 handler.
KeyboardHook(VK_RETURN, 100, WM_KEYDOWN,
'\n',
false,
false);
580 text.push_back(
'\n');
584 handler.
KeyboardHook(0x4E, 100, WM_KEYDOWN,
'n',
false,
false);
586 std::u16string textN;
589 handler.
KeyboardHook(0x49, 100, WM_KEYDOWN,
'i',
false,
false);
590 std::u16string textNi;
594 handler.
KeyboardHook(VK_RETURN, 100, WM_KEYDOWN,
'\n',
false,
false);
595 std::u16string textChineseCharacter;
596 text.push_back(u
'\u4F60');
608 int selection_base = -1;
609 TestBinaryMessenger messenger([&](
const std::string& channel,
610 const uint8_t*
message,
size_t size,
615 const auto& args = *method->arguments();
616 const auto& editing_state = args[1];
619 ASSERT_NE(base, editing_state.MemberEnd());
620 ASSERT_TRUE(base->value.IsInt());
621 ASSERT_NE(extent, editing_state.MemberEnd());
622 ASSERT_TRUE(extent->value.IsInt());
623 selection_base = base->value.GetInt();
624 EXPECT_EQ(extent->value.GetInt(), selection_base);
630 auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
631 auto& allocator = args->GetAllocator();
632 args->PushBack(123, allocator);
633 rapidjson::Value client_config(rapidjson::kObjectType);
634 client_config.AddMember(
kViewId, 456, allocator);
635 args->PushBack(client_config, allocator);
638 EXPECT_TRUE(messenger.SimulateEngineMessage(
640 [](
const uint8_t* reply,
size_t reply_size) {}));
642 plugin.ComposeBeginHook();
643 EXPECT_EQ(selection_base, 0);
644 plugin.ComposeChangeHook(u
"abc", 3);
645 EXPECT_EQ(selection_base, 3);
647 plugin.ComposeCommitHook();
648 plugin.ComposeEndHook();
649 EXPECT_EQ(selection_base, 3);
651 plugin.ComposeBeginHook();
652 plugin.ComposeChangeHook(u
"1", 1);
653 EXPECT_EQ(selection_base, 4);
655 plugin.ComposeChangeHook(u
"12", 2);
656 EXPECT_EQ(selection_base, 5);
658 plugin.ComposeChangeHook(u
"12", 1);
659 EXPECT_EQ(selection_base, 4);
661 plugin.ComposeChangeHook(u
"12", 2);
662 EXPECT_EQ(selection_base, 5);
675 double ime_width = 50;
676 double ime_height = 60;
679 std::array<std::array<double, 4>, 4> editabletext_transform = {
680 1.0, 0.0, 0.0, view_x,
681 0.0, 1.0, 0.0, view_y,
685 TestBinaryMessenger messenger([](
const std::string& channel,
686 const uint8_t*
message,
size_t message_size,
688 BinaryReply reply_handler = [](
const uint8_t* reply,
size_t reply_size) {};
696 EXPECT_CALL(*view(), OnCursorRectUpdated(Rect{{view_x, view_y}, {0, 0}}));
700 std::make_unique<rapidjson::Document>(rapidjson::kObjectType);
701 auto& allocator = arguments->GetAllocator();
703 rapidjson::Value transoform(rapidjson::kArrayType);
704 for (
int i = 0; i < 4 * 4; i++) {
706 transoform.PushBack(editabletext_transform[i % 4][i / 4], allocator);
709 arguments->AddMember(
"transform", transoform, allocator);
711 auto message = codec.EncodeMethodCall(
712 {
"TextInput.setEditableSizeAndTransform", std::move(arguments)});
714 message->size(), reply_handler);
718 OnCursorRectUpdated(Rect{{view_x + ime_x, view_y + ime_y},
719 {ime_width, ime_height}}));
723 std::make_unique<rapidjson::Document>(rapidjson::kObjectType);
724 auto& allocator = arguments->GetAllocator();
726 arguments->AddMember(
"x", ime_x, allocator);
727 arguments->AddMember(
"y", ime_y, allocator);
728 arguments->AddMember(
"width", ime_width, allocator);
729 arguments->AddMember(
"height", ime_height, allocator);
731 auto message = codec.EncodeMethodCall(
732 {
"TextInput.setMarkedTextRect", std::move(arguments)});
734 message->size(), reply_handler);
741 TestBinaryMessenger messenger([](
const std::string& channel,
742 const uint8_t*
message,
size_t message_size,
746 BinaryReply reply_handler = [&reply](
const uint8_t* reply_bytes,
748 reply = std::string(
reinterpret_cast<const char*
>(reply_bytes), reply_size);
756 std::make_unique<rapidjson::Document>(rapidjson::kObjectType);
757 auto& allocator = arguments->GetAllocator();
759 arguments->AddMember(
"x", 0, allocator);
760 arguments->AddMember(
"y", 0, allocator);
761 arguments->AddMember(
"width", 0, allocator);
762 arguments->AddMember(
"height", 0, allocator);
764 auto message = codec.EncodeMethodCall(
765 {
"TextInput.setMarkedTextRect", std::move(arguments)});
767 message->size(), reply_handler);
771 "[\"Internal Consistency Error\",\"Text input is not available because "
772 "view with view_id=0 cannot be found\",null]");
779 bool sent_message =
false;
780 TestBinaryMessenger messenger(
781 [&sent_message](
const std::string& channel,
const uint8_t*
message,
787 auto const set_client_and_send_message = [&](
int client_id,
int view_id) {
788 auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
789 auto& allocator = args->GetAllocator();
790 args->PushBack(client_id, allocator);
792 rapidjson::Value client_config(rapidjson::kObjectType);
793 client_config.AddMember(
kViewId, view_id, allocator);
795 args->PushBack(client_config, allocator);
800 BinaryReply reply_handler = [&reply](
const uint8_t* reply_bytes,
803 std::string(
reinterpret_cast<const char*
>(reply_bytes), reply_size);
806 EXPECT_TRUE(messenger.SimulateEngineMessage(
807 kChannelName, encoded->data(), encoded->size(), reply_handler));
809 sent_message =
false;
810 handler.ComposeBeginHook();
811 EXPECT_TRUE(sent_message);
812 sent_message =
false;
813 handler.ComposeChangeHook(u
"4", 1);
814 EXPECT_TRUE(sent_message);
815 sent_message =
false;
816 handler.ComposeCommitHook();
817 EXPECT_FALSE(sent_message);
818 sent_message =
false;
819 handler.ComposeEndHook();
820 EXPECT_TRUE(sent_message);
823 set_client_and_send_message(123, 456);
824 set_client_and_send_message(123, 789);
832 TestBinaryMessenger messenger([](
const std::string& channel,
833 const uint8_t*
message,
size_t message_size,
835 BinaryReply reply_handler = [](
const uint8_t* reply,
size_t reply_size) {};
843 auto set_client_message = codec.EncodeMethodCall(
844 {
"TextInput.setClient",
845 EncodedClientConfig(
"TextInputType.text",
"TextInputAction.done")});
846 messenger.SimulateEngineMessage(
kChannelName, set_client_message->data(),
847 set_client_message->size(), reply_handler);
864 TestBinaryMessenger messenger([](
const std::string& channel,
865 const uint8_t*
message,
size_t message_size,
867 BinaryReply reply_handler = [](
const uint8_t* reply,
size_t reply_size) {};
875 auto set_client_message = codec.EncodeMethodCall(
876 {
"TextInput.setClient",
877 EncodedClientConfig(
"TextInputType.text",
"TextInputAction.done")});
878 messenger.SimulateEngineMessage(
kChannelName, set_client_message->data(),
879 set_client_message->size(), reply_handler);
896 TestBinaryMessenger messenger([](
const std::string& channel,
897 const uint8_t*
message,
size_t message_size,
899 BinaryReply reply_handler = [](
const uint8_t* reply,
size_t reply_size) {};
907 auto set_client_message = codec.EncodeMethodCall(
908 {
"TextInput.setClient",
909 EncodedClientConfig(
"TextInputType.text",
"TextInputAction.done")});
910 messenger.SimulateEngineMessage(
kChannelName, set_client_message->data(),
911 set_client_message->size(), reply_handler);
FlutterWindowsView(FlutterViewId view_id, FlutterWindowsEngine *engine, std::unique_ptr< WindowBindingHandler > window_binding, bool is_sized_to_content, const BoxConstraints &box_constraints, FlutterWindowsViewSizingDelegate *sizing_delegate=nullptr, std::shared_ptr< WindowsProcTable > windows_proc_table=nullptr)
static const JsonMessageCodec & GetInstance()
static const JsonMethodCodec & GetInstance()
std::unique_ptr< std::vector< uint8_t > > EncodeMessage(const T &message) const
std::unique_ptr< MethodCall< T > > DecodeMethodCall(const uint8_t *message, size_t message_size) const
std::unique_ptr< std::vector< uint8_t > > EncodeMethodCall(const MethodCall< T > &method_call) const
TextRange composing_range() const
virtual void ComposeCommitHook()
void OnViewRemoved(FlutterViewId view_id)
virtual void ComposeChangeHook(const std::u16string &text, int cursor_pos)
virtual void ComposeEndHook()
virtual void KeyboardHook(int key, int scancode, int action, char32_t character, bool extended, bool was_down)
virtual void ComposeBeginHook()
FlutterViewId GetViewId()
const TextInputModel * GetActiveModel() const
void SetViewId(FlutterViewId view_id)
TextInputPluginModifier(TextInputPlugin *text_input_plugin)
MOCK_METHOD(void, NotifyWinEventWrapper,(ui::AXPlatformNodeWin *, ax::mojom::Event),(override))
MockFlutterWindowsView(FlutterWindowsEngine *engine, std::unique_ptr< WindowBindingHandler > wbh)
TextInputPluginTest()=default
MockWindowBindingHandler * window()
virtual ~TextInputPluginTest()=default
FlutterWindowsEngine * engine()
MockFlutterWindowsView * view()
std::unique_ptr< MockFlutterWindowsView > AddViewWithId(int view_id)
static constexpr char kChannelName[]
TEST_F(AccessibilityPluginTest, DirectAnnounceCall)
std::function< void(const uint8_t *reply, size_t reply_size)> BinaryReply
constexpr FlutterViewId kImplicitViewId
static constexpr char kEnableDeltaModel[]
static constexpr char kSelectionIsDirectionalKey[]
static constexpr char kSetEditingStateMethod[]
static constexpr char kSelectionExtentKey[]
static constexpr char kSetClientMethod[]
static constexpr char kUpdateEditingStateMethod[]
static constexpr char kComposingExtentKey[]
static constexpr char kComposingBaseKey[]
static constexpr char kAffinityDownstream[]
static constexpr char kSelectionAffinityKey[]
static constexpr char kViewId[]
static constexpr char kSelectionBaseKey[]