[glom] test_selfhosting_new_then_image: Move some code to test_utils.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] test_selfhosting_new_then_image: Move some code to test_utils.
- Date: Tue, 13 Dec 2011 09:42:05 +0000 (UTC)
commit 2b58f667765afb769d6557d54d545dd8b5e81497
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Dec 13 10:38:53 2011 +0100
test_selfhosting_new_then_image: Move some code to test_utils.
* Makefile_tests.am:
* tests/test_selfhosting_new_then_image.cc: Move the test image-loading
code to:
* tests/test_utils.[h|cc]: get_value_for_image().
ChangeLog | 9 +++++++++
Makefile_tests.am | 10 +++++-----
tests/test_selfhosting_new_then_image.cc | 25 +++----------------------
tests/test_utils.cc | 27 +++++++++++++++++++++++++++
tests/test_utils.h | 1 +
5 files changed, 45 insertions(+), 27 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ff48d43..d833363 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-12-13 Murray Cumming <murrayc murrayc com>
+
+ test_selfhosting_new_then_image: Move some code to test_utils.
+
+ * Makefile_tests.am:
+ * tests/test_selfhosting_new_then_image.cc: Move the test image-loading
+ code to:
+ * tests/test_utils.[h|cc]: get_value_for_image().
+
2011-12-12 Murray Cumming <murrayc murrayc com>
LayoutGroup: Correct the get_items_recursive_with_groups() implementaiton.
diff --git a/Makefile_tests.am b/Makefile_tests.am
index 700b550..fdefcf0 100644
--- a/Makefile_tests.am
+++ b/Makefile_tests.am
@@ -107,11 +107,11 @@ glom_libglom_test_sharedptr_layoutitem_CPPFLAGS = $(tests_cppflags)
tests_test_document_load_SOURCES = tests/test_document_load.cc $(sources_test_utils)
tests_test_document_load_LDADD = $(tests_ldadd)
-tests_test_document_load_CPPFLAGS = $(tests_cppflags)
+tests_test_document_load_CPPFLAGS = $(tests_cppflags) $(glom_test_image_defines)
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)
+tests_test_document_load_and_change_CPPFLAGS = $(tests_cppflags) $(glom_test_image_defines)
tests_test_document_load_and_save_SOURCES = tests/test_document_load_and_save.cc
tests_test_document_load_and_save_LDADD = $(tests_ldadd)
@@ -174,7 +174,7 @@ tests_import_test_signals_SOURCES = \
tests_import_test_signals_LDADD = $(tests_ldadd)
tests_import_test_signals_CPPFLAGS = $(tests_cppflags)
-
+# Note that wherever we use this we must also use glom_test_image_defines.
sources_test_utils = tests/test_utils.h \
tests/test_utils.cc
@@ -201,7 +201,7 @@ tests_test_selfhosting_new_then_report_SOURCES = tests/test_selfhosting_new_then
tests_test_selfhosting_new_then_report_LDADD = $(tests_ldadd)
tests_test_selfhosting_new_then_report_CPPFLAGS = $(tests_cppflags)
-tests_test_selfhosting_new_then_image_SOURCES = tests/test_selfhosting_new_then_image.cc $(sources_test_selfhosting_utils)
+tests_test_selfhosting_new_then_image_SOURCES = tests/test_selfhosting_new_then_image.cc $(sources_test_selfhosting_utils) $(sources_test_utils)
tests_test_selfhosting_new_then_image_LDADD = $(tests_ldadd)
tests_test_selfhosting_new_then_image_CPPFLAGS = $(tests_cppflags) $(glom_test_image_defines)
@@ -211,7 +211,7 @@ tests_test_selfhosting_new_then_lookup_CPPFLAGS = $(tests_cppflags)
tests_test_selfhosting_new_then_choices_SOURCES = tests/test_selfhosting_new_then_choices.cc $(sources_test_selfhosting_utils) $(sources_test_utils)
tests_test_selfhosting_new_then_choices_LDADD = $(tests_ldadd)
-tests_test_selfhosting_new_then_choices_CPPFLAGS = $(tests_cppflags)
+tests_test_selfhosting_new_then_choices_CPPFLAGS = $(tests_cppflags) $(glom_test_image_defines)
tests_test_selfhosting_new_then_backup_restore_SOURCES = tests/test_selfhosting_new_then_backup_restore.cc $(sources_test_selfhosting_utils)
tests_test_selfhosting_new_then_backup_restore_LDADD = $(tests_ldadd)
diff --git a/tests/test_selfhosting_new_then_image.cc b/tests/test_selfhosting_new_then_image.cc
index bf0ead2..75192d7 100644
--- a/tests/test_selfhosting_new_then_image.cc
+++ b/tests/test_selfhosting_new_then_image.cc
@@ -19,6 +19,7 @@
*/
#include "tests/test_selfhosting_utils.h"
+#include "tests/test_utils.h"
#include <libglom/init.h>
#include <libglom/utils.h>
#include <libglom/db_utils.h>
@@ -58,28 +59,8 @@ static bool test(Glom::Document::HostingMode hosting_mode)
const Gnome::Gda::SqlExpr where_clause =
Glom::Utils::build_simple_where_expression(table_name, key_field, Gnome::Gda::Value(1));
- //Fill a value from a file:
- const std::string filename =
- Glib::build_filename(GLOM_TESTS_IMAGE_DATA_NOTINSTALLED, "test_image.jpg");
- std::string data;
- try
- {
- data = Glib::file_get_contents(filename);
- }
- catch(const Glib::Error& ex)
- {
- std::cerr << "Failed: file_get_contents() failed: " << ex.what() << std::endl;
- return false; //Something went wrong. It does not exist.
- }
-
- if(data.empty())
- {
- std::cerr << "Failed: The data read from the file was empty. filepath=" << filename << std::endl;
- return false;
- }
-
- //Set the value:
- Gnome::Gda::Value value_set((const guchar*)data.c_str(), data.size());
+ //Set the value, from an image file:
+ const Gnome::Gda::Value value_set = get_value_for_image();
const Glib::RefPtr<const Gnome::Gda::SqlBuilder> builder_set =
Glom::Utils::build_sql_update_with_where_clause(table_name,
field, value_set, where_clause);
diff --git a/tests/test_utils.cc b/tests/test_utils.cc
index ada0ea5..bed1b83 100644
--- a/tests/test_utils.cc
+++ b/tests/test_utils.cc
@@ -19,6 +19,9 @@
*/
#include "tests/test_utils.h"
+#include <glibmm/miscutils.h>
+#include <glibmm/fileutils.h>
+#include <iostream>
Glom::sharedptr<const Glom::LayoutItem_Field> get_field_on_layout(const Glom::Document& document, const Glib::ustring& layout_table_name, const Glib::ustring& table_name, const Glib::ustring& field_name)
{
@@ -51,4 +54,28 @@ Glom::sharedptr<const Glom::LayoutItem_Field> get_field_on_layout(const Glom::Do
return Glom::sharedptr<const Glom::LayoutItem_Field>();
}
+Gnome::Gda::Value get_value_for_image()
+{
+ //Fill a value from a file:
+ const std::string filename =
+ Glib::build_filename(GLOM_TESTS_IMAGE_DATA_NOTINSTALLED, "test_image.jpg");
+ std::string data;
+ try
+ {
+ data = Glib::file_get_contents(filename);
+ }
+ catch(const Glib::Error& ex)
+ {
+ std::cerr << "Failed: file_get_contents() failed: " << ex.what() << std::endl;
+ return Gnome::Gda::Value(); //Something went wrong. It does not exist.
+ }
+ if(data.empty())
+ {
+ std::cerr << "Failed: The data read from the file was empty. filepath=" << filename << std::endl;
+ return Gnome::Gda::Value();
+ }
+
+ //Set the value:
+ return Gnome::Gda::Value((const guchar*)data.c_str(), data.size());
+}
diff --git a/tests/test_utils.h b/tests/test_utils.h
index 8284090..4535b4a 100644
--- a/tests/test_utils.h
+++ b/tests/test_utils.h
@@ -26,6 +26,7 @@
Glom::sharedptr<const Glom::LayoutItem_Field> get_field_on_layout(const Glom::Document& document, const Glib::ustring& layout_table_name, const Glib::ustring& table_name, const Glib::ustring& field_name);
+Gnome::Gda::Value get_value_for_image();
#endif //GLOM_TEST_UTILS_H
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]