NeoMutt  2020-06-26-30-g76c339
Teaching an old dog new tricks
DOXYGEN
reflow.c File Reference

Test code for window_reflow() More...

#include "config.h"
#include "acutest.h"
#include <stdint.h>
#include "mutt/lib.h"
#include "gui/mutt_window.h"
#include "gui/reflow.h"
+ Include dependency graph for reflow.c:

Go to the source code of this file.

Macros

#define TEST_NO_MAIN
 

Typedefs

typedef uint16_t MuttRedrawFlags
 

Functions

void debug_win_dump (void)
 
void mutt_menu_set_current_redraw_full (void)
 Flag the current menu to be fully redrawn. More...
 
void mutt_menu_set_current_redraw (MuttRedrawFlags redraw)
 Set redraw flags on the current menu. More...
 
static const char * win_size (struct MuttWindow *win)
 
static void win_serialise (struct MuttWindow *win, struct Buffer *buf)
 
void test_window_reflow (void)
 

Detailed Description

Test code for window_reflow()

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file reflow.c.

Macro Definition Documentation

◆ TEST_NO_MAIN

#define TEST_NO_MAIN

Definition at line 23 of file reflow.c.

Typedef Documentation

◆ MuttRedrawFlags

typedef uint16_t MuttRedrawFlags

Definition at line 31 of file reflow.c.

Function Documentation

◆ debug_win_dump()

void debug_win_dump ( void  )

Definition at line 33 of file reflow.c.

34 {
35 }
+ Here is the caller graph for this function:

◆ mutt_menu_set_current_redraw_full()

void mutt_menu_set_current_redraw_full ( void  )

Flag the current menu to be fully redrawn.

Definition at line 37 of file reflow.c.

38 {
39 }
+ Here is the call graph for this function:

◆ mutt_menu_set_current_redraw()

void mutt_menu_set_current_redraw ( MuttRedrawFlags  redraw)

Set redraw flags on the current menu.

Parameters
redrawFlags to set, see MuttRedrawFlags

Definition at line 41 of file reflow.c.

42 {
43 }
+ Here is the call graph for this function:

◆ win_size()

static const char* win_size ( struct MuttWindow win)
static

Definition at line 45 of file reflow.c.

46 {
47  if (!win)
48  return "???";
49 
50  switch (win->size)
51  {
53  return "FIX";
55  return "MAX";
57  return "MIN";
58  }
59 
60  return "???";
61 }
Window has a fixed size.
Definition: mutt_window.h:44
Window size depends on its children.
Definition: mutt_window.h:46
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Definition: mutt_window.h:117
Window wants as much space as possible.
Definition: mutt_window.h:45
+ Here is the caller graph for this function:

◆ win_serialise()

static void win_serialise ( struct MuttWindow win,
struct Buffer buf 
)
static

Definition at line 63 of file reflow.c.

64 {
65  if (!mutt_window_is_visible(win))
66  return;
67 
68  mutt_buffer_add_printf(buf, "<%s {%dx,%dy} [%dC,%dR]", win_size(win),
69  win->state.col_offset, win->state.row_offset,
70  win->state.cols, win->state.rows);
71 
72  struct MuttWindow *np = NULL;
73  TAILQ_FOREACH(np, &win->children, entries)
74  {
75  win_serialise(np, buf);
76  }
77 
78  mutt_buffer_addstr(buf, ">");
79 }
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
static void win_serialise(struct MuttWindow *win, struct Buffer *buf)
Definition: reflow.c:63
A division of the screen.
Definition: mutt_window.h:108
short col_offset
Absolute on-screen column.
Definition: mutt_window.h:59
int mutt_buffer_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition: buffer.c:203
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:57
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:113
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:630
short row_offset
Absolute on-screen row.
Definition: mutt_window.h:60
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:58
static const char * win_size(struct MuttWindow *win)
Definition: reflow.c:45
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:121
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_window_reflow()

void test_window_reflow ( void  )

Definition at line 81 of file reflow.c.

82 {
83  // void window_reflow(struct MuttWindow *win);
84 
85  {
86  window_reflow(NULL);
87  TEST_CHECK_(1, "window_reflow(NULL)");
88  }
89 
90  // ---------------------------------------------------------------------------
91  // Horizontal tests in a fixed root of 80x24
92 
93  TEST_CASE("Horizontal");
94  {
95  // Root containing 'fix 40'
96  static const char *expected =
97  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [40C,24R]>>";
98 
100  MUTT_WIN_SIZE_FIXED, 80, 24);
101  root->state.rows = root->req_rows;
102  root->state.cols = root->req_cols;
103 
104  struct MuttWindow *fix1 =
107  fix1->req_cols = 40;
108 
109  mutt_window_add_child(root, fix1);
110 
111  window_reflow(root);
112 
113  struct Buffer buf = mutt_buffer_make(1024);
114  win_serialise(root, &buf);
115  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
116  TEST_MSG("Expected %s\n", expected);
117  TEST_MSG("Got %s\n", mutt_b2s(&buf));
118 
119  mutt_buffer_dealloc(&buf);
120  mutt_window_free(&root);
121  }
122 
123  {
124  // Root containing 'max'
125  static const char *expected =
126  "<FIX {0x,0y} [80C,24R]<MAX {0x,0y} [80C,24R]>>";
127 
129  MUTT_WIN_SIZE_FIXED, 80, 24);
130  root->state.rows = root->req_rows;
131  root->state.cols = root->req_cols;
132 
133  struct MuttWindow *max1 =
136 
137  mutt_window_add_child(root, max1);
138 
139  window_reflow(root);
140 
141  struct Buffer buf = mutt_buffer_make(1024);
142  win_serialise(root, &buf);
143  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
144  TEST_MSG("Expected %s\n", expected);
145  TEST_MSG("Got %s\n", mutt_b2s(&buf));
146 
147  mutt_buffer_dealloc(&buf);
148  mutt_window_free(&root);
149  }
150 
151  {
152  // Root containing ('min' containing ('fix 20'))
153  static const char *expected =
154  "<FIX {0x,0y} [80C,24R]<MIN {0x,0y} [20C,24R]<FIX {0x,0y} [20C,24R]>>>";
155 
157  MUTT_WIN_SIZE_FIXED, 80, 24);
158  root->state.rows = root->req_rows;
159  root->state.cols = root->req_cols;
160 
162  MUTT_WIN_SIZE_MINIMISE, 0, 0);
163 
164  struct MuttWindow *fix1 =
167  fix1->state.rows = fix1->req_rows;
168  fix1->state.cols = fix1->req_cols;
169 
170  mutt_window_add_child(root, min1);
171  mutt_window_add_child(min1, fix1);
172 
173  window_reflow(root);
174 
175  struct Buffer buf = mutt_buffer_make(1024);
176  win_serialise(root, &buf);
177  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
178  TEST_MSG("Expected %s\n", expected);
179  TEST_MSG("Got %s\n", mutt_b2s(&buf));
180 
181  mutt_buffer_dealloc(&buf);
182  mutt_window_free(&root);
183  }
184 
185  {
186  // Root containing ('min' containing ('fix 20' and 'inv'))
187  static const char *expected =
188  "<FIX {0x,0y} [80C,24R]<MIN {0x,0y} [20C,24R]<FIX {0x,0y} [20C,24R]>>>";
189 
191  MUTT_WIN_SIZE_FIXED, 80, 24);
192  root->state.rows = root->req_rows;
193  root->state.cols = root->req_cols;
194 
196  MUTT_WIN_SIZE_MINIMISE, 0, 0);
197 
198  struct MuttWindow *fix1 =
201  fix1->state.rows = fix1->req_rows;
202  fix1->state.cols = fix1->req_cols;
203 
204  struct MuttWindow *inv1 =
207  inv1->state.visible = false;
208 
209  mutt_window_add_child(root, min1);
210  mutt_window_add_child(min1, fix1);
211  mutt_window_add_child(min1, inv1);
212 
213  window_reflow(root);
214 
215  struct Buffer buf = mutt_buffer_make(1024);
216  win_serialise(root, &buf);
217  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
218  TEST_MSG("Expected %s\n", expected);
219  TEST_MSG("Got %s\n", mutt_b2s(&buf));
220 
221  mutt_buffer_dealloc(&buf);
222  mutt_window_free(&root);
223  }
224 
225  {
226  // Root containing ('min' containing ('fix 20' and 'fix 10'))
227  static const char *expected =
228  "<FIX {0x,0y} [80C,24R]<MIN {0x,0y} [30C,24R]<FIX {0x,0y} "
229  "[20C,24R]><FIX {20x,0y} [10C,24R]>>>";
230 
232  MUTT_WIN_SIZE_FIXED, 80, 24);
233  root->state.rows = root->req_rows;
234  root->state.cols = root->req_cols;
235 
237  MUTT_WIN_SIZE_MINIMISE, 0, 0);
238 
239  struct MuttWindow *fix1 =
242  fix1->state.rows = fix1->req_rows;
243  fix1->state.cols = fix1->req_cols;
244 
245  struct MuttWindow *fix2 =
248  fix2->state.rows = fix2->req_rows;
249  fix2->state.cols = fix2->req_cols;
250 
251  mutt_window_add_child(root, min1);
252  mutt_window_add_child(min1, fix1);
253  mutt_window_add_child(min1, fix2);
254 
255  window_reflow(root);
256 
257  struct Buffer buf = mutt_buffer_make(1024);
258  win_serialise(root, &buf);
259  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
260  TEST_MSG("Expected %s\n", expected);
261  TEST_MSG("Got %s\n", mutt_b2s(&buf));
262 
263  mutt_buffer_dealloc(&buf);
264  mutt_window_free(&root);
265  }
266 
267  {
268  // Root containing ('fix 40' and 'fix 20')
269  static const char *expected = "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} "
270  "[40C,24R]><FIX {40x,0y} [20C,24R]>>";
271 
273  MUTT_WIN_SIZE_FIXED, 80, 24);
274  root->state.rows = root->req_rows;
275  root->state.cols = root->req_cols;
276 
277  struct MuttWindow *fix1 =
280  fix1->state.rows = fix1->req_rows;
281  fix1->state.cols = fix1->req_cols;
282 
283  struct MuttWindow *fix2 =
286  fix2->state.rows = fix2->req_rows;
287  fix2->state.cols = fix2->req_cols;
288 
289  mutt_window_add_child(root, fix1);
290  mutt_window_add_child(root, fix2);
291 
292  window_reflow(root);
293 
294  struct Buffer buf = mutt_buffer_make(1024);
295  win_serialise(root, &buf);
296  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
297  TEST_MSG("Expected %s\n", expected);
298  TEST_MSG("Got %s\n", mutt_b2s(&buf));
299 
300  mutt_buffer_dealloc(&buf);
301  mutt_window_free(&root);
302  }
303 
304  {
305  // Root containing ('fix 35' and 'max')
306  static const char *expected = "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} "
307  "[35C,24R]><MAX {35x,0y} [45C,24R]>>";
308 
310  MUTT_WIN_SIZE_FIXED, 80, 24);
311  root->state.rows = root->req_rows;
312  root->state.cols = root->req_cols;
313 
314  struct MuttWindow *fix1 =
317  fix1->state.rows = fix1->req_rows;
318  fix1->state.cols = fix1->req_cols;
319 
320  struct MuttWindow *max1 =
323 
324  mutt_window_add_child(root, fix1);
325  mutt_window_add_child(root, max1);
326 
327  window_reflow(root);
328 
329  struct Buffer buf = mutt_buffer_make(1024);
330  win_serialise(root, &buf);
331  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
332  TEST_MSG("Expected %s\n", expected);
333  TEST_MSG("Got %s\n", mutt_b2s(&buf));
334 
335  mutt_buffer_dealloc(&buf);
336  mutt_window_free(&root);
337  }
338 
339  {
340  // Root containing ('fix 35', 'inv', 'max' and 'inv')
341  static const char *expected = "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} "
342  "[35C,24R]><MAX {35x,0y} [45C,24R]>>";
343 
345  MUTT_WIN_SIZE_FIXED, 80, 24);
346  root->state.rows = root->req_rows;
347  root->state.cols = root->req_cols;
348 
349  struct MuttWindow *fix1 =
352  fix1->state.rows = fix1->req_rows;
353  fix1->state.cols = fix1->req_cols;
354 
355  struct MuttWindow *inv1 =
358  inv1->state.visible = false;
359 
360  struct MuttWindow *max1 =
363 
364  struct MuttWindow *inv2 =
367  inv2->state.visible = false;
368 
369  mutt_window_add_child(root, fix1);
370  mutt_window_add_child(root, inv1);
371  mutt_window_add_child(root, max1);
372  mutt_window_add_child(root, inv2);
373 
374  window_reflow(root);
375 
376  struct Buffer buf = mutt_buffer_make(1024);
377  win_serialise(root, &buf);
378  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
379  TEST_MSG("Expected %s\n", expected);
380  TEST_MSG("Got %s\n", mutt_b2s(&buf));
381 
382  mutt_buffer_dealloc(&buf);
383  mutt_window_free(&root);
384  }
385 
386  {
387  // Root containing ('max' and 'fix 35')
388  static const char *expected = "<FIX {0x,0y} [80C,24R]<MAX {0x,0y} "
389  "[45C,24R]><FIX {45x,0y} [35C,24R]>>";
390 
392  MUTT_WIN_SIZE_FIXED, 80, 24);
393  root->state.rows = root->req_rows;
394  root->state.cols = root->req_cols;
395 
396  struct MuttWindow *max1 =
399 
400  struct MuttWindow *fix1 =
403  fix1->state.rows = fix1->req_rows;
404  fix1->state.cols = fix1->req_cols;
405 
406  mutt_window_add_child(root, max1);
407  mutt_window_add_child(root, fix1);
408 
409  window_reflow(root);
410 
411  struct Buffer buf = mutt_buffer_make(1024);
412  win_serialise(root, &buf);
413  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
414  TEST_MSG("Expected %s\n", expected);
415  TEST_MSG("Got %s\n", mutt_b2s(&buf));
416 
417  mutt_buffer_dealloc(&buf);
418  mutt_window_free(&root);
419  }
420 
421  {
422  // Root containing ('max' and 'max')
423  static const char *expected = "<FIX {0x,0y} [80C,24R]<MAX {0x,0y} "
424  "[40C,24R]><MAX {40x,0y} [40C,24R]>>";
425 
427  MUTT_WIN_SIZE_FIXED, 80, 24);
428  root->state.rows = root->req_rows;
429  root->state.cols = root->req_cols;
430 
431  struct MuttWindow *max1 =
434  struct MuttWindow *max2 =
437 
438  mutt_window_add_child(root, max1);
439  mutt_window_add_child(root, max2);
440 
441  window_reflow(root);
442 
443  struct Buffer buf = mutt_buffer_make(1024);
444  win_serialise(root, &buf);
445  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
446  TEST_MSG("Expected %s\n", expected);
447  TEST_MSG("Got %s\n", mutt_b2s(&buf));
448 
449  mutt_buffer_dealloc(&buf);
450  mutt_window_free(&root);
451  }
452 
453  {
454  // Root containing ('max', 'max', 'max' and 'max')
455  static const char *expected =
456  "<FIX {0x,0y} [80C,24R]<MAX {0x,0y} [20C,24R]><MAX {20x,0y} "
457  "[20C,24R]><MAX {40x,0y} [20C,24R]><MAX {60x,0y} [20C,24R]>>";
458 
460  MUTT_WIN_SIZE_FIXED, 80, 24);
461  root->state.rows = root->req_rows;
462  root->state.cols = root->req_cols;
463 
464  struct MuttWindow *max1 =
467  struct MuttWindow *max2 =
470  struct MuttWindow *max3 =
473  struct MuttWindow *max4 =
476 
477  mutt_window_add_child(root, max1);
478  mutt_window_add_child(root, max2);
479  mutt_window_add_child(root, max3);
480  mutt_window_add_child(root, max4);
481 
482  window_reflow(root);
483 
484  struct Buffer buf = mutt_buffer_make(1024);
485  win_serialise(root, &buf);
486  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
487  TEST_MSG("Expected %s\n", expected);
488  TEST_MSG("Got %s\n", mutt_b2s(&buf));
489 
490  mutt_buffer_dealloc(&buf);
491  mutt_window_free(&root);
492  }
493 
494  {
495  // Root containing ('fix 40', 'fix 30' and 'fix 30')
496  // Too big to fit on screen
497  static const char *expected =
498  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [40C,24R]><FIX {40x,0y} "
499  "[30C,24R]><FIX {70x,0y} [10C,24R]>>";
500 
502  MUTT_WIN_SIZE_FIXED, 80, 24);
503  root->state.rows = root->req_rows;
504  root->state.cols = root->req_cols;
505 
506  struct MuttWindow *fix1 =
509  struct MuttWindow *fix2 =
512  struct MuttWindow *fix3 =
515 
516  mutt_window_add_child(root, fix1);
517  mutt_window_add_child(root, fix2);
518  mutt_window_add_child(root, fix3);
519 
520  window_reflow(root);
521 
522  struct Buffer buf = mutt_buffer_make(1024);
523  win_serialise(root, &buf);
524  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
525  TEST_MSG("Expected %s\n", expected);
526  TEST_MSG("Got %s\n", mutt_b2s(&buf));
527 
528  mutt_buffer_dealloc(&buf);
529  mutt_window_free(&root);
530  }
531 
532  {
533  // Root containing ('fix 40', 'fix 60' and 'fix 20')
534  // Too big to fit on screen (third is completely offscreen)
535  static const char *expected =
536  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [40C,24R]><FIX {40x,0y} "
537  "[40C,24R]><FIX {80x,0y} [0C,24R]>>";
538 
540  MUTT_WIN_SIZE_FIXED, 80, 24);
541  root->state.rows = root->req_rows;
542  root->state.cols = root->req_cols;
543 
544  struct MuttWindow *fix1 =
547  struct MuttWindow *fix2 =
550  struct MuttWindow *fix3 =
553 
554  mutt_window_add_child(root, fix1);
555  mutt_window_add_child(root, fix2);
556  mutt_window_add_child(root, fix3);
557 
558  window_reflow(root);
559 
560  struct Buffer buf = mutt_buffer_make(1024);
561  win_serialise(root, &buf);
562  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
563  TEST_MSG("Expected %s\n", expected);
564  TEST_MSG("Got %s\n", mutt_b2s(&buf));
565 
566  mutt_buffer_dealloc(&buf);
567  mutt_window_free(&root);
568  }
569 
570  {
571  // Root containing ('fix 45' containing ('fix 10' and 'max') and 'max')
572  static const char *expected =
573  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [45C,24R]<FIX {0x,0y} "
574  "[10C,24R]><MAX {10x,0y} [35C,24R]>><MAX {45x,0y} [35C,24R]>>";
575 
577  MUTT_WIN_SIZE_FIXED, 80, 24);
578  root->state.rows = root->req_rows;
579  root->state.cols = root->req_cols;
580 
581  struct MuttWindow *fix1 =
584  struct MuttWindow *fix2 =
587  struct MuttWindow *max1 =
590  struct MuttWindow *max2 =
593 
594  mutt_window_add_child(root, fix1);
595  mutt_window_add_child(fix1, fix2);
596  mutt_window_add_child(fix1, max1);
597  mutt_window_add_child(root, max2);
598 
599  window_reflow(root);
600 
601  struct Buffer buf = mutt_buffer_make(1024);
602  win_serialise(root, &buf);
603  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
604  TEST_MSG("Expected %s\n", expected);
605  TEST_MSG("Got %s\n", mutt_b2s(&buf));
606 
607  mutt_buffer_dealloc(&buf);
608  mutt_window_free(&root);
609  }
610 
611  {
612  // Root containing ('max' containing ('max' and 'fix 10') and 'fix 35')
613  static const char *expected =
614  "<FIX {0x,0y} [80C,24R]<MAX {0x,0y} [45C,24R]<MAX {0x,0y} "
615  "[35C,24R]><FIX {35x,0y} [10C,24R]>><FIX {45x,0y} [35C,24R]>>";
616 
618  MUTT_WIN_SIZE_FIXED, 80, 24);
619  root->state.rows = root->req_rows;
620  root->state.cols = root->req_cols;
621 
622  struct MuttWindow *fix1 =
625  struct MuttWindow *fix2 =
628  struct MuttWindow *max1 =
631  struct MuttWindow *max2 =
634 
635  mutt_window_add_child(root, max1);
636  mutt_window_add_child(max1, max2);
637  mutt_window_add_child(max1, fix1);
638  mutt_window_add_child(root, fix2);
639 
640  window_reflow(root);
641 
642  struct Buffer buf = mutt_buffer_make(1024);
643  win_serialise(root, &buf);
644  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
645  TEST_MSG("Expected %s\n", expected);
646  TEST_MSG("Got %s\n", mutt_b2s(&buf));
647 
648  mutt_buffer_dealloc(&buf);
649  mutt_window_free(&root);
650  }
651 
652  {
653  // Root containing ('fix 35' containing ('max' and 'fix 10') and 'max')
654  static const char *expected =
655  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [35C,24R]<MAX {0x,0y} "
656  "[25C,24R]><FIX {25x,0y} [10C,24R]>><MAX {35x,0y} [45C,24R]>>";
657 
659  MUTT_WIN_SIZE_FIXED, 80, 24);
660  root->state.rows = root->req_rows;
661  root->state.cols = root->req_cols;
662 
663  struct MuttWindow *fix1 =
666  struct MuttWindow *fix2 =
669  struct MuttWindow *max1 =
672  struct MuttWindow *max2 =
675 
676  mutt_window_add_child(root, fix1);
677  mutt_window_add_child(fix1, max1);
678  mutt_window_add_child(fix1, fix2);
679  mutt_window_add_child(root, max2);
680 
681  window_reflow(root);
682 
683  struct Buffer buf = mutt_buffer_make(1024);
684  win_serialise(root, &buf);
685  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
686  TEST_MSG("Expected %s\n", expected);
687  TEST_MSG("Got %s\n", mutt_b2s(&buf));
688 
689  mutt_buffer_dealloc(&buf);
690  mutt_window_free(&root);
691  }
692 
693  {
694  // Root containing ('max' containing ('max' and 'fix 10') and 'fix 35')
695  static const char *expected =
696  "<FIX {0x,0y} [80C,24R]<MAX {0x,0y} [45C,24R]<MAX {0x,0y} "
697  "[35C,24R]><FIX {35x,0y} [10C,24R]>><FIX {45x,0y} [35C,24R]>>";
698 
700  MUTT_WIN_SIZE_FIXED, 80, 24);
701  root->state.rows = root->req_rows;
702  root->state.cols = root->req_cols;
703 
704  struct MuttWindow *fix1 =
707  struct MuttWindow *fix2 =
710  struct MuttWindow *max1 =
713  struct MuttWindow *max2 =
716 
717  mutt_window_add_child(root, max1);
718  mutt_window_add_child(max1, max2);
719  mutt_window_add_child(max1, fix1);
720  mutt_window_add_child(root, fix2);
721 
722  window_reflow(root);
723 
724  struct Buffer buf = mutt_buffer_make(1024);
725  win_serialise(root, &buf);
726  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
727  TEST_MSG("Expected %s\n", expected);
728  TEST_MSG("Got %s\n", mutt_b2s(&buf));
729 
730  mutt_buffer_dealloc(&buf);
731  mutt_window_free(&root);
732  }
733 
734  // ---------------------------------------------------------------------------
735  // Vertical tests in a fixed root of 80x24
736 
737  TEST_CASE("Vertical");
738  {
739  // Root containing 'fix 20'
740  static const char *expected =
741  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [80C,20R]>>";
742 
744  MUTT_WIN_SIZE_FIXED, 80, 24);
745  root->state.rows = root->req_rows;
746  root->state.cols = root->req_cols;
747 
748  struct MuttWindow *fix1 =
751  fix1->req_rows = 20;
752 
753  mutt_window_add_child(root, fix1);
754 
755  window_reflow(root);
756 
757  struct Buffer buf = mutt_buffer_make(1024);
758  win_serialise(root, &buf);
759  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
760  TEST_MSG("Expected %s\n", expected);
761  TEST_MSG("Got %s\n", mutt_b2s(&buf));
762 
763  mutt_buffer_dealloc(&buf);
764  mutt_window_free(&root);
765  }
766 
767  {
768  // Root containing 'max'
769  static const char *expected =
770  "<FIX {0x,0y} [80C,24R]<MAX {0x,0y} [80C,24R]>>";
771 
773  MUTT_WIN_SIZE_FIXED, 80, 24);
774  root->state.rows = root->req_rows;
775  root->state.cols = root->req_cols;
776 
777  struct MuttWindow *max1 =
780 
781  mutt_window_add_child(root, max1);
782 
783  window_reflow(root);
784 
785  struct Buffer buf = mutt_buffer_make(1024);
786  win_serialise(root, &buf);
787  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
788  TEST_MSG("Expected %s\n", expected);
789  TEST_MSG("Got %s\n", mutt_b2s(&buf));
790 
791  mutt_buffer_dealloc(&buf);
792  mutt_window_free(&root);
793  }
794 
795  {
796  // Root containing ('min' containing ('fix 20'))
797  static const char *expected =
798  "<FIX {0x,0y} [80C,24R]<MIN {0x,0y} [80C,20R]<FIX {0x,0y} [80C,20R]>>>";
799 
801  MUTT_WIN_SIZE_FIXED, 80, 24);
802  root->state.rows = root->req_rows;
803  root->state.cols = root->req_cols;
804 
806  MUTT_WIN_SIZE_MINIMISE, 0, 0);
807 
808  struct MuttWindow *fix1 =
811  fix1->state.rows = fix1->req_rows;
812  fix1->state.cols = fix1->req_cols;
813 
814  mutt_window_add_child(root, min1);
815  mutt_window_add_child(min1, fix1);
816 
817  window_reflow(root);
818 
819  struct Buffer buf = mutt_buffer_make(1024);
820  win_serialise(root, &buf);
821  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
822  TEST_MSG("Expected %s\n", expected);
823  TEST_MSG("Got %s\n", mutt_b2s(&buf));
824 
825  mutt_buffer_dealloc(&buf);
826  mutt_window_free(&root);
827  }
828 
829  {
830  // Root containing ('min' containing ('fix 20' and 'inv'))
831  static const char *expected =
832  "<FIX {0x,0y} [80C,24R]<MIN {0x,0y} [80C,20R]<FIX {0x,0y} [80C,20R]>>>";
833 
835  MUTT_WIN_SIZE_FIXED, 80, 24);
836  root->state.rows = root->req_rows;
837  root->state.cols = root->req_cols;
838 
840  MUTT_WIN_SIZE_MINIMISE, 0, 0);
841 
842  struct MuttWindow *fix1 =
845  fix1->state.rows = fix1->req_rows;
846  fix1->state.cols = fix1->req_cols;
847 
848  struct MuttWindow *inv1 =
851  inv1->state.visible = false;
852 
853  mutt_window_add_child(root, min1);
854  mutt_window_add_child(min1, fix1);
855  mutt_window_add_child(min1, inv1);
856 
857  window_reflow(root);
858 
859  struct Buffer buf = mutt_buffer_make(1024);
860  win_serialise(root, &buf);
861  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
862  TEST_MSG("Expected %s\n", expected);
863  TEST_MSG("Got %s\n", mutt_b2s(&buf));
864 
865  mutt_buffer_dealloc(&buf);
866  mutt_window_free(&root);
867  }
868 
869  {
870  // Root containing ('min' containing ('fix 10' and 'fix 5'))
871  static const char *expected =
872  "<FIX {0x,0y} [80C,24R]<MIN {0x,0y} [80C,15R]<FIX {0x,0y} "
873  "[80C,10R]><FIX {0x,10y} [80C,5R]>>>";
874 
876  MUTT_WIN_SIZE_FIXED, 80, 24);
877  root->state.rows = root->req_rows;
878  root->state.cols = root->req_cols;
879 
881  MUTT_WIN_SIZE_MINIMISE, 0, 0);
882 
883  struct MuttWindow *fix1 =
886  fix1->state.rows = fix1->req_rows;
887  fix1->state.cols = fix1->req_cols;
888 
889  struct MuttWindow *fix2 =
892  fix2->state.rows = fix2->req_rows;
893  fix2->state.cols = fix2->req_cols;
894 
895  mutt_window_add_child(root, min1);
896  mutt_window_add_child(min1, fix1);
897  mutt_window_add_child(min1, fix2);
898 
899  window_reflow(root);
900 
901  struct Buffer buf = mutt_buffer_make(1024);
902  win_serialise(root, &buf);
903  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
904  TEST_MSG("Expected %s\n", expected);
905  TEST_MSG("Got %s\n", mutt_b2s(&buf));
906 
907  mutt_buffer_dealloc(&buf);
908  mutt_window_free(&root);
909  }
910 
911  {
912  // Root containing ('fix 10' and 'fix 5')
913  static const char *expected =
914  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [80C,10R]><FIX {0x,10y} [80C,5R]>>";
915 
917  MUTT_WIN_SIZE_FIXED, 80, 24);
918  root->state.rows = root->req_rows;
919  root->state.cols = root->req_cols;
920 
921  struct MuttWindow *fix1 =
924  fix1->state.rows = fix1->req_rows;
925  fix1->state.cols = fix1->req_cols;
926 
927  struct MuttWindow *fix2 =
930  fix2->state.rows = fix2->req_rows;
931  fix2->state.cols = fix2->req_cols;
932 
933  mutt_window_add_child(root, fix1);
934  mutt_window_add_child(root, fix2);
935 
936  window_reflow(root);
937 
938  struct Buffer buf = mutt_buffer_make(1024);
939  win_serialise(root, &buf);
940  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
941  TEST_MSG("Expected %s\n", expected);
942  TEST_MSG("Got %s\n", mutt_b2s(&buf));
943 
944  mutt_buffer_dealloc(&buf);
945  mutt_window_free(&root);
946  }
947 
948  {
949  // Root containing ('fix 15' and 'max')
950  static const char *expected =
951  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [80C,15R]><MAX {0x,15y} [80C,9R]>>";
952 
954  MUTT_WIN_SIZE_FIXED, 80, 24);
955  root->state.rows = root->req_rows;
956  root->state.cols = root->req_cols;
957 
958  struct MuttWindow *fix1 =
961  fix1->state.rows = fix1->req_rows;
962  fix1->state.cols = fix1->req_cols;
963 
964  struct MuttWindow *max1 =
967 
968  mutt_window_add_child(root, fix1);
969  mutt_window_add_child(root, max1);
970 
971  window_reflow(root);
972 
973  struct Buffer buf = mutt_buffer_make(1024);
974  win_serialise(root, &buf);
975  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
976  TEST_MSG("Expected %s\n", expected);
977  TEST_MSG("Got %s\n", mutt_b2s(&buf));
978 
979  mutt_buffer_dealloc(&buf);
980  mutt_window_free(&root);
981  }
982 
983  {
984  // Root containing ('fix 15', 'inv', 'max' and 'inv')
985  static const char *expected =
986  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [80C,15R]><MAX {0x,15y} [80C,9R]>>";
987 
989  MUTT_WIN_SIZE_FIXED, 80, 24);
990  root->state.rows = root->req_rows;
991  root->state.cols = root->req_cols;
992 
993  struct MuttWindow *fix1 =
996  fix1->state.rows = fix1->req_rows;
997  fix1->state.cols = fix1->req_cols;
998 
999  struct MuttWindow *inv1 =
1002  inv1->state.visible = false;
1003 
1004  struct MuttWindow *max1 =
1007 
1008  struct MuttWindow *inv2 =
1011  inv2->state.visible = false;
1012 
1013  mutt_window_add_child(root, fix1);
1014  mutt_window_add_child(root, inv1);
1015  mutt_window_add_child(root, max1);
1016  mutt_window_add_child(root, inv2);
1017 
1018  window_reflow(root);
1019 
1020  struct Buffer buf = mutt_buffer_make(1024);
1021  win_serialise(root, &buf);
1022  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
1023  TEST_MSG("Expected %s\n", expected);
1024  TEST_MSG("Got %s\n", mutt_b2s(&buf));
1025 
1026  mutt_buffer_dealloc(&buf);
1027  mutt_window_free(&root);
1028  }
1029 
1030  {
1031  // Root containing ('max' and 'fix 15')
1032  static const char *expected =
1033  "<FIX {0x,0y} [80C,24R]<MAX {0x,0y} [80C,9R]><FIX {0x,9y} [80C,15R]>>";
1034 
1036  MUTT_WIN_SIZE_FIXED, 80, 24);
1037  root->state.rows = root->req_rows;
1038  root->state.cols = root->req_cols;
1039 
1040  struct MuttWindow *max1 =
1043 
1044  struct MuttWindow *fix1 =
1047  fix1->state.rows = fix1->req_rows;
1048  fix1->state.cols = fix1->req_cols;
1049 
1050  mutt_window_add_child(root, max1);
1051  mutt_window_add_child(root, fix1);
1052 
1053  window_reflow(root);
1054 
1055  struct Buffer buf = mutt_buffer_make(1024);
1056  win_serialise(root, &buf);
1057  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
1058  TEST_MSG("Expected %s\n", expected);
1059  TEST_MSG("Got %s\n", mutt_b2s(&buf));
1060 
1061  mutt_buffer_dealloc(&buf);
1062  mutt_window_free(&root);
1063  }
1064 
1065  {
1066  // Root containing ('max' and 'max')
1067  static const char *expected = "<FIX {0x,0y} [80C,24R]<MAX {0x,0y} "
1068  "[80C,12R]><MAX {0x,12y} [80C,12R]>>";
1069 
1071  MUTT_WIN_SIZE_FIXED, 80, 24);
1072  root->state.rows = root->req_rows;
1073  root->state.cols = root->req_cols;
1074 
1075  struct MuttWindow *max1 =
1078  struct MuttWindow *max2 =
1081 
1082  mutt_window_add_child(root, max1);
1083  mutt_window_add_child(root, max2);
1084 
1085  window_reflow(root);
1086 
1087  struct Buffer buf = mutt_buffer_make(1024);
1088  win_serialise(root, &buf);
1089  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
1090  TEST_MSG("Expected %s\n", expected);
1091  TEST_MSG("Got %s\n", mutt_b2s(&buf));
1092 
1093  mutt_buffer_dealloc(&buf);
1094  mutt_window_free(&root);
1095  }
1096 
1097  {
1098  // Root containing ('max', 'max', 'max' and 'max')
1099  static const char *expected =
1100  "<FIX {0x,0y} [80C,24R]<MAX {0x,0y} [80C,6R]><MAX {0x,6y} "
1101  "[80C,6R]><MAX {0x,12y} [80C,6R]><MAX {0x,18y} [80C,6R]>>";
1102 
1104  MUTT_WIN_SIZE_FIXED, 80, 24);
1105  root->state.rows = root->req_rows;
1106  root->state.cols = root->req_cols;
1107 
1108  struct MuttWindow *max1 =
1111  struct MuttWindow *max2 =
1114  struct MuttWindow *max3 =
1117  struct MuttWindow *max4 =
1120 
1121  mutt_window_add_child(root, max1);
1122  mutt_window_add_child(root, max2);
1123  mutt_window_add_child(root, max3);
1124  mutt_window_add_child(root, max4);
1125 
1126  window_reflow(root);
1127 
1128  struct Buffer buf = mutt_buffer_make(1024);
1129  win_serialise(root, &buf);
1130  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
1131  TEST_MSG("Expected %s\n", expected);
1132  TEST_MSG("Got %s\n", mutt_b2s(&buf));
1133 
1134  mutt_buffer_dealloc(&buf);
1135  mutt_window_free(&root);
1136  }
1137 
1138  {
1139  // Root containing ('fix 10', 'fix 12' and 'fix 15')
1140  // Too big to fit on screen
1141  static const char *expected =
1142  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [80C,10R]><FIX {0x,10y} "
1143  "[80C,12R]><FIX {0x,22y} [80C,2R]>>";
1144 
1146  MUTT_WIN_SIZE_FIXED, 80, 24);
1147  root->state.rows = root->req_rows;
1148  root->state.cols = root->req_cols;
1149 
1150  struct MuttWindow *fix1 =
1153  struct MuttWindow *fix2 =
1156  struct MuttWindow *fix3 =
1159 
1160  mutt_window_add_child(root, fix1);
1161  mutt_window_add_child(root, fix2);
1162  mutt_window_add_child(root, fix3);
1163 
1164  window_reflow(root);
1165 
1166  struct Buffer buf = mutt_buffer_make(1024);
1167  win_serialise(root, &buf);
1168  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
1169  TEST_MSG("Expected %s\n", expected);
1170  TEST_MSG("Got %s\n", mutt_b2s(&buf));
1171 
1172  mutt_buffer_dealloc(&buf);
1173  mutt_window_free(&root);
1174  }
1175 
1176  {
1177  // Root containing ('fix 20', 'fix 10' and 'fix 5')
1178  // Too big to fit on screen (third is completely offscreen)
1179  static const char *expected =
1180  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [80C,20R]><FIX {0x,20y} "
1181  "[80C,4R]><FIX {0x,24y} [80C,0R]>>";
1182 
1184  MUTT_WIN_SIZE_FIXED, 80, 24);
1185  root->state.rows = root->req_rows;
1186  root->state.cols = root->req_cols;
1187 
1188  struct MuttWindow *fix1 =
1191  struct MuttWindow *fix2 =
1194  struct MuttWindow *fix3 =
1197 
1198  mutt_window_add_child(root, fix1);
1199  mutt_window_add_child(root, fix2);
1200  mutt_window_add_child(root, fix3);
1201 
1202  window_reflow(root);
1203 
1204  struct Buffer buf = mutt_buffer_make(1024);
1205  win_serialise(root, &buf);
1206  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
1207  TEST_MSG("Expected %s\n", expected);
1208  TEST_MSG("Got %s\n", mutt_b2s(&buf));
1209 
1210  mutt_buffer_dealloc(&buf);
1211  mutt_window_free(&root);
1212  }
1213 
1214  {
1215  // Root containing ('fix 15' containing ('fix 5' and 'max') and 'max')
1216  static const char *expected =
1217  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [80C,15R]<FIX {0x,0y} "
1218  "[80C,5R]><MAX {0x,5y} [80C,10R]>><MAX {0x,15y} [80C,9R]>>";
1219 
1221  MUTT_WIN_SIZE_FIXED, 80, 24);
1222  root->state.rows = root->req_rows;
1223  root->state.cols = root->req_cols;
1224 
1225  struct MuttWindow *fix1 =
1228  struct MuttWindow *fix2 =
1231  struct MuttWindow *max1 =
1234  struct MuttWindow *max2 =
1237 
1238  mutt_window_add_child(root, fix1);
1239  mutt_window_add_child(fix1, fix2);
1240  mutt_window_add_child(fix1, max1);
1241  mutt_window_add_child(root, max2);
1242 
1243  window_reflow(root);
1244 
1245  struct Buffer buf = mutt_buffer_make(1024);
1246  win_serialise(root, &buf);
1247  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
1248  TEST_MSG("Expected %s\n", expected);
1249  TEST_MSG("Got %s\n", mutt_b2s(&buf));
1250 
1251  mutt_buffer_dealloc(&buf);
1252  mutt_window_free(&root);
1253  }
1254 
1255  {
1256  // Root containing ('max' containing ('max' and 'fix 10') and 'fix 12')
1257  static const char *expected =
1258  "<FIX {0x,0y} [80C,24R]<MAX {0x,0y} [80C,12R]<MAX {0x,0y} "
1259  "[80C,2R]><FIX {0x,2y} [80C,10R]>><FIX {0x,12y} [80C,12R]>>";
1260 
1262  MUTT_WIN_SIZE_FIXED, 80, 24);
1263  root->state.rows = root->req_rows;
1264  root->state.cols = root->req_cols;
1265 
1266  struct MuttWindow *fix1 =
1269  struct MuttWindow *fix2 =
1272  struct MuttWindow *max1 =
1275  struct MuttWindow *max2 =
1278 
1279  mutt_window_add_child(root, max1);
1280  mutt_window_add_child(max1, max2);
1281  mutt_window_add_child(max1, fix1);
1282  mutt_window_add_child(root, fix2);
1283 
1284  window_reflow(root);
1285 
1286  struct Buffer buf = mutt_buffer_make(1024);
1287  win_serialise(root, &buf);
1288  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
1289  TEST_MSG("Expected %s\n", expected);
1290  TEST_MSG("Got %s\n", mutt_b2s(&buf));
1291 
1292  mutt_buffer_dealloc(&buf);
1293  mutt_window_free(&root);
1294  }
1295 
1296  {
1297  // Root containing ('fix 15' containing ('max' and 'fix 10') and 'max')
1298  static const char *expected =
1299  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [80C,15R]<MAX {0x,0y} "
1300  "[80C,5R]><FIX {0x,5y} [80C,10R]>><MAX {0x,15y} [80C,9R]>>";
1301 
1303  MUTT_WIN_SIZE_FIXED, 80, 24);
1304  root->state.rows = root->req_rows;
1305  root->state.cols = root->req_cols;
1306 
1307  struct MuttWindow *fix1 =
1310  struct MuttWindow *fix2 =
1313  struct MuttWindow *max1 =
1316  struct MuttWindow *max2 =
1319 
1320  mutt_window_add_child(root, fix1);
1321  mutt_window_add_child(fix1, max1);
1322  mutt_window_add_child(fix1, fix2);
1323  mutt_window_add_child(root, max2);
1324 
1325  window_reflow(root);
1326 
1327  struct Buffer buf = mutt_buffer_make(1024);
1328  win_serialise(root, &buf);
1329  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
1330  TEST_MSG("Expected %s\n", expected);
1331  TEST_MSG("Got %s\n", mutt_b2s(&buf));
1332 
1333  mutt_buffer_dealloc(&buf);
1334  mutt_window_free(&root);
1335  }
1336 
1337  {
1338  // Root containing ('max' containing ('max' and 'fix 10') and 'fix 5')
1339  static const char *expected =
1340  "<FIX {0x,0y} [80C,24R]<MAX {0x,0y} [80C,19R]<MAX {0x,0y} "
1341  "[80C,9R]><FIX {0x,9y} [80C,10R]>><FIX {0x,19y} [80C,5R]>>";
1342 
1344  MUTT_WIN_SIZE_FIXED, 80, 24);
1345  root->state.rows = root->req_rows;
1346  root->state.cols = root->req_cols;
1347 
1348  struct MuttWindow *fix1 =
1351  struct MuttWindow *fix2 =
1354  struct MuttWindow *max1 =
1357  struct MuttWindow *max2 =
1360 
1361  mutt_window_add_child(root, max1);
1362  mutt_window_add_child(max1, max2);
1363  mutt_window_add_child(max1, fix1);
1364  mutt_window_add_child(root, fix2);
1365 
1366  window_reflow(root);
1367 
1368  struct Buffer buf = mutt_buffer_make(1024);
1369  win_serialise(root, &buf);
1370  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
1371  TEST_MSG("Expected %s\n", expected);
1372  TEST_MSG("Got %s\n", mutt_b2s(&buf));
1373 
1374  mutt_buffer_dealloc(&buf);
1375  mutt_window_free(&root);
1376  }
1377 
1378  // ---------------------------------------------------------------------------
1379  // Index/Pager test in a fixed root of 80x24
1380  TEST_CASE("Index/Pager");
1381  {
1382  // (help, sidebar, pager_index_lines visible, status_on_top=no)
1383  static const char *expected =
1384  "<FIX {0x,0y} [80C,24R]<FIX {0x,0y} [80C,1R]><MAX {0x,1y} "
1385  "[80C,22R]<MAX {0x,1y} [80C,22R]<FIX {0x,1y} [15C,22R]><MAX {15x,1y} "
1386  "[65C,22R]<MIN {15x,1y} [65C,6R]<FIX {15x,1y} [65C,5R]><FIX {15x,6y} "
1387  "[65C,1R]>><MAX {15x,7y} [65C,16R]<MAX {15x,7y} [65C,15R]><FIX "
1388  "{15x,22y} [65C,1R]>>>>><FIX {0x,23y} [80C,1R]>>";
1389 
1391  MUTT_WIN_SIZE_FIXED, 80, 24);
1392  root->state.rows = root->req_rows;
1393  root->state.cols = root->req_cols;
1394 
1395  struct MuttWindow *help =
1398  struct MuttWindow *all_dialogs =
1401  struct MuttWindow *message =
1404 
1405  mutt_window_add_child(root, help);
1406  mutt_window_add_child(root, all_dialogs);
1407  mutt_window_add_child(root, message);
1408 
1409  struct MuttWindow *index_dlg =
1412  struct MuttWindow *sidebar =
1415  struct MuttWindow *right_cont =
1418 
1419  mutt_window_add_child(all_dialogs, index_dlg);
1420  mutt_window_add_child(index_dlg, sidebar);
1421  mutt_window_add_child(index_dlg, right_cont);
1422 
1423  struct MuttWindow *index_panel = mutt_window_new(
1425  struct MuttWindow *index =
1428  struct MuttWindow *index_bar =
1431 
1432  mutt_window_add_child(index_panel, index);
1433  mutt_window_add_child(index_panel, index_bar);
1434 
1435  struct MuttWindow *pager_panel =
1438  struct MuttWindow *pager =
1441  struct MuttWindow *pager_bar =
1444 
1445  mutt_window_add_child(pager_panel, pager);
1446  mutt_window_add_child(pager_panel, pager_bar);
1447 
1448  mutt_window_add_child(right_cont, index_panel);
1449  mutt_window_add_child(right_cont, pager_panel);
1450 
1451  window_reflow(root);
1452 
1453  struct Buffer buf = mutt_buffer_make(1024);
1454  win_serialise(root, &buf);
1455  TEST_CHECK(strcmp(mutt_b2s(&buf), expected) == 0);
1456  TEST_MSG("Expected %s\n", expected);
1457  TEST_MSG("Got %s\n", mutt_b2s(&buf));
1458 
1459  mutt_buffer_dealloc(&buf);
1460  mutt_window_free(&root);
1461  }
1462 }
Window uses all available vertical space.
Definition: mutt_window.h:35
static void win_serialise(struct MuttWindow *win, struct Buffer *buf)
Definition: reflow.c:63
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
String manipulation buffer.
Definition: buffer.h:33
Parent of All Windows.
Definition: mutt_window.h:69
#define TEST_MSG(...)
Definition: acutest.h:214
#define TEST_CHECK(cond)
Definition: acutest.h:83
A division of the screen.
Definition: mutt_window.h:108
void window_reflow(struct MuttWindow *win)
Reflow Windows.
Definition: reflow.c:222
#define TEST_CHECK_(cond,...)
Definition: acutest.h:82
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:150
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
Window with a custom drawing function.
Definition: mutt_window.h:91
Window has a fixed size.
Definition: mutt_window.h:44
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:57
#define mutt_b2s(buf)
Definition: buffer.h:41
Window size depends on its children.
Definition: mutt_window.h:46
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:113
bool visible
Window is visible.
Definition: mutt_window.h:56
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:49
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:58
#define TEST_CASE(name)
Definition: acutest.h:182
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:564
Window uses all available horizontal space.
Definition: mutt_window.h:36
short req_rows
Number of rows required.
Definition: mutt_window.h:111
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
Definition: mutt_window.c:131
Window wants as much space as possible.
Definition: mutt_window.h:45
short req_cols
Number of columns required.
Definition: mutt_window.h:110
+ Here is the call graph for this function: