当前位置: 首页>>代码示例>>Java>>正文


Java Assertions类代码示例

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


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

示例1: whenShown_thenButtonsTextsCorrect

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void whenShown_thenButtonsTextsCorrect() {
  String positive = "126kas";
  String neutral = "12asi";
  String negative = "98io8";

  DialogFields fields = DialogFields.builder(activity)
      .positiveText(positive)
      .neutralText(neutral)
      .negativeText(negative)
      .build();

  LambdaDialogs.delegate(activity)
      .parameter(fields)
      .method(new AlertDialogFactory<>())
      .show();

  AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
  Assertions.assertThat(dialog.getButton(AlertDialog.BUTTON_POSITIVE)).hasText(positive);
  Assertions.assertThat(dialog.getButton(AlertDialog.BUTTON_NEUTRAL)).hasText(neutral);
  Assertions.assertThat(dialog.getButton(AlertDialog.BUTTON_NEGATIVE)).hasText(negative);
}
 
开发者ID:jraska,项目名称:lambda-dialogs,代码行数:23,代码来源:LambdaDialogsBuilderTest.java

示例2: testEmptyResponse

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void testEmptyResponse() {
    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))
            .commit();
    verify(itemManager).getStories(any(),
            eq(ItemManager.MODE_DEFAULT),
            listener.capture());
    listener.getValue().onResponse(new Item[0]);
    assertThat((SwipeRefreshLayout) activity.findViewById(R.id.swipe_layout)).isNotRefreshing();
    Assertions.assertThat((View) activity.findViewById(R.id.empty)).isNotVisible();
    controller.pause().stop().destroy();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:19,代码来源:ListFragmentTest.java

示例3: testErrorResponse

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void testErrorResponse() {
    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))
            .commit();
    verify(itemManager).getStories(any(),
            eq(ItemManager.MODE_DEFAULT),
            listener.capture());
    listener.getValue().onError(null);
    assertThat((SwipeRefreshLayout) activity.findViewById(R.id.swipe_layout)).isNotRefreshing();
    Assertions.assertThat((View) activity.findViewById(R.id.empty)).isVisible();
    controller.pause().stop().destroy();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:19,代码来源:ListFragmentTest.java

示例4: givenActionTextAndClickListener_whenBuildWrapper_thenActionTextAndClickListenerSet

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void givenActionTextAndClickListener_whenBuildWrapper_thenActionTextAndClickListenerSet() {
  RuntimeEnvironment.application.setTheme(R.style.TestSnackbarBuilder_AppTheme);
  CoordinatorLayout parent = new CoordinatorLayout(RuntimeEnvironment.application);

  SnackbarWrapper wrapper = new SnackbarBuilder(parent)
      .actionText("action")
      .actionClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
          view.setBackgroundColor(Color.RED);
        }
      })
      .buildWrapper();

  assertThat(wrapper.getActionText()).isEqualTo("action");
  View actionView = wrapper.getView().findViewById(R.id.snackbar_action);
  actionView.performClick();
  Assertions.assertThat((ColorDrawable) actionView.getBackground()).hasColor(Color.RED);
}
 
开发者ID:andrewlord1990,项目名称:SnackbarBuilder,代码行数:21,代码来源:SnackbarBuilderTest.java

示例5: givenIcon_whenBuild_thenIconAddedToSnackbar

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void givenIcon_whenBuild_thenIconAddedToSnackbar() {
  RuntimeEnvironment.application.setTheme(R.style.TestSnackbarBuilder_AppTheme);
  CoordinatorLayout parent = new CoordinatorLayout(RuntimeEnvironment.application);

  Snackbar snackbar = new SnackbarBuilder(parent)
      .message("messsage")
      .icon(drawable)
      .iconMargin(10)
      .build();

  TextView messageView = (TextView) snackbar.getView().findViewById(R.id.snackbar_text);
  Assertions.assertThat(messageView)
      .hasCompoundDrawablePadding(10);
  assertThat(messageView.getCompoundDrawables()[0]).isEqualTo(drawable);
}
 
开发者ID:andrewlord1990,项目名称:SnackbarBuilder,代码行数:17,代码来源:SnackbarBuilderTest.java

示例6: testRefreshError

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void testRefreshError() {
    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))
            .commit();
    verify(itemManager).getStories(any(),
            eq(ItemManager.MODE_DEFAULT),
            listener.capture());
    listener.getValue().onResponse(new Item[]{new TestItem() {}});
    Assertions.assertThat((View) activity.findViewById(R.id.empty)).isNotVisible();
    reset(itemManager);
    ShadowSwipeRefreshLayout shadowSwipeRefreshLayout = (ShadowSwipeRefreshLayout)
            ShadowExtractor.extract(activity.findViewById(R.id.swipe_layout));
    shadowSwipeRefreshLayout.getOnRefreshListener().onRefresh();
    verify(itemManager).getStories(any(),
            eq(ItemManager.MODE_NETWORK),
            listener.capture());
    listener.getValue().onError(null);
    Assertions.assertThat((View) activity.findViewById(R.id.empty)).isNotVisible();
    assertNotNull(ShadowToast.getLatestToast());
    controller.pause().stop().destroy();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:28,代码来源:ListFragmentTest.java

示例7: count

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void count() {
    List<Persona> personas = generatePersonas();

    PersonasAdapter personasAdapter = new PersonasAdapter(context, personas);

    Assertions.assertThat(personasAdapter).hasCount(personas.size());
}
 
开发者ID:hawkular,项目名称:hawkular-android-client,代码行数:9,代码来源:PersonasAdapterTester.java

示例8: item

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void item() {
    Persona persona = generatePersona();

    List<Persona> personas = new ArrayList<>();
    personas.add(persona);
    personas.addAll(generatePersonas());

    PersonasAdapter personasAdapter = new PersonasAdapter(context, personas);

    Assertions.assertThat(personasAdapter).hasItem(persona, 0);
}
 
开发者ID:hawkular,项目名称:hawkular-android-client,代码行数:13,代码来源:PersonasAdapterTester.java

示例9: alerts

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void alerts() {
    Intent intent = Intents.Builder.of(context).buildAlertsIntent(generateResource());

    Assertions.assertThat(intent).hasComponent(context, AlertsActivity.class);
    Assertions.assertThat(intent).hasExtra(Intents.Extras.RESOURCE);
}
 
开发者ID:hawkular,项目名称:hawkular-android-client,代码行数:8,代码来源:IntentsTester.java

示例10: metric

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void metric() {
    Intent intent = Intents.Builder.of(context).buildMetricIntent(generateMetric());

    Assertions.assertThat(intent).hasComponent(context, MetricActivity.class);
    Assertions.assertThat(intent).hasExtra(Intents.Extras.METRIC);
}
 
开发者ID:hawkular,项目名称:hawkular-android-client,代码行数:8,代码来源:IntentsTester.java

示例11: metrics

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void metrics() {
    Intent intent = Intents.Builder.of(context).buildMetricsIntent(generateEnvironment(), generateResource());

    Assertions.assertThat(intent).hasComponent(context, MetricsActivity.class);
    Assertions.assertThat(intent).hasExtra(Intents.Extras.ENVIRONMENT);
    Assertions.assertThat(intent).hasExtra(Intents.Extras.RESOURCE);
}
 
开发者ID:hawkular,项目名称:hawkular-android-client,代码行数:9,代码来源:IntentsTester.java

示例12: metrics

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void metrics() {
    Fragment fragment = Fragments.Builder.buildMetricsFragment(generateEnvironment(), generateResource());

    Assertions.assertThat(fragment.getArguments()).hasKey(Fragments.Arguments.ENVIRONMENT);
    Assertions.assertThat(fragment.getArguments()).hasKey(Fragments.Arguments.RESOURCE);
}
 
开发者ID:hawkular,项目名称:hawkular-android-client,代码行数:8,代码来源:FragmentsTester.java

示例13: givenClickListener_whenSetActionWithResource_thenActionSetAndShown

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void givenClickListener_whenSetActionWithResource_thenActionSetAndShown() {
  TestClickListener clickListener = new TestClickListener();

  wrapper.setAction(R.string.snackbarbuilder_action_undo, clickListener);

  Assertions.assertThat(getActionView())
      .isVisible()
      .hasText("Undo");
  getActionView().performClick();
  assertThat(clickListener.isClicked()).isTrue();
}
 
开发者ID:andrewlord1990,项目名称:SnackbarBuilder,代码行数:13,代码来源:SnackbarWrapperTest.java

示例14: givenClickListener_whenSetAction_thenActionSetAndShown

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void givenClickListener_whenSetAction_thenActionSetAndShown() {
  TestClickListener clickListener = new TestClickListener();
  String actionText = "some action";

  wrapper.setAction(actionText, clickListener);

  Assertions.assertThat(getActionView())
      .isVisible()
      .hasText(actionText);
  getActionView().performClick();
  assertThat(clickListener.isClicked()).isTrue();
}
 
开发者ID:andrewlord1990,项目名称:SnackbarBuilder,代码行数:14,代码来源:SnackbarWrapperTest.java

示例15: whenSetBackgroundColor_thenBackgroundColorSet

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void whenSetBackgroundColor_thenBackgroundColorSet() {
  wrapper.setBackgroundColor(Color.MAGENTA);

  Assertions.assertThat((ColorDrawable) wrapper.getView().getBackground())
      .hasColor(Color.MAGENTA);
}
 
开发者ID:andrewlord1990,项目名称:SnackbarBuilder,代码行数:8,代码来源:SnackbarWrapperTest.java


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