Commit 18d59c94 authored by Murray Cumming's avatar Murray Cumming
Browse files

Added test_imageglom_widget.

parent a53adb0a
......@@ -216,6 +216,9 @@ dist_noinst_DATA = \
tests/import/data/albums.csv \
tests/translations_po/data/test.po \
tests/test_image.jpg \
tests/test_image2.jpg \
tests/test_image.pdf \
tests/test_image2.pdf \
tests/test_example_music_collection_text_pk_fields.glom
# Let the .cc source code know about this path:
......@@ -358,6 +361,7 @@ check_PROGRAMS += \
glom/utility_widgets/eggspreadtablemm/test_spreadtablednd \
glom/test_pyembed \
tests/ui/test_glade_derived_instantiation \
tests/ui/test_imageglom_widget \
tests/ui/glade_toplevels_instantiation \
tests/python/test_python_execute_func \
tests/python/test_python_execute_func_bad_syntax \
......@@ -394,6 +398,7 @@ if GLOM_ENABLE_UI_TESTS
TESTS += \
tests/ui/test_glade_toplevels_instantiation.sh \
tests/ui/test_glade_derived_instantiation \
tests/ui/test_imageglom_widget \
tests/test_glom_date_in_locales.sh \
tests/test_glom_date_in_locales_lc_time.sh
endif #GLOM_ENABLE_UI_TESTS
......@@ -491,6 +496,14 @@ tests_ui_test_glade_derived_instantiation_SOURCES = tests/ui/test_glade_derived_
tests_ui_test_glade_derived_instantiation_LDADD = $(glom_all_libs)
tests_ui_test_glade_derived_instantiation_CPPFLAGS = $(tests_cppflags_ui)
# TODO: Find a subset of glom_source_files that is enough:
tests_ui_test_imageglom_widget_SOURCES = tests/ui/test_imageglom_widget.cc \
$(glom_source_files) \
$(sources_test_utils) \
$(sources_test_utils_images)
tests_ui_test_imageglom_widget_LDADD = $(glom_all_libs)
tests_ui_test_imageglom_widget_CPPFLAGS = $(tests_cppflags_ui) $(glom_test_image_defines)
tests_ui_glade_toplevels_instantiation_SOURCES = tests/ui/glade_toplevels_instantiation.cc
tests_ui_glade_toplevels_instantiation_LDADD = $(tests_ldadd) $(GLOM_LIBS)
tests_ui_glade_toplevels_instantiation_CPPFLAGS = $(tests_cppflags_ui)
......
......@@ -48,11 +48,9 @@ std::shared_ptr<const Glom::LayoutItem_Field> get_field_on_layout(const std::sha
return std::shared_ptr<const Glom::LayoutItem_Field>();
}
Gnome::Gda::Value get_value_for_image()
Gnome::Gda::Value get_value_for_image_from_file(const std::string& filename)
{
//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
{
......@@ -73,3 +71,11 @@ Gnome::Gda::Value get_value_for_image()
//Set the value:
return Gnome::Gda::Value((const guchar*)data.c_str(), data.size());
}
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");
return get_value_for_image_from_file(filename);
}
......@@ -27,6 +27,7 @@
std::shared_ptr<const Glom::LayoutItem_Field> get_field_on_layout(const std::shared_ptr<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();
Gnome::Gda::Value get_value_for_image_from_file(const std::string& filename);
#endif //GLOM_TEST_UTILS_H
/* Glom
*
* Copyright (C) 2016 Murray Cumming
*
* 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
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*/
#include <gtkmm/application.h>
#include <gtkmm/window.h>
#include <glibmm/miscutils.h>
#include <glom/utility_widgets/imageglom.h>
#include "tests/test_utils.h"
#include "tests/test_utils_images.h"
const std::string IMAGE_FILE_JPG1 = "test_image.jpg";
const std::string IMAGE_FILE_JPG2 = "test_image2.jpg";
const std::string IMAGE_FILE_PDF1 = "test_image.pdf";
const std::string IMAGE_FILE_PDF2 = "test_image2.pdf";
auto get_image(const std::string& name)
{
const std::string filename =
Glib::build_filename(GLOM_TESTS_IMAGE_DATA_NOTINSTALLED, name);
return get_value_for_image_from_file(filename);
}
void test_use_jpg()
{
Glom::ImageGlom imageWidget;
imageWidget.set_value(get_image(IMAGE_FILE_JPG1));
}
void test_reset_same_jpg()
{
Glom::ImageGlom imageWidget;
imageWidget.set_value(get_image(IMAGE_FILE_JPG1));
imageWidget.set_value(get_image(IMAGE_FILE_JPG1));
}
void test_changing_jpg()
{
Glom::ImageGlom imageWidget;
imageWidget.set_value(get_image(IMAGE_FILE_JPG1));
imageWidget.set_value(get_image(IMAGE_FILE_JPG2));
imageWidget.set_value(get_image(IMAGE_FILE_JPG1));
}
void test_use_pdf()
{
Glom::ImageGlom imageWidget;
imageWidget.set_value(get_image(IMAGE_FILE_PDF1));
}
void test_reset_same_pdf()
{
Glom::ImageGlom imageWidget;
imageWidget.set_value(get_image(IMAGE_FILE_PDF1));
imageWidget.set_value(get_image(IMAGE_FILE_PDF1));
}
void test_changing_pdf()
{
Glom::ImageGlom imageWidget;
imageWidget.set_value(get_image(IMAGE_FILE_PDF1));
imageWidget.set_value(get_image(IMAGE_FILE_PDF2));
imageWidget.set_value(get_image(IMAGE_FILE_PDF1));
}
void test_changing_from_jpg_to_pdf_to_jpg()
{
Glom::ImageGlom imageWidget;
imageWidget.set_value(get_image(IMAGE_FILE_JPG1));
imageWidget.set_value(get_image(IMAGE_FILE_PDF1));
imageWidget.set_value(get_image(IMAGE_FILE_JPG2));
}
int main(int argc, char *argv[])
{
auto app =
Gtk::Application::create(argc, argv, "org.glom.test_glade_derived_instantiation");
test_use_jpg();
test_reset_same_jpg();
test_changing_jpg();
test_use_pdf();
test_reset_same_pdf();
test_changing_pdf();
test_changing_from_jpg_to_pdf_to_jpg();
return EXIT_SUCCESS;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment