AUDIT: r21832 - gnucash/trunk/src - [Bug 666329] - Empty database after a little while
John Ralls
jralls at code.gnucash.org
Mon Jan 9 18:10:20 EST 2012
Author: jralls
Date: 2012-01-09 18:10:20 -0500 (Mon, 09 Jan 2012)
New Revision: 21832
Trac: http://svn.gnucash.org/trac/changeset/21832
Modified:
gnucash/trunk/src/backend/sql/gnc-backend-sql.c
gnucash/trunk/src/backend/sql/test/utest-gnc-backend-sql.c
gnucash/trunk/src/backend/xml/gnc-backend-xml.c
gnucash/trunk/src/backend/xml/io-gncxml-v2.c
gnucash/trunk/src/gnome-utils/gnc-file.c
gnucash/trunk/src/gnome-utils/gnc-main-window.c
gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.c
gnucash/trunk/src/libqof/qof/qofbook.c
gnucash/trunk/src/libqof/qof/qofbook.h
gnucash/trunk/src/libqof/qof/test/test-qofbook.c
Log:
[Bug 666329] - Empty database after a little while
Separate the two uses of QofBook::dirty -- indicating that the book object
itself has been edited and indicating that some object in the dataset has
been changed -- into two separate variables with separate getters & setters.
The latter purpose, indicating that some object has been changed, is moved
to a new member variable of QofBook, session_dirty. Its new setter
qof_book_mark_session_dirty() and canceler qof_book_mark_session_saved()
are called only from the xml backend or gnc-autosave(). Its tester,
qof_book_session_not_saved() is used to check for the need to autosave
and to activate FileSaveAction.
BP
Modified: gnucash/trunk/src/backend/sql/gnc-backend-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-backend-sql.c 2012-01-09 23:10:06 UTC (rev 21831)
+++ gnucash/trunk/src/backend/sql/gnc-backend-sql.c 2012-01-09 23:10:20 UTC (rev 21832)
@@ -270,8 +270,10 @@
be->loading = FALSE;
- // Mark the book as clean
- qof_book_mark_saved( book );
+ /* Mark the sessoion as clean -- though it should never be marked
+ * dirty with this backend
+ */
+ qof_book_mark_session_saved( book );
finish_progress( be );
LEAVE( "" );
@@ -545,8 +547,10 @@
{
be->is_pristine_db = FALSE;
- // Mark the book as clean
- qof_book_mark_saved( book );
+ /* Mark the session as clean -- though it shouldn't ever get
+ * marked dirty with this backend
+ */
+ qof_book_mark_session_saved( book );
}
else
{
@@ -632,7 +636,7 @@
if ( strcmp( inst->e_type, "PriceDB" ) == 0 )
{
qof_instance_mark_clean( inst );
- qof_book_mark_saved( be->book );
+ qof_book_mark_session_saved( be->book );
return;
}
@@ -672,7 +676,7 @@
(void)gnc_sql_connection_rollback_transaction( be->conn );
// Don't let unknown items still mark the book as being dirty
- qof_book_mark_saved( be->book );
+ qof_book_mark_session_saved( be->book );
qof_instance_mark_clean(inst);
LEAVE( "Rolled back - unknown object type" );
return;
@@ -689,7 +693,7 @@
(void)gnc_sql_connection_commit_transaction( be->conn );
- qof_book_mark_saved( be->book );
+ qof_book_mark_session_saved( be->book );
qof_instance_mark_clean(inst);
LEAVE( "" );
Modified: gnucash/trunk/src/backend/sql/test/utest-gnc-backend-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/test/utest-gnc-backend-sql.c 2012-01-09 23:10:06 UTC (rev 21831)
+++ gnucash/trunk/src/backend/sql/test/utest-gnc-backend-sql.c 2012-01-09 23:10:20 UTC (rev 21832)
@@ -220,24 +220,34 @@
be.loading = FALSE;
qof_book_set_dirty_cb (be.book, test_dirty_cb, &dirty_called);
qof_instance_set_dirty_flag (inst, TRUE);
- qof_book_mark_dirty (be.book);
+ qof_book_mark_session_dirty (be.book);
g_assert (qof_instance_get_dirty_flag (inst));
- g_assert (qof_book_not_saved (be.book));
+ g_assert (qof_book_session_not_saved (be.book));
g_assert_cmpint (dirty_called, ==, 1);
gnc_sql_commit_edit (&be, inst);
g_assert (!qof_instance_get_dirty_flag (inst));
- g_assert (!qof_book_not_saved (be.book));
+ g_assert (!qof_book_session_not_saved (be.book));
g_assert_cmpint (dirty_called, ==, 0);
- qof_book_mark_dirty (be.book);
+ qof_book_mark_session_dirty (be.book);
+ g_assert (!qof_instance_get_dirty_flag (QOF_INSTANCE (be.book)));
+ g_assert (qof_book_session_not_saved (be.book));
+ g_assert_cmpint (dirty_called, ==, 1);
+ gnc_sql_commit_edit (&be, QOF_INSTANCE (be.book));
+ g_assert (!qof_instance_get_dirty_flag (QOF_INSTANCE (be.book)));
+ g_assert (qof_book_session_not_saved (be.book));
+ g_assert_cmpint (dirty_called, ==, 1);
+
+ qof_instance_set_dirty_flag (QOF_INSTANCE (be.book), TRUE);
+
g_assert (qof_instance_get_dirty_flag (QOF_INSTANCE (be.book)));
- g_assert (qof_book_not_saved (be.book));
+ g_assert (qof_book_session_not_saved (be.book));
g_assert_cmpint (dirty_called, ==, 1);
gnc_sql_commit_edit (&be, QOF_INSTANCE (be.book));
g_assert (!qof_instance_get_dirty_flag (QOF_INSTANCE (be.book)));
- g_assert (!qof_book_not_saved (be.book));
+ g_assert (!qof_book_session_not_saved (be.book));
g_assert_cmpint (dirty_called, ==, 0);
g_log_remove_handler (logdomain, hdlr1);
Modified: gnucash/trunk/src/backend/xml/gnc-backend-xml.c
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-backend-xml.c 2012-01-09 23:10:06 UTC (rev 21831)
+++ gnucash/trunk/src/backend/xml/gnc-backend-xml.c 2012-01-09 23:10:20 UTC (rev 21832)
@@ -692,7 +692,7 @@
/* If the book is 'clean', recently saved, then don't save again. */
/* XXX this is currently broken due to faulty 'Save As' logic. */
- /* if (FALSE == qof_book_not_saved (book)) return FALSE; */
+ /* if (FALSE == qof_book_session_not_saved (book)) return FALSE; */
tmp_name = g_new(char, strlen(datafile) + 12);
strcpy(tmp_name, datafile);
@@ -794,7 +794,7 @@
/* Since we successfully saved the book,
* we should mark it clean. */
- qof_book_mark_saved (book);
+ qof_book_mark_session_saved (book);
LEAVE (" successful save of book=%p to file=%s", book, datafile);
return TRUE;
}
@@ -1061,7 +1061,7 @@
!(qof_instance_get_infant(inst) && qof_instance_get_destroying(inst)))
{
qof_collection_mark_dirty(qof_instance_get_collection(inst));
- qof_book_mark_dirty(qof_instance_get_book(inst));
+ qof_book_mark_session_dirty(qof_instance_get_book(inst));
}
#if BORKEN_FOR_NOW
FileBackend *fbe = (FileBackend *) be;
@@ -1153,7 +1153,7 @@
}
/* We just got done loading, it can't possibly be dirty !! */
- qof_book_mark_saved (book);
+ qof_book_mark_session_saved (book);
}
/* ---------------------------------------------------------------------- */
Modified: gnucash/trunk/src/backend/xml/io-gncxml-v2.c
===================================================================
--- gnucash/trunk/src/backend/xml/io-gncxml-v2.c 2012-01-09 23:10:06 UTC (rev 21831)
+++ gnucash/trunk/src/backend/xml/io-gncxml-v2.c 2012-01-09 23:10:20 UTC (rev 21832)
@@ -783,8 +783,8 @@
xaccEnableDataScrubbing();
- /* Mark the book as saved */
- qof_book_mark_saved (book);
+ /* Mark the session as saved */
+ qof_book_mark_session_saved (book);
/* Call individual scrub functions */
memset(&be_data, 0, sizeof(be_data));
Modified: gnucash/trunk/src/gnome-utils/gnc-file.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-file.c 2012-01-09 23:10:06 UTC (rev 21831)
+++ gnucash/trunk/src/gnome-utils/gnc-file.c 2012-01-09 23:10:20 UTC (rev 21832)
@@ -551,7 +551,7 @@
* up the file-selection dialog, we don't blow him out of the water;
* instead, give them another chance to say "no" to the verify box.
*/
- while (qof_book_not_saved(current_book))
+ while (qof_book_session_not_saved(current_book))
{
GtkWidget *dialog;
gint response;
@@ -565,7 +565,7 @@
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
"%s", title);
- oldest_change = qof_book_get_dirty_time(current_book);
+ oldest_change = qof_book_get_session_dirty_time(current_book);
minutes = (time(NULL) - oldest_change) / 60 + 1;
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
ngettext("If you don't save, changes from the past %d minute will be discarded.",
Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c 2012-01-09 23:10:06 UTC (rev 21831)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c 2012-01-09 23:10:20 UTC (rev 21832)
@@ -1143,7 +1143,7 @@
GTK_BUTTONS_NONE,
title,
filename);
- oldest_change = qof_book_get_dirty_time(book);
+ oldest_change = qof_book_get_session_dirty_time(book);
minutes = (time(NULL) - oldest_change) / 60 + 1;
hours = minutes / 60;
minutes = minutes % 60;
@@ -1182,7 +1182,7 @@
return FALSE;
case GTK_RESPONSE_CLOSE:
- qof_book_mark_saved(book);
+ qof_book_mark_session_saved(book);
return FALSE;
default:
@@ -1237,7 +1237,7 @@
gboolean needs_save, do_shutdown;
session = gnc_get_current_session();
- needs_save = qof_book_not_saved(qof_session_get_book(session)) &&
+ needs_save = qof_book_session_not_saved(qof_session_get_book(session)) &&
!gnc_file_save_in_progress();
do_shutdown = !needs_save ||
(needs_save && !gnc_main_window_prompt_for_save(GTK_WIDGET(window)));
@@ -1369,7 +1369,7 @@
{
book_id = qof_session_get_url (gnc_get_current_session ());
book = gnc_get_current_book();
- if (qof_instance_is_dirty(QOF_INSTANCE(book)))
+ if (qof_book_session_not_saved (book))
{
dirty = "*";
if (action != NULL)
@@ -3434,7 +3434,7 @@
return TRUE;
}
session = gnc_get_current_session();
- needs_save = qof_book_not_saved(qof_session_get_book(session)) &&
+ needs_save = qof_book_session_not_saved(qof_session_get_book(session)) &&
!gnc_file_save_in_progress();
if (needs_save && gnc_main_window_prompt_for_save(GTK_WIDGET(window)))
return TRUE;
Modified: gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.c 2012-01-09 23:10:06 UTC (rev 21831)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-kvp.c 2012-01-09 23:10:20 UTC (rev 21832)
@@ -134,10 +134,8 @@
{
kvp_frame *frame = gnc_ab_get_book_kvp(b, TRUE);
kvp_value *value = kvp_value_new_glist_nc(template_list);
- qof_book_begin_edit(b);
kvp_frame_set_slot_nc(frame, AB_TEMPLATES, value);
- qof_book_mark_dirty(b);
- qof_book_commit_edit(b);
+ qof_book_kvp_changed (b);
}
static kvp_frame *
Modified: gnucash/trunk/src/libqof/qof/qofbook.c
===================================================================
--- gnucash/trunk/src/libqof/qof/qofbook.c 2012-01-09 23:10:06 UTC (rev 21831)
+++ gnucash/trunk/src/libqof/qof/qofbook.c 2012-01-09 23:10:20 UTC (rev 21832)
@@ -77,6 +77,7 @@
book->book_open = 'y';
book->read_only = FALSE;
+ book->session_dirty = FALSE;
book->version = 0;
}
@@ -154,41 +155,35 @@
/* ====================================================================== */
gboolean
-qof_book_not_saved (const QofBook *book)
+qof_book_session_not_saved (const QofBook *book)
{
if (!book) return FALSE;
+ return book->session_dirty;
- return(qof_instance_get_dirty_flag(book) || qof_object_is_dirty(book));
}
void
-qof_book_mark_saved (QofBook *book)
+qof_book_mark_session_saved (QofBook *book)
{
- gboolean was_dirty;
-
if (!book) return;
- was_dirty = qof_instance_get_dirty_flag(book);
- qof_instance_set_dirty_flag(book, FALSE);
book->dirty_time = 0;
- qof_object_mark_clean (book);
- if (was_dirty)
+ if (book->session_dirty)
{
+/* Set the session clean upfront, because the callback will check. */
+ book->session_dirty = FALSE;
if (book->dirty_cb)
book->dirty_cb(book, FALSE, book->dirty_data);
}
}
-void qof_book_mark_dirty (QofBook *book)
+void qof_book_mark_session_dirty (QofBook *book)
{
- gboolean was_dirty;
-
if (!book) return;
-
- was_dirty = qof_instance_get_dirty_flag(book);
- qof_instance_set_dirty_flag(book, TRUE);
- if (!was_dirty)
+ if (!book->session_dirty)
{
+/* Set the session dirty upfront, because the callback will check. */
+ book->session_dirty = TRUE;
book->dirty_time = time(NULL);
if (book->dirty_cb)
book->dirty_cb(book, TRUE, book->dirty_data);
@@ -196,7 +191,7 @@
}
time_t
-qof_book_get_dirty_time (const QofBook *book)
+qof_book_get_session_dirty_time (const QofBook *book)
{
return book->dirty_time;
}
@@ -243,7 +238,7 @@
void qof_book_kvp_changed (QofBook *book)
{
qof_book_begin_edit(book);
- qof_book_mark_dirty(book);
+ qof_instance_set_dirty (QOF_INSTANCE (book));
qof_book_commit_edit(book);
}
@@ -441,7 +436,7 @@
value = kvp_value_new_gint64 (counter);
kvp_frame_set_slot_path (kvp, value, "counters", counter_name, NULL);
kvp_value_delete (value);
- qof_book_mark_dirty(book);
+ qof_instance_set_dirty (QOF_INSTANCE (book));
qof_book_commit_edit(book);
format = qof_book_get_counter_format(book, counter_name);
@@ -657,7 +652,7 @@
{
qof_book_begin_edit(book);
kvp_frame_set_string(qof_book_get_slots(book), opt_name, opt_val);
- qof_book_mark_dirty(book);
+ qof_instance_set_dirty (QOF_INSTANCE (book));
qof_book_commit_edit(book);
}
Modified: gnucash/trunk/src/libqof/qof/qofbook.h
===================================================================
--- gnucash/trunk/src/libqof/qof/qofbook.h 2012-01-09 23:10:06 UTC (rev 21831)
+++ gnucash/trunk/src/libqof/qof/qofbook.h 2012-01-09 23:10:20 UTC (rev 21832)
@@ -69,8 +69,18 @@
{
QofInstance inst; /* Unique guid for this book. */
+ /* Boolean indicates that the session is dirty -- that is, it has
+ * not yet been written out to disk after the last time the
+ * backend ran commit_edit(). This is distinct from the inherited
+ * QofInstance::dirty, which indicates that some persisitent
+ * property of the book object itself has been edited and not
+ * committed. Some backends write data out as part of
+ * commit_edit() and so don't use this flag.
+ */
+ gboolean session_dirty;
+
/* The time when the book was first dirtied. This is a secondary
- * indicator. It should only be used when inst.dirty is TRUE. */
+ * indicator. It should only be used when session_saved is FALSE. */
time_t dirty_time;
/* This callback function is called any time the book dirty flag
@@ -97,7 +107,7 @@
GHashTable *data_table_finalizers;
/* Boolean indicates whether book is safe to write to (true means
- * that it isn't. The usual reason will be a database version
+ * that it isn't). The usual reason will be a database version
* mismatch with the running instance of Gnucash.
*/
gboolean read_only;
@@ -241,15 +251,14 @@
/** Is the book shutting down? */
gboolean qof_book_shutting_down (const QofBook *book);
-/** qof_book_not_saved() will return TRUE if any
- * data in the book hasn't been saved to long-term storage.
- * (Actually, that's not quite true. The book doesn't know
- * anything about saving. Its just that whenever data is modified,
- * the 'dirty' flag is set. This routine returns the value of the
- * 'dirty' flag. Its up to the backend to periodically reset this
- * flag, when it actually does save the data.)
+/** qof_book_not_saved() returns the value of the session_dirty flag,
+ * set when changes to any object in the book are committed
+ * (qof_backend->commit_edit has been called) and the backend hasn't
+ * yet written out the changes. (Note that SQL backends write commits
+ * out immediately; file backends don't, and use the flag to control
+ * an autosave timer.)
*/
-gboolean qof_book_not_saved (const QofBook *book);
+gboolean qof_book_session_not_saved (const QofBook *book);
/* The following functions are not useful in scripting languages */
#ifndef SWIG
@@ -259,16 +268,16 @@
* notsaved flag as FALSE just after loading. Can also be used
* by the frontend when the used has said to abandon any changes.
*/
-void qof_book_mark_saved(QofBook *book);
+void qof_book_mark_session_saved(QofBook *book);
/** The qof_book_mark_dirty() routine marks the book as having been
* modified. It can be used by frontend when the used has made a
* change at the book level.
*/
-void qof_book_mark_dirty(QofBook *book);
+void qof_book_mark_session_dirty(QofBook *book);
/** Retrieve the earliest modification time on the book. */
-time_t qof_book_get_dirty_time(const QofBook *book);
+time_t qof_book_get_session_dirty_time(const QofBook *book);
/** Set the function to call when a book transitions from clean to
* dirty, or vice versa.
Modified: gnucash/trunk/src/libqof/qof/test/test-qofbook.c
===================================================================
--- gnucash/trunk/src/libqof/qof/test/test-qofbook.c 2012-01-09 23:10:06 UTC (rev 21831)
+++ gnucash/trunk/src/libqof/qof/test/test-qofbook.c 2012-01-09 23:10:20 UTC (rev 21832)
@@ -196,35 +196,31 @@
const char *opt_value = "Option Value";
g_assert( fixture->book != NULL );
qof_book_set_string_option( fixture->book, opt_name, opt_value);
- g_assert( qof_book_not_saved( fixture->book ) );
+ g_assert( qof_instance_is_dirty (QOF_INSTANCE (fixture->book)) );
}
static void
-test_book_not_saved( Fixture *fixture, gconstpointer pData )
+test_book_session_not_saved( Fixture *fixture, gconstpointer pData )
{
- const char *opt_name = "Option Name";
- const char *opt_value = "Option Value";
g_assert( fixture->book != NULL );
- g_assert( !qof_book_not_saved( fixture->book ) );
- qof_book_set_string_option( fixture->book, opt_name, opt_value );
- g_assert( qof_book_not_saved( fixture->book ) );
- qof_book_mark_saved( fixture->book );
- g_assert( !qof_book_not_saved( fixture->book ) );
- qof_book_mark_dirty( fixture-> book );
- g_assert( qof_book_not_saved( fixture->book ) );
+ g_assert( !qof_book_session_not_saved( fixture->book ) );
+ qof_book_mark_session_saved( fixture->book );
+ g_assert( !qof_book_session_not_saved( fixture->book ) );
+ qof_book_mark_session_dirty( fixture-> book );
+ g_assert( qof_book_session_not_saved( fixture->book ) );
}
static void
-test_book_mark_saved( Fixture *fixture, gconstpointer pData )
+test_book_mark_session_saved( Fixture *fixture, gconstpointer pData )
{
time_t dirty_time, clean_time;
- qof_book_mark_dirty( fixture-> book );
- g_assert( qof_book_not_saved( fixture->book ) );
- dirty_time = qof_book_get_dirty_time( fixture->book );
- qof_book_mark_saved( fixture->book );
- clean_time = qof_book_get_dirty_time( fixture->book );
- g_assert( !qof_book_not_saved( fixture->book ) );
+ qof_book_mark_session_dirty( fixture-> book );
+ g_assert( qof_book_session_not_saved( fixture->book ) );
+ dirty_time = qof_book_get_session_dirty_time( fixture->book );
+ qof_book_mark_session_saved( fixture->book );
+ clean_time = qof_book_get_session_dirty_time( fixture->book );
+ g_assert( !qof_book_session_not_saved( fixture->book ) );
g_assert( dirty_time != clean_time );
g_assert( clean_time == 0);
}
@@ -343,7 +339,7 @@
counter = qof_book_get_counter( fixture->book, counter_name );
format = qof_book_get_counter_format( fixture->book, counter_name );
g_assert_cmpint( counter, == , 1 );
- g_assert( qof_book_not_saved( fixture->book ) );
+ g_assert( qof_instance_is_dirty (QOF_INSTANCE (fixture->book)) );
g_assert_cmpstr( r, == , g_strdup_printf( format, counter ));
g_free( r );
@@ -360,9 +356,9 @@
test_book_kvp_changed( Fixture *fixture, gconstpointer pData )
{
g_test_message( "Testing book is marked dirty after kvp_changed" );
- g_assert( !qof_book_not_saved( fixture->book ) );
+ g_assert( !qof_instance_is_dirty (QOF_INSTANCE (fixture->book)) );
qof_book_kvp_changed( fixture->book );
- g_assert( qof_book_not_saved( fixture->book ) );
+ g_assert( qof_instance_is_dirty (QOF_INSTANCE (fixture->book)) );
}
static void
@@ -392,70 +388,70 @@
}
static void
-test_book_mark_dirty( Fixture *fixture, gconstpointer pData )
+test_book_mark_session_dirty( Fixture *fixture, gconstpointer pData )
{
QofBook *_empty = NULL;
time_t before, after;
guint param = (guint) g_test_rand_int();
g_test_message( "Testing when book is NULL" );
- qof_book_mark_dirty( _empty );
+ qof_book_mark_session_dirty( _empty );
g_assert( _empty == NULL );
g_test_message( "Testing when book is not dirty and dirty_cb is null" );
- g_assert_cmpint( qof_book_get_dirty_time( fixture->book ), == , 0);
+ g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), == , 0);
g_assert( fixture->book->dirty_cb == NULL );
- g_assert( qof_book_not_saved( fixture->book ) == FALSE );
+ g_assert( qof_book_session_not_saved( fixture->book ) == FALSE );
before = time( NULL );
- qof_book_mark_dirty( fixture->book );
+ qof_book_mark_session_dirty( fixture->book );
after = time( NULL );
- g_assert_cmpint( qof_book_get_dirty_time( fixture->book ), >= , before);
- g_assert_cmpint( qof_book_get_dirty_time( fixture->book ), <= , after);
- g_assert( qof_book_not_saved( fixture->book ) == TRUE );
+ g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), >= , before);
+ g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), <= , after);
+ g_assert( qof_book_session_not_saved( fixture->book ) == TRUE );
g_test_message( "Testing when book is not dirty and dirty_cb is not null" );
/* prepare conditions */
- qof_book_mark_saved( fixture->book );
+ qof_book_mark_session_saved( fixture->book );
qof_book_set_dirty_cb( fixture->book, mock_dirty_cb, (gpointer) (¶m) );
test_struct.data = (gpointer) (¶m);
test_struct.called = FALSE;
g_assert( fixture->book->dirty_cb != NULL );
- g_assert_cmpint( qof_book_get_dirty_time( fixture->book ), == , 0);
- g_assert( qof_book_not_saved( fixture->book ) == FALSE );
+ g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), == , 0);
+ g_assert( qof_book_session_not_saved( fixture->book ) == FALSE );
/* run FUT */
before = time( NULL );
- qof_book_mark_dirty( fixture->book );
+ qof_book_mark_session_dirty( fixture->book );
after = time( NULL );
/* test output */
- g_assert_cmpint( qof_book_get_dirty_time( fixture->book ), >= , before);
- g_assert_cmpint( qof_book_get_dirty_time( fixture->book ), <= , after);
- g_assert( qof_book_not_saved( fixture->book ) == TRUE );
+ g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), >= , before);
+ g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), <= , after);
+ g_assert( qof_book_session_not_saved( fixture->book ) == TRUE );
g_assert( test_struct.called );
g_test_message( "Testing when book is dirty" );
- g_assert( qof_book_not_saved( fixture->book ) == TRUE );
- before = qof_book_get_dirty_time( fixture->book );
- qof_book_mark_dirty( fixture->book );
- g_assert( qof_book_not_saved( fixture->book ) == TRUE );
- after = qof_book_get_dirty_time( fixture->book );
+ g_assert( qof_book_session_not_saved( fixture->book ) == TRUE );
+ before = qof_book_get_session_dirty_time( fixture->book );
+ qof_book_mark_session_dirty( fixture->book );
+ g_assert( qof_book_session_not_saved( fixture->book ) == TRUE );
+ after = qof_book_get_session_dirty_time( fixture->book );
g_assert_cmpint( before, == , after );
}
static void
-test_book_get_dirty_time( Fixture *fixture, gconstpointer pData )
+test_book_get_session_dirty_time( Fixture *fixture, gconstpointer pData )
{
time_t before, after;
g_test_message( "Testing time on saved book = 0" );
- g_assert( qof_book_not_saved( fixture->book ) == FALSE );
- g_assert_cmpint( qof_book_get_dirty_time( fixture->book ), == , 0);
+ g_assert( qof_book_session_not_saved( fixture->book ) == FALSE );
+ g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), == , 0);
g_test_message( "Testing time on dirty book is correct" );
before = time( NULL );
- qof_book_mark_dirty( fixture->book );
+ qof_book_mark_session_dirty( fixture->book );
after = time( NULL );
- g_assert_cmpint( qof_book_get_dirty_time( fixture->book ), >= , before);
- g_assert_cmpint( qof_book_get_dirty_time( fixture->book ), <= , after);
+ g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), >= , before);
+ g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), <= , after);
}
@@ -693,15 +689,15 @@
GNC_TEST_ADD_FUNC( suitename, "validate counter", test_book_validate_counter );
GNC_TEST_ADD( suitename, "get string option", Fixture, NULL, setup, test_book_get_string_option, teardown );
GNC_TEST_ADD( suitename, "set string option", Fixture, NULL, setup, test_book_set_string_option, teardown );
- GNC_TEST_ADD( suitename, "not saved", Fixture, NULL, setup, test_book_not_saved, teardown );
- GNC_TEST_ADD( suitename, "mark saved", Fixture, NULL, setup, test_book_mark_saved, teardown );
+ GNC_TEST_ADD( suitename, "session not saved", Fixture, NULL, setup, test_book_session_not_saved, teardown );
+ GNC_TEST_ADD( suitename, "session mark saved", Fixture, NULL, setup, test_book_mark_session_saved, teardown );
GNC_TEST_ADD( suitename, "get counter", Fixture, NULL, setup, test_book_get_counter, teardown );
GNC_TEST_ADD( suitename, "get counter format", Fixture, NULL, setup, test_book_get_counter_format, teardown );
GNC_TEST_ADD( suitename, "increment and format counter", Fixture, NULL, setup, test_book_increment_and_format_counter, teardown );
GNC_TEST_ADD( suitename, "kvp changed", Fixture, NULL, setup, test_book_kvp_changed, teardown );
GNC_TEST_ADD( suitename, "use trading accounts", Fixture, NULL, setup, test_book_use_trading_accounts, teardown );
- GNC_TEST_ADD( suitename, "mark dirty", Fixture, NULL, setup, test_book_mark_dirty, teardown );
- GNC_TEST_ADD( suitename, "dirty time", Fixture, NULL, setup, test_book_get_dirty_time, teardown );
+ GNC_TEST_ADD( suitename, "mark session dirty", Fixture, NULL, setup, test_book_mark_session_dirty, teardown );
+ GNC_TEST_ADD( suitename, "session dirty time", Fixture, NULL, setup, test_book_get_session_dirty_time, teardown );
GNC_TEST_ADD( suitename, "set dirty callback", Fixture, NULL, setup, test_book_set_dirty_cb, teardown );
GNC_TEST_ADD( suitename, "shutting down", Fixture, NULL, setup, test_book_shutting_down, teardown );
GNC_TEST_ADD( suitename, "set get data", Fixture, NULL, setup, test_book_set_get_data, teardown );
More information about the gnucash-changes
mailing list