-
-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20def04
commit 1275c1e
Showing
27 changed files
with
922 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:meta/meta.dart'; | ||
|
||
import 'sentry_view_hierarchy_element.dart'; | ||
|
||
@immutable | ||
class SentryViewHierarchy { | ||
SentryViewHierarchy(this.renderingSystem); | ||
|
||
final String renderingSystem; | ||
final List<SentryViewHierarchyElement> windows = []; | ||
|
||
/// Header encoded as JSON | ||
Map<String, dynamic> toJson() { | ||
return { | ||
'rendering_system': renderingSystem, | ||
if (windows.isNotEmpty) | ||
'windows': windows.map((e) => e.toJson()).toList(growable: false), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import 'package:meta/meta.dart'; | ||
|
||
@immutable | ||
class SentryViewHierarchyElement { | ||
SentryViewHierarchyElement( | ||
this.type, { | ||
this.depth, | ||
this.identifier, | ||
this.width, | ||
this.height, | ||
this.x, | ||
this.y, | ||
this.z, | ||
this.visible, | ||
this.alpha, | ||
this.extra, | ||
}); | ||
|
||
final String type; | ||
final int? depth; | ||
final String? identifier; | ||
final List<SentryViewHierarchyElement> children = []; | ||
final double? width; | ||
final double? height; | ||
final double? x; | ||
final double? y; | ||
final double? z; | ||
final bool? visible; | ||
final double? alpha; | ||
final Map<String, dynamic>? extra; | ||
|
||
/// Header encoded as JSON | ||
Map<String, dynamic> toJson() { | ||
final jsonMap = { | ||
'type': type, | ||
if (depth != null) 'depth': depth, | ||
if (identifier != null) 'identifier': identifier, | ||
if (width != null) 'width': width, | ||
if (height != null) 'height': height, | ||
if (x != null) 'x': x, | ||
if (y != null) 'y': y, | ||
if (z != null) 'z': z, | ||
if (visible != null) 'visible': visible, | ||
if (alpha != null) 'alpha': alpha, | ||
if (children.isNotEmpty) | ||
'children': children.map((e) => e.toJson()).toList(growable: false), | ||
}; | ||
|
||
if (extra?.isNotEmpty ?? false) { | ||
jsonMap.addAll(extra!); | ||
} | ||
|
||
return jsonMap; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
dart/test/protocol/sentry_view_hierarchy_element_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import 'package:sentry/sentry.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('json', () { | ||
test('toJson with children', () { | ||
final element = SentryViewHierarchyElement( | ||
'RenderObjectToWidgetAdapter<RenderBox>', | ||
depth: 1, | ||
identifier: 'RenderView#a2216', | ||
width: 100, | ||
height: 200, | ||
x: 100, | ||
y: 50, | ||
z: 30, | ||
visible: true, | ||
alpha: 90, | ||
extra: {'key': 'value'}, | ||
); | ||
final element2 = SentryViewHierarchyElement( | ||
'SentryScreenshotWidget', | ||
depth: 2, | ||
); | ||
element.children.add(element2); | ||
|
||
final map = element.toJson(); | ||
|
||
expect(map, { | ||
'type': 'RenderObjectToWidgetAdapter<RenderBox>', | ||
'depth': 1, | ||
'identifier': 'RenderView#a2216', | ||
'children': [ | ||
{ | ||
'type': 'SentryScreenshotWidget', | ||
'depth': 2, | ||
}, | ||
], | ||
'width': 100, | ||
'height': 200, | ||
'x': 100, | ||
'y': 50, | ||
'z': 30, | ||
'visible': true, | ||
'alpha': 90, | ||
'key': 'value', | ||
}); | ||
}); | ||
|
||
test('toJson no children', () { | ||
final element = SentryViewHierarchyElement( | ||
'RenderObjectToWidgetAdapter<RenderBox>', | ||
depth: 1, | ||
identifier: 'RenderView#a2216', | ||
); | ||
|
||
final map = element.toJson(); | ||
|
||
expect(map, { | ||
'type': 'RenderObjectToWidgetAdapter<RenderBox>', | ||
'depth': 1, | ||
'identifier': 'RenderView#a2216', | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import 'package:sentry/sentry.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('json', () { | ||
test('toJson with children', () { | ||
final element = SentryViewHierarchyElement( | ||
'RenderObjectToWidgetAdapter<RenderBox>', | ||
depth: 1, | ||
identifier: 'RenderView#a2216', | ||
); | ||
|
||
final element2 = SentryViewHierarchyElement( | ||
'SentryScreenshotWidget', | ||
depth: 2, | ||
); | ||
element.children.add(element2); | ||
|
||
final viewHierrchy = SentryViewHierarchy('flutter'); | ||
viewHierrchy.windows.add(element); | ||
|
||
final map = viewHierrchy.toJson(); | ||
|
||
expect(map, { | ||
'rendering_system': 'flutter', | ||
'windows': [ | ||
{ | ||
'type': 'RenderObjectToWidgetAdapter<RenderBox>', | ||
'depth': 1, | ||
'identifier': 'RenderView#a2216', | ||
'children': [ | ||
{ | ||
'type': 'SentryScreenshotWidget', | ||
'depth': 2, | ||
}, | ||
] | ||
}, | ||
], | ||
}); | ||
}); | ||
|
||
test('toJson no children', () { | ||
final viewHierrchy = SentryViewHierarchy('flutter'); | ||
|
||
final map = viewHierrchy.toJson(); | ||
|
||
expect(map, { | ||
'rendering_system': 'flutter', | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ void main() { | |
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive; | ||
|
||
// Using fake DSN for testing purposes. | ||
Future<void> setupSentryAndApp(WidgetTester tester) async { | ||
await setupSentry(() async { | ||
await tester.pumpWidget(SentryScreenshotWidget( | ||
|
@@ -16,7 +17,7 @@ void main() { | |
child: const MyApp(), | ||
))); | ||
await tester.pumpAndSettle(); | ||
}); | ||
}, 'https://[email protected]/1234567'); | ||
} | ||
|
||
// Tests | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.