public void testProfileActivityLoadsCorrectData() throws Throwable {

    TestUtils.setupSocializeOverrides(true, true);
    Instrumentation.ActivityMonitor monitor =
        TestUtils.setUpActivityMonitor(this, ProfileActivity.class);

    final User dummy = new User();

    dummy.setId(69L);
    dummy.setFirstName("foo");
    dummy.setLastName("bar");

    SocializeUserUtils userUtils =
        new SocializeUserUtils() {
          @Override
          public void getUser(Context context, long id, UserGetListener listener) {
            listener.onGet(dummy);
          }

          @Override
          public User getCurrentUser(Context context) {
            return dummy;
          }
        };

    SocializeAccess.setUserUtilsProxy(userUtils);

    // Ensure facebook is enabled
    ConfigUtils.getConfig(getContext()).setFacebookAppId("1234567890");
    ConfigUtils.getConfig(getContext())
        .setTwitterKeySecret(
            "U18LUnVjULkkpGoJ6CoP3A", "RiIljnFq4RWV9LEaCM1ZLsAHf053vX2KyhJhmCOlBE");

    UserUtils.showUserSettings(TestUtils.getActivity(this));

    Activity waitForActivity = monitor.waitForActivityWithTimeout(5000);

    assertNotNull(waitForActivity);

    // Check that the user's name is displayed
    assertTrue(TestUtils.lookForText(waitForActivity, "foo", 10000));
    assertTrue(TestUtils.lookForText(waitForActivity, "bar", 10000));

    waitForActivity.finish();
  }
  public void testOnActionBarShareEventListenerIsCalledOnDialogDisplay() throws Throwable {

    Activity activity = TestUtils.getActivity(this);

    ConfigUtils.getConfig(activity).setProperty(SocializeConfig.FACEBOOK_APP_ID, "");
    ConfigUtils.getConfig(activity).setProperty(SocializeConfig.TWITTER_CONSUMER_KEY, "");
    ConfigUtils.getConfig(activity).setProperty(SocializeConfig.TWITTER_CONSUMER_SECRET, "");
    ConfigUtils.getConfig(activity).setProperty(SocializeConfig.SOCIALIZE_REQUIRE_AUTH, "false");

    ShareUtils.preloadShareDialog(TestUtils.getActivity(this));
    ShareUtils.preloadLinkDialog(TestUtils.getActivity(this));

    final ActionBarView actionBar = TestUtils.findView(activity, ActionBarView.class, 5000);
    final ActionBarLayoutView actionBarView =
        TestUtils.findView(activity, ActionBarLayoutView.class, 10000);

    assertNotNull(actionBar);

    final Like like = new Like();

    like.setId(-1L);
    like.setEntity(entity);

    final CountDownLatch shareLatch = new CountDownLatch(1);
    final CountDownLatch dialogLatch = new CountDownLatch(1);

    final SocializeLikeUtils mockLikeUtils =
        new SocializeLikeUtils() {
          @Override
          public void getLike(Activity context, String entityKey, LikeGetListener listener) {
            listener.onGet(like);
          }
        };

    actionBar.setOnActionBarEventListener(
        new OnActionBarShareEventListener() {

          @Override
          public void onShow(Dialog dialog, SharePanelView dialogView) {
            TestUtils.addResult(dialogView);
            dialogLatch.countDown();
          }
        });

    SocializeAccess.setLikeUtilsProxy(mockLikeUtils);

    // Simulate share

    this.runTestOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            assertTrue(actionBarView.getShareButton().performClick());
            shareLatch.countDown();
          }
        });

    assertTrue(shareLatch.await(5, TimeUnit.SECONDS));
    dialogLatch.await(90, TimeUnit.SECONDS);

    SharePanelView dialogView = TestUtils.getResult(0);

    assertNotNull(dialogView);
  }