QA/vclauto/A step by step example

From Apache OpenOffice Wiki
< QA‎ | vclauto
Revision as of 15:17, 25 October 2021 by DiGro (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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
2.Add method @Rule, @Before, @AfterClass to the class. You can refer to the 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 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\test\testscript\src\testlib\ 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, you can directly use following codes.
  • 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
public void testBVTDatabase() throws Exception {
    String saveTo = fullPath("temp/" + "EmbeddedDatabase.odb");
    //Create a new database
    // Database wizard dialog, use default setting;;
    // Input database name to be saved
    // Check the statusbar to verify if database is created successfully
    assertEquals("Embedded database", StatusBar.getItemText(0));
Personal tools