<commit_before>package com.anysoftkeyboard.keyboards;

import com.menny.android.anysoftkeyboard.AskGradleTestRunner;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

@RunWith(AskGradleTestRunner.class)
public class KeyboardAddOnTest {

    public static final String ASK_ENGLISH_1_ID = "keyboard_c7535083-4fe6-49dc-81aa-c5438a1a343a";
    public static final String ASK_ENGLISH_16_KEYS_ID = "keyboard_12335055-4aa6-49dc-8456-c7d38a1a5123";

    @Test
    public void testGetKeyboardDefaultEnabled() throws Exception {
        List<KeyboardAddOnAndBuilder> enabledKeyboards = KeyboardFactory.getEnabledKeyboards(RuntimeEnvironment.application);
        //checking that ASK English is enabled
        boolean askEnglishEnabled = false;
        for (KeyboardAddOnAndBuilder addOnAndBuilder : enabledKeyboards) {
            if (addOnAndBuilder.getId().equals(ASK_ENGLISH_1_ID)) {
                assertTrue(addOnAndBuilder.getKeyboardDefaultEnabled());
                assertEquals(addOnAndBuilder.getPackageName(), RuntimeEnvironment.application.getPackageName());
                askEnglishEnabled = true;
            }
        }
        assertTrue(askEnglishEnabled);
        //only one enabled keyboard
        Assert.assertEquals(1, enabledKeyboards.size());
    }

    @Test
    public void testGetEnabledDefaultFromAllKeyboards() throws Exception {
        List<KeyboardAddOnAndBuilder> allAvailableKeyboards = KeyboardFactory.getAllAvailableKeyboards(RuntimeEnvironment.application);

        Map<String, Boolean> keyboardsEnabled = new HashMap<>();
        for (KeyboardAddOnAndBuilder addOnAndBuilder : allAvailableKeyboards) {
            keyboardsEnabled.put(addOnAndBuilder.getId(), addOnAndBuilder.getKeyboardDefaultEnabled());
        }

        Assert.assertEquals(3, keyboardsEnabled.size());
        Assert.assertTrue(keyboardsEnabled.containsKey(ASK_ENGLISH_1_ID));
        Assert.assertTrue(keyboardsEnabled.get(ASK_ENGLISH_1_ID));
        Assert.assertTrue(keyboardsEnabled.containsKey(ASK_ENGLISH_16_KEYS_ID));
        Assert.assertFalse(keyboardsEnabled.get(ASK_ENGLISH_16_KEYS_ID));
    }

    private KeyboardAddOnAndBuilder getKeyboardFromFactory(String id) {
        List<KeyboardAddOnAndBuilder> keyboards = KeyboardFactory.getAllAvailableKeyboards(RuntimeEnvironment.application);

        for (KeyboardAddOnAndBuilder addOnAndBuilder : keyboards) {
            if (addOnAndBuilder.getId().equals(id)) {
                return addOnAndBuilder;
            }
        }

        return null;
    }

    @Test
    public void testGetKeyboardLocale() throws Exception {
        KeyboardAddOnAndBuilder askEnglish = getKeyboardFromFactory(ASK_ENGLISH_1_ID);
        assertNotNull(askEnglish);
        assertEquals(askEnglish.getKeyboardLocale(), "en");

        KeyboardAddOnAndBuilder testerEnglish = getKeyboardFromFactory(ASK_ENGLISH_16_KEYS_ID);
        assertNotNull(testerEnglish);
        assertEquals(testerEnglish.getKeyboardLocale(), "en");
    }

    @Test
    public void testGetIcon() throws Exception {

    }

    @Test
    public void testHasScreenshot() throws Exception {
        KeyboardAddOnAndBuilder askEnglish = getKeyboardFromFactory(ASK_ENGLISH_1_ID);
        assertNotNull(askEnglish);
        assertTrue(askEnglish.hasScreenshot());

        KeyboardAddOnAndBuilder testerEnglish = getKeyboardFromFactory(ASK_ENGLISH_16_KEYS_ID);
        assertNotNull(testerEnglish);
        assertTrue(askEnglish.hasScreenshot());
    }

    @Test
    public void testGetScreenshot() throws Exception {

    }

    @Test<commit_msg>DEPLOY-CANARY: fixing unit tests related to screenshots<commit_after>package com.anysoftkeyboard.keyboards;

import com.menny.android.anysoftkeyboard.AskGradleTestRunner;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

@RunWith(AskGradleTestRunner.class)
public class KeyboardAddOnTest {

    public static final String ASK_ENGLISH_1_ID = "keyboard_c7535083-4fe6-49dc-81aa-c5438a1a343a";
    public static final String ASK_ENGLISH_16_KEYS_ID = "keyboard_12335055-4aa6-49dc-8456-c7d38a1a5123";

    @Test
    public void testGetKeyboardDefaultEnabled() throws Exception {
        List<KeyboardAddOnAndBuilder> enabledKeyboards = KeyboardFactory.getEnabledKeyboards(RuntimeEnvironment.application);
        //checking that ASK English is enabled
        boolean askEnglishEnabled = false;
        for (KeyboardAddOnAndBuilder addOnAndBuilder : enabledKeyboards) {
            if (addOnAndBuilder.getId().equals(ASK_ENGLISH_1_ID)) {
                assertTrue(addOnAndBuilder.getKeyboardDefaultEnabled());
                assertEquals(addOnAndBuilder.getPackageName(), RuntimeEnvironment.application.getPackageName());
                askEnglishEnabled = true;
            }
        }
        assertTrue(askEnglishEnabled);
        //only one enabled keyboard
        Assert.assertEquals(1, enabledKeyboards.size());
    }

    @Test
    public void testGetEnabledDefaultFromAllKeyboards() throws Exception {
        List<KeyboardAddOnAndBuilder> allAvailableKeyboards = KeyboardFactory.getAllAvailableKeyboards(RuntimeEnvironment.application);

        Map<String, Boolean> keyboardsEnabled = new HashMap<>();
        for (KeyboardAddOnAndBuilder addOnAndBuilder : allAvailableKeyboards) {
            keyboardsEnabled.put(addOnAndBuilder.getId(), addOnAndBuilder.getKeyboardDefaultEnabled());
        }

        Assert.assertEquals(3, keyboardsEnabled.size());
        Assert.assertTrue(keyboardsEnabled.containsKey(ASK_ENGLISH_1_ID));
        Assert.assertTrue(keyboardsEnabled.get(ASK_ENGLISH_1_ID));
        Assert.assertTrue(keyboardsEnabled.containsKey(ASK_ENGLISH_16_KEYS_ID));
        Assert.assertFalse(keyboardsEnabled.get(ASK_ENGLISH_16_KEYS_ID));
    }

    private KeyboardAddOnAndBuilder getKeyboardFromFactory(String id) {
        List<KeyboardAddOnAndBuilder> keyboards = KeyboardFactory.getAllAvailableKeyboards(RuntimeEnvironment.application);

        for (KeyboardAddOnAndBuilder addOnAndBuilder : keyboards) {
            if (addOnAndBuilder.getId().equals(id)) {
                return addOnAndBuilder;
            }
        }

        return null;
    }

    @Test
    public void testGetKeyboardLocale() throws Exception {
        KeyboardAddOnAndBuilder askEnglish = getKeyboardFromFactory(ASK_ENGLISH_1_ID);
        assertNotNull(askEnglish);
        assertEquals(askEnglish.getKeyboardLocale(), "en");

        KeyboardAddOnAndBuilder testerEnglish = getKeyboardFromFactory(ASK_ENGLISH_16_KEYS_ID);
        assertNotNull(testerEnglish);
        assertEquals(testerEnglish.getKeyboardLocale(), "en");
    }

    @Test
{'fraction_non_alphanumeric': 0.08153310104529617, 'fraction_numerical': 0.017142857142857144, 'mean_word_length': 3.9421487603305785, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '4230411', 'n_tokens_mistral': 2066, 'n_tokens_neox': 2009, 'n_words': 315}