Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
5e50ed97
Unverified
Commit
5e50ed97
authored
Jan 23, 2023
by
yaakovschectman
Committed by
GitHub
Jan 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test Utf8FromUtf16 (#118647)
parent
392dffeb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
0 deletions
+44
-0
main.dart
dev/integration_tests/windows_startup_test/lib/main.dart
+13
-0
windows.dart
dev/integration_tests/windows_startup_test/lib/windows.dart
+12
-0
main_test.dart
...ion_tests/windows_startup_test/test_driver/main_test.dart
+9
-0
flutter_window.cpp
...ts/windows_startup_test/windows/runner/flutter_window.cpp
+10
-0
No files found.
dev/integration_tests/windows_startup_test/lib/main.dart
View file @
5e50ed97
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
;
import
'package:flutter_driver/driver_extension.dart'
;
...
...
@@ -44,6 +45,18 @@ void main() async {
return
(
app
==
system
)
?
'success'
:
'error: app dark mode (
$app
) does not match system dark mode (
$system
)'
;
}
else
if
(
message
==
'verifyStringConversion'
)
{
// Use a test string that contains code points that fit in both 8 and 16 bits.
// The code points are passed a list of integers through the method channel,
// which will use the UTF16 to UTF8 utility function to convert them to a
// std::string, which should equate to the original expected string.
// TODO(schectman): Remove trailing null from returned string
const
String
expected
=
'ABCℵ
\
x00'
;
final
Int32List
codePoints
=
Int32List
.
fromList
(
expected
.
codeUnits
);
final
String
converted
=
await
testStringConversion
(
codePoints
);
return
(
converted
==
expected
)
?
'success'
:
'error: conversion of UTF16 string to UTF8 failed, expected "
${expected.codeUnits}
" but got "
${converted.codeUnits}
"'
;
}
throw
'Unrecognized message:
$message
'
;
...
...
dev/integration_tests/windows_startup_test/lib/windows.dart
View file @
5e50ed97
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:typed_data'
;
import
'package:flutter/services.dart'
;
const
MethodChannel
_kMethodChannel
=
...
...
@@ -36,3 +38,13 @@ Future<bool> isSystemDarkModeEnabled() async {
return
enabled
;
}
/// Test conversion of a UTF16 string to UTF8 using the app template utils.
Future
<
String
>
testStringConversion
(
Int32List
twoByteCodes
)
async
{
final
String
?
converted
=
await
_kMethodChannel
.
invokeMethod
<
String
?>(
'convertString'
,
twoByteCodes
);
if
(
converted
==
null
)
{
throw
'Method channel unavailable.'
;
}
return
converted
;
}
dev/integration_tests/windows_startup_test/test_driver/main_test.dart
View file @
5e50ed97
...
...
@@ -23,4 +23,13 @@ void main() {
await
driver
.
close
();
},
timeout:
Timeout
.
none
);
test
(
'Windows app template can convert string from UTF16 to UTF8'
,
()
async
{
final
FlutterDriver
driver
=
await
FlutterDriver
.
connect
(
printCommunication:
true
);
final
String
result
=
await
driver
.
requestData
(
'verifyStringConversion'
);
expect
(
result
,
equals
(
'success'
));
await
driver
.
close
();
},
timeout:
Timeout
.
none
);
}
dev/integration_tests/windows_startup_test/windows/runner/flutter_window.cpp
View file @
5e50ed97
...
...
@@ -12,6 +12,7 @@
#include <flutter/standard_method_codec.h>
#include "flutter/generated_plugin_registrant.h"
#include "utils.h"
/// Window attribute that enables dark mode window decorations.
///
...
...
@@ -106,6 +107,15 @@ bool FlutterWindow::OnCreate() {
}
else
{
result
->
Error
(
"error"
,
"Received status "
+
status
);
}
}
else
if
(
method
==
"convertString"
)
{
const
flutter
::
EncodableValue
*
argument
=
call
.
arguments
();
const
std
::
vector
<
int32_t
>
code_points
=
std
::
get
<
std
::
vector
<
int32_t
>>
(
*
argument
);
std
::
vector
<
wchar_t
>
wide_str
;
for
(
int32_t
code_point
:
code_points
)
{
wide_str
.
push_back
((
wchar_t
)(
code_point
));
}
const
std
::
string
string
=
Utf8FromUtf16
(
wide_str
.
data
());
result
->
Success
(
string
);
}
else
{
result
->
NotImplemented
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment