Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::testing::TestAssetResolver Class Reference
Inheritance diagram for flutter::testing::TestAssetResolver:
flutter::AssetResolver

Public Member Functions

 TestAssetResolver (bool valid, AssetResolver::AssetResolverType type)
 
bool IsValid () const override
 
bool IsValidAfterAssetManagerChange () const override
 Certain asset resolvers are still valid after the asset manager is replaced before a hot reload, or after a new run configuration is created during a hot restart. By preserving these resolvers and re-inserting them into the new resolver or run configuration, the tooling can avoid needing to sync all application assets through the Dart devFS upon connecting to the VM Service. Besides improving the startup performance of running a Flutter application, it also reduces the occurrence of tool failures due to repeated network flakes caused by damaged cables or hereto unknown bugs in the Dart HTTP server implementation. More...
 
AssetResolver::AssetResolverType GetType () const override
 Gets the type of AssetResolver this is. Types are defined in AssetResolverType. More...
 
std::unique_ptr< fml::MappingGetAsMapping (const std::string &asset_name) const override
 
std::vector< std::unique_ptr< fml::Mapping > > GetAsMappings (const std::string &asset_pattern, const std::optional< std::string > &subdir) const override
 Same as GetAsMapping() but returns mappings for all files who's name matches a given pattern. Returns empty vector if no matching assets are found. More...
 
bool operator== (const AssetResolver &other) const override
 
- Public Member Functions inherited from flutter::AssetResolver
 AssetResolver ()=default
 
virtual ~AssetResolver ()=default
 
virtual const AssetManageras_asset_manager () const
 
virtual const APKAssetProvideras_apk_asset_provider () const
 
virtual const DirectoryAssetBundleas_directory_asset_bundle () const
 
virtual bool IsValid () const =0
 
virtual bool IsValidAfterAssetManagerChange () const =0
 Certain asset resolvers are still valid after the asset manager is replaced before a hot reload, or after a new run configuration is created during a hot restart. By preserving these resolvers and re-inserting them into the new resolver or run configuration, the tooling can avoid needing to sync all application assets through the Dart devFS upon connecting to the VM Service. Besides improving the startup performance of running a Flutter application, it also reduces the occurrence of tool failures due to repeated network flakes caused by damaged cables or hereto unknown bugs in the Dart HTTP server implementation. More...
 
virtual AssetResolverType GetType () const =0
 Gets the type of AssetResolver this is. Types are defined in AssetResolverType. More...
 
virtual std::unique_ptr< fml::MappingGetAsMapping (const std::string &asset_name) const =0
 
virtual std::vector< std::unique_ptr< fml::Mapping > > GetAsMappings (const std::string &asset_pattern, const std::optional< std::string > &subdir) const
 Same as GetAsMapping() but returns mappings for all files who's name matches a given pattern. Returns empty vector if no matching assets are found. More...
 
virtual bool operator== (const AssetResolver &other) const =0
 
bool operator!= (const AssetResolver &other) const
 

Additional Inherited Members

- Public Types inherited from flutter::AssetResolver
enum  AssetResolverType { kAssetManager , kApkAssetProvider , kDirectoryAssetBundle }
 Identifies the type of AssetResolver an instance is. More...
 

Detailed Description

Definition at line 239 of file shell_unittests.cc.

Constructor & Destructor Documentation

◆ TestAssetResolver()

flutter::testing::TestAssetResolver::TestAssetResolver ( bool  valid,
AssetResolver::AssetResolverType  type 
)
inline

Definition at line 241 of file shell_unittests.cc.

242 : valid_(valid), type_(type) {}
GLenum type

Member Function Documentation

◆ GetAsMapping()

std::unique_ptr< fml::Mapping > flutter::testing::TestAssetResolver::GetAsMapping ( const std::string &  asset_name) const
inlineoverridevirtual

Implements flutter::AssetResolver.

Definition at line 251 of file shell_unittests.cc.

252 {
253 return nullptr;
254 }

◆ GetAsMappings()

std::vector< std::unique_ptr< fml::Mapping > > flutter::testing::TestAssetResolver::GetAsMappings ( const std::string &  asset_pattern,
const std::optional< std::string > &  subdir 
) const
inlineoverridevirtual

Same as GetAsMapping() but returns mappings for all files who's name matches a given pattern. Returns empty vector if no matching assets are found.

Parameters
[in]asset_patternThe pattern to match file names against.
[in]subdirOptional subdirectory in which to search for files. If supplied this function does a flat search within the subdirectory instead of a recursive search through the entire assets directory.
Returns
Returns a vector of mappings of files which match the search parameters.

Reimplemented from flutter::AssetResolver.

Definition at line 256 of file shell_unittests.cc.

258 {
259 return {};
260 };

◆ GetType()

AssetResolver::AssetResolverType flutter::testing::TestAssetResolver::GetType ( ) const
inlineoverridevirtual

Gets the type of AssetResolver this is. Types are defined in AssetResolverType.

Returns
Returns the AssetResolverType that this resolver is.

Implements flutter::AssetResolver.

Definition at line 249 of file shell_unittests.cc.

249{ return type_; }

◆ IsValid()

bool flutter::testing::TestAssetResolver::IsValid ( ) const
inlineoverridevirtual

Implements flutter::AssetResolver.

Definition at line 244 of file shell_unittests.cc.

244{ return true; }

◆ IsValidAfterAssetManagerChange()

bool flutter::testing::TestAssetResolver::IsValidAfterAssetManagerChange ( ) const
inlineoverridevirtual

Certain asset resolvers are still valid after the asset manager is replaced before a hot reload, or after a new run configuration is created during a hot restart. By preserving these resolvers and re-inserting them into the new resolver or run configuration, the tooling can avoid needing to sync all application assets through the Dart devFS upon connecting to the VM Service. Besides improving the startup performance of running a Flutter application, it also reduces the occurrence of tool failures due to repeated network flakes caused by damaged cables or hereto unknown bugs in the Dart HTTP server implementation.

Returns
Returns whether this resolver is valid after the asset manager or run configuration is updated.

Implements flutter::AssetResolver.

Definition at line 247 of file shell_unittests.cc.

247{ return valid_; }

◆ operator==()

bool flutter::testing::TestAssetResolver::operator== ( const AssetResolver other) const
inlineoverridevirtual

Implements flutter::AssetResolver.

Definition at line 262 of file shell_unittests.cc.

262 {
263 return this == &other;
264 }

The documentation for this class was generated from the following file: