/** * Test updateStatus * * @throws NoSuchFieldException * @throws IllegalArgumentException * @throws IllegalAccessException */ public void testCase01_updateStatus() throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException { Logger.d(TAG, "testCase01_updateStatus"); Field fieldmIsRead = Utils.getPrivateField(mReceivedChatMessage.getClass(), "mIsRead"); assertFalse(fieldmIsRead.getBoolean(mReceivedChatMessage)); mReceivedChatMessage.updateStatus(true); assertTrue(fieldmIsRead.getBoolean(mReceivedChatMessage)); }
/** * Test onAddChatWindow * * @throws IllegalArgumentException * @throws NoSuchFieldException * @throws IllegalAccessException */ public void testCase02_onAddChatWindow() throws IllegalArgumentException, NoSuchFieldException, IllegalAccessException { Logger.d(TAG, "testCase02_onAddChatWindow"); ConcurrentHashMap<IChatWindow, IChatWindowMessage> chatWindowMap = getChatWindowMapFiled(); chatWindowMap.clear(); mReceivedChatMessage.onAddChatWindow(null); assertTrue(chatWindowMap.size() == 0); mOneOneWindow.mShouldAddSentMessage = false; mReceivedChatMessage.onAddChatWindow(mOneOneWindow); assertTrue(chatWindowMap.size() == 0); mOneOneWindow.mShouldAddSentMessage = true; mReceivedChatMessage.onAddChatWindow(mOneOneWindow); assertTrue(chatWindowMap.containsKey(mOneOneWindow)); chatWindowMap.clear(); }
@SuppressWarnings("unchecked") private ConcurrentHashMap<IChatWindow, IChatWindowMessage> getChatWindowMapFiled() throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException { Field fieldmChatWindowMap = Utils.getPrivateField(mReceivedChatMessage.getClass().getSuperclass(), "mChatWindowMap"); return (ConcurrentHashMap<IChatWindow, IChatWindowMessage>) fieldmChatWindowMap.get(mReceivedChatMessage); }