# Test scenario for session/session_handler_scenario_test

# Tests for ImeOn/Off, Cancel, Revert

SET_CONFIG	preedit_method	ROMAN
SWITCH_COMPOSITION_MODE	HIRAGANA
SET_CONFIG	session_keymap	MSIME

# ON/OFF is largely handled by client.
# Here we perform basic test only.
RESET_CONTEXT
SEND_KEY	ON
SEND_KEYS	a
EXPECT_PREEDIT	あ
EXPECT_RESULT

SEND_KEY	OFF
EXPECT_PREEDIT
EXPECT_RESULT	あ
SEND_KEYS	a
EXPECT_CONSUMED	false

# Test for Cancel
RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	CTRL z
EXPECT_PREEDIT
EXPECT_RESULT
# IME should be on after Cancel.
SEND_KEY	a
EXPECT_PREEDIT	あ

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	ESC
EXPECT_PREEDIT
EXPECT_RESULT
# IME should be on after Cancel.
SEND_KEY	a
EXPECT_PREEDIT	あ

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SHIFT ESC
EXPECT_PREEDIT
EXPECT_RESULT
# IME should be on after Cancel.
SEND_KEY	a
EXPECT_PREEDIT	あ

# IMEOff in Composition
RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	HANKAKU/ZENKAKU
EXPECT_PREEDIT
EXPECT_RESULT	あ

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	KANJI
EXPECT_PREEDIT
EXPECT_RESULT	あ

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	OFF
EXPECT_PREEDIT
EXPECT_RESULT	あ

# Cancel in Conversion
RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	BACKSPACE
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	CTRL BACKSPACE
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	CTRL g
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	CTRL h
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	CTRL z
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	DELETE
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	ESC
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	SHIFT BACKSPACE
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	SHIFT ESC
EXPECT_PREEDIT	あ
EXPECT_RESULT

# IMEOff in Conversion
RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	HANKAKU/ZENKAKU
EXPECT_PREEDIT
EXPECT_RESULT	あ

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	KANJI
EXPECT_PREEDIT
EXPECT_RESULT	あ

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	OFF
EXPECT_PREEDIT
EXPECT_RESULT	あ


SET_CONFIG	session_keymap	KOTOERI

# ON/OFF is largely handled by client.
# Here we perform basic test only.
RESET_CONTEXT
SEND_KEY	ON
SEND_KEYS	a
EXPECT_PREEDIT	あ
EXPECT_RESULT

SEND_KEY	OFF
EXPECT_PREEDIT
EXPECT_RESULT	あ
SEND_KEYS	a
EXPECT_CONSUMED	false

# Test for Cancel
RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	CTRL g
EXPECT_PREEDIT
EXPECT_RESULT
# IME should be on after Cancel.
SEND_KEY	a
EXPECT_PREEDIT	あ

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	ESC
EXPECT_PREEDIT
EXPECT_RESULT
# IME should be on after Cancel.
SEND_KEY	a
EXPECT_PREEDIT	あ

# IMEOff in Composition
RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	HANKAKU/ZENKAKU
EXPECT_PREEDIT
EXPECT_RESULT	あ

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	KANJI
EXPECT_PREEDIT
EXPECT_RESULT	あ

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	OFF
EXPECT_PREEDIT
EXPECT_RESULT	あ

# Cancel in Conversion
RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	BACKSPACE
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	CTRL h
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	ESC
EXPECT_PREEDIT	あ
EXPECT_RESULT

# IMEOff in Conversion
RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	HANKAKU/ZENKAKU
EXPECT_PREEDIT
EXPECT_RESULT	あ

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	KANJI
EXPECT_PREEDIT
EXPECT_RESULT	あ

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	OFF
EXPECT_PREEDIT
EXPECT_RESULT	あ

SET_CONFIG	session_keymap	ATOK

# ON/OFF is largely handled by client.
# Here we perform basic test only.
RESET_CONTEXT
SEND_KEY	ON
SEND_KEYS	a
EXPECT_PREEDIT	あ
EXPECT_RESULT

# CancelAndIMEOff
SEND_KEY	OFF
EXPECT_PREEDIT
EXPECT_RESULT
SEND_KEYS	a
EXPECT_CONSUMED	false

# Test for Cancel
RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	CTRL [
EXPECT_PREEDIT
EXPECT_RESULT
# IME should be on after Cancel.
SEND_KEY	a
EXPECT_PREEDIT	あ

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	ESC
EXPECT_PREEDIT
EXPECT_RESULT
# IME should be on after Cancel.
SEND_KEY	a
EXPECT_PREEDIT	あ

# CancelAndIMEOff
RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	HANKAKU/ZENKAKU
EXPECT_PREEDIT
EXPECT_RESULT
# IME should be off after Cancel.
SEND_KEY	a
EXPECT_CONSUMED	false

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	KANJI
EXPECT_PREEDIT
EXPECT_RESULT
# IME should be off after Cancel.
SEND_KEY	a
EXPECT_CONSUMED	false

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	OFF
EXPECT_PREEDIT
EXPECT_RESULT
# IME should be off after Cancel.
SEND_KEY	a
EXPECT_CONSUMED	false

# Cancel in Conversion
RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	BACKSPACE
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	CTRL [
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	CTRL h
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	ESC
EXPECT_PREEDIT	あ
EXPECT_RESULT

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	INSERT
EXPECT_PREEDIT	あ
EXPECT_RESULT

# CancelAndIMEOff in Conversion
RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	HANKAKU/ZENKAKU
EXPECT_PREEDIT
EXPECT_RESULT
SEND_KEY	a
EXPECT_CONSUMED	false

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	KANJI
EXPECT_PREEDIT
EXPECT_RESULT
SEND_KEY	a
EXPECT_CONSUMED	false

RESET_CONTEXT
SEND_KEY	ON
SEND_KEY	a
EXPECT_PREEDIT	あ
SEND_KEY	SPACE
EXPECT_PREEDIT	あ
SEND_KEY	OFF
EXPECT_PREEDIT
EXPECT_RESULT
SEND_KEY	a
EXPECT_CONSUMED	false
