#ifndef AURUM_C_BINDINGS_H
#define AURUM_C_BINDINGS_H
+/**
+ * Aurum C APIs for Rust bindings. Do not use these directly from C++ applications. Use Aurum API instead.
+ */
#ifdef __cplusplus
extern "C" {
#endif
// Initialize the Aurum library.
void aurum_init();
+ // Shutdown the Aurum library. This will release all resources.
+ void aurum_shutdown();
// Dump current screen as JSON string.
- const char* dump_screen();
+ const char* aurum_dump_screen();
// Free the allocated string memory.
- void free_string_result(const char* ptr);
+ void aurum_free_string_result(const char* ptr);
+ // Click the given coordinates. Returns 1 if successful. Otherwise -1.
+ int aurum_click(int x, int y);
+ // Press the given key code. Returns 1 if successful. Otherwise -1.
+ int aurum_press_key_code(const char* key_code);
#ifdef __cplusplus
}
#endif
ecore_main_loop_thread_safe_call_sync([](void *data)->void*{
TizenDeviceImpl *obj = static_cast<TizenDeviceImpl*>(data);
obj->mFakeTouchHandle = efl_util_input_initialize_generator_with_sync(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, "SMSRC Fake Input");
- obj->mFakeKeyboardHandle =
- efl_util_input_initialize_generator_with_sync(EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, "SMSRC Fake Input");
+ obj->mFakeKeyboardHandle = efl_util_input_initialize_generator_with_sync(EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, "SMSRC Fake Input");
obj->mFakePointerHandle = efl_util_input_initialize_generator_with_sync(EFL_UTIL_INPUT_DEVTYPE_POINTER, "SMSRC Fake Input");
return NULL;
#include "Aurum.h"
#include <cstring>
+#ifdef TIZEN
+#include <Ecore.h>
+#endif
+
using namespace Aurum;
void aurum_init()
{
LOGI("aurum_init");
AccessibleWatcher::getInstance();
+// TODO: Move this to Application side.
+#ifdef TIZEN
+ ecore_init();
+ ecore_main_loop_begin();
+#endif
+}
+
+void aurum_shutdown()
+{
+ LOGI("aurum_shutdown");
+// TODO: Move this to Application side.
+#ifdef TIZEN
+ ecore_main_loop_quit();
+ ecore_shutdown();
+#endif
}
-const char* dump_screen()
+const char* aurum_dump_screen()
{
LOGI("dump_screen");
auto device = UiDevice::getInstance();
std::string dumpResult{"["};
for (const auto& root: windowRoots) {
+ root->setIncludeHidden(true);
dumpResult += root->dumpTree();
dumpResult += ",";
}
char* cResult = new char[dumpResult.size() + 1]; // Consumers must free this memory later
std::strcpy(cResult, dumpResult.c_str());
return cResult;
-
}
-void free_string_result(const char* ptr)
+void aurum_free_string_result(const char* ptr)
{
LOGI("free_string_result");
delete[] ptr;
-}
\ No newline at end of file
+}
+
+int aurum_click(int x, int y)
+{
+ LOGI("click(%d,%d)", x, y);
+ auto device = UiDevice::getInstance();
+ return device->click(x, y) ? 0 : -1;;
+}
+
+int aurum_press_key_code(const char *key_code)
+{
+ LOGI("press_key_code(%s)", key_code);
+ auto device = UiDevice::getInstance();
+ return device->pressKeyCode(key_code, KeyRequestType::STROKE) ? 0 : -1;
+}
TEST(CBindingsTest, DumpScreen)
{
aurum_init();
- const char *c_str = dump_screen();
+ const char *c_str = aurum_dump_screen();
EXPECT_NE(c_str, nullptr);
- free_string_result(c_str);
+ aurum_free_string_result(c_str);
+ aurum_shutdown();
}
TEST(CBindingsTest, FreeStringResultWorksWithNull)
{
- free_string_result(nullptr);
+ aurum_free_string_result(nullptr);
}
\ No newline at end of file