[glom] LDTP: Reopen documents after creation, also test new, empty documents



commit 4979a3bf33636f020e75c12b1397be2814b79dac
Author: Armin Burgmeier <armin arbur net>
Date:   Fri Jun 26 14:08:50 2009 +0200

    LDTP: Reopen documents after creation, also test new, empty documents
    
    	* glom/dialog_glom.h:
    	* glom/dialog_glom.cc: Added an optional second parameter to the
    	constructor, to specify a title name for the dialog.
    
    	* glom/frame_glom.cc: Set the title of the tables dialog to "Tables",
    	so that it can be accessed via LDTP.
    
    	* glom/glom.glade: Also change the title of that dialog, even though
    	it's not used, since only the window's child widget is loaded from the
    	glade file.
    
    	* glom/utility_widgets/adddel/adddel.h:
    	* glom/utility_widgets/adddel/adddel.cc: Added a
    	set_treeview_accessible_name() function, to set the accessible name of
    	the AddDel's TreeView.
    
    	* glom/navigation/box_tables.cc: Set an accessible name for the
    	TreeView, to be able to access it via LDTP.
    
    	* glom/utility_widgets/filechooserdialog_saveextras.cc: Set an
    	accessible name for the database title text entry.
    
    	* ldtp/common.py (select_backend): Added a dialog_title parameter, as
    	the dialog has a different title when creating a new, empty document.
    	(wait_for_database_open): Rely on the database title being 'Test', not
    	'Small Business Example'.
    
    	* ldtp/database-creation/create-db.py: Change the database title of
    	the newly created database to 'Test'. Support creating new, empty
    	documents, and reopen the document after it has been closed, to make
    	sure the document has been saved correctly.
    
    	* ldtp/database-creation/postgres-central-example.xml:
    	* ldtp/database-creation/postgres-self-example.xml:
    	* ldtp/database-creation/sqlite-example.xml: Moved from the files
    	without -example, set the <example> tag to 1.
    
    	* ldtp/database-creation/postgres-central-example.xml:
    	* ldtp/database-creation/postgres-self-example.xml:
    	* ldtp/database-creation/sqlite-example.xml: Same with <example> set
    	to 0.
    
    	* ldtp/test.xml: Added the three new files which create an empty
    	document instead of creating one from the Small Business Example.

 ChangeLog                                          |   47 ++++++++++++
 glom/dialog_glom.cc                                |    5 +-
 glom/dialog_glom.h                                 |    2 +-
 glom/frame_glom.cc                                 |    2 +-
 glom/glom.glade                                    |    2 +-
 glom/navigation/box_tables.cc                      |    3 +
 glom/utility_widgets/adddel/adddel.cc              |    5 ++
 glom/utility_widgets/adddel/adddel.h               |    3 +
 .../filechooserdialog_saveextras.cc                |    1 +
 ldtp/common.py                                     |   10 ++--
 ldtp/database-creation/create-db.py                |   74 +++++++++++++++++---
 ...es-central.xml => postgres-central-example.xml} |    1 +
 ...postgres-self.xml => postgres-self-example.xml} |    1 +
 ldtp/database-creation/sqlite-example.xml          |    4 +
 ldtp/database-creation/sqlite.xml                  |    3 -
 ldtp/test.xml                                      |   20 +++++-
 16 files changed, 157 insertions(+), 26 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7fd17fd..ea77bd6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,50 @@
+2009-06-26  Armin Burgmeier  <armin openismus com>
+
+	* glom/dialog_glom.h:
+	* glom/dialog_glom.cc: Added an optional second parameter to the
+	constructor, to specify a title name for the dialog.
+
+	* glom/frame_glom.cc: Set the title of the tables dialog to "Tables",
+	so that it can be accessed via LDTP.
+
+	* glom/glom.glade: Also change the title of that dialog, even though
+	it's not used, since only the window's child widget is loaded from the
+	glade file.
+
+	* glom/utility_widgets/adddel/adddel.h:
+	* glom/utility_widgets/adddel/adddel.cc: Added a
+	set_treeview_accessible_name() function, to set the accessible name of
+	the AddDel's TreeView.
+
+	* glom/navigation/box_tables.cc: Set an accessible name for the
+	TreeView, to be able to access it via LDTP.
+
+	* glom/utility_widgets/filechooserdialog_saveextras.cc: Set an
+	accessible name for the database title text entry.
+
+	* ldtp/common.py (select_backend): Added a dialog_title parameter, as
+	the dialog has a different title when creating a new, empty document.
+	(wait_for_database_open): Rely on the database title being 'Test', not
+	'Small Business Example'.
+
+	* ldtp/database-creation/create-db.py: Change the database title of
+	the newly created database to 'Test'. Support creating new, empty
+	documents, and reopen the document after it has been closed, to make
+	sure the document has been saved correctly.
+
+	* ldtp/database-creation/postgres-central-example.xml:
+	* ldtp/database-creation/postgres-self-example.xml:
+	* ldtp/database-creation/sqlite-example.xml: Moved from the files
+	without -example, set the <example> tag to 1.
+
+	* ldtp/database-creation/postgres-central-example.xml:
+	* ldtp/database-creation/postgres-self-example.xml:
+	* ldtp/database-creation/sqlite-example.xml: Same with <example> set
+	to 0.
+
+	* ldtp/test.xml: Added the three new files which create an empty
+	document instead of creating one from the Small Business Example.
+
 2009-06-24  Armin Burgmeier  <armin openismus com>
 
 	* ldtp/common.py: Work around bug #586291, added a function to enter
diff --git a/glom/dialog_glom.cc b/glom/dialog_glom.cc
index 6449e95..b3b7a4d 100644
--- a/glom/dialog_glom.cc
+++ b/glom/dialog_glom.cc
@@ -24,8 +24,11 @@
 namespace Glom
 {
 
-Dialog_Glom::Dialog_Glom(Box_WithButtons* pBox)
+Dialog_Glom::Dialog_Glom(Box_WithButtons* pBox, const Glib::ustring& title)
 {
+  if(!title.empty())
+    set_title(title);
+
   set_border_width(Utils::DEFAULT_SPACING_SMALL);
 
   m_pBox = pBox;
diff --git a/glom/dialog_glom.h b/glom/dialog_glom.h
index 60e9c5d..c425727 100644
--- a/glom/dialog_glom.h
+++ b/glom/dialog_glom.h
@@ -32,7 +32,7 @@ class Dialog_Glom :
   public Gtk::Dialog
 {
 public: 
-  Dialog_Glom(Box_WithButtons* pBox);
+  Dialog_Glom(Box_WithButtons* pBox, const Glib::ustring& title = Glib::ustring());
   virtual ~Dialog_Glom();
 
   //Signal handlers:
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index df5a699..1a90e80 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -1263,7 +1263,7 @@ void Frame_Glom::do_menu_Navigate_Table(bool open_default)
   if(!m_pBox_Tables)
   {
     Utils::get_glade_widget_derived_with_warning("box_navigation_tables", m_pBox_Tables);
-    m_pDialog_Tables = new Dialog_Glom(m_pBox_Tables);
+    m_pDialog_Tables = new Dialog_Glom(m_pBox_Tables, _("Tables"));
     m_pDialog_Tables->signal_hide().connect(sigc::mem_fun(*this, &Frame_Glom::on_dialog_tables_hide));
 
     Gtk::Window* pWindow = get_app_window();
diff --git a/glom/glom.glade b/glom/glom.glade
index 4f15383..1db7c1a 100644
--- a/glom/glom.glade
+++ b/glom/glom.glade
@@ -4,7 +4,7 @@
   <!-- interface-naming-policy toplevel-contextual -->
   <object class="GtkWindow" id="window_tables">
     <property name="border_width">12</property>
-    <property name="title" translatable="yes">window1</property>
+    <property name="title" translatable="yes">Tables</property>
     <child>
       <object class="GtkVBox" id="box_navigation_tables">
         <property name="visible">True</property>
diff --git a/glom/navigation/box_tables.cc b/glom/navigation/box_tables.cc
index 05519e1..54ef6d7 100644
--- a/glom/navigation/box_tables.cc
+++ b/glom/navigation/box_tables.cc
@@ -40,6 +40,9 @@ Box_Tables::Box_Tables(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
   builder->get_widget("button_cancel", pButtonCancel);
   set_button_cancel(*pButtonCancel);
 
+  // Set a name for the AddDel TreeView, so it can be accessed by LDTP
+  m_AddDel.set_treeview_accessible_name("Tables");
+
   Gtk::Alignment* pAligmentPlaceholder = 0;
   builder->get_widget("alignment_placeholder_adddel", pAligmentPlaceholder);
   pAligmentPlaceholder->add(m_AddDel);
diff --git a/glom/utility_widgets/adddel/adddel.cc b/glom/utility_widgets/adddel/adddel.cc
index 70fd7c0..dc0a14f 100644
--- a/glom/utility_widgets/adddel/adddel.cc
+++ b/glom/utility_widgets/adddel/adddel.cc
@@ -144,6 +144,11 @@ AddDel::~AddDel()
 {
 }
 
+void AddDel::set_treeview_accessible_name(const Glib::ustring& name)
+{
+  m_TreeView.get_accessible()->set_name(name);
+}
+
 void AddDel::warn_about_duplicate()
 {
   Glib::ustring message;
diff --git a/glom/utility_widgets/adddel/adddel.h b/glom/utility_widgets/adddel/adddel.h
index ef8e900..a077cd0 100644
--- a/glom/utility_widgets/adddel/adddel.h
+++ b/glom/utility_widgets/adddel/adddel.h
@@ -72,6 +72,9 @@ public:
   AddDel(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder);
   virtual ~AddDel();
 
+  // Set the accessible name for the TreeView widget
+  void set_treeview_accessible_name(const Glib::ustring& name);
+
   void set_allow_user_actions(bool bVal = true);
   bool get_allow_user_actions() const;
 
diff --git a/glom/utility_widgets/filechooserdialog_saveextras.cc b/glom/utility_widgets/filechooserdialog_saveextras.cc
index 3855885..4c0901a 100644
--- a/glom/utility_widgets/filechooserdialog_saveextras.cc
+++ b/glom/utility_widgets/filechooserdialog_saveextras.cc
@@ -95,6 +95,7 @@ void FileChooserDialog_SaveExtras::create_child_widgets()
   box_label->pack_start(*label_title, Gtk::PACK_SHRINK);
   label_title->show();
   box_label->pack_start(m_entry_title);
+  m_entry_title.get_accessible()->set_name(_("Title"));
   m_entry_title.show();
   box_label->show();
   vbox->pack_start(*box_label);
diff --git a/ldtp/common.py b/ldtp/common.py
index 8edb8d0..7d1078e 100644
--- a/ldtp/common.py
+++ b/ldtp/common.py
@@ -39,7 +39,7 @@ def launch_glom():
 def exit_glom():
 	ldtp.selectmenuitem(main_window, 'mnuFile;mnuClose')
 
-	if ldtp.waittillguinotexist('Glom-SmallBusinessExample') == 0:
+	if ldtp.waittillguinotexist('*Glom*') == 0:
 		raise ldtp.LdtpExecutionError('The Glom Window does not disappear after closing the application')
 
 # Reads hostname, username and password to use for access to a
@@ -78,15 +78,15 @@ def enter_connection_credentials(backend_name):
 			raise ldtp.LdtpExecutionError('Connection details dialog does not disappear')
 
 # Selects one of the backends in button_texts in the database creation dialog
-def select_backend(backend_name):
+def select_backend(dialog_title, backend_name):
 	try:
 		button_texts = backend_create_db_button_texts[backend_name]
 	except KeyError:
 		raise ldtp.LdtpExecutionError('Backend "' + backend + '" does not exist')
 
 	for text in button_texts:
-		if ldtp.objectexist('Creating From Example File', 'rbtn' + text):
-			ldtp.click('Creating From Example File', 'rbtn' + text)
+		if ldtp.objectexist(dialog_title, 'rbtn' + text):
+			ldtp.click(dialog_title, 'rbtn' + text)
 			break
 	else:
 		raise ldtp.LdtpExecutionError('Backend "' + backend + '" not supported')
@@ -100,7 +100,7 @@ def wait_for_database_open():
 	# TODO: Maybe we can use setcontext(), to avoid this.
 	# TODO: Or maybe this has been fixed in LDTP in the meanwhile,
 	# see bug #583021.
-	while not ldtp.guiexist('Glom-SmallBusinessExample') or not ldtp.objectexist('Glom-SmallBusinessExample', 'ptlListOrDetailsView'):
+	while not ldtp.guiexist('Glom-Test') or not ldtp.objectexist('Glom-Test', 'ptlListOrDetailsView'):
 		# onwindowcreate calls the callback in a new thread, which
 		# does not really help us since we don't have a mainloop the
 		# callback thread could notify, so we would need to have to
diff --git a/ldtp/database-creation/create-db.py b/ldtp/database-creation/create-db.py
index d846056..00c0d46 100755
--- a/ldtp/database-creation/create-db.py
+++ b/ldtp/database-creation/create-db.py
@@ -47,6 +47,7 @@ def delete_database(backend):
 try:
 	parser = LdtpDataFileParser(datafilename)
 	backend = parser.gettagvalue('backend')[0]
+	example = int(parser.gettagvalue('example')[0])
 
 	common.launch_glom()
 
@@ -61,7 +62,10 @@ try:
 	# believe) prefix, for example notebooks are prefixed by 'ptl' and
 	# treeviews are prefixed by 'ttbl'.
 	selecttab(common.initial_dialog, 'ptlOpenorcreateDocument', 'Create New Document')
-	selectrow(common.initial_dialog, 'ttblCreateNewDocument', 'Small Business Example')
+	if example:
+		selectrow(common.initial_dialog, 'ttblCreateNewDocument', 'Small Business Example')
+	else:
+		selectrow(common.initial_dialog, 'ttblCreateNewDocument', 'New Empty Document')
 
 	# Buttons (prefix: 'btn') are addressed via their label text:
 	click(common.initial_dialog, 'btnSelect')
@@ -70,35 +74,83 @@ try:
 	if not os.path.exists('TestDatabase'):
 		os.mkdir('TestDatabase')
 
+	# The file chooser dialog has a different title depending on whether
+	# we create an empty document, or an example document.
+	creation_dialog = ''
+	if example:
+		creation_dialog = 'Creating From Example File'
+	else:
+		creation_dialog = 'Save Document'
+
 	# Wait for the file chooser dialog to appear:
-	if waittillguiexist('Creating From Example File') == 0:
+	if waittillguiexist(creation_dialog) == 0:
 		raise LdtpExecutionError('File chooser does not show up')
 
 	# Navigate into the newly created folder:
-	doubleclickrow('Creating From Example File', 'tblFiles', 'TestDatabase')
+	doubleclickrow(creation_dialog, 'tblFiles', 'TestDatabase')
 
-	# Call the new document 'Test':
-	settextvalue('Creating From Example File', 'txtName', 'Test');
+	# Call the new document 'Test', and save it as 'Test.glom':
+	settextvalue(creation_dialog, 'txtName', 'Test');
+	settextvalue(creation_dialog, 'txtTitle', 'Test');
 
 	# Make sure we use the correct backend:
-	common.select_backend(backend)
+	common.select_backend(creation_dialog, backend)
 
 	# Acknowledge the dialog:
-	click('Creating From Example File', 'btnSave')
+	click(creation_dialog, 'btnSave')
+
+	# Enter the connection credentials for the centrally hosted database
+	common.enter_connection_credentials(backend)
+
+	if not example:
+		# Wait for the Tables dialog to appear
+		if waittillguiexist('Tables') == 0:
+			raise LdtpExecutionError('Tables dialog does not appear')
+
+		# Create an initial table
+		click('Tables', 'Add')
+		# This does not seem to work here, I'm not sure why.
+		# getcellvalue works.
+		#setcellvalue('Tables', 'tblTables', 0, 0, 'TestTable')
+		generatekeyevent('TestTable<enter>')
+		click('Tables', 'Close')
+
+		common.wait_for_database_open()
+	else:
+		# Wait until the database has been created:
+		common.wait_for_database_open()
+		# Check that the example database has been loaded correctly:
+		common.check_small_business_integrity()
+
+	# Exit the application.
+	common.exit_glom()
+
+	# Now, open the newly created database, making sure the document was
+	# saved correctly and we can open it:
+	common.launch_glom()
+
+	# It should be in the Recent document list in the recently
+	# used documents:
+	selectrow(common.initial_dialog, 'ttblOpenExistingDocument', 'Test.glom')
+
+	# Buttons (prefix: 'btn') are addressed via their label text:
+	click(common.initial_dialog, 'btnSelect')
 
 	# Enter the connection credentials for the centrally hosted database
 	common.enter_connection_credentials(backend)
 
-	# Wait until the database has been created:
+	# Wait until the database has been opened:
 	common.wait_for_database_open()
 
-	# Everything finished, so check the created database for consistency.
-	common.check_small_business_integrity()
+	# Everything finished, check that no information has been lost in
+	# the database:
+	if example:
+		common.check_small_business_integrity()
 
 	# Exit the application.
 	common.exit_glom()
 
-	# Wait until Glom has cleaned up everything, so that removing the 
+	# Wait until Glom has cleaned up everything, so that removing the
 	# test database is going to work.
 	wait(2)
 
diff --git a/ldtp/database-creation/postgres-central.xml b/ldtp/database-creation/postgres-central-example.xml
similarity index 69%
rename from ldtp/database-creation/postgres-central.xml
rename to ldtp/database-creation/postgres-central-example.xml
index 97f2938..3e8d07b 100644
--- a/ldtp/database-creation/postgres-central.xml
+++ b/ldtp/database-creation/postgres-central-example.xml
@@ -1,3 +1,4 @@
 <data>
 	<backend>PostgresCentral</backend>
+	<example>1</example>
 </data>
diff --git a/ldtp/database-creation/postgres-self.xml b/ldtp/database-creation/postgres-self-example.xml
similarity index 68%
rename from ldtp/database-creation/postgres-self.xml
rename to ldtp/database-creation/postgres-self-example.xml
index 6d7c7e7..d8e842e 100644
--- a/ldtp/database-creation/postgres-self.xml
+++ b/ldtp/database-creation/postgres-self-example.xml
@@ -1,3 +1,4 @@
 <data>
 	<backend>PostgresSelf</backend>
+	<example>1</example>
 </data>
diff --git a/ldtp/database-creation/sqlite-example.xml b/ldtp/database-creation/sqlite-example.xml
new file mode 100644
index 0000000..53bdc2b
--- /dev/null
+++ b/ldtp/database-creation/sqlite-example.xml
@@ -0,0 +1,4 @@
+<data>
+	<backend>SQLite</backend>
+	<example>1</example>
+</data>
diff --git a/ldtp/test.xml b/ldtp/test.xml
index 201ff8f..fd189cf 100644
--- a/ldtp/test.xml
+++ b/ldtp/test.xml
@@ -5,17 +5,31 @@
 	<group>
 		<testcaseid>database-creation</testcaseid>
 		<comment>Test whether creation of a new database work for all available backends</comment>
+
+		<script>
+			<name>database-creation/create-db.py</name>
+			<data>database-creation/postgres-self-empty.xml</data>
+		</script>
+		<script>
+			<name>database-creation/create-db.py</name>
+			<data>database-creation/postgres-central-empty.xml</data>
+		</script>
+		<script>
+			<name>database-creation/create-db.py</name>
+			<data>database-creation/sqlite-empty.xml</data>
+		</script>
+
 		<script>
 			<name>database-creation/create-db.py</name>
-			<data>database-creation/postgres-self.xml</data>
+			<data>database-creation/postgres-self-example.xml</data>
 		</script>
 		<script>
 			<name>database-creation/create-db.py</name>
-			<data>database-creation/postgres-central.xml</data>
+			<data>database-creation/postgres-central-example.xml</data>
 		</script>
 		<script>
 			<name>database-creation/create-db.py</name>
-			<data>database-creation/sqlite.xml</data>
+			<data>database-creation/sqlite-example.xml</data>
 		</script>
 	</group>
 



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