4
4
import os
5
5
import unittest
6
6
import logging
7
+ import time
7
8
import kaptan
8
9
from .. import Window , config , exc
9
10
from ..workspacebuilder import WorkspaceBuilder
@@ -24,7 +25,7 @@ class TwoPaneTest(TmuxTestCase):
24
25
- vim
25
26
start_directory: '~'
26
27
- shell_command:
27
- - cowsay "hey"
28
+ - echo "hey"
28
29
window_name: editor
29
30
- panes:
30
31
- shell_command:
@@ -70,9 +71,9 @@ class ThreePaneTest(TmuxTestCase):
70
71
- vim
71
72
start_directory: '~'
72
73
- shell_command:
73
- - cowsay "hey"
74
+ - echo "hey"
74
75
- shell_command:
75
- - cowsay "moo"
76
+ - echo "moo"
76
77
'''
77
78
78
79
def test_split_windows (self ):
@@ -112,9 +113,9 @@ class FocusAndPaneIndexTest(TmuxTestCase):
112
113
- vim
113
114
start_directory: '~'
114
115
- shell_command:
115
- - cowsay "hey"
116
+ - echo "hey"
116
117
- shell_command:
117
- - cowsay "moo"
118
+ - echo "moo"
118
119
- top
119
120
focus: true
120
121
- window_name: window 2
@@ -124,9 +125,9 @@ class FocusAndPaneIndexTest(TmuxTestCase):
124
125
start_directory: '~'
125
126
focus: true
126
127
- shell_command:
127
- - cowsay "hey"
128
+ - echo "hey"
128
129
- shell_command:
129
- - cowsay "moo"
130
+ - echo "moo"
130
131
131
132
'''
132
133
@@ -165,8 +166,6 @@ def test_split_windows(self):
165
166
166
167
class WindowOptions (TmuxTestCase ):
167
168
168
- '''sample config with no session name'''
169
-
170
169
yaml_config = '''
171
170
session_name: test window options
172
171
start_directory: '~'
@@ -179,9 +178,9 @@ class WindowOptions(TmuxTestCase):
179
178
- vim
180
179
start_directory: '~'
181
180
- shell_command:
182
- - cowsay "hey"
181
+ - echo "hey"
183
182
- shell_command:
184
- - cowsay "moo"
183
+ - echo "moo"
185
184
window_name: editor
186
185
'''
187
186
@@ -208,6 +207,69 @@ def test_window_options(self):
208
207
w .select_layout (wconf ['layout' ])
209
208
210
209
210
+ class WindowAutomaticRename (TmuxTestCase ):
211
+
212
+ yaml_config = '''
213
+ session_name: test window options
214
+ start_directory: '~'
215
+ windows:
216
+ - layout: main-horizontal
217
+ options:
218
+ automatic-rename: on
219
+ panes:
220
+ - shell_command:
221
+ - nano
222
+ start_directory: '~'
223
+ - shell_command:
224
+ - echo "hey"
225
+ - shell_command:
226
+ - echo "moo"
227
+ '''
228
+
229
+ def test_automatic_rename_option (self ):
230
+ """ with option automatic-rename: on. """
231
+ s = self .session
232
+ sconfig = kaptan .Kaptan (handler = 'yaml' )
233
+ sconfig = sconfig .import_config (self .yaml_config ).get ()
234
+
235
+ builder = WorkspaceBuilder (sconf = sconfig )
236
+
237
+ window_count = len (self .session ._windows ) # current window count
238
+ self .assertEqual (len (s ._windows ), window_count )
239
+ for w , wconf in builder .iter_create_windows (s ):
240
+
241
+ window_pane_count = len (w ._panes )
242
+ for p in builder .iter_create_panes (w , wconf ):
243
+ p = p
244
+ self .assertEqual (len (s ._windows ), window_count )
245
+ self .assertIsInstance (w , Window )
246
+ self .assertEqual (w .show_window_option ('automatic-rename' ), 'on' )
247
+
248
+ self .assertEqual (len (s ._windows ), window_count )
249
+
250
+ window_count += 1
251
+ w .select_layout (wconf ['layout' ])
252
+
253
+ w = s .attached_window ()
254
+
255
+ for i in range (5 ):
256
+ w = s .attached_window ()
257
+ if w ['window_name' ] == 'nano' :
258
+ break
259
+ time .sleep (.1 )
260
+
261
+ self .assertEqual (w .get ('window_name' ), 'nano' )
262
+
263
+ w .select_pane ('-D' )
264
+ for i in range (5 ):
265
+ w = s .attached_window ()
266
+ if w ['window_name' ] != 'nano' :
267
+ break
268
+ time .sleep (.1 )
269
+
270
+ self .assertNotEqual (w .get ('window_name' ), 'nano' )
271
+
272
+
211
273
class TestsToDo (object ):
212
274
213
275
def test_uses_first_window_if_exists (self ):
0 commit comments