mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Some tools to dump other trees. (#9999)
This commit is contained in:
parent
4773a8cd4b
commit
db84df230d
@ -68,6 +68,16 @@ abstract class RendererBinding extends BindingBase implements SchedulerBinding,
|
|||||||
callback: () { debugDumpRenderTree(); return debugPrintDone; }
|
callback: () { debugDumpRenderTree(); return debugPrintDone; }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
registerSignalServiceExtension(
|
||||||
|
name: 'debugDumpLayerTree',
|
||||||
|
callback: () { debugDumpLayerTree(); return debugPrintDone; }
|
||||||
|
);
|
||||||
|
|
||||||
|
registerSignalServiceExtension(
|
||||||
|
name: 'debugDumpSemanticsTree',
|
||||||
|
callback: () { debugDumpSemanticsTree(); return debugPrintDone; }
|
||||||
|
);
|
||||||
|
|
||||||
assert(() {
|
assert(() {
|
||||||
// this service extension only works in checked mode
|
// this service extension only works in checked mode
|
||||||
registerBoolServiceExtension(
|
registerBoolServiceExtension(
|
||||||
|
@ -142,16 +142,52 @@ void main() {
|
|||||||
expect(result, <String, String>{});
|
expect(result, <String, String>{});
|
||||||
expect(console, <Matcher>[
|
expect(console, <Matcher>[
|
||||||
matches(
|
matches(
|
||||||
|
r'^'
|
||||||
r'RenderView#[0-9]+\n'
|
r'RenderView#[0-9]+\n'
|
||||||
r' debug mode enabled - [a-zA-Z]+\n'
|
r' debug mode enabled - [a-zA-Z]+\n'
|
||||||
r' window size: Size\(800\.0, 600\.0\) \(in physical pixels\)\n'
|
r' window size: Size\(800\.0, 600\.0\) \(in physical pixels\)\n'
|
||||||
r' device pixel ratio: 1\.0 \(physical pixels per logical pixel\)\n'
|
r' device pixel ratio: 1\.0 \(physical pixels per logical pixel\)\n'
|
||||||
r' configuration: Size\(800\.0, 600\.0\) at 1\.0x \(in logical pixels\)\n'
|
r' configuration: Size\(800\.0, 600\.0\) at 1\.0x \(in logical pixels\)\n'
|
||||||
|
r'$'
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
console.clear();
|
console.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Service extensions - debugDumpLayerTree', () async {
|
||||||
|
Map<String, String> result;
|
||||||
|
|
||||||
|
await binding.doFrame();
|
||||||
|
result = await binding.testExtension('debugDumpLayerTree', <String, String>{});
|
||||||
|
expect(result, <String, String>{});
|
||||||
|
expect(console, <Matcher>[
|
||||||
|
matches(
|
||||||
|
r'^'
|
||||||
|
r'TransformLayer#[0-9]+\n'
|
||||||
|
r' owner: RenderView#[0-9]+\n'
|
||||||
|
r' creator: RenderView\n'
|
||||||
|
r' offset: Offset\(0\.0, 0\.0\)\n'
|
||||||
|
r' transform:\n'
|
||||||
|
r' \[0] 1\.0,0\.0,0\.0,0\.0\n'
|
||||||
|
r' \[1] 0\.0,1\.0,0\.0,0\.0\n'
|
||||||
|
r' \[2] 0\.0,0\.0,1\.0,0\.0\n'
|
||||||
|
r' \[3] 0\.0,0\.0,0\.0,1\.0\n'
|
||||||
|
r'$'
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
console.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Service extensions - debugDumpSemanticsTree', () async {
|
||||||
|
Map<String, String> result;
|
||||||
|
|
||||||
|
await binding.doFrame();
|
||||||
|
result = await binding.testExtension('debugDumpSemanticsTree', <String, String>{});
|
||||||
|
expect(result, <String, String>{});
|
||||||
|
expect(console, <String>['Semantics not collected.']);
|
||||||
|
console.clear();
|
||||||
|
});
|
||||||
|
|
||||||
test('Service extensions - debugPaint', () async {
|
test('Service extensions - debugPaint', () async {
|
||||||
Map<String, String> result;
|
Map<String, String> result;
|
||||||
Future<Map<String, String>> pendingResult;
|
Future<Map<String, String>> pendingResult;
|
||||||
@ -381,7 +417,7 @@ void main() {
|
|||||||
test('Service extensions - posttest', () async {
|
test('Service extensions - posttest', () async {
|
||||||
// If you add a service extension... TEST IT! :-)
|
// If you add a service extension... TEST IT! :-)
|
||||||
// ...then increment this number.
|
// ...then increment this number.
|
||||||
expect(binding.extensions.length, 12);
|
expect(binding.extensions.length, 14);
|
||||||
|
|
||||||
expect(console, isEmpty);
|
expect(console, isEmpty);
|
||||||
debugPrint = debugPrintThrottled;
|
debugPrint = debugPrintThrottled;
|
||||||
|
@ -147,12 +147,22 @@ class FlutterDevice {
|
|||||||
await view.uiIsolate.flutterDebugDumpRenderTree();
|
await view.uiIsolate.flutterDebugDumpRenderTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Null> debugDumpLayerTree() async {
|
||||||
|
for (FlutterView view in views)
|
||||||
|
await view.uiIsolate.flutterDebugDumpLayerTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Null> debugDumpSemanticsTree() async {
|
||||||
|
for (FlutterView view in views)
|
||||||
|
await view.uiIsolate.flutterDebugDumpSemanticsTree();
|
||||||
|
}
|
||||||
|
|
||||||
Future<Null> toggleDebugPaintSizeEnabled() async {
|
Future<Null> toggleDebugPaintSizeEnabled() async {
|
||||||
for (FlutterView view in views)
|
for (FlutterView view in views)
|
||||||
await view.uiIsolate.flutterToggleDebugPaintSizeEnabled();
|
await view.uiIsolate.flutterToggleDebugPaintSizeEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> togglePlatform({String from}) async {
|
Future<String> togglePlatform({ String from }) async {
|
||||||
String to;
|
String to;
|
||||||
switch (from) {
|
switch (from) {
|
||||||
case 'iOS':
|
case 'iOS':
|
||||||
@ -163,9 +173,8 @@ class FlutterDevice {
|
|||||||
to = 'iOS';
|
to = 'iOS';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (FlutterView view in views) {
|
for (FlutterView view in views)
|
||||||
await view.uiIsolate.flutterPlatformOverride(to);
|
await view.uiIsolate.flutterPlatformOverride(to);
|
||||||
}
|
|
||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,6 +424,18 @@ abstract class ResidentRunner {
|
|||||||
await device.debugDumpRenderTree();
|
await device.debugDumpRenderTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Null> _debugDumpLayerTree() async {
|
||||||
|
await refreshViews();
|
||||||
|
for (FlutterDevice device in flutterDevices)
|
||||||
|
await device.debugDumpLayerTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Null> _debugDumpSemanticsTree() async {
|
||||||
|
await refreshViews();
|
||||||
|
for (FlutterDevice device in flutterDevices)
|
||||||
|
await device.debugDumpSemanticsTree();
|
||||||
|
}
|
||||||
|
|
||||||
Future<Null> _debugToggleDebugPaintSizeEnabled() async {
|
Future<Null> _debugToggleDebugPaintSizeEnabled() async {
|
||||||
await refreshViews();
|
await refreshViews();
|
||||||
for (FlutterDevice device in flutterDevices)
|
for (FlutterDevice device in flutterDevices)
|
||||||
@ -505,9 +526,8 @@ abstract class ResidentRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Null> connectToServiceProtocol({String viewFilter}) async {
|
Future<Null> connectToServiceProtocol({String viewFilter}) async {
|
||||||
if (!debuggingOptions.debuggingEnabled) {
|
if (!debuggingOptions.debuggingEnabled)
|
||||||
return new Future<Null>.error('Error the service protocol is not enabled.');
|
return new Future<Null>.error('Error the service protocol is not enabled.');
|
||||||
}
|
|
||||||
|
|
||||||
bool viewFound = false;
|
bool viewFound = false;
|
||||||
for (FlutterDevice device in flutterDevices) {
|
for (FlutterDevice device in flutterDevices) {
|
||||||
@ -564,12 +584,22 @@ abstract class ResidentRunner {
|
|||||||
await _debugDumpRenderTree();
|
await _debugDumpRenderTree();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} else if (character == 'L') {
|
||||||
|
if (supportsServiceProtocol) {
|
||||||
|
await _debugDumpLayerTree();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (character == 'S') {
|
||||||
|
if (supportsServiceProtocol) {
|
||||||
|
await _debugDumpSemanticsTree();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} else if (lower == 'p') {
|
} else if (lower == 'p') {
|
||||||
if (supportsServiceProtocol && isRunningDebug) {
|
if (supportsServiceProtocol && isRunningDebug) {
|
||||||
await _debugToggleDebugPaintSizeEnabled();
|
await _debugToggleDebugPaintSizeEnabled();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (lower == 's') {
|
} else if (character == 's') {
|
||||||
for (FlutterDevice device in flutterDevices) {
|
for (FlutterDevice device in flutterDevices) {
|
||||||
if (device.device.supportsScreenshot)
|
if (device.device.supportsScreenshot)
|
||||||
await _screenshot(device);
|
await _screenshot(device);
|
||||||
@ -656,16 +686,13 @@ abstract class ResidentRunner {
|
|||||||
final DependencyChecker dependencyChecker =
|
final DependencyChecker dependencyChecker =
|
||||||
new DependencyChecker(dartDependencySetBuilder, assetBundle);
|
new DependencyChecker(dartDependencySetBuilder, assetBundle);
|
||||||
final String path = device.package.packagePath;
|
final String path = device.package.packagePath;
|
||||||
if (path == null) {
|
if (path == null)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
final FileStat stat = fs.file(path).statSync();
|
final FileStat stat = fs.file(path).statSync();
|
||||||
if (stat.type != FileSystemEntityType.FILE) {
|
if (stat.type != FileSystemEntityType.FILE)
|
||||||
return true;
|
return true;
|
||||||
}
|
if (!fs.file(path).existsSync())
|
||||||
if (!fs.file(path).existsSync()) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
final DateTime lastBuildTime = stat.modified;
|
final DateTime lastBuildTime = stat.modified;
|
||||||
return dependencyChecker.check(lastBuildTime);
|
return dependencyChecker.check(lastBuildTime);
|
||||||
}
|
}
|
||||||
@ -683,8 +710,9 @@ abstract class ResidentRunner {
|
|||||||
|
|
||||||
void printHelpDetails() {
|
void printHelpDetails() {
|
||||||
if (supportsServiceProtocol) {
|
if (supportsServiceProtocol) {
|
||||||
printStatus('To dump the widget hierarchy of the app (debugDumpApp), press "w".');
|
printStatus('You can dump the widget hierarchy of the app (debugDumpApp) by pressing "w".');
|
||||||
printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "t".');
|
printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "t".');
|
||||||
|
printStatus('For layers (debugDumpLayerTree), use "L"; accessibility (debugDumpSemantics), "S".');
|
||||||
if (isRunningDebug) {
|
if (isRunningDebug) {
|
||||||
printStatus('To toggle the display of construction lines (debugPaintSizeEnabled), press "p".');
|
printStatus('To toggle the display of construction lines (debugPaintSizeEnabled), press "p".');
|
||||||
printStatus('To simulate different operating systems, (defaultTargetPlatform), press "o".');
|
printStatus('To simulate different operating systems, (defaultTargetPlatform), press "o".');
|
||||||
|
@ -998,6 +998,14 @@ class Isolate extends ServiceObjectOwner {
|
|||||||
return invokeFlutterExtensionRpcRaw('ext.flutter.debugDumpRenderTree', timeout: kLongRequestTimeout);
|
return invokeFlutterExtensionRpcRaw('ext.flutter.debugDumpRenderTree', timeout: kLongRequestTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> flutterDebugDumpLayerTree() {
|
||||||
|
return invokeFlutterExtensionRpcRaw('ext.flutter.debugDumpLayerTree', timeout: kLongRequestTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> flutterDebugDumpSemanticsTree() {
|
||||||
|
return invokeFlutterExtensionRpcRaw('ext.flutter.debugDumpSemanticsTree', timeout: kLongRequestTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> flutterToggleDebugPaintSizeEnabled() async {
|
Future<Map<String, dynamic>> flutterToggleDebugPaintSizeEnabled() async {
|
||||||
Map<String, dynamic> state = await invokeFlutterExtensionRpcRaw('ext.flutter.debugPaint');
|
Map<String, dynamic> state = await invokeFlutterExtensionRpcRaw('ext.flutter.debugPaint');
|
||||||
if (state != null && state.containsKey('enabled') && state['enabled'] is String) {
|
if (state != null && state.containsKey('enabled') && state['enabled'] is String) {
|
||||||
|
Loading…
Reference in New Issue
Block a user