Пример #1
0
  @Override
  protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    uiHelper.onSaveInstanceState(outState);

    outState.putString(PENDING_ACTION_BUNDLE_KEY, pendingAction.name());
  }
Пример #2
0
  @Test
  public void verify_properties_displayed_in_json_per_installing_plugin() throws Exception {
    when(pluginDownloader.getDownloadedPlugins()).thenReturn(of(gitPluginInfo()));
    UpdateCenter updateCenter = mock(UpdateCenter.class);
    when(updateCenterMatrixFactory.getUpdateCenter(false)).thenReturn(Optional.of(updateCenter));
    when(updateCenter.findAllCompatiblePlugins())
        .thenReturn(Arrays.asList(new Plugin("scmgit").setCategory("cat_1")));

    underTest.handle(request, response);

    assertJson(response.outputAsString())
        .isSimilarTo(
            "{"
                + "  \"installing\": "
                + "  ["
                + "    {"
                + "      \"key\": \"scmgit\","
                + "      \"name\": \"Git\","
                + "      \"description\": \"Git SCM Provider.\","
                + "      \"version\": \"1.0\","
                + "      \"license\": \"GNU LGPL 3\","
                + "      \"category\":\"cat_1\","
                + "      \"organizationName\": \"SonarSource\","
                + "      \"organizationUrl\": \"http://www.sonarsource.com\","
                + "      \"homepageUrl\": \"http://redirect.sonarsource.com/plugins/scmgit.html\","
                + "      \"issueTrackerUrl\": \"http://jira.sonarsource.com/browse/SONARSCGIT\","
                + "      \"implementationBuild\": \"9ce9d330c313c296fab051317cc5ad4b26319e07\""
                + "    }"
                + "  ],"
                + "  \"removing\": []"
                + "}");
  }
Пример #3
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   // TODO Auto-generated method stub
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_login);
   uiHelper = new UiLifecycleHelper(this, callback);
   uiHelper.onCreate(savedInstanceState);
   if (savedInstanceState != null) {
     String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY);
     pendingAction = PendingAction.valueOf(name);
   }
   loginButton = (LoginButton) findViewById(R.id.login_button);
   loginButton.setReadPermissions(
       Arrays.asList("public_profile", "email", "user_likes", "user_status"));
   loginButton.setUserInfoChangedCallback(
       new LoginButton.UserInfoChangedCallback() {
         @Override
         public void onUserInfoFetched(GraphUser user) {
           LoginActivity.this.user = user;
           updateUI();
           // It's possible that we were waiting for this.user to
           // be populated in order to post a
           // status update.
           handlePendingAction();
         }
       });
   init();
 }
Пример #4
0
  @Test
  public void removing_plugins_are_sorted_and_unique() throws Exception {
    when(serverPluginRepository.getUninstalledPlugins())
        .thenReturn(
            of(
                newPluginInfo(0).setName("Foo"),
                newPluginInfo(3).setName("Bar"),
                newPluginInfo(2).setName("Bar")));

    underTest.handle(request, response);

    assertJson(response.outputAsString())
        .withStrictArrayOrder()
        .isSimilarTo(
            "{"
                + "  \"installing\": [],"
                + "  \"removing\": "
                + "  ["
                + "    {"
                + "      \"key\": \"key2\","
                + "      \"name\": \"Bar\","
                + "    },"
                + "    {"
                + "      \"key\": \"key3\","
                + "      \"name\": \"Bar\","
                + "    },"
                + "    {"
                + "      \"key\": \"key0\","
                + "      \"name\": \"Foo\","
                + "    }"
                + "  ]"
                + "}");
  }
Пример #5
0
  @Test
  public void verify_properties_displayed_in_json_per_removing_plugin() throws Exception {
    when(serverPluginRepository.getUninstalledPlugins()).thenReturn(of(gitPluginInfo()));

    underTest.handle(request, response);

    assertJson(response.outputAsString())
        .isSimilarTo(
            "{"
                + "  \"installing\": [],"
                + "  \"removing\": "
                + "  ["
                + "    {"
                + "      \"key\": \"scmgit\","
                + "      \"name\": \"Git\","
                + "      \"description\": \"Git SCM Provider.\","
                + "      \"version\": \"1.0\","
                + "      \"license\": \"GNU LGPL 3\","
                + "      \"organizationName\": \"SonarSource\","
                + "      \"organizationUrl\": \"http://www.sonarsource.com\","
                + "      \"homepageUrl\": \"http://redirect.sonarsource.com/plugins/scmgit.html\","
                + "      \"issueTrackerUrl\": \"http://jira.sonarsource.com/browse/SONARSCGIT\","
                + "      \"implementationBuild\": \"9ce9d330c313c296fab051317cc5ad4b26319e07\""
                + "    }"
                + "  ]"
                + "}");
  }
Пример #6
0
  @Test
  public void empty_arrays_are_returned_when_there_nothing_pending() throws Exception {
    underTest.handle(request, response);

    assertJson(response.outputAsString())
        .withStrictArrayOrder()
        .isSimilarTo("{" + "  \"installing\": []," + "  \"removing\": []" + "}");
  }
Пример #7
0
  @Test
  public void empty_arrays_are_returned_when_update_center_is_unavailable() throws Exception {
    when(updateCenterMatrixFactory.getUpdateCenter(false))
        .thenReturn(Optional.<UpdateCenter>absent());

    underTest.handle(request, response);

    assertJson(response.outputAsString())
        .withStrictArrayOrder()
        .isSimilarTo("{" + "  \"installing\": []," + "  \"removing\": []" + "}");
  }
Пример #8
0
  @Test
  public void action_pending_is_defined() {
    WsTester wsTester = new WsTester();
    WebService.NewController newController =
        wsTester.context().createController(DUMMY_CONTROLLER_KEY);

    underTest.define(newController);
    newController.done();

    WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY);
    assertThat(controller.actions()).extracting("key").containsExactly("pending");

    WebService.Action action = controller.actions().iterator().next();
    assertThat(action.isPost()).isFalse();
    assertThat(action.description()).isNotEmpty();
    assertThat(action.responseExample()).isNotNull();
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
      String name = savedInstanceState.getString(PENDING_ACTION_KEY);
      mPendingAcction = PendingAction.valueOf(name);
    }
    View view = inflater.inflate(R.layout.post_image, container);
    imgImage = (ImageView) view.findViewById(R.id.imgToPost);
    txtMessage = (EditText) view.findViewById(R.id.txtMessage);
    btnPost = (Button) view.findViewById(R.id.btnPost);
    btnPost.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            performPublish(PendingAction.POST_PHOTO, true);
          }
        });
    btnCancel = (Button) view.findViewById(R.id.btnCancel);
    btnCancel.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View view) {
            PostToFacebookFrgamentDialog.this.dismiss();
          }
        });

    mProgressBar = (ProgressBar) view.findViewById(R.id.progressBar);

    Bitmap bmp = getArguments().getParcelable("snapshot");
    if (bmp != null) {
      imgImage.setImageBitmap(bmp);
    }

    return view;
  }
Пример #10
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
      String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY);
      pendingAction = PendingAction.valueOf(name);
    }

    setContentView(R.layout.new_login);

    loginButton = (LoginButton) findViewById(R.id.login_button);
    loginButton.setUserInfoChangedCallback(
        new LoginButton.UserInfoChangedCallback() {
          public void onUserInfoFetched(GraphUser user) {
            NewLogin.this.user = user;
            updateUI();
            // It's possible that we were waiting for this.user to be populated in order to post a
            // status update.
            handlePendingAction();
          }
        });
    profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture);
    greeting = (TextView) findViewById(R.id.greeting);

    postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton);
    postStatusUpdateButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            onClickPostStatusUpdate();
          }
        });

    postPhotoButton = (Button) findViewById(R.id.postPhotoButton);
    postPhotoButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            onClickPostPhoto();
          }
        });

    pickFriendsButton = (Button) findViewById(R.id.pickFriendsButton);
    pickFriendsButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            onClickPickFriends();
          }
        });

    pickPlaceButton = (Button) findViewById(R.id.pickPlaceButton);
    pickPlaceButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            onClickPickPlace();
          }
        });
    controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container);

    final FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);
    if (fragment != null) {
      // If we're being re-created and have a fragment, we need to a) hide the main UI controls and
      // b) hook up its listeners again.
      controlsContainer.setVisibility(View.GONE);
    }

    // Listen for changes in the back stack so we know if a fragment got popped off because the user
    // clicked the back button.
    fm.addOnBackStackChangedListener(
        new FragmentManager.OnBackStackChangedListener() {
          public void onBackStackChanged() {
            if (fm.getBackStackEntryCount() == 0) {
              // We need to re-show our UI.
              controlsContainer.setVisibility(View.VISIBLE);
            }
          }
        });
  }
 @Override
 public void onSaveInstanceState(Bundle state) {
   super.onSaveInstanceState(state);
   state.putString(PENDING_ACTION_KEY, mPendingAcction.name());
 }