Difference between revisions of "QA/vclauto/A step by step example"

From Apache OpenOffice Wiki
< QA‎ | vclauto
Jump to: navigation, search
(Step to Add the Database Test Case)
m (Step to Add the Database Test Case)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
 
== Scenario of Test Case ==
 
== Scenario of Test Case ==
To add a test case about creating a embedded database.<br />
+
To add a test case about creating a embedded database file.<br />
1.Start the openoffice.<br />
+
1.Start OpenOffice.<br />
2.From the open window, new a Database.<br />
+
2.From the opened window, new Database.<br />
3.In the pop up “Database wizard” dialog, step 1(Select database), keep default setting(Create a new database), click “next”.<br />
+
3.In the pop up “Database wizard” dialog, step 1 (Select database), keep default setting (Create a new database), click “next”.<br />
4.In step 2(Save and proceed), keep default setting(Yes, register the database for me. Open the database for editing). Click “Finish”.<br />
+
4.In step 2 (Save and proceed), keep default setting(Yes, register the database for me. Open the database for editing). Click “Finish”.<br />
 
5.In the pop up “Save as” dialog, input a name for the new database. Click “Save”.<br />
 
5.In the pop up “Save as” dialog, input a name for the new database. Click “Save”.<br />
 
6.Check if the database is created successfully. The status bar is “Embedded database”.<br />
 
6.Check if the database is created successfully. The status bar is “Embedded database”.<br />
Line 13: Line 12:
 
2.Add method @Rule, @Before, @AfterClass to the class. You can refer to the BVTFileType.java. About the meaning of @Rule, @Before, @AfterClass, you can refer to JUnit.<br />
 
2.Add method @Rule, @Before, @AfterClass to the class. You can refer to the BVTFileType.java. About the meaning of @Rule, @Before, @AfterClass, you can refer to JUnit.<br />
 
3.Add method @Test, which is the key method.<br />
 
3.Add method @Test, which is the key method.<br />
* Step 1 of test scenario: start the openoffice. This step is realized by “setUp” method, namely in annotation @Before.
+
* Step 1 of test scenario: start OpenOffice. This step is implemented by “setUp” method, namely in annotation @Before.
* Step 2: new a Database. You can new a database from the main menu of the open window. So you have to get the control ID of open window. Use test assistant to inspect open window. See following screenshot. From the screenshot we can see the open window is already defined with the name “startcenter”. So we can directly use it like this:
+
 
<source lang="bash">
+
* Step 2: new a Database. You can select a new database from the main menu of the open window. So you have to get the control ID of open window. Use test assistant to inspect open window. See following screenshot.<br />
 +
Make sure you drag the gray circle to the control and then release the button, rather than just click the gray circle.<br />
 +
From the screenshot we can see the open window is already defined with the name “startcenter”. So we can directly use it like this:
 +
<syntaxhighlight lang="bash">
 
startcenter.menuItem("File->New->Database").select();
 
startcenter.menuItem("File->New->Database").select();
</source>
+
</syntaxhighlight>
[[File:startcenter_new_database.png]]<br />
+
[[File:startcenter_new_database.png|800px]]<br />
* Step 3. After above operations, “Database wizard” dialog will pop up. In this dialog “Next” button is not defined yet. So you should find the ID of “Next” button in Vcl Explorer dialog, which is DBACCESS_HID_DBWIZ_NEXT. See following screenshot. <br />
+
 
[[File:new_database_next.png]]<br />
+
* Step 3. After above operations, “Database wizard” dialog will pop up. In this dialog “Next” button is not defined yet. So you should find the ID of “Next” button in VCL Explorer dialog, which is DBACCESS_HID_DBWIZ_NEXT. See following screenshot. <br />
Doubld click empty “Name” area of this control, and input a name into it, then press “Enter”. Then you will find a UI control defined automatically in the last line of UIMap.java.(%EclipseWorkspaceDir%\test\testscript\src\testlib\UIMap.java). See screenshot.<br />
+
[[File:new_database_next.png|800px]]<br />
[[File:new_database_addbutton.png]]
+
Double-click empty “Name” area of this control, and input a name into it, then press “Enter”. Then you will find a UI control defined automatically in the last line of UIMap.java.(%EclipseWorkspaceDir%\test\testscript\src\testlib\UIMap.java). See screenshot.<br />
 +
[[File:new_database_addbutton.png|800px]]
 +
 
 
* Step 4. Use the same way to add “Finish” button definition.
 
* Step 4. Use the same way to add “Finish” button definition.
[[File:new_database_addfinishbutton.png]]
+
[[File:new_database_addfinishbutton.png|800px]]
 +
 
 
* Step 5: Input a name to “Save as” dialog. Because this operation is completed by AppUtil.java, you can directly use following codes.
 
* Step 5: Input a name to “Save as” dialog. Because this operation is completed by AppUtil.java, you can directly use following codes.
<source lang="bash">
+
<syntaxhighlight lang="bash">
 
FileUtil.deleteFile(saveTo);
 
FileUtil.deleteFile(saveTo);
 
submitSaveDlg(saveTo);
 
submitSaveDlg(saveTo);
</source>
+
</syntaxhighlight>
 +
 
 
* Step 6. The last step is to check whether the database is created successfully. You can check the status bar. Status bar is already defined, you can directly use it.
 
* Step 6. The last step is to check whether the database is created successfully. You can check the status bar. Status bar is already defined, you can directly use it.
[[File:new_database_statusbar.png]]
+
[[File:new_database_statusbar.png|800px]]<br />
 +
 
 
So finally the codes are below.
 
So finally the codes are below.
<source lang="bash">
+
<syntaxhighlight lang="bash">
 
/**
 
/**
 
  * Test New/Save a database
 
  * Test New/Save a database
Line 55: Line 62:
 
     assertEquals("Embedded database", StatusBar.getItemText(0));
 
     assertEquals("Embedded database", StatusBar.getItemText(0));
 
}
 
}
</source>
+
</syntaxhighlight>
 +
 
 +
[[Category:Quality Assurance]]

Latest revision as of 15:17, 25 October 2021

Scenario of Test Case

To add a test case about creating a embedded database file.
1.Start OpenOffice.
2.From the opened window, new Database.
3.In the pop up “Database wizard” dialog, step 1 (Select database), keep default setting (Create a new database), click “next”.
4.In step 2 (Save and proceed), keep default setting(Yes, register the database for me. Open the database for editing). Click “Finish”.
5.In the pop up “Save as” dialog, input a name for the new database. Click “Save”.
6.Check if the database is created successfully. The status bar is “Embedded database”.

Step to Add the Database Test Case

1.New a java class, say BVTDatabase.java.
2.Add method @Rule, @Before, @AfterClass to the class. You can refer to the BVTFileType.java. About the meaning of @Rule, @Before, @AfterClass, you can refer to JUnit.
3.Add method @Test, which is the key method.

  • Step 1 of test scenario: start OpenOffice. This step is implemented by “setUp” method, namely in annotation @Before.
  • Step 2: new a Database. You can select a new database from the main menu of the open window. So you have to get the control ID of open window. Use test assistant to inspect open window. See following screenshot.

Make sure you drag the gray circle to the control and then release the button, rather than just click the gray circle.
From the screenshot we can see the open window is already defined with the name “startcenter”. So we can directly use it like this:

startcenter.menuItem("File->New->Database").select();

Startcenter new database.png

  • Step 3. After above operations, “Database wizard” dialog will pop up. In this dialog “Next” button is not defined yet. So you should find the ID of “Next” button in VCL Explorer dialog, which is DBACCESS_HID_DBWIZ_NEXT. See following screenshot.

New database next.png
Double-click empty “Name” area of this control, and input a name into it, then press “Enter”. Then you will find a UI control defined automatically in the last line of UIMap.java.(%EclipseWorkspaceDir%\test\testscript\src\testlib\UIMap.java). See screenshot.
New database addbutton.png

  • Step 4. Use the same way to add “Finish” button definition.

New database addfinishbutton.png

  • Step 5: Input a name to “Save as” dialog. Because this operation is completed by AppUtil.java, you can directly use following codes.
FileUtil.deleteFile(saveTo);
submitSaveDlg(saveTo);
  • Step 6. The last step is to check whether the database is created successfully. You can check the status bar. Status bar is already defined, you can directly use it.

New database statusbar.png

So finally the codes are below.

/**
 * Test New/Save a database
 * @throws Exception
 */
@Test
public void testBVTDatabase() throws Exception {
    String saveTo = fullPath("temp/" + "EmbeddedDatabase.odb");
    //Create a new database
    startcenter.menuItem("File->New->Database").select();
 
    // Database wizard dialog, use default setting
    Database_NewWizard_Next.click();
    Database_NewWizard_Finish.click();
 
    // Input database name to be saved
    FileUtil.deleteFile(saveTo);
    submitSaveDlg(saveTo);	
 
    // Check the statusbar to verify if database is created successfully
    assertEquals("Embedded database", StatusBar.getItemText(0));
}
Personal tools