package com.xtremelabs.robolectric.shadows;

import android.app.Application;
import android.view.MenuInflater;
import com.xtremelabs.robolectric.view.TestMenu;
import com.xtremelabs.robolectric.view.TestMenuItem;
import com.xtremelabs.robolectric.R;
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.WithTestDefaultsRunner;
import com.xtremelabs.robolectric.res.ResourceLoader;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.File;
import static com.xtremelabs.robolectric.Robolectric.shadowOf;

import static org.junit.Assert.assertEquals;

@RunWith(WithTestDefaultsRunner.class)
public class MenuInflaterTest {
    private ShadowMenuInflater MenuInflater;

    @Before
    public void setUp() throws Exception {
        Robolectric.bindDefaultShadowClasses();
        Robolectric.application = ShadowApplication.bind(new Application(), new ResourceLoader(R.class, new File("test/res")));
        MenuInflater = shadowOf(new MenuInflater(Robolectric.application));
    }

	@Test
	public void canRetrieveMenuList()
	{
        TestMenu menu = new TestMenu();
		System.out.println(MenuInflater);
		MenuInflater.inflate(R.menu.test, menu);
		
        TestMenuItem testMenuItem = (TestMenuItem) menu.getItem(0);
        assertEquals(testMenuItem.getTitle().toString(), "Test menu item 1");
        testMenuItem.click();

		testMenuItem = (TestMenuItem) menu.getItem(1);
        assertEquals(testMenuItem.getTitle().toString(), "Test menu item 2");
        testMenuItem.click();
	}

}

@@ -1294,32 +1294,52 @@
    assertEquals(
+%22Test menu item 1%22, 
 testMenuItem.get
@@ -1360,28 +1360,8 @@
 ng()
-, %22Test menu item 1%22
 );%0A 
@@ -1460,16 +1460,36 @@
 tEquals(
+%22Test menu item 2%22, 
 testMenu
@@ -1518,28 +1518,8 @@
 ng()
-, %22Test menu item 2%22
 );%0A 

Swap assertEquals orders for nicer error messages