From 9aed29873a3c8f4b8897224cf8291dcddd60e54a Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Fri, 18 Feb 2022 20:43:35 -0800 Subject: [PATCH] Revert "Add more tests to slider to avoid future breakages (#98772)" (#98783) This reverts commit baa2803fe1da00b18c47797abc31db230a64f5df. --- .../value_indicating_slider_test.dart | 233 ------------------ 1 file changed, 233 deletions(-) delete mode 100644 packages/flutter/test/material/value_indicating_slider_test.dart diff --git a/packages/flutter/test/material/value_indicating_slider_test.dart b/packages/flutter/test/material/value_indicating_slider_test.dart deleted file mode 100644 index ffe3456378..0000000000 --- a/packages/flutter/test/material/value_indicating_slider_test.dart +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright 2014 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. - -// This file is run as part of a reduced test set in CI on Mac and Windows -// machines. -@Tags(['reduced-test-set']) - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - testWidgets('Slider value indicator', (WidgetTester tester) async { - await _buildValueIndicatorStaticSlider( - tester, - value: 0, - ); - - await _pressStartThumb(tester); - - await expectLater( - find.byType(MaterialApp), - matchesGoldenFile('slider_start_text_scale_1_width_0'), - ); - - await _buildValueIndicatorStaticSlider( - tester, - value: 0.5, - ); - - await _pressMiddleThumb(tester); - - await expectLater( - find.byType(MaterialApp), - matchesGoldenFile('slider_middle_text_scale_1_width_0'), - ); - - await _buildValueIndicatorStaticSlider( - tester, - value: 1, - ); - - await _pressEndThumb(tester); - - await expectLater( - find.byType(MaterialApp), - matchesGoldenFile('slider_end_text_scale_1_width_0'), - ); - }); - - testWidgets('Slider value indicator wide text', (WidgetTester tester) async { - await _buildValueIndicatorStaticSlider( - tester, - value: 0, - decimalCount: 5, - ); - - await _pressStartThumb(tester); - - await expectLater( - find.byType(MaterialApp), - matchesGoldenFile('slider_start_text_scale_1_width_5'), - ); - - await _buildValueIndicatorStaticSlider( - tester, - value: 0.5, - decimalCount: 5, - ); - - await _pressMiddleThumb(tester); - - await expectLater( - find.byType(MaterialApp), - matchesGoldenFile('slider_middle_text_scale_1_width_5'), - ); - - await _buildValueIndicatorStaticSlider( - tester, - value: 1, - decimalCount: 5, - ); - - await _pressEndThumb(tester); - - await expectLater( - find.byType(MaterialApp), - matchesGoldenFile('slider_end_text_scale_1_width_5'), - ); - }); - - testWidgets('Slider value indicator large text scale', (WidgetTester tester) async { - await _buildValueIndicatorStaticSlider( - tester, - value: 0, - textScale: 3, - ); - - await _pressStartThumb(tester); - - await expectLater( - find.byType(MaterialApp), - matchesGoldenFile('slider_start_text_scale_4_width_0'), - ); - - await _buildValueIndicatorStaticSlider( - tester, - value: 0.5, - textScale: 3, - ); - - await _pressMiddleThumb(tester); - - await expectLater( - find.byType(MaterialApp), - matchesGoldenFile('slider_middle_text_scale_4_width_0'), - ); - - await _buildValueIndicatorStaticSlider( - tester, - value: 1, - textScale: 3, - ); - - await _pressEndThumb(tester); - - await expectLater( - find.byType(MaterialApp), - matchesGoldenFile('slider_end_text_scale_4_width_0'), - ); - }); - - testWidgets('Slider value indicator large text scale and wide text', - (WidgetTester tester) async { - await _buildValueIndicatorStaticSlider( - tester, - value: 0, - textScale: 3, - decimalCount: 5, - ); - - await _pressStartThumb(tester); - - await expectLater( - find.byType(MaterialApp), - matchesGoldenFile('slider_start_text_scale_4_width_5'), - ); - - await _buildValueIndicatorStaticSlider( - tester, - value: 0.5, - textScale: 3, - decimalCount: 5, - ); - - await _pressMiddleThumb(tester); - - await expectLater( - find.byType(MaterialApp), - matchesGoldenFile('slider_middle_text_scale_4_width_5'), - ); - - await _buildValueIndicatorStaticSlider( - tester, - value: 1, - textScale: 3, - decimalCount: 5, - ); - - await _pressEndThumb(tester); - - await expectLater( - find.byType(MaterialApp), - matchesGoldenFile('slider_end_text_scale_4_width_5'), - ); - }); -} - -Future _pressStartThumb(WidgetTester tester) async { - final Offset bottomLeft = tester.getBottomLeft(find.byType(Slider)); - final Offset topLeft = tester.getTopLeft(find.byType(Slider)); - final Offset left = (bottomLeft + topLeft) / 2; - final Offset start = left + const Offset(24, 0); - await tester.startGesture(start); - await tester.pumpAndSettle(); -} - -Future _pressMiddleThumb(WidgetTester tester) async { - await tester.press(find.byType(Slider)); - await tester.pumpAndSettle(); -} - -Future _pressEndThumb(WidgetTester tester) async { - final Offset bottomRight = tester.getBottomRight(find.byType(Slider)); - final Offset topRight = tester.getTopRight(find.byType(Slider)); - final Offset right = (bottomRight + topRight) / 2; - final Offset start = right - const Offset(24, 0); - await tester.startGesture(start); - await tester.pumpAndSettle(); -} - -Future _buildValueIndicatorStaticSlider( - WidgetTester tester, { - required double value, - double textScale = 1.0, - int decimalCount = 0, -}) async { - await tester.pumpWidget( - MaterialApp( - home: Scaffold( - body: Builder( - builder: (BuildContext context) { - return Center( - child: MediaQuery( - data: MediaQueryData(textScaleFactor: textScale), - child: SliderTheme( - data: Theme.of(context).sliderTheme.copyWith( - showValueIndicator: ShowValueIndicator.always, - ), - child: Slider( - value: value, - label: value.toStringAsFixed(decimalCount), - onChanged: (double newValue) {}, - ), - ), - ), - ); - }, - ), - ), - ), - ); -}