示例#1
0
 @Test
 public void testUpdateDataSet() throws IllegalAccessException, NoSuchFieldException {
   chatActivity.onResume();
   chatActivity.showMessage("test");
   assertTrue(recyclerView.hasPendingAdapterUpdates());
   chatActivity.updateDataSet();
   // assertFalse(recyclerView.hasPendingAdapterUpdates());
   chatActivity.onStop();
 }
示例#2
0
 @Test
 public void testShowDataList() throws IOException, NoSuchFieldException, IllegalAccessException {
   int before = adapter.getItemCount();
   chatActivity.showDataList(null);
   Field field = ChatRecyclerAdapter.class.getDeclaredField("mDataList");
   field.setAccessible(true);
   List<Data> dataList = (List<Data>) field.get(adapter);
   assertNull(dataList);
   chatActivity.showDataList(chat.getDataObjects());
   dataList = (List<Data>) field.get(adapter);
   assertTrue(dataList != null);
   int after = adapter.getItemCount();
   assertEquals(before, after);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    long[] pattern = {0, 100, 1000};
    v.vibrate(pattern, 0);

    fromUsername = intent.getStringExtra(HomeActivity.FROM_USERNAME);
    signaller = Signaller.incomingChatSignaller;
    signaller.setObserver(this);
    setContentView(R.layout.activity_incoming_call);
    Resources res = getResources();
    String text = String.format(res.getString(R.string.from_username_calling_text), fromUsername);
    TextView fromUsernameText = (TextView) findViewById(R.id.fromUsernameCallingText);
    fromUsernameText.setText(text);

    findViewById(R.id.acceptButton)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                findViewById(R.id.acceptButton).setEnabled(false);
                findViewById(R.id.declineButton).setEnabled(false);
                v.cancel();
                openChatDisplayActivity(fromUsername);
                answered = true;
                finish();
              }
            });

    findViewById(R.id.declineButton)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                findViewById(R.id.acceptButton).setEnabled(false);
                findViewById(R.id.declineButton).setEnabled(false);
                v.cancel();
                signaller.sendInitialChatAnswer(ChatStatus.DECLINED);
                answered = true;
                finish();
              }
            });

    Timer t = new Timer();
    t.schedule(
        new TimerTask() {
          @Override
          public void run() {
            if (!answered) {
              findViewById(R.id.acceptButton).setEnabled(false);
              findViewById(R.id.declineButton).setEnabled(false);
              v.cancel();
              signaller.sendInitialChatAnswer(ChatStatus.DECLINED);
              finish();
            }
          }
        },
        17500);
  }
示例#4
0
 @Test
 public void testShowMessageString() {
   int calculated = adapter.getItemCount() + 1;
   chatActivity.showMessage("Test that ***.");
   int after = adapter.getItemCount();
   assertEquals(calculated, after);
 }
示例#5
0
 @Test
 public void testShowMessageFile() throws IOException {
   int calculated = adapter.getItemCount() + 1;
   File file = File.createTempFile("Test that ***.", ".jpeg", context.getFilesDir());
   chatActivity.showMessage(file);
   int after = adapter.getItemCount();
   assertEquals(calculated, after);
 }
示例#6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    mGroupId = getIntent().getStringExtra(EXTRA_GROUPID);
    mGroupName = getIntent().getStringExtra(EXTRA_GROUPNAME);
    super.onCreate(savedInstanceState);
    //		if(!SCApplication.isIMConnectionSuccess()) {
    //			ToastManager.getInstance(getApplicationContext()).show("聊天服务器未连接");
    //			finish();
    //			return;
    //		}
  }
示例#7
0
  @Override
  protected void onInit() {
    super.onInit();

    DBReadMessageCountParam param =
        new DBReadMessageCountParam(HPMessage.FROMTYPE_CHATROOM, mGroupId);
    AndroidEventManager.getInstance().runEvent(new DBReadMessageCountEvent(0), param);
    mLastReadPosition = param.mReturnCount - 1;

    loadOnePage();

    mListView.setSelection(mMessageAdapter.getCount() - 1);
  }
 @Override
 public void onResume() {
   super.onResume();
   signaller.setObserver(this);
 }
示例#9
0
 @Override
 protected void onInitMessage(HPMessage m) {
   super.onInitMessage(m);
   m.setFromType(HPMessage.FROMTYPE_CHATROOM);
   m.setGroupId(mGroupId);
 }
示例#10
0
 @Override
 protected void onInitAttribute(BaseAttribute ba) {
   super.onInitAttribute(ba);
   ba.mTitleText = mGroupName == null ? "" : mGroupName;
 }
示例#11
0
 @Override
 protected void onInitChatAttribute(ChatAttribute attr) {
   super.onInitChatAttribute(attr);
   attr.mFromId = mGroupId;
 }
示例#12
0
 @Test
 public void testScrollDown() throws NoSuchFieldException, IllegalAccessException {
   assertTrue(recyclerView.getVerticalScrollbarPosition() == 0);
   chatActivity.scrollDown();
   assertTrue(recyclerView.getVerticalScrollbarPosition() == 0);
 }
示例#13
0
 @Test(expected = NullPointerException.class)
 public void testOnContextItemSelected() {
   chatActivity.onContextItemSelected(null);
 }