Permalink
Browse files

move dragdrop test to playground

  • Loading branch information...
1 parent cef0d8a commit b12bb87d4895f1fd676c1f78c0b830bcefa60529 Sven Fuchs committed Feb 18, 2010
Showing with 60 additions and 58 deletions.
  1. +0 −58 test/dragdrop_test.rb
  2. +60 −0 test/playground/dragdrop_behavior.rb
View
58 test/dragdrop_test.rb
@@ -1,58 +0,0 @@
-# $: << File.expand_path("../../lib", __FILE__)
-#
-# require 'steam'
-#
-# include Steam
-#
-# @app = Connection::Mock.new
-# root = File.expand_path("../fixtures/public", __FILE__)
-# static = Connection::Static.new(:root => root, :urls => %w(/ /javascripts /stylesheets))
-# @browser = Browser::HtmlUnit.new(Rack::Cascade.new([static, @app]))
-#
-# def drag_to(target)
-# @browser.page.executeJavaScript('$("#log").text("")')
-#
-# drag = @browser.locate_in_browser(:div, :class => 'drag')
-# drop = @browser.locate_in_browser(:div, :id => target)
-#
-# puts "\nDRAGGING #{drag.getCanonicalXPath}"
-# puts "DROPPING ONTO (#{drop.getCanonicalXPath}):\n" + drop.asXml
-#
-# drag.mouseDown
-# drop.mouseMove
-# page = drop.mouseUp
-#
-# log = page.executeJavaScript('$("#log").text()').getJavaScriptResult
-# puts "RECEIVED DROP EVENT ON:\n" + log.toString
-# end
-#
-# @browser.request('/index.html')
-# drag_to('drop_1')
-# drag_to('drop_2')
-# drag_to('drop_3')
-# drag_to('drop_4')
-# drag_to('drop_5')
-# drag_to('drop_6')
-
-# OUTPUT:
-#
-# DROPPING ONTO (/html/body/div[2]):
-# <div class="drop ui-droppable" id="drop_2">
-# </div>
-# RECEIVED DROP EVENT ON:
-# <div id="drop_1" class="drop ui-droppable"></div>
-#
-# DROPPING ONTO (/html/body/div[3]):
-# <div class="drop ui-droppable" id="drop_3">
-# </div>
-# RECEIVED DROP EVENT ON:
-# <div id="drop_2" class="drop ui-droppable"></div>
-#
-# DROPPING ONTO (/html/body/div[4]):
-# <div class="drop ui-droppable" id="drop_4">
-# </div>
-# RECEIVED DROP EVENT ON:
-# <div id="drop_3" class="drop ui-droppable"></div>
-
-
-
View
60 test/playground/dragdrop_behavior.rb
@@ -0,0 +1,60 @@
+$: << File.expand_path("../../lib", __FILE__)
+
+require 'steam'
+
+include Steam
+
+Steam.config[:html_unit][:java_path] = File.expand_path("../../lib/htmlunit-2.7/", __FILE__)
+
+@app = Connection::Mock.new
+root = File.expand_path("../fixtures/public", __FILE__)
+static = Connection::Static.new(:root => root, :urls => %w(/ /javascripts /stylesheets))
+@browser = Browser::HtmlUnit.new(Rack::Cascade.new([static, @app]))
+
+def drag_to(target)
+ @browser.page.executeJavaScript('$("#log").text("")')
+
+ drag = @browser.locate_in_browser(:div, :class => 'drag')
+ drop = @browser.locate_in_browser(:div, :id => target)
+
+ puts "\nDRAGGING #{drag.getCanonicalXPath}"
+ puts "DROPPING ONTO:\n" + drop.asXml # (#{drop.getCanonicalXPath})
+
+ drag.mouseDown
+ drop.mouseMove
+ page = drop.mouseUp
+
+ log = page.executeJavaScript('$("#log").text()').getJavaScriptResult
+ puts "RECEIVED DROP EVENT ON:\n" + log.toString
+end
+
+@browser.request('/index.html')
+drag_to('drop_1')
+drag_to('drop_2')
+drag_to('drop_3')
+# drag_to('drop_4')
+# drag_to('drop_5')
+# drag_to('drop_6')
+
+# OUTPUT:
+#
+# DROPPING ONTO (/html/body/div[2]):
+# <div class="drop ui-droppable" id="drop_2">
+# </div>
+# RECEIVED DROP EVENT ON:
+# <div id="drop_1" class="drop ui-droppable"></div>
+#
+# DROPPING ONTO (/html/body/div[3]):
+# <div class="drop ui-droppable" id="drop_3">
+# </div>
+# RECEIVED DROP EVENT ON:
+# <div id="drop_2" class="drop ui-droppable"></div>
+#
+# DROPPING ONTO (/html/body/div[4]):
+# <div class="drop ui-droppable" id="drop_4">
+# </div>
+# RECEIVED DROP EVENT ON:
+# <div id="drop_3" class="drop ui-droppable"></div>
+
+
+

0 comments on commit b12bb87

Please sign in to comment.