popup: no fallbacks for work areas no desktop has; text setup cannot fail
popuplayout had two refit stages for a work area shorter than one padded row — 40 pixels — and popupdraw re-checked the layout it had just been handed, against an Imgh that bounded no buffer any more. Pango and Cairo abort rather than return nil, so textinit is void and the layout is never nil; the stride Cairo computes for RGB24 is w*4 by definition; and textdraw set the layout's width and ellipsis twice.
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
#include "fn.h"
|
||||
#include "test.h"
|
||||
|
||||
/* A popup with every section, tall enough for the tests. */
|
||||
#define Imgh (2*PopupPad + (Maxdisp + 2)*Fontsz + PopupSep)
|
||||
|
||||
enum {
|
||||
Rgbmask = 0xffffff,
|
||||
};
|
||||
@@ -40,9 +43,6 @@ checkpadding(struct ct *t, u32int *img, Popup *p)
|
||||
void
|
||||
popup_layout(struct ct *t)
|
||||
{
|
||||
int tinyheight[] = {
|
||||
1, PopupPad, 2*PopupPad + Fontsz - 1,
|
||||
};
|
||||
static const struct {
|
||||
int first;
|
||||
int shown;
|
||||
@@ -132,8 +132,7 @@ popup_layout(struct ct *t)
|
||||
CT_EQ_INT(t, 100, x);
|
||||
CT_EQ_INT(t, 200, y);
|
||||
|
||||
if(!CT_CHECK(t, textinit()))
|
||||
return;
|
||||
textinit();
|
||||
|
||||
/* Empty sections reserve nothing. */
|
||||
memset(&dc, 0, sizeof dc);
|
||||
@@ -320,24 +319,5 @@ popup_layout(struct ct *t)
|
||||
CT_CHECK(t, numink > 0); /* full-width 9 */
|
||||
CT_CHECK(t, markink > 0); /* 9-9/9 */
|
||||
|
||||
/* The selected row wins over preedit and footer in one-row height. */
|
||||
dc.pre = mkstr("preedit");
|
||||
popuplayout(&dc, PopupBasew, 2*PopupPad + Fontsz, &p);
|
||||
CT_EQ_INT(t, -1, p.prey);
|
||||
CT_EQ_INT(t, 1, p.n);
|
||||
CT_EQ_INT(t, Maxdisp - 1, p.row0);
|
||||
CT_EQ_INT(t, -1, p.marky);
|
||||
|
||||
/* With less than one padded row, selected content starts at the top. */
|
||||
for(i = 0; i < nelem(tinyheight); i++){
|
||||
popuplayout(&dc, PopupBasew, tinyheight[i], &p);
|
||||
CT_EQ_INT(t, min(tinyheight[i], Fontsz), p.h);
|
||||
CT_EQ_INT(t, 0, p.rowsy);
|
||||
CT_EQ_INT(t, 0, p.sely);
|
||||
CT_EQ_INT(t, 1, p.n);
|
||||
CT_EQ_INT(t, Maxdisp - 1, p.row0);
|
||||
popupdraw(img, &dc, &p);
|
||||
CT_EQ_UINT(t, Colsel, pixel(img, &p, p.w - PopupPad - 1, 0));
|
||||
}
|
||||
free(img);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user