[libgdata/offline-testing] tests: Use a random port > 1024 for unit testing
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/offline-testing] tests: Use a random port > 1024 for unit testing
- Date: Tue, 30 Jul 2013 08:26:16 +0000 (UTC)
commit ac9e60496d8c74f7219b43d6f6c41cb66ac5933d
Author: Philip Withnall <philip tecnocode co uk>
Date: Sun Jul 7 17:52:14 2013 +0100
tests: Use a random port > 1024 for unit testing
This means we don’t need root privileges to run the tests.
gdata/tests/mock-server.c | 139 +++++++++++++++++++++++++++++++++++++++------
gdata/tests/mock-server.h | 3 +
gdata/tests/youtube.c | 77 +++++++++++++++----------
3 files changed, 172 insertions(+), 47 deletions(-)
---
diff --git a/gdata/tests/mock-server.c b/gdata/tests/mock-server.c
index e702f4b..3f87b83 100644
--- a/gdata/tests/mock-server.c
+++ b/gdata/tests/mock-server.c
@@ -40,13 +40,17 @@ static void load_file_stream_thread_cb (GTask *task, gpointer source_object, gpo
static void load_file_iteration_thread_cb (GTask *task, gpointer source_object, gpointer task_data,
GCancellable *cancellable);
static GFileInputStream *load_file_stream (GFile *trace_file, GCancellable *cancellable, GError **error);
-static SoupMessage *load_file_iteration (GFileInputStream *input_stream, GCancellable *cancellable, GError
**error);
+static SoupMessage *load_file_iteration (GFileInputStream *input_stream, SoupURI *base_uri, GCancellable
*cancellable, GError **error);
struct _GDataMockServerPrivate {
SoupServer *server;
GDataMockResolver *resolver;
GThread *server_thread;
+ /* Server interface. */
+ SoupAddress *address; /* unowned */
+ guint port;
+
GFile *trace_file;
GFileInputStream *input_stream;
GFileOutputStream *output_stream;
@@ -61,6 +65,8 @@ enum {
PROP_TRACE_DIRECTORY = 1,
PROP_ENABLE_ONLINE,
PROP_ENABLE_LOGGING,
+ PROP_ADDRESS,
+ PROP_PORT,
};
enum {
@@ -115,6 +121,24 @@ gdata_mock_server_class_init (GDataMockServerClass *klass)
/**
* TODO: Document me.
*/
+ g_object_class_install_property (gobject_class, PROP_ADDRESS,
+ g_param_spec_object ("address",
+ "Server Address", "TODO",
+ SOUP_TYPE_ADDRESS,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * TODO: Document me.
+ */
+ g_object_class_install_property (gobject_class, PROP_PORT,
+ g_param_spec_uint ("port",
+ "Server Port", "TODO",
+ 0, G_MAXUINT, 0,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * TODO: Document me.
+ */
signals[SIGNAL_HANDLE_MESSAGE] = g_signal_new ("handle-message", G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GDataMockServerClass, handle_message),
g_signal_accumulator_true_handled, NULL,
@@ -164,6 +188,12 @@ gdata_mock_server_get_property (GObject *object, guint property_id, GValue *valu
case PROP_ENABLE_LOGGING:
g_value_set_boolean (value, priv->enable_logging);
break;
+ case PROP_ADDRESS:
+ g_value_set_object (value, priv->address);
+ break;
+ case PROP_PORT:
+ g_value_set_uint (value, priv->port);
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -186,6 +216,9 @@ gdata_mock_server_set_property (GObject *object, guint property_id, const GValue
case PROP_ENABLE_LOGGING:
gdata_mock_server_set_enable_logging (self, g_value_get_boolean (value));
break;
+ case PROP_ADDRESS:
+ case PROP_PORT:
+ /* Read-only. */
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -193,6 +226,32 @@ gdata_mock_server_set_property (GObject *object, guint property_id, const GValue
}
}
+typedef struct {
+ GFileInputStream *input_stream;
+ SoupURI *base_uri;
+} LoadFileIterationData;
+
+static void
+load_file_iteration_data_free (LoadFileIterationData *data)
+{
+ g_object_unref (data->input_stream);
+ soup_uri_free (data->base_uri);
+ g_slice_free (LoadFileIterationData, data);
+}
+
+static SoupURI * /* transfer full */
+build_base_uri (GDataMockServer *self)
+{
+ gchar *base_uri_string;
+ SoupURI *base_uri;
+
+ base_uri_string = g_strdup_printf ("https://%s:%u", soup_address_get_physical (self->priv->address),
self->priv->port);
+ base_uri = soup_uri_new (base_uri_string);
+ g_free (base_uri_string);
+
+ return base_uri;
+}
+
static inline gboolean
parts_equal (const char *one, const char *two, gboolean insensitive)
{
@@ -300,10 +359,15 @@ real_handle_message (GDataMockServer *self, SoupMessage *message, SoupClientCont
/* Asynchronously load the next expected message from the trace file. */
if (priv->next_message == NULL) {
GTask *task;
+ LoadFileIterationData *data;
GError *child_error = NULL;
+ data = g_slice_new (LoadFileIterationData);
+ data->input_stream = g_object_ref (priv->input_stream);
+ data->base_uri = build_base_uri (self);
+
task = g_task_new (self, NULL, NULL, NULL);
- g_task_set_task_data (task, g_object_ref (priv->input_stream), g_object_unref);
+ g_task_set_task_data (task, data, (GDestroyNotify) load_file_iteration_data_free);
g_task_run_in_thread_sync (task, load_file_iteration_thread_cb);
/* Handle the results. */
@@ -445,15 +509,16 @@ error:
return FALSE;
}
+/* base_uri is the base URI for the server, e.g. https://127.0.0.1:1431. */
static SoupMessage *
-trace_to_soup_message (const gchar *trace)
+trace_to_soup_message (const gchar *trace, SoupURI *base_uri)
{
SoupMessage *message;
const gchar *i, *j, *method;
gchar *uri_string, *response_message;
SoupHTTPVersion http_version;
guint response_status;
- SoupURI *base_uri, *uri;
+ SoupURI *uri;
g_return_val_if_fail (trace != NULL, NULL);
@@ -530,12 +595,9 @@ trace_to_soup_message (const gchar *trace)
trace++;
/* Build the message. */
- base_uri = soup_uri_new ("https://127.0.0.1:443"); /* TODO */
uri = soup_uri_new_with_base (base_uri, uri_string);
message = soup_message_new_from_uri (method, uri);
-
soup_uri_free (uri);
- soup_uri_free (base_uri);
if (message == NULL) {
g_warning ("Invalid URI ‘%s’.", uri_string);
@@ -660,7 +722,7 @@ load_message_half (GFileInputStream *input_stream, GString *current_message, gch
}
static SoupMessage *
-load_file_iteration (GFileInputStream *input_stream, GCancellable *cancellable, GError **error)
+load_file_iteration (GFileInputStream *input_stream, SoupURI *base_uri, GCancellable *cancellable, GError
**error)
{
SoupMessage *output_message = NULL;
GString *current_message = NULL;
@@ -675,7 +737,7 @@ load_file_iteration (GFileInputStream *input_stream, GCancellable *cancellable,
}
if (current_message->len > 0) {
- output_message = trace_to_soup_message (current_message->str);
+ output_message = trace_to_soup_message (current_message->str, base_uri);
} else {
/* Reached the end of the file. */
output_message = NULL;
@@ -715,14 +777,17 @@ load_file_stream_thread_cb (GTask *task, gpointer source_object, gpointer task_d
static void
load_file_iteration_thread_cb (GTask *task, gpointer source_object, gpointer task_data, GCancellable
*cancellable)
{
+ LoadFileIterationData *data = task_data;
GFileInputStream *input_stream;
SoupMessage *output_message;
+ SoupURI *base_uri;
GError *child_error = NULL;
- input_stream = task_data;
+ input_stream = data->input_stream;
g_assert (G_IS_FILE_INPUT_STREAM (input_stream));
+ base_uri = data->base_uri;
- output_message = load_file_iteration (input_stream, cancellable, &child_error);
+ output_message = load_file_iteration (input_stream, base_uri, cancellable, &child_error);
if (child_error != NULL) {
g_task_return_error (task, child_error);
@@ -737,22 +802,29 @@ load_file_iteration_thread_cb (GTask *task, gpointer source_object, gpointer tas
void
gdata_mock_server_load_trace (GDataMockServer *self, GFile *trace_file, GCancellable *cancellable, GError
**error)
{
+ SoupURI *base_uri;
+
g_return_if_fail (GDATA_IS_MOCK_SERVER (self));
g_return_if_fail (G_IS_FILE (trace_file));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
g_return_if_fail (error == NULL || *error == NULL);
g_return_if_fail (self->priv->trace_file == NULL && self->priv->input_stream == NULL &&
self->priv->next_message == NULL);
+ base_uri = build_base_uri (self);
+
self->priv->trace_file = g_object_ref (trace_file);
self->priv->input_stream = load_file_stream (self->priv->trace_file, cancellable, error);
if (self->priv->input_stream != NULL) {
- self->priv->next_message = load_file_iteration (self->priv->input_stream, cancellable, error);
+ self->priv->next_message = load_file_iteration (self->priv->input_stream, base_uri,
cancellable, error);
}
+
+ soup_uri_free (base_uri);
}
typedef struct {
GAsyncReadyCallback callback;
gpointer user_data;
+ SoupURI *base_uri;
} LoadTraceData;
static void
@@ -760,6 +832,7 @@ load_trace_async_cb (GObject *source_object, GAsyncResult *result, gpointer user
{
GDataMockServer *self = GDATA_MOCK_SERVER (source_object);
LoadTraceData *data = user_data;
+ LoadFileIterationData *iteration_data;
GTask *task;
GError *child_error = NULL;
@@ -769,8 +842,13 @@ load_trace_async_cb (GObject *source_object, GAsyncResult *result, gpointer user
self->priv->input_stream = g_task_propagate_pointer (G_TASK (result), &child_error);
+ iteration_data = g_slice_new (LoadFileIterationData);
+ iteration_data->input_stream = g_object_ref (self->priv->input_stream);
+ iteration_data->base_uri = data->base_uri; /* transfer ownership */
+ data->base_uri = NULL;
+
task = g_task_new (g_task_get_source_object (G_TASK (result)), g_task_get_cancellable (G_TASK
(result)), data->callback, data->user_data);
- g_task_set_task_data (task, g_object_ref (self->priv->input_stream), g_object_unref);
+ g_task_set_task_data (task, iteration_data, (GDestroyNotify) load_file_iteration_data_free);
if (child_error != NULL) {
g_task_return_error (task, child_error);
@@ -802,6 +880,7 @@ gdata_mock_server_load_trace_async (GDataMockServer *self, GFile *trace_file, GC
data = g_slice_new (LoadTraceData);
data->callback = callback;
data->user_data = user_data;
+ data->base_uri = build_base_uri (self);
task = g_task_new (self, cancellable, load_trace_async_cb, data);
g_task_set_task_data (task, g_object_ref (self->priv->trace_file), g_object_unref);
@@ -854,7 +933,7 @@ gdata_mock_server_run (GDataMockServer *self)
memset (&sock, 0, sizeof (sock));
sock.sin_family = AF_INET;
sock.sin_addr.s_addr = htonl (INADDR_LOOPBACK); /* TODO: don't hard-code this */
- sock.sin_port = htons (443);
+ sock.sin_port = htons (0); /* random port */
addr = soup_address_new_from_sockaddr ((struct sockaddr *) &sock, sizeof (sock));
g_assert (addr != NULL);
@@ -870,13 +949,16 @@ gdata_mock_server_run (GDataMockServer *self)
/* Set up the server. */
thread_context = g_main_context_new ();
priv->server = soup_server_new ("interface", addr,
- "port", 443,
"ssl-cert-file", "/etc/pki/tls/certs/localhost.crt", /* TODO */
"ssl-key-file", "/etc/pki/tls/private/localhost.key" /* TODO */,
"async-context", thread_context,
NULL);
soup_server_add_handler (priv->server, "/", server_handler_cb, self, NULL);
+ /* Grab the randomly selected address and port. */
+ priv->address = soup_socket_get_local_address (soup_server_get_listener (priv->server));
+ priv->port = soup_server_get_port (priv->server);
+
g_main_context_unref (thread_context);
g_object_unref (addr);
@@ -990,6 +1072,7 @@ gdata_mock_server_start_trace_full (GDataMockServer *self, GFile *trace_file)
}
if (priv->enable_online == FALSE) {
+ gdata_mock_server_run (self);
gdata_mock_server_load_trace (self, trace_file, NULL, &child_error);
if (child_error != NULL) {
@@ -999,10 +1082,10 @@ gdata_mock_server_start_trace_full (GDataMockServer *self, GFile *trace_file)
g_error_free (child_error);
+ gdata_mock_server_stop (self);
+
return;
}
-
- gdata_mock_server_run (self);
}
}
@@ -1103,3 +1186,25 @@ gdata_mock_server_log_message_chunk (GDataMockServer *self, const gchar *message
return;
}
}
+
+/**
+ * TODO: Document me.
+ */
+SoupAddress *
+gdata_mock_server_get_address (GDataMockServer *self)
+{
+ g_return_val_if_fail (GDATA_IS_MOCK_SERVER (self), NULL);
+
+ return self->priv->address;
+}
+
+/**
+ * TODO: Document me.
+ */
+guint
+gdata_mock_server_get_port (GDataMockServer *self)
+{
+ g_return_val_if_fail (GDATA_IS_MOCK_SERVER (self), 0);
+
+ return self->priv->port;
+}
diff --git a/gdata/tests/mock-server.h b/gdata/tests/mock-server.h
index 710eaff..66029ec 100644
--- a/gdata/tests/mock-server.h
+++ b/gdata/tests/mock-server.h
@@ -75,6 +75,9 @@ void gdata_mock_server_set_enable_logging (GDataMockServer *self, gboolean enabl
void gdata_mock_server_log_message_chunk (GDataMockServer *self, const gchar *message_chunk);
+SoupAddress *gdata_mock_server_get_address (GDataMockServer *self);
+guint gdata_mock_server_get_port (GDataMockServer *self);
+
G_END_DECLS
#endif /* !GDATA_MOCK_SERVER_H */
diff --git a/gdata/tests/youtube.c b/gdata/tests/youtube.c
index 02f1e27..2c1fe45 100644
--- a/gdata/tests/youtube.c
+++ b/gdata/tests/youtube.c
@@ -29,13 +29,25 @@
static GDataMockServer *mock_server = NULL;
static void
+gdata_test_mock_server_start_trace (GDataMockServer *server, const gchar *trace_filename)
+{
+ gchar *port_string;
+
+ gdata_mock_server_start_trace (server, trace_filename);
+
+ port_string = g_strdup_printf ("%u", gdata_mock_server_get_port (server));
+ g_setenv ("LIBGDATA_HTTPS_PORT", port_string, TRUE);
+ g_free (port_string);
+}
+
+static void
test_authentication (void)
{
gboolean retval;
GDataClientLoginAuthorizer *authorizer;
GError *error = NULL;
- gdata_mock_server_start_trace (mock_server, "authentication");
+ gdata_test_mock_server_start_trace (mock_server, "authentication");
/* Create an authorizer */
authorizer = gdata_client_login_authorizer_new (CLIENT_ID, GDATA_TYPE_YOUTUBE_SERVICE);
@@ -125,10 +137,15 @@ test_authentication_error (void)
for (i = 0; i < G_N_ELEMENTS (authentication_errors); i++) {
const RequestErrorData *data = &authentication_errors[i];
GQuark error_domain;
+ gchar *port_string;
handler_id = g_signal_connect (mock_server, "handle-message", (GCallback)
authentication_error_cb, (gpointer) data);
gdata_mock_server_run (mock_server);
+ port_string = g_strdup_printf ("%u", gdata_mock_server_get_port (mock_server));
+ g_setenv ("LIBGDATA_HTTPS_PORT", port_string, TRUE);
+ g_free (port_string);
+
/* Create an authorizer */
authorizer = gdata_client_login_authorizer_new (CLIENT_ID, GDATA_TYPE_YOUTUBE_SERVICE);
@@ -159,7 +176,7 @@ GDATA_ASYNC_TEST_FUNCTIONS (authentication, void,
G_STMT_START {
GDataClientLoginAuthorizer *authorizer;
- gdata_mock_server_start_trace (mock_server, "authentication-async");
+ gdata_test_mock_server_start_trace (mock_server, "authentication-async");
/* Create an authorizer */
authorizer = gdata_client_login_authorizer_new (CLIENT_ID, GDATA_TYPE_YOUTUBE_SERVICE);
@@ -220,7 +237,7 @@ test_query_standard_feed (gconstpointer service)
GDataFeed *feed;
GError *error = NULL;
- gdata_mock_server_start_trace (mock_server, "query-standard-feed");
+ gdata_test_mock_server_start_trace (mock_server, "query-standard-feed");
feed = gdata_youtube_service_query_standard_feed (GDATA_YOUTUBE_SERVICE (service),
GDATA_YOUTUBE_TOP_RATED_FEED, NULL, NULL, NULL, NULL, &error);
g_assert_no_error (error);
@@ -236,7 +253,7 @@ test_query_standard_feed (gconstpointer service)
GDATA_ASYNC_TEST_FUNCTIONS (query_standard_feed, void,
G_STMT_START {
- gdata_mock_server_start_trace (mock_server, "query-standard-feed-async");
+ gdata_test_mock_server_start_trace (mock_server, "query-standard-feed-async");
gdata_youtube_service_query_standard_feed_async (GDATA_YOUTUBE_SERVICE (service),
GDATA_YOUTUBE_TOP_RATED_FEED, NULL, cancellable,
NULL, NULL, NULL, async_ready_callback, async_data);
@@ -265,7 +282,7 @@ test_query_standard_feed_async_progress_closure (gconstpointer service)
g_assert (service != NULL);
- gdata_mock_server_start_trace (mock_server, "query-standard-feed-async-progress-closure");
+ gdata_test_mock_server_start_trace (mock_server, "query-standard-feed-async-progress-closure");
data->main_loop = g_main_loop_new (NULL, TRUE);
@@ -361,7 +378,7 @@ test_query_related (gconstpointer service)
GDataYouTubeVideo *video;
GError *error = NULL;
- gdata_mock_server_start_trace (mock_server, "query-related");
+ gdata_test_mock_server_start_trace (mock_server, "query-related");
video = get_video_for_related ();
feed = gdata_youtube_service_query_related (GDATA_YOUTUBE_SERVICE (service), video, NULL, NULL, NULL,
NULL, &error);
@@ -381,7 +398,7 @@ GDATA_ASYNC_TEST_FUNCTIONS (query_related, void,
G_STMT_START {
GDataYouTubeVideo *video;
- gdata_mock_server_start_trace (mock_server, "query-related");
+ gdata_test_mock_server_start_trace (mock_server, "query-related");
video = get_video_for_related ();
gdata_youtube_service_query_related_async (GDATA_YOUTUBE_SERVICE (service), video, NULL, cancellable,
NULL,
@@ -413,7 +430,7 @@ test_query_related_async_progress_closure (gconstpointer service)
g_assert (service != NULL);
- gdata_mock_server_start_trace (mock_server, "query-related-async-progress-closure");
+ gdata_test_mock_server_start_trace (mock_server, "query-related-async-progress-closure");
data->main_loop = g_main_loop_new (NULL, TRUE);
video = get_video_for_related ();
@@ -484,7 +501,7 @@ set_up_upload (UploadData *data, gconstpointer service)
static void
tear_down_upload (UploadData *data, gconstpointer service)
{
- gdata_mock_server_start_trace (mock_server, "teardown-upload");
+ gdata_test_mock_server_start_trace (mock_server, "teardown-upload");
/* Delete the uploaded video, if possible */
if (data->updated_video != NULL) {
@@ -511,7 +528,7 @@ test_upload_simple (UploadData *data, gconstpointer service)
gssize transfer_size;
GError *error = NULL;
- gdata_mock_server_start_trace (mock_server, "upload-simple");
+ gdata_test_mock_server_start_trace (mock_server, "upload-simple");
/* Prepare the upload stream */
upload_stream = gdata_youtube_service_upload_video (GDATA_YOUTUBE_SERVICE (service), data->video,
data->slug, data->content_type, NULL,
@@ -563,7 +580,7 @@ G_STMT_START {
GFileInputStream *file_stream;
GError *error = NULL;
- gdata_mock_server_start_trace (mock_server, "upload-async");
+ gdata_test_mock_server_start_trace (mock_server, "upload-async");
/* Prepare the upload stream */
upload_stream = gdata_youtube_service_upload_video (GDATA_YOUTUBE_SERVICE (service), data->video,
data->slug,
@@ -1478,7 +1495,7 @@ test_query_single (gconstpointer service)
GDataYouTubeVideo *video;
GError *error = NULL;
- gdata_mock_server_start_trace (mock_server, "query-single");
+ gdata_test_mock_server_start_trace (mock_server, "query-single");
video = GDATA_YOUTUBE_VIDEO (gdata_service_query_single_entry (GDATA_SERVICE (service),
gdata_youtube_service_get_primary_authorization_domain (),
@@ -1499,7 +1516,7 @@ test_query_single (gconstpointer service)
GDATA_ASYNC_TEST_FUNCTIONS (query_single, void,
G_STMT_START {
- gdata_mock_server_start_trace (mock_server, "query-single-async");
+ gdata_test_mock_server_start_trace (mock_server, "query-single-async");
gdata_service_query_single_entry_async (GDATA_SERVICE (service),
gdata_youtube_service_get_primary_authorization_domain (),
"tag:youtube.com,2008:video:_LeQuMpwbW4", NULL,
GDATA_TYPE_YOUTUBE_VIDEO,
@@ -1530,7 +1547,7 @@ typedef struct {
static void
set_up_comment (CommentData *data, gconstpointer service)
{
- gdata_mock_server_start_trace (mock_server, "setup-comment");
+ gdata_test_mock_server_start_trace (mock_server, "setup-comment");
/* Get a video known to have comments on it. */
data->video = GDATA_YOUTUBE_VIDEO (gdata_service_query_single_entry (GDATA_SERVICE (service),
@@ -1582,7 +1599,7 @@ test_comment_query (CommentData *data, gconstpointer service)
GDataFeed *comments_feed;
GError *error = NULL;
- gdata_mock_server_start_trace (mock_server, "comment-query");
+ gdata_test_mock_server_start_trace (mock_server, "comment-query");
/* Get the comments feed for the video */
comments_feed = gdata_commentable_query_comments (GDATA_COMMENTABLE (data->video), GDATA_SERVICE
(service), NULL, NULL, NULL, NULL, &error);
@@ -1600,7 +1617,7 @@ GDATA_ASYNC_CLOSURE_FUNCTIONS (comment, CommentData);
GDATA_ASYNC_TEST_FUNCTIONS (comment_query, CommentData,
G_STMT_START {
- gdata_mock_server_start_trace (mock_server, "comment-query-async");
+ gdata_test_mock_server_start_trace (mock_server, "comment-query-async");
gdata_commentable_query_comments_async (GDATA_COMMENTABLE (data->video), GDATA_SERVICE (service),
NULL, cancellable, NULL, NULL, NULL,
async_ready_callback, async_data);
@@ -1629,7 +1646,7 @@ test_comment_query_async_progress_closure (CommentData *query_data, gconstpointe
{
GDataAsyncProgressClosure *data = g_slice_new0 (GDataAsyncProgressClosure);
- gdata_mock_server_start_trace (mock_server, "comment-query-async-progress-closure");
+ gdata_test_mock_server_start_trace (mock_server, "comment-query-async-progress-closure");
data->main_loop = g_main_loop_new (NULL, TRUE);
@@ -1660,7 +1677,7 @@ set_up_insert_comment (InsertCommentData *data, gconstpointer service)
{
set_up_comment ((CommentData*) data, service);
- gdata_mock_server_start_trace (mock_server, "setup-insert-comment");
+ gdata_test_mock_server_start_trace (mock_server, "setup-insert-comment");
/* Create a test comment to be inserted. */
data->comment = gdata_youtube_comment_new (NULL);
@@ -1674,7 +1691,7 @@ set_up_insert_comment (InsertCommentData *data, gconstpointer service)
static void
tear_down_insert_comment (InsertCommentData *data, gconstpointer service)
{
- gdata_mock_server_start_trace (mock_server, "teardown-insert-comment");
+ gdata_test_mock_server_start_trace (mock_server, "teardown-insert-comment");
if (data->comment != NULL) {
g_object_unref (data->comment);
@@ -1715,7 +1732,7 @@ test_comment_insert (InsertCommentData *data, gconstpointer service)
GDataComment *new_comment;
GError *error = NULL;
- gdata_mock_server_start_trace (mock_server, "comment-insert");
+ gdata_test_mock_server_start_trace (mock_server, "comment-insert");
new_comment = gdata_commentable_insert_comment (GDATA_COMMENTABLE (data->parent.video), GDATA_SERVICE
(service), GDATA_COMMENT (data->comment),
NULL, &error);
@@ -1733,7 +1750,7 @@ GDATA_ASYNC_CLOSURE_FUNCTIONS (insert_comment, InsertCommentData);
GDATA_ASYNC_TEST_FUNCTIONS (comment_insert, InsertCommentData,
G_STMT_START {
- gdata_mock_server_start_trace (mock_server, "comment-insert-async");
+ gdata_test_mock_server_start_trace (mock_server, "comment-insert-async");
gdata_commentable_insert_comment_async (GDATA_COMMENTABLE (data->parent.video), GDATA_SERVICE
(service),
GDATA_COMMENT (data->comment), cancellable,
async_ready_callback, async_data);
@@ -1760,7 +1777,7 @@ test_comment_delete (InsertCommentData *data, gconstpointer service)
gboolean success;
GError *error = NULL;
- gdata_mock_server_start_trace (mock_server, "comment-delete");
+ gdata_test_mock_server_start_trace (mock_server, "comment-delete");
/* We attempt to delete a comment which hasn't been inserted here, but that doesn't matter as the
function should always immediately
* return an error because deleting YouTube comments isn't allowed. */
@@ -1775,7 +1792,7 @@ test_comment_delete (InsertCommentData *data, gconstpointer service)
GDATA_ASYNC_TEST_FUNCTIONS (comment_delete, InsertCommentData,
G_STMT_START {
- gdata_mock_server_start_trace (mock_server, "comment-delete-async");
+ gdata_test_mock_server_start_trace (mock_server, "comment-delete-async");
gdata_commentable_delete_comment_async (GDATA_COMMENTABLE (data->parent.video), GDATA_SERVICE
(service),
GDATA_COMMENT (data->comment), cancellable,
async_ready_callback, async_data);
@@ -1840,7 +1857,7 @@ test_categories (gconstpointer service)
GError *error = NULL;
gchar *category_label, *old_locale;
- gdata_mock_server_start_trace (mock_server, "categories");
+ gdata_test_mock_server_start_trace (mock_server, "categories");
app_categories = gdata_youtube_service_get_categories (GDATA_YOUTUBE_SERVICE (service), NULL, &error);
g_assert_no_error (error);
@@ -1884,7 +1901,7 @@ test_categories (gconstpointer service)
GDATA_ASYNC_TEST_FUNCTIONS (categories, void,
G_STMT_START {
- gdata_mock_server_start_trace (mock_server, "categories-async");
+ gdata_test_mock_server_start_trace (mock_server, "categories-async");
gdata_youtube_service_get_categories_async (GDATA_YOUTUBE_SERVICE (service), cancellable,
async_ready_callback, async_data);
} G_STMT_END,
@@ -1920,7 +1937,7 @@ setup_batch (BatchData *data, gconstpointer service)
GDataEntry *video;
GError *error = NULL;
- gdata_mock_server_start_trace (mock_server, "setup-batch");
+ gdata_test_mock_server_start_trace (mock_server, "setup-batch");
/* We can't insert new videos as they'd just hit the moderation queue and cause tests to fail.
Instead, we rely on two videos already existing
* on the server with the given IDs. */
@@ -1952,7 +1969,7 @@ test_batch (BatchData *data, gconstpointer service)
guint op_id, op_id2;
GError *error = NULL;
- gdata_mock_server_start_trace (mock_server, "batch");
+ gdata_test_mock_server_start_trace (mock_server, "batch");
/* Here we hardcode the feed URI, but it should really be extracted from a video feed, as the
GDATA_LINK_BATCH link.
* It looks like this feed is read-only, so we can only test querying. */
@@ -2019,7 +2036,7 @@ test_batch_async (BatchData *data, gconstpointer service)
GDataBatchOperation *operation;
GMainLoop *main_loop;
- gdata_mock_server_start_trace (mock_server, "batch-async");
+ gdata_test_mock_server_start_trace (mock_server, "batch-async");
/* Run an async query operation on the video */
operation = gdata_batchable_create_operation (GDATA_BATCHABLE (service),
gdata_youtube_service_get_primary_authorization_domain (),
@@ -2056,7 +2073,7 @@ test_batch_async_cancellation (BatchData *data, gconstpointer service)
GCancellable *cancellable;
GError *error = NULL;
- gdata_mock_server_start_trace (mock_server, "batch-async-cancellation");
+ gdata_test_mock_server_start_trace (mock_server, "batch-async-cancellation");
/* Run an async query operation on the video */
operation = gdata_batchable_create_operation (GDATA_BATCHABLE (service),
gdata_youtube_service_get_primary_authorization_domain (),
@@ -2103,7 +2120,7 @@ main (int argc, char *argv[])
gdata_mock_server_set_trace_directory (mock_server, trace_directory);
g_object_unref (trace_directory);
- gdata_mock_server_start_trace (mock_server, "global-authentication");
+ gdata_test_mock_server_start_trace (mock_server, "global-authentication");
authorizer = GDATA_AUTHORIZER (gdata_client_login_authorizer_new (CLIENT_ID,
GDATA_TYPE_YOUTUBE_SERVICE));
gdata_client_login_authorizer_authenticate (GDATA_CLIENT_LOGIN_AUTHORIZER (authorizer), USERNAME,
PASSWORD, NULL, NULL);
gdata_mock_server_end_trace (mock_server);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]