1 ## Copyright 2004-2007 Castle Project - http://www.castleproject.org/
\r
3 ## Licensed under the Apache License, Version 2.0 (the "License");
\r
4 ## you may not use this file except in compliance with the License.
\r
5 ## You may obtain a copy of the License at
\r
7 ## http://www.apache.org/licenses/LICENSE-2.0
\r
9 ## Unless required by applicable law or agreed to in writing, software
\r
10 ## distributed under the License is distributed on an "AS IS" BASIS,
\r
11 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 ## See the License for the specific language governing permissions and
\r
13 ## limitations under the License.
\r
18 require 'test/unit/ui/console/testrunner'
\r
24 # Test cases for MonoRail AjaxHelper
\r
26 class ObserveFieldTestCase < Test::Unit::TestCase
\r
27 include CommonIEDriver
\r
29 def test_fieldchange()
\r
30 $ie.goto("#{$base_url}/ajax/observefield.rails")
\r
34 $ie.text_field(:id, "zip").set(content)
\r
38 assert_equal("Address #{content}", $ie.div(:id, 'address').text)
\r
43 class ObserveFormTestCase < Test::Unit::TestCase
\r
44 include CommonIEDriver
\r
46 def test_fieldchange()
\r
47 $ie.goto("#{$base_url}/ajax/observeform.rails")
\r
50 address = 'sao paulo';
\r
52 $ie.text_field(:id, "name").set(name)
\r
53 $ie.text_field(:id, "addressf").set(address)
\r
57 assert_equal("name #{name} address #{address}", $ie.div(:id, 'message').text)
\r
62 class PeriodicallyCallRemoteTestCase < Test::Unit::TestCase
\r
63 include CommonIEDriver
\r
65 def test_fieldchange()
\r
66 $ie.goto("#{$base_url}/ajax/periodicallycall.rails")
\r
68 $ie.text_field(:id, "value").set('1')
\r
72 assert_equal("2", $ie.div(:id, 'newValue').text)
\r
74 $ie.text_field(:id, "value").set('4')
\r
78 assert_equal("8", $ie.div(:id, 'newValue').text)
\r
83 class JsProxiesTestCase < Test::Unit::TestCase
\r
84 include CommonIEDriver
\r
86 def test_parameterless_remote_method()
\r
87 $ie.goto("#{$base_url}/ajax/jsproxies.rails")
\r
89 $ie.button(:id, 'invocableMethodButton').click
\r
93 assert_equal("Success", $ie.div(:id, 'result').text)
\r
96 def test_parameterful_remote_method()
\r
97 $ie.goto("#{$base_url}/ajax/jsproxies.rails")
\r
99 $ie.button(:id, 'anotherMethodButton').click
\r
103 assert_equal("Success something", $ie.div(:id, 'result').text)
\r
108 class FormRemoteTagTestCase < Test::Unit::TestCase
\r
109 include CommonIEDriver
\r
111 def test_submit_form_async()
\r
112 $ie.goto("#{$base_url}/ajax/formremotetag.rails")
\r
114 $ie.text_field(:id, "name").set('hammett')
\r
115 $ie.text_field(:id, "email").set('hammett@apache.org')
\r
117 $ie.button(:id, 'sub').click
\r
121 assert_equal("hammett", $ie.span(:id, 'hammett_name').text)
\r
122 assert_equal("hammett@apache.org", $ie.span(:id, 'hammett_email').text)
\r
129 suite = Test::Unit::TestSuite.new
\r
130 suite << ObserveFieldTestCase.suite
\r
131 suite << ObserveFormTestCase.suite
\r
132 suite << PeriodicallyCallRemoteTestCase.suite
\r
133 suite << JsProxiesTestCase.suite
\r
134 suite << FormRemoteTagTestCase.suite
\r
139 $base_url = "http://localhost:88"
\r
142 #$ie.set_fast_speed
\r
143 Test::Unit::UI::Console::TestRunner.run(CastleTests)
\r