MCPcopy Create free account
hub / github.com/blender/blender / text_editor_edit_mode_mix

Function text_editor_edit_mode_mix

tests/python/ui_simulate/test_undo.py:123–194  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

121
122
123def text_editor_edit_mode_mix():
124 # Ensure text edits and mesh edits can co-exist properly (see: T66658).
125 e, t, window = ui.test_window()
126
127 import bpy
128 yield from _text_editor_and_3dview_startup(e, window)
129 text = bpy.data.texts[0]
130
131 pos_text = ui.get_area_center_from_spacetype(window, 'TEXT_EDITOR')
132 pos_v3d = ui.get_area_center_from_spacetype(window, 'VIEW_3D')
133
134 # View 3D: edit-mode
135 e.cursor_position_set(*pos_v3d, move=True)
136 yield from ui.call_menu(e, "Add -> Mesh -> Cube")
137
138 yield e.numpad_period() # View all.
139 yield e.tab() # Edit mode.
140 yield e.a() # Select all.
141
142 # Text: add text 'AA'.
143 e.cursor_position_set(*pos_text, move=True)
144 yield e.text("AA")
145 t.assertEqual(text.as_string(), "AA")
146
147 # View 3D: duplicate & move.
148 e.cursor_position_set(*pos_v3d, move=True)
149 yield e.shift.d().x().text("3").ret()
150 yield e.g().z().text("1").ret()
151 t.assertEqual(len(_bmesh_from_object(window.view_layer.objects.active).verts), 8 * 2)
152 e.home()
153
154 # Text: add text 'BB'
155 e.cursor_position_set(*pos_text, move=True)
156 yield e.text("BB")
157 t.assertEqual(text.as_string(), "AABB")
158
159 # View 3D: duplicate & move.
160 e.cursor_position_set(*pos_v3d, move=True)
161 yield e.shift.d().x().text("3").ret()
162 yield e.g().z().text("1").ret()
163 e.home()
164 t.assertEqual(len(_bmesh_from_object(window.view_layer.objects.active).verts), 8 * 3)
165
166 # Text: add text 'CC'
167 e.cursor_position_set(*pos_text, move=True)
168 yield e.text("CC")
169 t.assertEqual(text.as_string(), "AABBCC")
170
171 # View 3D: duplicate & move.
172 e.cursor_position_set(*pos_v3d, move=True)
173 yield e.shift.d().x().text("3").ret()
174 yield e.g().z().text("1").ret()
175 e.home()
176 t.assertEqual(len(_bmesh_from_object(window.view_layer.objects.active).verts), 8 * 4)
177
178 # Undo and check the state is valid.
179 yield e.ctrl.z(4)
180 t.assertEqual(len(_bmesh_from_object(window.view_layer.objects.active).verts), 8 * 3)

Callers

nothing calls this directly

Calls 7

_bmesh_from_objectFunction · 0.85
cursor_position_setMethod · 0.80
textMethod · 0.80
lenFunction · 0.50
xMethod · 0.45
zMethod · 0.45

Tested by

no test coverage detected