spiegel-keyman/core/tests/unit/kmnkbd/keyboard_api.cpp
Marc Durdin e5c2525241 refactor(core): split context API from Core primary API
Relates to #9999.
Fixes #10384.

The context API endpoints should no longer be considered as part of the
standard Core API. The only consumers that have a need to access these
APIs are the IMX integration in Engine for Windows, and the Keyman
Developer Debugger.

These symbols are currently used by Developer:
* `km_core_context` struct
* `km_core_context_type` enum
* `km_core_context_item` struct
* `KM_CORE_CONTEXT_ITEM_END` macro
* `km_core_state_context()`
* `km_core_context_set()`
* `km_core_context_clear()`

These symbols are currently used by Windows IMX:
* `km_core_context` struct
* `km_core_context_type` enum
* `km_core_context_item` struct
* `KM_CORE_CONTEXT_ITEM_END` macro
* `km_core_context_items_dispose()`
* `km_core_context_item_list_size()`
* `km_core_state_get_intermediate_context()`

The following functions and symbols are moving to
keyman_core_api_context.h:
* `km_core_context` struct
* `km_core_context_type` enum
* `km_core_context_item` struct
* `KM_CORE_CONTEXT_ITEM_END` macro
* `km_core_state_context()` function
* `km_core_state_get_intermediate_context()` function
* `km_core_context_set()` function
* `km_core_context_clear()` function
* `km_core_context_get()` function
* `km_core_context_items_from_utf16()` function
* `km_core_context_items_from_utf8()` function
* `km_core_context_items_to_utf8()` function
* `km_core_context_items_to_utf16()` function
* `km_core_context_items_to_utf32()` function
* `km_core_context_items_dispose()` function
* `km_core_context_length()` function
* `km_core_context_append()` function
* `km_core_context_shrink()` function
* `km_core_context_item_list_size()` function
2024-01-16 12:04:41 +07:00

42 lines
1.1 KiB
C++

/*
Copyright: © 2018 SIL International.
Description: Tests for the Keyboard API family of functions.
Create Date: 30 Oct 2018
Authors: Tim Eves (TSE)
*/
#include <string>
#include "keyman_core.h"
#include "path.hpp"
//#include "keyboard.hpp"
namespace
{
km::core::path const test_kb_path = "/a/dummy/keyboard.mock";
}
#define try_status(expr) \
{auto __s = (expr); if (__s != KM_CORE_STATUS_OK) return 100*__LINE__+__s;}
int main(int, char *[])
{
km_core_keyboard * test_kb = nullptr;
km_core_keyboard_attrs const * kb_attrs = nullptr;
km_core_keyboard_key * kb_key_list = nullptr;
km_core_keyboard_imx * kb_imx_list = nullptr;
try_status(km_core_keyboard_load(test_kb_path.c_str(), &test_kb));
try_status(km_core_keyboard_get_attrs(test_kb, &kb_attrs));
try_status(km_core_keyboard_get_key_list(test_kb,&kb_key_list));
try_status(km_core_keyboard_get_imx_list(test_kb,&kb_imx_list));
if (kb_attrs->folder_path != test_kb_path.parent())
return __LINE__;
km_core_keyboard_dispose(test_kb);
km_core_keyboard_key_list_dispose(kb_key_list);
km_core_keyboard_imx_list_dispose(kb_imx_list);
return 0;
}