Permalink
Browse files

Make more features pass.

  • Loading branch information...
1 parent a790e17 commit 804a36d4ccb28473e7a30d1b80e4a4c8b1d2be89 @danlucraft committed Oct 31, 2011
Showing with 519 additions and 317 deletions.
  1. +22 −0 env.rb
  2. +4 −4 lib/redcar_quick_start.rb
  3. +8 −7 plugins/application/features/step_definitions/command_steps.rb
  4. +28 −16 plugins/application/features/step_definitions/speedbar_steps.rb
  5. +75 −9 plugins/application/features/support/env.rb
  6. +7 −7 plugins/auto_completer/features/auto_complete.feature
  7. +3 −1 plugins/auto_completer/features/step_definitions/auto_complete_steps.rb
  8. 0 plugins/auto_completer/features/step_definitions/dependency_steps.rb
  9. +5 −3 plugins/auto_indenter/features/java_style_indentation.feature
  10. +13 −13 plugins/auto_indenter/features/ruby_style_indentation.feature
  11. +3 −1 plugins/auto_indenter/features/step_definitions/indentation_steps.rb
  12. +1 −1 plugins/auto_pairer/features/auto_pairer.feature
  13. +31 −26 plugins/comment/features/line_comment.feature
  14. +1 −1 plugins/comment/features/selection_comment.feature
  15. +6 −2 plugins/comment/features/step_definitions/comment_steps.rb
  16. +39 −39 plugins/document_search/features/find.feature
  17. +6 −2 plugins/document_search/features/step_definitions/find_steps.rb
  18. +48 −48 plugins/edit_view/features/multiple_windows.feature
  19. +0 −4 plugins/edit_view/features/step_definitions/application_steps.rb
  20. 0 plugins/edit_view/features/step_definitions/dependency_steps.rb
  21. +97 −45 plugins/edit_view/features/step_definitions/editing_steps.rb
  22. +35 −21 plugins/edit_view/features/step_definitions/notebook_steps.rb
  23. +71 −53 plugins/edit_view/features/step_definitions/window_steps.rb
  24. +1 −0 plugins/edit_view/features/support/env.rb
  25. 0 plugins/{application → redcar}/features/navigation_history.feature
  26. +13 −12 plugins/scm_svn/features/support/env.rb
  27. +2 −2 plugins/tree_view_swt/lib/tree_view_swt.rb
View
22 env.rb
@@ -0,0 +1,22 @@
+$KCODE="U"
+#
+# The cucumber environment. Loads support env.rb files and step definition
+# files from every plugin.
+#
+
+$:.push(File.expand_path("../lib", __FILE__))
+$redcar_process_start_time = Time.now
+
+require 'redcar'
+Redcar.environment = :test
+Redcar.load_unthreaded
+
+Dir["plugins/*/features/support/*.rb"].each do |fn|
+ require fn
+end
+
+Dir["plugins/*/features/step_definitions/*.rb"].each do |fn|
+ require fn
+end
+
+Redcar::Top.start
@@ -5,14 +5,14 @@ module Redcar
DRB_PORTS = {"user" => 10021, "test" => 10022, "development" => 10021}
DONT_READ_STDIN_ARG = "--ignore-stdin"
- def self.environment
- :user
- end
-
def self.drb_port
DRB_PORTS[Redcar.environment.to_s]
end
+ def self.environment
+ :user
+ end
+
def self.read_stdin
if not $stdin.tty? and not ARGV.include?(DONT_READ_STDIN_ARG)
data = ""
@@ -1,10 +1,11 @@
-
When /^I run the command ([^\s]+)$/ do |command_name|
- command_class = eval(command_name)
- command = command_class.new
- if command.is_a?(Redcar::DocumentCommand)
- command.run(:env => {:edit_view => implicit_edit_view})
- else
- command.run
+ Swt.sync_exec do
+ command_class = eval(command_name)
+ command = command_class.new
+ if command.is_a?(Redcar::DocumentCommand)
+ command.run(:env => {:edit_view => implicit_edit_view})
+ else
+ command.run
+ end
end
end
@@ -25,37 +25,49 @@ def get_speedbar_field(field_name, expected_klass, speedbar=nil)
end
When /^I type "([^"]*)" into the "([^"]*)" field in the speedbar$/ do |text, field_name|
- get_speedbar_text_field(field_name).edit_view.document.text = text
+ Swt.sync_exec do
+ get_speedbar_text_field(field_name).edit_view.document.text = text
+ end
end
When /^I press "([^"]*)" in the speedbar$/ do |button_name|
- speedbar = Redcar.app.focussed_window.speedbar
- speedbar.controller.execute_listener_in_model(speedbar.__get_item_by_text_or_name(button_name))
+ Swt.sync_exec do
+ speedbar = Redcar.app.focussed_window.speedbar
+ speedbar.controller.execute_listener_in_model(speedbar.__get_item_by_text_or_name(button_name))
+ end
end
When /^I check "([^"]*)" in the speedbar$/ do |checkbox_name|
- speedbar = Redcar.app.focussed_window.speedbar
- item = speedbar.__get_item_by_text_or_name(checkbox_name)
- item.set_value(true)
- speedbar.controller.execute_listener_in_model(item, true)
+ Swt.sync_exec do
+ speedbar = Redcar.app.focussed_window.speedbar
+ item = speedbar.__get_item_by_text_or_name(checkbox_name)
+ item.set_value(true)
+ speedbar.controller.execute_listener_in_model(item, true)
+ end
end
When /^I uncheck "([^"]*)" in the speedbar$/ do |checkbox_name|
- speedbar = Redcar.app.focussed_window.speedbar
- item = speedbar.__get_item_by_text_or_name(checkbox_name)
- item.set_value(false)
- speedbar.controller.execute_listener_in_model(item, false)
+ Swt.sync_exec do
+ speedbar = Redcar.app.focussed_window.speedbar
+ item = speedbar.__get_item_by_text_or_name(checkbox_name)
+ item.set_value(false)
+ speedbar.controller.execute_listener_in_model(item, false)
+ end
end
When /^I choose "([^"]*)" in the "([^"]*)" field in the speedbar$/ do |value, combo_name|
- speedbar = Redcar.app.focussed_window.speedbar
- item = get_speedbar_field(combo_name, Redcar::Speedbar::ComboItem)
- item.set_value(value)
- speedbar.controller.execute_listener_in_model(item, value)
+ Swt.sync_exec do
+ speedbar = Redcar.app.focussed_window.speedbar
+ item = get_speedbar_field(combo_name, Redcar::Speedbar::ComboItem)
+ item.set_value(value)
+ speedbar.controller.execute_listener_in_model(item, value)
+ end
end
When /^I close the speedbar$/ do
- Redcar.app.focussed_window.close_speedbar
+ Swt.sync_exec do
+ Redcar.app.focussed_window.close_speedbar
+ end
end
Then /^the "([^"]*)" field in the speedbar should have text "([^"]*)"$/ do |field_name, text|
@@ -1,12 +1,3 @@
-$:.push(File.expand_path("../../../../../lib", __FILE__))
-require "redcar_quick_start"
-
-$redcar_process_start_time = Time.now
-
-require 'redcar'
-Redcar.environment = :test
-Redcar.load_unthreaded
-Redcar::Top.start
require File.expand_path("../fake_event", __FILE__)
@@ -121,11 +112,86 @@ def available_message_box_types
module SwtHelper
+ def main_menu
+ display = Redcar::ApplicationSWT.display
+ shell = display.get_shells.to_a.first
+ menu_bar = shell.get_menu_bar
+ menu_bar
+ end
+
+ def first_shell
+ Redcar::ApplicationSWT.display.get_shells.to_a.first
+ end
+
+ def active_shell
+ focussed_window.controller.shell
+ end
+
+ def focussed_window
+ Redcar.app.focussed_window
+ end
+
+ def focussed_treebook_width
+ Redcar.app.focussed_window.controller.treebook_width
+ end
+
+ def focussed_tree
+ focussed_window.treebook.focussed_tree
+ end
+
+ def default_treebook_width
+ Redcar.app.focussed_window.controller.default_treebook_width
+ end
+
+ def tree_with_title(title)
+ focussed_window.treebook.trees.detect {|t| t.tree_mirror.title == title }
+ end
+
+ def dialog(type)
+ dialogs.detect {|d| d.is_a?(type) }
+ end
+
def dialogs
Redcar::ApplicationSWT.display.get_shells.to_a.map do |s|
Redcar::ApplicationSWT.shell_dialogs[s]
end.compact
end
+
+ def visible_tree_items(tree, items = [])
+ tree.getItems.to_a.each do |item|
+ items << item
+ visible_tree_items(item, items) if item.expanded?
+ end
+ return items
+ end
+
+ def top_tree
+ tree = focussed_tree.controller.viewer.get_tree
+ tree.extend(TreeHelpers)
+ tree
+ end
+
+ def find_node_with_text(top, node_text)
+ node = top.detect { |node| node.text == node_text }
+ return node if node
+ all_children = top.map{ |node| node.children }.flatten
+ find_node_with_text(all_children, node_text) unless all_children.empty?
+ end
+
+ def swt_label_for_item(vtabitem)
+ vtablabel = vtabitem.instance_variable_get "@label"
+ vtablabel.instance_variable_get "@label"
+ end
+
+ module TreeHelpers
+ def items
+ getItems.to_a
+ end
+
+ def item_texts
+ getItems.to_a.map {|item| item.getText}
+ end
+ end
end
World(SwtHelper)
@@ -3,21 +3,21 @@ Feature: Auto Complete
Scenario: Autocomplete with no completions
When I open a new edit tab
And I replace the contents with "Tess"
- And I move the cursor to 4
+ And I move the cursor to (0,4)
And I auto-complete
Then I should see "Tess" in the edit tab
Scenario: Autocomplete with one completions
When I open a new edit tab
And I replace the contents with "Daly Da"
- And I move the cursor to 7
+ And I move the cursor to (0,7)
And I auto-complete
Then I should see "Daly Daly" in the edit tab
Scenario: Autocomplete with one completions, twice
When I open a new edit tab
And I replace the contents with "Daly Da"
- And I move the cursor to 7
+ And I move the cursor to (0,7)
And I auto-complete
And I auto-complete
Then I should see "Daly Da" in the edit tab
@@ -26,22 +26,22 @@ Feature: Auto Complete
Scenario: Autocomplete with two completions
When I open a new edit tab
And I replace the contents with "Dan Daly Da"
- And I move the cursor to 11
+ And I move the cursor to (0,11)
And I auto-complete
Then I should see "Dan Daly Daly" in the edit tab
Scenario: Autocomplete with two completions, twice
When I open a new edit tab
And I replace the contents with "Dan Daly Da"
- And I move the cursor to 11
+ And I move the cursor to (0,11)
And I auto-complete
And I auto-complete
Then I should see "Dan Daly Dan" in the edit tab
Scenario: Autocomplete with two completions, thrice
When I open a new edit tab
And I replace the contents with "Dan Daly Da"
- And I move the cursor to 11
+ And I move the cursor to (0,11)
And I auto-complete
And I auto-complete
And I auto-complete
@@ -58,7 +58,7 @@ Feature: Auto Complete
Scenario: Autocomplete with one completions at the end of a line
When I open a new edit tab
And I replace the contents with "Daly Da\nfoo"
- And I move the cursor to 7
+ And I move the cursor to (0,7)
And I auto-complete
Then I should see "Daly Daly\nfoo" in the edit tab
@@ -1,4 +1,6 @@
When /I auto-complete/ do
- Redcar::AutoCompleter::AutoCompleteCommand.new.run
+ Swt.sync_exec do
+ Redcar::AutoCompleter::AutoCompleteCommand.new.run
+ end
end
@@ -10,8 +10,9 @@ Feature: Indents Java code correctly
"""
if(condition) {
// stuff goes here...
- } <c>
+ }
"""
+ And I move the cursor to (2,4)
When I type "e"
Then the content should be:
"""
@@ -23,9 +24,10 @@ Feature: Indents Java code correctly
Scenario: It should expand blocks
Given the content is:
"""
- if(condition) {<c>}
+ if(condition) {}
"""
- When I insert "\n" at the cursor
+ And I move the cursor to (0,17)
+ When I type "\n"
Then the content should be:
"""
if(condition) {
@@ -6,32 +6,32 @@ Feature: Indents Ruby code correctly
And tabs are hard
Scenario: It should increase indentation after 'def's
- When I insert "def f" at the cursor
- And I move the cursor to 5
- And I insert "\n" at the cursor
+ Given I replace the contents with "def f"
+ And I move the cursor to (0,5)
+ And I type "\n"
Then the contents should be "def f\n\t"
Scenario: It should decrease indentation on 'end' line
- When I insert "def f\n\t1\n\ten" at the cursor
- And I move the cursor to 12
- And I insert "d" at the cursor
+ When I replace the contents with "def f\n\t1\n\ten"
+ And I move the cursor to (2,3)
+ And I type "d"
Then the contents should be "def f\n\t1\nend"
Scenario: It should keep indentation the same if no change
- When I insert "\tfoo" at the cursor
- And I move the cursor to 4
- And I insert "\n" at the cursor
+ When I replace the contents with "\tfoo"
+ And I move the cursor to (0,4)
+ And I type "\n"
Then the contents should be "\tfoo\n\t"
Scenario: It should autoindent correctly
- When I insert "\tdef my_awesome_method\n\t\tfoo\n\tend" at the cursor
- And I select from 0 to 33
+ When I replace the contents with "\tdef my_awesome_method\n\t\tfoo\n\tend"
+ And I select from (0,0) to (2,4)
And I auto-indent
Then the contents should be "def my_awesome_method\n\tfoo\nend"
Scenario: It should autoindent correctly
- When I insert "\tdef my_awesome_method\n\t\tfoo\n\tend" at the cursor
- And I select from 0 to 33
+ When I replace the contents with "\tdef my_awesome_method\n\t\tfoo\n\tend"
+ And I select from (0,0) to (2,4)
And I auto-indent
Then the contents should be "def my_awesome_method\n\tfoo\nend"
When I undo
@@ -11,5 +11,7 @@
end
When /^I auto-indent/ do
- Redcar::AutoIndenter::IndentCommand.new.run
+ Swt.sync_exec do
+ Redcar::AutoIndenter::IndentCommand.new.run
+ end
end
@@ -39,7 +39,7 @@ Feature: Automatically insert paired characters
Scenario: Wrap selected text
When I open a new edit tab
And I type "Boris"
- And I select from 0 to 5
+ And I select from (0,0) to (0,5)
And I type "("
Then the contents should be "(Boris)<c>"
Oops, something went wrong.

0 comments on commit 804a36d

Please sign in to comment.