更新
This commit is contained in:
@@ -45,7 +45,7 @@ class CapsuleWindowTest(TestCase):
|
||||
|
||||
widgets = (
|
||||
self.capsule.status_group,
|
||||
self.capsule.timer,
|
||||
self.capsule.progress,
|
||||
self.capsule.divider,
|
||||
self.capsule.stop_button,
|
||||
self.capsule.expand_button,
|
||||
@@ -90,6 +90,41 @@ class CapsuleWindowTest(TestCase):
|
||||
)
|
||||
self.assertLessEqual(timer_width, self.capsule.timer.contentsRect().width())
|
||||
|
||||
def test_the_timer_sits_directly_above_the_progress_line(self):
|
||||
# 缩成胶囊后只剩状态点和时长,看不出机器人此刻在忙什么
|
||||
timer_top = self.capsule.timer.mapTo(self.capsule.panel, QPoint(0, 0)).y()
|
||||
progress_top = self.capsule.progress.mapTo(self.capsule.panel, QPoint(0, 0)).y()
|
||||
self.assertLess(timer_top + self.capsule.timer.height(), progress_top + 1)
|
||||
|
||||
def test_the_progress_line_says_who_is_being_answered(self):
|
||||
self.capsule.set_progress("正在回复 高瑞@微信")
|
||||
self.app.processEvents()
|
||||
self.assertEqual(self.capsule.progress.text(), "正在回复 高瑞@微信")
|
||||
|
||||
def test_a_long_nickname_is_shortened_instead_of_overflowing(self):
|
||||
long_name = "正在回复 甄养堂医疗助理-盛灵莉客户服务专员@微信"
|
||||
self.capsule.set_progress(long_name)
|
||||
self.app.processEvents()
|
||||
shown = self.capsule.progress.text()
|
||||
self.assertNotEqual(shown, long_name)
|
||||
width = QFontMetrics(self.capsule.progress.font()).horizontalAdvance(shown)
|
||||
self.assertLessEqual(width, self.capsule.progress.width())
|
||||
# 省略之后还得能查到全名,否则不知道回的是谁
|
||||
self.assertEqual(self.capsule.progress.toolTip(), long_name)
|
||||
|
||||
def test_stopping_clears_a_stale_progress_line(self):
|
||||
# 停下来还挂着"正在回复 XXX"会让人以为它还在干活
|
||||
self.capsule.set_progress("正在回复 高瑞@微信")
|
||||
self.capsule.set_status("stopped", "已停止")
|
||||
self.app.processEvents()
|
||||
self.assertEqual(self.capsule.progress.text(), "")
|
||||
|
||||
def test_running_keeps_the_progress_line_alone(self):
|
||||
self.capsule.set_progress("正在读取 高瑞@微信 的消息")
|
||||
self.capsule.set_status("running", "监听中")
|
||||
self.app.processEvents()
|
||||
self.assertEqual(self.capsule.progress.text(), "正在读取 高瑞@微信 的消息")
|
||||
|
||||
def test_status_copy_and_actions_remain_connected(self):
|
||||
self.capsule.set_status("waiting", "等待企业微信")
|
||||
self.assertEqual(self.capsule.status.text(), "等待企业微信")
|
||||
|
||||
Reference in New Issue
Block a user