<commit_before>// Copyright 2013 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.

// ignore_for_file: avoid_print

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:web_benchmarks/client.dart';

import '../aboutpage.dart' show backKey;
import '../homepage.dart' show aboutPageKey, textKey;
import '../main.dart';

/// A recorder that measures frame building durations.
abstract class AppRecorder extends WidgetRecorder {
  AppRecorder({required this.benchmarkName}) : super(name: benchmarkName);

  final String benchmarkName;

  Future<void> automate();

  @override
  Widget createWidget() {
    Future<void>.delayed(const Duration(milliseconds: 400), automate);
    return const MyApp();
  }

  Future<void> animationStops() async {
    while (WidgetsBinding.instance.hasScheduledFrame) {
      await Future<void>.delayed(const Duration(milliseconds: 200));
    }
  }
}

class ScrollRecorder extends AppRecorder {
  ScrollRecorder() : super(benchmarkName: 'scroll');

  @override
  Future<void> automate() async {
    final ScrollableState scrollable =
        Scrollable.of(find.byKey(textKey).evaluate().single)!;
    await scrollable.position.animateTo(
      30000,
      curve: Curves.linear,
      duration: const Duration(seconds: 20),
    );
  }
}

class PageRecorder extends AppRecorder {
  PageRecorder() : super(benchmarkName: 'page');

  bool _completed = false;

  @override
  bool shouldContinue() => profile.shouldContinue() || !_completed;

  @override<commit_msg>[web_benchmarks] add ignore unnecessary_non_null_assertion for Scrollable.of (#2765)<commit_after>// Copyright 2013 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.

// ignore_for_file: avoid_print

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:web_benchmarks/client.dart';

import '../aboutpage.dart' show backKey;
import '../homepage.dart' show aboutPageKey, textKey;
import '../main.dart';

/// A recorder that measures frame building durations.
abstract class AppRecorder extends WidgetRecorder {
  AppRecorder({required this.benchmarkName}) : super(name: benchmarkName);

  final String benchmarkName;

  Future<void> automate();

  @override
  Widget createWidget() {
    Future<void>.delayed(const Duration(milliseconds: 400), automate);
    return const MyApp();
  }

  Future<void> animationStops() async {
    while (WidgetsBinding.instance.hasScheduledFrame) {
      await Future<void>.delayed(const Duration(milliseconds: 200));
    }
  }
}

class ScrollRecorder extends AppRecorder {
  ScrollRecorder() : super(benchmarkName: 'scroll');

  @override
  Future<void> automate() async {
    final ScrollableState scrollable =
        // TODO(cyanglaz): Fix the unnecessary non null assertion when https://github.com/flutter/flutter/commit/37b72342b0ce86fbfc238a9d43e524608b89af3a is on stable,
        // https://github.com/flutter/flutter/issues/114434
        //ignore: unnecessary_non_null_assertion
        Scrollable.of(find.byKey(textKey).evaluate().single)!;
    await scrollable.position.animateTo(
      30000,
      curve: Curves.linear,
      duration: const Duration(seconds: 20),
    );
  }
}

class PageRecorder extends AppRecorder {
  PageRecorder() : super(benchmarkName: 'page');

  bool _completed = false;

  @override
  bool shouldContinue() => profile.shouldContinue() || !_completed;

  @override
{'fraction_non_alphanumeric': 0.11243093922651934, 'fraction_numerical': 0.019060773480662985, 'mean_word_length': 4.317180616740088, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '16521', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1067, 'n_words': 274}