-
Notifications
You must be signed in to change notification settings - Fork 6k
hasStrings on Windows #27749
hasStrings on Windows #27749
Changes from 6 commits
70a0f5e
c9d633a
39990f3
c3060cd
83af633
b7c562e
64c5751
85528fd
a640fcc
aa4dc9e
61e2fa5
5a35ed2
6cef1f2
1c6744a
e4587a8
4c5afb3
b81e8f3
3a161be
620e7aa
b06f2c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ using ::testing::_; | |
| static constexpr char kChannelName[] = "flutter/platform"; | ||
|
|
||
| static constexpr char kGetClipboardDataMethod[] = "Clipboard.getData"; | ||
| static constexpr char kHasStringsClipboardMethod[] = "Clipboard.hasStrings"; | ||
| static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; | ||
|
|
||
| static constexpr char kTextPlainFormat[] = "text/plain"; | ||
|
|
@@ -103,6 +104,52 @@ TEST(PlatformHandler, RejectsGettingUnknownTypes) { | |
| })); | ||
| } | ||
|
|
||
| TEST(PlatformHandler, HasStringsCallsThrough) { | ||
|
||
| TestBinaryMessenger messenger; | ||
| TestPlatformHandler platform_handler(&messenger); | ||
|
|
||
| auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType); | ||
| auto& allocator = args->GetAllocator(); | ||
| args->PushBack(kTextPlainFormat, allocator); | ||
| auto encoded = JsonMethodCodec::GetInstance().EncodeMethodCall( | ||
| MethodCall<rapidjson::Document>(kHasStringsClipboardMethod, | ||
| std::move(args))); | ||
|
|
||
| // Set up a handler to call a response on |result| so that it doesn't log | ||
| // on destruction about leaking. | ||
| ON_CALL(platform_handler, HasStrings) | ||
| .WillByDefault( | ||
| [](std::unique_ptr<MethodResult<rapidjson::Document>> result, | ||
| auto key) { result->NotImplemented(); }); | ||
|
|
||
| EXPECT_CALL(platform_handler, HasStrings(_, ::testing::StrEq("text"))); | ||
| EXPECT_TRUE(messenger.SimulateEngineMessage( | ||
| kChannelName, encoded->data(), encoded->size(), | ||
| [](const uint8_t* reply, size_t reply_size) {})); | ||
| } | ||
|
|
||
| TEST(PlatformHandler, RejectsHasStringsOnUnknownTypes) { | ||
| TestBinaryMessenger messenger; | ||
| TestPlatformHandler platform_handler(&messenger); | ||
|
|
||
| auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType); | ||
| auto& allocator = args->GetAllocator(); | ||
| args->PushBack("madeup/contenttype", allocator); | ||
| auto encoded = JsonMethodCodec::GetInstance().EncodeMethodCall( | ||
| MethodCall<rapidjson::Document>(kHasStringsClipboardMethod, | ||
| std::move(args))); | ||
|
|
||
| MockMethodResult result; | ||
| // Requsting an unknow content type is an error. | ||
| EXPECT_CALL(result, ErrorInternal(_, _, _)); | ||
| EXPECT_TRUE(messenger.SimulateEngineMessage( | ||
| kChannelName, encoded->data(), encoded->size(), | ||
| [&](const uint8_t* reply, size_t reply_size) { | ||
| JsonMethodCodec::GetInstance().DecodeAndProcessResponseEnvelope( | ||
| reply, reply_size, &result); | ||
| })); | ||
| } | ||
|
|
||
| TEST(PlatformHandler, SettingTextCallsThrough) { | ||
| TestBinaryMessenger messenger; | ||
| TestPlatformHandler platform_handler(&messenger); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if I'm revisiting an established design. But this name looks pretty confusing. Why is it
HasStringinstead ofHasString? And can we rename it to a "verb", such asGetHasStringto represent the fact that it is a query from the framework?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plural
HasStringscame from native iOS hasStrings, which is where all of this started. I'll change the Windows methods toGetHasStringswhile keeping the method channel name the same "Clipboard.hasStrings".