Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Unified Diff: client/deps/ibusclient/src/ibusclient.cc

Issue 1371006: Add more tests to desktopui_IBusTest (Closed)
Patch Set: add time back Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | client/site_tests/desktopui_IBusTest/desktopui_IBusTest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/deps/ibusclient/src/ibusclient.cc
diff --git a/client/deps/ibusclient/src/ibusclient.cc b/client/deps/ibusclient/src/ibusclient.cc
index 4f053a1c969970ddc78207a4430df1eb62f0a2e0..aee7f0a25f4274afd9642f3ed1aa9d926e3ae588 100644
--- a/client/deps/ibusclient/src/ibusclient.cc
+++ b/client/deps/ibusclient/src/ibusclient.cc
@@ -3,14 +3,51 @@
// found in the LICENSE file.
#include <assert.h>
+#include <glib.h>
#include <ibus.h>
+#include <stdio.h>
+#include <string>
+
+// Prints the names of the given engines. Takes the ownership of |engines|.
+void PrintEngineNames(GList* engines) {
+ for (GList* cursor = engines; cursor; cursor = g_list_next(cursor)) {
+ IBusEngineDesc* engine_desc = IBUS_ENGINE_DESC(cursor->data);
+ assert(engine_desc);
+ printf("%s\n", engine_desc->name);
+ g_object_unref(IBUS_ENGINE_DESC(cursor->data));
+ }
+ g_list_free(engines);
+}
int main(int argc, char **argv) {
+ if (argc == 1) {
+ printf("Usage: %s COMMAND\n", argv[0]);
+ printf("check_reachable Check if ibus-daemon is reachable\n");
+ printf("list_engines List engine names (all engines)\n");
+ printf("list_active_engines List active engine names\n");
+ return 1;
+ }
+
ibus_init();
+ bool connected = false;
IBusBus* ibus = ibus_bus_new();
+ if (ibus) {
+ connected = ibus_bus_is_connected(ibus);
+ }
+
+ const std::string command = argv[1];
+ if (command == "check_reachable") {
+ printf("%s\n", connected ? "YES" : "NO");
+ }
+
+ // Other commands need the bus to be connected.
assert(ibus);
- // This fails if ibus daemon is not running.
- assert(ibus_bus_is_connected(ibus));
- // TODO(satorux): Add more tests.
+ assert(connected);
+ if (command == "list_engines") {
+ PrintEngineNames(ibus_bus_list_engines(ibus));
+ } else if (command == "list_active_engines") {
+ PrintEngineNames(ibus_bus_list_active_engines(ibus));
+ }
+
return 0;
}
« no previous file with comments | « no previous file | client/site_tests/desktopui_IBusTest/desktopui_IBusTest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698