Skip to content

Add comprehensive unit tests for location, geofence, and media managers#4001

Merged
shai-almog merged 9 commits intomasterfrom
codex/create-unit-tests-for-locationmanager,-geofencemanager,-medi
Oct 20, 2025
Merged

Add comprehensive unit tests for location, geofence, and media managers#4001
shai-almog merged 9 commits intomasterfrom
codex/create-unit-tests-for-locationmanager,-geofencemanager,-medi

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • add LocationManagerTest to exercise synchronous lookup paths, listener lifecycle, and background bindings
  • introduce GeofenceManagerTest to validate persistence, activation, and listener class handling via in-memory stubs
  • create MediaManagerTest covering audio buffer management, remote control transitions, recorder validation, and async media wrapping

Testing

  • mvn -f maven/core-unittests/pom.xml test (fails: missing dependency com.codenameone:codenameone-factory:jar:8.0-SNAPSHOT)

https://chatgpt.com/codex/tasks/task_e_68f5c11c28108331b5380a6d927225d5

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +75 to +88
void updateActivatesGeofencesWithinBubble() {
Geofence near = createGeofence("near", 0.001, 0.001, 50, -1L);
Geofence far = createGeofence("far", 2.0, 2.0, 100, -1L);
manager.add(near, far);
locationManager.clearRecords();

manager.update(1000);

assertTrue(locationManager.addedIds.contains("near"));
assertTrue(locationManager.addedIds.contains("$AsyncGeoStreamer.bubble"));
assertTrue(manager.isCurrentlyActive("near"));
assertFalse(manager.isCurrentlyActive("far"));
assertTrue(locationManager.backgroundCleared);
assertFalse(locationManager.removedIds.contains("near"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Correct bubble expectations in geofence update test

The test assumes GeofenceManager.update() always re-registers $AsyncGeoStreamer.bubble and clears a background listener on every call. In reality the bubble is only added once (or after the device moves ~100 m) and clearing only occurs when a listener was previously set. Because the singleton is initialized in setupManager() before the assertions, addedIds never contains the bubble and backgroundCleared remains false even though the production code is behaving correctly. These assertions will fail consistently and should be removed or the state should be reset explicitly before the update.

Useful? React with 👍 / 👎.

Comment on lines +35 to +45
@Test
void getCurrentLocationSyncWithoutListenerBindsAndReturnsResult() {
Location expected = new Location(1.0, 2.0);
manager.setCurrentLocation(expected);

Location result = manager.getCurrentLocationSync(1000);

assertSame(expected, result);
assertEquals(1, manager.bindCount);
assertEquals(LocationManager.AVAILABLE, manager.getStatus());
assertNull(manager.getStoredRequest());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Adjust status assertion after getCurrentLocationSync

getCurrentLocationSync() uses LL to bind a temporary listener and LL.locationUpdated() immediately calls setLocationListener(null), which resets status to TEMPORARILY_UNAVAILABLE. The test’s expectation that manager.getStatus() remains AVAILABLE contradicts this behavior, so the assertion fails even when the implementation works as intended. The check should either expect TEMPORARILY_UNAVAILABLE or omit the status verification.

Useful? React with 👍 / 👎.

@github-actions
Copy link
Copy Markdown

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog shai-almog merged commit 7049a90 into master Oct 20, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant