[glom] Test for autosaves without URI and for explicit saves while using autosave.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Test for autosaves without URI and for explicit saves while using autosave.
- Date: Wed, 7 Dec 2011 03:21:52 +0000 (UTC)
commit c8443a3774aef38cb49a22ccdccf3ce631e3ff7a
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Dec 6 22:50:03 2011 +0100
Test for autosaves without URI and for explicit saves while using autosave.
* glom/libglom/document/bakery/document.cc: write_to_disk():
Warn if the URI has not been set, because the caller probably wants
either autosave (meaning he should have set a URI first) or explicit
save (meaning he should disable autosave).
* glom/libglom/document/bakery/document_xml.cc: Warn about an attempt
to save when nothing has been modified, because this is usually caused
by a previous autosave, and the caller should probably be aware of that.
* tests/test_document_autosave.cc:
* tests/test_document_change.cc:
* tests/test_selfhosting_new_empty.cc:
* tests/test_selfhosting_new_then_backup_restore.cc:
* tests/test_selfhosting_utils.cc: Disable autosave so we can use
a simpler explicit save, avoiding these new warnings.
ChangeLog | 18 ++++++++++++++++++
glom/libglom/document/bakery/document.cc | 3 +++
glom/libglom/document/bakery/document_xml.cc | 1 +
tests/test_document_autosave.cc | 1 +
tests/test_document_change.cc | 1 +
tests/test_selfhosting_new_empty.cc | 1 +
tests/test_selfhosting_new_then_backup_restore.cc | 2 +-
tests/test_selfhosting_utils.cc | 2 ++
8 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0a99355..2f0189d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2011-12-06 Murray Cumming <murrayc murrayc com>
+ Test for autosaves without URI and for explicit saves while using autosave.
+
+ * glom/libglom/document/bakery/document.cc: write_to_disk():
+ Warn if the URI has not been set, because the caller probably wants
+ either autosave (meaning he should have set a URI first) or explicit
+ save (meaning he should disable autosave).
+ * glom/libglom/document/bakery/document_xml.cc: Warn about an attempt
+ to save when nothing has been modified, because this is usually caused
+ by a previous autosave, and the caller should probably be aware of that.
+ * tests/test_document_autosave.cc:
+ * tests/test_document_change.cc:
+ * tests/test_selfhosting_new_empty.cc:
+ * tests/test_selfhosting_new_then_backup_restore.cc:
+ * tests/test_selfhosting_utils.cc: Disable autosave so we can use
+ a simpler explicit save, avoiding these new warnings.
+
+2011-12-06 Murray Cumming <murrayc murrayc com>
+
Add a test that resaves (temporarily) all examples and checks the result.
* Makefile_tests.am:
diff --git a/glom/libglom/document/bakery/document.cc b/glom/libglom/document/bakery/document.cc
index 84a5e24..35eb02d 100644
--- a/glom/libglom/document/bakery/document.cc
+++ b/glom/libglom/document/bakery/document.cc
@@ -260,7 +260,10 @@ bool Document::read_from_disk(int& failure_code)
bool Document::write_to_disk()
{
if(m_file_uri.empty())
+ {
+ std::cerr << G_STRFUNC << ": m_file_uri is empty." << std::endl;
return false;
+ }
//Write the changed data to disk:
if(get_modified())
diff --git a/glom/libglom/document/bakery/document_xml.cc b/glom/libglom/document/bakery/document_xml.cc
index a01c0e8..ffa9378 100644
--- a/glom/libglom/document/bakery/document_xml.cc
+++ b/glom/libglom/document/bakery/document_xml.cc
@@ -84,6 +84,7 @@ bool Document_XML::save_before()
}
else
{
+ std::cout << G_STRFUNC << ": not saving, because not modified" << std::endl;
return true; //Success. (At doing nothing, because nothing needed to be done.)
}
}
diff --git a/tests/test_document_autosave.cc b/tests/test_document_autosave.cc
index 316513f..8d9da44 100644
--- a/tests/test_document_autosave.cc
+++ b/tests/test_document_autosave.cc
@@ -68,6 +68,7 @@ int main()
//Test manual saving:
{
Glom::Document document;
+ document.set_allow_autosave(false);
document.set_file_uri(file_uri);
document.set_hosting_mode(Glom::Document::HOSTING_MODE_POSTGRES_CENTRAL);
document.set_database_title(test_title);
diff --git a/tests/test_document_change.cc b/tests/test_document_change.cc
index 06cc3c3..982048e 100644
--- a/tests/test_document_change.cc
+++ b/tests/test_document_change.cc
@@ -49,6 +49,7 @@ int main()
Glom::libglom_init();
Glom::Document document;
+ document.set_allow_autosave(false); //Avoid warnings about it having no URI.
//Test some simple get/set operations:
const char* title = "Music Collection";
diff --git a/tests/test_selfhosting_new_empty.cc b/tests/test_selfhosting_new_empty.cc
index 743ec35..2b1d794 100644
--- a/tests/test_selfhosting_new_empty.cc
+++ b/tests/test_selfhosting_new_empty.cc
@@ -87,6 +87,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
//Save the file. TODO: Do we need to do this for the test?
const Glib::ustring file_uri = Glib::filename_to_uri(temp_filepath);
+ document.set_allow_autosave(false); //To simplify things and to not depend implicitly on autosave.
document.set_file_uri(file_uri);
document.set_hosting_mode(hosting_mode);
diff --git a/tests/test_selfhosting_new_then_backup_restore.cc b/tests/test_selfhosting_new_then_backup_restore.cc
index c402037..2ef10cb 100644
--- a/tests/test_selfhosting_new_then_backup_restore.cc
+++ b/tests/test_selfhosting_new_then_backup_restore.cc
@@ -73,7 +73,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
}
//Create a document from the backup:
- std::cout << "debug: recreated_uri=" << recreated_uri << std::endl;
+ //std::cout << "debug: recreated_uri=" << recreated_uri << std::endl;
Glom::Document document;
const bool recreated =
test_create_and_selfhost_from_uri(recreated_uri, document, hosting_mode);
diff --git a/tests/test_selfhosting_utils.cc b/tests/test_selfhosting_utils.cc
index 6401fd3..056fbd9 100644
--- a/tests/test_selfhosting_utils.cc
+++ b/tests/test_selfhosting_utils.cc
@@ -169,6 +169,7 @@ bool test_create_and_selfhost_from_uri(const Glib::ustring& example_file_uri, Gl
}
// Load the document:
+ document.set_allow_autosave(false); //To simplify things and to not depend implicitly on autosave.
document.set_file_uri(example_file_uri);
int failure_code = 0;
const bool test = document.load(failure_code);
@@ -205,6 +206,7 @@ bool test_create_and_selfhost_from_uri(const Glib::ustring& example_file_uri, Gl
//Save the example as a real file:
const Glib::ustring file_uri = Glib::filename_to_uri(temp_filepath);
+ document.set_allow_autosave(false); //To simplify things and to not depend implicitly on autosave.
document.set_file_uri(file_uri);
document.set_hosting_mode(hosting_mode);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]