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
7bc4074f
Unverified
Commit
7bc4074f
authored
Sep 02, 2019
by
Jonah Williams
Committed by
GitHub
Sep 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use dpr and window size from binding (#39577)
parent
f12a5ec3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
7 deletions
+48
-7
accessibility.dart
packages/flutter_test/lib/src/accessibility.dart
+8
-7
accessibility_window_test.dart
packages/flutter_test/test/accessibility_window_test.dart
+40
-0
No files found.
packages/flutter_test/lib/src/accessibility.dart
View file @
7bc4074f
...
...
@@ -201,7 +201,7 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
final
ByteData
byteData
=
await
tester
.
binding
.
runAsync
<
ByteData
>(()
async
{
// Needs to be the same pixel ratio otherwise our dimensions won't match the
// last transform layer.
image
=
await
layer
.
toImage
(
renderView
.
paintBounds
,
pixelRatio:
1
/
3
);
image
=
await
layer
.
toImage
(
renderView
.
paintBounds
,
pixelRatio:
1
/
tester
.
binding
.
window
.
devicePixelRatio
);
return
image
.
toByteData
();
});
...
...
@@ -260,7 +260,7 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
return
result
;
}
if
(
_isNodeOffScreen
(
paintBounds
))
{
if
(
_isNodeOffScreen
(
paintBounds
,
tester
.
binding
.
window
))
{
return
result
;
}
final
List
<
int
>
subset
=
_subsetToRect
(
byteData
,
paintBounds
,
image
.
width
,
image
.
height
);
...
...
@@ -302,13 +302,14 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
// Returns a rect that is entirely on screen, or null if it is too far off.
//
// Given an 1800 * 2400 pixel buffer, can we actually get all the data from
// this node? allow a small delta overlap before culling the node.
bool
_isNodeOffScreen
(
Rect
paintBounds
)
{
// Given a pixel buffer based on the physical window size, can we actually
// get all the data from this node? allow a small delta overlap before
// culling the node.
bool
_isNodeOffScreen
(
Rect
paintBounds
,
ui
.
Window
window
)
{
return
paintBounds
.
top
<
-
50.0
||
paintBounds
.
left
<
-
50.0
||
paintBounds
.
bottom
>
2400.0
+
50.0
||
paintBounds
.
right
>
1800.0
+
50.0
;
||
paintBounds
.
bottom
>
(
window
.
physicalSize
.
height
*
window
.
devicePixelRatio
)
+
50.0
||
paintBounds
.
right
>
(
window
.
physicalSize
.
width
*
window
.
devicePixelRatio
)
+
50.0
;
}
List
<
int
>
_subsetToRect
(
ByteData
data
,
Rect
paintBounds
,
int
width
,
int
height
)
{
...
...
packages/flutter_test/test/accessibility_window_test.dart
0 → 100644
View file @
7bc4074f
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'Fails correctly with configured screen size - small'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
window
.
devicePixelRatioTestValue
=
1.2
;
tester
.
binding
.
window
.
physicalSizeTestValue
=
const
Size
(
250
,
300
);
final
RaisedButton
invalidButton
=
RaisedButton
(
onPressed:
()
{},
child:
const
Text
(
'Button'
),
textColor:
Colors
.
orange
,
color:
Colors
.
orangeAccent
,
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
invalidButton
)));
final
Evaluation
result
=
await
textContrastGuideline
.
evaluate
(
tester
);
expect
(
result
.
passed
,
false
);
});
testWidgets
(
'Fails correctly with configured screen size - large'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
window
.
devicePixelRatioTestValue
=
4.2
;
tester
.
binding
.
window
.
physicalSizeTestValue
=
const
Size
(
2500
,
3000
);
final
RaisedButton
invalidButton
=
RaisedButton
(
onPressed:
()
{},
child:
const
Text
(
'Button'
),
textColor:
Colors
.
orange
,
color:
Colors
.
orangeAccent
,
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
invalidButton
)));
final
Evaluation
result
=
await
textContrastGuideline
.
evaluate
(
tester
);
expect
(
result
.
passed
,
false
);
});
}
\ No newline at end of file
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