Skip to content

Commit 4c71cb6

Browse files
committed
test
1 parent c19167c commit 4c71cb6

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ TODO: Remove this section if there are not any updates.
2727

2828
## CPU profiler updates
2929

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

3232
## Memory updates
3333

packages/devtools_app/test/shared/charts/flame_chart_test.dart

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

55
import 'package:devtools_app/devtools_app.dart';
6+
import 'package:devtools_app/src/screens/profiler/cpu_profile_transformer.dart';
67
import 'package:devtools_app/src/screens/profiler/cpu_profiler_controller.dart';
78
import 'package:devtools_app/src/screens/profiler/panes/cpu_flame_chart.dart';
89
import 'package:devtools_app/src/shared/charts/flame_chart.dart';
@@ -624,6 +625,56 @@ void main() {
624625
);
625626
});
626627
});
628+
629+
testWidgets('re-lays out elements when container width changes', (
630+
WidgetTester tester,
631+
) async {
632+
final transformer = CpuProfileTransformer();
633+
final cpuProfileData = CpuProfileData.fromJson(cpuProfileResponseJson);
634+
await tester.runAsync(() async {
635+
await transformer.processData(cpuProfileData, processId: 'test');
636+
});
637+
638+
flameChart = CpuProfileFlameChart(
639+
data: cpuProfileData,
640+
width: 1000.0,
641+
height: 1000.0,
642+
selectionNotifier: ValueNotifier<CpuStackFrame?>(null),
643+
searchMatchesNotifier: controller.searchMatches,
644+
activeSearchMatchNotifier: controller.activeSearchMatch,
645+
onDataSelected: (_) {},
646+
);
647+
648+
await pumpFlameChart(tester);
649+
expect(find.byWidget(flameChart), findsOneWidget);
650+
final FlameChartState state = tester.state(find.byWidget(flameChart));
651+
652+
// Find first row that has nodes.
653+
final rowWithNodes = state.rows.firstWhere((row) => row.nodes.isNotEmpty);
654+
final node = rowWithNodes.nodes[0];
655+
final initialNodeWidth = node.rect.width;
656+
expect(initialNodeWidth, greaterThan(0.0));
657+
658+
// Update the flame chart with a new width.
659+
flameChart = CpuProfileFlameChart(
660+
data: cpuProfileData,
661+
width: 2000.0,
662+
height: 1000.0,
663+
selectionNotifier: ValueNotifier<CpuStackFrame?>(null),
664+
searchMatchesNotifier: controller.searchMatches,
665+
activeSearchMatchNotifier: controller.activeSearchMatch,
666+
onDataSelected: (_) {},
667+
);
668+
await pumpFlameChart(tester);
669+
await tester.pumpAndSettle();
670+
671+
final updatedRowWithNodes = state.rows.firstWhere(
672+
(row) => row.nodes.isNotEmpty,
673+
);
674+
final updatedNode = updatedRowWithNodes.nodes[0];
675+
expect(updatedNode.rect.width, isNot(equals(initialNodeWidth)));
676+
expect(updatedNode.rect.width, greaterThan(initialNodeWidth));
677+
});
627678
});
628679

629680
group('ScrollingFlameChartRow', () {

0 commit comments

Comments
 (0)