コード例 #1
0
  @SuppressWarnings("unchecked")
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    appUtils = AndroidMock.createMock(AppUtils.class);
    context = AndroidMock.createMock(Activity.class);
    locationManager = AndroidMock.createMock(SocializeLocationManager.class, appUtils);
    locationListenerFactory = AndroidMock.createMock(IBeanFactory.class);
    listener = AndroidMock.createMock(SocializeLocationListener.class);
  }
  @SuppressWarnings("unchecked")
  @UsesMocks({
    SocializeProvider.class,
    SocializeSession.class,
    SocializeResponseFactory.class,
    SocializeEntityResponse.class,
    SocializeConfig.class,
    Properties.class,
    SocializeSessionConsumer.class
  })
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    signal = new CountDownLatch(1);
    provider = AndroidMock.createMock(SocializeProvider.class);
    responseFactory = AndroidMock.createMock(SocializeResponseFactory.class);
    mockEntityResponse = AndroidMock.createMock(SocializeEntityResponse.class);

    mockSessionConsumer = AndroidMock.createMock(SocializeSessionConsumer.class);

    api = new SocializeApi<SocializeObject, SocializeProvider<SocializeObject>>(provider);

    mockSession = AndroidMock.createMock(SocializeSession.class);

    AndroidMock.replay(mockSession);

    listener =
        new SocializeActionListener() {

          @Override
          public void onResult(RequestType type, SocializeResponse response) {
            System.out.println("Api listener onResult fired");
            signal.countDown();
          }

          @Override
          public void onError(SocializeException error) {
            System.out.println("Api listener onError fired");
            signal.countDown();
          }
        };
  }