Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ abstract class FlameChartState<
verticalControllerGroup.resetScroll();
zoomController.reset();
verticalExtentDelegate.recompute();
} else if (widget.containerWidth != oldWidget.containerWidth) {
initFlameChartElements();
verticalExtentDelegate.recompute();
}
FocusScope.of(context).requestFocus(focusNode);
super.didUpdateWidget(oldWidget);
Expand Down
6 changes: 4 additions & 2 deletions packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ TODO: Remove this section if there are not any updates.

## CPU profiler updates

TODO: Remove this section if there are not any updates.
* Fixed a bug where resizing the CPU flame chart changes the timing values
across the top of the chart.
[#9915](https://github.com/flutter/devtools/pull/9915)

## Memory updates

Expand All @@ -40,7 +42,7 @@ TODO: Remove this section if there are not any updates.

## Network profiler updates

- Fixed exported response status in HAR files so that they parse as integers
* Fixed exported response status in HAR files so that they parse as integers
instead of strings. [#9900](https://github.com/flutter/devtools/pull/9900)

## Logging updates
Expand Down
51 changes: 51 additions & 0 deletions packages/devtools_app/test/shared/charts/flame_chart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.

import 'package:devtools_app/devtools_app.dart';
import 'package:devtools_app/src/screens/profiler/cpu_profile_transformer.dart';
import 'package:devtools_app/src/screens/profiler/cpu_profiler_controller.dart';
import 'package:devtools_app/src/screens/profiler/panes/cpu_flame_chart.dart';
import 'package:devtools_app/src/shared/charts/flame_chart.dart';
Expand Down Expand Up @@ -624,6 +625,56 @@ void main() {
);
});
});

testWidgets('re-lays out elements when container width changes', (
WidgetTester tester,
) async {
final transformer = CpuProfileTransformer();
final cpuProfileData = CpuProfileData.fromJson(cpuProfileResponseJson);
await tester.runAsync(() async {
await transformer.processData(cpuProfileData, processId: 'test');
});

flameChart = CpuProfileFlameChart(
data: cpuProfileData,
width: 1000.0,
height: 1000.0,
selectionNotifier: ValueNotifier<CpuStackFrame?>(null),
searchMatchesNotifier: controller.searchMatches,
activeSearchMatchNotifier: controller.activeSearchMatch,
onDataSelected: (_) {},
);

await pumpFlameChart(tester);
expect(find.byWidget(flameChart), findsOneWidget);
final FlameChartState state = tester.state(find.byWidget(flameChart));

// Find first row that has nodes.
final rowWithNodes = state.rows.firstWhere((row) => row.nodes.isNotEmpty);
final node = rowWithNodes.nodes[0];
final initialNodeWidth = node.rect.width;
expect(initialNodeWidth, greaterThan(0.0));

// Update the flame chart with a new width.
flameChart = CpuProfileFlameChart(
data: cpuProfileData,
width: 2000.0,
height: 1000.0,
selectionNotifier: ValueNotifier<CpuStackFrame?>(null),
searchMatchesNotifier: controller.searchMatches,
activeSearchMatchNotifier: controller.activeSearchMatch,
onDataSelected: (_) {},
);
await pumpFlameChart(tester);
await tester.pumpAndSettle();

final updatedRowWithNodes = state.rows.firstWhere(
(row) => row.nodes.isNotEmpty,
);
final updatedNode = updatedRowWithNodes.nodes[0];
expect(updatedNode.rect.width, isNot(equals(initialNodeWidth)));
expect(updatedNode.rect.width, greaterThan(initialNodeWidth));
});
});

group('ScrollingFlameChartRow', () {
Expand Down
Loading