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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | client/site_tests/desktopui_IBusTest/desktopui_IBusTest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <assert.h> 5 #include <assert.h>
6 #include <glib.h>
6 #include <ibus.h> 7 #include <ibus.h>
8 #include <stdio.h>
9 #include <string>
10
11 // Prints the names of the given engines. Takes the ownership of |engines|.
12 void PrintEngineNames(GList* engines) {
13 for (GList* cursor = engines; cursor; cursor = g_list_next(cursor)) {
14 IBusEngineDesc* engine_desc = IBUS_ENGINE_DESC(cursor->data);
15 assert(engine_desc);
16 printf("%s\n", engine_desc->name);
17 g_object_unref(IBUS_ENGINE_DESC(cursor->data));
18 }
19 g_list_free(engines);
20 }
7 21
8 int main(int argc, char **argv) { 22 int main(int argc, char **argv) {
23 if (argc == 1) {
24 printf("Usage: %s COMMAND\n", argv[0]);
25 printf("check_reachable Check if ibus-daemon is reachable\n");
26 printf("list_engines List engine names (all engines)\n");
27 printf("list_active_engines List active engine names\n");
28 return 1;
29 }
30
9 ibus_init(); 31 ibus_init();
32 bool connected = false;
10 IBusBus* ibus = ibus_bus_new(); 33 IBusBus* ibus = ibus_bus_new();
34 if (ibus) {
35 connected = ibus_bus_is_connected(ibus);
36 }
37
38 const std::string command = argv[1];
39 if (command == "check_reachable") {
40 printf("%s\n", connected ? "YES" : "NO");
41 }
42
43 // Other commands need the bus to be connected.
11 assert(ibus); 44 assert(ibus);
12 // This fails if ibus daemon is not running. 45 assert(connected);
13 assert(ibus_bus_is_connected(ibus)); 46 if (command == "list_engines") {
14 // TODO(satorux): Add more tests. 47 PrintEngineNames(ibus_bus_list_engines(ibus));
48 } else if (command == "list_active_engines") {
49 PrintEngineNames(ibus_bus_list_active_engines(ibus));
50 }
51
15 return 0; 52 return 0;
16 } 53 }
OLDNEW
« 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