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


Java Robolectric类代码示例

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


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

示例1: testWindowsFocusChanged

import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void testWindowsFocusChanged() throws Exception {
    BaseChromiumApplication app = (BaseChromiumApplication) Robolectric.application;

    WindowFocusChangedListener mock = mock(WindowFocusChangedListener.class);
    app.registerWindowFocusChangedListener(mock);

    ActivityController<Activity> controller =
            Robolectric.buildActivity(Activity.class).create().start().visible();
    TrackingShadowActivity shadow =
            (TrackingShadowActivity) Robolectric.shadowOf(controller.get());

    controller.get().getWindow().getCallback().onWindowFocusChanged(true);
    // Assert that listeners were notified.
    verify(mock).onWindowFocusChanged(controller.get(), true);
    // Also ensure that the original activity is forwarded the notification.
    Assert.assertEquals(1, shadow.mWindowFocusCalls);
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:19,代码来源:BaseChromiumApplicationTest.java

示例2: startWithMissingProperty

import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void startWithMissingProperty()
{
    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    bundle.putLong("id", 0);
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertyPicturesActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    assertTrue(activity.isFinishing());

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNotNull(latestToast);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:18,代码来源:PropertyPicturesActivityTest.java

示例3: startWithoutProperty

import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void startWithoutProperty()
{
    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertyPicturesActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    assertTrue(activity.isFinishing());

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNotNull(latestToast);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:17,代码来源:PropertyPicturesActivityTest.java

示例4: testBindActivity

import org.robolectric.Robolectric; //导入依赖的package包/类
@Test public void testBindActivity() throws Exception {
  ActivityController controller = Robolectric.buildActivity(TestActivity.class).create().start();
  NaviActivity activity = (NaviActivity) controller.get();

  this.presenter.bind(activity);

  controller.create();
  //before activity start view is unbound
  assertTrue(this.presenter.view == null);

  controller.start();
  //after activity started view has been bound automatically
  assertTrue(this.presenter.view != null);

  controller.destroy();
  //before activity destroyed view is unbound
  assertTrue(this.presenter.view == null);
}
 
开发者ID:ezhome,项目名称:Android-RxPresenter,代码行数:19,代码来源:RxPresenterTest.java

示例5: setUp

import org.robolectric.Robolectric; //导入依赖的package包/类
@Before public void setUp() throws Exception {
  activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
  timeZone = TimeZone.getTimeZone("GMT+06:00");
  locale = Locale.US;
  view = new CalendarPickerView(activity, null);
  today = Calendar.getInstance(timeZone, locale);
  today.set(2012, NOVEMBER, 16, 0, 0);
  minDate = today.getTime();
  today.set(2013, NOVEMBER, 16, 0, 0);
  maxDate = today.getTime();
  today.set(2012, NOVEMBER, 16, 0, 0);
  Date startDate = today.getTime();
  view.init(minDate, maxDate, timeZone, locale) //
      .inMode(SINGLE) //
      .withSelectedDate(startDate);

  // Do not change the internal state of the CalendarPickerView until init() has run.
  view.today.setTime(startDate);
}
 
开发者ID:savvisingh,项目名称:DateRangePickerLibrary,代码行数:20,代码来源:CalendarPickerViewTest.java

示例6: setUp

import org.robolectric.Robolectric; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    Context context = ShadowApplication.getInstance().getApplicationContext();
    Robolectric.getBackgroundThreadScheduler().pause();

    recipientMvpView = mock(RecipientMvpView.class);
    account = mock(Account.class);
    composePgpInlineDecider = mock(ComposePgpInlineDecider.class);
    composePgpEnableByDefaultDecider = mock(ComposePgpEnableByDefaultDecider.class);
    autocryptStatusInteractor = mock(AutocryptStatusInteractor.class);
    replyToParser = mock(ReplyToParser.class);
    LoaderManager loaderManager = mock(LoaderManager.class);
    listener = mock(RecipientPresenter.RecipientsChangedListener.class);

    recipientPresenter = new RecipientPresenter(
            context, loaderManager, recipientMvpView, account, composePgpInlineDecider,
            composePgpEnableByDefaultDecider, autocryptStatusInteractor, replyToParser, listener);
    runBackgroundTask();

    noRecipientsAutocryptResult = new RecipientAutocryptStatus(RecipientAutocryptStatusType.NO_RECIPIENTS, null);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:22,代码来源:RecipientPresenterTest.java

示例7: setUp

import org.robolectric.Robolectric; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();
    RecipeMainActivity recipeMainActivity = new RecipeMainActivity() {
        public ImageLoader getImageLoader() {
            return imageLoader;
        }

        public RecipeMainPresenter getPresenter() {
            return presenter;
        }
    };

    controller = ActivityController.of(Robolectric.getShadowsAdapter(), recipeMainActivity).create().visible();
    activity = controller.get();
    view = (RecipeMainView) activity;
    shadowAcivity = shadowOf(activity);
}
 
开发者ID:micromasterandroid,项目名称:androidadvanced,代码行数:19,代码来源:RecipeMainActivityTest.java

示例8: startWithProperty

import org.robolectric.Robolectric; //导入依赖的package包/类
private ActivityController startWithProperty(Property property)
{
    long id = db.insertProperty(property);

    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    bundle.putLong("id", id);
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertyProjectionsActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();
    assertTrue(activity.isFinishing() == false);

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNull(latestToast);

    return controller;
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:23,代码来源:PropertyProjectionsActivityTest.java

示例9: startWithoutProperty

import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void startWithoutProperty()
{
    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertyWorksheetActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    assertTrue(activity.isFinishing());

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNotNull(latestToast);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:17,代码来源:PropertyWorksheetActivityTest.java

示例10: startWithMissingProperty

import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void startWithMissingProperty()
{
    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    bundle.putLong("id", 0);
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertyProjectionsActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();
    assertTrue(activity.isFinishing());

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNotNull(latestToast);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:20,代码来源:PropertyProjectionsActivityTest.java

示例11: testFirstRunStartsIntro

import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void testFirstRunStartsIntro()
{
    prefs.edit().remove("firstrun").commit();

    ActivityController controller = Robolectric.buildActivity(PropertiesListActivity.class).create();
    Activity activity = (Activity)controller.get();

    assertTrue(activity.isFinishing() == false);

    Intent next = shadowOf(activity).getNextStartedActivity();

    ComponentName componentName = next.getComponent();
    String name = componentName.flattenToShortString();
    assertEquals("protect.rentalcalc/.IntroActivity", name);

    Bundle extras = next.getExtras();
    assertNull(extras);

    assertEquals(false, prefs.getBoolean("firstrun", true));
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:22,代码来源:PropertiesListActivityTest.java

示例12: testSetResize

import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void testSetResize() throws Exception {
  ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class));
  mWXImage.mHost = imageView;

  mWXImage.setResize("cover");
  ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType();
  assertEquals(scaleType, ImageView.ScaleType.CENTER_CROP);
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:10,代码来源:WXImageTest.java

示例13: testSetResizeMode

import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void testSetResizeMode() throws Exception {

  ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class));
  mWXImage.mHost = imageView;

  mWXImage.setResizeMode("cover");
  ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType();
  assertEquals(scaleType, ImageView.ScaleType.CENTER_CROP);

}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:12,代码来源:WXImageTest.java

示例14: startWithoutProperty

import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void startWithoutProperty()
{
    Intent intent = new Intent();
    final Bundle bundle = new Bundle();
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(PropertyOverviewActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    controller.visible();
    controller.resume();
    assertTrue(activity.isFinishing());

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNotNull(latestToast);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:19,代码来源:PropertyOverviewActivityTest.java

示例15: testSetImageBitmap

import org.robolectric.Robolectric; //导入依赖的package包/类
@Test
public void testSetImageBitmap(){
  ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class));
  imageView.setLayoutParams(new ViewGroup.LayoutParams(
      ViewGroup.LayoutParams.WRAP_CONTENT,
      ViewGroup.LayoutParams.WRAP_CONTENT));
  imageView.setImageBitmap(null);
  assertNull(imageView.getDrawable());

  imageView.setImageBitmap(Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565));
  assertNotNull(imageView.getDrawable());
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:13,代码来源:WXImageTest.java


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