popup: show the candidate page
This commit is contained in:
@@ -694,7 +694,9 @@ checkcandidatepage(struct ct *t, char *where, int first, int n, int sel)
|
||||
show();
|
||||
if(!CT_CHECK(t, draindraw(&dc) > 0))
|
||||
return 0;
|
||||
if(!CT_EQ_INT(t, n, dc.nkouho) || !CT_EQ_INT(t, sel, dc.sel))
|
||||
if(!CT_EQ_INT(t, n, dc.nkouho) || !CT_EQ_INT(t, sel, dc.sel) ||
|
||||
!CT_EQ_INT(t, first, dc.first) ||
|
||||
!CT_EQ_INT(t, im.nkouho, dc.total))
|
||||
return 0;
|
||||
if(n == 0)
|
||||
return 1;
|
||||
@@ -705,6 +707,50 @@ checkcandidatepage(struct ct *t, char *where, int first, int n, int sel)
|
||||
return checkstr(t, where, want, &dc.kouho[n-1]);
|
||||
}
|
||||
|
||||
void
|
||||
engine_candidate_page_metadata(struct ct *t)
|
||||
{
|
||||
static const struct {
|
||||
int total;
|
||||
int sel;
|
||||
int first;
|
||||
int shown;
|
||||
int local;
|
||||
} cases[] = {
|
||||
{ 9, 8, 0, 9, 8 },
|
||||
{ 10, 8, 0, 9, 8 },
|
||||
{ 10, 9, 9, 1, 0 },
|
||||
{ 18, 8, 0, 9, 8 },
|
||||
{ 18, 17, 9, 9, 8 },
|
||||
{ 32, 8, 0, 9, 8 },
|
||||
{ 32, 17, 9, 9, 8 },
|
||||
{ 32, 26, 18, 9, 8 },
|
||||
{ 32, 31, 27, 5, 4 },
|
||||
};
|
||||
Drawcmd dc;
|
||||
int i;
|
||||
|
||||
/* A clearing draw is the observable zero-candidate snapshot. */
|
||||
candidatebegin(1);
|
||||
show();
|
||||
draindraw(nil);
|
||||
setcandidates(0);
|
||||
show();
|
||||
if(CT_CHECK(t, draindraw(&dc) > 0)){
|
||||
CT_EQ_INT(t, 0, dc.nkouho);
|
||||
CT_EQ_INT(t, -1, dc.sel);
|
||||
CT_EQ_INT(t, 0, dc.first);
|
||||
CT_EQ_INT(t, 0, dc.total);
|
||||
}
|
||||
|
||||
for(i = 0; i < nelem(cases); i++){
|
||||
candidatebegin(cases[i].total);
|
||||
im.sel = cases[i].sel;
|
||||
checkcandidatepage(t, "candidate page metadata",
|
||||
cases[i].first, cases[i].shown, cases[i].local);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
engine_candidate_page_snapshots(struct ct *t)
|
||||
{
|
||||
|
||||
@@ -4,8 +4,33 @@
|
||||
void
|
||||
popup_layout(struct ct *t)
|
||||
{
|
||||
static const struct {
|
||||
int first;
|
||||
int shown;
|
||||
int total;
|
||||
char *want;
|
||||
} markers[] = {
|
||||
{ 0, 0, 0, "" },
|
||||
{ 0, 9, 9, "" },
|
||||
{ 0, 9, 10, "1-9/10" },
|
||||
{ 9, 1, 10, "10-10/10" },
|
||||
{ 0, 9, 18, "1-9/18" },
|
||||
{ 9, 9, 18, "10-18/18" },
|
||||
{ 9, 9, 32, "10-18/32" },
|
||||
{ 18, 9, 32, "19-27/32" },
|
||||
{ 27, 5, 32, "28-32/32" },
|
||||
};
|
||||
char buf[32];
|
||||
Caret caret;
|
||||
int x, y;
|
||||
int i, n, x, y;
|
||||
|
||||
for(i = 0; i < nelem(markers); i++){
|
||||
n = pagemarker(buf, sizeof buf, markers[i].first,
|
||||
markers[i].shown, markers[i].total);
|
||||
CT_EQ_INT(t, strlen(markers[i].want), n);
|
||||
CT_CHECK(t, strcmp(markers[i].want, buf) == 0);
|
||||
}
|
||||
CT_EQ_INT(t, (1 + Maxdisp + 1) * Fontsz, Imgh);
|
||||
|
||||
memset(&caret, 0, sizeof caret);
|
||||
popupposition(&caret, 40, 50, 800, 600, 100, 60, &x, &y);
|
||||
|
||||
@@ -32,6 +32,7 @@ void engine_clears_candidates(struct ct*);
|
||||
void engine_backspace_clears_candidates(struct ct*);
|
||||
void engine_selects_visible_candidate(struct ct*);
|
||||
void engine_candidate_shortcut_modifiers(struct ct*);
|
||||
void engine_candidate_page_metadata(struct ct*);
|
||||
void engine_candidate_page_snapshots(struct ct*);
|
||||
void engine_candidate_page_movement(struct ct*);
|
||||
void engine_candidate_completion(struct ct*);
|
||||
|
||||
@@ -86,6 +86,7 @@ static const struct ct_test tests[] = {
|
||||
{ "engine/backspace-clears-candidates", engine_backspace_clears_candidates },
|
||||
{ "engine/selects-visible-candidate", engine_selects_visible_candidate },
|
||||
{ "engine/candidate-shortcut-modifiers", engine_candidate_shortcut_modifiers },
|
||||
{ "engine/candidate-page-metadata", engine_candidate_page_metadata },
|
||||
{ "engine/candidate-page-snapshots", engine_candidate_page_snapshots },
|
||||
{ "engine/candidate-page-movement", engine_candidate_page_movement },
|
||||
{ "engine/candidate-completion", engine_candidate_completion },
|
||||
|
||||
Reference in New Issue
Block a user