<commit_before>package io.github.tobyhs.timetalker;

import android.content.Intent;

import org.junit.Test;
import org.junit.runner.RunWith;

import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.util.ServiceController;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;

@RunWith(RobolectricTestRunner.class)
public class ScreenServiceTest {
    @Test
    public void isRunning() {
        ServiceController<ScreenService> controller = Robolectric.buildService(ScreenService.class);
        controller.create();
        assertThat(ScreenService.isRunning(), is(true));

        controller.destroy();
        assertThat(ScreenService.isRunning(), is(false));
    }

    @Test
    public void registersReceiverForScreenOn() {
        Intent intent = new Intent(Intent.ACTION_SCREEN_ON);
        ShadowApplication shadowApp = ShadowApplication.getInstance();

        ServiceController serviceController = Robolectric.buildService(ScreenService.class);
        serviceController.create();
        assertThat(shadowApp.hasReceiverForIntent(intent), is(true));
        serviceController.destroy();
        assertThat(shadowApp.hasReceiverForIntent(intent), is(false));
    }

    @Test
    public void onBind_returnsNull() {
        ScreenService service = new ScreenService();
        assertThat(service.onBind(new Intent()), is(nullValue()));
    }
}<commit_msg>Improve receiver check in ScreenServiceTest<commit_after>package io.github.tobyhs.timetalker;

import android.content.BroadcastReceiver;
import android.content.Intent;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;

import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.util.ServiceController;

import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.isA;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;

@RunWith(RobolectricTestRunner.class)
public class ScreenServiceTest {
    @Test
    public void isRunning() {
        ServiceController<ScreenService> controller = Robolectric.buildService(ScreenService.class);
        controller.create();
        assertThat(ScreenService.isRunning(), is(true));

        controller.destroy();
        assertThat(ScreenService.isRunning(), is(false));
    }

    @Test
    public void registersReceiverForScreenOn() {
        Intent intent = new Intent(Intent.ACTION_SCREEN_ON);
        ShadowApplication shadowApp = ShadowApplication.getInstance();

        ServiceController serviceController = Robolectric.buildService(ScreenService.class);
        serviceController.create();
        List<BroadcastReceiver> receivers = shadowApp.getReceiversForIntent(intent);
        assertThat(receivers, hasItem(isA(ScreenActionReceiver.class)));

        serviceController.destroy();
        assertThat(shadowApp.hasReceiverForIntent(intent), is(false));
    }

    @Test
    public void onBind_returnsNull() {
        ScreenService service = new ScreenService();
        assertThat(service.onBind(new Intent()), is(nullValue()));
    }
}
{'fraction_non_alphanumeric': 0.09861642625846335, 'fraction_numerical': 0.0, 'mean_word_length': 4.534201954397394, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2405062', 'n_tokens_mistral': 938, 'n_tokens_neox': 919, 'n_words': 163}