Skip to content

Commit

Permalink
Fixed broken test on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyObtiva committed Nov 5, 2020
1 parent e42fdd9 commit b789562
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 50 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Expand Up @@ -4,7 +4,7 @@ Here is a list of tasks to do (moved to [CHANGELOG.md](CHANGELOG.md) once done).

## Next

- Support table default sort configuration via initial_sort_property, initial_sort, or initial_sort_by block
- Support table default sort configuration via initial_sort_property, initial_sort, and initial_sort_by block
- method on shell to indicate if it conatins widget in focus
- Support table editing via `spinner` for integer values
- Support table editing via `date_time` for date/time values
Expand Down
2 changes: 1 addition & 1 deletion lib/glimmer/swt/table_proxy.rb
@@ -1,5 +1,5 @@
# Copyright (c) 2007-2020 Andy Maleh
#
# Copyright (c) 2007-2020 Andy Maleh
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
Expand Down
99 changes: 51 additions & 48 deletions spec/lib/glimmer/dsl/swt/glimmer__table__spec.rb
Expand Up @@ -428,57 +428,60 @@ class ::RedTable
expect(selection.first.getData).to eq(person2)
end

it "triggers table widget editing on selected table item via :editable SWT style" do
@target = shell {
@table = table(:editable) {
table_column {
text "Name"
width 120
}
table_column {
text "Age"
width 120
}
table_column {
text "Adult"
width 120
unless OS.linux?
it "triggers table widget editing on selected table item via :editable SWT style" do
@target = shell {
@table = table(:editable) {
table_column {
text "Name"
width 120
}
table_column {
text "Age"
width 120
}
table_column {
text "Adult"
width 120
}
items bind(group, :people), column_properties(:name, :age, :adult)
selection bind(group, :selected_person)
}
items bind(group, :people), column_properties(:name, :age, :adult)
selection bind(group, :selected_person)
}
}

item_height = @table.swt_widget.items.first.bounds.height

expect(@table.table_editor_widget_proxy).to be_nil
event = Event.new
event.display = @table.swt_widget.getDisplay
event.item = @table.swt_widget.items.first
event.widget = @table.swt_widget
event.type = Glimmer::SWT::SWTProxy[:mouseup]
event.x = 5
event.y = item_height + 15 # skip first item, go to the second item
@table.swt_widget.notifyListeners(Glimmer::SWT::SWTProxy[:mouseup], event)

expect(@table.table_editor_widget_proxy).to_not be_nil
@table.table_editor_widget_proxy.swt_widget.setText('Julie Fan')
# simulate hitting enter to trigger write action
event = Event.new
event.keyCode = Glimmer::SWT::SWTProxy[:cr]
event.doit = true
event.character = "\n"
event.display = @table.table_editor_widget_proxy.swt_widget.getDisplay
event.item = @table.table_editor_widget_proxy.swt_widget
event.widget = @table.table_editor_widget_proxy.swt_widget
event.type = Glimmer::SWT::SWTProxy[:keydown]
@table.table_editor_widget_proxy.swt_widget.notifyListeners(Glimmer::SWT::SWTProxy[:keydown], event)
expect(@table.edit_in_progress?).to eq(false)
expect(person2.name).to eq('Julie Fan')

# test that it maintains selection
selection = @table.swt_widget.getSelection
expect(selection.size).to eq(1)
expect(selection.first.getData).to eq(person2)
item_height = @table.swt_widget.items.first.bounds.height

expect(@table.table_editor_widget_proxy).to be_nil
event = Event.new
event.display = @table.swt_widget.getDisplay
event.item = @table.swt_widget.items.first
event.widget = @table.swt_widget
event.type = Glimmer::SWT::SWTProxy[:mouseup]
event.x = 5
event.y = item_height + 5 # skip first item, go to the second item
@table.swt_widget.notifyListeners(Glimmer::SWT::SWTProxy[:mouseup], event)

expect(@table.table_editor_widget_proxy).to_not be_nil
@table.table_editor_widget_proxy.swt_widget.setText('Julie Fan')
# simulate hitting enter to trigger write action
event = Event.new
event.keyCode = Glimmer::SWT::SWTProxy[:cr]
event.doit = true
event.character = "\n"
event.display = @table.table_editor_widget_proxy.swt_widget.getDisplay
event.item = @table.table_editor_widget_proxy.swt_widget
event.widget = @table.table_editor_widget_proxy.swt_widget
event.type = Glimmer::SWT::SWTProxy[:keydown]
@table.table_editor_widget_proxy.swt_widget.notifyListeners(Glimmer::SWT::SWTProxy[:keydown], event)
expect(@table.edit_in_progress?).to eq(false)

expect(person2.name).to eq('Julie Fan')

# test that it maintains selection
selection = @table.swt_widget.getSelection
expect(selection.size).to eq(1)
expect(selection.first.getData).to eq(person2)
end
end

it "triggers configured column-specific table widget combo editing on specified table item" do
Expand Down

0 comments on commit b789562

Please sign in to comment.