Closed leviwilson closed 11 years ago
Should the Table
class be able to be used for ListBox
controls as well (rather than the ListBox
class)? I noticed that it uses the fruits ListBox
on the main screen for the #strings
test in table_spec.rb
.
Added one comment to your code. I don't understand the second question by you - do you mean if ListBox
should be a subclass of Table
? If that makes sense and there is possible code reuse then yes, why not.
Saw your comment, I fixed that. I didn't realize there was a Control#hwnd method.
As for my question, I was just pointing out that in the #strings
test for table.rb
it uses a ListBox
control rather than a ListView
control. With the changes I have made, you can't wrap a Table
class around a ListBox
as the UIA code expects the HWND
to implement the TablePattern
. I don't think that the Table
control should work with a ListBox
, and was confused that the #strings
spec used it.
it "#strings" do
table = RAutomation::Window.new(:title => "MainFormWindow").table(:id => "FruitListBox")
table.strings.should == ["Apple", "Orange", "Mango"]
end
To be honest, i don't have any opinions on Table#strings, since i haven't been much of involved with MsUia adapter. If you think it's wrong then i would be happily accept a separate pull request with that fix :)
Thanks!
Fact: I should pay more attention and chime in more often.
At first glance your comment on UiaDll::find_children got me worrying that you would change it to only return data items instead of all children of the element but looking at your code this is not the case and all is well.
Regarding the similarity of the Table and ListBox classes, I believe that is due to Table being created way back in the day because Stephan and I needed a class ASAP and so one was pulled from the usual place. ListBox came later, after I had started really trying to understand how the UIA framework worked and named things but before realizing that it and Table were essentially the same thing under the covers.
The table#row_count method for the UIA version of the table class used the
UiaDll::find_children
method to get the row count. This is incorrect as it takes into account the header items, scroll bars, etc. In addition, there was not a test for this in the table_spec.rb. I've added a spec for this as well as fixed therow_count
method as well as theselect
method to use the UIA version.