mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fixes several bugs in the clipboard code, and makes some structural
improvements:
- Adds scoped wrappers for clipboard open/close and global lock/unlock,
to prevent missing cleanup, fixing at least one case where the lock
was not released.
- Adds the relevant window handle to the clipboard calls, since the docs
suggest that some operations won't work without one.
- Adds a missing clear step to setting the clipboard data.
- Switches from TEXT to UNICODETEXT to handle non-ASCII text correctly.
- To enable that, adds UTF-16/-8 conversion utilities built on the
Win32 APIs (rather than the deprecated std::codecvt functions, as
have been previously used in the engine).
- Fixes handling of getting data when the clipboard is empty, correctly
returning null.
- Passes more errors back through the method channel, with details, for
easier debugging of future issues.
Fixes https://github.com/flutter/flutter/issues/54226
38 lines
917 B
C++
38 lines
917 B
C++
// 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/string_conversion.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
namespace flutter {
|
|
namespace testing {
|
|
|
|
TEST(StringConversion, Utf16FromUtf8Empty) {
|
|
EXPECT_EQ(Utf16FromUtf8(""), L"");
|
|
}
|
|
|
|
TEST(StringConversion, Utf16FromUtf8Ascii) {
|
|
EXPECT_EQ(Utf16FromUtf8("abc123"), L"abc123");
|
|
}
|
|
|
|
TEST(StringConversion, Utf16FromUtf8Unicode) {
|
|
EXPECT_EQ(Utf16FromUtf8("\xe2\x98\x83"), L"\x2603");
|
|
}
|
|
|
|
TEST(StringConversion, Utf8FromUtf16Empty) {
|
|
EXPECT_EQ(Utf8FromUtf16(L""), "");
|
|
}
|
|
|
|
TEST(StringConversion, Utf8FromUtf16Ascii) {
|
|
EXPECT_EQ(Utf8FromUtf16(L"abc123"), "abc123");
|
|
}
|
|
|
|
TEST(StringConversion, Utf8FromUtf16Unicode) {
|
|
EXPECT_EQ(Utf8FromUtf16(L"\x2603"), "\xe2\x98\x83");
|
|
}
|
|
|
|
} // namespace testing
|
|
} // namespace flutter
|