Unverified Commit 20f029e3 authored by Phil Quitslund's avatar Phil Quitslund Committed by GitHub

[devicelab, flutter_test, ...] rename local functions with `_`s (#102833)

parent adb8b607
......@@ -21,8 +21,8 @@ TaskFunction createMicrobenchmarkTask() {
await device.unlock();
await device.clearLogs();
Future<Map<String, double>> _runMicrobench(String benchmarkPath) async {
Future<Map<String, double>> _run() async {
Future<Map<String, double>> runMicrobench(String benchmarkPath) async {
Future<Map<String, double>> run() async {
print('Running $benchmarkPath');
final Directory appDir = dir(
path.join(flutterDirectory.path, 'dev/benchmarks/microbenchmarks'));
......@@ -45,25 +45,25 @@ TaskFunction createMicrobenchmarkTask() {
return readJsonResults(flutterProcess);
}
return _run();
return run();
}
final Map<String, double> allResults = <String, double>{
...await _runMicrobench('lib/stocks/layout_bench.dart'),
...await _runMicrobench('lib/stocks/build_bench.dart'),
...await _runMicrobench('lib/geometry/matrix_utils_transform_bench.dart'),
...await _runMicrobench('lib/geometry/rrect_contains_bench.dart'),
...await _runMicrobench('lib/gestures/velocity_tracker_bench.dart'),
...await _runMicrobench('lib/gestures/gesture_detector_bench.dart'),
...await _runMicrobench('lib/stocks/animation_bench.dart'),
...await _runMicrobench('lib/language/compute_bench.dart'),
...await _runMicrobench('lib/language/sync_star_bench.dart'),
...await _runMicrobench('lib/language/sync_star_semantics_bench.dart'),
...await _runMicrobench('lib/foundation/all_elements_bench.dart'),
...await _runMicrobench('lib/foundation/change_notifier_bench.dart'),
...await _runMicrobench('lib/foundation/standard_method_codec_bench.dart'),
...await _runMicrobench('lib/foundation/standard_message_codec_bench.dart'),
...await _runMicrobench('lib/foundation/timeline_bench.dart'),
...await runMicrobench('lib/stocks/layout_bench.dart'),
...await runMicrobench('lib/stocks/build_bench.dart'),
...await runMicrobench('lib/geometry/matrix_utils_transform_bench.dart'),
...await runMicrobench('lib/geometry/rrect_contains_bench.dart'),
...await runMicrobench('lib/gestures/velocity_tracker_bench.dart'),
...await runMicrobench('lib/gestures/gesture_detector_bench.dart'),
...await runMicrobench('lib/stocks/animation_bench.dart'),
...await runMicrobench('lib/language/compute_bench.dart'),
...await runMicrobench('lib/language/sync_star_bench.dart'),
...await runMicrobench('lib/language/sync_star_semantics_bench.dart'),
...await runMicrobench('lib/foundation/all_elements_bench.dart'),
...await runMicrobench('lib/foundation/change_notifier_bench.dart'),
...await runMicrobench('lib/foundation/standard_method_codec_bench.dart'),
...await runMicrobench('lib/foundation/standard_message_codec_bench.dart'),
...await runMicrobench('lib/foundation/timeline_bench.dart'),
};
return TaskResult.success(allResults,
......
......@@ -2636,7 +2636,7 @@ void main() {
}
group('SliverAppBar', () {
Widget _buildSliverApp({
Widget buildSliverApp({
required double contentHeight,
bool reverse = false,
bool includeFlexibleSpace = false,
......@@ -2674,7 +2674,7 @@ void main() {
testWidgets('backgroundColor', (WidgetTester tester) async {
await tester.pumpWidget(
_buildSliverApp(contentHeight: 1200.0)
buildSliverApp(contentHeight: 1200.0)
);
expect(getAppBarBackgroundColor(tester), defaultColor);
......@@ -2699,7 +2699,7 @@ void main() {
testWidgets('backgroundColor with FlexibleSpace', (WidgetTester tester) async {
await tester.pumpWidget(
_buildSliverApp(contentHeight: 1200.0, includeFlexibleSpace: true)
buildSliverApp(contentHeight: 1200.0, includeFlexibleSpace: true)
);
expect(getAppBarBackgroundColor(tester), defaultColor);
......@@ -2724,7 +2724,7 @@ void main() {
testWidgets('backgroundColor - reverse', (WidgetTester tester) async {
await tester.pumpWidget(
_buildSliverApp(contentHeight: 1200.0, reverse: true)
buildSliverApp(contentHeight: 1200.0, reverse: true)
);
expect(getAppBarBackgroundColor(tester), defaultColor);
......@@ -2749,7 +2749,7 @@ void main() {
testWidgets('backgroundColor with FlexibleSpace - reverse', (WidgetTester tester) async {
await tester.pumpWidget(
_buildSliverApp(
buildSliverApp(
contentHeight: 1200.0,
reverse: true,
includeFlexibleSpace: true,
......@@ -2778,7 +2778,7 @@ void main() {
testWidgets('backgroundColor - not triggered in reverse for short content', (WidgetTester tester) async {
await tester.pumpWidget(
_buildSliverApp(contentHeight: 200, reverse: true)
buildSliverApp(contentHeight: 200, reverse: true)
);
// In reverse, the content here is not long enough to scroll under the app
......@@ -2797,7 +2797,7 @@ void main() {
testWidgets('backgroundColor with FlexibleSpace - not triggered in reverse for short content', (WidgetTester tester) async {
await tester.pumpWidget(
_buildSliverApp(
buildSliverApp(
contentHeight: 200,
reverse: true,
includeFlexibleSpace: true,
......@@ -2820,7 +2820,7 @@ void main() {
});
group('AppBar', () {
Widget _buildAppBar({
Widget buildAppBar({
required double contentHeight,
bool reverse = false,
bool includeFlexibleSpace = false
......@@ -2851,7 +2851,7 @@ void main() {
testWidgets('backgroundColor', (WidgetTester tester) async {
await tester.pumpWidget(
_buildAppBar(contentHeight: 1200.0)
buildAppBar(contentHeight: 1200.0)
);
expect(getAppBarBackgroundColor(tester), defaultColor);
......@@ -2876,7 +2876,7 @@ void main() {
testWidgets('backgroundColor with FlexibleSpace', (WidgetTester tester) async {
await tester.pumpWidget(
_buildAppBar(contentHeight: 1200.0, includeFlexibleSpace: true)
buildAppBar(contentHeight: 1200.0, includeFlexibleSpace: true)
);
expect(getAppBarBackgroundColor(tester), defaultColor);
......@@ -2901,7 +2901,7 @@ void main() {
testWidgets('backgroundColor - reverse', (WidgetTester tester) async {
await tester.pumpWidget(
_buildAppBar(contentHeight: 1200.0, reverse: true)
buildAppBar(contentHeight: 1200.0, reverse: true)
);
await tester.pump();
......@@ -2929,7 +2929,7 @@ void main() {
testWidgets('backgroundColor with FlexibleSpace - reverse', (WidgetTester tester) async {
await tester.pumpWidget(
_buildAppBar(
buildAppBar(
contentHeight: 1200.0,
reverse: true,
includeFlexibleSpace: true,
......@@ -3027,7 +3027,7 @@ void main() {
testWidgets('backgroundColor - not triggered in reverse for short content', (WidgetTester tester) async {
await tester.pumpWidget(
_buildAppBar(
buildAppBar(
contentHeight: 200.0,
reverse: true,
)
......@@ -3050,7 +3050,7 @@ void main() {
testWidgets('backgroundColor with FlexibleSpace - not triggered in reverse for short content', (WidgetTester tester) async {
await tester.pumpWidget(
_buildAppBar(
buildAppBar(
contentHeight: 200.0,
reverse: true,
includeFlexibleSpace: true,
......
......@@ -226,7 +226,7 @@ void main() {
const Size kCommonScreenSizePortrait = Size(1070, 1770);
const Size kCommonScreenSizeLandscape = Size(1770, 1070);
Future<void> _showPicker(WidgetTester tester, Locale locale, Size size) async {
Future<void> showPicker(WidgetTester tester, Locale locale, Size size) async {
tester.binding.window.physicalSizeTestValue = size;
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
tester.binding.window.devicePixelRatioTestValue = 1.0;
......@@ -260,22 +260,22 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/20171
testWidgets('common screen size - portrait - Chinese', (WidgetTester tester) async {
await _showPicker(tester, const Locale('zh', 'CN'), kCommonScreenSizePortrait);
await showPicker(tester, const Locale('zh', 'CN'), kCommonScreenSizePortrait);
expect(tester.takeException(), isNull);
});
testWidgets('common screen size - landscape - Chinese', (WidgetTester tester) async {
await _showPicker(tester, const Locale('zh', 'CN'), kCommonScreenSizeLandscape);
await showPicker(tester, const Locale('zh', 'CN'), kCommonScreenSizeLandscape);
expect(tester.takeException(), isNull);
});
testWidgets('common screen size - portrait - Japanese', (WidgetTester tester) async {
await _showPicker(tester, const Locale('ja', 'JA'), kCommonScreenSizePortrait);
await showPicker(tester, const Locale('ja', 'JA'), kCommonScreenSizePortrait);
expect(tester.takeException(), isNull);
});
testWidgets('common screen size - landscape - Japanese', (WidgetTester tester) async {
await _showPicker(tester, const Locale('ja', 'JA'), kCommonScreenSizeLandscape);
await showPicker(tester, const Locale('ja', 'JA'), kCommonScreenSizeLandscape);
expect(tester.takeException(), isNull);
});
});
......
......@@ -638,7 +638,7 @@ Map<Color, int> _colorsWithinRect(
final Map<int, int> rgbaToCount = <int, int>{};
int _getPixel(ByteData data, int x, int y) {
int getPixel(ByteData data, int x, int y) {
final int offset = (y * width + x) * 4;
return data.getUint32(offset);
}
......@@ -646,7 +646,7 @@ Map<Color, int> _colorsWithinRect(
for (int x = leftX; x < rightX; x++) {
for (int y = topY; y < bottomY; y++) {
rgbaToCount.update(
_getPixel(data, x, y),
getPixel(data, x, y),
(int count) => count + 1,
ifAbsent: () => 1,
);
......
......@@ -757,7 +757,7 @@ class KeyEventSimulator {
PhysicalKeyboardKey? physicalKey,
String? character,
}) async {
Future<bool> _simulateByRawEvent() {
Future<bool> simulateByRawEvent() {
return _simulateKeyEventByRawEvent(() {
platform ??= _defaultPlatform;
return getKeyData(key, platform: platform!, physicalKey: physicalKey, character: character);
......@@ -765,7 +765,7 @@ class KeyEventSimulator {
}
switch (_transitMode) {
case KeyDataTransitMode.rawKeyData:
return _simulateByRawEvent();
return simulateByRawEvent();
case KeyDataTransitMode.keyDataThenRawKeyData:
final LogicalKeyboardKey logicalKey = _getKeySynonym(key);
final bool resultByKeyEvent = ServicesBinding.instance.keyEventManager.handleKeyData(
......@@ -778,7 +778,7 @@ class KeyEventSimulator {
synthesized: false,
),
);
return (await _simulateByRawEvent()) || resultByKeyEvent;
return (await simulateByRawEvent()) || resultByKeyEvent;
}
}
......@@ -802,7 +802,7 @@ class KeyEventSimulator {
String? platform,
PhysicalKeyboardKey? physicalKey,
}) async {
Future<bool> _simulateByRawEvent() {
Future<bool> simulateByRawEvent() {
return _simulateKeyEventByRawEvent(() {
platform ??= _defaultPlatform;
return getKeyData(key, platform: platform!, isDown: false, physicalKey: physicalKey);
......@@ -810,7 +810,7 @@ class KeyEventSimulator {
}
switch (_transitMode) {
case KeyDataTransitMode.rawKeyData:
return _simulateByRawEvent();
return simulateByRawEvent();
case KeyDataTransitMode.keyDataThenRawKeyData:
final LogicalKeyboardKey logicalKey = _getKeySynonym(key);
final bool resultByKeyEvent = ServicesBinding.instance.keyEventManager.handleKeyData(
......@@ -823,7 +823,7 @@ class KeyEventSimulator {
synthesized: false,
),
);
return (await _simulateByRawEvent()) || resultByKeyEvent;
return (await simulateByRawEvent()) || resultByKeyEvent;
}
}
......@@ -848,7 +848,7 @@ class KeyEventSimulator {
PhysicalKeyboardKey? physicalKey,
String? character,
}) async {
Future<bool> _simulateByRawEvent() {
Future<bool> simulateByRawEvent() {
return _simulateKeyEventByRawEvent(() {
platform ??= _defaultPlatform;
return getKeyData(key, platform: platform!, physicalKey: physicalKey, character: character);
......@@ -856,7 +856,7 @@ class KeyEventSimulator {
}
switch (_transitMode) {
case KeyDataTransitMode.rawKeyData:
return _simulateByRawEvent();
return simulateByRawEvent();
case KeyDataTransitMode.keyDataThenRawKeyData:
final LogicalKeyboardKey logicalKey = _getKeySynonym(key);
final bool resultByKeyEvent = ServicesBinding.instance.keyEventManager.handleKeyData(
......@@ -869,7 +869,7 @@ class KeyEventSimulator {
synthesized: false,
),
);
return (await _simulateByRawEvent()) || resultByKeyEvent;
return (await simulateByRawEvent()) || resultByKeyEvent;
}
}
}
......
......@@ -59,14 +59,14 @@ void main() {
TextStyle(color: blue29, backgroundColor: surface, fontSize: 18),
];
Widget _appWithTextWidget(TextStyle style) => _boilerplate(
Widget appWithTextWidget(TextStyle style) => _boilerplate(
Text('this is text', style: style.copyWith(height: 30.0)),
);
for (final TextStyle style in textStylesMeetingGuideline) {
testWidgets('text with style $style', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(_appWithTextWidget(style));
await tester.pumpWidget(appWithTextWidget(style));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -75,7 +75,7 @@ void main() {
for (final TextStyle style in textStylesDoesNotMeetingGuideline) {
testWidgets('text with $style', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(_appWithTextWidget(style));
await tester.pumpWidget(appWithTextWidget(style));
await expectLater(tester, doesNotMeetGuideline(textContrastGuideline));
handle.dispose();
});
......@@ -261,7 +261,7 @@ void main() {
});
group('custom minimum contrast guideline', () {
Widget _icon({
Widget iconWidget({
IconData icon = Icons.search,
required Color color,
required Color background,
......@@ -273,7 +273,7 @@ void main() {
);
}
Widget _text({
Widget textWidget({
String text = 'Text',
required Color color,
required Color background,
......@@ -285,16 +285,16 @@ void main() {
);
}
Widget _row(List<Widget> widgets) => _boilerplate(Row(children: widgets));
Widget rowWidget(List<Widget> widgets) => _boilerplate(Row(children: widgets));
final Finder findIcons = find.byWidgetPredicate((Widget widget) => widget is Icon);
final Finder findTexts = find.byWidgetPredicate((Widget widget) => widget is Text);
final Finder findIconsAndTexts = find.byWidgetPredicate((Widget widget) => widget is Icon || widget is Text);
testWidgets('Black icons on white background', (WidgetTester tester) async {
await tester.pumpWidget(_row(<Widget>[
_icon(color: Colors.black, background: Colors.white),
_icon(color: Colors.black, background: Colors.white),
await tester.pumpWidget(rowWidget(<Widget>[
iconWidget(color: Colors.black, background: Colors.white),
iconWidget(color: Colors.black, background: Colors.white),
]));
await expectLater(
......@@ -304,9 +304,9 @@ void main() {
});
testWidgets('Black icons on black background', (WidgetTester tester) async {
await tester.pumpWidget(_row(<Widget>[
_icon(color: Colors.black, background: Colors.black),
_icon(color: Colors.black, background: Colors.black),
await tester.pumpWidget(rowWidget(<Widget>[
iconWidget(color: Colors.black, background: Colors.black),
iconWidget(color: Colors.black, background: Colors.black),
]));
await expectLater(
......@@ -317,9 +317,9 @@ void main() {
testWidgets('White icons on black background ("dark mode")',
(WidgetTester tester) async {
await tester.pumpWidget(_row(<Widget>[
_icon(color: Colors.white, background: Colors.black),
_icon(color: Colors.white, background: Colors.black),
await tester.pumpWidget(rowWidget(<Widget>[
iconWidget(color: Colors.white, background: Colors.black),
iconWidget(color: Colors.white, background: Colors.black),
]));
await expectLater(
......@@ -329,11 +329,11 @@ void main() {
});
testWidgets('Using different icons', (WidgetTester tester) async {
await tester.pumpWidget(_row(<Widget>[
_icon(color: Colors.black, background: Colors.white, icon: Icons.more_horiz),
_icon(color: Colors.black, background: Colors.white, icon: Icons.description),
_icon(color: Colors.black, background: Colors.white, icon: Icons.image),
_icon(color: Colors.black, background: Colors.white, icon: Icons.beach_access),
await tester.pumpWidget(rowWidget(<Widget>[
iconWidget(color: Colors.black, background: Colors.white, icon: Icons.more_horiz),
iconWidget(color: Colors.black, background: Colors.white, icon: Icons.description),
iconWidget(color: Colors.black, background: Colors.white, icon: Icons.image),
iconWidget(color: Colors.black, background: Colors.white, icon: Icons.beach_access),
]));
await expectLater(
......@@ -344,9 +344,9 @@ void main() {
testWidgets('One invalid instance fails entire test',
(WidgetTester tester) async {
await tester.pumpWidget(_row(<Widget>[
_icon(color: Colors.black, background: Colors.white),
_icon(color: Colors.black, background: Colors.black),
await tester.pumpWidget(rowWidget(<Widget>[
iconWidget(color: Colors.black, background: Colors.white),
iconWidget(color: Colors.black, background: Colors.black),
]));
await expectLater(
......@@ -357,11 +357,11 @@ void main() {
testWidgets('White on different colors, passing',
(WidgetTester tester) async {
await tester.pumpWidget(_row(<Widget>[
_icon(color: Colors.white, background: Colors.red[800]!, icon: Icons.more_horiz),
_icon(color: Colors.white, background: Colors.green[800]!, icon: Icons.description),
_icon(color: Colors.white, background: Colors.blue[800]!, icon: Icons.image),
_icon(color: Colors.white, background: Colors.purple[800]!, icon: Icons.beach_access),
await tester.pumpWidget(rowWidget(<Widget>[
iconWidget(color: Colors.white, background: Colors.red[800]!, icon: Icons.more_horiz),
iconWidget(color: Colors.white, background: Colors.green[800]!, icon: Icons.description),
iconWidget(color: Colors.white, background: Colors.blue[800]!, icon: Icons.image),
iconWidget(color: Colors.white, background: Colors.purple[800]!, icon: Icons.beach_access),
]));
await expectLater(tester,
......@@ -370,11 +370,11 @@ void main() {
testWidgets('White on different colors, failing',
(WidgetTester tester) async {
await tester.pumpWidget(_row(<Widget>[
_icon(color: Colors.white, background: Colors.red[200]!, icon: Icons.more_horiz),
_icon(color: Colors.white, background: Colors.green[400]!, icon: Icons.description),
_icon(color: Colors.white, background: Colors.blue[600]!, icon: Icons.image),
_icon(color: Colors.white, background: Colors.purple[800]!, icon: Icons.beach_access),
await tester.pumpWidget(rowWidget(<Widget>[
iconWidget(color: Colors.white, background: Colors.red[200]!, icon: Icons.more_horiz),
iconWidget(color: Colors.white, background: Colors.green[400]!, icon: Icons.description),
iconWidget(color: Colors.white, background: Colors.blue[600]!, icon: Icons.image),
iconWidget(color: Colors.white, background: Colors.purple[800]!, icon: Icons.beach_access),
]));
await expectLater(
......@@ -384,7 +384,7 @@ void main() {
});
testWidgets('Absence of icons, passing', (WidgetTester tester) async {
await tester.pumpWidget(_row(<Widget>[]));
await tester.pumpWidget(rowWidget(<Widget>[]));
await expectLater(
tester,
......@@ -394,9 +394,9 @@ void main() {
testWidgets('Absence of icons, passing - 2nd test',
(WidgetTester tester) async {
await tester.pumpWidget(_row(<Widget>[
_text(color: Colors.black, background: Colors.white),
_text(color: Colors.black, background: Colors.black),
await tester.pumpWidget(rowWidget(<Widget>[
textWidget(color: Colors.black, background: Colors.white),
textWidget(color: Colors.black, background: Colors.black),
]));
await expectLater(
......@@ -407,11 +407,11 @@ void main() {
testWidgets('Guideline ignores widgets of other types',
(WidgetTester tester) async {
await tester.pumpWidget(_row(<Widget>[
_icon(color: Colors.black, background: Colors.white),
_icon(color: Colors.black, background: Colors.white),
_text(color: Colors.black, background: Colors.white),
_text(color: Colors.black, background: Colors.black),
await tester.pumpWidget(rowWidget(<Widget>[
iconWidget(color: Colors.black, background: Colors.white),
iconWidget(color: Colors.black, background: Colors.white),
textWidget(color: Colors.black, background: Colors.white),
textWidget(color: Colors.black, background: Colors.black),
]));
await expectLater(
......@@ -429,9 +429,9 @@ void main() {
});
testWidgets('Custom minimum ratio - Icons', (WidgetTester tester) async {
await tester.pumpWidget(_row(<Widget>[
_icon(color: Colors.blue, background: Colors.white),
_icon(color: Colors.black, background: Colors.white),
await tester.pumpWidget(rowWidget(<Widget>[
iconWidget(color: Colors.blue, background: Colors.white),
iconWidget(color: Colors.black, background: Colors.white),
]));
await expectLater(
......@@ -445,9 +445,9 @@ void main() {
});
testWidgets('Custom minimum ratio - Texts', (WidgetTester tester) async {
await tester.pumpWidget(_row(<Widget>[
_text(color: Colors.blue, background: Colors.white),
_text(color: Colors.black, background: Colors.white),
await tester.pumpWidget(rowWidget(<Widget>[
textWidget(color: Colors.blue, background: Colors.white),
textWidget(color: Colors.black, background: Colors.white),
]));
await expectLater(
......@@ -463,11 +463,11 @@ void main() {
testWidgets(
'Custom minimum ratio - Different standards for icons and texts',
(WidgetTester tester) async {
await tester.pumpWidget(_row(<Widget>[
_icon(color: Colors.blue, background: Colors.white),
_icon(color: Colors.black, background: Colors.white),
_text(color: Colors.blue, background: Colors.white),
_text(color: Colors.black, background: Colors.white),
await tester.pumpWidget(rowWidget(<Widget>[
iconWidget(color: Colors.blue, background: Colors.white),
iconWidget(color: Colors.black, background: Colors.white),
textWidget(color: Colors.blue, background: Colors.white),
textWidget(color: Colors.black, background: Colors.white),
]));
await expectLater(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment