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
adda8e93
Unverified
Commit
adda8e93
authored
Apr 13, 2022
by
chunhtai
Committed by
GitHub
Apr 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set the Clipboard more reliably in android semantics integration test. (#101851)
parent
65a82672
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
23 deletions
+28
-23
MainActivity.java
...ava/com/yourcompany/platforminteraction/MainActivity.java
+12
-0
main.dart
...integration_tests/android_semantics_testing/lib/main.dart
+15
-0
main_test.dart
...ests/android_semantics_testing/test_driver/main_test.dart
+1
-23
No files found.
dev/integration_tests/android_semantics_testing/android/app/src/main/java/com/yourcompany/platforminteraction/MainActivity.java
View file @
adda8e93
...
...
@@ -15,6 +15,8 @@ import android.os.Build;
import
android.os.Bundle
;
import
android.util.DisplayMetrics
;
import
android.view.WindowManager
;
import
android.content.ClipboardManager
;
import
android.content.ClipData
;
import
android.content.Context
;
import
androidx.annotation.NonNull
;
...
...
@@ -66,6 +68,16 @@ public class MainActivity extends FlutterActivity {
result
.
success
(
convertSemantics
(
node
,
id
));
return
;
}
if
(
methodCall
.
method
.
equals
(
"setClipboard"
))
{
Map
<
String
,
Object
>
data
=
methodCall
.
arguments
();
@SuppressWarnings
(
"unchecked"
)
String
message
=
(
String
)
data
.
get
(
"message"
);
ClipboardManager
clipboard
=
(
ClipboardManager
)
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
ClipData
clip
=
ClipData
.
newPlainText
(
"message"
,
message
);
clipboard
.
setPrimaryClip
(
clip
);
result
.
success
(
null
);
return
;
}
result
.
notImplemented
();
}
...
...
dev/integration_tests/android_semantics_testing/lib/main.dart
View file @
adda8e93
...
...
@@ -39,6 +39,21 @@ Future<String> dataHandler(String message) async {
completeSemantics
();
return
completer
.
future
;
}
if
(
message
.
contains
(
'setClipboard'
))
{
final
Completer
<
String
>
completer
=
Completer
<
String
>();
final
String
str
=
message
.
split
(
'#'
)[
1
];
Future
<
void
>
completeSetClipboard
([
Object
_
])
async
{
await
kSemanticsChannel
.
invokeMethod
<
dynamic
>(
'setClipboard'
,
<
String
,
dynamic
>{
'message'
:
str
,
});
completer
.
complete
(
''
);
}
if
(
SchedulerBinding
.
instance
.
hasScheduledFrame
)
SchedulerBinding
.
instance
.
addPostFrameCallback
(
completeSetClipboard
);
else
completeSetClipboard
();
return
completer
.
future
;
}
throw
UnimplementedError
();
}
...
...
dev/integration_tests/android_semantics_testing/test_driver/main_test.dart
View file @
adda8e93
...
...
@@ -120,29 +120,7 @@ void main() {
// Ideally this should test the case where there is nothing on the
// clipboard as well, but there is no reliable way to clear the
// clipboard on Android devices.
final
SerializableFinder
normalTextField
=
find
.
descendant
(
of:
find
.
byValueKey
(
normalTextFieldKeyValue
),
matching:
find
.
byType
(
'Semantics'
),
firstMatchOnly:
true
,
);
await
driver
.
tap
(
normalTextField
);
await
Future
<
void
>.
delayed
(
const
Duration
(
milliseconds:
500
));
await
driver
.
enterText
(
'hello world'
);
await
Future
<
void
>.
delayed
(
const
Duration
(
milliseconds:
500
));
await
driver
.
tap
(
normalTextField
);
await
Future
<
void
>.
delayed
(
const
Duration
(
milliseconds:
50
));
await
driver
.
tap
(
normalTextField
);
await
Future
<
void
>.
delayed
(
const
Duration
(
milliseconds:
500
));
await
driver
.
tap
(
find
.
text
(
'Select all'
));
await
Future
<
void
>.
delayed
(
const
Duration
(
milliseconds:
500
));
await
driver
.
tap
(
find
.
text
(
'Copy'
));
await
Future
<
void
>.
delayed
(
const
Duration
(
milliseconds:
50
));
await
driver
.
enterText
(
''
);
await
Future
<
void
>.
delayed
(
const
Duration
(
milliseconds:
500
));
// Go back to previous page and forward again to unfocus the field.
await
driver
.
tap
(
find
.
byValueKey
(
backButtonKeyValue
));
await
Future
<
void
>.
delayed
(
const
Duration
(
milliseconds:
500
));
await
driver
.
tap
(
find
.
text
(
textFieldRoute
));
await
driver
.
requestData
(
'setClipboard#Hello World'
);
await
Future
<
void
>.
delayed
(
const
Duration
(
milliseconds:
500
));
});
...
...
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