style: euqal -> equal

This commit is contained in:
Liu
2024-05-13 22:49:18 +08:00
parent 62ca908c81
commit 59e3220370
24 changed files with 787 additions and 752 deletions
+15 -15
View File
@@ -6,7 +6,7 @@
static void check_length(const char *str, css_numeric_value_t actual,
css_numeric_value_t expected)
{
ctest_euqal_int(str, (int)actual, (int)expected);
ctest_equal_int(str, (int)actual, (int)expected);
}
static test_button_focus_style(void)
@@ -19,10 +19,10 @@ static test_button_focus_style(void)
result = css_select_style(selector);
css_cascade_style(result, &computed);
ctest_euqal_str("content", computed.content, "submit");
ctest_equal_str("content", computed.content, "submit");
check_length("font-size", computed.font_size, 16);
check_length("min-width", computed.min_width, 80);
ctest_euqal_int("box-sizing", computed.type_bits.box_sizing,
ctest_equal_int("box-sizing", computed.type_bits.box_sizing,
CSS_BOX_SIZING_BORDER_BOX);
check_length("padding-left", computed.padding_left, 8);
@@ -35,18 +35,18 @@ static test_button_focus_style(void)
check_length("border-bottom-width", computed.border_bottom_width, 1);
check_length("border-left-width", computed.border_left_width, 1);
ctest_euqal_int("border-top-style", computed.type_bits.border_top_style,
ctest_equal_int("border-top-style", computed.type_bits.border_top_style,
CSS_BORDER_STYLE_SOLID);
ctest_euqal_int("border-right-style",
ctest_equal_int("border-right-style",
computed.type_bits.border_right_style,
CSS_BORDER_STYLE_SOLID);
ctest_euqal_int("border-bottom-style",
ctest_equal_int("border-bottom-style",
computed.type_bits.border_bottom_style,
CSS_BORDER_STYLE_SOLID);
ctest_euqal_int("border-left-style",
ctest_equal_int("border-left-style",
computed.type_bits.border_left_style,
CSS_BORDER_STYLE_SOLID);
ctest_euqal_uint("background-color", computed.background_color,
ctest_equal_uint("background-color", computed.background_color,
css_color(255, 0, 0x50, 0xc9));
check_length("border-top-left-radius", computed.border_top_left_radius,
@@ -61,7 +61,7 @@ static test_button_focus_style(void)
check_length("box-shadow-y", computed.box_shadow_y, 0);
check_length("box-shadow-blur", computed.box_shadow_blur, 0);
check_length("box-shadow-spread", computed.box_shadow_spread, 2);
ctest_euqal_uint("box-shadow-color", computed.box_shadow_color,
ctest_equal_uint("box-shadow-color", computed.box_shadow_color,
css_color(127, 0, 0, 200));
css_style_decl_destroy(result);
@@ -81,9 +81,9 @@ void test_container_style(void)
check_length("margin-top", computed.margin_top, 24);
check_length("margin-bottom", computed.margin_top, 24);
ctest_euqal_int("margin-left", computed.type_bits.margin_left,
ctest_equal_int("margin-left", computed.type_bits.margin_left,
CSS_MARGIN_AUTO);
ctest_euqal_int("margin-right", computed.type_bits.margin_right,
ctest_equal_int("margin-right", computed.type_bits.margin_right,
CSS_MARGIN_AUTO);
css_style_decl_destroy(result);
@@ -105,15 +105,15 @@ void test_button_borderless_style(void)
check_length("border-right-width", computed.border_right_width, 0);
check_length("border-bottom-width", computed.border_bottom_width, 0);
check_length("border-left-width", computed.border_left_width, 0);
ctest_euqal_int("border-top-style", computed.type_bits.border_top_style,
ctest_equal_int("border-top-style", computed.type_bits.border_top_style,
CSS_BORDER_STYLE_NONE);
ctest_euqal_int("border-right-style",
ctest_equal_int("border-right-style",
computed.type_bits.border_right_style,
CSS_BORDER_STYLE_NONE);
ctest_euqal_int("border-bottom-style",
ctest_equal_int("border-bottom-style",
computed.type_bits.border_bottom_style,
CSS_BORDER_STYLE_NONE);
ctest_euqal_int("border-left-style",
ctest_equal_int("border-left-style",
computed.type_bits.border_left_style,
CSS_BORDER_STYLE_NONE);
+2 -2
View File
@@ -8,7 +8,7 @@ static void test_keyword_value(const char *name, int value)
char str[256] = { 0 };
snprintf(str, 255, "keyword('%s').value", name);
ctest_euqal_int(str, css_get_keyword_key(name), value);
ctest_equal_int(str, css_get_keyword_key(name), value);
}
static void test_keyword_register(const char *name)
@@ -18,7 +18,7 @@ static void test_keyword_register(const char *name)
int b = css_get_keyword_key(name);
snprintf(str, 255, "keyword('%s')", name);
ctest_euqal_int(str, a, b);
ctest_equal_int(str, a, b);
}
void test_css_keywords(void)
+53 -53
View File
@@ -14,8 +14,8 @@ static void test_css_valdef_string(const css_valdef_t *valdef)
ret = val.array_value[0].type == CSS_STRING_VALUE;
}
css_style_value_destroy(&val);
ctest_euqal_bool("match('\"abc\"')", ret, 1);
ctest_euqal_bool("match('auto')", css_parse_value(valdef, "auto", &val) > 0, 1);
ctest_equal_bool("match('\"abc\"')", ret, 1);
ctest_equal_bool("match('auto')", css_parse_value(valdef, "auto", &val) > 0, 1);
css_style_value_destroy(&val);
}
@@ -31,7 +31,7 @@ static void test_css_valdef_color(const css_valdef_t *valdef)
}
css_style_value_destroy(&val);
ctest_euqal_uint("match('#fff')", (int)color, (int)css_color(255, 255, 255, 255));
ctest_equal_uint("match('#fff')", (int)color, (int)css_color(255, 255, 255, 255));
color = 0;
if (css_parse_value(valdef, "#ffffff", &val) > 0 &&
@@ -40,7 +40,7 @@ static void test_css_valdef_color(const css_valdef_t *valdef)
}
css_style_value_destroy(&val);
ctest_euqal_uint("match('#ffffff')", color, css_color(255, 255, 255, 255));
ctest_equal_uint("match('#ffffff')", color, css_color(255, 255, 255, 255));
color = 0;
if (css_parse_value(valdef, "transparent", &val) > 0 &&
@@ -49,7 +49,7 @@ static void test_css_valdef_color(const css_valdef_t *valdef)
}
css_style_value_destroy(&val);
ctest_euqal_uint("match('transparent')", color, CSS_COLOR_TRANSPARENT);
ctest_equal_uint("match('transparent')", color, CSS_COLOR_TRANSPARENT);
color = 0;
if (css_parse_value(valdef, "rgb(100, 200, 255)", &val) > 0 &&
@@ -58,7 +58,7 @@ static void test_css_valdef_color(const css_valdef_t *valdef)
}
css_style_value_destroy(&val);
ctest_euqal_uint("match('rgb(100, 200, 255)')", color,
ctest_equal_uint("match('rgb(100, 200, 255)')", color,
css_color(255, 100, 200, 255));
color = 0;
@@ -68,7 +68,7 @@ static void test_css_valdef_color(const css_valdef_t *valdef)
}
css_style_value_destroy(&val);
ctest_euqal_uint("match('rgba(100, 200, 255, 0.5)')", color,
ctest_equal_uint("match('rgba(100, 200, 255, 0.5)')", color,
css_color(127, 100, 200, 255));
}
@@ -84,8 +84,8 @@ static void test_css_valdef_none(const css_valdef_t *valdef)
css_get_keyword_key("none");
}
css_style_value_destroy(&val);
ctest_euqal_bool("match('none')", ret, 1);
ctest_euqal_bool("notMatch('auto')", css_parse_value(valdef, "auto", &val) <= 0, 1);
ctest_equal_bool("match('none')", ret, 1);
ctest_equal_bool("notMatch('auto')", css_parse_value(valdef, "auto", &val) <= 0, 1);
css_style_value_destroy(&val);
}
@@ -102,12 +102,12 @@ static void test_css_valdef_none_or_auto(const css_valdef_t *valdef)
}
css_style_value_destroy(&val);
ctest_euqal_bool("match('none')", ret, 1);
ctest_equal_bool("match('none')", ret, 1);
ret = css_parse_value(valdef, "auto", &val) > 0 &&
val.type == CSS_ARRAY_VALUE;
ctest_euqal_bool("match('auto')", ret, 1);
ctest_euqal_bool("notMatch('normal')", css_parse_value(valdef, "normal", &val) <= 0,
ctest_equal_bool("match('auto')", ret, 1);
ctest_equal_bool("notMatch('normal')", css_parse_value(valdef, "normal", &val) <= 0,
1);
css_style_value_destroy(&val);
}
@@ -117,15 +117,15 @@ static void test_css_valdef_border(const css_valdef_t *valdef)
int ret;
css_style_value_t val = { 0 };
ctest_euqal_bool("match('1px solid #eee')",
ctest_equal_bool("match('1px solid #eee')",
css_parse_value(valdef, "1px solid #eee", &val) > 0, 1);
css_style_value_destroy(&val);
ctest_euqal_bool("match('#eee 1px solid')",
ctest_equal_bool("match('#eee 1px solid')",
css_parse_value(valdef, "#eee 1px solid", &val) > 0, 1);
css_style_value_destroy(&val);
ctest_euqal_bool("match('solid #eee 1px')",
ctest_equal_bool("match('solid #eee 1px')",
css_parse_value(valdef, "solid #eee 1px", &val) > 0, 1);
css_style_value_destroy(&val);
@@ -135,7 +135,7 @@ static void test_css_valdef_border(const css_valdef_t *valdef)
ret = val.array_value[0].type == CSS_UNIT_VALUE &&
val.array_value[0].unit_value.value == 1.;
}
ctest_euqal_bool("match('1px')", ret, 1);
ctest_equal_bool("match('1px')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "solid", &val) > 0 &&
@@ -145,13 +145,13 @@ static void test_css_valdef_border(const css_valdef_t *valdef)
val.array_value[0].keyword_value ==
css_get_keyword_key("solid");
}
ctest_euqal_bool("match('solid')", ret, 1);
ctest_equal_bool("match('solid')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "#eee", &val) > 0 &&
val.type == CSS_ARRAY_VALUE;
ret = val.array_value[0].color_value == 0xffeeeeee;
ctest_euqal_bool("match('#eee')", ret, 1);
ctest_equal_bool("match('#eee')", ret, 1);
css_style_value_destroy(&val);
}
@@ -160,31 +160,31 @@ static void test_css_valdef_border_2(const css_valdef_t *valdef)
int ret;
css_style_value_t val = { 0 };
ctest_euqal_bool("match('1px solid #eee')",
ctest_equal_bool("match('1px solid #eee')",
css_parse_value(valdef, "1px solid #eee", &val) > 0, 1);
css_style_value_destroy(&val);
ctest_euqal_bool("match('#eee 1px solid')",
ctest_equal_bool("match('#eee 1px solid')",
css_parse_value(valdef, "#eee 1px solid", &val) > 0, 1);
css_style_value_destroy(&val);
ctest_euqal_bool("match('solid #eee 1px')",
ctest_equal_bool("match('solid #eee 1px')",
css_parse_value(valdef, "solid #eee 1px", &val) > 0, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE;
ctest_euqal_bool("notMatch('1px')", ret, 0);
ctest_equal_bool("notMatch('1px')", ret, 0);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "solid", &val) > 0 &&
val.type == CSS_ARRAY_VALUE;
ctest_euqal_bool("notMatch('solid')", ret, 0);
ctest_equal_bool("notMatch('solid')", ret, 0);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "#eee", &val) > 0 &&
val.type == CSS_ARRAY_VALUE;
ctest_euqal_bool("notMatch('#eee')", ret, 0);
ctest_equal_bool("notMatch('#eee')", ret, 0);
css_style_value_destroy(&val);
}
@@ -192,31 +192,31 @@ static void test_css_valdef_box_shadow(const css_valdef_t *valdef)
{
css_style_value_t val = { 0 };
ctest_euqal_bool("match('none')",
ctest_equal_bool("match('none')",
css_parse_value(valdef, "none", &val) > 0 &&
val.array_value[0].keyword_value == CSS_KEYWORD_NONE,
1);
css_style_value_destroy(&val);
ctest_euqal_bool("match('0 0')",
ctest_equal_bool("match('0 0')",
css_parse_value(valdef, "0 0", &val) > 0 &&
css_style_value_get_array_length(&val) == 2,
1);
css_style_value_destroy(&val);
ctest_euqal_bool("match('0 0 4px')",
ctest_equal_bool("match('0 0 4px')",
css_parse_value(valdef, "0 0 4px", &val) > 0 &&
css_style_value_get_array_length(&val) == 3,
1);
css_style_value_destroy(&val);
ctest_euqal_bool("match('0 0 4px #000')",
ctest_equal_bool("match('0 0 4px #000')",
css_parse_value(valdef, "0 0 4px #000", &val) > 0 &&
css_style_value_get_array_length(&val) == 4,
1);
css_style_value_destroy(&val);
ctest_euqal_bool(
ctest_equal_bool(
"match('0 0 6px rgba(33,150,243,0.4)')",
css_parse_value(valdef, "0 0 6px rgba(33,150,243,0.4)", &val) > 0 &&
css_style_value_get_array_length(&val) == 4 &&
@@ -234,11 +234,11 @@ static void test_css_valdef_length_2(const css_valdef_t *valdef)
ret = css_parse_value(valdef, "1px 2px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 2;
ctest_euqal_bool("match('1px 2px')", ret, 1);
ctest_equal_bool("match('1px 2px')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px", &val) != 0;
ctest_euqal_bool("notMatch('1px')", ret, 1);
ctest_equal_bool("notMatch('1px')", ret, 1);
css_style_value_destroy(&val);
}
@@ -248,37 +248,37 @@ static void test_css_valdef_length_1_4(const css_valdef_t *valdef)
css_style_value_t val = { 0 };
ret = css_parse_value(valdef, "", &val) <= 0;
ctest_euqal_bool("notMatch('')", ret, 1);
ctest_equal_bool("notMatch('')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 1;
ctest_euqal_bool("match('1px')", ret, 1);
ctest_equal_bool("match('1px')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px 2px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 2;
ctest_euqal_bool("match('1px 2px')", ret, 1);
ctest_equal_bool("match('1px 2px')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px 2px 3px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 3;
ctest_euqal_bool("match('1px 2px 3px')", ret, 1);
ctest_equal_bool("match('1px 2px 3px')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px 2px 3px 4px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 4;
ctest_euqal_bool("match('1px 2px 3px 4px')", ret, 1);
ctest_equal_bool("match('1px 2px 3px 4px')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px 2px 3px 4px 5px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 4;
ctest_euqal_bool("Match('1px 2px 3px 4px 5px')", ret, 1);
ctest_equal_bool("Match('1px 2px 3px 4px 5px')", ret, 1);
css_style_value_destroy(&val);
}
@@ -288,61 +288,61 @@ static void test_css_valdef_length_percentage_1_4(const css_valdef_t *valdef)
css_style_value_t val = { 0 };
ret = css_parse_value(valdef, "", &val) <= 0;
ctest_euqal_bool("notMatch('')", ret, 1);
ctest_equal_bool("notMatch('')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 1;
ctest_euqal_bool("match('1px')", ret, 1);
ctest_equal_bool("match('1px')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 1;
ctest_euqal_bool("match('50%')", ret, 1);
ctest_equal_bool("match('50%')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px 2px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 2;
ctest_euqal_bool("match('1px 2px')", ret, 1);
ctest_equal_bool("match('1px 2px')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px 2px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 2;
ctest_euqal_bool("match('50% 50%')", ret, 1);
ctest_equal_bool("match('50% 50%')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px 2px 3px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 3;
ctest_euqal_bool("match('1px 2px 3px')", ret, 1);
ctest_equal_bool("match('1px 2px 3px')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px 2px 3px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 3;
ctest_euqal_bool("match('50% 50% 50%')", ret, 1);
ctest_equal_bool("match('50% 50% 50%')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px 2px 3px 4px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 4;
ctest_euqal_bool("match('1px 2px 3px 4px')", ret, 1);
ctest_equal_bool("match('1px 2px 3px 4px')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px 2px 3px 4px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 4;
ctest_euqal_bool("match('50% 50% 50% 50%')", ret, 1);
ctest_equal_bool("match('50% 50% 50% 50%')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "1px 2px 3px 4px 5px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 4;
ctest_euqal_bool("Match('1px 2px 3px 4px 5px')", ret, 1);
ctest_equal_bool("Match('1px 2px 3px 4px 5px')", ret, 1);
css_style_value_destroy(&val);
}
@@ -355,19 +355,19 @@ static void test_css_valdef_background_position(const css_valdef_t *valdef)
ret = css_parse_value(valdef, "center", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 1;
ctest_euqal_bool("match('center')", ret, 1);
ctest_equal_bool("match('center')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "10px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 1;
ctest_euqal_bool("match('10px')", ret, 1);
ctest_equal_bool("match('10px')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "50%", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 1;
ctest_euqal_bool("match('50%')", ret, 1);
ctest_equal_bool("match('50%')", ret, 1);
css_style_value_destroy(&val);
if (css_parse_value(valdef, "top center", &val) > 0) {
@@ -376,13 +376,13 @@ static void test_css_valdef_background_position(const css_valdef_t *valdef)
} else {
ret = 0;
}
ctest_euqal_bool("match('top center')", ret, 1);
ctest_equal_bool("match('top center')", ret, 1);
css_style_value_destroy(&val);
ret = css_parse_value(valdef, "bottom 10px right 20px", &val) > 0 &&
val.type == CSS_ARRAY_VALUE &&
css_style_value_get_array_length(&val) == 4;
ctest_euqal_bool("match('bottom 10px right 20px')", ret, 1);
ctest_equal_bool("match('bottom 10px right 20px')", ret, 1);
css_style_value_destroy(&val);
}
@@ -399,7 +399,7 @@ static void test_css_valdef(const char *definition,
if (valdef) {
func(valdef);
} else {
ctest_euqal_bool("should be able to parse", 0, 1);
ctest_equal_bool("should be able to parse", 0, 1);
}
ctest_group_end();
ctest_printf("\n");
+5 -5
View File
@@ -17,11 +17,11 @@ int ctest_uint_to_str(void *data, char *str, unsigned max_len);
int ctest_float_to_str(void *data, char *str, unsigned max_len);
int ctest_str_to_str(void *data, char *str, unsigned max_len);
int ctest_bool_to_str(void *data, char *str, unsigned max_len);
bool ctest_euqal_int(const char *name, int actual, int expected);
bool ctest_euqal_bool(const char *name, bool actual, bool expected);
bool ctest_euqal_uint(const char *name, unsigned actual, unsigned expected);
bool ctest_euqal_float(const char *name, float actual, float expected);
bool ctest_euqal_str(const char *name, const char *actual,
bool ctest_equal_int(const char *name, int actual, int expected);
bool ctest_equal_bool(const char *name, bool actual, bool expected);
bool ctest_equal_uint(const char *name, unsigned actual, unsigned expected);
bool ctest_equal_float(const char *name, float actual, float expected);
bool ctest_equal_str(const char *name, const char *actual,
const char *expected);
int ctest_finish(void);
+5 -5
View File
@@ -110,27 +110,27 @@ int ctest_bool_to_str(void *data, char *str, unsigned max_len)
return snprintf(str, max_len, "%s", *(bool*)data ? "true" : "false");
}
bool ctest_euqal_int(const char *name, int actual, int expected)
bool ctest_equal_int(const char *name, int actual, int expected)
{
return ctest_equal(name, ctest_int_to_str, &actual, &expected);
}
bool ctest_euqal_bool(const char *name, bool actual, bool expected)
bool ctest_equal_bool(const char *name, bool actual, bool expected)
{
return ctest_equal(name, ctest_bool_to_str, &actual, &expected);
}
bool ctest_euqal_uint(const char *name, unsigned actual, unsigned expected)
bool ctest_equal_uint(const char *name, unsigned actual, unsigned expected)
{
return ctest_equal(name, ctest_uint_to_str, &actual, &expected);
}
bool ctest_euqal_float(const char *name, float actual, float expected)
bool ctest_equal_float(const char *name, float actual, float expected)
{
return ctest_equal(name, ctest_float_to_str, &actual, &expected);
}
bool ctest_euqal_str(const char *name, const char *actual, const char *expected)
bool ctest_equal_str(const char *name, const char *actual, const char *expected)
{
return ctest_equal(name, ctest_str_to_str, (void *)actual, (void *)expected);
}
+10 -10
View File
@@ -7,44 +7,44 @@ void test_i18n(void)
wchar_t lang[32];
len = i18n_detect_language(lang, 32);
ctest_euqal_bool("i18n_detect_language()", len > 0, true);
ctest_euqal_bool(
ctest_equal_bool("i18n_detect_language()", len > 0, true);
ctest_equal_bool(
"i18n_load_language(L\"zh-CN\", \"locales/zh-CN.yml\")",
i18n_load_language(L"zh-CN", "locales/zh-CN.yml"), true);
ctest_euqal_bool("i18n_load_language(L\"en\", \"locales/en.yml\")",
ctest_equal_bool("i18n_load_language(L\"en\", \"locales/en.yml\")",
i18n_load_language(L"en", "locales/en.yml"),
true);
ctest_euqal_bool(
ctest_equal_bool(
"i18n_load_language(L\"notfound\", \"locales/notfound.yml\")",
i18n_load_language(L"notfound", "locales/notfound.yml"), false);
i18n_change_language(L"en");
ctest_euqal_bool("i18n_translate(L\"name\") == L\"English\")",
ctest_equal_bool("i18n_translate(L\"name\") == L\"English\")",
wcscmp(i18n_translate(L"name"), L"English") == 0,
true);
ctest_euqal_bool("i18n_translate(L\"button.ok\") == L\"Ok\")",
ctest_equal_bool("i18n_translate(L\"button.ok\") == L\"Ok\")",
wcscmp(i18n_translate(L"button.ok"), L"Ok") == 0,
true);
ctest_euqal_bool("i18n_translate(L\"button.notfound\") == NULL)",
ctest_equal_bool("i18n_translate(L\"button.notfound\") == NULL)",
i18n_translate(L"button.notfound")== NULL,
true);
i18n_change_language(L"zh-CN");
ctest_euqal_bool("i18n_translate(L\"name\") == L\"中文\")",
ctest_equal_bool("i18n_translate(L\"name\") == L\"中文\")",
wcscmp(i18n_translate(L"name"), L"中文") == 0,
true);
ctest_euqal_bool("i18n_translate(L\"button.ok\") == L\"确定\")",
ctest_equal_bool("i18n_translate(L\"button.ok\") == L\"确定\")",
wcscmp(i18n_translate(L"button.ok"), L"确定") == 0,
true);
ctest_euqal_bool("i18n_translate(L\"button.notfound\") == NULL)",
ctest_equal_bool("i18n_translate(L\"button.notfound\") == NULL)",
i18n_translate(L"button.notfound")== NULL,
true);
i18n_clear();
+4 -4
View File
@@ -39,20 +39,20 @@ void test_canvas_mix(void)
pd_canvas_mix(&red_layer, &blue_layer, 10, 10, PD_TRUE);
pixel = pd_canvas_pixel_at(&red_layer, 15, 15);
color2str(rgba_str, pixel);
ctest_euqal_str("red_layer(15, 15)", rgba_str, "rgba(50, 0, 204, 1)");
ctest_equal_str("red_layer(15, 15)", rgba_str, "rgba(50, 0, 204, 1)");
pd_canvas_mix(&white_layer, &red_layer, 10, 10, PD_TRUE);
pixel = pd_canvas_pixel_at(&white_layer, 0, 0);
color2str(rgba_str, pixel);
ctest_euqal_str("white_layer(0, 0)", rgba_str, "rgba(255, 255, 255, 1)");
ctest_equal_str("white_layer(0, 0)", rgba_str, "rgba(255, 255, 255, 1)");
pixel = pd_canvas_pixel_at(&white_layer, 15, 15);
color2str(rgba_str, pixel);
ctest_euqal_str("white_layer(15, 15)", rgba_str, "rgba(255, 127, 127, 1)");
ctest_equal_str("white_layer(15, 15)", rgba_str, "rgba(255, 127, 127, 1)");
pixel = pd_canvas_pixel_at(&white_layer, 25, 25);
color2str(rgba_str, pixel);
ctest_euqal_str("white_layer(25, 25)", rgba_str, "rgba(152, 127, 229, 1)");
ctest_equal_str("white_layer(25, 25)", rgba_str, "rgba(152, 127, 229, 1)");
pd_canvas_destroy(&white_layer);
pd_canvas_destroy(&red_layer);
+88 -88
View File
@@ -16,13 +16,13 @@ void test_router_location(void)
location = router_location_normalize(raw, NULL, FALSE);
str = strmap_get(location->query, "type");
ctest_euqal_str("location.query.type", str, "issue");
ctest_equal_str("location.query.type", str, "issue");
str = strmap_get(location->query, "order");
ctest_euqal_str("location.query.order", str, "desc");
ctest_equal_str("location.query.order", str, "desc");
str = location->path;
ctest_euqal_str("location.path", str, "/search");
ctest_equal_str("location.path", str, "/search");
router_location_destroy(raw);
router_location_destroy(location);
@@ -31,7 +31,7 @@ void test_router_location(void)
location = router_location_normalize(raw, NULL, FALSE);
str = location->hash;
ctest_euqal_str("location.hash", str, "#pagination");
ctest_equal_str("location.hash", str, "#pagination");
router_location_destroy(raw);
router_location_destroy(location);
@@ -45,7 +45,7 @@ void test_router_location(void)
router_location_set_param(raw, "user", "foo");
router_location_set_param(raw, "repo", "bar");
location = router_location_normalize(raw, route, FALSE);
ctest_euqal_str(
ctest_equal_str(
"normalize({ params: { user: 'foo', repo: 'bar' } }).path",
router_location_get_path(location), "/repos/foo/bar/issues");
router_location_destroy(raw);
@@ -55,7 +55,7 @@ void test_router_location(void)
router_location_set_param(raw, "user", "root");
router_location_set_param(raw, "repo", "example");
location = router_location_normalize(raw, route, FALSE);
ctest_euqal_str(
ctest_equal_str(
"normalize({ params: { user: 'root', repo: 'example' } }).path",
router_location_get_path(location), "/repos/root/example/issues");
router_location_destroy(raw);
@@ -66,7 +66,7 @@ void test_router_location(void)
router_location_set_query(raw, "state", "closed");
location = router_location_normalize(raw, route, FALSE);
path = router_location_stringify(location);
ctest_euqal_str(
ctest_equal_str(
"stringify(normalize({ query: { q: 'bug', state: 'closed' } }))",
path, "/repos/root/example/issues?q=bug&state=closed");
free(path);
@@ -78,7 +78,7 @@ void test_router_location(void)
router_location_set_query(raw, "assignee", "root");
location = router_location_normalize(raw, route, FALSE);
path = router_location_stringify(location);
ctest_euqal_str("stringify(normalize({ query: { order: 'desc', "
ctest_equal_str("stringify(normalize({ query: { order: 'desc', "
"assignee: 'root' } }))",
path,
"/repos/root/example/issues?order=desc&assignee=root");
@@ -102,19 +102,19 @@ void test_router_route(void)
location = router_location_normalize(raw, NULL, FALSE);
route = router_route_create(NULL, location);
ctest_euqal_str("route.path", router_route_get_path(route),
ctest_equal_str("route.path", router_route_get_path(route),
"/user/profile");
ctest_euqal_str("route.query.q", router_route_get_query(route, "q"),
ctest_equal_str("route.query.q", router_route_get_query(route, "q"),
"test");
ctest_euqal_str("route.query.tab", router_route_get_query(route, "tab"),
ctest_equal_str("route.query.tab", router_route_get_query(route, "tab"),
"repos");
ctest_euqal_str("route.query.order",
ctest_equal_str("route.query.order",
router_route_get_query(route, "order"), "desc");
ctest_euqal_str("route.query.other",
ctest_equal_str("route.query.other",
router_route_get_query(route, "other"), NULL);
ctest_euqal_str("route.hash", router_route_get_hash(route),
ctest_equal_str("route.hash", router_route_get_hash(route),
"#pagination");
ctest_euqal_str("route.fullPath.length",
ctest_equal_str("route.fullPath.length",
router_route_get_full_path(route), full_path);
router_location_destroy(raw);
router_location_destroy(location);
@@ -199,13 +199,13 @@ void test_router_matcher(void)
router_location_destroy(location);
route = router_resolved_get_route(resolved);
str = router_route_get_param(route, "username");
ctest_euqal_str("match('/users/root').route.params.username", str,
ctest_equal_str("match('/users/root').route.params.username", str,
"root");
router_resolved_destroy(resolved);
location = router_location_create("user#posts", NULL);
resolved = router_resolve(router, location, FALSE);
ctest_euqal_bool("match({ name: 'user#posts' })", !resolved, FALSE);
ctest_equal_bool("match({ name: 'user#posts' })", !resolved, FALSE);
router_location_destroy(location);
router_resolved_destroy(resolved);
@@ -214,12 +214,12 @@ void test_router_matcher(void)
router_location_destroy(location);
location = router_location_create("user#posts", NULL);
resolved = router_resolve(router, location, FALSE);
ctest_euqal_bool("match({ name: 'user#posts' })", !!resolved, TRUE);
ctest_equal_bool("match({ name: 'user#posts' })", !!resolved, TRUE);
route = router_resolved_get_route(resolved);
str = router_route_get_param(route, "username");
ctest_euqal_str("match({ name: 'user#posts' }).route.params.username",
ctest_equal_str("match({ name: 'user#posts' }).route.params.username",
router_route_get_param(route, "username"), "root");
ctest_euqal_str("match({ name: 'user#posts' }).route.fullPath",
ctest_equal_str("match({ name: 'user#posts' }).route.fullPath",
router_route_get_full_path(route), "/users/root/posts");
router_location_destroy(location);
router_resolved_destroy(resolved);
@@ -229,17 +229,17 @@ void test_router_matcher(void)
router_location_destroy(location);
route = router_resolved_get_route(resolved);
record = router_route_get_matched_record(route, 0);
ctest_euqal_bool("match('/users/root/posts').route.matched[0] != null",
ctest_equal_bool("match('/users/root/posts').route.matched[0] != null",
!!record, TRUE);
ctest_euqal_str(
ctest_equal_str(
"match('/users/root/posts').route.matched[0].components.default",
record ? router_route_record_get_component(record, NULL) : NULL,
"user-show");
route = router_resolved_get_route(resolved);
record = router_route_get_matched_record(route, 1);
ctest_euqal_bool("match('/users/root/posts').route.matched[1] != null",
ctest_equal_bool("match('/users/root/posts').route.matched[1] != null",
!!record, TRUE);
ctest_euqal_str(
ctest_equal_str(
"match('/users/root/posts').route.matched[1].components.default",
record ? router_route_record_get_component(record, NULL) : NULL,
"user-posts");
@@ -250,14 +250,14 @@ void test_router_matcher(void)
router_location_destroy(location);
route = router_resolved_get_route(resolved);
record = router_route_get_matched_record(route, 0);
ctest_euqal_bool(
ctest_equal_bool(
"match('/other/path/to/file').route.matched[0] != null", !!record,
TRUE);
ctest_euqal_str(
ctest_equal_str(
"match('/other/path/to/file').route.matched[0].components.default",
record ? router_route_record_get_component(record, NULL) : NULL,
"not-found");
ctest_euqal_str(
ctest_equal_str(
"match('/other/path/to/file').route.params.pathMatch",
route ? router_route_get_param(route, "pathMatch") : NULL,
"other/path/to/file");
@@ -268,11 +268,11 @@ void test_router_matcher(void)
router_location_destroy(location);
route = router_resolved_get_route(resolved);
record = router_route_get_matched_record(route, 0);
ctest_euqal_str(
ctest_equal_str(
"match('/files/path/to/file').route.matched[0].components.default",
record ? router_route_record_get_component(record, NULL) : NULL,
"files");
ctest_euqal_str(
ctest_equal_str(
"match('/files/path/to/file').route.params.pathMatch",
route ? router_route_get_param(route, "pathMatch") : NULL,
"path/to/file");
@@ -298,112 +298,112 @@ void test_router_utils(void)
strmap_set(a, "name", "git");
strmap_set(b, "name", "git");
ctest_euqal_bool(
ctest_equal_bool(
"isObjectEqual({ id: '404', name: 'git' }, { id: '404', name: "
"'git' })",
strmap_equal(a, b), TRUE);
strmap_set(b, "id", "200");
ctest_euqal_bool(
ctest_equal_bool(
"isObjectEqual({ id: '404', name: 'git' }, { id: '200', name: "
"'git' })",
strmap_equal(a, b), FALSE);
strmap_delete(b, "id");
ctest_euqal_bool(
ctest_equal_bool(
"isObjectIncludes({ id: '404', name: 'git' }, { name: 'git' })",
strmap_includes(a, b), TRUE);
strmap_delete(a, "name");
ctest_euqal_bool("isObjectIncludes({ id: '404' }, { name: '200' })",
ctest_equal_bool("isObjectIncludes({ id: '404' }, { name: '200' })",
strmap_includes(a, b), FALSE);
strmap_delete(a, "id");
strmap_delete(b, "name");
ctest_euqal_bool("isObjectEqual({}, {})", strmap_equal(a, b), TRUE);
ctest_euqal_int("string.compare('', '')", router_string_compare("", ""),
ctest_equal_bool("isObjectEqual({}, {})", strmap_equal(a, b), TRUE);
ctest_equal_int("string.compare('', '')", router_string_compare("", ""),
0);
ctest_euqal_bool("string.compare(null, 'a') != 0",
ctest_equal_bool("string.compare(null, 'a') != 0",
router_string_compare(NULL, "a") != 0, TRUE);
ctest_euqal_int("string.compare(null, null)",
ctest_equal_int("string.compare(null, null)",
router_string_compare(NULL, NULL), 0);
strmap_destroy(a);
strmap_destroy(b);
str = router_path_resolve("", NULL, TRUE);
ctest_euqal_str("path.resolve('', null, true) == '/'", str, "/");
ctest_equal_str("path.resolve('', null, true) == '/'", str, "/");
free(str);
str = router_path_resolve("", "/root", TRUE);
ctest_euqal_str("path.resolve('', '/root', true)", str, "/root");
ctest_equal_str("path.resolve('', '/root', true)", str, "/root");
free(str);
str = router_path_resolve("hello/../world/./", NULL, TRUE);
ctest_euqal_str("path.resolve('hello/../world/./', null, true)", str,
ctest_equal_str("path.resolve('hello/../world/./', null, true)", str,
"/world");
free(str);
str = router_path_resolve("/root/path", "base/path", TRUE);
ctest_euqal_str("path.resolve('/root/path', 'base/path', true)", str,
ctest_equal_str("path.resolve('/root/path', 'base/path', true)", str,
"/root/path");
free(str);
str = router_path_resolve("../../profile", "base/path/to/file", TRUE);
ctest_euqal_str(
ctest_equal_str(
"path.resolve('../../profile', 'base/path/to/file', true)", str,
"/base/path/profile");
free(str);
str = router_path_resolve("profile", "base/file", FALSE);
ctest_euqal_str("path.resolve('profile', 'base/profile', false)", str,
ctest_equal_str("path.resolve('profile', 'base/profile', false)", str,
"/base/profile");
free(str);
str = router_path_resolve("/profile", "base/file", FALSE);
ctest_euqal_str("path.resolve('/profile', 'base/profile', false)", str,
ctest_equal_str("path.resolve('/profile', 'base/profile', false)", str,
"/profile");
free(str);
ctest_euqal_bool("path.compare('/a/b', '/a/b/')",
ctest_equal_bool("path.compare('/a/b', '/a/b/')",
router_path_compare("/a/b", "/a/b/"), TRUE);
ctest_euqal_bool("path.compare('/a/b/', '/a/b/')",
ctest_equal_bool("path.compare('/a/b/', '/a/b/')",
router_path_compare("/a/b/", "/a/b"), TRUE);
ctest_euqal_bool("path.compare('', '')",
ctest_equal_bool("path.compare('', '')",
router_path_compare("", "") == 0, TRUE);
ctest_euqal_bool("path.compare('a', '')",
ctest_equal_bool("path.compare('a', '')",
router_path_compare("a", "") != 0, TRUE);
ctest_euqal_bool("path.compare('', 'b')",
ctest_equal_bool("path.compare('', 'b')",
router_path_compare("", "b") != 0, TRUE);
ctest_euqal_bool("path.compare('a', 'b')",
ctest_equal_bool("path.compare('a', 'b')",
router_path_compare("a", "b") != 0, TRUE);
ctest_euqal_bool(
ctest_equal_bool(
"path.startsWith('/profile/events', '/profile/event')",
router_path_starts_with("/profile/events", "/profile/event"),
FALSE);
ctest_euqal_bool(
ctest_equal_bool(
"path.startsWith('/profile/events', '/profile/')",
router_path_starts_with("/profile/events", "/profile/"), TRUE);
ctest_euqal_bool("path.startsWith('/profile', '/profile/')",
ctest_equal_bool("path.startsWith('/profile', '/profile/')",
router_path_starts_with("/profile", "/profile/"),
TRUE);
ctest_euqal_bool("path.startsWith('/profile/', '/profile')",
ctest_equal_bool("path.startsWith('/profile/', '/profile')",
router_path_starts_with("/profile/", "/profile"),
TRUE);
p = str = "/:username/:repo/settings";
p = router_path_parse_key(p, key, &key_len);
ctest_euqal_str("path.keys('/:username/:repo/settings')[0].key", key,
ctest_equal_str("path.keys('/:username/:repo/settings')[0].key", key,
"username");
ctest_euqal_int("path.keys('/:username/:repo/settings')[0].index",
ctest_equal_int("path.keys('/:username/:repo/settings')[0].index",
(int)(p ? p - str : 0), 11);
p = router_path_parse_key(p, key, &key_len);
ctest_euqal_str("path.keys('/:username/:repo/settings')[1].key", key,
ctest_equal_str("path.keys('/:username/:repo/settings')[1].key", key,
"repo");
ctest_euqal_int("path.keys('/:username/:repo/settings')[1].index",
ctest_equal_int("path.keys('/:username/:repo/settings')[1].index",
(int)(p ? p - str : 0), 17);
p = router_path_parse_key(p, key, &key_len);
ctest_euqal_str("path.keys('/:username/:repo/settings')[2].key", key,
ctest_equal_str("path.keys('/:username/:repo/settings')[2].key", key,
"");
ctest_euqal_int("path.keys('/:username/:repo/settings')[2].index",
ctest_equal_int("path.keys('/:username/:repo/settings')[2].index",
(int)(p ? p - str : -1), -1);
params = strmap_create();
@@ -412,21 +412,21 @@ void test_router_utils(void)
strmap_set(params, "3", "three");
strmap_set(params, "word", "good");
str = router_path_fill_params("/:1/:2/:3/foo", params);
ctest_euqal_str(
ctest_equal_str(
"path.fillParams('/:1/:2/:3/foo', { 1: 'one', 2: 'two', 3: "
"'three' })",
str, "/one/two/three/foo");
free(str);
str = router_path_fill_params("/:1:2:3/foo", params);
ctest_euqal_str(
ctest_equal_str(
"path.fillParams('/:1:2:3/foo', { 1: 'one', 2: 'two', 3: "
"'three' })",
str, NULL);
strmap_destroy(params);
str = router_path_fill_params("/foo/bar", NULL);
ctest_euqal_str("path.fillParams('/foo/bar')", str, "/foo/bar");
ctest_equal_str("path.fillParams('/foo/bar')", str, "/foo/bar");
free(str);
}
@@ -461,94 +461,94 @@ void test_router_history(void)
location = router_location_create(NULL, "/foo/bar");
router_push(router, location);
route = router_get_current_route(router);
ctest_euqal_str("router.push('/foo/bar'), router.currentRoute.path",
ctest_equal_str("router.push('/foo/bar'), router.currentRoute.path",
router_route_get_path(route), "/foo/bar");
router_location_destroy(location);
location = router_location_create(NULL, "/bar");
router_push(router, location);
route = router_get_current_route(router);
ctest_euqal_str("router.push('/bar'), router.currentRoute.path",
ctest_equal_str("router.push('/bar'), router.currentRoute.path",
router_route_get_path(route), "/bar");
router_location_destroy(location);
location = router_location_create(NULL, "/foo");
router_push(router, location);
route = router_get_current_route(router);
ctest_euqal_str("router.push('/foo'), router.currentRoute.path",
ctest_equal_str("router.push('/foo'), router.currentRoute.path",
router_route_get_path(route), "/foo");
router_location_destroy(location);
ctest_euqal_int("router.history.index",
ctest_equal_int("router.history.index",
(int)router_history_get_index(history), 2);
router_back(router);
route = router_get_current_route(router);
ctest_euqal_str("router.back(), router.currentRoute.path",
ctest_equal_str("router.back(), router.currentRoute.path",
router_route_get_path(route), "/bar");
router_back(router);
route = router_get_current_route(router);
ctest_euqal_str("router.back(), router.currentRoute.path",
ctest_equal_str("router.back(), router.currentRoute.path",
router_route_get_path(route), "/foo/bar");
router_back(router);
route = router_get_current_route(router);
ctest_euqal_str("router.back(), router.currentRoute.path",
ctest_equal_str("router.back(), router.currentRoute.path",
router_route_get_path(route), "/foo/bar");
router_forward(router);
route = router_get_current_route(router);
ctest_euqal_str("router.forward(), router.currentRoute.path",
ctest_equal_str("router.forward(), router.currentRoute.path",
router_route_get_path(route), "/bar");
router_back(router);
router_go(router, 100);
route = router_get_current_route(router);
ctest_euqal_str(
ctest_equal_str(
"router.back(), router.go(100), router.currentRoute.path",
router_route_get_path(route), "/foo");
router_go(router, -2);
route = router_get_current_route(router);
ctest_euqal_str(
ctest_equal_str(
"router.back(), router.go(-2), router.currentRoute.path",
router_route_get_path(route), "/foo/bar");
router_go(router, -100);
route = router_get_current_route(router);
ctest_euqal_str(
ctest_equal_str(
"router.back(), router.go(-100), router.currentRoute.path",
router_route_get_path(route), "/foo/bar");
location = router_location_create(NULL, "/bar");
ctest_euqal_int("router.history.length",
ctest_equal_int("router.history.length",
(int)router_history_get_length(history), 3);
router_push(router, location);
ctest_euqal_int("router.push('/bar'), router.history.length",
ctest_equal_int("router.push('/bar'), router.history.length",
(int)router_history_get_length(history), 2);
router_location_destroy(location);
location = router_location_create(NULL, "/foo");
router_replace(router, location);
route = router_get_current_route(router);
ctest_euqal_str("router.replace('/foo'), router.currentRoute.path",
ctest_equal_str("router.replace('/foo'), router.currentRoute.path",
router_route_get_path(route), "/foo");
router_location_destroy(location);
router_back(router);
route = router_get_current_route(router);
ctest_euqal_str("router.back(), router.currentRoute.path",
ctest_equal_str("router.back(), router.currentRoute.path",
router_route_get_path(route), "/foo/bar");
router_forward(router);
route = router_get_current_route(router);
ctest_euqal_str("router.forward(), router.currentRoute.path",
ctest_equal_str("router.forward(), router.currentRoute.path",
router_route_get_path(route), "/foo");
router_forward(router);
route = router_get_current_route(router);
ctest_euqal_str("router.forward(), router.currentRoute.path",
ctest_equal_str("router.forward(), router.currentRoute.path",
router_route_get_path(route), "/foo");
router_destroy(router);
@@ -609,18 +609,18 @@ void test_router_components(void)
ui_event_init(&e, "click");
ui_widget_emit_event(link_foo, e, NULL);
matched_widget = ui_router_view_get_matched_widget(view);
ctest_euqal_bool("[/foo] <router-view> widget should load <foo> widget",
ctest_equal_bool("[/foo] <router-view> widget should load <foo> widget",
strcmp(matched_widget->type, "foo") == 0, TRUE);
ctest_euqal_bool(
ctest_equal_bool(
"[/foo] linkFoo should has active classes",
(ui_widget_has_class(link_foo, "router-link-active") &&
ui_widget_has_class(link_foo, "router-link-exact-active")),
TRUE);
ui_widget_emit_event(link_bar, e, NULL);
matched_widget = ui_router_view_get_matched_widget(view);
ctest_euqal_bool("[/bar] <router-view> widget should load <bar> widget",
ctest_equal_bool("[/bar] <router-view> widget should load <bar> widget",
strcmp(matched_widget->type, "bar") == 0, TRUE);
ctest_euqal_bool(
ctest_equal_bool(
"[/bar] linkFoo should not has active classes",
(!ui_widget_has_class(link_foo, "router-link-exact-active") &&
!ui_widget_has_class(link_foo, "router-link-active")),
@@ -628,22 +628,22 @@ void test_router_components(void)
ui_widget_emit_event(link_foobar, e, NULL);
matched_widget = ui_router_view_get_matched_widget(view);
ctest_euqal_bool(
ctest_equal_bool(
"[/foo/bar] <router-view> widget should load <foobar> widget",
strcmp(matched_widget->type, "foobar") == 0, TRUE);
ctest_euqal_bool(
ctest_equal_bool(
"[/foo/bar] linkFooBar should has active classes",
(ui_widget_has_class(link_foobar, "router-link-exact-active") &&
ui_widget_has_class(link_foobar, "router-link-active")),
TRUE);
ctest_euqal_bool(
ctest_equal_bool(
"[/foo/bar] linkFoo should only has the exact active class",
(!ui_widget_has_class(link_foo, "router-link-exact-active") &&
ui_widget_has_class(link_foo, "router-link-active")),
TRUE);
ui_widget_set_attr(link_foo, "exact", "exact");
ui_widget_emit_event(link_foobar, e, NULL);
ctest_euqal_bool(
ctest_equal_bool(
"[/foo/bar] linkFoo should not has any active classes (exact)",
(!ui_widget_has_class(link_foo, "router-link-exact-active") &&
!ui_widget_has_class(link_foo, "router-link-active")),
+108 -108
View File
@@ -7,11 +7,11 @@ static void test_dropdown(void)
int width, height;
w = ui_get_widget("test-dropdown-menu");
ctest_euqal_bool("$('#test-dropdown-menu')[0].border_box.height < 200",
ctest_equal_bool("$('#test-dropdown-menu')[0].border_box.height < 200",
w->border_box.width < 200, TRUE);
ctest_euqal_bool("$('#test-dropdown-menu')[0].border_box.width > 100",
ctest_equal_bool("$('#test-dropdown-menu')[0].border_box.width > 100",
w->border_box.width > 100, TRUE);
ctest_euqal_int("$('#test-dropdown-menu')[0].border_box.height",
ctest_equal_int("$('#test-dropdown-menu')[0].border_box.height",
(int)w->border_box.height, 142);
w = ui_widget_get_child(w, 0);
@@ -19,21 +19,21 @@ static void test_dropdown(void)
height = (int)w->border_box.height;
w = ui_widget_next(w);
ctest_euqal_int("$('#test-dropdown-menu .dropdown-item')[1].border_box.width",
ctest_equal_int("$('#test-dropdown-menu .dropdown-item')[1].border_box.width",
(int)w->border_box.width, width);
ctest_euqal_int("$('#test-dropdown-menu .dropdown-item')[1].border_box.height",
ctest_equal_int("$('#test-dropdown-menu .dropdown-item')[1].border_box.height",
(int)w->border_box.height, height);
w = ui_widget_next(w);
ctest_euqal_int("$('#test-dropdown-menu .dropdown-item')[2].border_box.width",
ctest_equal_int("$('#test-dropdown-menu .dropdown-item')[2].border_box.width",
(int)w->border_box.width, width);
ctest_euqal_int("$('#test-dropdown-menu .dropdown-item')[2].border_box.height",
ctest_equal_int("$('#test-dropdown-menu .dropdown-item')[2].border_box.height",
(int)w->border_box.height, height);
w = ui_widget_next(w);
ctest_euqal_int("$('#test-dropdown-menu .dropdown-item')[3].border_box.width",
ctest_equal_int("$('#test-dropdown-menu .dropdown-item')[3].border_box.width",
(int)w->border_box.width, width);
ctest_euqal_int("$('#test-dropdown-menu .dropdown-item')[3].border_box.height",
ctest_equal_int("$('#test-dropdown-menu .dropdown-item')[3].border_box.height",
(int)w->border_box.height, height);
}
@@ -54,18 +54,18 @@ static void test_auto_size(void)
rect.y = 5;
rect.width = 200;
rect.height = 50;
ctest_euqal_ui_rect("$('#test-text-auto-height')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#test-text-auto-height')[0].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
ctest_euqal_int("$('#test-text-auto-size')[0].border_box.y", (int)w->border_box.y,
ctest_equal_int("$('#test-text-auto-size')[0].border_box.y", (int)w->border_box.y,
5 + 50);
w = ui_widget_next(w);
ctest_euqal_int("$('#test-text-block-auto-height')[0].border_box.y",
ctest_equal_int("$('#test-text-block-auto-height')[0].border_box.y",
(int)w->border_box.y, 5 + 50 + 31);
ctest_euqal_int("$('.example')[2].border_box.height",
ctest_equal_int("$('.example')[2].border_box.height",
(int)example->border_box.height, 166);
// Update #test-text-auto-size content
@@ -77,20 +77,20 @@ static void test_auto_size(void)
L"long long long long long long long long long long long long "
L"long long text");
ui_update();
ctest_euqal_int("$('#test-text-auto-size')[0].border_box.x", (int)w->border_box.x,
ctest_equal_int("$('#test-text-auto-size')[0].border_box.x", (int)w->border_box.x,
5);
ctest_euqal_int("$('#test-text-auto-size')[0].border_box.y", (int)w->border_box.y,
ctest_equal_int("$('#test-text-auto-size')[0].border_box.y", (int)w->border_box.y,
5 + 50);
ctest_euqal_bool("$('#test-text-auto-size')[0].border_box.width <= 758",
ctest_equal_bool("$('#test-text-auto-size')[0].border_box.width <= 758",
w->border_box.width < 758.f, TRUE);
ctest_euqal_int("$('#test-text-auto-size')[0].border_box.height",
ctest_equal_int("$('#test-text-auto-size')[0].border_box.height",
(int)w->border_box.height, 50);
w = ui_widget_next(w);
ctest_euqal_int("$('#test-text-block-auto-height')[0].border_box.y",
ctest_equal_int("$('#test-text-block-auto-height')[0].border_box.y",
(int)w->border_box.y, 5 + 50 + 50);
ctest_euqal_int("$('.example')[2].border_box.height",
ctest_equal_int("$('.example')[2].border_box.height",
(int)example->border_box.height, 185);
// Update test-text-block-auto-height content
@@ -106,7 +106,7 @@ static void test_auto_size(void)
rect.y = 5 + 50 + 50;
rect.width = 758;
rect.height = 50;
ctest_euqal_ui_rect("$('#test-text-block-auto-height')[0].border_box",
ctest_equal_ui_rect("$('#test-text-block-auto-height')[0].border_box",
&w->border_box, &rect);
}
@@ -120,7 +120,7 @@ static void test_inline_block_nesting(void)
rect.y = 5;
rect.width = ui_widget_get_child(w, 0)->border_box.width * 2;
rect.height = 31 * 3;
ctest_euqal_ui_rect("$('#example-inline-block-nesting__block-1')[0].border_box",
ctest_equal_ui_rect("$('#example-inline-block-nesting__block-1')[0].border_box",
&w->border_box, &rect);
w = ui_widget_get_child(w, 1);
@@ -128,7 +128,7 @@ static void test_inline_block_nesting(void)
rect.height = 31;
rect.x = rect.width;
rect.y = 0;
ctest_euqal_ui_rect(
ctest_equal_ui_rect(
"$('#example-inline-block-nesting__block-1 .box')[1].border_box",
&w->border_box, &rect);
@@ -136,13 +136,13 @@ static void test_inline_block_nesting(void)
rect.width = rect.width * 2;
rect.x = 0;
rect.y = 31;
ctest_euqal_ui_rect(
ctest_equal_ui_rect(
"$('#example-inline-block-nesting__block-1 .box')[2].border_box",
&w->border_box, &rect);
w = ui_widget_next(w);
rect.y = 31 * 2;
ctest_euqal_ui_rect(
ctest_equal_ui_rect(
"$('#example-inline-block-nesting__block-1 .box')[3].border_box",
&w->border_box, &rect);
@@ -152,7 +152,7 @@ static void test_inline_block_nesting(void)
rect.x = w->parent->computed_style.padding_left;
rect.x += w->parent->content_box.width - rect.width;
rect.y = 5;
ctest_euqal_ui_rect("$('#example-inline-block-nesting__block-2')[0].border_box",
ctest_equal_ui_rect("$('#example-inline-block-nesting__block-2')[0].border_box",
&w->border_box, &rect);
}
@@ -161,7 +161,7 @@ static void test_absolutely_positioned_progress_bar(void)
ui_widget_t *w;
w = ui_get_widget("example-progress-bar__bar");
ctest_euqal_int("It should have the correct width", (int)w->border_box.width,
ctest_equal_int("It should have the correct width", (int)w->border_box.width,
(int)(w->parent->content_box.width * 0.5));
}
@@ -182,42 +182,42 @@ static void test_block_layout_1280(void)
rect.width = 780;
rect.height = 404;
w = ui_widget_get_child(container, 0);
ctest_euqal_ui_rect("$('.example')[0].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[0].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 304;
w = ui_widget_get_child(container, 1);
ctest_euqal_ui_rect("$('.example')[1].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[1].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 147;
w = ui_widget_get_child(container, 2);
ctest_euqal_ui_rect("$('.example')[2].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[2].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 550;
w = ui_widget_get_child(container, 3);
ctest_euqal_ui_rect("$('.example')[3].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[3].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 4);
ctest_euqal_ui_rect("$('.example')[4].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[4].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 254;
w = ui_widget_get_child(container, 5);
ctest_euqal_ui_rect("$('.example')[5].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[5].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 6);
ctest_euqal_ui_rect("$('.example')[6].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[6].border_box", &w->border_box, &rect);
w = ui_get_widget("example-inline-block-nesting");
rect.y += rect.height + 10;
rect.height = 147;
ctest_euqal_ui_rect("$('#example-inline-block-nesting')[0].border_box",
ctest_equal_ui_rect("$('#example-inline-block-nesting')[0].border_box",
&w->border_box, &rect);
example = ui_widget_get_child(container, 0);
@@ -227,21 +227,21 @@ static void test_block_layout_1280(void)
rect.height = 50;
rect.x = content->computed_style.padding_left;
rect.y = 150 + content->computed_style.padding_top;
ctest_euqal_ui_rect("$('.example:eq(0) .box')[13].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(0) .box')[13].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x = content->content_box.width - 150.f;
rect.x += content->computed_style.padding_left;
rect.y += 50;
ctest_euqal_ui_rect("$('.example:eq(0) .box.ml-auto')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(0) .box.ml-auto')[0].border_box",
&w->border_box, &rect);
w = ui_widget_next(w);
rect.x = (content->content_box.width - 150.f) / 2.f;
rect.x += content->computed_style.padding_left;
rect.y += 50;
ctest_euqal_ui_rect("$('.example:eq(0) .box.ml-auto.mr-auto')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(0) .box.ml-auto.mr-auto')[0].border_box",
&w->border_box, &rect);
example = ui_widget_get_child(container, 1);
@@ -251,51 +251,51 @@ static void test_block_layout_1280(void)
rect.y = content->computed_style.padding_top;
rect.width = content->content_box.width * 0.5f;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[0].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.y += 50;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[1].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[1].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.y += 50;
rect.width = content->content_box.width;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[2].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[2].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.y += 50;
rect.width = content->content_box.width * 0.5f;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[3].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[3].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[4].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[4].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.y += 50;
rect.x = content->computed_style.padding_left;
rect.width = content->content_box.width * 0.25f;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[5].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[5].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[6].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[6].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[7].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[7].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[8].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[8].border_box", &w->border_box,
&rect);
example = ui_widget_get_child(container, 3);
@@ -309,7 +309,7 @@ static void test_block_layout_1280(void)
rect.width -=
w->computed_style.margin_left + w->computed_style.margin_right;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(3) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[0].border_box", &w->border_box,
&rect);
w = ui_widget_get_child(content, 5);
@@ -317,21 +317,21 @@ static void test_block_layout_1280(void)
rect.y = content->computed_style.padding_top + rect.height + 32;
rect.width = 50;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(3) .box')[5].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[5].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width - 8;
rect.y += 8;
rect.width = 150;
ctest_euqal_ui_rect("$('.example:eq(3) .box')[6].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[6].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width + w->computed_style.margin_left + 8;
rect.y -= 8;
rect.width = 100;
ctest_euqal_ui_rect("$('.example:eq(3 .box')[7].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3 .box')[7].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
@@ -340,7 +340,7 @@ static void test_block_layout_1280(void)
(8 + 50 + 8) - 16;
rect.width = content->content_box.width + 32;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(3) .box')[8].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[8].border_box", &w->border_box,
&rect);
content = ui_widget_get_child(ui_widget_get_child(example, 1), 1);
@@ -349,32 +349,32 @@ static void test_block_layout_1280(void)
rect.y = content->computed_style.padding_top;
rect.width = content->content_box.width;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(3) .box')[9].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[9].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += w->computed_style.margin_left;
rect.y += 50;
rect.width -= w->computed_style.margin_left;
ctest_euqal_ui_rect("$('.example:eq(3) .box')[10].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[10].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.y += 50;
rect.width = content->content_box.width + 16;
ctest_euqal_ui_rect("$('.example:eq(3) .box.ml--1.mr--1')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(3) .box.ml--1.mr--1')[0].border_box",
&w->border_box, &rect);
w = ui_widget_next(w);
rect.y += 50;
rect.width = 200;
ctest_euqal_ui_rect("$('.example:eq(3) .box.ml--1.mr--1')[1].border_box",
ctest_equal_ui_rect("$('.example:eq(3) .box.ml--1.mr--1')[1].border_box",
&w->border_box, &rect);
w = ui_widget_next(w);
rect.y += 50;
rect.width = content->content_box.width;
ctest_euqal_ui_rect("$('.example:eq(3) .box.ml--1.mr--1')[2].border_box",
ctest_equal_ui_rect("$('.example:eq(3) .box.ml--1.mr--1')[2].border_box",
&w->border_box, &rect);
example = ui_widget_get_child(container, 5);
@@ -385,29 +385,29 @@ static void test_block_layout_1280(void)
rect.y = 0;
rect.width = 100;
rect.height = 100;
ctest_euqal_ui_rect("$('#box-absolute-top-left')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#box-absolute-top-left')[0].border_box", &w->border_box,
&rect);
w = ui_get_widget("box-absolute-top-right");
rect.x = content->padding_box.width - rect.width;
ctest_euqal_ui_rect("$('#box-absolute-top-right')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#box-absolute-top-right')[0].border_box", &w->border_box,
&rect);
w = ui_get_widget("box-absolute-center");
rect.x = (content->padding_box.width - rect.width) * 0.5f;
rect.y = (content->padding_box.height - rect.height) * 0.5f;
ctest_euqal_ui_rect("$('#box-absolute-center')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#box-absolute-center')[0].border_box", &w->border_box,
&rect);
w = ui_get_widget("box-absolute-bottom-left");
rect.x = 0;
rect.y = content->padding_box.height - rect.height;
ctest_euqal_ui_rect("$('#box-absolute-bottom-left')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#box-absolute-bottom-left')[0].border_box", &w->border_box,
&rect);
w = ui_get_widget("box-absolute-bottom-right");
rect.x = content->padding_box.width - rect.width;
ctest_euqal_ui_rect("$('#box-absolute-bottom-right')[0].border_box",
ctest_equal_ui_rect("$('#box-absolute-bottom-right')[0].border_box",
&w->border_box, &rect);
// (2) Auto size
@@ -417,19 +417,19 @@ static void test_block_layout_1280(void)
rect.y = 5;
rect.width = 200;
rect.height = 31;
ctest_euqal_ui_rect("$('#test-text-auto-height')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#test-text-auto-height')[0].border_box", &w->border_box,
&rect);
w = ui_get_widget("test-text-auto-size");
ctest_euqal_bool("$('#test-text-auto-size')[0].width < 140px",
ctest_equal_bool("$('#test-text-auto-size')[0].width < 140px",
w->border_box.width < 170, TRUE);
ctest_euqal_int("$('#test-text-auto-size')[0].height", (int)w->border_box.height,
ctest_equal_int("$('#test-text-auto-size')[0].height", (int)w->border_box.height,
31);
w = ui_get_widget("test-text-block-auto-height");
ctest_euqal_int("$('#test-text-block-auto-height')[0].width",
ctest_equal_int("$('#test-text-block-auto-height')[0].width",
(int)w->border_box.width, 758);
ctest_euqal_int("$('#test-text-block-auto-height')[0].height",
ctest_equal_int("$('#test-text-block-auto-height')[0].height",
(int)w->border_box.height, 31);
ctest_describe("test auto size", test_auto_size);
@@ -456,32 +456,32 @@ static void test_block_layout_600(void)
rect.width = 600 - 20 - 14;
rect.height = 504;
w = ui_widget_get_child(container, 0);
ctest_euqal_ui_rect("$('.example')[0].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[0].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 304;
w = ui_widget_get_child(container, 1);
ctest_euqal_ui_rect("$('.example')[1].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[1].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 204;
w = ui_widget_get_child(container, 2);
ctest_euqal_ui_rect("$('.example')[2].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[2].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 600;
w = ui_widget_get_child(container, 3);
ctest_euqal_ui_rect("$('.example')[3].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[3].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 4);
ctest_euqal_ui_rect("$('.example')[4].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[4].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 254;
w = ui_widget_get_child(container, 5);
ctest_euqal_ui_rect("$('.example')[5].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[5].border_box", &w->border_box, &rect);
example = ui_widget_get_child(container, 0);
content = ui_widget_get_child(example, 1);
@@ -490,7 +490,7 @@ static void test_block_layout_600(void)
rect.height = 50;
rect.x = content->computed_style.padding_left;
rect.y = 100 + content->computed_style.padding_top;
ctest_euqal_ui_rect("$('.example:eq(0) .box')[11].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(0) .box')[11].border_box", &w->border_box,
&rect);
w = ui_widget_get_child(content, 14);
@@ -498,14 +498,14 @@ static void test_block_layout_600(void)
rect.x = content->computed_style.padding_left;
rect.x += content->content_box.width - rect.width;
rect.y = 250 + content->computed_style.padding_top;
ctest_euqal_ui_rect("$('.example:eq(0) .box')[14].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(0) .box')[14].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x = content->computed_style.padding_left;
rect.x += (content->content_box.width - rect.width) / 2.f;
rect.y += 50;
ctest_euqal_ui_rect("$('.example:eq(0) .box')[15].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(0) .box')[15].border_box", &w->border_box,
&rect);
w = ui_widget_get_child(content, 26);
@@ -513,7 +513,7 @@ static void test_block_layout_600(void)
rect.y = content->computed_style.padding_top + 400;
rect.width = 50;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(0) .box')[26].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(0) .box')[26].border_box", &w->border_box,
&rect);
example = ui_widget_get_child(container, 1);
@@ -523,51 +523,51 @@ static void test_block_layout_600(void)
rect.y = content->computed_style.padding_top;
rect.width = content->content_box.width * 0.5f;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[0].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.y += 50;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[1].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[1].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.y += 50;
rect.width = content->content_box.width;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[2].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[2].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.y += 50;
rect.width = content->content_box.width * 0.5f;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[3].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[3].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[4].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[4].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.y += 50;
rect.x = content->computed_style.padding_left;
rect.width = content->content_box.width * 0.25f;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[5].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[5].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[6].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[6].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[7].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[7].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[8].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[8].border_box", &w->border_box,
&rect);
example = ui_widget_get_child(container, 3);
@@ -579,7 +579,7 @@ static void test_block_layout_600(void)
content->computed_style.padding_top + (16 + 50 + 16) + (8 + 50 + 8);
rect.width = 100;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(3) .box')[7].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[7].border_box", &w->border_box,
&rect);
content = ui_widget_get_child(ui_widget_get_child(example, 1), 1);
@@ -588,7 +588,7 @@ static void test_block_layout_600(void)
rect.y = content->computed_style.padding_top + 200;
rect.width = content->content_box.width;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(3) .box')[13].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[13].border_box", &w->border_box,
&rect);
example = ui_widget_get_child(container, 5);
@@ -599,29 +599,29 @@ static void test_block_layout_600(void)
rect.y = 0;
rect.width = 100;
rect.height = 100;
ctest_euqal_ui_rect("$('#box-absolute-top-left')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#box-absolute-top-left')[0].border_box", &w->border_box,
&rect);
w = ui_get_widget("box-absolute-top-right");
rect.x = content->padding_box.width - rect.width;
ctest_euqal_ui_rect("$('#box-absolute-top-right')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#box-absolute-top-right')[0].border_box", &w->border_box,
&rect);
w = ui_get_widget("box-absolute-center");
rect.x = (content->padding_box.width - rect.width) * 0.5f;
rect.y = (content->padding_box.height - rect.height) * 0.5f;
ctest_euqal_ui_rect("$('#box-absolute-center')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#box-absolute-center')[0].border_box", &w->border_box,
&rect);
w = ui_get_widget("box-absolute-bottom-left");
rect.x = 0;
rect.y = content->padding_box.height - rect.height;
ctest_euqal_ui_rect("$('#box-absolute-bottom-left')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#box-absolute-bottom-left')[0].border_box", &w->border_box,
&rect);
w = ui_get_widget("box-absolute-bottom-right");
rect.x = content->padding_box.width - rect.width;
ctest_euqal_ui_rect("$('#box-absolute-bottom-right')[0].border_box",
ctest_equal_ui_rect("$('#box-absolute-bottom-right')[0].border_box",
&w->border_box, &rect);
}
@@ -642,32 +642,32 @@ static void test_block_layout_320(void)
rect.width = 320 - 20 - 14;
rect.height = 604;
w = ui_widget_get_child(container, 0);
ctest_euqal_ui_rect("$('.example')[0].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[0].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 304;
w = ui_widget_get_child(container, 1);
ctest_euqal_ui_rect("$('.example')[1].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[1].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 280;
w = ui_widget_get_child(container, 2);
ctest_euqal_ui_rect("$('.example')[2].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[2].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 732;
w = ui_widget_get_child(container, 3);
ctest_euqal_ui_rect("$('.example')[3].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[3].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 504;
w = ui_widget_get_child(container, 4);
ctest_euqal_ui_rect("$('.example')[4].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[4].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 254;
w = ui_widget_get_child(container, 5);
ctest_euqal_ui_rect("$('.example')[5].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[5].border_box", &w->border_box, &rect);
example = ui_widget_get_child(container, 0);
content = ui_widget_get_child(example, 1);
@@ -677,7 +677,7 @@ static void test_block_layout_320(void)
rect.y = content->computed_style.padding_top + 150;
rect.width = 50;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(0) .box')[11].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(0) .box')[11].border_box", &w->border_box,
&rect);
w = ui_widget_get_child(content, 14);
@@ -685,14 +685,14 @@ static void test_block_layout_320(void)
rect.x = content->computed_style.padding_left;
rect.x += content->content_box.width - rect.width;
rect.y = content->computed_style.padding_top + 300;
ctest_euqal_ui_rect("$('.example:eq(0) .box')[14].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(0) .box')[14].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x = content->computed_style.padding_left;
rect.x += (content->content_box.width - rect.width) / 2.f;
rect.y += 50;
ctest_euqal_ui_rect("$('.example:eq(0) .box')[15].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(0) .box')[15].border_box", &w->border_box,
&rect);
w = ui_widget_get_child(content, 26);
@@ -700,7 +700,7 @@ static void test_block_layout_320(void)
rect.y = content->computed_style.padding_top + 500;
rect.width = 50;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(0) .box')[26].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(0) .box')[26].border_box", &w->border_box,
&rect);
example = ui_widget_get_child(container, 3);
@@ -711,7 +711,7 @@ static void test_block_layout_320(void)
3 * (8 + 50 + 8);
rect.width = 100;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(3) .box')[7].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[7].border_box", &w->border_box,
&rect);
example = ui_widget_get_child(container, 5);
@@ -722,29 +722,29 @@ static void test_block_layout_320(void)
rect.y = 0;
rect.width = 100;
rect.height = 100;
ctest_euqal_ui_rect("$('#box-absolute-top-left')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#box-absolute-top-left')[0].border_box", &w->border_box,
&rect);
w = ui_get_widget("box-absolute-top-right");
rect.x = content->padding_box.width - rect.width;
ctest_euqal_ui_rect("$('#box-absolute-top-right')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#box-absolute-top-right')[0].border_box", &w->border_box,
&rect);
w = ui_get_widget("box-absolute-center");
rect.x = (content->padding_box.width - rect.width) * 0.5f;
rect.y = (content->padding_box.height - rect.height) * 0.5f;
ctest_euqal_ui_rect("$('#box-absolute-center')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#box-absolute-center')[0].border_box", &w->border_box,
&rect);
w = ui_get_widget("box-absolute-bottom-left");
rect.x = 0;
rect.y = content->padding_box.height - rect.height;
ctest_euqal_ui_rect("$('#box-absolute-bottom-left')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('#box-absolute-bottom-left')[0].border_box", &w->border_box,
&rect);
w = ui_get_widget("box-absolute-bottom-right");
rect.x = content->padding_box.width - rect.width;
ctest_euqal_ui_rect("$('#box-absolute-bottom-right')[0].border_box",
ctest_equal_ui_rect("$('#box-absolute-bottom-right')[0].border_box",
&w->border_box, &rect);
}
+1 -1
View File
@@ -38,7 +38,7 @@ static void on_check_text(ui_widget_t *w, ui_event_t *e, void *arg)
if (clipboard && clipboard->text) {
encode_utf8(actual_text, clipboard->text, 31);
}
ctest_euqal_str("check the pasted text", actual_text, "helloworld");
ctest_equal_str("check the pasted text", actual_text, "helloworld");
lcui_quit();
}
+106 -106
View File
@@ -19,81 +19,81 @@ static void test_flex_layout_with_content_width(float width)
rect.width = width;
rect.height = 104;
w = ui_widget_get_child(container, 0);
ctest_euqal_ui_rect("$('.example')[0].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[0].border_box", &w->border_box, &rect);
rect.y += 114;
w = ui_widget_get_child(container, 1);
ctest_euqal_ui_rect("$('.example')[1].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[1].border_box", &w->border_box, &rect);
rect.y += 114;
w = ui_widget_get_child(container, 2);
ctest_euqal_ui_rect("$('.example')[2].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[2].border_box", &w->border_box, &rect);
rect.y += 114;
w = ui_widget_get_child(container, 3);
ctest_euqal_ui_rect("$('.example')[3].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[3].border_box", &w->border_box, &rect);
rect.y += 114;
w = ui_widget_get_child(container, 4);
ctest_euqal_ui_rect("$('.example')[4].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[4].border_box", &w->border_box, &rect);
rect.y += 114;
w = ui_widget_get_child(container, 5);
ctest_euqal_ui_rect("$('.example')[5].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[5].border_box", &w->border_box, &rect);
rect.y += 114;
w = ui_widget_get_child(container, 6);
ctest_euqal_ui_rect("$('.example')[6].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[6].border_box", &w->border_box, &rect);
rect.y += 114;
rect.height = 344;
w = ui_widget_get_child(container, 7);
ctest_euqal_ui_rect("$('.example')[7].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[7].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 204;
w = ui_widget_get_child(container, 8);
ctest_euqal_ui_rect("$('.example')[8].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[8].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 9);
ctest_euqal_ui_rect("$('.example')[9].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[9].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 10);
ctest_euqal_ui_rect("$('.example')[10].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[10].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 11);
ctest_euqal_ui_rect("$('.example')[11].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[11].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 12);
ctest_euqal_ui_rect("$('.example')[12].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[12].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 13);
ctest_euqal_ui_rect("$('.example')[13].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[13].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 254;
w = ui_widget_get_child(container, 14);
ctest_euqal_ui_rect("$('.example')[14].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[14].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 185;
w = ui_widget_get_child(container, 15);
ctest_euqal_ui_rect("$('.example')[15].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[15].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 16);
ctest_euqal_ui_rect("$('.example')[16].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[16].border_box", &w->border_box, &rect);
// (1) justify-content: center;;
@@ -104,7 +104,7 @@ static void test_flex_layout_with_content_width(float width)
rect.y = 5;
rect.width = 50;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[0].border_box", &w->border_box,
&rect);
// (2) justify-content: flex-end;
@@ -113,7 +113,7 @@ static void test_flex_layout_with_content_width(float width)
content = ui_widget_get_child(example, 1);
w = ui_widget_get_child(content, 0);
rect.x = 5 + (content_width - 300);
ctest_euqal_ui_rect("$('.example:eq(2) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(2) .box')[0].border_box", &w->border_box,
&rect);
// (3) justify-content: space-between;
@@ -122,17 +122,17 @@ static void test_flex_layout_with_content_width(float width)
content = ui_widget_get_child(example, 1);
w = ui_widget_get_child(content, 0);
rect.x = 5;
ctest_euqal_ui_rect("$('.example:eq(3) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[0].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x = 5 + 50 + (content_width - 300) / 5.f;
ctest_euqal_ui_rect("$('.example:eq(3) .box')[1].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[1].border_box", &w->border_box,
&rect);
w = ui_widget_get_child(content, 5);
rect.x = 5 + (content_width - 50);
ctest_euqal_ui_rect("$('.example:eq(3) .box')[5].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[5].border_box", &w->border_box,
&rect);
// (4) justify-content: space-around;
@@ -141,17 +141,17 @@ static void test_flex_layout_with_content_width(float width)
content = ui_widget_get_child(example, 1);
w = ui_widget_get_child(content, 0);
rect.x = 5 + (content_width - 300) / 6.f / 2.f;
ctest_euqal_ui_rect("$('.example:eq(4) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(4) .box')[0].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += 50 + (content_width - 300) / 6.f;
ctest_euqal_ui_rect("$('.example:eq(4) .box')[1].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(4) .box')[1].border_box", &w->border_box,
&rect);
w = ui_widget_get_child(content, 5);
rect.x = 5 + content_width - (content_width - 300) / 6.f / 2.f - 50;
ctest_euqal_ui_rect("$('.example:eq(4) .box')[5].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(4) .box')[5].border_box", &w->border_box,
&rect);
// (5) Auto margin
@@ -160,22 +160,22 @@ static void test_flex_layout_with_content_width(float width)
content = ui_widget_get_child(example, 1);
w = ui_widget_get_child(content, 0);
rect.x = 5;
ctest_euqal_ui_rect("$('.example:eq(5) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(5) .box')[0].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += 50 + (content_width - 200) / 2.f;
ctest_euqal_ui_rect("$('.example:eq(5) .box')[1].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(5) .box')[1].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += 50;
ctest_euqal_ui_rect("$('.example:eq(5) .box')[2].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(5) .box')[2].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += 50 + (content_width - 200) / 2.f;
ctest_euqal_ui_rect("$('.example:eq(5) .box')[3].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(5) .box')[3].border_box", &w->border_box,
&rect);
// (7) flex-grow
@@ -185,17 +185,17 @@ static void test_flex_layout_with_content_width(float width)
w = ui_widget_get_child(content, 0);
rect.x = 5;
rect.width = content_width / 3.f;
ctest_euqal_ui_rect("$('.example:eq(7) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(7) .box')[0].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
ctest_euqal_ui_rect("$('.example:eq(7) .box')[1].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(7) .box')[1].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
ctest_euqal_ui_rect("$('.example:eq(7) .box')[2].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(7) .box')[2].border_box", &w->border_box,
&rect);
// line 1
@@ -204,7 +204,7 @@ static void test_flex_layout_with_content_width(float width)
w = ui_widget_get_child(content, 0);
rect.x = 5;
rect.width = content_width - 50 - 50;
ctest_euqal_ui_rect("$('.example:eq(7) .box')[3].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(7) .box')[3].border_box", &w->border_box,
&rect);
// line 2
@@ -213,12 +213,12 @@ static void test_flex_layout_with_content_width(float width)
w = ui_widget_get_child(content, 0);
rect.x = 5;
rect.width = (content_width - 50) / 2.f;
ctest_euqal_ui_rect("$('.example:eq(7) .box')[6].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(7) .box')[6].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
ctest_euqal_ui_rect("$('.example:eq(7) .box')[7].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(7) .box')[7].border_box", &w->border_box,
&rect);
// line 3
@@ -226,12 +226,12 @@ static void test_flex_layout_with_content_width(float width)
content = ui_widget_get_child(example, 4);
w = ui_widget_get_child(content, 1);
rect.x = 5 + 50;
ctest_euqal_ui_rect("$('.example:eq(7) .box')[10].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(7) .box')[10].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
ctest_euqal_ui_rect("$('.example:eq(7) .box')[11].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(7) .box')[11].border_box", &w->border_box,
&rect);
// line 4
@@ -240,19 +240,19 @@ static void test_flex_layout_with_content_width(float width)
w = ui_widget_get_child(content, 0);
rect.x = 5;
rect.width = 12 + (content_width - 3 * 12) * 4.f / 7.f;
ctest_euqal_ui_rect("$('.example:eq(7) .box')[12].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(7) .box')[12].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
rect.width = 12 + (content_width - 3 * 12) * 2.f / 7.f;
ctest_euqal_ui_rect("$('.example:eq(7) .box')[13].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(7) .box')[13].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
rect.width = 12 + (content_width - 3 * 12) / 7.f;
ctest_euqal_ui_rect("$('.example:eq(7) .box')[14].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(7) .box')[14].border_box", &w->border_box,
&rect);
// (10) align-items: center; height: 300px;
@@ -263,12 +263,12 @@ static void test_flex_layout_with_content_width(float width)
rect.x = 5;
rect.y = 5 + (300 / 3.f - 50) / 2.f;
rect.width = 50;
ctest_euqal_ui_rect("$('.example:eq(10) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(10) .box')[0].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += 50;
ctest_euqal_ui_rect("$('.example:eq(10) .box')[1].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(10) .box')[1].border_box", &w->border_box,
&rect);
// (11) align-items: end; height: 300px;
@@ -279,12 +279,12 @@ static void test_flex_layout_with_content_width(float width)
rect.x = 5;
rect.y = 5 + (300 / 3.f - 50);
rect.width = 50;
ctest_euqal_ui_rect("$('.example:eq(11) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(11) .box')[0].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += 50;
ctest_euqal_ui_rect("$('.example:eq(11) .box')[1].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(11) .box')[1].border_box", &w->border_box,
&rect);
// (12) align-items: stretch; height: 300px;
@@ -296,19 +296,19 @@ static void test_flex_layout_with_content_width(float width)
rect.y = 5;
rect.width = 50;
rect.height = 100;
ctest_euqal_ui_rect("$('.example:eq(12) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(12) .box')[0].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += 50;
ctest_euqal_ui_rect("$('.example:eq(12) .box')[1].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(12) .box')[1].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
w = ui_widget_next(w);
rect.x = 5 + 3 * 50;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(12) .box')[3].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(12) .box')[3].border_box", &w->border_box,
&rect);
// (13) Vertically Centered Layout
@@ -320,7 +320,7 @@ static void test_flex_layout_with_content_width(float width)
rect.y = 5 + (300 - 50) / 2.f;
rect.width = 50;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(13) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(13) .box')[0].border_box", &w->border_box,
&rect);
// (14) flex-direction: column;
@@ -332,19 +332,19 @@ static void test_flex_layout_with_content_width(float width)
rect.y = 5;
rect.width = 50;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(14) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(14) .box')[0].border_box", &w->border_box,
&rect);
w = ui_widget_get_child(content, 4);
rect.x = 5 + 50 + (content_width - 50 - 150 - 200 - 50 - 50) / 5.f;
rect.width = 150;
ctest_euqal_ui_rect("$('.example:eq(14) .box')[4].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(14) .box')[4].border_box", &w->border_box,
&rect);
w = ui_widget_get_child(content, 8);
rect.x += 150 + (content_width - 50 - 150 - 200 - 50 - 50) / 5.f;
rect.width = 50;
ctest_euqal_ui_rect("$('.example:eq(14) .box')[8].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(14) .box')[8].border_box", &w->border_box,
&rect);
// (15) Holy Grail Layout
@@ -356,12 +356,12 @@ static void test_flex_layout_with_content_width(float width)
rect.y = 5;
rect.width = content_width;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(15) .layout__header')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(15) .layout__header')[0].border_box",
&w->border_box, &rect);
w = ui_widget_get_child(content, 2);
rect.y = 5 + 50 + 31;
ctest_euqal_ui_rect("$('.example:eq(15) .layout__footer')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(15) .layout__footer')[0].border_box",
&w->border_box, &rect);
rect.x = 0;
@@ -370,19 +370,19 @@ static void test_flex_layout_with_content_width(float width)
rect.height = 31;
w = ui_widget_get_child(content, 1);
w = ui_widget_get_child(w, 0);
ctest_euqal_ui_rect("$('.example:eq(15) .layout__left')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(15) .layout__left')[0].border_box",
&w->border_box, &rect);
w = ui_widget_next(w);
rect.x = 100;
rect.width = content_width - 100 - 100;
ctest_euqal_ui_rect("$('.example:eq(15) .layout__center')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(15) .layout__center')[0].border_box",
&w->border_box, &rect);
w = ui_widget_next(w);
rect.x += rect.width;
rect.width = 100;
ctest_euqal_ui_rect("$('.example:eq(15) .layout__right')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(15) .layout__right')[0].border_box",
&w->border_box, &rect);
// (16) Holy Grail Layout (height: 300px)
@@ -394,12 +394,12 @@ static void test_flex_layout_with_content_width(float width)
rect.y = 5;
rect.width = content_width;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(16) .layout__header')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(16) .layout__header')[0].border_box",
&w->border_box, &rect);
w = ui_widget_get_child(content, 2);
rect.y = 5 + 50 + 200;
ctest_euqal_ui_rect("$('.example:eq(16) .layout__footer')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(16) .layout__footer')[0].border_box",
&w->border_box, &rect);
rect.x = 0;
@@ -408,19 +408,19 @@ static void test_flex_layout_with_content_width(float width)
rect.height = 200;
w = ui_widget_get_child(content, 1);
w = ui_widget_get_child(w, 0);
ctest_euqal_ui_rect("$('.example:eq(16) .layout__left')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(16) .layout__left')[0].border_box",
&w->border_box, &rect);
w = ui_widget_next(w);
rect.x = 100;
rect.width = content_width - 100 - 100;
ctest_euqal_ui_rect("$('.example:eq(16) .layout__center')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(16) .layout__center')[0].border_box",
&w->border_box, &rect);
w = ui_widget_next(w);
rect.x += rect.width;
rect.width = 100;
ctest_euqal_ui_rect("$('.example:eq(16) .layout__right')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(16) .layout__right')[0].border_box",
&w->border_box, &rect);
}
@@ -431,29 +431,29 @@ static void test_browser_layout(void)
w = ui_get_widget("browser-tabbar");
w = ui_widget_get_child(w, 0);
ctest_euqal_int("$('#browser-tabbar .c-frame-tab')[0].width",
ctest_equal_int("$('#browser-tabbar .c-frame-tab')[0].width",
(int)w->border_box.width, 101);
w = ui_widget_next(w);
ctest_euqal_int("$('#browser-tabbar .c-frame-tab')[1].width",
ctest_equal_int("$('#browser-tabbar .c-frame-tab')[1].width",
(int)w->border_box.width, 101);
w = ui_widget_next(w);
ctest_euqal_int("$('#browser-tabbar .c-frame-tab')[2].width",
ctest_equal_int("$('#browser-tabbar .c-frame-tab')[2].width",
(int)w->border_box.width, 101);
w = ui_widget_next(w);
ctest_euqal_int("$('#browser-tabbar .c-frame-tab')[3].width",
ctest_equal_int("$('#browser-tabbar .c-frame-tab')[3].width",
(int)w->border_box.width, 101);
w = ui_widget_next(w);
ctest_euqal_int("$('#browser-tabbar .c-frame-tab')[4].width",
ctest_equal_int("$('#browser-tabbar .c-frame-tab')[4].width",
(int)w->border_box.width, 101);
w = ui_get_widget("browser-frame-client");
ctest_euqal_int("$('#browser-frame-client')[0].height", (int)w->border_box.height,
ctest_equal_int("$('#browser-frame-client')[0].height", (int)w->border_box.height,
224);
w = ui_get_widget("browser-frame-content");
ctest_euqal_int("$('#browser-frame-content')[0].height", (int)w->border_box.height,
ctest_equal_int("$('#browser-frame-content')[0].height", (int)w->border_box.height,
224);
w = ui_get_widget("browser-page-home");
ctest_euqal_int("$('#browser-page-home')[0].height", (int)w->border_box.height,
ctest_equal_int("$('#browser-page-home')[0].height", (int)w->border_box.height,
224);
w = ui_get_widget("browser-page-home-container");
rect.width = 256;
@@ -462,7 +462,7 @@ static void test_browser_layout(void)
(538.f - rect.width) / 2.f + w->parent->computed_style.padding_left;
rect.y =
(204.f - rect.height) / 2.f + w->parent->computed_style.padding_top;
ctest_euqal_ui_rect("$('#browser-page-home-container')[0].border_box",
ctest_equal_ui_rect("$('#browser-page-home-container')[0].border_box",
&w->border_box, &rect);
}
@@ -498,81 +498,81 @@ static void test_flex_layout_320(void)
rect.width = width;
rect.height = 104;
w = ui_widget_get_child(container, 0);
ctest_euqal_ui_rect("$('.example')[0].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[0].border_box", &w->border_box, &rect);
rect.y += 114;
w = ui_widget_get_child(container, 1);
ctest_euqal_ui_rect("$('.example')[1].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[1].border_box", &w->border_box, &rect);
rect.y += 114;
w = ui_widget_get_child(container, 2);
ctest_euqal_ui_rect("$('.example')[2].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[2].border_box", &w->border_box, &rect);
rect.y += 114;
w = ui_widget_get_child(container, 3);
ctest_euqal_ui_rect("$('.example')[3].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[3].border_box", &w->border_box, &rect);
rect.y += 114;
w = ui_widget_get_child(container, 4);
ctest_euqal_ui_rect("$('.example')[4].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[4].border_box", &w->border_box, &rect);
rect.y += 114;
w = ui_widget_get_child(container, 5);
ctest_euqal_ui_rect("$('.example')[5].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[5].border_box", &w->border_box, &rect);
rect.y += 114;
w = ui_widget_get_child(container, 6);
ctest_euqal_ui_rect("$('.example')[6].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[6].border_box", &w->border_box, &rect);
rect.y += 114;
rect.height = 344;
w = ui_widget_get_child(container, 7);
ctest_euqal_ui_rect("$('.example')[7].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[7].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 8);
ctest_euqal_ui_rect("$('.example')[8].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[8].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 9);
ctest_euqal_ui_rect("$('.example')[9].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[9].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 10);
ctest_euqal_ui_rect("$('.example')[10].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[10].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 11);
ctest_euqal_ui_rect("$('.example')[11].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[11].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 12);
ctest_euqal_ui_rect("$('.example')[12].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[12].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 13);
ctest_euqal_ui_rect("$('.example')[13].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[13].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 254;
w = ui_widget_get_child(container, 14);
ctest_euqal_ui_rect("$('.example')[14].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[14].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 185;
w = ui_widget_get_child(container, 15);
ctest_euqal_ui_rect("$('.example')[15].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[15].border_box", &w->border_box, &rect);
rect.y += rect.height + 10;
rect.height = 354;
w = ui_widget_get_child(container, 16);
ctest_euqal_ui_rect("$('.example')[16].border_box", &w->border_box, &rect);
ctest_equal_ui_rect("$('.example')[16].border_box", &w->border_box, &rect);
// (1) justify-content: center;;
@@ -583,7 +583,7 @@ static void test_flex_layout_320(void)
rect.y = 5;
rect.width = 50 + (content_width - 300) / 6.f;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(1) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(1) .box')[0].border_box", &w->border_box,
&rect);
// (2) justify-content: flex-end;
@@ -591,7 +591,7 @@ static void test_flex_layout_320(void)
example = ui_widget_get_child(container, 2);
content = ui_widget_get_child(example, 1);
w = ui_widget_get_child(content, 0);
ctest_euqal_ui_rect("$('.example:eq(2) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(2) .box')[0].border_box", &w->border_box,
&rect);
// (3) justify-content: space-between;
@@ -599,17 +599,17 @@ static void test_flex_layout_320(void)
example = ui_widget_get_child(container, 3);
content = ui_widget_get_child(example, 1);
w = ui_widget_get_child(content, 0);
ctest_euqal_ui_rect("$('.example:eq(3) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[0].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += rect.width;
ctest_euqal_ui_rect("$('.example:eq(3) .box')[1].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[1].border_box", &w->border_box,
&rect);
w = ui_widget_get_child(content, 5);
rect.x = 5 + content_width - rect.width;
ctest_euqal_ui_rect("$('.example:eq(3) .box')[5].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(3) .box')[5].border_box", &w->border_box,
&rect);
// (5) Auto margin
@@ -619,22 +619,22 @@ static void test_flex_layout_320(void)
w = ui_widget_get_child(content, 0);
rect.x = 5;
rect.width = 50;
ctest_euqal_ui_rect("$('.example:eq(5) .box')[0].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(5) .box')[0].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += 50 + (content_width - 200) / 2.f;
ctest_euqal_ui_rect("$('.example:eq(5) .box')[1].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(5) .box')[1].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += 50;
ctest_euqal_ui_rect("$('.example:eq(5) .box')[2].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(5) .box')[2].border_box", &w->border_box,
&rect);
w = ui_widget_next(w);
rect.x += 50 + (content_width - 200) / 2.f;
ctest_euqal_ui_rect("$('.example:eq(5) .box')[3].border_box", &w->border_box,
ctest_equal_ui_rect("$('.example:eq(5) .box')[3].border_box", &w->border_box,
&rect);
// (15) Holy Grail Layout
@@ -646,12 +646,12 @@ static void test_flex_layout_320(void)
rect.y = 5;
rect.width = content_width;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(15) .layout__header')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(15) .layout__header')[0].border_box",
&w->border_box, &rect);
w = ui_widget_get_child(content, 2);
rect.y = 5 + 50 + 31;
ctest_euqal_ui_rect("$('.example:eq(15) .layout__footer')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(15) .layout__footer')[0].border_box",
&w->border_box, &rect);
rect.x = 0;
@@ -660,19 +660,19 @@ static void test_flex_layout_320(void)
rect.height = 31;
w = ui_widget_get_child(content, 1);
w = ui_widget_get_child(w, 0);
ctest_euqal_ui_rect("$('.example:eq(15) .layout__left')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(15) .layout__left')[0].border_box",
&w->border_box, &rect);
w = ui_widget_next(w);
rect.x = 100;
rect.width = content_width - 100 - 100;
ctest_euqal_ui_rect("$('.example:eq(15) .layout__center')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(15) .layout__center')[0].border_box",
&w->border_box, &rect);
w = ui_widget_next(w);
rect.x += rect.width;
rect.width = 100;
ctest_euqal_ui_rect("$('.example:eq(15) .layout__right')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(15) .layout__right')[0].border_box",
&w->border_box, &rect);
// (16) Holy Grail Layout (height: 300px)
@@ -684,12 +684,12 @@ static void test_flex_layout_320(void)
rect.y = 5;
rect.width = content_width;
rect.height = 50;
ctest_euqal_ui_rect("$('.example:eq(15) .layout__header')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(15) .layout__header')[0].border_box",
&w->border_box, &rect);
w = ui_widget_get_child(content, 2);
rect.y = 5 + 50 + 200;
ctest_euqal_ui_rect("$('.example:eq(16) .layout__footer')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(16) .layout__footer')[0].border_box",
&w->border_box, &rect);
rect.x = 0;
@@ -698,19 +698,19 @@ static void test_flex_layout_320(void)
rect.height = 200;
w = ui_widget_get_child(content, 1);
w = ui_widget_get_child(w, 0);
ctest_euqal_ui_rect("$('.example:eq(16) .layout__left')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(16) .layout__left')[0].border_box",
&w->border_box, &rect);
w = ui_widget_next(w);
rect.x = 100;
rect.width = content_width - 100 - 100;
ctest_euqal_ui_rect("$('.example:eq(16) .layout__center')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(16) .layout__center')[0].border_box",
&w->border_box, &rect);
w = ui_widget_next(w);
rect.x += rect.width;
rect.width = 100;
ctest_euqal_ui_rect("$('.example:eq(16) .layout__right')[0].border_box",
ctest_equal_ui_rect("$('.example:eq(16) .layout__right')[0].border_box",
&w->border_box, &rect);
}
+170 -130
View File
@@ -7,145 +7,185 @@
void test_segoe_ui_font_load(void)
{
pd_font_t *font;
int id;
if (pd_font_library_load_file("C:/windows/fonts/segoeui.ttf") != 0) {
return;
}
ctest_euqal_int("load segoeui.ttf",
pd_font_library_load_file("C:/windows/fonts/segoeui.ttf"), 0);
ctest_euqal_int("load segoeuib.ttf",
pd_font_library_load_file("C:/windows/fonts/segoeuib.ttf"), 0);
ctest_euqal_int("load segoeuii.ttf",
pd_font_library_load_file("C:/windows/fonts/segoeuii.ttf"), 0);
ctest_euqal_int("load segoeuil.ttf",
pd_font_library_load_file("C:/windows/fonts/segoeuil.ttf"), 0);
ctest_euqal_int("load segoeuisl.ttf",
pd_font_library_load_file("C:/windows/fonts/segoeuisl.ttf"), 0);
ctest_euqal_int("load segoeuiz.ttf",
pd_font_library_load_file("C:/windows/fonts/segoeuiz.ttf"), 0);
ctest_euqal_int("load seguibl.ttf",
pd_font_library_load_file("C:/windows/fonts/seguibl.ttf"), 0);
ctest_euqal_int("load seguili.ttf",
pd_font_library_load_file("C:/windows/fonts/seguili.ttf"), 0);
ctest_euqal_bool("check get font (style: normal, weight: normal)",
id = GetSegoeUIFont(PD_FONT_STYLE_NORMAL, PD_FONT_WEIGHT_NORMAL),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_euqal_int("check font style", font->style, PD_FONT_STYLE_NORMAL);
ctest_euqal_int("check font weight", font->weight, PD_FONT_WEIGHT_NORMAL);
}
ctest_euqal_bool("check get font (style: italic, weight: normal)",
id = GetSegoeUIFont(PD_FONT_STYLE_ITALIC, PD_FONT_WEIGHT_NORMAL),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_euqal_int("check font style", font->style, PD_FONT_STYLE_ITALIC);
ctest_euqal_int("check font weight", font->weight, PD_FONT_WEIGHT_NORMAL);
}
ctest_euqal_bool("check get font (style: normal, weight: bold)",
id = GetSegoeUIFont(PD_FONT_STYLE_NORMAL, PD_FONT_WEIGHT_BOLD),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_euqal_int("check font style", font->style, PD_FONT_STYLE_NORMAL);
ctest_euqal_int("check font weight", font->weight, PD_FONT_WEIGHT_BOLD);
}
ctest_euqal_bool("check get font (style: normal, weight: light)",
id = GetSegoeUIFont(PD_FONT_STYLE_NORMAL, PD_FONT_WEIGHT_LIGHT),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_euqal_int("check font style", font->style, PD_FONT_STYLE_NORMAL);
ctest_euqal_int("check font weight", font->weight, PD_FONT_WEIGHT_LIGHT);
}
ctest_euqal_bool("check get font (style: italic, weight: extra light)",
id = GetSegoeUIFont(PD_FONT_STYLE_ITALIC,
PD_FONT_WEIGHT_EXTRA_LIGHT),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_euqal_int("check font style", font->style, PD_FONT_STYLE_ITALIC);
ctest_euqal_int("check font weight", font->weight,
PD_FONT_WEIGHT_EXTRA_LIGHT);
}
pd_font_t *font;
int id;
if (pd_font_library_load_file("C:/windows/fonts/segoeui.ttf") != 0) {
return;
}
ctest_equal_int(
"load segoeui.ttf",
pd_font_library_load_file("C:/windows/fonts/segoeui.ttf"), 0);
ctest_equal_int(
"load segoeuib.ttf",
pd_font_library_load_file("C:/windows/fonts/segoeuib.ttf"), 0);
ctest_equal_int(
"load segoeuii.ttf",
pd_font_library_load_file("C:/windows/fonts/segoeuii.ttf"), 0);
ctest_equal_int(
"load segoeuil.ttf",
pd_font_library_load_file("C:/windows/fonts/segoeuil.ttf"), 0);
ctest_equal_int(
"load segoeuisl.ttf",
pd_font_library_load_file("C:/windows/fonts/segoeuisl.ttf"), 0);
ctest_equal_int(
"load segoeuiz.ttf",
pd_font_library_load_file("C:/windows/fonts/segoeuiz.ttf"), 0);
ctest_equal_int(
"load seguibl.ttf",
pd_font_library_load_file("C:/windows/fonts/seguibl.ttf"), 0);
ctest_equal_int(
"load seguili.ttf",
pd_font_library_load_file("C:/windows/fonts/seguili.ttf"), 0);
ctest_equal_bool(
"check get font (style: normal, weight: normal)",
id = GetSegoeUIFont(PD_FONT_STYLE_NORMAL, PD_FONT_WEIGHT_NORMAL),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_equal_int("check font style", font->style,
PD_FONT_STYLE_NORMAL);
ctest_equal_int("check font weight", font->weight,
PD_FONT_WEIGHT_NORMAL);
}
ctest_equal_bool(
"check get font (style: italic, weight: normal)",
id = GetSegoeUIFont(PD_FONT_STYLE_ITALIC, PD_FONT_WEIGHT_NORMAL),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_equal_int("check font style", font->style,
PD_FONT_STYLE_ITALIC);
ctest_equal_int("check font weight", font->weight,
PD_FONT_WEIGHT_NORMAL);
}
ctest_equal_bool(
"check get font (style: normal, weight: bold)",
id = GetSegoeUIFont(PD_FONT_STYLE_NORMAL, PD_FONT_WEIGHT_BOLD),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_equal_int("check font style", font->style,
PD_FONT_STYLE_NORMAL);
ctest_equal_int("check font weight", font->weight,
PD_FONT_WEIGHT_BOLD);
}
ctest_equal_bool(
"check get font (style: normal, weight: light)",
id = GetSegoeUIFont(PD_FONT_STYLE_NORMAL, PD_FONT_WEIGHT_LIGHT),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_equal_int("check font style", font->style,
PD_FONT_STYLE_NORMAL);
ctest_equal_int("check font weight", font->weight,
PD_FONT_WEIGHT_LIGHT);
}
ctest_equal_bool("check get font (style: italic, weight: extra light)",
id = GetSegoeUIFont(PD_FONT_STYLE_ITALIC,
PD_FONT_WEIGHT_EXTRA_LIGHT),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_equal_int("check font style", font->style,
PD_FONT_STYLE_ITALIC);
ctest_equal_int("check font weight", font->weight,
PD_FONT_WEIGHT_EXTRA_LIGHT);
}
}
void test_arial_font_load(void)
{
int id;
pd_font_t *font;
if (pd_font_library_load_file("C:/windows/fonts/arial.ttf") != 0) {
return;
}
ctest_euqal_int("load arialbd.ttf",
pd_font_library_load_file("C:/windows/fonts/arialbd.ttf"), 0);
ctest_euqal_int("load arialblk.ttf",
pd_font_library_load_file("C:/windows/fonts/ariblk.ttf"), 0);
ctest_euqal_int("load arialbi.ttf",
pd_font_library_load_file("C:/windows/fonts/arialbi.ttf"), 0);
ctest_euqal_int("load ariali.ttf",
pd_font_library_load_file("C:/windows/fonts/ariali.ttf"), 0);
ctest_euqal_bool("check get font (style: normal, weight: normal)",
id = GetArialFont(PD_FONT_STYLE_NORMAL, PD_FONT_WEIGHT_NORMAL),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_euqal_int("check font style", font->style, PD_FONT_STYLE_NORMAL);
ctest_euqal_int("check font weight", font->weight, PD_FONT_WEIGHT_NORMAL);
}
ctest_euqal_bool("check get font (style: italic, weight: normal)",
id = GetArialFont(PD_FONT_STYLE_ITALIC, PD_FONT_WEIGHT_NORMAL),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_euqal_int("check font style", font->style, PD_FONT_STYLE_ITALIC);
ctest_euqal_int("check font weight", font->weight, PD_FONT_WEIGHT_NORMAL);
}
ctest_euqal_bool("check get font (style: normal, weight: bold)",
id = GetArialFont(PD_FONT_STYLE_NORMAL, PD_FONT_WEIGHT_BOLD),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_euqal_int("check font style", font->style, PD_FONT_STYLE_NORMAL);
ctest_euqal_int("check font weight", font->weight, PD_FONT_WEIGHT_BOLD);
}
ctest_euqal_bool("check get font (style: normal, weight: black)",
id = GetArialFont(PD_FONT_STYLE_NORMAL, PD_FONT_WEIGHT_BLACK),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_euqal_int("check font style", font->style, PD_FONT_STYLE_NORMAL);
ctest_euqal_int("check font weight", font->weight, PD_FONT_WEIGHT_BLACK);
}
ctest_euqal_bool("check get font (style: italic, weight: bold)",
id = GetSegoeUIFont(PD_FONT_STYLE_ITALIC, PD_FONT_WEIGHT_BOLD),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_euqal_int("check font style", font->style, PD_FONT_STYLE_ITALIC);
ctest_euqal_int("check font weight", font->weight, PD_FONT_WEIGHT_BOLD);
}
int id;
pd_font_t *font;
if (pd_font_library_load_file("C:/windows/fonts/arial.ttf") != 0) {
return;
}
ctest_equal_int(
"load arialbd.ttf",
pd_font_library_load_file("C:/windows/fonts/arialbd.ttf"), 0);
ctest_equal_int(
"load arialblk.ttf",
pd_font_library_load_file("C:/windows/fonts/ariblk.ttf"), 0);
ctest_equal_int(
"load arialbi.ttf",
pd_font_library_load_file("C:/windows/fonts/arialbi.ttf"), 0);
ctest_equal_int(
"load ariali.ttf",
pd_font_library_load_file("C:/windows/fonts/ariali.ttf"), 0);
ctest_equal_bool(
"check get font (style: normal, weight: normal)",
id = GetArialFont(PD_FONT_STYLE_NORMAL, PD_FONT_WEIGHT_NORMAL),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_equal_int("check font style", font->style,
PD_FONT_STYLE_NORMAL);
ctest_equal_int("check font weight", font->weight,
PD_FONT_WEIGHT_NORMAL);
}
ctest_equal_bool(
"check get font (style: italic, weight: normal)",
id = GetArialFont(PD_FONT_STYLE_ITALIC, PD_FONT_WEIGHT_NORMAL),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_equal_int("check font style", font->style,
PD_FONT_STYLE_ITALIC);
ctest_equal_int("check font weight", font->weight,
PD_FONT_WEIGHT_NORMAL);
}
ctest_equal_bool(
"check get font (style: normal, weight: bold)",
id = GetArialFont(PD_FONT_STYLE_NORMAL, PD_FONT_WEIGHT_BOLD), TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_equal_int("check font style", font->style,
PD_FONT_STYLE_NORMAL);
ctest_equal_int("check font weight", font->weight,
PD_FONT_WEIGHT_BOLD);
}
ctest_equal_bool(
"check get font (style: normal, weight: black)",
id = GetArialFont(PD_FONT_STYLE_NORMAL, PD_FONT_WEIGHT_BLACK),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_equal_int("check font style", font->style,
PD_FONT_STYLE_NORMAL);
ctest_equal_int("check font weight", font->weight,
PD_FONT_WEIGHT_BLACK);
}
ctest_equal_bool(
"check get font (style: italic, weight: bold)",
id = GetSegoeUIFont(PD_FONT_STYLE_ITALIC, PD_FONT_WEIGHT_BOLD),
TRUE);
if (id > 0) {
font = pd_font_library_get_font(id);
ctest_equal_int("check font style", font->style,
PD_FONT_STYLE_ITALIC);
ctest_equal_int("check font weight", font->weight,
PD_FONT_WEIGHT_BOLD);
}
}
void test_font_load(void)
{
pd_font_library_init();
/* 测试是否能够从字体文件中载入字体 */
ctest_euqal_int("check pd_font_library_load_file success",
pd_font_library_load_file("test_font_load.ttf"), 0);
pd_font_library_init();
/* 测试是否能够从字体文件中载入字体 */
ctest_equal_int("check pd_font_library_load_file success",
pd_font_library_load_file("test_font_load.ttf"), 0);
#ifdef LIBPLAT_WIN32
ctest_describe("test segoe ui font load", test_segoe_ui_font_load);
ctest_describe("test arial font load", test_arial_font_load);
ctest_describe("test segoe ui font load", test_segoe_ui_font_load);
ctest_describe("test arial font load", test_arial_font_load);
#endif
pd_font_library_destroy();
pd_font_library_destroy();
ui_init();
/* 测试是否能够根据 CSS 文件中定义的 @font-face 规则来载入字体 */
ctest_euqal_int("check LCUIFont_LoadCSSFile success",
ui_load_css_file("test_font_load.css"), 0);
ctest_euqal_bool("check pd_font_library_get_font_id success",
pd_font_library_get_font_id("icomoon", 0, 0) > 0, TRUE);
ui_destroy();
ui_init();
/* 测试是否能够根据 CSS 文件中定义的 @font-face 规则来载入字体 */
ctest_equal_int("check LCUIFont_LoadCSSFile success",
ui_load_css_file("test_font_load.css"), 0);
ctest_equal_bool("check pd_font_library_get_font_id success",
pd_font_library_get_font_id("icomoon", 0, 0) > 0,
TRUE);
ui_destroy();
}
+6 -6
View File
@@ -13,15 +13,15 @@ void test_image_reader(void)
pd_canvas_init(&img);
snprintf(file, 255, "test_image_reader.%s", formats[i]);
logger_debug("image file: %s\n", file);
ctest_euqal_int("check pd_read_image_from_file", pd_read_image_from_file(file, &img),
ctest_equal_int("check pd_read_image_from_file", pd_read_image_from_file(file, &img),
0);
ctest_euqal_int("check image width with ReadImageFile", img.width, 91);
ctest_euqal_int("check image height with ReadImageFile", img.height, 69);
ctest_euqal_int("check pd_read_image_size_from_file",
ctest_equal_int("check image width with ReadImageFile", img.width, 91);
ctest_equal_int("check image height with ReadImageFile", img.height, 69);
ctest_equal_int("check pd_read_image_size_from_file",
pd_read_image_size_from_file(file, &width, &height), 0);
logger_debug("image size: (%d, %d)\n", width, height);
ctest_euqal_int("check image width with GetImageSize", width, 91);
ctest_euqal_int("check image height with GetImageSize", height, 69);
ctest_equal_int("check image width with GetImageSize", width, 91);
ctest_equal_int("check image height with GetImageSize", height, 69);
pd_canvas_destroy(&img);
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ static void ObserverThread(void *arg)
for (i = 0; i < 20 && !*exited; ++i) {
sleep_ms(100);
}
ctest_euqal_bool("main loop should exit within 2000ms", *exited, TRUE);
ctest_equal_bool("main loop should exit within 2000ms", *exited, TRUE);
if (!*exited) {
exit(-ctest_finish());
return;
+124 -129
View File
@@ -1,26 +1,21 @@
#include <LCUI.h>
#include <ctest-custom.h>
/* clang-format off */
const char *test_css = css_string(
.container {
width: 300px;
height: 240px;
padding: 10px;
margin: 20px auto 0 auto;
border: 1px solid #eee;
}
text {
white-space: nowrap;
display: inline-block;
}
);
/* clang-format on */
const char *test_css = "\
.container {\
width: 300px;\
height: 240px;\
padding: 10px;\
margin: 20px auto 0 auto;\
border: 1px solid #eee;\
}\
\
text {\
white-space: nowrap;\
display: inline-block;\
}\
\
);";
const char *test_content = "\n\
/* ***************************************************************************\n\
@@ -57,142 +52,142 @@ const char *test_content = "\n\
/* Build content view with native C code */
void BuildContentView(void)
{
ui_widget_t* container = ui_create_widget(NULL);
ui_widget_t* content = ui_create_widget("text");
ui_widget_t* vscrollbar = ui_create_widget("scrollbar");
ui_widget_t* hscrollbar = ui_create_widget("scrollbar");
ui_widget_t *container = ui_create_widget(NULL);
ui_widget_t *content = ui_create_widget("text");
ui_widget_t *vscrollbar = ui_create_widget("scrollbar");
ui_widget_t *hscrollbar = ui_create_widget("scrollbar");
ui_widget_set_id(content, "license_content");
ui_text_set_content(content, test_content);
ui_scrollbar_set_direction(hscrollbar, UI_SCROLLBAR_HORIZONTAL);
ui_scrollbar_bind_target(vscrollbar, content);
ui_scrollbar_bind_target(hscrollbar, content);
ui_widget_add_class(container, "container");
ui_widget_append(container, content);
ui_widget_append(container, vscrollbar);
ui_widget_append(container, hscrollbar);
ui_root_append(container);
ui_widget_set_id(content, "license_content");
ui_text_set_content(content, test_content);
ui_scrollbar_set_direction(hscrollbar, UI_SCROLLBAR_HORIZONTAL);
ui_scrollbar_bind_target(vscrollbar, content);
ui_scrollbar_bind_target(hscrollbar, content);
ui_widget_add_class(container, "container");
ui_widget_append(container, content);
ui_widget_append(container, vscrollbar);
ui_widget_append(container, hscrollbar);
ui_root_append(container);
}
/* Build content view with the XML code in test_scrollbar.xml */
int BuildContentViewFromXML(void)
{
ui_widget_t* root = ui_root();
ui_widget_t* pack = ui_load_xml_file("test_scrollbar.xml");
ui_widget_t *root = ui_root();
ui_widget_t *pack = ui_load_xml_file("test_scrollbar.xml");
if (!pack) {
return -1;
}
ui_widget_append(root, pack);
ui_widget_unwrap(pack);
return 0;
if (!pack) {
return -1;
}
ui_widget_append(root, pack);
ui_widget_unwrap(pack);
return 0;
}
void test_scrollbar(void)
{
float left, top;
ui_event_t e = { 0 };
ui_widget_t* content;
float left, top;
ui_event_t e = { 0 };
ui_widget_t *content;
lcui_init();
ui_widget_resize(ui_root(), 800, 640);
ui_load_css_string(test_css, __FILE__);
BuildContentView();
lcui_update_ui();
lcui_init();
ui_widget_resize(ui_root(), 800, 640);
ui_load_css_string(test_css, __FILE__);
BuildContentView();
lcui_update_ui();
content = ui_get_widget("license_content");
left = content->computed_style.left;
top = content->computed_style.top;
content = ui_get_widget("license_content");
left = content->computed_style.left;
top = content->computed_style.top;
e.type = UI_EVENT_MOUSEMOVE;
e.mouse.x = 300;
e.mouse.y = 275;
ui_dispatch_event(&e);
lcui_update_ui();
e.type = UI_EVENT_MOUSEMOVE;
e.mouse.x = 300;
e.mouse.y = 275;
ui_dispatch_event(&e);
lcui_update_ui();
e.type = UI_EVENT_MOUSEDOWN;
e.mouse.button = MOUSE_BUTTON_LEFT;
e.mouse.x = 300;
e.mouse.y = 275;
ui_dispatch_event(&e);
lcui_update_ui();
e.type = UI_EVENT_MOUSEDOWN;
e.mouse.button = MOUSE_BUTTON_LEFT;
e.mouse.x = 300;
e.mouse.y = 275;
ui_dispatch_event(&e);
lcui_update_ui();
e.type = UI_EVENT_MOUSEMOVE;
e.mouse.x = 600;
e.mouse.y = 275;
ui_dispatch_event(&e);
lcui_update_ui();
e.type = UI_EVENT_MOUSEMOVE;
e.mouse.x = 600;
e.mouse.y = 275;
ui_dispatch_event(&e);
lcui_update_ui();
ctest_euqal_bool("content should be moved to the left",
content->computed_style.left < left &&
top == content->computed_style.top,
TRUE);
ctest_equal_bool("content should be moved to the left",
content->computed_style.left < left &&
top == content->computed_style.top,
TRUE);
left = content->computed_style.left;
top = content->computed_style.top;
left = content->computed_style.left;
top = content->computed_style.top;
e.type = UI_EVENT_MOUSEMOVE;
e.mouse.x = 400;
e.mouse.y = 275;
ui_dispatch_event(&e);
e.type = UI_EVENT_MOUSEUP;
e.mouse.button = MOUSE_BUTTON_LEFT;
e.mouse.x = 400;
e.mouse.y = 275;
ui_dispatch_event(&e);
lcui_update_ui();
e.type = UI_EVENT_MOUSEMOVE;
e.mouse.x = 400;
e.mouse.y = 275;
ui_dispatch_event(&e);
e.type = UI_EVENT_MOUSEUP;
e.mouse.button = MOUSE_BUTTON_LEFT;
e.mouse.x = 400;
e.mouse.y = 275;
ui_dispatch_event(&e);
lcui_update_ui();
ctest_euqal_bool("content should be moved to the right",
content->computed_style.left > left &&
top == content->computed_style.top,
TRUE);
ctest_equal_bool("content should be moved to the right",
content->computed_style.left > left &&
top == content->computed_style.top,
TRUE);
left = content->computed_style.left;
top = content->computed_style.top;
left = content->computed_style.left;
top = content->computed_style.top;
e.type = UI_EVENT_MOUSEMOVE;
e.mouse.x = 555;
e.mouse.y = 45;
ui_dispatch_event(&e);
lcui_update_ui();
e.type = UI_EVENT_MOUSEMOVE;
e.mouse.x = 555;
e.mouse.y = 45;
ui_dispatch_event(&e);
lcui_update_ui();
e.type = UI_EVENT_MOUSEDOWN;
e.mouse.button = MOUSE_BUTTON_LEFT;
e.mouse.x = 555;
e.mouse.y = 45;
ui_dispatch_event(&e);
lcui_update_ui();
e.type = UI_EVENT_MOUSEDOWN;
e.mouse.button = MOUSE_BUTTON_LEFT;
e.mouse.x = 555;
e.mouse.y = 45;
ui_dispatch_event(&e);
lcui_update_ui();
e.type = UI_EVENT_MOUSEMOVE;
e.mouse.x = 555;
e.mouse.y = 200;
ui_dispatch_event(&e);
lcui_update_ui();
e.type = UI_EVENT_MOUSEMOVE;
e.mouse.x = 555;
e.mouse.y = 200;
ui_dispatch_event(&e);
lcui_update_ui();
ctest_euqal_bool("content should be moved to the top",
content->computed_style.left == left &&
top > content->computed_style.top,
TRUE);
ctest_equal_bool("content should be moved to the top",
content->computed_style.left == left &&
top > content->computed_style.top,
TRUE);
left = content->computed_style.left;
top = content->computed_style.top;
left = content->computed_style.left;
top = content->computed_style.top;
e.type = UI_EVENT_MOUSEMOVE;
e.mouse.x = 555;
e.mouse.y = 100;
ui_dispatch_event(&e);
e.type = UI_EVENT_MOUSEUP;
e.mouse.button = MOUSE_BUTTON_LEFT;
e.mouse.x = 555;
e.mouse.y = 100;
ui_dispatch_event(&e);
lcui_update_ui();
e.type = UI_EVENT_MOUSEMOVE;
e.mouse.x = 555;
e.mouse.y = 100;
ui_dispatch_event(&e);
e.type = UI_EVENT_MOUSEUP;
e.mouse.button = MOUSE_BUTTON_LEFT;
e.mouse.x = 555;
e.mouse.y = 100;
ui_dispatch_event(&e);
lcui_update_ui();
ctest_euqal_bool("the content should have scrolled to the bottom",
content->computed_style.left == left &&
top < content->computed_style.top,
TRUE);
ctest_equal_bool("the content should have scrolled to the bottom",
content->computed_style.left == left &&
top < content->computed_style.top,
TRUE);
lcui_quit();
lcui_main();
lcui_quit();
lcui_main();
}
+10 -10
View File
@@ -10,7 +10,7 @@ static void check_settings_frame_rate_cap(void *arg)
sprintf(str, "should work when frame cap is %u (actual %u)", fps_limit,
fps);
ctest_euqal_bool(str, fps <= fps_limit + 2 && fps > fps_limit / 2, TRUE);
ctest_equal_bool(str, fps <= fps_limit + 2 && fps > fps_limit / 2, TRUE);
lcui_quit();
}
@@ -22,10 +22,10 @@ static void test_default_settings(void)
lcui_reset_settings();
lcui_get_settings(&settings);
ctest_euqal_int("check default frame rate cap", settings.frame_rate_cap, 120);
ctest_euqal_int("check default parallel rendering threads",
ctest_equal_int("check default frame rate cap", settings.frame_rate_cap, 120);
ctest_equal_int("check default parallel rendering threads",
settings.parallel_rendering_threads, 4);
ctest_euqal_bool("check default paint flashing", settings.paint_flashing, FALSE);
ctest_equal_bool("check default paint flashing", settings.paint_flashing, FALSE);
lcui_quit();
lcui_main();
}
@@ -41,10 +41,10 @@ static void test_apply_settings(void)
lcui_init();
lcui_apply_settings(&settings);
lcui_get_settings(&settings);
ctest_euqal_int("check frame rate cap", settings.frame_rate_cap, 60);
ctest_euqal_int("check parallel rendering threads",
ctest_equal_int("check frame rate cap", settings.frame_rate_cap, 60);
ctest_equal_int("check parallel rendering threads",
settings.parallel_rendering_threads, 2);
ctest_euqal_bool("check paint flashing", settings.paint_flashing, TRUE);
ctest_equal_bool("check paint flashing", settings.paint_flashing, TRUE);
settings.frame_rate_cap = -1;
settings.parallel_rendering_threads = -1;
@@ -52,14 +52,14 @@ static void test_apply_settings(void)
lcui_apply_settings(&settings);
lcui_get_settings(&settings);
ctest_euqal_int("check frame rate cap minimum", settings.frame_rate_cap, 1);
ctest_euqal_int("check parallel rendering threads minimum",
ctest_equal_int("check frame rate cap minimum", settings.frame_rate_cap, 1);
ctest_equal_int("check parallel rendering threads minimum",
settings.parallel_rendering_threads, 1);
lcui_reset_settings();
lcui_get_settings(&settings);
ctest_euqal_int("check frame rate cap", settings.frame_rate_cap, LCUI_MAX_FRAMES_PER_SEC);
ctest_equal_int("check frame rate cap", settings.frame_rate_cap, LCUI_MAX_FRAMES_PER_SEC);
lcui_quit();
lcui_main();
}
+12 -12
View File
@@ -75,13 +75,13 @@ static void check_text_set_content(void)
{
ui_update();
ctest_euqal_bool("check block width",
ctest_equal_bool("check block width",
self.block->border_box.width == 122.0f, TRUE);
ctest_euqal_bool("check block height",
ctest_equal_bool("check block height",
self.block->border_box.height > 140.0f, TRUE);
ctest_euqal_bool("check inline block width",
ctest_equal_bool("check inline block width",
self.inline_block->border_box.width > 520.0f, TRUE);
ctest_euqal_bool("check inline block height",
ctest_equal_bool("check inline block height",
self.inline_block->border_box.height < 45.0f, TRUE);
}
@@ -95,13 +95,13 @@ static void check_text_set_short_content_css(void)
{
ui_update();
ctest_euqal_bool("check block width",
ctest_equal_bool("check block width",
self.block->border_box.width == 122.0f, TRUE);
ctest_euqal_bool("check block height",
ctest_equal_bool("check block height",
self.block->border_box.height < 45.0f, TRUE);
ctest_euqal_bool("check inline block width",
ctest_equal_bool("check inline block width",
self.inline_block->border_box.width < 70.0f, TRUE);
ctest_euqal_bool("check inline block height",
ctest_equal_bool("check inline block height",
self.inline_block->border_box.height < 45.0f, TRUE);
}
@@ -117,13 +117,13 @@ static void check_text_set_long_content_css(void)
{
ui_update();
ctest_euqal_bool("check block width",
ctest_equal_bool("check block width",
self.block->border_box.width == 122.0f, TRUE);
ctest_euqal_bool("check block height",
ctest_equal_bool("check block height",
self.block->border_box.height > 60.0f, TRUE);
ctest_euqal_bool("check inline block width",
ctest_equal_bool("check inline block width",
self.inline_block->border_box.width > 250.0f, TRUE);
ctest_euqal_bool("check inline block height",
ctest_equal_bool("check inline block height",
self.inline_block->border_box.height < 45.0f, TRUE);
}
+12 -12
View File
@@ -12,29 +12,29 @@ void test_textinput(void)
ui_textinput_set_text_w(w, L"hello");
ui_widget_update(w);
ctest_euqal_bool("check TextEdit_GetLength after ui_textinput_set_text_w",
ctest_equal_bool("check TextEdit_GetLength after ui_textinput_set_text_w",
ui_textinput_get_text_length(w) == wcslen(L"hello"), TRUE);
ctest_euqal_bool("check ui_textinput_get_text_w after ui_textinput_set_text_w",
ctest_equal_bool("check ui_textinput_get_text_w after ui_textinput_set_text_w",
ui_textinput_get_text_w(w, 0, 64, wcs) == wcslen(L"hello"), TRUE);
ctest_euqal_bool("check string retrieved from ui_textinput_get_text_w",
ctest_equal_bool("check string retrieved from ui_textinput_get_text_w",
wcscmp(L"hello", wcs) == 0, TRUE);
ui_widget_set_text(w, "hello");
ui_widget_update(w);
ctest_euqal_bool("check TextEdit_GetLength after ui_textinput_set_text",
ctest_equal_bool("check TextEdit_GetLength after ui_textinput_set_text",
ui_textinput_get_text_length(w) == wcslen(L"hello"), TRUE);
ctest_euqal_bool("check ui_textinput_get_text_w after ui_textinput_set_text",
ctest_equal_bool("check ui_textinput_get_text_w after ui_textinput_set_text",
ui_textinput_get_text_w(w, 0, 64, wcs) == wcslen(L"hello"), TRUE);
ctest_euqal_bool("check string retrieved from ui_textinput_get_text_w",
ctest_equal_bool("check string retrieved from ui_textinput_get_text_w",
wcscmp(L"hello", wcs) == 0, TRUE);
ui_textinput_append_text_w(w, L"world");
ui_widget_update(w);
ctest_euqal_bool("check TextEdit_GetLength after ui_textinput_append_text_w",
ctest_equal_bool("check TextEdit_GetLength after ui_textinput_append_text_w",
ui_textinput_get_text_length(w) == wcslen(L"helloworld"), TRUE);
ctest_euqal_bool("check ui_textinput_get_text_w after ui_textinput_append_text_w",
ctest_equal_bool("check ui_textinput_get_text_w after ui_textinput_append_text_w",
ui_textinput_get_text_w(w, 0, 64, wcs) == wcslen(L"helloworld"), TRUE);
ctest_euqal_bool("check string retrieved from ui_textinput_get_text_w",
ctest_equal_bool("check string retrieved from ui_textinput_get_text_w",
wcscmp(L"helloworld", wcs) == 0, TRUE);
ui_textinput_move_caret(w, 0, 5);
@@ -43,12 +43,12 @@ void test_textinput(void)
ui_textinput_move_caret(w, 0, 100);
ui_textinput_insert_text_w(w, L"!");
ui_widget_update(w);
ctest_euqal_bool("check TextEdit_GetLength after inserting text",
ctest_equal_bool("check TextEdit_GetLength after inserting text",
ui_textinput_get_text_length(w) == wcslen(L"hello, world!"), TRUE);
ctest_euqal_bool("check ui_textinput_get_text_w after inserting text",
ctest_equal_bool("check ui_textinput_get_text_w after inserting text",
ui_textinput_get_text_w(w, 0, 64, wcs) == wcslen(L"hello, world!"),
TRUE);
ctest_euqal_bool("check string retrieved from ui_textinput_get_text_w",
ctest_equal_bool("check string retrieved from ui_textinput_get_text_w",
wcscmp(L"hello, world!", wcs) == 0, TRUE);
ui_widget_destroy(w);
lcui_quit();
+2 -2
View File
@@ -78,6 +78,6 @@ void test_thread(void)
TestWorker_Send(&worker, "bye!");
sleep_ms(100);
TestWorker_Destroy(&worker);
ctest_euqal_int("check worker data count", worker.data_count, 7);
ctest_euqal_bool("check worker is no longer active", worker.active, FALSE);
ctest_equal_int("check worker data count", worker.data_count, 7);
ctest_equal_bool("check worker is no longer active", worker.active, FALSE);
}
+21 -21
View File
@@ -26,33 +26,33 @@ void test_widget_mouse_event(void)
ev.mouse.y = 150;
ui_dispatch_event(&ev);
ui_update();
ctest_euqal_bool("mousemove(150, 150): root.hasStatus('hover') == true",
ctest_equal_bool("mousemove(150, 150): root.hasStatus('hover') == true",
ui_widget_has_status(root, "hover"), TRUE);
ctest_euqal_bool("mousemove(150, 150): parent.hasStatus('hover') == false",
ctest_equal_bool("mousemove(150, 150): parent.hasStatus('hover') == false",
ui_widget_has_status(parent, "hover"), FALSE);
ctest_euqal_bool("mousemove(150, 150): child.hasStatus('hover') == false",
ctest_equal_bool("mousemove(150, 150): child.hasStatus('hover') == false",
ui_widget_has_status(child, "hover"), FALSE);
ev.mouse.x = 80;
ev.mouse.y = 80;
ui_dispatch_event(&ev);
ui_update();
ctest_euqal_bool("mousemove(80, 80): root.hasStatus('hover') == true",
ctest_equal_bool("mousemove(80, 80): root.hasStatus('hover') == true",
ui_widget_has_status(root, "hover"), TRUE);
ctest_euqal_bool("mousemove(80, 80): parent.hasStatus('hover') == true",
ctest_equal_bool("mousemove(80, 80): parent.hasStatus('hover') == true",
ui_widget_has_status(parent, "hover"), TRUE);
ctest_euqal_bool("mousemove(80, 80): child.hasStatus('hover') == false",
ctest_equal_bool("mousemove(80, 80): child.hasStatus('hover') == false",
ui_widget_has_status(child, "hover"), FALSE);
ev.mouse.x = 40;
ev.mouse.y = 40;
ui_dispatch_event(&ev);
ui_update();
ctest_euqal_bool("mousemove(40, 40): root.hasStatus('hover') == true",
ctest_equal_bool("mousemove(40, 40): root.hasStatus('hover') == true",
ui_widget_has_status(root, "hover"), TRUE);
ctest_euqal_bool("mousemove(40, 40): parent.hasStatus('hover') == true",
ctest_equal_bool("mousemove(40, 40): parent.hasStatus('hover') == true",
ui_widget_has_status(parent, "hover"), TRUE);
ctest_euqal_bool("mousemove(40, 40): child.hasStatus('hover') == true",
ctest_equal_bool("mousemove(40, 40): child.hasStatus('hover') == true",
ui_widget_has_status(child, "hover"), TRUE);
ev.type = UI_EVENT_MOUSEDOWN;
@@ -61,21 +61,21 @@ void test_widget_mouse_event(void)
ev.mouse.button = MOUSE_BUTTON_LEFT;
ui_dispatch_event(&ev);
ui_update();
ctest_euqal_bool("mousedown(40, 40): root.hasStatus('active') == true",
ctest_equal_bool("mousedown(40, 40): root.hasStatus('active') == true",
ui_widget_has_status(root, "active"), TRUE);
ctest_euqal_bool("mousedown(40, 40): parent.hasStatus('active') == true",
ctest_equal_bool("mousedown(40, 40): parent.hasStatus('active') == true",
ui_widget_has_status(parent, "active"), TRUE);
ctest_euqal_bool("mousedown(40, 40): child.hasStatus('active') == true",
ctest_equal_bool("mousedown(40, 40): child.hasStatus('active') == true",
ui_widget_has_status(child, "active"), TRUE);
ev.type = UI_EVENT_MOUSEUP;
ui_dispatch_event(&ev);
ui_update();
ctest_euqal_bool("mouseup(40, 40): root.hasStatus('active') == false",
ctest_equal_bool("mouseup(40, 40): root.hasStatus('active') == false",
ui_widget_has_status(root, "active"), FALSE);
ctest_euqal_bool("mouseup(40, 40): parent.hasStatus('active') == false",
ctest_equal_bool("mouseup(40, 40): parent.hasStatus('active') == false",
ui_widget_has_status(parent, "active"), FALSE);
ctest_euqal_bool("mouseup(40, 40): child.hasStatus('active') == false",
ctest_equal_bool("mouseup(40, 40): child.hasStatus('active') == false",
ui_widget_has_status(child, "active"), FALSE);
ev.type = UI_EVENT_MOUSEMOVE;
@@ -83,22 +83,22 @@ void test_widget_mouse_event(void)
ev.mouse.y = 80;
ui_dispatch_event(&ev);
ui_update();
ctest_euqal_bool("mousemove(80, 80): root.hasStatus('hover') == true",
ctest_equal_bool("mousemove(80, 80): root.hasStatus('hover') == true",
ui_widget_has_status(root, "hover"), TRUE);
ctest_euqal_bool("mousemove(80, 80): parent.hasStatus('hover') == true",
ctest_equal_bool("mousemove(80, 80): parent.hasStatus('hover') == true",
ui_widget_has_status(parent, "hover"), TRUE);
ctest_euqal_bool("mousemove(80, 80): child.hasStatus('hover') == false",
ctest_equal_bool("mousemove(80, 80): child.hasStatus('hover') == false",
ui_widget_has_status(child, "hover"), FALSE);
ev.mouse.x = 150;
ev.mouse.y = 150;
ui_dispatch_event(&ev);
ui_update();
ctest_euqal_bool("mousemove(150, 150): root.hasStatus('hover') == true",
ctest_equal_bool("mousemove(150, 150): root.hasStatus('hover') == true",
ui_widget_has_status(root, "hover"), TRUE);
ctest_euqal_bool("mousemove(150, 150): parent.hasStatus('hover') == false",
ctest_equal_bool("mousemove(150, 150): parent.hasStatus('hover') == false",
ui_widget_has_status(parent, "hover"), FALSE);
ctest_euqal_bool("mousemove(150, 150): child.hasStatus('hover') == false",
ctest_equal_bool("mousemove(150, 150): child.hasStatus('hover') == false",
ui_widget_has_status(child, "hover"), FALSE);
lcui_quit();
+6 -6
View File
@@ -66,14 +66,14 @@ static void check_widget_opactiy(void)
color = pd_canvas_get_pixel(&canvas, 10, 10);
pd_blend_pixel(&expected_color, &parent_bcolor,
(int)(PARENT_OPACITY * 255));
ctest_euqal_bool("check parent border color", check_color(expected_color, color),
ctest_equal_bool("check parent border color", check_color(expected_color, color),
TRUE);
expected_color = bgcolor;
color = pd_canvas_get_pixel(&canvas, 30, 30);
pd_blend_pixel(&expected_color, &parent_bgcolor,
(int)(PARENT_OPACITY * 255));
ctest_euqal_bool("check parent background color",
ctest_equal_bool("check parent background color",
check_color(expected_color, color), TRUE);
tmp = parent_bgcolor;
@@ -81,7 +81,7 @@ static void check_widget_opactiy(void)
color = pd_canvas_get_pixel(&canvas, 60, 90);
pd_blend_pixel(&tmp, &child_bgcolor, (int)(CHILD_OPACITY * 255));
pd_blend_pixel(&expected_color, &tmp, (int)(PARENT_OPACITY * 255));
ctest_euqal_bool("check child 1 background color",
ctest_equal_bool("check child 1 background color",
check_color(expected_color, color), TRUE);
tmp = parent_bgcolor;
@@ -89,18 +89,18 @@ static void check_widget_opactiy(void)
color = pd_canvas_get_pixel(&canvas, 60, 120);
pd_blend_pixel(&tmp, &child_footer_bgcolor, (int)(CHILD_OPACITY * 255));
pd_blend_pixel(&expected_color, &tmp, (int)(PARENT_OPACITY * 255));
ctest_euqal_bool("check child 1 footer background color",
ctest_equal_bool("check child 1 footer background color",
check_color(expected_color, color), TRUE);
expected_color = bgcolor;
color = pd_canvas_get_pixel(&canvas, 220, 90);
pd_blend_pixel(&expected_color, &child_bgcolor,
(int)(PARENT_OPACITY * 255));
ctest_euqal_bool("check child 2 background color",
ctest_equal_bool("check child 2 background color",
check_color(expected_color, color), TRUE);
expected_color = child_footer_bgcolor;
color = pd_canvas_get_pixel(&canvas, 220, 120);
ctest_euqal_bool("check child 2 footer background color",
ctest_equal_bool("check child 2 footer background color",
check_color(expected_color, color), TRUE);
pd_canvas_destroy(&canvas);
+15 -15
View File
@@ -38,7 +38,7 @@ void test_widget_rect(void)
ui_dispatch_event(&e);
ui_update();
ui_widget_get_dirty_rects(root, &rects);
ctest_euqal_bool("app.trigger({ type: 'mousemove', x: 150, y: 150}), "
ctest_equal_bool("app.trigger({ type: 'mousemove', x: 150, y: 150}), "
"root.getDirtyRects().length == 0",
rects.length == 0, TRUE);
@@ -47,7 +47,7 @@ void test_widget_rect(void)
ui_dispatch_event(&e);
ui_update();
ui_widget_get_dirty_rects(root, &rects);
ctest_euqal_bool("app.trigger({ type: 'mousemove', x: 80, y: 80 }), "
ctest_equal_bool("app.trigger({ type: 'mousemove', x: 80, y: 80 }), "
"root.getDirtyRects().length == 1",
rects.length == 1, TRUE);
@@ -58,7 +58,7 @@ void test_widget_rect(void)
if (rects.length == 1) {
rect = *(pd_rect_t *)list_get(&rects, 0);
}
ctest_euqal_pd_rect("root.getDirtyRects()[0]", &rect, &expected_rect);
ctest_equal_pd_rect("root.getDirtyRects()[0]", &rect, &expected_rect);
list_destroy(&rects, free);
e.mouse.x = 40;
@@ -66,7 +66,7 @@ void test_widget_rect(void)
ui_dispatch_event(&e);
ui_update();
ui_widget_get_dirty_rects(root, &rects);
ctest_euqal_bool("app.trigger({ type: 'mousemove', x: 40, y: 40 }), "
ctest_equal_bool("app.trigger({ type: 'mousemove', x: 40, y: 40 }), "
"root.getDirtyRects().length == 0",
rects.length == 0, TRUE);
@@ -77,26 +77,26 @@ void test_widget_rect(void)
ui_dispatch_event(&e);
ui_update();
ui_widget_get_dirty_rects(root, &rects);
ctest_euqal_bool("app.trigger({ type: 'mousedown', x: 40, y: 40 }), "
ctest_equal_bool("app.trigger({ type: 'mousedown', x: 40, y: 40 }), "
"root.getDirtyRects().length == 1",
rects.length == 1, TRUE);
if (rects.length == 1) {
rect = *(pd_rect_t *)list_get(&rects, 0);
}
ctest_euqal_pd_rect("root.getDirtyRects()[0]", &rect, &expected_rect);
ctest_equal_pd_rect("root.getDirtyRects()[0]", &rect, &expected_rect);
list_destroy(&rects, free);
e.type = UI_EVENT_MOUSEUP;
ui_dispatch_event(&e);
ui_update();
ui_widget_get_dirty_rects(root, &rects);
ctest_euqal_bool("app.trigger({ type: 'mouseup', x: 40, y: 40 }), "
ctest_equal_bool("app.trigger({ type: 'mouseup', x: 40, y: 40 }), "
"root.getDirtyRects().length == 1",
rects.length == 1, TRUE);
if (rects.length == 1) {
rect = *(pd_rect_t *)list_get(&rects, 0);
}
ctest_euqal_pd_rect("root.getDirtyRects()[0]", &rect, &expected_rect);
ctest_equal_pd_rect("root.getDirtyRects()[0]", &rect, &expected_rect);
list_destroy(&rects, free);
e.type = UI_EVENT_MOUSEMOVE;
@@ -105,7 +105,7 @@ void test_widget_rect(void)
ui_dispatch_event(&e);
ui_update();
ui_widget_get_dirty_rects(root, &rects);
ctest_euqal_bool("app.trigger({ type: 'mousemove', x: 80, y: 80 }), "
ctest_equal_bool("app.trigger({ type: 'mousemove', x: 80, y: 80 }), "
"root.getDirtyRects().length == 0",
rects.length == 0, TRUE);
@@ -115,13 +115,13 @@ void test_widget_rect(void)
ui_update();
ui_widget_get_dirty_rects(root, &rects);
ctest_euqal_bool("app.trigger({ type: 'mousemove', x: 150, y: 150 }), "
ctest_equal_bool("app.trigger({ type: 'mousemove', x: 150, y: 150 }), "
"root.getDirtyRects().length == 1",
rects.length == 1, TRUE);
if (rects.length == 1) {
rect = *(pd_rect_t *)list_get(&rects, 0);
}
ctest_euqal_pd_rect("root.getDirtyRects()[0]", &rect, &expected_rect);
ctest_equal_pd_rect("root.getDirtyRects()[0]", &rect, &expected_rect);
list_destroy(&rects, free);
expected_rect.x = 21;
@@ -131,12 +131,12 @@ void test_widget_rect(void)
ui_widget_remove(child);
ui_update();
ui_widget_get_dirty_rects(root, &rects);
ctest_euqal_bool("child.destroy(), root.getDirtyRects().length == 1",
ctest_equal_bool("child.destroy(), root.getDirtyRects().length == 1",
rects.length == 1, TRUE);
if (rects.length == 1) {
rect = *(pd_rect_t *)list_get(&rects, 0);
}
ctest_euqal_pd_rect("root.getDirtyRects()[0]", &rect, &expected_rect);
ctest_equal_pd_rect("root.getDirtyRects()[0]", &rect, &expected_rect);
list_destroy(&rects, free);
expected_rect.x = 0;
@@ -146,12 +146,12 @@ void test_widget_rect(void)
ui_widget_remove(parent);
ui_update();
ui_widget_get_dirty_rects(root, &rects);
ctest_euqal_bool("parent.destroy(), root.getDirtyRects().length == 1",
ctest_equal_bool("parent.destroy(), root.getDirtyRects().length == 1",
rects.length == 1, TRUE);
if (rects.length == 1) {
rect = *(pd_rect_t *)list_get(&rects, 0);
}
ctest_euqal_pd_rect("root.getDirtyRects()[0]", &rect, &expected_rect);
ctest_equal_pd_rect("root.getDirtyRects()[0]", &rect, &expected_rect);
list_destroy(&rects, free);
lcui_destroy();
+9 -9
View File
@@ -6,13 +6,13 @@ static void check_widget_attribute(void)
ui_widget_t* w;
w = ui_get_widget("test-attr-disabled-1");
ctest_euqal_bool("check element-1 is disabled", w->disabled, TRUE);
ctest_equal_bool("check element-1 is disabled", w->disabled, TRUE);
w = ui_get_widget("test-attr-disabled-2");
ctest_euqal_bool("check element-2 is disabled", w->disabled, TRUE);
ctest_equal_bool("check element-2 is disabled", w->disabled, TRUE);
w = ui_get_widget("test-attr-disabled-3");
ctest_euqal_bool("check element-3 is disabled", w->disabled, TRUE);
ctest_equal_bool("check element-3 is disabled", w->disabled, TRUE);
w = ui_get_widget("test-attr-disabled-4");
ctest_euqal_bool("check element-4 is normal", w->disabled, FALSE);
ctest_equal_bool("check element-4 is normal", w->disabled, FALSE);
}
static void check_widget_loaded_from_nested_xml(void)
@@ -20,13 +20,13 @@ static void check_widget_loaded_from_nested_xml(void)
ui_widget_t* w;
w = ui_get_widget("test-nested-1");
ctest_euqal_bool("check test-nested-1 should exist", w != NULL, TRUE);
ctest_equal_bool("check test-nested-1 should exist", w != NULL, TRUE);
w = ui_get_widget("test-nested-2");
ctest_euqal_bool("check test-nested-2 should exist", w != NULL, TRUE);
ctest_equal_bool("check test-nested-2 should exist", w != NULL, TRUE);
w = ui_get_widget("test-nested-3");
ctest_euqal_bool("check test-nested-3 should exist", w != NULL, TRUE);
ctest_equal_bool("check test-nested-3 should exist", w != NULL, TRUE);
w = ui_get_widget("test-nested-4");
ctest_euqal_bool("check test-nested-4 should exist", w != NULL, TRUE);
ctest_equal_bool("check test-nested-4 should exist", w != NULL, TRUE);
}
void test_xml_parser(void)
@@ -34,7 +34,7 @@ void test_xml_parser(void)
ui_widget_t *pack;
ui_init();
ctest_euqal_bool("load XML file",
ctest_equal_bool("load XML file",
(pack = ui_load_xml_file("test_xml_parser.xml")) != NULL,
TRUE);
if (!pack) {
+2 -2
View File
@@ -3,13 +3,13 @@
#include <ui/rect.h>
#include <ctest.h>
static inline bool ctest_euqal_pd_rect(const char *name, pd_rect_t *actual,
static inline bool ctest_equal_pd_rect(const char *name, pd_rect_t *actual,
pd_rect_t *expected)
{
return ctest_equal(name, (ctest_to_str_func_t)pd_rect_to_str, actual, expected);
}
static inline bool ctest_euqal_ui_rect(const char *name, ui_rect_t *actual,
static inline bool ctest_equal_ui_rect(const char *name, ui_rect_t *actual,
ui_rect_t *expected)
{
return ctest_equal(name, (ctest_to_str_func_t)ui_rect_to_str, actual, expected);