[glom] Instantiation test: warn if the widget is too big for small screens.



commit 7cc427cd7d3724dcd1b4f63967bc26aaa8fd0d3d
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Sep 30 09:50:31 2011 +0200

    Instantiation test: warn if the widget is too big for small screens.
    
    	* tests/test_glade_derived_instantiation.cc: Actually show the window
    	(Is there a way to get the size without showing it) and warn if it is too
    	big, but do not fail yet.
    	Note that this is very dependent on the theme in use, though maybe we
    	can set that at runtime for the test.

 ChangeLog                                 |   10 ++++++++++
 tests/test_glade_derived_instantiation.cc |   21 ++++++++++++++++++++-
 2 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6566605..81294b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-09-30  Murray Cumming  <murrayc murrayc com>>
+
+	Instantiation test: warn if the widget is too big for small screens.
+
+	* tests/test_glade_derived_instantiation.cc: Actually show the window
+	(Is there a way to get the size without showing it) and warn if it is too 
+	big, but do not fail yet.
+	Note that this is very dependent on the theme in use, though maybe we 
+	can set that at runtime for the test.
+
 2011-09-30  Murray Cumming  <murrayc murrayc com>
 
 	Field Formatting window: Make it slightly less tall.
diff --git a/tests/test_glade_derived_instantiation.cc b/tests/test_glade_derived_instantiation.cc
index d2b065d..928217c 100644
--- a/tests/test_glade_derived_instantiation.cc
+++ b/tests/test_glade_derived_instantiation.cc
@@ -55,6 +55,8 @@
 #include <glom/dialog_progress_creating.h>
 #include <glom/dialog_invalid_data.h>
 
+const int GLOM_MAX_WINDOW_WIDTH = 800;
+const int GLOM_MAX_WINDOW_HEIGHT = 600;
 
 template<class T_Widget>
 bool instantiate_widget()
@@ -68,7 +70,24 @@ bool instantiate_widget()
     exit(EXIT_FAILURE); //Make sure that our test case fails.
     return false;
   }
-
+  
+  //Also check that it is not too big for our target minimum screen size.
+  //Note that this is not testing all .glade files, or all windows (some not using glade),
+  //and doesn't even reliably check all uses of .glade files,
+  //but hopefully it will catch some problems:
+  widget->show();
+  const Gtk::Allocation allocation = widget->get_allocation();
+ 
+  if( (allocation.get_height() > GLOM_MAX_WINDOW_HEIGHT) ||
+    (allocation.get_width() > GLOM_MAX_WINDOW_WIDTH))
+  {
+    std::cerr << "Test: The window/widget is too big: " << T_Widget::glade_id << std::endl;
+    std::cerr << "  height=" << allocation.get_height() << std::endl; 
+    std::cerr << "  width=" << allocation.get_width() << std::endl;
+    std::cerr << "  (Ignored, though it should be fixed.)" << std::endl; 
+    //TODO: Uncomment this when all the windows are small enough: exit(EXIT_FAILURE); //Make sure that our test case fails.
+  }
+  
   delete widget;
   return true;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]