{"action":"created","issue":{"url":"https://api.github.com/repos/robolectric/robolectric/issues/1545","labels_url":"https://api.github.com/repos/robolectric/robolectric/issues/1545/labels{/name}","comments_url":"https://api.github.com/repos/robolectric/robolectric/issues/1545/comments","events_url":"https://api.github.com/repos/robolectric/robolectric/issues/1545/events","html_url":"https://github.com/robolectric/robolectric/issues/1545","id":56928502,"number":1545,"title":"After Android.onCreateOptionsMenu() returns false, Fragment.onOptionsItemSelected() is not being called.","user":{"login":"WojciechKo","id":5589559,"avatar_url":"https://avatars.githubusercontent.com/u/5589559?v=3","gravatar_id":"","url":"https://api.github.com/users/WojciechKo","html_url":"https://github.com/WojciechKo","followers_url":"https://api.github.com/users/WojciechKo/followers","following_url":"https://api.github.com/users/WojciechKo/following{/other_user}","gists_url":"https://api.github.com/users/WojciechKo/gists{/gist_id}","starred_url":"https://api.github.com/users/WojciechKo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WojciechKo/subscriptions","organizations_url":"https://api.github.com/users/WojciechKo/orgs","repos_url":"https://api.github.com/users/WojciechKo/repos","events_url":"https://api.github.com/users/WojciechKo/events{/privacy}","received_events_url":"https://api.github.com/users/WojciechKo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-07T22:20:57Z","updated_at":"2015-03-15T17:48:54Z","closed_at":null,"body":"I have Activity with single Fragment.\r\nIn Activity I create `delete` and `save` menu. `delete` menu is handled by `MyActivity` and `save` menu in `MyFragment`.\r\nProblem is when I call in test:  \r\n\r\n    activity.onOptionsItemSelected(new RoboMenuItem(R.id.menu_save));\r\n\r\nIt doesn't call Fragment.onOptionsItemSelected() after return false like it does on Android device.\r\nThe same with `TestMenuItem` from 2.4 and `RoboMenuItem` from 3.0-SNAPSHOT\r\nAm i doing something wrong, or is it a bug?\r\n\r\n### MyActivity:  \r\n\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        \r\n        if (savedInstanceState == null) {\r\n            getSupportFragmentManager()\r\n                    .beginTransaction()\r\n                    .replace(R.id.container, MyFragment.newInstance())\r\n                    .commit();\r\n        }\r\n    }\r\n    \r\n    \r\n    @Override\r\n    public boolean onCreateOptionsMenu(Menu menu) {\r\n        getMenuInflater().inflate(R.menu.action_delete, menu);\r\n        getMenuInflater().inflate(R.menu.action_save, menu);\r\n        return super.onCreateOptionsMenu(menu);\r\n    }\r\n\r\n    @Override\r\n    public boolean onOptionsItemSelected(MenuItem item) {\r\n        boolean result = super.onOptionsItemSelected(item);\r\n        if (item.getItemId() == R.id.menu_delete) {\r\n            onDeleteOptionSelected();\r\n            return true;\r\n        }\r\n        return result;\r\n    }\r\n    \r\n### MyFragment:  \r\n\r\n    @Override\r\n    public boolean onOptionsItemSelected(MenuItem item) {\r\n        boolean result = super.onOptionsItemSelected(item);\r\n        if (item.getItemId() == R.id.menu_save) {\r\n            onSaveOptionSelected();\r\n            return true;\r\n        }\r\n        return result;\r\n    }"},"comment":{"url":"https://api.github.com/repos/robolectric/robolectric/issues/comments/81176426","html_url":"https://github.com/robolectric/robolectric/issues/1545#issuecomment-81176426","issue_url":"https://api.github.com/repos/robolectric/robolectric/issues/1545","id":81176426,"user":{"login":"erd","id":184194,"avatar_url":"https://avatars.githubusercontent.com/u/184194?v=3","gravatar_id":"","url":"https://api.github.com/users/erd","html_url":"https://github.com/erd","followers_url":"https://api.github.com/users/erd/followers","following_url":"https://api.github.com/users/erd/following{/other_user}","gists_url":"https://api.github.com/users/erd/gists{/gist_id}","starred_url":"https://api.github.com/users/erd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erd/subscriptions","organizations_url":"https://api.github.com/users/erd/orgs","repos_url":"https://api.github.com/users/erd/repos","events_url":"https://api.github.com/users/erd/events{/privacy}","received_events_url":"https://api.github.com/users/erd/received_events","type":"User","site_admin":false},"created_at":"2015-03-15T17:48:54Z","updated_at":"2015-03-15T17:48:54Z","body":"Could you try replacing the call to:\r\n\r\n    activity.onOptionsItemSelected(new RoboMenuItem(R.id.menu_save));\r\n\r\nwith \r\n\r\n    shadowOf(activity).clickMenuItem(R.id.menu_save)\r\n\r\n(assuming you're using 3.0-SNAPSHOT). I would suggest avoiding `RoboMenuItem` since it's a completely fake implementation of `MenuItem`."}}