@Test
  public void Thirty_Love_after_player1_scores_twice() {
    player1Score.performClick();
    player1Score.performClick();

    assertEquals("Thirty Love", scoreView.getText().toString());
  }
Ejemplo n.º 2
0
  /** This test simulates a user submitting an empty form during registration. */
  @MediumTest
  public void testAttemptRegister_Fail() {
    Fragment currentFragment;

    // create a fake email in the sharedPreference, which
    // should be created in LoginActivity
    Utils.putPreference(getActivity(), Utils.PREFS_ACCOUNT_KEY, randomString(10) + "@anytaxi.hk");

    // create a new registration form
    currentFragment = rFragmentManager.findFragmentById(R.id.register_fragment_container);

    displayFragment(currentFragment, new Register_FormFragment(), true);

    EditText rField_FirstName = (EditText) getActivity().findViewById(R.id.register_first_name);
    EditText rField_LastName = (EditText) getActivity().findViewById(R.id.register_last_name);
    EditText rField_Phone = (EditText) getActivity().findViewById(R.id.register_phone);

    Button rConfirmBtn = (Button) getActivity().findViewById(R.id.register_confirm_btn);

    // simulate a user submitting the form with empty inputs
    rConfirmBtn.performClick();

    // errors should have been set for all fields
    assertNotNull("No error is shown in First Name.", rField_FirstName.getError());
    assertNotNull("No error is shown in Last Name.", rField_LastName.getError());
    assertNotNull("No error is shown in Phone.", rField_Phone.getError());

    // no other activity will start
    assertNull("A unintended activity has been started.", getStartedActivityIntent());
  }
Ejemplo n.º 3
0
 /**
  * on bottom loading, you can call it by manual, but you should manual call onBottomComplete at
  * the same time.
  */
 public void onBottom() {
   if (isOnBottomStyle && !isOnBottomLoading) {
     isOnBottomLoading = true;
     onBottomBegin();
     footerButton.performClick();
   }
 }
 @Override
 public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
   if (actionId == EditorInfo.IME_ACTION_DONE) {
     mOkButton.performClick();
     return true;
   }
   return false;
 }
Ejemplo n.º 5
0
  // Reaction to the menu selection
  @Override
  public boolean onMenuItemSelected(int featureId, MenuItem item) {
    //        Intent i;
    mItem = item.getItemId();
    openCode = mItem;
    //        fileRegExp=".*";

    fileRequest = item.getItemId();
    switch (item.getItemId()) {
      case mNewDB:
        i = new Intent(this, getText.class);
        startActivityForResult(i, mNewDB);
        //			getDBname();
        return true;
      case mCopy:
        fileName = CreateShopDatabase.DATABASE_NAME;
        confirmButton.performClick();

        //                i = new Intent(this, getText.class);
        //                startActivityForResult(i, mCopy);

        //			getDBname();
      case mXMLImp:
        confirmButton.setVisibility(View.VISIBLE);
        fileRequest = item.getItemId();
        //                fileRegExp=".*";

        fileRegExp = "(?i)hs2_.*\\.xml";
        //                fileRegExp="hs2.*\\.xml";
        getDir(sdcard, "(?i)hs2_.*\\.xml");
        //                getDir(sdcard, "hs2.*\\.xml");
        //                getDir(sdcard, ".*");

        //                i = new Intent(this, getText.class);
        //                startActivityForResult(i, mXMLImp);

        return true;
      case mExport:
        fileRegExp = ".*";
        getDir(sdcard, "/");
        confirmButton.setVisibility(View.VISIBLE);
        /*
                        fileRequest = item.getItemId();
                        fileName=nameDialog("Export to:","")
                        i = new Intent(this, getText.class);
        */
        //                startActivityForResult(i, mExport);

        // context.deleteDatabase(DATABASE_NAME);
        // http://stackoverflow.com/questions/4406067/how-to-delete-sqlite-database-from-android-programmatically
        return true;

      case mQuit:
        return true;
    }
    return super.onMenuItemSelected(featureId, item);
  }
 @Test
 public void shouldThrowUnauthorizedErrorForInvalidUsernameAndPassword() throws IOException {
   Robolectric.getFakeHttpLayer().setDefaultHttpResponse(401, "some response body");
   loginButton.performClick();
   ShadowHandler.idleMainLooper();
   assertThat(
       ShadowToast.getTextOfLatestToast(),
       equalTo(loginActivity.getString(R.string.unauthorized)));
 }
  @Test
  public void should_clean_login_and_password_content_when_reset_button_clicked() {
    LoginActivityPresenter presenter = mock(LoginActivityPresenter.class);
    loginActivity.setListeners(null, presenter);

    resetButton.performClick();

    verify(presenter).reset();
  }
Ejemplo n.º 8
0
 @Override
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case 2:
       cutscreen.performClick();
       break;
   }
   super.handleMessage(msg);
 }
Ejemplo n.º 9
0
  @Test
  public void login() {
    assertTrue(AppUtils.isFirstRun(loginActivity));
    Button loginButton = (Button) loginActivity.findViewById(R.id.login_button);
    assertNotNull(loginButton);

    loginButton.performClick();
    assertNextActivity(loginActivity, OAuthActivity.class);
    assertFalse(AppUtils.isFirstRun(loginActivity));
  }
  @Test
  public void should_show_status_text_when_login_button_clicked_but_failed() {
    LoginActivityPresenter presenter = mock(LoginActivityPresenter.class);
    UserProfile userProfile = mock(UserProfile.class);
    loginActivity.setListeners(userProfile, presenter);

    loginButton.performClick();

    verify(presenter).login(eq(userProfile));
  }
  @Test
  public void shouldLoginSuccessfullyForValidUserAndUrl() {
    Robolectric.getFakeHttpLayer().setDefaultHttpResponse(201, "some response body");

    loginButton.performClick();
    ShadowHandler.idleMainLooper();
    assertThat(
        ShadowToast.getTextOfLatestToast(),
        equalTo(loginActivity.getString(R.string.login_successful)));
  }
 @Test
 public void shouldThrowConnectionRefusedIfServerIsNotAvailable() throws IOException {
   serverUrl.setText("rapidftr.com:abcd");
   Robolectric.getFakeHttpLayer().setDefaultHttpResponse(404, "some response body");
   loginButton.performClick();
   ShadowHandler.idleMainLooper();
   assertThat(
       ShadowToast.getTextOfLatestToast(),
       equalTo(loginActivity.getString(R.string.server_not_reachable)));
 }
Ejemplo n.º 13
0
  @Test
  public void testButtonAction() {
    Button button = (Button) activity.findViewById(R.id.button);
    assertEquals(button.getVisibility(), View.VISIBLE);
    assertNotNull("button is null", button);
    button.performClick();

    textView = (TextView) activity.findViewById(R.id.section_label);
    assertEquals(textView.getVisibility(), View.VISIBLE);
    assertEquals("Fragment 3", textView.getText().toString());
  }
Ejemplo n.º 14
0
  /** Associate the "done" button on the soft keyboard with the okay button in the view */
  @Override
  public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (EditorInfo.IME_ACTION_DONE == actionId) {
      AlertDialog dialog = ((AlertDialog) getDialog());
      Button bt = dialog.getButton(AlertDialog.BUTTON_POSITIVE);

      bt.performClick();
      return true;
    }
    return false;
  }
  /** Test that the register button when no password */
  @MediumTest
  public void testIncorrectDetails2() {
    username.setText("test456778900");
    password.setText("");
    final Button launchLoginButton = (Button) getActivity().findViewById(R.id.email_sign_in_button);
    launchLoginButton.performClick();

    final Intent launchIntent = getStartedActivityIntent();
    assertNull("Intent was not null", launchIntent);
    // assertFalse("Wrong Activity Launched",
    // launchIntent.resolveActivity(getInstrumentation().getTargetContext().getPackageManager()).getClassName().equals(MainActivity.class.getCanonicalName()));
  }
Ejemplo n.º 16
0
 @Override
 public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
   if (mFilterExpand.isOpen()) {
     mFilter.performClick();
     return true;
   } else {
     if (keyCode == KeyEvent.KEYCODE_BACK) {
       finish();
     }
     return super.onKeyDown(keyCode, event);
   }
 };
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
      // Associate the "done" button on the soft keyboard with the okay button in the view
      if (EditorInfo.IME_ACTION_DONE == actionId) {
        AlertDialog dialog = ((AlertDialog) getDialog());
        Button bt = dialog.getButton(AlertDialog.BUTTON_POSITIVE);

        bt.performClick();
        return true;
      }
      return false;
    }
Ejemplo n.º 18
0
 @Override
 public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
   if (mDialog != null) {
     Button button = mDialog.getButton(DialogInterface.BUTTON_POSITIVE);
     if (button != null) {
       button.performClick();
     }
     return true;
   } else {
     return false;
   }
 }
Ejemplo n.º 19
0
  private void initView() {
    conversationBtn = (Button) findViewById(R.id.btn_message);
    contactBtn = (Button) findViewById(R.id.btn_contact);
    discoverBtn = (Button) findViewById(R.id.btn_discover);
    mySpaceBtn = (Button) findViewById(R.id.btn_my_space);
    mFragmentContainer = findViewById(R.id.fragment_container);
    mRecentTips = findViewById(R.id.iv_recent_tips);
    mContactTips = findViewById(R.id.iv_contact_tips);

    mTabs = new Button[] {conversationBtn, contactBtn, discoverBtn, mySpaceBtn};

    conversationBtn.performClick();
  }
  @Test
  public void shouldSaveServerUrlAfterSuccessfulLogin() {
    SharedPreferences sharedPreferences =
        Robolectric.application.getSharedPreferences("RAPIDFTR_PREFERENCES", Context.MODE_PRIVATE);
    sharedPreferences.edit().putString("SERVER_URL", "").commit();

    serverUrl.setText("http://dev.rapidftr.com:3000");
    Robolectric.getFakeHttpLayer().setDefaultHttpResponse(201, "some response body");

    loginButton.performClick();
    assertThat(
        sharedPreferences.getString("SERVER_URL", ""), equalTo(serverUrl.getText().toString()));
  }
  @Test
  public void shouldPutRandomNumberInAmountAfterButtonClick() {
    // given
    double value = 100.0;
    given(randomAmount.getAmount()).willReturn(value);
    Button button = ButterKnife.findById(fragment.getView(), R.id.random);

    // when
    button.performClick();

    // then
    EditText amount = ButterKnife.findById(fragment.getView(), R.id.amount);
    ANDROID.assertThat(amount).hasTextString(String.valueOf(value));
  }
Ejemplo n.º 22
0
 @Override
 protected void onEnter() {
   if (rSingle.isChecked()) {
     if (FunText.isFocused()) {
       aXText.requestFocus();
     } else if (aXText.isFocused()) {
       bXText.requestFocus();
     } else if (bXText.isFocused()) {
       button.performClick();
     }
   } else {
     if (FunText.isFocused()) {
       aXText.requestFocus();
     } else if (aXText.isFocused()) {
       bXText.requestFocus();
     } else if (bXText.isFocused()) {
       aYText.requestFocus();
     } else if (aYText.isFocused()) {
       bYText.requestFocus();
     } else if (bYText.isFocused()) {
       button.performClick();
     }
   }
 }
Ejemplo n.º 23
0
  /** Creates the view, sets up the layout. */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_categories);

    changed = false;
    press = false;
    intentGlob = getIntent();
    if (intentGlob != null) {
      Bundle extras = intentGlob.getExtras();
      if (extras != null) {
        press = extras.getBoolean("FROMDIALOG", false);
      }
    }

    lastClicked = 0;

    sp = PreferenceManager.getDefaultSharedPreferences(this);
    edit = sp.edit();

    chFont = Typeface.createFromAsset(this.getAssets(), getString(R.string.exo2));
    chFontBold = Typeface.createFromAsset(this.getAssets(), getString(R.string.exo2Bold));

    catLabel = (TextView) findViewById(R.id.catLabel2);
    catLabel.setTypeface(chFontBold);
    addNewCat = (Button) findViewById(R.id.addCatBtn);
    addNewCat.setTypeface(chFont);
    addNewCat.setOnClickListener(this);

    lv = (ListView) findViewById(android.R.id.list);
    lv.setOnItemClickListener(this);

    datasource = new DataSource(this);
    datasource.open();

    values = datasource.getAllCategories();
    Collections.reverse(values); // to show latest added categories first

    exps = datasource.getAllExpenses();

    adapter = new CustomListAdapter(this, R.layout.cust_list_cats, values, chFont);
    setListAdapter(adapter);

    if (press) {
      addNewCat.performClick(); // bring up dialog
    }
  }
Ejemplo n.º 24
0
  private void initProperties() {
    Log.d(TAG1, "===>>initProperties");
    mDataMultiple.clear();
    mDataPriceDec.clear();
    mDataPriceInc.clear();
    mDataSale.clear();

    curPage = 1;
    curPageNew = 1;
    curPageSale = 1;
    curPagePriceDec = 1;
    curPagePriceInc = 1;
    priceOrd = -1;
    isLoadFirst = true;
    isChangeOrd = false;
    btn_multiple.performClick();
  }
  /** Test that the login button opens the main activity on correct input */
  @MediumTest
  public void testCorrectDetails() {
    // startActivity(mLaunchIntent, null, null);
    username.setText("test");
    password.setText("test");
    final Button launchLoginButton = (Button) getActivity().findViewById(R.id.email_sign_in_button);
    launchLoginButton.performClick();

    final Intent launchIntent = getStartedActivityIntent();
    assertNotNull("Intent was null", launchIntent);
    assertTrue(
        "Wrong Activity Launched",
        launchIntent
            .resolveActivity(getInstrumentation().getTargetContext().getPackageManager())
            .getClassName()
            .equals(MainActivity.class.getCanonicalName()));
    assertTrue("user incorrect", User.getUser().getUsername().equals("test"));
  }
Ejemplo n.º 26
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_product_list);
    init();
    findviews();
    initDatas();

    btn_multiple.performClick();

    view_back.setOnClickListener(new BtnOnClick());
    btn_multiple.setOnClickListener(new BtnOnClick());
    btn_sale.setOnClickListener(new BtnOnClick());
    ll_price.setOnClickListener(new BtnOnClick());
    btn_filter.setOnClickListener(new BtnOnClick());
    right_menu_btn.setOnClickListener(new BtnOnClick());

    searchProduct();
  }
Ejemplo n.º 27
0
  /** This test simulates a user submitting a valid form during registration. */
  @MediumTest
  public void testAttemptRegister_Succeed() throws Exception {
    Fragment currentFragment;

    // create a fake email in the sharedPreference, which
    // should be created in LoginActivity
    Utils.putPreference(getActivity(), Utils.PREFS_ACCOUNT_KEY, randomString(10) + "@anytaxi.hk");

    // create a new registration form
    currentFragment = rFragmentManager.findFragmentById(R.id.register_fragment_container);

    displayFragment(currentFragment, new Register_FormFragment(), true);

    EditText rField_FirstName = (EditText) getActivity().findViewById(R.id.register_first_name);
    EditText rField_LastName = (EditText) getActivity().findViewById(R.id.register_last_name);
    EditText rField_Phone = (EditText) getActivity().findViewById(R.id.register_phone);

    Button rConfirmBtn = (Button) getActivity().findViewById(R.id.register_confirm_btn);

    // create valid inputs for the fields
    rField_FirstName.setText("Valid");
    rField_LastName.setText("Test");
    rField_Phone.setText("69999999");

    // simulate a user submitting the form with empty inputs
    rConfirmBtn.performClick();

    // errors should have been set for all fields
    assertNull("Unexpected error is shown in First Name.", rField_FirstName.getError());
    assertNull("Unexpected error is shown in Last Name.", rField_LastName.getError());
    assertNull("Unexpected error is shown in Phone.", rField_Phone.getError());

    // ensure to have Internet connection
    assertTrue("No internet connection.", Utils.isOnline(getActivity()));
    Thread.sleep(5000);

    // RequestActivity should be started
    final Intent redirect = getStartedActivityIntent();
    assertNotNull("No activity is started.", redirect);
    assertEquals(redirect.getComponent().getShortClassName(), ".RequestActivity");
  }
 private void performClick(final Button button) {
   if (!cbAllDay.isChecked()) {
     button.performClick();
   }
 }
Ejemplo n.º 29
0
 protected void performButtonClick() {
   mEndButton.performClick();
 }
 public void click() {
   assertThat(button.performClick()).isTrue();
 }