Skip to content

Commit

Permalink
New record button (#7573)
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderDake authored Apr 19, 2024
1 parent 37cfc80 commit 2afc06e
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 41 deletions.
25 changes: 8 additions & 17 deletions packages/devtools_app/lib/src/screens/network/network_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -213,24 +213,15 @@ class _NetworkProfilerControlsState extends State<_NetworkProfilerControls>
final hasRequests = _filteredRequests.isNotEmpty;
return Row(
children: [
PauseButton(
minScreenWidthForTextBeforeScaling:
_NetworkProfilerControls._includeTextWidth,
tooltip: 'Pause recording network traffic',
gaScreen: gac.network,
gaSelection: gac.pause,
onPressed:
_recording ? () => widget.controller.togglePolling(false) : null,
),
const SizedBox(width: denseSpacing),
ResumeButton(
minScreenWidthForTextBeforeScaling:
_NetworkProfilerControls._includeTextWidth,
tooltip: 'Resume recording network traffic',
StartStopRecordingButton(
recording: _recording,
onPressed: () => widget.controller.togglePolling(!_recording),
tooltipOverride: _recording
? 'Stop recording network traffic'
: 'Resume recording network traffic',
minScreenWidthForTextBeforeScaling: double.infinity,
gaScreen: gac.network,
gaSelection: gac.resume,
onPressed:
_recording ? null : () => widget.controller.togglePolling(true),
gaSelection: _recording ? gac.pause : gac.resume,
),
const SizedBox(width: denseSpacing),
ClearButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,14 @@ class _PrimaryControls extends StatelessWidget {
Widget build(BuildContext context) {
return Row(
children: [
RecordButton(
StartStopRecordingButton(
recording: recording,
gaScreen: gac.cpuProfiler,
gaSelection: gac.record,
gaSelection: recording ? gac.stop : gac.record,
minScreenWidthForTextBeforeScaling:
_primaryControlsMinIncludeTextWidth,
onPressed: controller.startRecording,
),
const SizedBox(width: denseSpacing),
StopRecordingButton(
recording: recording,
gaScreen: gac.cpuProfiler,
gaSelection: gac.stop,
minScreenWidthForTextBeforeScaling:
_primaryControlsMinIncludeTextWidth,
onPressed: controller.stopRecording,
onPressed:
recording ? controller.stopRecording : controller.startRecording,
),
const SizedBox(width: denseSpacing),
ClearButton(
Expand Down
29 changes: 29 additions & 0 deletions packages/devtools_app/lib/src/shared/common_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,35 @@ class ToolbarRefresh extends ToolbarAction {
});
}

class StartStopRecordingButton extends GaDevToolsButton {
StartStopRecordingButton({
super.key,
required this.recording,
required super.onPressed,
required super.gaScreen,
required super.gaSelection,
super.minScreenWidthForTextBeforeScaling,
String? tooltipOverride,
Color? colorOverride,
String? labelOverride,
}) : super(
icon: _icon(recording),
label: labelOverride ?? _label(recording),
color: colorOverride ?? _color(recording),
tooltip: tooltipOverride ?? _tooltip(recording),
);

static IconData _icon(bool recording) =>
recording ? Icons.stop : Icons.fiber_manual_record;
static String _label(bool recording) =>
recording ? 'Stop recording' : 'Start recording';
static String _tooltip(bool recording) =>
recording ? 'Stop recording' : 'Start recording';
static Color? _color(bool recording) => recording ? Colors.red : null;

final bool recording;
}

/// Button to start recording data.
///
/// * `recording`: Whether recording is in progress.
Expand Down
9 changes: 7 additions & 2 deletions packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ TODO: Remove this section if there are not any general updates.

## CPU profiler updates

TODO: Remove this section if there are not any general updates.
* Changed to a single button, for starting and stopping
recording. - [#7573](https://github.com/flutter/devtools/pull/7573)
![A screen shot of the CPU profiler tab, with the new recording button.](./images/profiler_recording.png)

## Memory updates

Expand All @@ -34,7 +36,10 @@ TODO: Remove this section if there are not any general updates.
* During a hot-restart, `pause_isolates_on_start` and only `resume` the app once breakpoints are set. - [#7234](https://github.com/flutter/devtools/pull/7234)

## Network profiler updates


* Changed to a single button, for starting and stopping
recording. - [#7573](https://github.com/flutter/devtools/pull/7573)
![A screen shot of the network tab, with the new recording button.](./images/network_recording.png)
* Added text selection in text viewer for requests and responses. - [#7596](https://github.com/flutter/devtools/pull/7596)
* Added a JSON copy experience to the JSON viewer. - [#7596](https://github.com/flutter/devtools/pull/7596)
![An image of the new json copy experience for the JSON viewer](./images/json_viewer_copy.png)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ void main() {

group('ProfilerScreen', () {
void verifyBaseState() {
expect(find.byType(RecordButton), findsOneWidget);
expect(find.byType(StopRecordingButton), findsOneWidget);
expect(find.byType(StartStopRecordingButton), findsOneWidget);
expect(find.byType(ClearButton), findsOneWidget);
expect(find.text('Load all CPU samples'), findsOneWidget);
if (scene.fakeServiceConnection.serviceManager.connectedApp!
Expand Down Expand Up @@ -102,7 +101,7 @@ void main() {
verifyBaseState();

// Start recording.
await tester.tap(find.byType(RecordButton));
await tester.tap(find.byType(StartStopRecordingButton));
await tester.pump(const Duration(seconds: 1));
expect(
find.byType(ProfileRecordingInstructions),
Expand All @@ -113,7 +112,7 @@ void main() {
expect(find.byType(CpuProfiler), findsNothing);

// Stop recording.
await tester.tap(find.byType(StopRecordingButton));
await tester.tap(find.byType(StartStopRecordingButton));
await tester.pumpAndSettle(const Duration(seconds: 2));

expect(find.byType(CircularProgressIndicator), findsNothing);
Expand Down
11 changes: 5 additions & 6 deletions packages/devtools_app/test/network/network_profiler_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ void main() {
expect(controller.recordingNotifier.value, true);

// Pause recording.
expect(find.byType(PauseButton), findsOneWidget);
await tester.tap(find.byType(PauseButton));
expect(find.byType(StartStopRecordingButton), findsOneWidget);
await tester.tap(find.byType(StartStopRecordingButton));
await tester.pumpAndSettle();

// Check that we've stopped polling.
Expand All @@ -101,8 +101,7 @@ void main() {
});

Future<void> loadRequestsAndCheck(WidgetTester tester) async {
expect(find.byType(ResumeButton), findsOneWidget);
expect(find.byType(PauseButton), findsOneWidget);
expect(find.byType(StartStopRecordingButton), findsOneWidget);
expect(find.byType(ClearButton), findsOneWidget);
expect(find.byType(SplitPane), findsOneWidget);

Expand Down Expand Up @@ -290,7 +289,7 @@ void main() {
}

// Pause recording.
await tester.tap(find.byType(PauseButton));
await tester.tap(find.byType(StartStopRecordingButton));
await tester.pump();

await clearTimeouts(tester);
Expand Down Expand Up @@ -336,7 +335,7 @@ void main() {
await loadRequestsAndCheck(tester);

// Pause the profiler.
await tester.tap(find.byType(PauseButton));
await tester.tap(find.byType(StartStopRecordingButton));
await tester.pumpAndSettle();

// Clear the results.
Expand Down

0 comments on commit 2afc06e

Please sign in to comment.