Lines Matching defs:fixture
42 static gboolean finish_loading(DomDomviewFixture* fixture)
44 if (g_main_loop_is_running(fixture->loop))
45 g_main_loop_quit(fixture->loop);
50 static void dom_domview_fixture_setup(DomDomviewFixture* fixture, gconstpointer data)
52 fixture->loop = g_main_loop_new(NULL, TRUE);
53 fixture->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
54 fixture->webView = webkit_web_view_new();
55 fixture->data = data;
57 gtk_container_add(GTK_CONTAINER(fixture->window), GTK_WIDGET(fixture->webView));
60 static void dom_domview_fixture_teardown(DomDomviewFixture* fixture, gconstpointer data)
62 gtk_widget_destroy(fixture->window);
63 g_main_loop_unref(fixture->loop);
66 static gboolean loadedCallback(WebKitDOMDOMWindow* view, WebKitDOMEvent* event, DomDomviewFixture* fixture)
68 g_assert(fixture->loaded == FALSE);
69 fixture->loaded = TRUE;
74 static gboolean clickedCallback(WebKitDOMDOMWindow* view, WebKitDOMEvent* event, DomDomviewFixture* fixture)
89 g_assert(fixture->clicked == FALSE);
90 fixture->clicked = TRUE;
92 finish_loading(fixture);
97 gboolean map_event_cb(GtkWidget *widget, GdkEvent* event, DomDomviewFixture* fixture)
99 webkit_web_view_load_string(WEBKIT_WEB_VIEW (fixture->webView), (const char*)fixture->data, NULL, NULL, NULL);
104 static void load_event_callback(WebKitWebView* webView, GParamSpec* spec, DomDomviewFixture* fixture)
108 webkit_dom_event_target_add_event_listener(WEBKIT_DOM_EVENT_TARGET(fixture->domWindow), "click", G_CALLBACK(clickedCallback), false, fixture);
110 g_assert(fixture->clicked == FALSE);
111 gtk_test_widget_click(GTK_WIDGET(fixture->webView), 1, 0);
116 static void test_dom_domview_signals(DomDomviewFixture* fixture, gconstpointer data)
118 g_assert(fixture);
119 WebKitWebView* view = (WebKitWebView*)fixture->webView;
126 fixture->domWindow = domWindow;
128 webkit_dom_event_target_add_event_listener(WEBKIT_DOM_EVENT_TARGET(fixture->domWindow), "load", G_CALLBACK(loadedCallback), false, fixture);
129 g_signal_connect(fixture->window, "map-event", G_CALLBACK(map_event_cb), fixture);
130 g_signal_connect(fixture->webView, "notify::load-status", G_CALLBACK(load_event_callback), fixture);
132 gtk_widget_show_all(fixture->window);
133 gtk_window_present(GTK_WINDOW(fixture->window));
135 g_main_loop_run(fixture->loop);
137 g_assert(fixture->loaded);
138 g_assert(fixture->clicked);
142 clicked_cb(WebKitDOMEventTarget* target, WebKitDOMEvent* event, DomDomviewFixture* fixture)
144 g_assert(fixture->clicked == FALSE);
145 fixture->clicked = TRUE;
146 finish_loading(fixture);
150 static void load_status_callback(WebKitWebView* webView, GParamSpec* spec, DomDomviewFixture* fixture)
160 document = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(fixture->webView));
164 fixture->domWindow = domWindow;
176 fixture->domWindow, 0, 0, 0, clientX, clientY,
179 webkit_dom_event_target_add_event_listener(WEBKIT_DOM_EVENT_TARGET(element), "click", G_CALLBACK(clicked_cb), false, fixture);
180 g_assert(fixture->clicked == FALSE);
186 static void test_dom_domview_dispatch_event(DomDomviewFixture* fixture, gconstpointer data)
188 g_signal_connect(fixture->window, "map-event", G_CALLBACK(map_event_cb), fixture);
189 g_signal_connect(fixture->webView, "notify::load-status", G_CALLBACK(load_status_callback), fixture);
191 gtk_widget_show_all(fixture->window);
192 gtk_window_present(GTK_WINDOW(fixture->window));
194 g_main_loop_run (fixture->loop);
195 g_assert(fixture->clicked);