* feat: Introduce a robust Google Maps initializer
This commit refactors the map initialization logic to be more robust and
test-friendly.
Previously, the map initialization was coupled with the attribution ID
logic, which made it difficult to handle initialization failures,
especially in test environments where the Maps SDK might be mocked.
This change introduces a new `GoogleMapsInitializer` object that manages
the initialization process with a state machine. This provides more
control over the initialization process and allows for better error
handling.
The key changes are:
- A new `GoogleMapsInitializer` object that manages the initialization
of the Google Maps SDK.
- An `InitializationState` enum that represents the different states of
the initialization process.
- An `initialize` function that starts the initialization process on a
background thread.
- A `reset` function that allows for re-initialization in test
environments.
- The `GoogleMap` composable now uses the `GoogleMapsInitializer` to
ensure that the map is only displayed after the SDK has been
successfully initialized.
* chore: address copyright header issues
* refactor: Make GoogleMapsInitializer suspendable
This change refactors the `GoogleMapsInitializer` to use suspend functions for initialization and reset operations, improving its testability and adherence to structured concurrency.
Key changes:
- Converted `GoogleMapsInitializer.initialize()` and `GoogleMapsInitializer.reset()` to `suspend` functions.
- Removed the internal `CoroutineScope` and job management from `GoogleMapsInitializer`.
- Updated unit and instrumentation tests to use `runTest` from `kotlinx-coroutines-test`, removing the need for `Thread.sleep()`.
- Added the `kotlinx-coroutines-test` dependency to the `maps-app` module.
* refactor(maps-compose): Make GoogleMapsInitializer fully suspending
The `initialize` function has been refactored to be a fully suspending operation.
Key changes:
- Replaced `launch(Dispatchers.IO)` with `withContext(Dispatchers.IO)`. This ensures the `initialize` function suspends until the blocking initialization call is complete, rather than returning immediately.
- Added explicit handling for non-SUCCESS results from `MapsInitializer.initialize()` to set the state to `FAILURE`.
- Restructured the `try-catch` block to correctly handle exceptions from the `withContext` block.
* chore: Update Material, Robolectric, and Truth dependencies
* test: Add StrictMode check to GoogleMapsInitializerTest
Wraps the `GoogleMapsInitializer.initialize()` call with strict
StrictMode policies. This ensures the initialization process does not
perform any violations, such as disk reads, which would cause the
test to fail.
* test: Refactor GoogleMapViewTests to use Truth assertions
Key changes:
- Introduced a custom `LatLngSubject` for the Truth assertion library to allow for `LatLng` comparisons with a tolerance.
- Migrated assertions in `GoogleMapViewTests` from JUnit to Truth for improved readability and more expressive tests.
- Added explicit Google Maps SDK initialization within the test setup.
* chore: add license headers to test files