[glom/glom-1-20] tests/test_document_load_and_change: Change a relationship name.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/glom-1-20] tests/test_document_load_and_change: Change a relationship name.
- Date: Mon, 5 Dec 2011 15:24:38 +0000 (UTC)
commit 5b083eca34f9456e31133a41a1b50b9134c9a5f1
Author: Murray Cumming <murrayc murrayc com>
Date: Sat Dec 3 14:48:07 2011 +0100
tests/test_document_load_and_change: Change a relationship name.
* Makefile_tests.am: Use the test_utils.
* tests/test_document_load_and_change.cc: Also rename a relationship
and check that a layout item uses the new relationship name.
ChangeLog | 8 ++++++++
Makefile_tests.am | 2 +-
tests/test_document_load_and_change.cc | 30 ++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 75c5815..059fdca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2011-12-03 Murray Cumming <murrayc murrayc com>
+ tests/test_document_load_and_change: Change a relationship name.
+
+ * Makefile_tests.am: Use the test_utils.
+ * tests/test_document_load_and_change.cc: Also rename a relationship
+ and check that a layout item uses the new relationship name.
+
+2011-12-03 Murray Cumming <murrayc murrayc com>
+
Tests: Add a shared get_field_on_layout() function.
* tests/test_document_load.cc: Move get_field_on_layout() to
diff --git a/Makefile_tests.am b/Makefile_tests.am
index 02451c6..737496e 100644
--- a/Makefile_tests.am
+++ b/Makefile_tests.am
@@ -100,7 +100,7 @@ tests_test_document_load_SOURCES = tests/test_document_load.cc $(sources_test_ut
tests_test_document_load_LDADD = $(tests_ldadd)
tests_test_document_load_CPPFLAGS = $(tests_cppflags)
-tests_test_document_load_and_change_SOURCES = tests/test_document_load_and_change.cc
+tests_test_document_load_and_change_SOURCES = tests/test_document_load_and_change.cc $(sources_test_utils)
tests_test_document_load_and_change_LDADD = $(tests_ldadd)
tests_test_document_load_and_change_CPPFLAGS = $(tests_cppflags)
diff --git a/tests/test_document_load_and_change.cc b/tests/test_document_load_and_change.cc
index 064b3d4..ef95689 100644
--- a/tests/test_document_load_and_change.cc
+++ b/tests/test_document_load_and_change.cc
@@ -18,6 +18,7 @@
* Boston, MA 02111-1307, USA.
*/
+#include "tests/test_utils.h"
#include <libglom/document/document.h>
#include <libglom/init.h>
#include <giomm/file.h>
@@ -130,6 +131,35 @@ int main()
return false;
}
+ {
+ //Change a relationship name:
+ const Glib::ustring table_name = "invoices";
+ const Glib::ustring relationship_name_original = "contacts";
+ const Glib::ustring relationship_name_new = "newrelationshipname";
+ document.change_relationship_name(table_name,
+ relationship_name_original, relationship_name_new);
+ if(document.get_relationship(table_name, relationship_name_original))
+ {
+ std::cerr << "Failure: The original relationship name still exists." << std::endl;
+ return false;
+ }
+
+ if(!document.get_relationship(table_name, relationship_name_new))
+ {
+ std::cerr << "Failure: The new relationship name does not exist." << std::endl;
+ return false;
+ }
+
+ //Check that the old relationship name is not used.
+ Glom::sharedptr<const Glom::LayoutItem_Field> field_on_layout =
+ get_field_on_layout(document, table_name, "contacts", "name_full");
+ g_assert(field_on_layout);
+ if(field_on_layout->get_relationship_name() != relationship_name_new)
+ {
+ std::cerr << "Failure: A layout item does not use the new relationship name as expected." << std::endl;
+ return false;
+ }
+ }
//Remove a field from the whole document:
document.remove_field("publisher", "publisher_id");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]