• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RoboMenuItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.robolectric.fakes.RoboMenuItem的典型用法代码示例。如果您正苦于以下问题:Java RoboMenuItem类的具体用法?Java RoboMenuItem怎么用?Java RoboMenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RoboMenuItem类属于org.robolectric.fakes包,在下文中一共展示了RoboMenuItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testListMenu

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@Test
public void testListMenu() {
    Bundle args = new Bundle();
    args.putString(ListFragment.EXTRA_ITEM_MANAGER, HackerNewsClient.class.getName());
    args.putString(ListFragment.EXTRA_FILTER, ItemManager.TOP_FETCH_MODE);
    activity.getSupportFragmentManager()
            .beginTransaction()
            .add(android.R.id.list,
                    Fragment.instantiate(activity, ListFragment.class.getName(), args),
                    ListFragment.class.getName())
            .commit();
    activity.getSupportFragmentManager().findFragmentByTag(ListFragment.class.getName())
            .onOptionsItemSelected(new RoboMenuItem(R.id.menu_list));
    assertThat(activity.getSupportFragmentManager())
            .hasFragmentWithTag(PopupSettingsFragment.class.getName());
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:17,代码来源:ListFragmentTest.java


示例2: testFontSizeMenu

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@Test
public void testFontSizeMenu() {
    verify(readabilityClient).parse(eq("1"), eq("http://example.com/article.html"),
            callback.capture());
    callback.getValue().onResponse("<div>content</div>");
    fragment.onOptionsItemSelected(new RoboMenuItem(R.id.menu_font_options));
    assertThat(fragment.getFragmentManager())
            .hasFragmentWithTag(PopupSettingsFragment.class.getName());
    PreferenceManager.getDefaultSharedPreferences(activity)
            .edit()
            .putString(activity.getString(R.string.pref_readability_text_size), "3")
            .apply();
    WebView webView = (WebView) activity.findViewById(R.id.web_view);
    shadowOf(webView).getWebViewClient().onPageFinished(webView, "about:blank");
    assertThat(shadowOf(webView).getLastLoadDataWithBaseURL().data).contains("20");
    assertEquals(R.style.AppTextSize_XLarge,
            Preferences.Theme.resolvePreferredReadabilityTextSize(activity));
    controller.pause().stop().destroy();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:20,代码来源:ReadabilityFragmentTest.java


示例3: testDelete

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@Test
public void testDelete() {
    RecyclerView.ViewHolder holder = shadowAdapter.getViewHolder(0);
    holder.itemView.performLongClick();

    ActionMode actionMode = mock(ActionMode.class);
    activity.actionModeCallback.onActionItemClicked(actionMode, new RoboMenuItem(R.id.menu_clear));
    AlertDialog dialog = ShadowAlertDialog.getLatestAlertDialog();
    dialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick();
    assertEquals(2, adapter.getItemCount());

    activity.actionModeCallback.onActionItemClicked(actionMode, new RoboMenuItem(R.id.menu_clear));
    dialog = ShadowAlertDialog.getLatestAlertDialog();
    dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
    verify(favoriteManager).remove(any(Context.class), selection.capture());
    assertThat(selection.getValue()).contains("1");
    verify(actionMode).finish();

    when(favoriteManager.getSize()).thenReturn(1);
    observerCaptor.getValue().onChanged();
    assertEquals(1, adapter.getItemCount());
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:23,代码来源:FavoriteActivityTest.java


示例4: testWebControls

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@SuppressLint("NewApi")
@Test
public void testWebControls() {
    ShadowLocalBroadcastManager.getInstance(activity)
            .sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN)
                    .putExtra(WebFragment.EXTRA_FULLSCREEN, true));
    ShadowWebView shadowWebView = (ShadowWebView) ShadowExtractor
            .extract(activity.findViewById(R.id.web_view));
    activity.findViewById(R.id.button_more).performClick();
    shadowOf(ShadowPopupMenu.getLatestPopupMenu()).getOnMenuItemClickListener()
            .onMenuItemClick(new RoboMenuItem(R.id.menu_zoom_in));
    assertThat(shadowWebView.getZoomDegree()).isEqualTo(1);
    activity.findViewById(R.id.button_more).performClick();
    shadowOf(ShadowPopupMenu.getLatestPopupMenu()).getOnMenuItemClickListener()
            .onMenuItemClick(new RoboMenuItem(R.id.menu_zoom_out));
    assertThat(shadowWebView.getZoomDegree()).isEqualTo(0);
    activity.findViewById(R.id.button_forward).performClick();
    assertThat(shadowWebView.getPageIndex()).isEqualTo(1);
    activity.findViewById(R.id.button_back).performClick();
    assertThat(shadowWebView.getPageIndex()).isEqualTo(0);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:22,代码来源:WebFragmentTest.java


示例5: testContextMenu1

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@Test
public void testContextMenu1() {
    adapter.updateDataSet(contacts);
    RecyclerView.ViewHolder viewHolder = adapter.onCreateViewHolder(recyclerView, 0);
    adapter.onBindViewHolder(viewHolder, 0);
    try {
        viewHolder.itemView.performLongClick(); // Danke Robolectric. NullPointer weil irgendwas mit Menu buggy..
    } catch (NullPointerException e) {
        //Nichts tun.
    }

    RoboMenuItem item = new RoboMenuItem(R.id.context_tab_show_in_contacts);
    item.setGroupId(R.id.context_tab_contact_group);
    fragment.onContextItemSelected(item);
    ShadowActivity a = Shadows.shadowOf(activity);
    Intent i  = a.getNextStartedActivityForResult().intent;
    assertNotNull(i);

}
 
开发者ID:weichweich,项目名称:AluShare,代码行数:20,代码来源:ContactTabFragmentTest.java


示例6: testContextMenu2

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@Test (expected = NullPointerException.class)
public void testContextMenu2() {
    adapter.updateDataSet(contacts);
    RecyclerView.ViewHolder viewHolder = adapter.onCreateViewHolder(recyclerView, 0);
    adapter.onBindViewHolder(viewHolder, 0);
    try {
        viewHolder.itemView.performLongClick(); // Danke Robolectric. NullPointer weil irgendwas mit Menu buggy..
    } catch (NullPointerException e) {
        //Nichts tun.
    }

    Contact contact = contacts.get(0);
    RoboMenuItem item = new RoboMenuItem(R.id.context_tab_contact_delete);
    item.setGroupId(R.id.context_tab_contact_group);
    fragment.onContextItemSelected(item);
    contacts = contactHelper.getContacts();
    assertTrue(contacts.contains(contact));

}
 
开发者ID:weichweich,项目名称:AluShare,代码行数:20,代码来源:ContactTabFragmentTest.java


示例7: testContextMenu3

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@Test (expected = NullPointerException.class)
public void testContextMenu3() {
    adapter.updateDataSet(contacts);
    RecyclerView.ViewHolder viewHolder = adapter.onCreateViewHolder(recyclerView, 0);
    adapter.onBindViewHolder(viewHolder, 0);
    try {
        viewHolder.itemView.performLongClick(); // Danke Robolectric. NullPointer weil irgendwas mit Menu buggy..
    } catch (NullPointerException e) {
        //Nichts tun.
    }

    Contact contact = contacts.get(0);
    RoboMenuItem item = new RoboMenuItem(R.id.context_tab_contact_delete);
    item.setGroupId(R.id.context_tab_contact_group);
    contacts = contactHelper.getContacts();

    List<Chat> chatList = chatHelper.getChatsByContactID(contact.getId());
    for(Chat chat :  chatList) {
        chatHelper.delete(chat);
    }

    fragment.onContextItemSelected(item);
    contacts = contactHelper.getContacts();
    assertFalse(contacts.contains(contact));

}
 
开发者ID:weichweich,项目名称:AluShare,代码行数:27,代码来源:ContactTabFragmentTest.java


示例8: testContextMenu

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@Test
public void testContextMenu()  {
    adapter.updateDataSet(files);
    long fileToDelete = files.get(0).getId();
    FileTabRecyclerItemViewHolder viewHolder = (FileTabRecyclerItemViewHolder) adapter.onCreateViewHolder(recyclerView, 0);
    adapter.onBindViewHolder(viewHolder, 0);
    try {
        viewHolder.itemView.performLongClick(); // Danke Robolectric. NullPointer weil irgendwas mit Menu buggy..
    } catch (NullPointerException e) {
        //Nichts tun.
    }
    RoboMenuItem item = new RoboMenuItem(R.id.context_tab_file_delete);
    item.setGroupId(R.id.context_tab_file_group);

    fragment.onContextItemSelected(item); // Wirft NullPointerException weil Robolectric das Fragment nicht richtig mocked this.getView ist Null..
    assertNull(helper.getFileByID(fileToDelete));
}
 
开发者ID:weichweich,项目名称:AluShare,代码行数:18,代码来源:FileTabFragmentTest.java


示例9: testlContextDelete

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@Test
public void testlContextDelete() {
    adapter.updateDataSet(chats);
    String chatID = chats.get(0).getNetworkChatID();
    RecyclerView.ViewHolder viewHolder = adapter.onCreateViewHolder(recyclerView, 0);
    adapter.onBindViewHolder(viewHolder, 0);

    try {
        viewHolder.itemView.performLongClick(); // Danke Robolectric. NullPointer weil irgendwas mit Menu buggy..
    } catch (NullPointerException e) {
        //Nichts tun.
    }

    RoboMenuItem item = new RoboMenuItem(R.id.context_tab_chat_delete);
    item.setGroupId(R.id.context_tab_chat_group);

    fragment.onContextItemSelected(item);
    assertNull(helper.getChat(chatID));
}
 
开发者ID:weichweich,项目名称:AluShare,代码行数:20,代码来源:ChatTabFragmentTest.java


示例10: testDisplayMenu

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@Test
public void testDisplayMenu() {
    WebItem webItem = mock(WebItem.class);
    when(webItem.getId()).thenReturn("1");
    Bundle args = new Bundle();
    args.putParcelable(ItemFragment.EXTRA_ITEM, webItem);
    Fragment fragment = Fragment.instantiate(RuntimeEnvironment.application,
            ItemFragment.class.getName(), args);
    makeVisible(fragment);
    fragment.onOptionsItemSelected(new RoboMenuItem(R.id.menu_comments));
    assertThat(fragment.getFragmentManager())
            .hasFragmentWithTag(PopupSettingsFragment.class.getName());
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:14,代码来源:ItemFragmentMultiPageTest.java


示例11: testWebToggle

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@Test
public void testWebToggle() {
    fragment.onOptionsItemSelected(new RoboMenuItem(R.id.menu_readability));
    WebView webView = (WebView) activity.findViewById(R.id.web_view);
    shadowOf(webView).getWebViewClient().onPageFinished(webView, "about:blank");
    assertThat(shadowOf(webView).getLastLoadedUrl()).isEqualTo("http://example.com/article.html");
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:8,代码来源:ReadabilityFragmentTest.java


示例12: testFullscreenMenu

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@SuppressLint("NewApi")
@Test
public void testFullscreenMenu() {
    verify(readabilityClient).parse(eq("1"), eq("http://example.com/article.html"),
            callback.capture());
    callback.getValue().onResponse("<div>content</div>");
    ShadowLocalBroadcastManager.getInstance(activity)
            .sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN)
                    .putExtra(WebFragment.EXTRA_FULLSCREEN, true));
    activity.findViewById(R.id.button_more).performClick();
    shadowOf(ShadowPopupMenu.getLatestPopupMenu()).getOnMenuItemClickListener()
            .onMenuItemClick(new RoboMenuItem(R.id.menu_font_options));
    assertThat(fragment.getFragmentManager())
            .hasFragmentWithTag(PopupSettingsFragment.class.getName());
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:16,代码来源:ReadabilityFragmentTest.java


示例13: testVote

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVote() {
    viewHolder.itemView.findViewById(R.id.button_more).performClick();
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    assertNotNull(popupMenu);
    shadowOf(popupMenu).getOnMenuItemClickListener()
            .onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_vote));
    verify(userServices).voteUp(any(Context.class), any(), voteCallback.capture());
    voteCallback.getValue().onDone(true);
    assertEquals(activity.getString(R.string.voted), ShadowToast.getTextOfLatestToast());
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:13,代码来源:ItemFragmentSinglePageTest.java


示例14: testVoteItemPromptToLogin

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVoteItemPromptToLogin() {
    viewHolder.itemView.findViewById(R.id.button_more).performClick();
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    assertNotNull(popupMenu);
    shadowOf(popupMenu).getOnMenuItemClickListener()
            .onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_vote));
    verify(userServices).voteUp(any(Context.class), any(), voteCallback.capture());
    voteCallback.getValue().onDone(false);
    assertThat(shadowOf(activity).getNextStartedActivity())
            .hasComponent(activity, LoginActivity.class);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:14,代码来源:ItemFragmentSinglePageTest.java


示例15: testVoteItemFailed

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVoteItemFailed() {
    viewHolder.itemView.findViewById(R.id.button_more).performClick();
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    assertNotNull(popupMenu);
    shadowOf(popupMenu).getOnMenuItemClickListener()
            .onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_vote));
    verify(userServices).voteUp(any(Context.class), any(), voteCallback.capture());
    voteCallback.getValue().onError(new IOException());
    assertEquals(activity.getString(R.string.vote_failed), ShadowToast.getTextOfLatestToast());
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:13,代码来源:ItemFragmentSinglePageTest.java


示例16: testReply

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testReply() {
    viewHolder.itemView.findViewById(R.id.button_more).performClick();
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    assertNotNull(popupMenu);
    shadowOf(popupMenu).getOnMenuItemClickListener()
            .onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_comment));
    assertThat(shadowOf(activity).getNextStartedActivity())
            .hasComponent(activity, ComposeActivity.class)
            .hasExtra(ComposeActivity.EXTRA_PARENT_ID, "1");
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:13,代码来源:ItemFragmentSinglePageTest.java


示例17: testShare

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testShare() {
    TestApplication.addResolver(new Intent(Intent.ACTION_SEND));
    viewHolder.itemView.findViewById(R.id.button_more).performClick();
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    assertNotNull(popupMenu);
    shadowOf(popupMenu).getOnMenuItemClickListener()
            .onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_share));
    assertThat(shadowOf(activity).getNextStartedActivity())
            .hasAction(Intent.ACTION_SEND);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:13,代码来源:ItemFragmentSinglePageTest.java


示例18: testRefresh

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@Test
public void testRefresh() {
    RecyclerView.ViewHolder holder = shadowAdapter.getViewHolder(0);
    holder.itemView.performLongClick();

    ActionMode actionMode = mock(ActionMode.class);
    activity.actionModeCallback.onActionItemClicked(actionMode, new RoboMenuItem(R.id.menu_refresh));
    verify(syncScheduler).scheduleSync(any(), any());
    verify(actionMode).finish();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:11,代码来源:FavoriteActivityTest.java


示例19: testVoteItem

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVoteItem() {
    shadowAdapter.getViewHolder(0).itemView.findViewById(R.id.button_more).performClick();
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    Assert.assertNotNull(popupMenu);
    shadowOf(popupMenu).getOnMenuItemClickListener()
            .onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_vote));
    verify(userServices).voteUp(any(Context.class), any(), userServicesCallback.capture());
    userServicesCallback.getValue().onDone(true);
    assertEquals(activity.getString(R.string.voted), ShadowToast.getTextOfLatestToast());
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:13,代码来源:FavoriteActivityTest.java


示例20: testVoteItemPromptToLogin

import org.robolectric.fakes.RoboMenuItem; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVoteItemPromptToLogin() {
    shadowAdapter.getViewHolder(0).itemView.findViewById(R.id.button_more).performClick();
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    Assert.assertNotNull(popupMenu);
    shadowOf(popupMenu).getOnMenuItemClickListener()
            .onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_vote));
    verify(userServices).voteUp(any(Context.class), any(), userServicesCallback.capture());
    userServicesCallback.getValue().onDone(false);
    assertThat(shadowOf(activity).getNextStartedActivity())
            .hasComponent(activity, LoginActivity.class);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:14,代码来源:FavoriteActivityTest.java



注:本文中的org.robolectric.fakes.RoboMenuItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ArArchiveEntry类代码示例发布时间:2022-05-23
下一篇:
Java LocalNameQualifiedNamesMap类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap