Skip to content

Conversation

MihaiCristianCondrea
Copy link
Owner

Summary

  • test AppUsageNotificationWorker handles threshold logic and updates timestamp
  • ensure AppUsageNotificationsManager schedules repeating alarm every three days

Testing

  • ./gradlew test (fails: SDK location not found)

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

Copy link

@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 suggestions.

Reply with @codex fix comments to fix any unresolved comments.

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, or 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 fix this CI failure" or "@codex address that feedback".

Comment on lines +49 to +50
try (MockedStatic<PreferenceManager> prefManager = mockStatic(PreferenceManager.class);
MockedConstruction<NotificationChannel> ignoredChannel = mockConstruction(NotificationChannel.class)) {

Choose a reason for hiding this comment

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

[P0] Import mockStatic to compile worker tests

Both test methods rely on mockStatic to stub PreferenceManager.getDefaultSharedPreferences, but the file never imports org.mockito.Mockito.mockStatic. Because the method is referenced without qualification, the test suite will not compile (cannot find symbol: method mockStatic) and ./gradlew test will fail before any tests run.

Useful? React with 👍 / 👎.

Comment on lines +24 to +33
@Test
public void scheduleAppUsageCheck_setsRepeatingAlarmWithThreeDayInterval() {
AlarmManager alarmManager = mock(AlarmManager.class);
Context context = mock(Context.class);
when(context.getSystemService(Context.ALARM_SERVICE)).thenReturn(alarmManager);
when(context.getApplicationContext()).thenReturn(context);

long now = System.currentTimeMillis();
AppUsageNotificationsManager manager = new AppUsageNotificationsManager(context);

Choose a reason for hiding this comment

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

[P1] Stub PendingIntent to avoid RuntimeException in manager test

The new unit test constructs AppUsageNotificationsManager, which immediately calls PendingIntent.getBroadcast. In the local app/src/test environment there is no Robolectric dependency, so calling this Android framework method throws RuntimeException("Stub!") and the test will crash before reaching the verification. The test should mock or stub the PendingIntent static call (or be moved to androidTest) so the suite can execute.

Useful? React with 👍 / 👎.

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