Skip to content

Commit a99f207

Browse files
Even-YeYiluMao
authored andcommitted
add backlight/button/lcd/uvoice/unzip test cases
1 parent beed5e1 commit a99f207

File tree

12 files changed

+662
-25
lines changed

12 files changed

+662
-25
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (C) 2020-2023 Alibaba Group Holding Limited
3+
*/
4+
5+
#include <stdio.h>
6+
#include <sched.h>
7+
#include <pthread.h>
8+
#include <yunit/yunit.h>
9+
extern void backlight_test_init(void);
10+
extern void backlight_test_onoff(void);
11+
extern void backlight_test_silent_reset(void);
12+
extern void backlight_test_get_status(void);
13+
14+
static int init(void)
15+
{
16+
return 0;
17+
}
18+
19+
static int cleanup(void)
20+
{
21+
return 0;
22+
}
23+
24+
static void setup(void)
25+
{
26+
}
27+
28+
static void teardown(void)
29+
{
30+
}
31+
32+
static void setup_pri_save(void)
33+
{
34+
}
35+
36+
static void teardown_pri_restore(void)
37+
{
38+
}
39+
40+
static yunit_test_case_t aos_backlight_testcases[] = {
41+
{"backlight_test_init", backlight_test_init},
42+
{"backlight_test_onoff", backlight_test_onoff},
43+
{"backlight_test_silent_reset", backlight_test_silent_reset},
44+
{"backlight_test_get_status", backlight_test_get_status},
45+
YUNIT_TEST_CASE_NULL};
46+
47+
static yunit_test_suite_t suites[] = {
48+
{"backlight", init, cleanup, setup, teardown, aos_backlight_testcases},
49+
YUNIT_TEST_SUITE_NULL};
50+
51+
void aos_backlight_test(void)
52+
{
53+
yunit_add_test_suites(suites);
54+
}
55+
56+
AOS_TESTCASE(aos_backlight_test);
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (C) 2015-2023 Alibaba Group Holding Limited
3+
*/
4+
5+
#include <stdio.h>
6+
#include <stdint.h>
7+
#include <stdlib.h>
8+
#include <yunit/yunit.h>
9+
#include "aos/kernel.h"
10+
11+
/* module name used by log print*/
12+
#define MODULE_NAME "backlight_test"
13+
14+
/* test backlight init */
15+
void backlight_test_init(void)
16+
{
17+
int ret;
18+
ret=aos_lcd_backlight_on();
19+
for (uint8_t i = 0; i < 5; i++) {
20+
ret = aos_lcd_backlight(i*20);
21+
aos_lcd_backlight_valid();
22+
aos_msleep(2000);
23+
YUNIT_ASSERT_EQUAL(ret, 0);
24+
}
25+
}
26+
27+
/* test backlight onoff */
28+
void backlight_test_onoff(void)
29+
{
30+
int ret;
31+
aos_lcd_backlight_off();
32+
YUNIT_ASSERT_EQUAL(ret, 0);
33+
aos_msleep(2000);
34+
aos_lcd_backlight_on();
35+
YUNIT_ASSERT_EQUAL(ret, 0);
36+
aos_msleep(2000);
37+
aos_lcd_backlight_toggle();
38+
YUNIT_ASSERT_EQUAL(ret, 0);
39+
aos_msleep(2000);
40+
}
41+
42+
/* test backlight silent_reset */
43+
void backlight_test_silent_reset(void)
44+
{
45+
int ret;
46+
ret = aos_lcd_backlight(5);
47+
YUNIT_ASSERT_EQUAL(ret, 0);
48+
aos_lcd_backlight_valid_for_silent_reset();
49+
YUNIT_ASSERT_EQUAL(ret, 0);
50+
}
51+
52+
/* test backlight get_status */
53+
void backlight_test_get_status(void)
54+
{
55+
int ret;
56+
uint8_t onoff, level;
57+
ret = aos_lcd_backlight_status(&onoff, &level);
58+
YUNIT_ASSERT_EQUAL(ret, 0);
59+
printf("[%s] backlight status onoff=%d level=%d \n", MODULE_NAME, onoff, level);
60+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (C) 2020-2023 Alibaba Group Holding Limited
3+
*/
4+
5+
#include <stdio.h>
6+
#include <yunit/yunit.h>
7+
extern void button_test_init(void);
8+
9+
static int init(void)
10+
{
11+
return 0;
12+
}
13+
14+
static int cleanup(void)
15+
{
16+
return 0;
17+
}
18+
19+
static void setup(void)
20+
{
21+
}
22+
23+
static void teardown(void)
24+
{
25+
}
26+
27+
static yunit_test_case_t aos_button_testcases[] = {
28+
{"button_test_init", button_test_init}, YUNIT_TEST_CASE_NULL};
29+
30+
static yunit_test_suite_t suites[] = {
31+
{"button", init, cleanup, setup, teardown, aos_button_testcases},
32+
YUNIT_TEST_SUITE_NULL};
33+
34+
void aos_button_test(void)
35+
{
36+
yunit_add_test_suites(suites);
37+
}
38+
39+
AOS_TESTCASE(aos_button_test);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (C) 2015-2023 Alibaba Group Holding Limited
3+
*/
4+
5+
#include <stdint.h>
6+
#include <stdio.h>
7+
#include <stdlib.h>
8+
#include "aos/kernel.h"
9+
10+
#include <aos_button.h>
11+
#include <yunit/yunit.h>
12+
13+
/* module name used by log print*/
14+
#define MODULE_NAME "button_test"
15+
16+
/* module parameters */
17+
aos_key_cfg_t button_cfg;
18+
static uint8_t button_short_press_flag = 0;
19+
static uint8_t button_long_press_flag = 0;
20+
21+
static void _short_press_handler() { button_short_press_flag = 1; }
22+
static void _long_press_handler() { button_long_press_flag = 1; }
23+
24+
/* test button init */
25+
void button_test_init(void)
26+
{
27+
int ret;
28+
button_cfg.short_press_max_ms = 500;
29+
button_cfg.long_press_min_ms = 1000;
30+
button_cfg.short_press_handler = _short_press_handler;
31+
button_cfg.long_press_handler = _long_press_handler;
32+
ret = aos_key_init(button_cfg);
33+
YUNIT_ASSERT_EQUAL(ret, 0);
34+
printf("please short press button");
35+
aos_msleep(2000);
36+
YUNIT_ASSERT_EQUAL(button_short_press_flag, 1);
37+
printf("please long press button for 1s");
38+
aos_msleep(2000);
39+
YUNIT_ASSERT_EQUAL(button_long_press_flag, 1);
40+
}

test/testcase/kv_test/function/kv_test_device.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,10 @@ static uint8_t sem_flag = 0;
2424
void kv_test_init(void)
2525
{
2626
int ret;
27-
//ret=aos_hal_flash_init(HAL_PARTITION_APPLICATION);
27+
ret=aos_hal_flash_init(HAL_PARTITION_APPLICATION);
2828
YUNIT_ASSERT_EQUAL(ret, 0);
2929
}
3030

31-
#if 0
32-
/* test kv item */
33-
void kv_test_item(void)
34-
{
35-
int ret;
36-
int set_len = strlen(test_val);
37-
int get_len;
38-
char get_value[32] = {0};
39-
ret = kv_item_set(test_key, test_val, set_len, 1); /* set kv item */
40-
YUNIT_ASSERT_EQUAL(ret, 0);
41-
ret = kv_item_get(test_key, get_value, &get_len); /* get kv item */
42-
YUNIT_ASSERT_EQUAL(ret, 0);
43-
YUNIT_ASSERT_EQUAL(get_len, set_len);
44-
ret = strcmp(get_value, test_val);
45-
YUNIT_ASSERT_EQUAL(ret, 0);
46-
ret = kv_item_delete(test_key); /* del kv item */
47-
YUNIT_ASSERT_EQUAL(ret, 0);
48-
}
49-
#endif
50-
5131
/* test kv flash */
5232
void kv_test_flash(void)
5333
{

test/testcase/kv_test/kv_test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ static void teardown_pri_restore(void)
3939
}
4040

4141
static yunit_test_case_t aos_kv_testcases[] = {
42-
//{ "kv_test_init", kv_test_init},
43-
//{ "kv_test_flash", kv_test_flash},
44-
//{ "kv_test_lock", kv_test_lock},
45-
//{ "kv_test_malloc", kv_test_malloc},
42+
{ "kv_test_init", kv_test_init},
43+
{ "kv_test_flash", kv_test_flash},
44+
{ "kv_test_lock", kv_test_lock},
45+
{ "kv_test_malloc", kv_test_malloc},
4646
{ "kv_test_task", kv_test_task},
4747
YUNIT_TEST_CASE_NULL
4848
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright (C) 2015-2023 Alibaba Group Holding Limited
3+
*/
4+
5+
#include <stdio.h>
6+
#include <stdint.h>
7+
#include <stdlib.h>
8+
#include <aos_lcd.h>
9+
#include <yunit/yunit.h>
10+
#include "aos/kernel.h"
11+
12+
#define YELLOW 0xFFE0
13+
#define BLUE 0x001F
14+
15+
/* module name used by log print*/
16+
#define MODULE_NAME "lcd_test"
17+
18+
/* module parameters */
19+
#define area_image_w 10
20+
#define area_image_h 10
21+
uint16_t *area_image = NULL;
22+
23+
/* test lcd init */
24+
void lcd_test_init(void)
25+
{
26+
int ret;
27+
ret = aos_hal_lcd_init(1);
28+
YUNIT_ASSERT_EQUAL(ret, 0);
29+
}
30+
31+
/* test lcd onoff */
32+
void lcd_test_onoff(void)
33+
{
34+
int ret;
35+
ret = aos_hal_lcd_display_on();
36+
YUNIT_ASSERT_EQUAL(ret, 0);
37+
ret = aos_hal_lcd_display_off();
38+
YUNIT_ASSERT_EQUAL(ret, 0);
39+
}
40+
41+
/* test lcd image */
42+
static void color_prepare(uint16_t color) {
43+
area_image = (uint16_t*)aos_malloc(area_image_w*area_image_h*2);
44+
for (int i = 0; i <(area_image_w*area_image_h); i++) {
45+
area_image[i] = color;
46+
}
47+
}
48+
49+
void lcd_test_image(void)
50+
{
51+
int ret;
52+
color_prepare(YELLOW);
53+
ret=aos_hal_lcd_image(0,0,area_image_w,area_image_h,area_image);
54+
YUNIT_ASSERT_EQUAL(ret, 0);
55+
aos_msleep(500);
56+
ret = aos_hal_lcd_clear(BLUE);
57+
YUNIT_ASSERT_EQUAL(ret, 0);
58+
aos_msleep(500);
59+
aos_free(area_image);
60+
}
61+
62+
/* test lcd finalize */
63+
void lcd_test_finalize(void)
64+
{
65+
int ret;
66+
ret = aos_hal_lcd_display_off();
67+
YUNIT_ASSERT_EQUAL(ret, 0);
68+
}

test/testcase/lcd_test/lcd_test.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (C) 2020-2023 Alibaba Group Holding Limited
3+
*/
4+
5+
#include <stdio.h>
6+
#include <sched.h>
7+
#include <pthread.h>
8+
#include <yunit/yunit.h>
9+
extern void lcd_test_init(void);
10+
extern void lcd_test_onoff(void);
11+
extern void lcd_test_image(void);
12+
extern void lcd_test_finalize(void);
13+
14+
static int init(void)
15+
{
16+
return 0;
17+
}
18+
19+
static int cleanup(void)
20+
{
21+
return 0;
22+
}
23+
24+
static void setup(void)
25+
{
26+
}
27+
28+
static void teardown(void)
29+
{
30+
}
31+
32+
static void setup_pri_save(void)
33+
{
34+
}
35+
36+
static void teardown_pri_restore(void)
37+
{
38+
}
39+
40+
static yunit_test_case_t aos_lcd_testcases[] = {
41+
{ "lcd_test_init", lcd_test_init},
42+
{ "lcd_test_onoff", lcd_test_onoff},
43+
{ "lcd_test_image", lcd_test_image},
44+
{ "lcd_test_finalize", lcd_test_finalize},
45+
YUNIT_TEST_CASE_NULL
46+
};
47+
48+
static yunit_test_suite_t suites[] = {
49+
{ "lcd", init, cleanup, setup, teardown, aos_lcd_testcases },
50+
YUNIT_TEST_SUITE_NULL
51+
};
52+
53+
void aos_lcd_test(void)
54+
{
55+
yunit_add_test_suites(suites);
56+
}
57+
58+
AOS_TESTCASE(aos_lcd_test);

0 commit comments

Comments
 (0)