<commit_before>package pl.polidea.navigator;

import java.io.File;

import pl.polidea.navigator.factories.NavigationMenuFactoryBase;
import pl.polidea.navigator.menu.AbstractNavigationMenu;
import pl.polidea.navigator.menu.BasicMenuTypes;
import pl.polidea.navigator.menu.IconsMenu;
import pl.polidea.navigator.menu.ListMenu;
import pl.polidea.navigator.menu.MenuContext;
import pl.polidea.navigator.menu.MenuImport;
import pl.polidea.navigator.menu.PhoneNumberMenu;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;

/**
 * Test for menu reader.
 */
public class MenuReaderTest extends ActivityInstrumentationTestCase2<MenuNavigatorBaseActivity> {

    private MenuNavigatorBaseActivity mActivity;
    private AssetMenuRetriever assetRetriever;
    private AbstractNavigationMenu navigationMenu;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        mActivity = this.getActivity();
        assetRetriever = new AssetMenuRetriever(mActivity, "testmenu", "menu");
        assetRetriever.copyMenu();
        final JsonMenuReader reader = new JsonMenuReader(new File(assetRetriever.getBaseDirectory(), "menu"),
                "main_menu.json", null, new NavigationMenuFactoryBase(), true);
        reader.createMenu(new MenuContext());
        navigationMenu = reader.getMyMenu();
        Log.d("MenuReaderTest", navigationMenu.toString());
    }

    public MenuReaderTest() {
        super("pl.polidea.navigator", MenuNavigatorBaseActivity.class);
    }

    public void testPrecondition() {
        assertNotNull(mActivity);
    }

    public void testMainMenuReadCorrectly() {
        assertEquals("Main menu", navigationMenu.name);
        assertEquals("Choose menu", navigationMenu.description);
        assertEquals(BasicMenuTypes.ICONS, navigationMenu.menuType);
        assertTrue(navigationMenu instanceof IconsMenu);
        assertNull(navigationMenu.iconFile);
    }

    public void testMainMenuHas3Items() {
        final IconsMenu iconsNavigationMenu = (IconsMenu) navigationMenu;<commit_msg>Menu ready added<commit_after>package pl.polidea.navigator;

import java.io.File;

import pl.polidea.navigator.factories.NavigationMenuFactoryBase;
import pl.polidea.navigator.menu.AbstractNavigationMenu;
import pl.polidea.navigator.menu.BasicMenuTypes;
import pl.polidea.navigator.menu.IconsMenu;
import pl.polidea.navigator.menu.ListMenu;
import pl.polidea.navigator.menu.MenuContext;
import pl.polidea.navigator.menu.MenuImport;
import pl.polidea.navigator.menu.PhoneNumberMenu;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;

/**
 * Test for menu reader.
 */
public class MenuReaderTest extends ActivityInstrumentationTestCase2<MenuNavigatorBaseActivity> {

    private MenuNavigatorBaseActivity mActivity;
    private AssetMenuRetriever assetRetriever;
    private AbstractNavigationMenu navigationMenu;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        mActivity = this.getActivity();
        mActivity.signalMenuReady();
        assetRetriever = new AssetMenuRetriever(mActivity, "testmenu", "menu");
        assetRetriever.copyMenu();
        final JsonMenuReader reader = new JsonMenuReader(new File(assetRetriever.getBaseDirectory(), "menu"),
                "main_menu.json", null, new NavigationMenuFactoryBase(), true);
        reader.createMenu(new MenuContext());
        navigationMenu = reader.getMyMenu();
        Log.d("MenuReaderTest", navigationMenu.toString());
    }

    public MenuReaderTest() {
        super("pl.polidea.navigator", MenuNavigatorBaseActivity.class);
    }

    public void testPrecondition() {
        assertNotNull(mActivity);
    }

    public void testMainMenuReadCorrectly() {
        assertEquals("Main menu", navigationMenu.name);
        assertEquals("Choose menu", navigationMenu.description);
        assertEquals(BasicMenuTypes.ICONS, navigationMenu.menuType);
        assertTrue(navigationMenu instanceof IconsMenu);
        assertNull(navigationMenu.iconFile);
    }

    public void testMainMenuHas3Items() {
        final IconsMenu iconsNavigationMenu = (IconsMenu) navigationMenu;
{'fraction_non_alphanumeric': 0.09464627151051626, 'fraction_numerical': 0.0014340344168260039, 'mean_word_length': 4.2774274905422445, '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': '6074251', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1116, 'n_words': 214}