[epiphany/gnome-3-18] Fix search provider horribly breaking history service
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-3-18] Fix search provider horribly breaking history service
- Date: Sat, 4 Mar 2017 20:36:41 +0000 (UTC)
commit f04a4c9d78d22ba9aa08679c30c9e7d14e5dab3d
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sat Feb 18 20:47:50 2017 -0600
Fix search provider horribly breaking history service
If the search provider is running, all database transactions will fail
because the search provider will take a write lock on the database.
Ouch! This is worth a good string of profanities....
Notably, this causes opening the database to fail if you searched for
anything in the shell overview in the minute prior to starting Epiphany.
(One minute is our search provider timeout.) Then no history will ever
get saved, ever. I think. Something like that.
So, although our history service has read-only mode, it's enforced at
the history service level, not the SQLite connection level. SQLite
actually has a read-only mode, which we are not using, and which we need
to use in the search provider if we want to have any chance of reliably
saving history.
Accordingly, give EphySQLiteConnection a mode property, to indicate
whether it is in writable mode or read-only mode. Teach all callers to
set it properly. Use it, rather than a boolean, when creating the
EphyHistoryService, since boolean parameters are hard to read at call
sites. And actually put the underlying SQLite connection in read-only
mode when set.
Don't open transactions or ever attempt to rollback in read-only mode,
because that doesn't make any sense. This should never have been
happening due to the history service level read-only checks, but it
should be enforced at the SQLite connection level now, too.
Avoid initializing tables when opening the database in read-only mode.
This is obviously writing to the database, and now that we really have a
read-only SQLite connection it fails. As it should.
SQLite connection creation will now fail in case the connection is
read-only and the database does not yet exist; it will no longer be
created anyway. So handle this case gracefully. It's fine for the
history service to return nothing in this case. This has the small
advantage that the history thread will quit immediately after it's
created in this case, so it's not constantly running if there's no
history in incognito mode anymore. To check for this condition, we
expose the underlying SQLite error; previously, only the error message
was exposed outside of EphySQLiteConnection. Exposing the error isn't
really necessary or sufficient, though, since it's super generic and we
have to check if the file actually exists on disk anyway.
Test it. Ensure that a read/write history service functions properly if
it's running at the same time as a read-only history service. Using two
read/write services here fails very badly, but when one of the services
is read-only it works fine.
Also, remove the original read-only service test. It only ever tested
that creating a read-only history service with an empty history database
would succeed. And, as I just explained, that fails now.
Lastly, stop running a second history service for the search provider.
It needed its own once upon a time when the search provider did not run
an EphyShell instance. That changed when we stopped using the default
web context, because nothing works without EphyEmbedShell now, as all
sorts of places need it to get the embed's web context. And since
EphyEmbedShell runs its own history service, the search provider can
just use that now instead of running its own separate one.
https://bugzilla.gnome.org/show_bug.cgi?id=778649
embed/ephy-embed-shell.c | 10 ++++-
lib/Makefile.am | 3 +-
lib/ephy-profile-migrator.c | 2 +-
lib/ephy-sqlite-connection.c | 74 +++++++++++++++++++++++++++++++-----
lib/ephy-sqlite-connection.h | 13 ++++++-
lib/history/ephy-history-service.c | 20 +++++++---
lib/history/ephy-history-service.h | 4 +-
src/ephy-search-provider.c | 9 ++--
tests/ephy-history-test.c | 64 +++++++++++++++++++------------
tests/ephy-sqlite-test.c | 2 +-
10 files changed, 150 insertions(+), 51 deletions(-)
---
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index eca859a..f3a3d29 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -415,10 +415,16 @@ ephy_embed_shell_get_global_history_service (EphyEmbedShell *shell)
if (shell->priv->global_history_service == NULL) {
char *filename;
+ EphySQLiteConnectionMode mode;
+
+ if (shell->priv->mode == EPHY_EMBED_SHELL_MODE_INCOGNITO ||
+ shell->priv->mode == EPHY_EMBED_SHELL_MODE_SEARCH_PROVIDER)
+ mode = EPHY_SQLITE_CONNECTION_MODE_READ_ONLY;
+ else
+ mode = EPHY_SQLITE_CONNECTION_MODE_READWRITE;
filename = g_build_filename (ephy_dot_dir (), EPHY_HISTORY_FILE, NULL);
- shell->priv->global_history_service = ephy_history_service_new (filename,
- shell->priv->mode ==
EPHY_EMBED_SHELL_MODE_INCOGNITO);
+ shell->priv->global_history_service = ephy_history_service_new (filename, mode);
g_free (filename);
g_return_val_if_fail (shell->priv->global_history_service, NULL);
g_signal_connect (shell->priv->global_history_service, "urls-visited",
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 24d684b..fad0909 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -35,7 +35,8 @@ NOINST_H_FILES = \
TYPES_H_FILES = \
ephy-initial-state.h \
ephy-node.h \
- ephy-security-levels.h
+ ephy-security-levels.h \
+ ephy-sqlite-connection.h
INST_H_FILES = \
ephy-dialog.h \
diff --git a/lib/ephy-profile-migrator.c b/lib/ephy-profile-migrator.c
index fce3ad3..cdba8ce 100644
--- a/lib/ephy-profile-migrator.c
+++ b/lib/ephy-profile-migrator.c
@@ -783,7 +783,7 @@ migrate_new_urls_table (void)
GError *error = NULL;
filename = g_build_filename (ephy_dot_dir (), EPHY_HISTORY_FILE, NULL);
- history_database = ephy_sqlite_connection_new ();
+ history_database = ephy_sqlite_connection_new (EPHY_SQLITE_CONNECTION_MODE_READWRITE);
ephy_sqlite_connection_open (history_database, filename, &error);
if (error) {
diff --git a/lib/ephy-sqlite-connection.c b/lib/ephy-sqlite-connection.c
index 3955d76..b99b8f0 100644
--- a/lib/ephy-sqlite-connection.c
+++ b/lib/ephy-sqlite-connection.c
@@ -19,16 +19,27 @@
#include "config.h"
#include "ephy-sqlite-connection.h"
+#include "ephy-lib-type-builtins.h"
+
#include <sqlite3.h>
struct _EphySQLiteConnectionPrivate {
sqlite3 *database;
+ EphySQLiteConnectionMode mode;
};
#define EPHY_SQLITE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), EPHY_TYPE_SQLITE_CONNECTION,
EphySQLiteConnectionPrivate))
G_DEFINE_TYPE (EphySQLiteConnection, ephy_sqlite_connection, G_TYPE_OBJECT);
+enum {
+ PROP_0,
+ PROP_MODE,
+ LAST_PROP
+};
+
+static GParamSpec *obj_properties[LAST_PROP];
+
static void
ephy_sqlite_connection_finalize (GObject *self)
{
@@ -37,11 +48,42 @@ ephy_sqlite_connection_finalize (GObject *self)
}
static void
+ephy_sqlite_connection_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphySQLiteConnection *self = EPHY_SQLITE_CONNECTION (object);
+
+ switch (property_id) {
+ case PROP_MODE:
+ self->priv->mode = g_value_get_enum (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (self, property_id, pspec);
+ break;
+ }
+}
+
+static void
ephy_sqlite_connection_class_init (EphySQLiteConnectionClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = ephy_sqlite_connection_finalize;
- g_type_class_add_private (object_class, sizeof (EphySQLiteConnectionPrivate));
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = ephy_sqlite_connection_finalize;
+ gobject_class->set_property = ephy_sqlite_connection_set_property;
+
+ obj_properties[PROP_MODE] =
+ g_param_spec_enum ("mode",
+ "SQLite connection mode",
+ "Whether the SQLite connection is read-only or writable",
+ EPHY_TYPE_SQ_LITE_CONNECTION_MODE,
+ EPHY_SQLITE_CONNECTION_MODE_READWRITE,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (gobject_class, LAST_PROP, obj_properties);
+
+ g_type_class_add_private (gobject_class, sizeof (EphySQLiteConnectionPrivate));
}
static void
@@ -51,7 +93,7 @@ ephy_sqlite_connection_init (EphySQLiteConnection *self)
self->priv->database = NULL;
}
-static GQuark get_ephy_sqlite_quark (void)
+GQuark ephy_sqlite_error_quark (void)
{
return g_quark_from_static_string ("ephy-sqlite");
}
@@ -60,13 +102,15 @@ static void
set_error_from_string (const char* string, GError **error)
{
if (error)
- *error = g_error_new (get_ephy_sqlite_quark (), 0, string, 0);
+ *error = g_error_new_literal (ephy_sqlite_error_quark (), 0, string);
}
EphySQLiteConnection *
-ephy_sqlite_connection_new ()
+ephy_sqlite_connection_new (EphySQLiteConnectionMode mode)
{
- return EPHY_SQLITE_CONNECTION (g_object_new (EPHY_TYPE_SQLITE_CONNECTION, NULL));
+ return EPHY_SQLITE_CONNECTION (g_object_new (EPHY_TYPE_SQLITE_CONNECTION,
+ "mode", mode,
+ NULL));
}
gboolean
@@ -78,8 +122,12 @@ ephy_sqlite_connection_open (EphySQLiteConnection *self, const gchar *filename,
set_error_from_string ("Connection already open.", error);
return FALSE;
}
-
- if (sqlite3_open (filename, &priv->database) != SQLITE_OK) {
+
+ if (sqlite3_open_v2 (filename,
+ &priv->database,
+ priv->mode == EPHY_SQLITE_CONNECTION_MODE_READ_ONLY ? SQLITE_OPEN_READONLY
+ : SQLITE_OPEN_READWRITE |
SQLITE_OPEN_CREATE,
+ NULL) != SQLITE_OK) {
ephy_sqlite_connection_get_error (self, error);
priv->database = NULL;
return FALSE;
@@ -102,7 +150,7 @@ void
ephy_sqlite_connection_get_error (EphySQLiteConnection *self, GError **error)
{
if (error)
- *error = g_error_new (get_ephy_sqlite_quark (), 0, sqlite3_errmsg (self->priv->database), 0);
+ *error = g_error_new_literal (ephy_sqlite_error_quark (), sqlite3_errcode (self->priv->database),
sqlite3_errmsg (self->priv->database));
}
gboolean
@@ -153,18 +201,24 @@ ephy_sqlite_connection_get_last_insert_id (EphySQLiteConnection *self)
gboolean
ephy_sqlite_connection_begin_transaction (EphySQLiteConnection *self, GError **error)
{
+ if (self->priv->mode == EPHY_SQLITE_CONNECTION_MODE_READ_ONLY)
+ return TRUE;
return ephy_sqlite_connection_execute (self, "BEGIN TRANSACTION", error);
}
gboolean
ephy_sqlite_connection_rollback_transaction (EphySQLiteConnection *self, GError **error)
{
+ if (self->priv->mode == EPHY_SQLITE_CONNECTION_MODE_READ_ONLY)
+ return TRUE;
return ephy_sqlite_connection_execute (self, "ROLLBACK", error);
}
gboolean
ephy_sqlite_connection_commit_transaction (EphySQLiteConnection *self, GError **error)
{
+ if (self->priv->mode == EPHY_SQLITE_CONNECTION_MODE_READ_ONLY)
+ return TRUE;
return ephy_sqlite_connection_execute (self, "COMMIT", error);
}
diff --git a/lib/ephy-sqlite-connection.h b/lib/ephy-sqlite-connection.h
index 74f30bd..e4ecd5c 100644
--- a/lib/ephy-sqlite-connection.h
+++ b/lib/ephy-sqlite-connection.h
@@ -22,6 +22,8 @@
#include <glib-object.h>
#include "ephy-sqlite-statement.h"
+#include <sqlite3.h>
+
G_BEGIN_DECLS
/* convenience macros */
@@ -49,7 +51,12 @@ struct _EphySQLiteConnectionClass {
GType ephy_sqlite_connection_get_type (void);
-EphySQLiteConnection * ephy_sqlite_connection_new (void);
+typedef enum {
+ EPHY_SQLITE_CONNECTION_MODE_READ_ONLY,
+ EPHY_SQLITE_CONNECTION_MODE_READWRITE
+} EphySQLiteConnectionMode;
+
+EphySQLiteConnection * ephy_sqlite_connection_new (EphySQLiteConnectionMode mode);
gboolean ephy_sqlite_connection_open (EphySQLiteConnection *self, const
gchar *filename, GError **error);
void ephy_sqlite_connection_close (EphySQLiteConnection *self);
@@ -66,6 +73,10 @@ gboolean ephy_sqlite_connection_commit_transaction (EphySQLi
gboolean ephy_sqlite_connection_table_exists (EphySQLiteConnection *self, const
char *table_name);
+GQuark ephy_sqlite_error_quark (void);
+
+#define EPHY_SQLITE_ERROR ephy_sqlite_error_quark ()
+
G_END_DECLS
#endif /* EPHY_SQLITE_CONNECTION_H */
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index c36c0c0..3af20da 100644
--- a/lib/history/ephy-history-service.c
+++ b/lib/history/ephy-history-service.c
@@ -295,13 +295,13 @@ ephy_history_service_init (EphyHistoryService *self)
}
EphyHistoryService *
-ephy_history_service_new (const char *history_filename,
- gboolean read_only)
+ephy_history_service_new (const char *history_filename,
+ EphySQLiteConnectionMode mode)
{
return EPHY_HISTORY_SERVICE (g_object_new (EPHY_TYPE_HISTORY_SERVICE,
"history-filename", history_filename,
- "read-only", read_only,
- NULL));
+ "read-only", mode == EPHY_SQLITE_CONNECTION_MODE_READ_ONLY,
+ NULL));
}
static gint
@@ -405,12 +405,20 @@ ephy_history_service_open_database_connections (EphyHistoryService *self)
g_assert (priv->history_thread == g_thread_self ());
- priv->history_database = ephy_sqlite_connection_new ();
+ priv->history_database = ephy_sqlite_connection_new (priv->read_only ?
EPHY_SQLITE_CONNECTION_MODE_READ_ONLY
+ :
EPHY_SQLITE_CONNECTION_MODE_READWRITE);
ephy_sqlite_connection_open (priv->history_database, priv->history_filename, &error);
if (error) {
g_object_unref (priv->history_database);
priv->history_database = NULL;
- g_warning ("Could not open history database at %s: %s", priv->history_filename, error->message);
+
+ /* Opening the database is expected to fail if it's being opened in read-
+ * only mode and does not already exist. Otherwise, this is bad. */
+ if (!priv->read_only ||
+ !g_error_matches (error, EPHY_SQLITE_ERROR, SQLITE_CANTOPEN) ||
+ g_file_test (priv->history_filename, G_FILE_TEST_EXISTS)) {
+ g_warning ("Could not open history database at %s: %s", priv->history_filename, error->message);
+ }
g_error_free (error);
return FALSE;
}
diff --git a/lib/history/ephy-history-service.h b/lib/history/ephy-history-service.h
index c20f2c4..43244d2 100644
--- a/lib/history/ephy-history-service.h
+++ b/lib/history/ephy-history-service.h
@@ -23,7 +23,9 @@
#include <glib-object.h>
#include <gio/gio.h>
+
#include "ephy-history-types.h"
+#include "ephy-sqlite-connection.h"
G_BEGIN_DECLS
@@ -58,7 +60,7 @@ struct _EphyHistoryServiceClass {
};
GType ephy_history_service_get_type (void);
-EphyHistoryService * ephy_history_service_new (const char *history_filename,
gboolean read_only);
+EphyHistoryService * ephy_history_service_new (const char *history_filename,
EphySQLiteConnectionMode mode);
void ephy_history_service_add_visit (EphyHistoryService *self,
EphyHistoryPageVisit *visit, GCancellable *cancellable, EphyHistoryJobCallback callback, gpointer user_data);
void ephy_history_service_add_visits (EphyHistoryService *self, GList
*visits, GCancellable *cancellable, EphyHistoryJobCallback callback, gpointer user_data);
diff --git a/src/ephy-search-provider.c b/src/ephy-search-provider.c
index cdc802c..65f2dda 100644
--- a/src/ephy-search-provider.c
+++ b/src/ephy-search-provider.c
@@ -22,6 +22,7 @@
#include "ephy-search-provider.h"
#include "ephy-completion-model.h"
+#include "ephy-embed-shell.h"
#include "ephy-file-helpers.h"
#include "ephy-prefs.h"
#include "ephy-profile-utils.h"
@@ -40,7 +41,6 @@ struct _EphySearchProvider
GCancellable *cancellable;
GSettings *settings;
- EphyHistoryService *history_service;
EphyBookmarks *bookmarks;
EphyCompletionModel *model;
};
@@ -346,6 +346,7 @@ static void
ephy_search_provider_init (EphySearchProvider *self)
{
char *filename;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
g_application_set_flags (G_APPLICATION (self), G_APPLICATION_IS_SERVICE);
@@ -365,9 +366,10 @@ ephy_search_provider_init (EphySearchProvider *self)
self->settings = g_settings_new (EPHY_PREFS_SCHEMA);
filename = g_build_filename (ephy_dot_dir (), EPHY_HISTORY_FILE, NULL);
- self->history_service = ephy_history_service_new (filename, TRUE);
self->bookmarks = ephy_bookmarks_new ();
- self->model = ephy_completion_model_new (self->history_service, self->bookmarks, FALSE);
+ self->model = ephy_completion_model_new (EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service
(shell)),
+ self->bookmarks,
+ FALSE);
g_free (filename);
self->cancellable = g_cancellable_new ();
@@ -426,7 +428,6 @@ ephy_search_provider_dispose (GObject *object)
g_clear_object (&self->settings);
g_clear_object (&self->cancellable);
g_clear_object (&self->model);
- g_clear_object (&self->history_service);
g_clear_object (&self->bookmarks);
G_OBJECT_CLASS (ephy_search_provider_parent_class)->dispose (object);
diff --git a/tests/ephy-history-test.c b/tests/ephy-history-test.c
index 83962ab..295ad61 100644
--- a/tests/ephy-history-test.c
+++ b/tests/ephy-history-test.c
@@ -29,29 +29,19 @@
#include <gtk/gtk.h>
static EphyHistoryService *
-ensure_empty_history (const char* filename, gboolean readonly)
+ensure_empty_history (const char *filename)
{
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR))
g_unlink (filename);
- return ephy_history_service_new (filename, readonly);
+ return ephy_history_service_new (filename, EPHY_SQLITE_CONNECTION_MODE_READWRITE);
}
static void
test_create_history_service (void)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
- EphyHistoryService *service = ensure_empty_history (temporary_file, FALSE);
-
- g_free (temporary_file);
- g_object_unref (service);
-}
-
-static void
-test_create_readonly_history_service (void)
-{
- gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
- EphyHistoryService *service = ensure_empty_history (temporary_file, TRUE);
+ EphyHistoryService *service = ensure_empty_history (temporary_file);
g_free (temporary_file);
g_object_unref (service);
@@ -71,7 +61,7 @@ static void
test_create_history_service_and_destroy_later (void)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
- EphyHistoryService *service = ensure_empty_history (temporary_file, FALSE);
+ EphyHistoryService *service = ensure_empty_history (temporary_file);
g_free (temporary_file);
g_timeout_add (100, (GSourceFunc) destroy_history_service_and_end_main_loop, service);
@@ -81,9 +71,12 @@ test_create_history_service_and_destroy_later (void)
static void
page_vist_created (EphyHistoryService *service, gboolean success, gpointer result_data, gpointer user_data)
{
+ if (user_data != NULL) {
+ g_assert (EPHY_IS_HISTORY_SERVICE (user_data));
+ g_object_unref (user_data);
+ }
g_object_unref (service);
g_assert (result_data == NULL);
- g_assert (user_data == NULL);
g_assert (success);
gtk_main_quit ();
}
@@ -92,7 +85,7 @@ static void
test_create_history_entry (void)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
- EphyHistoryService *service = ensure_empty_history (temporary_file, FALSE);
+ EphyHistoryService *service = ensure_empty_history (temporary_file);
EphyHistoryPageVisit *visit = ephy_history_page_visit_new ("http://www.gnome.org", 0,
EPHY_PAGE_VISIT_TYPED);
ephy_history_service_add_visit (service, visit, NULL, page_vist_created, NULL);
@@ -102,6 +95,29 @@ test_create_history_entry (void)
gtk_main ();
}
+static void
+test_readonly_mode (void)
+{
+ gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
+ /* FIXME: This is racy, since we need to be sure the history thread of the
+ * first EphyHistoryService object has created the database before starting
+ * the history thread of the second EphyHistoryService object. This is a test
+ * bug, not an application bug.
+ */
+ EphyHistoryService *service = ensure_empty_history (temporary_file);
+ EphyHistoryService *readonly_service = ephy_history_service_new (temporary_file,
EPHY_SQLITE_CONNECTION_MODE_READ_ONLY);
+
+ /* Having the database open read-only should not break normal connections.
+ * https://bugzilla.gnome.org/show_bug.cgi?id=778649 */
+ EphyHistoryPageVisit *visit = ephy_history_page_visit_new ("http://www.gnome.org", 0,
EPHY_PAGE_VISIT_TYPED);
+ ephy_history_service_add_visit (service, visit, NULL, page_vist_created, readonly_service);
+ ephy_history_page_visit_free (visit);
+ g_free (temporary_file);
+
+ gtk_main ();
+}
+
+
static GList *
create_test_page_visit_list (void)
{
@@ -165,7 +181,7 @@ static void
test_create_history_entries (void)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
- EphyHistoryService *service = ensure_empty_history (temporary_file, FALSE);
+ EphyHistoryService *service = ensure_empty_history (temporary_file);
GList *visits = create_test_page_visit_list ();
@@ -214,7 +230,7 @@ static void
test_set_url_title_helper (gboolean test_results)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
- EphyHistoryService *service = ensure_empty_history (temporary_file, FALSE);
+ EphyHistoryService *service = ensure_empty_history (temporary_file);
EphyHistoryPageVisit *visit = ephy_history_page_visit_new ("http://www.gnome.org", 0,
EPHY_PAGE_VISIT_TYPED);
ephy_history_service_add_visit (service, visit, NULL, set_url_title_visit_created, GINT_TO_POINTER
(test_results));
@@ -248,7 +264,7 @@ static void
test_set_url_title_url_not_existent (void)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
- EphyHistoryService *service = ensure_empty_history (temporary_file, FALSE);
+ EphyHistoryService *service = ensure_empty_history (temporary_file);
g_free (temporary_file);
ephy_history_service_set_url_title (service, "http://www.gnome.org", "GNOME", NULL,
set_url_title_url_not_existent, NULL);
@@ -290,7 +306,7 @@ static void
test_get_url_helper (gboolean add_entry)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
- EphyHistoryService *service = ensure_empty_history (temporary_file, FALSE);
+ EphyHistoryService *service = ensure_empty_history (temporary_file);
g_free (temporary_file);
if (add_entry == TRUE) {
@@ -387,7 +403,7 @@ static void
test_complex_url_query (void)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
- EphyHistoryService *service = ensure_empty_history (temporary_file, FALSE);
+ EphyHistoryService *service = ensure_empty_history (temporary_file);
GList *visits;
visits = create_visits_for_complex_tests ();
@@ -427,7 +443,7 @@ static void
test_complex_url_query_with_time_range (void)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
- EphyHistoryService *service = ensure_empty_history (temporary_file, FALSE);
+ EphyHistoryService *service = ensure_empty_history (temporary_file);
GList *visits;
visits = create_visits_for_complex_tests ();
@@ -476,7 +492,7 @@ static void
test_clear (void)
{
gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
- EphyHistoryService *service = ensure_empty_history (temporary_file, FALSE);
+ EphyHistoryService *service = ensure_empty_history (temporary_file);
GList *visits = create_test_page_visit_list ();
ephy_history_service_add_visits (service, visits, NULL, NULL, NULL);
@@ -491,9 +507,9 @@ main (int argc, char *argv[])
gtk_test_init (&argc, &argv);
g_test_add_func ("/embed/history/test_create_history_service", test_create_history_service);
- g_test_add_func ("/embed/history/test_create_readonly_history_service",
test_create_readonly_history_service);
g_test_add_func ("/embed/history/test_create_history_service_and_destroy_later",
test_create_history_service_and_destroy_later);
g_test_add_func ("/embed/history/test_create_history_entry", test_create_history_entry);
+ g_test_add_func ("/embed/history/test_readonly_mode", test_readonly_mode);
g_test_add_func ("/embed/history/test_create_history_entries", test_create_history_entries);
g_test_add_func ("/embed/history/test_set_url_title", test_set_url_title);
g_test_add_func ("/embed/history/test_set_url_title_is_correct", test_set_url_title_is_correct);
diff --git a/tests/ephy-sqlite-test.c b/tests/ephy-sqlite-test.c
index 309f7cf..118c6f4 100644
--- a/tests/ephy-sqlite-test.c
+++ b/tests/ephy-sqlite-test.c
@@ -31,7 +31,7 @@
static EphySQLiteConnection *
ensure_empty_database (const char* filename)
{
- EphySQLiteConnection *connection = ephy_sqlite_connection_new ();
+ EphySQLiteConnection *connection = ephy_sqlite_connection_new (EPHY_SQLITE_CONNECTION_MODE_READWRITE);
GError *error = NULL;
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]