<commit_before>package com.example;

import android.test.ActivityInstrumentationTestCase2;
import android.test.TouchUtils;


public class MyActivityTest extends ActivityInstrumentationTestCase2<MyActivity> {

    private MyActivity mActivity;
    private CustomTimePicker timePicker;

    public MyActivityTest() {
        super("com.example", MyActivity.class);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        mActivity = this.getActivity();
        timePicker = (CustomTimePicker)mActivity.findViewById(R.id.alarmTimePicker);
    }

    public void testTimePickerHoursAdd(){
        timePicker.setHours(21);
        timePicker.setMinutes(30);
        int hoursBefore = timePicker.getHours();
        incrementHours();
        int hoursAfter = timePicker.getHours();
        assertEquals((hoursBefore)%24+1, hoursAfter);
    }

    private void incrementHours(){
        timePicker.setHours(timePicker.getHours()+1);
    }

    public void testSetAlarm(){
        AlarmScheduler alarmScheduler = new AlarmSchedulerMock();
        mActivity.setAlarmScheduler(alarmScheduler);
        incrementHours();
        TouchUtils.clickView(this, mActivity.findViewById(R.id.setAlarmButton));
        assertEquals("Did not add alarm", 1, ((AlarmSchedulerMock) alarmScheduler).getAdds());
        assertEquals("Wrong hours", timePicker.getHours(), ((AlarmSchedulerMock)alarmScheduler).getHours());
        assertEquals("Wrong minutes", timePicker.getMinutes(), ((AlarmSchedulerMock)alarmScheduler).getMinutes());
        assertEquals("Wrong interval (hard coded to 0)", 0, ((AlarmSchedulerMock)alarmScheduler).getInterval());
    }

    public void testDeleteAlarm(){
        AlarmScheduler alarmScheduler = new AlarmSchedulerMock();
        mActivity.setAlarmScheduler(alarmScheduler);
        TouchUtils.clickView(this, mActivity.findViewById(R.id.deleteAlarmButton));
        assertEquals("Did not delete alarm", 1, ((AlarmSchedulerMock) alarmScheduler).getDeletes());
    }

    public void testAlarmManagerSet(){
        AlarmManagerMock alarmManager = new AlarmManagerMock();
        mActivity.getAlarmScheduler().setAlarmManager(alarmManager);

        TouchUtils.clickView(this, mActivity.findViewById(R.id.setAlarmButton));
        assertEquals("Did not add alarm to manager", 1, alarmManager.getSets());
    }

    public void testAlarmManagerCancel(){
        AlarmManagerMock alarmManager = new AlarmManagerMock();
        mActivity.getAlarmScheduler().setAlarmManager(alarmManager);

        incrementHours();
        TouchUtils.clickView(this, mActivity.findViewById(R.id.setAlarmButton));
        incrementHours();
        TouchUtils.clickView(this, mActivity.findViewById(R.id.deleteAlarmButton));

        assertEquals("Did not add alarm to manager", 1, alarmManager.getCancels());
        assertTrue("Operations don't match", alarmManager.getOperationSet().equals(alarmManager.getOperationCancel()));
    }

<commit_msg>test fix 2<commit_after>package com.example;

import android.test.ActivityInstrumentationTestCase2;
import android.test.TouchUtils;


public class MyActivityTest extends ActivityInstrumentationTestCase2<MyActivity> {

    private MyActivity mActivity;
    private CustomTimePicker timePicker;

    public MyActivityTest() {
        super("com.example", MyActivity.class);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        mActivity = this.getActivity();
        timePicker = (CustomTimePicker)mActivity.findViewById(R.id.alarmTimePicker);
    }

    public void testTimePickerHoursAdd(){
        timePicker.setHours(21);
        timePicker.setMinutes(30);
        int hoursBefore = timePicker.getHours();
        incrementHours();
        int hoursAfter = timePicker.getHours();
        assertEquals((hoursBefore)%24+1, hoursAfter);
    }

    private void incrementHours(){
        timePicker.setHours(timePicker.getHours()+1);
    }

    public void testSetAlarm(){
        AlarmScheduler alarmScheduler = new AlarmSchedulerMock();
        mActivity.setAlarmScheduler(alarmScheduler);
        incrementHours();
        TouchUtils.clickView(this, mActivity.findViewById(R.id.setAlarmButton));
        assertEquals("Did not add alarm", 1, ((AlarmSchedulerMock) alarmScheduler).getAdds());
        assertEquals("Wrong hours", timePicker.getHours(), ((AlarmSchedulerMock)alarmScheduler).getHours());
        assertEquals("Wrong minutes", timePicker.getMinutes(), ((AlarmSchedulerMock)alarmScheduler).getMinutes());
    }

    public void testDeleteAlarm(){
        AlarmScheduler alarmScheduler = new AlarmSchedulerMock();
        mActivity.setAlarmScheduler(alarmScheduler);
        TouchUtils.clickView(this, mActivity.findViewById(R.id.deleteAlarmButton));
        assertEquals("Did not delete alarm", 1, ((AlarmSchedulerMock) alarmScheduler).getDeletes());
    }

    public void testAlarmManagerSet(){
        AlarmManagerMock alarmManager = new AlarmManagerMock();
        mActivity.getAlarmScheduler().setAlarmManager(alarmManager);

        TouchUtils.clickView(this, mActivity.findViewById(R.id.setAlarmButton));
        assertEquals("Did not add alarm to manager", 1, alarmManager.getSets());
    }

    public void testAlarmManagerCancel(){
        AlarmManagerMock alarmManager = new AlarmManagerMock();
        mActivity.getAlarmScheduler().setAlarmManager(alarmManager);

        incrementHours();
        TouchUtils.clickView(this, mActivity.findViewById(R.id.setAlarmButton));
        incrementHours();
        TouchUtils.clickView(this, mActivity.findViewById(R.id.deleteAlarmButton));

        assertEquals("Did not add alarm to manager", 1, alarmManager.getCancels());
        assertTrue("Operations don't match", alarmManager.getOperationSet().equals(alarmManager.getOperationCancel()));
    }


{'fraction_non_alphanumeric': 0.1079136690647482, 'fraction_numerical': 0.005310037684138403, 'mean_word_length': 3.9905982905982906, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5325229', 'n_tokens_mistral': 1639, 'n_tokens_neox': 1589, 'n_words': 284}