Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » RCP Testing Tool » Setting value of checkbox editor in wizard table doesn't work
Setting value of checkbox editor in wizard table doesn't work [message #1777430] Wed, 29 November 2017 11:01 Go to next message
Stephan Druskat is currently offline Stephan DruskatFriend
Messages: 102
Registered: October 2011
Location: Berlin, Germany
Senior Member

I have a simple wizard page with the following table:

tableViewer = new TableViewer(tableComposite, SWT.BORDER | SWT.FULL_SELECTION);

tableViewerColumn.setEditingSupport(new EditingSupport(tableViewer) {
			TextCellEditor textCellEditor = null;
			CheckboxCellEditor boolCellEditor = null;

			@Override
			protected boolean canEdit(Object element) {
				return true;
			}

			@Override
			protected CellEditor getCellEditor(Object element) {
				Object value = getValue(element);
				if (value instanceof String) {
					if (textCellEditor == null) {
						textCellEditor = new TextCellEditor((Composite) tableViewer.getControl());
					}
					return textCellEditor;
				}
				else if (value instanceof Boolean) {
					if (boolCellEditor == null) {
						boolCellEditor = new CheckboxCellEditor((Composite) tableViewer.getControl(),
								SWT.CHECK | SWT.READ_ONLY);
					}
					return boolCellEditor;
				}
				else {
					if (textCellEditor == null) {
						textCellEditor = new TextCellEditor((Composite) tableViewer.getControl());
					}
					return textCellEditor;
				}
			}

			@SuppressWarnings("unchecked")
			@Override
			protected void setValue(Object element, Object value) {
				if (value instanceof String) {
					((MyProperty<?>) element).setValueString(value != null ? value.toString() : null);
				}
				else if (value instanceof Boolean) {
					((MyProperty<Boolean>) element).setValue(value != null ? (Boolean) value : null);
				}
				tableViewer.refresh(element, true);

			}

			@Override
			protected Object getValue(Object element) {
				return ((MyProperty<?>) element).getValue();
			}
		});


One of the table items has a boolean value which is set to false per default.

I'm recording the test, and during the recording click the table cell once to set the value to true. This works fine during the test recording! The logic triggered by the true setting is triggered.

However, when I replay the test, the respective logic is not triggered.

I have tried to insert an assertion, but am unsure which value I need to test for. I have tried the following, which will always let the test fail, although the setting during the recording was true!

get-view Navigation | get-tree | get-menu -path "Import..." | click
with [get-window Import] {
    get-tree | select "My Import"
    get-button "Next >" | click
}

get-window "My Import" | get-table | select "do.something" | double-click
with [get-window "My Import" | get-table] {
    select "do.something"
    get-cell 5 1 | check
}
get-window "My Import" | get-table | get-item -path "do.something" | get-property "columns[1]" 
    | equals true | verify-true
with [get-window "My Import"] {
    get-button "Next >" | click
    get-editbox -after [get-label "Project name; must be unique"] | set-text "simple-project"
    get-button Finish | click
}


If anyone knows how to reliably set the value of the table item in a CheckboxCellEditor to true during an RCPTT test, I'd be very thankful!
Re: Setting value of checkbox editor in wizard table doesn't work [message #1777435 is a reply to message #1777430] Wed, 29 November 2017 11:34 Go to previous message
Stephan Druskat is currently offline Stephan DruskatFriend
Messages: 102
Registered: October 2011
Location: Berlin, Germany
Senior Member

The solution is to activate cell editing before checking the cell value:

get-window "My Import" | get-table | select "do.something" | double-click
with [get-window "My Import" | get-table] {
    select "do.something"
       get-cell 5 1 | activate-cell-edit | check
}
Previous Topic:RCPTT Testing tool startup failure
Next Topic:Scriptlet ReadExcelFile not found at read-excel-file
Goto Forum:
  


Current Time: Fri Jun 22 03:50:25 GMT 2018

Powered by FUDForum. Page generated in 0.02494 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top