summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-07-23 11:10:02 +0800
committerChromeBot <chrome-bot@google.com>2013-07-23 16:06:22 -0700
commitf98def750d61d48e654f02e2384c517e0d698a99 (patch)
treec08ba3d72bbcb37d3ec633ffb88f1779761eb98d
parent74abf3697109b2719d0dbc4e60667740de872fb3 (diff)
downloadchrome-ec-f98def750d61d48e654f02e2384c517e0d698a99.tar.gz
Test power button in kb_8042 test
This checks keycodes are sent correctly when power button is pressed. BUG=chrome-os-partner:19236 TEST=Pass the test BRANCH=None Change-Id: Ibaa4ffce749167be5b8376aada0786f9760e7707 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/62955 Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--test/kb_8042.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/kb_8042.c b/test/kb_8042.c
index a0fbaad4d5..0bac5fedcf 100644
--- a/test/kb_8042.c
+++ b/test/kb_8042.c
@@ -14,6 +14,7 @@
#include "keyboard_protocol.h"
#include "keyboard_scan.h"
#include "lpc.h"
+#include "power_button.h"
#include "system.h"
#include "test_util.h"
#include "timer.h"
@@ -28,6 +29,8 @@ static unsigned int lpc_char_cnt;
/*****************************************************************************/
/* Mock functions */
+static int mock_power_button = 1;
+
int lid_is_open(void)
{
return 1;
@@ -38,6 +41,13 @@ void lpc_keyboard_put_char(uint8_t chr, int send_irq)
lpc_char_buf[lpc_char_cnt++] = chr;
}
+int gpio_get_level(enum gpio_signal signal)
+{
+ if (signal == GPIO_POWER_BUTTON_L)
+ return mock_power_button;
+ return 0;
+}
+
/*****************************************************************************/
/* Test utilities */
@@ -194,6 +204,43 @@ static int test_scancode_set2(void)
return EC_SUCCESS;
}
+static int test_power_button(void)
+{
+ set_scancode(1);
+ test_chipset_on();
+
+ mock_power_button = 0;
+ power_button_interrupt(GPIO_POWER_BUTTON_L);
+ VERIFY_LPC_CHAR_DELAY("\xe0\x5e", 100);
+
+ mock_power_button = 1;
+ power_button_interrupt(GPIO_POWER_BUTTON_L);
+ VERIFY_LPC_CHAR_DELAY("\xe0\xde", 100);
+
+ set_scancode(2);
+ write_cmd_byte(read_cmd_byte() & ~I8042_XLATE);
+
+ mock_power_button = 0;
+ power_button_interrupt(GPIO_POWER_BUTTON_L);
+ VERIFY_LPC_CHAR_DELAY("\xe0\x37", 100);
+
+ mock_power_button = 1;
+ power_button_interrupt(GPIO_POWER_BUTTON_L);
+ VERIFY_LPC_CHAR_DELAY("\xe0\xf0\x37", 100);
+
+ test_chipset_off();
+
+ mock_power_button = 0;
+ power_button_interrupt(GPIO_POWER_BUTTON_L);
+ VERIFY_NO_CHAR();
+
+ mock_power_button = 1;
+ power_button_interrupt(GPIO_POWER_BUTTON_L);
+ VERIFY_NO_CHAR();
+
+ return EC_SUCCESS;
+}
+
static int test_sysjump(void)
{
set_scancode(2);
@@ -231,6 +278,7 @@ void run_test(void)
RUN_TEST(test_disable_keystroke);
RUN_TEST(test_typematic);
RUN_TEST(test_scancode_set2);
+ RUN_TEST(test_power_button);
RUN_TEST(test_sysjump);
} else {
RUN_TEST(test_sysjump_cont);