google4r-maps 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,129 @@
1
+ # Project: google4r/maps
2
+ # File: /test/gmarker_test.rb
3
+ # Author: Manuel Holtgrewe <purestorm at ggnore dot net>
4
+ # Copyright: (c) 2007 by Manuel Holtgrewe
5
+ # License: MIT License as follows:
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining
8
+ # a copy of this software and associated documentation files (the
9
+ # "Software"), to deal in the Software without restriction, including
10
+ # without limitation the rights to use, copy, modify, merge, publish,
11
+ # distribute, sublicense, and/or sell copies of the Software, and to permit
12
+ # persons to whom the Software is furnished to do so, subject to the
13
+ # following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included
16
+ # in all copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
24
+ # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+
26
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
27
+
28
+ require 'google4r/maps'
29
+
30
+ # Runs tests for the Google4R::Maps::GMarker class.
31
+ class GMarker < Test::Unit::TestCase
32
+ def test_creator_should_work_correctly
33
+ marker = Google4R::Maps::GMarker.new([1, 2])
34
+ assert_equal [1, 2], marker.point
35
+ end
36
+
37
+ def test_to_js_should_work_correctly_with_default_values
38
+ expected = %Q{function(icon) {
39
+ var options = { dragCrossMove: false, clickable: true, bouncy: false, bounceGravity: 1 }
40
+ if (icon != null) options['icon'] = icon;
41
+
42
+ var marker = new GMarker(new GLatLng(1, 2), options);
43
+ marker.disableDragging();
44
+
45
+ /* Setup event handlers. */
46
+
47
+ return marker;
48
+ }}
49
+
50
+ marker = Google4R::Maps::GMarker.new([1, 2])
51
+ assert_equal expected, marker.to_js
52
+ end
53
+
54
+ def test_to_js_should_work_correctly_with_all_values_set
55
+ expected = %Q{function(icon) {
56
+ var options = { dragCrossMove: true, title: "marker title", clickable: false, bouncy: true, bounceGravity: 2 }
57
+ if (icon != null) options['icon'] = icon;
58
+
59
+ var marker = new GMarker(new GLatLng(1, 2), options);
60
+ marker.enableDragging();
61
+
62
+ /* Setup event handlers. */
63
+
64
+ return marker;
65
+ }}
66
+
67
+ marker = Google4R::Maps::GMarker.new([1, 2])
68
+ marker.drag_cross_move = true;
69
+ marker.clickable = false;
70
+ marker.draggable = true;
71
+ marker.bouncy = true;
72
+ marker.title = "marker title";
73
+ marker.bounce_gravity = 2;
74
+
75
+ assert_equal expected, marker.to_js
76
+ end
77
+
78
+ def test_to_js_should_work_correctly_with_event_handlers
79
+ expected = %Q{function(icon) {
80
+ var options = { dragCrossMove: false, clickable: true, bouncy: false, bounceGravity: 1 }
81
+ if (icon != null) options['icon'] = icon;
82
+
83
+ var marker = new GMarker(new GLatLng(1, 2), options);
84
+ marker.disableDragging();
85
+
86
+ /* Setup event handlers. */
87
+ GEvent.addListener(marker, "click", function() {
88
+ // my handler
89
+ // code
90
+ });
91
+ GEvent.addListener(marker, "click", function() {
92
+ // my other handler
93
+ // code
94
+ });
95
+
96
+ return marker;
97
+ }}
98
+
99
+ marker = Google4R::Maps::GMarker.new([1, 2])
100
+
101
+ marker.onclick_handlers << "// my handler\n// code"
102
+ marker.onclick_handlers << "// my other handler\n// code"
103
+
104
+ assert_equal expected, marker.to_js
105
+ end
106
+
107
+ def test_info_window_html_should_work_correctly
108
+ expected = %Q{function(icon) {
109
+ var options = { dragCrossMove: false, clickable: true, bouncy: false, bounceGravity: 1 }
110
+ if (icon != null) options['icon'] = icon;
111
+
112
+ var marker = new GMarker(new GLatLng(1, 2), options);
113
+ marker.disableDragging();
114
+
115
+ /* Setup event handlers. */
116
+ GEvent.addListener(marker, "click", function() {
117
+ marker.openInfoWindowHtml("some html");
118
+ });
119
+
120
+ return marker;
121
+ }}
122
+
123
+ marker = Google4R::Maps::GMarker.new([1, 2])
124
+
125
+ marker.info_window_html = "some html"
126
+
127
+ assert_equal expected, marker.to_js
128
+ end
129
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.2
3
+ specification_version: 1
4
+ name: google4r-maps
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2007-05-12 00:00:00 +02:00
8
+ summary: Ruby library to create Google Maps HTML/JS and access the Google Maps Geocoder.
9
+ require_paths:
10
+ - lib
11
+ email:
12
+ homepage:
13
+ rubyforge_project:
14
+ description: Ruby library to create Google Maps HTML/JS and access the Google Maps Geocoder.
15
+ autorequire: ""
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.8.4
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Manuel Holtgrewe
31
+ files:
32
+ - lib/google4r/maps.rb
33
+ - README
34
+ - LICENSE
35
+ - CHANGES
36
+ test_files:
37
+ - test/geocoder_test.rb
38
+ - test/gicon_test.rb
39
+ - test/gmap2_test.rb
40
+ - test/gmarker_test.rb
41
+ rdoc_options: []
42
+
43
+ extra_rdoc_files:
44
+ - README
45
+ - LICENSE
46
+ - CHANGES
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ requirements: []
52
+
53
+ dependencies: []
54
+