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 @@ -37,30 +37,39 @@ class EventDetails extends StatelessWidget {
// (see html_event_details.dart).
final theme = Theme.of(context);
return OutlineDecoration(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AreaPaneHeader(
needsTopBorder: false,
tall: true,
title: Text(_generateHeaderText()),
actions: [
CpuSamplingRateDropdown(
screenId: PerformanceScreen.id,
profilePeriodFlagNotifier:
legacyController.cpuProfilerController.profilePeriodFlag!,
child: DualValueListenableBuilder<bool, Flag>(
firstListenable: offlineController.offlineMode,
secondListenable:
legacyController.cpuProfilerController.profilerFlagNotifier!,
builder: (context, offline, profilerFlag, _) {
final profilerEnabled = profilerFlag.valueAsString == 'true';
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AreaPaneHeader(
needsTopBorder: false,
tall: true,
title: Text(_generateHeaderText()),
actions: [
if (selectedEvent != null &&
selectedEvent!.isUiEvent &&
!offline &&
profilerEnabled)
CpuSamplingRateDropdown(
screenId: PerformanceScreen.id,
profilePeriodFlagNotifier: legacyController
.cpuProfilerController.profilePeriodFlag!,
),
],
),
Expanded(
child: selectedEvent != null
? _buildDetails(offline, profilerEnabled)
: _buildInstructions(theme),
),
],
),
Expanded(
child: selectedEvent != null
? ValueListenableBuilder<bool>(
valueListenable: offlineController.offlineMode,
builder: (context, offline, _) => _buildDetails(offline),
)
: _buildInstructions(theme),
),
],
);
},
),
);
}
Expand All @@ -74,23 +83,17 @@ class EventDetails extends StatelessWidget {
'${selected.name} (${msText(selected.time.duration)})';
}

Widget _buildDetails(bool offlineMode) {
Widget _buildDetails(bool offlineMode, bool profilerEnabled) {
final selected = selectedEvent!;
if (selected.isUiEvent) {
// In [offlineController.offlineMode], we do not need to worry about
// whether the profiler is enabled.
if (offlineMode) {
return _buildCpuProfiler(legacyController.cpuProfilerController);
}
return ValueListenableBuilder<Flag>(
valueListenable:
legacyController.cpuProfilerController.profilerFlagNotifier!,
builder: (context, profilerFlag, _) {
return profilerFlag.valueAsString == 'true'
? _buildCpuProfiler(legacyController.cpuProfilerController)
: CpuProfilerDisabled(legacyController.cpuProfilerController);
},
);
return profilerEnabled
? _buildCpuProfiler(legacyController.cpuProfilerController)
: CpuProfilerDisabled(legacyController.cpuProfilerController);
}
return EventSummary(selected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:devtools_app/src/screens/performance/panes/timeline_events/legac
import 'package:devtools_app/src/screens/profiler/cpu_profiler.dart';
import 'package:devtools_app/src/service/vm_flags.dart' as vm_flags;
import 'package:devtools_app/src/shared/config_specific/import_export/import_export.dart';
import 'package:devtools_app/src/shared/ui/vm_flag_widgets.dart';
import 'package:devtools_test/devtools_test.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
Expand Down Expand Up @@ -55,6 +56,19 @@ void main() {
(WidgetTester tester) async {
await pumpEventDetails(goldenUiTimelineEvent, tester);
expect(find.byType(CpuProfiler), findsOneWidget);
expect(find.byType(CpuSamplingRateDropdown), findsOneWidget);
expect(find.byType(CpuProfilerDisabled), findsNothing);
expect(find.byType(EventSummary), findsOneWidget);
expect(find.text(EventDetails.noEventSelected), findsNothing);
expect(find.text(EventDetails.instructions), findsNothing);
});

testWidgetsWithWindowSize('builds for UI event in offline mode', windowSize,
(WidgetTester tester) async {
offlineController.enterOfflineMode();
await pumpEventDetails(goldenUiTimelineEvent, tester);
expect(find.byType(CpuProfiler), findsOneWidget);
expect(find.byType(CpuSamplingRateDropdown), findsNothing);
expect(find.byType(CpuProfilerDisabled), findsNothing);
expect(find.byType(EventSummary), findsOneWidget);
expect(find.text(EventDetails.noEventSelected), findsNothing);
Expand All @@ -65,6 +79,7 @@ void main() {
(WidgetTester tester) async {
await pumpEventDetails(goldenRasterTimelineEvent, tester);
expect(find.byType(CpuProfiler), findsNothing);
expect(find.byType(CpuSamplingRateDropdown), findsNothing);
expect(find.byType(CpuProfilerDisabled), findsNothing);
expect(find.byType(EventSummary), findsOneWidget);
expect(find.text(EventDetails.noEventSelected), findsNothing);
Expand All @@ -75,6 +90,7 @@ void main() {
(WidgetTester tester) async {
await pumpEventDetails(asyncEventWithInstantChildren, tester);
expect(find.byType(CpuProfiler), findsNothing);
expect(find.byType(CpuSamplingRateDropdown), findsNothing);
expect(find.byType(CpuProfilerDisabled), findsNothing);
expect(find.byType(EventSummary), findsOneWidget);
expect(find.text(EventDetails.noEventSelected), findsNothing);
Expand All @@ -85,6 +101,7 @@ void main() {
(WidgetTester tester) async {
await pumpEventDetails(null, tester);
expect(find.byType(CpuProfiler), findsNothing);
expect(find.byType(CpuSamplingRateDropdown), findsNothing);
expect(find.byType(CpuProfilerDisabled), findsNothing);
expect(find.byType(EventSummary), findsNothing);
expect(find.text(EventDetails.noEventSelected), findsOneWidget);
Expand All @@ -96,6 +113,7 @@ void main() {
await serviceManager.service!.setFlag(vm_flags.profiler, 'false');
await pumpEventDetails(goldenUiTimelineEvent, tester);
expect(find.byType(CpuProfiler), findsNothing);
expect(find.byType(CpuSamplingRateDropdown), findsNothing);
expect(find.byType(CpuProfilerDisabled), findsOneWidget);
expect(find.byType(EventSummary), findsNothing);
expect(find.text(EventDetails.noEventSelected), findsNothing);
Expand All @@ -105,6 +123,7 @@ void main() {
await tester.pumpAndSettle();

expect(find.byType(CpuProfiler), findsOneWidget);
expect(find.byType(CpuSamplingRateDropdown), findsOneWidget);
expect(find.byType(CpuProfilerDisabled), findsNothing);
expect(find.byType(EventSummary), findsOneWidget);
});
Expand Down