-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_field_changes_display.py
More file actions
69 lines (54 loc) · 2.57 KB
/
Copy pathtest_field_changes_display.py
File metadata and controls
69 lines (54 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
测试历史记录差异对话框的字段变更显示功能
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from PySide6.QtWidgets import QApplication
from app.history.history_diff_dialog import HistoryDiffDialog
def test_field_changes_display():
"""测试字段变更显示功能"""
print("🚀 启动字段变更显示功能测试...")
app = QApplication(sys.argv)
# 测试内容变更(无字段变更)
print("\n=== 测试内容变更(无字段变更) ===")
current_content = "# 当前文档\n\n这是当前文档的内容。"
history_content = "# 历史文档\n\n这是历史文档的内容。"
field_changes = {}
dialog1 = HistoryDiffDialog(current_content, history_content, "content_update", field_changes)
print("✅ 内容变更对话框创建成功")
# 测试标题变更(有字段变更)
print("\n=== 测试标题变更(有字段变更) ===")
current_title = "当前文档标题"
history_title = "历史文档标题"
field_changes = {
'title': {'old': '当前文档标题', 'new': '历史文档标题'}
}
dialog2 = HistoryDiffDialog(current_title, history_title, "title_update", field_changes)
print("✅ 标题变更对话框创建成功")
# 测试显示名称变更(有字段变更)
print("\n=== 测试显示名称变更(有字段变更) ===")
current_display_name = "当前显示名称"
history_display_name = "历史显示名称"
field_changes = {
'display_name': {'old': '当前显示名称', 'new': '历史显示名称'}
}
dialog3 = HistoryDiffDialog(current_display_name, history_display_name, "display_name_update", field_changes)
print("✅ 显示名称变更对话框创建成功")
# 测试图标变更(有多个字段变更)
print("\n=== 测试图标变更(有多个字段变更) ===")
current_content = "# 文档\n\n文档内容。"
history_content = "# 文档\n\n文档内容。"
field_changes = {
'icon_type': {'old': 'file', 'new': 'folder'},
'icon_color': {'old': '#000000', 'new': '#FF0000'}
}
dialog4 = HistoryDiffDialog(current_content, history_content, "icon_update", field_changes)
print("✅ 图标变更对话框创建成功")
print("\n✅ 字段变更显示功能测试完成")
print("所有测试通过,字段变更显示功能正常工作")
return True
if __name__ == "__main__":
test_field_changes_display()