diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine.dart b/engine/src/flutter/lib/web_ui/lib/src/engine.dart index 8b246c159f..50cc107c91 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine.dart @@ -330,9 +330,12 @@ export 'engine/window.dart'; /// Keep these in sync with the same constants on the framework-side under foundation/constants.dart. const bool kReleaseMode = bool.fromEnvironment('dart.vm.product', defaultValue: false); +/// A constant that is true if the application was compiled in profile mode. const bool kProfileMode = bool.fromEnvironment('dart.vm.profile', defaultValue: false); +/// A constant that is true if the application was compiled in debug mode. const bool kDebugMode = !kReleaseMode && !kProfileMode; +/// Returns mode of the app is running in as a string. String get buildMode => kReleaseMode ? 'release' : kProfileMode @@ -454,6 +457,8 @@ void _addUrlStrategyListener() { }); } +/// Sanitizer used to convert const svg filter and clippath snippets to +/// SvgElement without sanitization. class NullTreeSanitizer implements html.NodeTreeSanitizer { @override void sanitizeTree(html.Node node) {} diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/alarm_clock.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/alarm_clock.dart index 265828c87d..900286e77d 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/alarm_clock.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/alarm_clock.dart @@ -18,6 +18,8 @@ typedef TimestampFunction = DateTime Function(); /// /// https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Notes class AlarmClock { + + /// Initializes Alarmclock with a closure that gets called with a timestamp. AlarmClock(TimestampFunction timestampFunction) : _timestampFunction = timestampFunction; diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/assets.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/assets.dart index a11e8ac8c4..350e4daa87 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/assets.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/assets.dart @@ -19,6 +19,7 @@ class AssetManager { /// The directory containing the assets. final String assetsDir; + /// Initializes [AssetManager] with path to assets relative to baseUrl. const AssetManager({this.assetsDir = _defaultAssetsDir}); String? get _baseUrl { @@ -53,6 +54,7 @@ class AssetManager { return Uri.encodeFull((_baseUrl ?? '') + '$assetsDir/$asset'); } + /// Loads an asset using an [html.HttpRequest] and returns data as [ByteData]. Future load(String asset) async { final String url = getAssetUrl(asset); try { @@ -77,10 +79,14 @@ class AssetManager { } } +/// Thrown to indicate http failure during asset loading. class AssetManagerException implements Exception { + /// Http request url for asset. final String url; + /// Http status of of response. final int httpStatus; + /// Initializes exception with request url and http status. AssetManagerException(this.url, this.httpStatus); @override @@ -89,8 +95,11 @@ class AssetManagerException implements Exception { /// An asset manager that gives fake empty responses for assets. class WebOnlyMockAssetManager implements AssetManager { + /// Mock asset directory relative to base url. String defaultAssetsDir = ''; + /// Mock empty asset manifest. String defaultAssetManifest = '{}'; + /// Mock font manifest overridable for unit testing. String defaultFontManifest = ''' [ { diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/browser_detection.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/browser_detection.dart index 3b3fc279bc..f0cf2adfb2 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/browser_detection.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/browser_detection.dart @@ -33,9 +33,9 @@ enum BrowserEngine { /// html webgl version qualifier constants. abstract class WebGLVersion { - // WebGL 1.0 is based on OpenGL ES 2.0 / GLSL 1.00 + /// WebGL 1.0 is based on OpenGL ES 2.0 / GLSL 1.00 static const int webgl1 = 1; - // WebGL 2.0 is based on OpenGL ES 3.0 / GLSL 3.00 + /// WebGL 2.0 is based on OpenGL ES 3.0 / GLSL 3.00 static const int webgl2 = 2; } @@ -78,6 +78,9 @@ bool _isSamsungBrowser(String agent) { return exp.hasMatch(agent.toUpperCase()); } +/// Detects browser engine for a given vendor and agent string. +/// +/// Used for testing this library. @visibleForTesting BrowserEngine detectBrowserEngineByVendorAgent(String vendor, String agent) { if (vendor == 'Google Inc.') { @@ -149,6 +152,7 @@ OperatingSystem get operatingSystem { /// This is intended to be used for testing and debugging only. OperatingSystem? debugOperatingSystemOverride; +/// Detects operating system using platform and UA used for unit testing. @visibleForTesting OperatingSystem detectOperatingSystem({ String? overridePlatform,