fix: restore native conversation row text layout
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package com.hyzq.boss;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(sdk = 34)
|
||||
public class BossUiConversationRowTest {
|
||||
@Test
|
||||
public void conversationRow_keepsCenterTextsVisibleWhenMeasured() {
|
||||
Context context = RuntimeEnvironment.getApplication();
|
||||
WechatSurfaceMapper.ConversationRow row = new WechatSurfaceMapper.ConversationRow(
|
||||
"北区试产线回归",
|
||||
"归档确认",
|
||||
"现场摄像头关键帧",
|
||||
"09:26",
|
||||
0,
|
||||
"置顶",
|
||||
1,
|
||||
false,
|
||||
"M",
|
||||
"W",
|
||||
new WechatSurfaceMapper.GroupAvatarMember[0]
|
||||
);
|
||||
|
||||
LinearLayout card = BossUi.buildConversationRow(context, row, null);
|
||||
|
||||
int width = View.MeasureSpec.makeMeasureSpec(BossUi.dp(context, 320), View.MeasureSpec.EXACTLY);
|
||||
int height = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
|
||||
card.measure(width, height);
|
||||
card.layout(0, 0, card.getMeasuredWidth(), card.getMeasuredHeight());
|
||||
|
||||
LinearLayout centerColumn = (LinearLayout) card.getChildAt(1);
|
||||
LinearLayout trailingColumn = (LinearLayout) card.getChildAt(2);
|
||||
TextView titleView = (TextView) centerColumn.getChildAt(0);
|
||||
TextView previewView = (TextView) centerColumn.getChildAt(centerColumn.getChildCount() - 1);
|
||||
|
||||
String metrics = String.format(
|
||||
"card=%d center=%d trailing=%d title=%d preview=%d",
|
||||
card.getMeasuredWidth(),
|
||||
centerColumn.getMeasuredWidth(),
|
||||
trailingColumn.getMeasuredWidth(),
|
||||
titleView.getMeasuredWidth(),
|
||||
previewView.getMeasuredWidth()
|
||||
);
|
||||
assertTrue("中间文字列不应被挤成 0 宽: " + metrics, centerColumn.getMeasuredWidth() > 0);
|
||||
assertTrue("标题需要保留可见宽度: " + metrics, titleView.getMeasuredWidth() > 0);
|
||||
assertTrue("预览需要保留可见宽度: " + metrics, previewView.getMeasuredWidth() > 0);
|
||||
assertTrue("右侧信息列不应吞掉中间内容: " + metrics, trailingColumn.getMeasuredWidth() < card.getMeasuredWidth() / 2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user