~ubuntu-branches/ubuntu/lucid/webkit/lucid-security

« back to all changes in this revision

Viewing changes to WebKit/gtk/tests/testatk.c

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Noronha Silva
  • Date: 2010-01-20 20:09:57 UTC
  • mfrom: (1.2.7 upstream) (4.3.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100120200957-3ng8lah18c7pmm52
* New upstream release
- Fixes crashes related to clearing the clipboard, which many users were
  experiencing (Closes: #565166)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
static const char* contentsInTextInput = "<html><body><input type='text' size='80' value='This is a test. This is the second sentence. And this the third.'/></body></html>";
36
36
 
 
37
static const char* contentsInParagraphAndBodySimple = "<html><body><p>This is a test.</p>Hello world.</body></html>";
 
38
 
 
39
static const char* contentsInParagraphAndBodyModerate = "<html><body><p>This is a test.</p>Hello world.<br /><font color='#00cc00'>This sentence is green.</font><br />This one is not.</body></html>";
 
40
 
37
41
static gboolean bail_out(GMainLoop* loop)
38
42
{
39
43
    if (g_main_loop_is_running(loop))
221
225
    g_assert(obj);
222
226
    obj = atk_object_ref_accessible_child(obj, 0);
223
227
    g_assert(obj);
224
 
    obj = atk_object_ref_accessible_child(obj, 0);
225
 
    g_assert(obj);
226
228
 
227
229
    text_obj = ATK_TEXT(obj);
228
230
    g_assert(ATK_IS_TEXT(text_obj));
254
256
    g_assert(obj);
255
257
    obj = atk_object_ref_accessible_child(obj, 0);
256
258
    g_assert(obj);
257
 
    obj = atk_object_ref_accessible_child(obj, 0);
258
 
    g_assert(obj);
259
259
 
260
260
    text_obj = ATK_TEXT(obj);
261
261
    g_assert(ATK_IS_TEXT(text_obj));
287
287
    g_assert(obj);
288
288
    obj = atk_object_ref_accessible_child(obj, 0);
289
289
    g_assert(obj);
290
 
    obj = atk_object_ref_accessible_child(obj, 0);
291
 
    g_assert(obj);
292
290
 
293
291
    text_obj = ATK_TEXT(obj);
294
292
    g_assert(ATK_IS_TEXT(text_obj));
364
362
    g_object_unref(webView);
365
363
}
366
364
 
 
365
static void testWebkitAtkGetTextInParagraphAndBodySimple(void)
 
366
{
 
367
    WebKitWebView* webView;
 
368
    AtkObject* obj;
 
369
    AtkObject* obj1;
 
370
    AtkObject* obj2;
 
371
    GMainLoop* loop;
 
372
    AtkText* textObj1;
 
373
    AtkText* textObj2;
 
374
 
 
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);
 
381
 
 
382
    g_timeout_add(100, (GSourceFunc)bail_out, loop);
 
383
    g_main_loop_run(loop);
 
384
 
 
385
    /* Get to the inner AtkText object */
 
386
    obj = gtk_widget_get_accessible(GTK_WIDGET(webView));
 
387
    g_assert(obj);
 
388
    obj1 = atk_object_ref_accessible_child(obj, 0);
 
389
    g_assert(obj1);
 
390
    obj2 = atk_object_ref_accessible_child(obj, 1);
 
391
    g_assert(obj2);
 
392
 
 
393
    textObj1 = ATK_TEXT(obj1);
 
394
    g_assert(ATK_IS_TEXT(textObj1));
 
395
    textObj2 = ATK_TEXT(obj2);
 
396
    g_assert(ATK_IS_TEXT(textObj2));
 
397
 
 
398
    char *text = atk_text_get_text(textObj1, 0, -1);
 
399
    g_assert_cmpstr(text, ==, "This is a test.");
 
400
 
 
401
    text = atk_text_get_text(textObj2, 0, 12);
 
402
    g_assert_cmpstr(text, ==, "Hello world.");
 
403
 
 
404
    g_object_unref(obj1);
 
405
    g_object_unref(obj2);
 
406
    g_object_unref(webView);
 
407
}
 
408
 
 
409
static void testWebkitAtkGetTextInParagraphAndBodyModerate(void)
 
410
{
 
411
    WebKitWebView* webView;
 
412
    AtkObject* obj;
 
413
    AtkObject* obj1;
 
414
    AtkObject* obj2;
 
415
    GMainLoop* loop;
 
416
    AtkText* textObj1;
 
417
    AtkText* textObj2;
 
418
 
 
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);
 
425
 
 
426
    g_timeout_add(100, (GSourceFunc)bail_out, loop);
 
427
    g_main_loop_run(loop);
 
428
 
 
429
    /* Get to the inner AtkText object */
 
430
    obj = gtk_widget_get_accessible(GTK_WIDGET(webView));
 
431
    g_assert(obj);
 
432
    obj1 = atk_object_ref_accessible_child(obj, 0);
 
433
    g_assert(obj1);
 
434
    obj2 = atk_object_ref_accessible_child(obj, 1);
 
435
    g_assert(obj2);
 
436
 
 
437
    textObj1 = ATK_TEXT(obj1);
 
438
    g_assert(ATK_IS_TEXT(textObj1));
 
439
    textObj2 = ATK_TEXT(obj2);
 
440
    g_assert(ATK_IS_TEXT(textObj2));
 
441
 
 
442
    char *text = atk_text_get_text(textObj1, 0, -1);
 
443
    g_assert_cmpstr(text, ==, "This is a test.");
 
444
 
 
445
    text = atk_text_get_text(textObj2, 0, 53);
 
446
    g_assert_cmpstr(text, ==, "Hello world.\nThis sentence is green.\nThis one is not.");
 
447
 
 
448
    g_object_unref(obj1);
 
449
    g_object_unref(obj2);
 
450
    g_object_unref(webView);
 
451
}
 
452
 
367
453
int main(int argc, char** argv)
368
454
{
369
455
    g_thread_init(NULL);
375
461
    g_test_add_func("/webkit/atk/get_text_at_offset_newlines", test_webkit_atk_get_text_at_offset_newlines);
376
462
    g_test_add_func("/webkit/atk/get_text_at_offset_textarea", test_webkit_atk_get_text_at_offset_textarea);
377
463
    g_test_add_func("/webkit/atk/get_text_at_offset_text_input", test_webkit_atk_get_text_at_offset_text_input);
 
464
    g_test_add_func("/webkit/atk/getTextInParagraphAndBodySimple", testWebkitAtkGetTextInParagraphAndBodySimple);
 
465
    g_test_add_func("/webkit/atk/getTextInParagraphAndBodyModerate", testWebkitAtkGetTextInParagraphAndBodyModerate);
378
466
    return g_test_run ();
379
467
}
380
468