Exemple #1
0
void test_Backspace_in_select()
{
    ChewingContext *ctx;
    int ret;

    ctx = chewing_new();
    start_testcase(ctx, fd);

    type_keystroke_by_string(ctx, "`<B>");
    ok_candidate(ctx, NULL, 0);

    type_keystroke_by_string(ctx, "hk4");
    ret = chewing_cand_TotalChoice(ctx);
    ok(ret == 0, "chewing_cand_TotalChoice() returns `%d' shall be `%d'", ret, 0);

    type_keystroke_by_string(ctx, "<D>");
    ret = chewing_cand_TotalChoice(ctx);
    ok(ret > 0, "chewing_cand_TotalChoice() returns `%d' shall be greater than `%d'", ret, 0);

    type_keystroke_by_string(ctx, "<B>");
    ret = chewing_cand_TotalChoice(ctx);
    ok(ret == 0, "chewing_cand_TotalChoice() returns `%d' shall be `%d'", ret, 0);

    chewing_delete(ctx);
}
Exemple #2
0
void test_select_candidate_rearward()
{
    /*
     * The following phrases are in dict
     * 一上來
     * 上來
     * 移上來
     * 移上
     */

    static const char *CAND_1[] = {
        "\xE4\xB8\x80\xE4\xB8\x8A\xE4\xBE\x86" /* 一上來 */ ,
        "\xE7\xA7\xBB\xE4\xB8\x8A\xE4\xBE\x86" /* 移上來 */ ,
    };

    static const char *CAND_2[] = {
        "\xE4\xB8\x8A\xE4\xBE\x86" /* 上來 */ ,
    };
    ChewingContext *ctx;

    clean_userphrase();

    ctx = chewing_new();
    start_testcase(ctx, fd);

    chewing_set_maxChiSymbolLen(ctx, 16);
    chewing_set_phraseChoiceRearward(ctx, 1);

    type_keystroke_by_string(ctx, "u6g;4x96");  /* ㄧˊㄕㄤˋㄌㄞˊ */
    ok_preedit_buffer(ctx, CAND_1[0]);

    type_keystroke_by_string(ctx, "<D>");       /* ㄧˊㄕㄤˋㄌㄞˊ */
    ok_candidate(ctx, CAND_1, ARRAY_SIZE(CAND_1));

    type_keystroke_by_string(ctx, "<D>");       /* ㄕㄤˋㄌㄞˊ */
    ok_candidate(ctx, CAND_2, ARRAY_SIZE(CAND_2));

    type_keystroke_by_string(ctx, "<D><D>2<E>");        /* select 移上來 */
    ok_commit_buffer(ctx, CAND_1[1]);

    chewing_delete(ctx);
}
Exemple #3
0
void test_Esc_in_select()
{
    ChewingContext *ctx;

    ctx = chewing_new();
    start_testcase(ctx, fd);
    type_keystroke_by_string(ctx, "`<EE>");
    ok_candidate(ctx, NULL, 0);

    chewing_delete(ctx);
}
Exemple #4
0
void test_select_candidate_no_phrase_choice_rearward()
{
	/*
	 * The following phrases are in dict
	 * 一上來
	 * 上來
	 * 移上來
	 * 移上
	 */

	static const char *CAND_1[] = {
		"\xE4\xB8\x80\xE4\xB8\x8A\xE4\xBE\x86" /* 一上來 */,
		"\xE7\xA7\xBB\xE4\xB8\x8A\xE4\xBE\x86" /* 移上來 */,
	};

	static const char *CAND_2[] = {
		"\xE7\xA7\xBB\xE4\xB8\x8A" /* 移上 */,
	};

	ChewingContext *ctx;

	remove( TEST_HASH_DIR PLAT_SEPARATOR HASH_FILE );


	ctx = chewing_new();

	chewing_set_maxChiSymbolLen( ctx, 16 );

	type_keystroke_by_string( ctx, "u6g;4x96<L><L><L>" ); /* ㄧˊㄕㄤˋㄌㄞˊ */

	type_keystroke_by_string( ctx, "<D>" ); /* ㄧˊㄕㄤˋㄌㄞˊ */
	ok_candidate( ctx, CAND_1, ARRAY_SIZE( CAND_1 ) );

	type_keystroke_by_string( ctx, "<D>" ); /* ㄕㄤˋㄌㄞˊ */
	ok_candidate( ctx, CAND_2, ARRAY_SIZE( CAND_2 ) );

	type_keystroke_by_string( ctx, "<D><D>2<E>" ); /* select 移上來 */
	ok_commit_buffer( ctx, CAND_1[1] );

	chewing_delete( ctx );
}
Exemple #5
0
void test_symbol_cand_page()
{
	ChewingContext *ctx;

	chewing_Init( NULL, NULL );

	ctx = chewing_new();

	chewing_set_candPerPage( ctx, 10 );
	chewing_set_maxChiSymbolLen( ctx, 16 );

	chewing_handle_Default( ctx, '`' );
	ok( chewing_cand_CurrentPage( ctx ) == 0, "current page shall be 0" );
	ok( chewing_cand_TotalPage( ctx ) == 2, "total page shall be 2" );

	ok_candidate( ctx, CAND, ARRAY_SIZE( CAND ) );

	chewing_delete( ctx );
	chewing_Terminate();
}