364
362
g_object_unref(webView);
365
static void testWebkitAtkGetTextInParagraphAndBodySimple(void)
367
WebKitWebView* webView;
375
webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
376
g_object_ref_sink(webView);
377
GtkAllocation alloc = { 0, 0, 800, 600 };
378
gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc);
379
webkit_web_view_load_string(webView, contentsInParagraphAndBodySimple, NULL, NULL, NULL);
380
loop = g_main_loop_new(NULL, TRUE);
382
g_timeout_add(100, (GSourceFunc)bail_out, loop);
383
g_main_loop_run(loop);
385
/* Get to the inner AtkText object */
386
obj = gtk_widget_get_accessible(GTK_WIDGET(webView));
388
obj1 = atk_object_ref_accessible_child(obj, 0);
390
obj2 = atk_object_ref_accessible_child(obj, 1);
393
textObj1 = ATK_TEXT(obj1);
394
g_assert(ATK_IS_TEXT(textObj1));
395
textObj2 = ATK_TEXT(obj2);
396
g_assert(ATK_IS_TEXT(textObj2));
398
char *text = atk_text_get_text(textObj1, 0, -1);
399
g_assert_cmpstr(text, ==, "This is a test.");
401
text = atk_text_get_text(textObj2, 0, 12);
402
g_assert_cmpstr(text, ==, "Hello world.");
404
g_object_unref(obj1);
405
g_object_unref(obj2);
406
g_object_unref(webView);
409
static void testWebkitAtkGetTextInParagraphAndBodyModerate(void)
411
WebKitWebView* webView;
419
webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
420
g_object_ref_sink(webView);
421
GtkAllocation alloc = { 0, 0, 800, 600 };
422
gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc);
423
webkit_web_view_load_string(webView, contentsInParagraphAndBodyModerate, NULL, NULL, NULL);
424
loop = g_main_loop_new(NULL, TRUE);
426
g_timeout_add(100, (GSourceFunc)bail_out, loop);
427
g_main_loop_run(loop);
429
/* Get to the inner AtkText object */
430
obj = gtk_widget_get_accessible(GTK_WIDGET(webView));
432
obj1 = atk_object_ref_accessible_child(obj, 0);
434
obj2 = atk_object_ref_accessible_child(obj, 1);
437
textObj1 = ATK_TEXT(obj1);
438
g_assert(ATK_IS_TEXT(textObj1));
439
textObj2 = ATK_TEXT(obj2);
440
g_assert(ATK_IS_TEXT(textObj2));
442
char *text = atk_text_get_text(textObj1, 0, -1);
443
g_assert_cmpstr(text, ==, "This is a test.");
445
text = atk_text_get_text(textObj2, 0, 53);
446
g_assert_cmpstr(text, ==, "Hello world.\nThis sentence is green.\nThis one is not.");
448
g_object_unref(obj1);
449
g_object_unref(obj2);
450
g_object_unref(webView);
367
453
int main(int argc, char** argv)
369
455
g_thread_init(NULL);