[glom] Add test_selfhosting_new_empty_change_sysprefs.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Add test_selfhosting_new_empty_change_sysprefs.
- Date: Mon, 30 Jan 2012 21:06:06 +0000 (UTC)
commit 67c9527957416f64ddbae0f1027304ba1563b50b
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Jan 30 21:52:23 2012 +0100
Add test_selfhosting_new_empty_change_sysprefs.
* Makefile_tests.am:
* tests/test_selfhosting_new_empty_change_sysprefs.cc: Add this
test to check that the writing and reading of System Preferences works.
ChangeLog | 8 ++
Makefile_tests.am | 6 ++
glom/libglom/data_structure/system_prefs.cc | 57 ++++++++++++
glom/libglom/data_structure/system_prefs.h | 14 +++-
tests/.gitignore | 1 +
.../test_selfhosting_new_empty_change_sysprefs.cc | 90 ++++++++++++++++++++
6 files changed, 174 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2b28cde..e75d3ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2012-01-30 Murray Cumming <murrayc murrayc com>
+ Add test_selfhosting_new_empty_change_sysprefs.
+
+ * Makefile_tests.am:
+ * tests/test_selfhosting_new_empty_change_sysprefs.cc: Add this
+ test to check that the writing and reading of System Preferences works.
+
+2012-01-30 Murray Cumming <murrayc murrayc com>
+
test_selfhosting_new_empty: Move some code into test_selfhosting_utils
* tests/test_selfhosting_utils.[h|cc]: Add functions for self-hosting
diff --git a/Makefile_tests.am b/Makefile_tests.am
index fabcfcb..ff0b9d3 100644
--- a/Makefile_tests.am
+++ b/Makefile_tests.am
@@ -35,6 +35,7 @@ check_PROGRAMS = \
tests/python/test_python_module \
tests/test_fake_connection \
tests/test_selfhosting_new_empty \
+ tests/test_selfhosting_new_empty_change_sysprefs \
tests/test_selfhosting_new_from_example \
tests/test_selfhosting_new_from_example_strangepath \
tests/test_selfhosting_new_then_report \
@@ -68,6 +69,7 @@ TESTS = tests/test_document_load \
tests/python/test_python_module \
tests/test_fake_connection \
tests/test_selfhosting_new_empty \
+ tests/test_selfhosting_new_empty_change_sysprefs \
tests/test_selfhosting_new_from_example \
tests/test_selfhosting_new_from_example_in_locales.sh \
tests/test_selfhosting_new_from_example_strangepath \
@@ -216,6 +218,10 @@ tests_test_selfhosting_new_empty_SOURCES = tests/test_selfhosting_new_empty.cc $
tests_test_selfhosting_new_empty_LDADD = $(tests_ldadd)
tests_test_selfhosting_new_empty_CPPFLAGS = $(tests_cppflags)
+tests_test_selfhosting_new_empty_change_sysprefs_SOURCES = tests/test_selfhosting_new_empty_change_sysprefs.cc $(sources_test_selfhosting_utils)
+tests_test_selfhosting_new_empty_change_sysprefs_LDADD = $(tests_ldadd)
+tests_test_selfhosting_new_empty_change_sysprefs_CPPFLAGS = $(tests_cppflags)
+
tests_test_selfhosting_new_from_example_SOURCES = tests/test_selfhosting_new_from_example.cc $(sources_test_selfhosting_utils)
tests_test_selfhosting_new_from_example_LDADD = $(tests_ldadd)
tests_test_selfhosting_new_from_example_CPPFLAGS = $(tests_cppflags)
diff --git a/glom/libglom/data_structure/system_prefs.cc b/glom/libglom/data_structure/system_prefs.cc
index 71a75d2..e81af10 100644
--- a/glom/libglom/data_structure/system_prefs.cc
+++ b/glom/libglom/data_structure/system_prefs.cc
@@ -18,3 +18,60 @@
* Boston, MA 02111-1307, USA.
*/
+#include <libglom/data_structure/system_prefs.h>
+
+namespace Glom
+{
+
+SystemPrefs::SystemPrefs()
+{
+}
+
+SystemPrefs::SystemPrefs(const SystemPrefs& src)
+: m_name(src.m_name),
+ m_org_name(src.m_org_name),
+ m_org_address_street(src.m_org_address_street),
+ m_org_address_street2(src.m_org_address_street2),
+ m_org_address_town(src.m_org_address_town),
+ m_org_address_county(src.m_org_address_county),
+ m_org_address_country(src.m_org_address_country),
+ m_org_address_postcode(src.m_org_address_postcode),
+ m_org_logo(src.m_org_logo)
+{
+}
+
+SystemPrefs& SystemPrefs::operator=(const SystemPrefs& src)
+{
+ m_name = src.m_name;
+ m_org_name =src.m_org_name;
+ m_org_address_street = src.m_org_address_street;
+ m_org_address_street2 = src.m_org_address_street2;
+ m_org_address_town = src.m_org_address_town;
+ m_org_address_county = src.m_org_address_county;
+ m_org_address_country = src.m_org_address_country;
+ m_org_address_postcode = src.m_org_address_postcode;
+ m_org_logo = src.m_org_logo;
+
+ return *this;
+}
+
+bool SystemPrefs::operator==(const SystemPrefs& src) const
+{
+ return (m_name == src.m_name) &&
+ (m_org_name == src.m_org_name) &&
+ (m_org_address_street == src.m_org_address_street) &&
+ (m_org_address_street2 == src.m_org_address_street2) &&
+ (m_org_address_town == src.m_org_address_town) &&
+ (m_org_address_county == src.m_org_address_county) &&
+ (m_org_address_country == src.m_org_address_country) &&
+ (m_org_address_postcode == src.m_org_address_postcode) &&
+ (m_org_logo == src.m_org_logo);
+}
+
+bool SystemPrefs::operator!=(const SystemPrefs& src) const
+{
+ return !(operator==(src));
+}
+
+} //namespace Glom
+
diff --git a/glom/libglom/data_structure/system_prefs.h b/glom/libglom/data_structure/system_prefs.h
index 3fa0226..696afae 100644
--- a/glom/libglom/data_structure/system_prefs.h
+++ b/glom/libglom/data_structure/system_prefs.h
@@ -30,10 +30,20 @@ namespace Glom
class SystemPrefs
{
public:
- Glib::ustring m_name, m_org_name,
+ SystemPrefs();
+ SystemPrefs(const SystemPrefs& src);
+
+ SystemPrefs& operator=(const SystemPrefs& src);
+
+ bool operator==(const SystemPrefs& src) const;
+ bool operator!=(const SystemPrefs& src) const;
+
+
+ //TODO: Add getters and setters:
+ Glib::ustring m_name, m_org_name,
m_org_address_street, m_org_address_street2, m_org_address_town,
m_org_address_county, m_org_address_country, m_org_address_postcode;
- Gnome::Gda::Value m_org_logo; //TYPE_IMAGE.
+ Gnome::Gda::Value m_org_logo; //TYPE_IMAGE.
};
} //namespace Glom
diff --git a/tests/.gitignore b/tests/.gitignore
index d443a5a..fbf004b 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -17,6 +17,7 @@
/test_document_load_translations
/test_glade_derived_instantiation
/test_selfhosting_new_empty
+/test_selfhosting_new_empty_change_sysprefs
/test_selfhosting_new_from_example
/test_selfhosting_new_then_alter_table
/test_selfhosting_new_then_backup_restore
diff --git a/tests/test_selfhosting_new_empty_change_sysprefs.cc b/tests/test_selfhosting_new_empty_change_sysprefs.cc
new file mode 100644
index 0000000..300e482
--- /dev/null
+++ b/tests/test_selfhosting_new_empty_change_sysprefs.cc
@@ -0,0 +1,90 @@
+/* Glom
+ *
+ * Copyright (C) 2012 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+71 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "tests/test_selfhosting_utils.h"
+#include <libglom/init.h>
+#include <libglom/privs.h>
+#include <libglom/db_utils.h>
+#include <iostream>
+
+static bool test(Glom::Document::HostingMode hosting_mode)
+{
+ // Create the document:
+ Glom::Document document;
+
+ if(!(test_create_and_selfhost_new_database(document, hosting_mode, "test_db")))
+ {
+ std::cerr << "test_create_and_selfhost_new_database() failed" << std::endl;
+ return false;
+ }
+
+ //Test some simple changes to the database:
+ try
+ {
+ Glom::SystemPrefs prefs_in;
+ prefs_in.m_name = "test name";
+ prefs_in.m_org_name = "test org name";
+ prefs_in.m_org_address_street = "test street 1";
+ prefs_in.m_org_address_street2 = "test street 2";
+ prefs_in.m_org_address_county = "test county";
+ prefs_in.m_org_address_postcode = "test postcode";
+ prefs_in.m_org_address_country = "test country";
+ Glom::DbUtils::set_database_preferences(&document, prefs_in);
+
+ const Glom::SystemPrefs prefs_out =
+ Glom::DbUtils::get_database_preferences(&document);
+ if(prefs_out != prefs_in)
+ {
+ std::cerr << "The System Preferences read out were not the same as those written." << std::endl;
+ return false;
+ }
+ }
+ catch(const Glom::ExceptionConnection& ex)
+ {
+ std::cerr << "Exception: " << ex.what() << std::endl;
+ return false;
+ }
+
+ test_selfhosting_cleanup();
+ return true;
+}
+
+int main()
+{
+ Glom::libglom_init();
+
+ if(!test(Glom::Document::HOSTING_MODE_POSTGRES_SELF))
+ {
+ std::cerr << "Failed with PostgreSQL" << std::endl;
+ test_selfhosting_cleanup();
+ return EXIT_FAILURE;
+ }
+
+ if(!test(Glom::Document::HOSTING_MODE_SQLITE))
+ {
+ std::cerr << "Failed with SQLite" << std::endl;
+ test_selfhosting_cleanup();
+ return EXIT_FAILURE;
+ }
+
+ Glom::libglom_deinit();
+
+ return EXIT_SUCCESS;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]