# Test scenario for session/session_handler_scenario_test

# Conversion

SEND_KEY	ON
SET_CONFIG	session_keymap	KOTOERI

# The spec for DisplayAs for ASCII is not defined.
# KOTOERI have no composition for ASCIIs (once the composition is started,
# we can input ASCIIs in composition).
# The current behavior is differ from platforms.
# TODO(team): Add test for composition with ASCIIs.

# TODO(team): Test DisplayAsHalfKatakana.
# DisplayAsHalfKatakana is not supported by the default keymap.

################################
# Tests for DisplayAsHalfWidth

# TODO(team): Fix the behavior.
# In KOTOERI, "あああ" will be converted into "aaa".

# Roman
SET_CONFIG	preedit_method	ROMAN

RESET_CONTEXT
SWITCH_INPUT_MODE	HIRAGANA
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	CTRL ;
EXPECT_PREEDIT	ｱk

RESET_CONTEXT
SWITCH_INPUT_MODE	FULL_KATAKANA
SEND_KEYS	ak
EXPECT_PREEDIT	アｋ
SEND_KEY	SPACE
SEND_KEY	CTRL ;
EXPECT_PREEDIT	ｱk

RESET_CONTEXT
SWITCH_INPUT_MODE	HALF_KATAKANA
SEND_KEYS	ak
EXPECT_PREEDIT	ｱk
SEND_KEY	SPACE
SEND_KEY	CTRL ;
EXPECT_PREEDIT	ｱk

# Kana
SET_CONFIG	preedit_method	KANA

RESET_CONTEXT
SWITCH_INPUT_MODE	HIRAGANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	ち
SEND_KEY	SPACE
SEND_KEY	CTRL ;
EXPECT_PREEDIT	ﾁ

RESET_CONTEXT
SWITCH_INPUT_MODE	FULL_KATAKANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	チ
SEND_KEY	SPACE
SEND_KEY	CTRL ;
EXPECT_PREEDIT	ﾁ

RESET_CONTEXT
SWITCH_INPUT_MODE	HALF_KATAKANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	ﾁ
SEND_KEY	SPACE
SEND_KEY	CTRL ;
EXPECT_PREEDIT	ﾁ

# Tests for keymaps for DisplayAsHalfWidth
CLEAR_ALL
SEND_KEY	ON
SET_CONFIG	session_keymap	KOTOERI
SWITCH_INPUT_MODE	HIRAGANA

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	F8
EXPECT_PREEDIT	ｱk

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	Option a
EXPECT_PREEDIT	ｱk

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	Option F4
EXPECT_PREEDIT	ｱk

################################
# Tests for DisplayAsHalfAlphanumeric

# Roman
SET_CONFIG	preedit_method	ROMAN

RESET_CONTEXT
SWITCH_INPUT_MODE	HIRAGANA
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	CTRL '
EXPECT_PREEDIT	ak

RESET_CONTEXT
SWITCH_INPUT_MODE	FULL_KATAKANA
SEND_KEYS	ak
EXPECT_PREEDIT	アｋ
SEND_KEY	SPACE
SEND_KEY	CTRL '
EXPECT_PREEDIT	ak

RESET_CONTEXT
SWITCH_INPUT_MODE	HALF_KATAKANA
SEND_KEYS	ak
EXPECT_PREEDIT	ｱk
SEND_KEY	SPACE
SEND_KEY	CTRL '
EXPECT_PREEDIT	ak

# Kana
SET_CONFIG	preedit_method	KANA

RESET_CONTEXT
SWITCH_INPUT_MODE	HIRAGANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	ち
SEND_KEY	SPACE
SEND_KEY	CTRL '
EXPECT_PREEDIT	a

RESET_CONTEXT
SWITCH_INPUT_MODE	FULL_KATAKANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	チ
SEND_KEY	SPACE
SEND_KEY	CTRL '
EXPECT_PREEDIT	a

RESET_CONTEXT
SWITCH_INPUT_MODE	HALF_KATAKANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	ﾁ
SEND_KEY	SPACE
SEND_KEY	CTRL '
EXPECT_PREEDIT	a

# Tests for keymaps for DisplayAsHalfWidth
CLEAR_ALL
SEND_KEY	ON
SET_CONFIG	session_keymap	KOTOERI
SWITCH_INPUT_MODE	HIRAGANA

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	CTRL :
EXPECT_PREEDIT	ak

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	F10
EXPECT_PREEDIT	ak

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	Option F5
EXPECT_PREEDIT	ak

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	Option s
EXPECT_PREEDIT	ak

################################
# Tests for DisplayAsHiragana

# Roman
SET_CONFIG	preedit_method	ROMAN

RESET_CONTEXT
SWITCH_INPUT_MODE	HIRAGANA
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	CTRL j
EXPECT_PREEDIT	あk

RESET_CONTEXT
SWITCH_INPUT_MODE	HALF_KATAKANA
SEND_KEYS	ak
EXPECT_PREEDIT	ｱk
SEND_KEY	SPACE
SEND_KEY	CTRL j
EXPECT_PREEDIT	あk

# Kana
SET_CONFIG	preedit_method	KANA

RESET_CONTEXT
SWITCH_INPUT_MODE	HIRAGANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	ち
SEND_KEY	SPACE
SEND_KEY	CTRL j
EXPECT_PREEDIT	ち

RESET_CONTEXT
SWITCH_INPUT_MODE	FULL_KATAKANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	チ
SEND_KEY	SPACE
SEND_KEY	CTRL j
EXPECT_PREEDIT	ち

RESET_CONTEXT
SWITCH_INPUT_MODE	HALF_KATAKANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	ﾁ
SEND_KEY	SPACE
SEND_KEY	CTRL j
EXPECT_PREEDIT	ち

# Tests for keymaps for DisplayAsHalfWidth
CLEAR_ALL
SEND_KEY	ON
SET_CONFIG	session_keymap	KOTOERI
SWITCH_INPUT_MODE	HIRAGANA

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	F6
EXPECT_PREEDIT	あk

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	Option F1
EXPECT_PREEDIT	あk

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	Option z
EXPECT_PREEDIT	あk

################################
# Tests for DisplayAsFullKatakana

# Roman
SET_CONFIG	preedit_method	ROMAN

RESET_CONTEXT
SWITCH_INPUT_MODE	HIRAGANA
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	CTRL k
EXPECT_PREEDIT	アk

RESET_CONTEXT
SWITCH_INPUT_MODE	FULL_KATAKANA
SEND_KEYS	ak
EXPECT_PREEDIT	アｋ
SEND_KEY	SPACE
SEND_KEY	CTRL k
EXPECT_PREEDIT	アk

RESET_CONTEXT
SWITCH_INPUT_MODE	HALF_KATAKANA
SEND_KEYS	ak
EXPECT_PREEDIT	ｱk
SEND_KEY	SPACE
SEND_KEY	CTRL k
EXPECT_PREEDIT	アk

# Kana
SET_CONFIG	preedit_method	KANA

RESET_CONTEXT
SWITCH_INPUT_MODE	HIRAGANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	ち
SEND_KEY	SPACE
SEND_KEY	CTRL k
EXPECT_PREEDIT	チ

RESET_CONTEXT
SWITCH_INPUT_MODE	FULL_KATAKANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	チ
SEND_KEY	SPACE
SEND_KEY	CTRL k
EXPECT_PREEDIT	チ

RESET_CONTEXT
SWITCH_INPUT_MODE	HALF_KATAKANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	ﾁ
SEND_KEY	SPACE
SEND_KEY	CTRL k
EXPECT_PREEDIT	チ

# Tests for keymaps for DisplayAsHalfWidth
CLEAR_ALL
SEND_KEY	ON
SET_CONFIG	session_keymap	KOTOERI
SWITCH_INPUT_MODE	HIRAGANA

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	F7
EXPECT_PREEDIT	アk

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	Option F2
EXPECT_PREEDIT	アk

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	Option x
EXPECT_PREEDIT	アk

################################
# Tests for DisplayAsFullAlphanumeric

# Roman
SET_CONFIG	preedit_method	ROMAN

RESET_CONTEXT
SWITCH_INPUT_MODE	HIRAGANA
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	CTRL l
EXPECT_PREEDIT	ａk

RESET_CONTEXT
SWITCH_INPUT_MODE	FULL_KATAKANA
SEND_KEYS	ak
EXPECT_PREEDIT	アｋ
SEND_KEY	SPACE
SEND_KEY	CTRL l
EXPECT_PREEDIT	ａk

RESET_CONTEXT
SWITCH_INPUT_MODE	HALF_KATAKANA
SEND_KEYS	ak
EXPECT_PREEDIT	ｱk
SEND_KEY	SPACE
SEND_KEY	CTRL l
EXPECT_PREEDIT	ａk

# Kana
SET_CONFIG	preedit_method	KANA

RESET_CONTEXT
SWITCH_INPUT_MODE	HIRAGANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	ち
SEND_KEY	SPACE
SEND_KEY	CTRL l
EXPECT_PREEDIT	ａ

RESET_CONTEXT
SWITCH_INPUT_MODE	FULL_KATAKANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	チ
SEND_KEY	SPACE
SEND_KEY	CTRL l
EXPECT_PREEDIT	ａ

RESET_CONTEXT
SWITCH_INPUT_MODE	HALF_KATAKANA
SEND_KANA_KEYS	a	ち
EXPECT_PREEDIT	ﾁ
SEND_KEY	SPACE
SEND_KEY	CTRL l
EXPECT_PREEDIT	ａ

# Tests for keymaps for DisplayAsHalfWidth
CLEAR_ALL
SEND_KEY	ON
SET_CONFIG	session_keymap	KOTOERI
SWITCH_INPUT_MODE	HIRAGANA

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	F9
EXPECT_PREEDIT	ａk

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	Option F3
EXPECT_PREEDIT	ａk

RESET_CONTEXT
SEND_KEYS	ak
EXPECT_PREEDIT	あｋ
SEND_KEY	SPACE
SEND_KEY	Option c
EXPECT_PREEDIT	ａk

