|
3 | 3 | // found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd. |
4 | 4 |
|
5 | 5 | import 'package:devtools_app/devtools_app.dart'; |
| 6 | +import 'package:devtools_app/src/screens/profiler/cpu_profile_transformer.dart'; |
6 | 7 | import 'package:devtools_app/src/screens/profiler/cpu_profiler_controller.dart'; |
7 | 8 | import 'package:devtools_app/src/screens/profiler/panes/cpu_flame_chart.dart'; |
8 | 9 | import 'package:devtools_app/src/shared/charts/flame_chart.dart'; |
@@ -624,6 +625,56 @@ void main() { |
624 | 625 | ); |
625 | 626 | }); |
626 | 627 | }); |
| 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 | + }); |
627 | 678 | }); |
628 | 679 |
|
629 | 680 | group('ScrollingFlameChartRow', () { |
|
0 commit comments