jpmobile 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +32 -10
- data/Rakefile +8 -8
- data/doc/classes/ActionController.html +120 -0
- data/doc/classes/ActionController/AbstractRequest.html +118 -0
- data/doc/classes/ActionController/CgiRequest.html +160 -0
- data/doc/classes/ActionView.html +101 -0
- data/doc/classes/DatumConv.html +324 -0
- data/doc/classes/Jpmobile/Display.html +333 -0
- data/doc/classes/Jpmobile/Emoticon.html +467 -0
- data/doc/classes/Jpmobile/Filter.html +120 -0
- data/doc/classes/Jpmobile/Filter/ApplyOnlyForMobile.html +172 -0
- data/doc/classes/Jpmobile/Filter/Base.html +269 -0
- data/doc/classes/Jpmobile/Filter/Emoticon.html +118 -0
- data/doc/classes/Jpmobile/Filter/Emoticon/Inner.html +184 -0
- data/doc/classes/Jpmobile/Filter/Emoticon/Outer.html +207 -0
- data/doc/classes/Jpmobile/Filter/FilterTable.html +178 -0
- data/doc/classes/Jpmobile/Filter/HankakuKana.html +126 -0
- data/doc/classes/Jpmobile/Filter/Sjis.html +271 -0
- data/doc/classes/Jpmobile/Helpers.html +588 -0
- data/doc/classes/Jpmobile/Mobile.html +150 -0
- data/doc/classes/Jpmobile/Mobile/AbstractMobile.html +389 -0
- data/doc/classes/Jpmobile/Mobile/Au.html +420 -0
- data/doc/classes/Jpmobile/Mobile/Ddipocket.html +138 -0
- data/doc/classes/Jpmobile/Mobile/Docomo.html +411 -0
- data/doc/classes/Jpmobile/Mobile/Emobile.html +183 -0
- data/doc/classes/Jpmobile/Mobile/Jphone.html +212 -0
- data/doc/classes/Jpmobile/Mobile/Softbank.html +344 -0
- data/doc/classes/Jpmobile/Mobile/Vodafone.html +176 -0
- data/doc/classes/Jpmobile/Mobile/Willcom.html +211 -0
- data/doc/classes/Jpmobile/Position.html +384 -0
- data/doc/classes/Jpmobile/RequestWithMobile.html +263 -0
- data/doc/created.rid +1 -0
- data/doc/files/CHANGELOG.html +110 -0
- data/doc/files/README.html +455 -0
- data/doc/files/lib/jpmobile/datum_conv_rb.html +110 -0
- data/doc/files/lib/jpmobile/emoticon/au_rb.html +124 -0
- data/doc/files/lib/jpmobile/emoticon/conversion_table_rb.html +124 -0
- data/doc/files/lib/jpmobile/emoticon/docomo_rb.html +119 -0
- data/doc/files/lib/jpmobile/emoticon/softbank_rb.html +119 -0
- data/doc/files/lib/jpmobile/emoticon/z_combine_rb.html +101 -0
- data/doc/files/lib/jpmobile/emoticon_rb.html +101 -0
- data/doc/files/lib/jpmobile/filter_rb.html +115 -0
- data/doc/files/lib/jpmobile/helpers_rb.html +105 -0
- data/doc/files/lib/jpmobile/hook_abstract_request_rb.html +108 -0
- data/doc/files/lib/jpmobile/hook_action_controller_rb.html +101 -0
- data/doc/files/lib/jpmobile/hook_action_view_rb.html +110 -0
- data/doc/files/lib/jpmobile/mobile/abstract_mobile_rb.html +108 -0
- data/doc/files/lib/jpmobile/mobile/au_rb.html +112 -0
- data/doc/files/lib/jpmobile/mobile/display_rb.html +111 -0
- data/doc/files/lib/jpmobile/mobile/docomo_rb.html +105 -0
- data/doc/files/lib/jpmobile/mobile/emobile_rb.html +105 -0
- data/doc/files/lib/jpmobile/mobile/softbank_rb.html +115 -0
- data/doc/files/lib/jpmobile/mobile/willcom_rb.html +108 -0
- data/doc/files/lib/jpmobile/mobile/z_display_info_docomo_rb.html +114 -0
- data/doc/files/lib/jpmobile/mobile/z_ip_addresses_au_rb.html +114 -0
- data/doc/files/lib/jpmobile/mobile/z_ip_addresses_docomo_rb.html +124 -0
- data/doc/files/lib/jpmobile/mobile/z_ip_addresses_emobile_rb.html +111 -0
- data/doc/files/lib/jpmobile/mobile/z_ip_addresses_softbank_rb.html +124 -0
- data/doc/files/lib/jpmobile/mobile/z_ip_addresses_willcom_rb.html +114 -0
- data/doc/files/lib/jpmobile/position_rb.html +105 -0
- data/doc/files/lib/jpmobile/request_with_mobile_rb.html +111 -0
- data/doc/files/lib/jpmobile/trans_sid_rb.html +118 -0
- data/doc/files/lib/jpmobile/version_rb.html +101 -0
- data/doc/files/lib/jpmobile_rb.html +101 -0
- data/doc/fr_class_index.html +55 -0
- data/doc/fr_file_index.html +58 -0
- data/doc/fr_method_index.html +134 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/jpmobile.rb +32 -1
- data/lib/jpmobile/emoticon.rb +18 -0
- data/lib/jpmobile/emoticon/au.rb +643 -0
- data/lib/jpmobile/filter.rb +5 -1
- data/lib/jpmobile/helpers.rb +9 -1
- data/lib/jpmobile/hook_abstract_request.rb +3 -24
- data/lib/jpmobile/hook_action_controller.rb +2 -2
- data/lib/jpmobile/hook_action_view.rb +41 -8
- data/lib/jpmobile/mobile/abstract_mobile.rb +18 -12
- data/lib/jpmobile/mobile/au.rb +11 -5
- data/lib/jpmobile/mobile/docomo.rb +27 -11
- data/lib/jpmobile/mobile/emobile.rb +15 -0
- data/lib/jpmobile/mobile/softbank.rb +11 -7
- data/lib/jpmobile/mobile/willcom.rb +5 -2
- data/lib/jpmobile/mobile/z_display_info_docomo.rb +343 -219
- data/lib/jpmobile/mobile/z_ip_addresses_au.rb +4 -1
- data/lib/jpmobile/mobile/z_ip_addresses_docomo.rb +10 -0
- data/lib/jpmobile/mobile/z_ip_addresses_emobile.rb +10 -0
- data/lib/jpmobile/mobile/{z_ip_addresses.rb → z_ip_addresses_softbank.rb} +2 -13
- data/lib/jpmobile/mobile/z_ip_addresses_willcom.rb +20 -1
- data/lib/jpmobile/position.rb +2 -2
- data/lib/jpmobile/request_with_mobile.rb +44 -0
- data/lib/jpmobile/trans_sid.rb +52 -14
- data/lib/jpmobile/version.rb +1 -1
- data/test/au_test.rb +94 -63
- data/test/autoload_test.rb +49 -0
- data/test/docomo_test.rb +92 -59
- data/test/emoticon_functional_test.rb +30 -3
- data/test/filter_test.rb +0 -64
- data/test/helper.rb +8 -1
- data/test/helpers_test.rb +14 -13
- data/test/softbank_test.rb +113 -85
- data/test/willcom_test.rb +30 -20
- data/tools/generate_au_emoticon_table.rb +12 -3
- data/tools/update_display_info_docomo.rb +0 -0
- data/tools/update_ip_addresses_au.rb +1 -1
- data/tools/update_ip_addresses_willcom.rb +1 -1
- metadata +135 -54
- data/test/filter_functional_test.rb +0 -146
data/test/helper.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'rubygems'
|
3
3
|
require 'action_controller'
|
4
|
+
require 'rack'
|
4
5
|
|
6
|
+
RAILS_ENV = "test"
|
5
7
|
require File.dirname(__FILE__)+'/../lib/jpmobile'
|
6
8
|
|
7
9
|
# ActionPackのTestのためのrequire
|
@@ -18,7 +20,12 @@ end
|
|
18
20
|
|
19
21
|
def request_with_ua(user_agent, env={})
|
20
22
|
fake_cgi = FakeCgi.new(user_agent, env)
|
21
|
-
|
23
|
+
[
|
24
|
+
ActionController::CgiRequest.new(fake_cgi),
|
25
|
+
Rack::Request.new(
|
26
|
+
Rack::MockRequest.env_for('http://www.example.jp', fake_cgi.env_table)
|
27
|
+
).extend(Jpmobile::RequestWithMobile)
|
28
|
+
]
|
22
29
|
end
|
23
30
|
|
24
31
|
## add helper methods to rails testing framework
|
data/test/helpers_test.rb
CHANGED
@@ -16,7 +16,7 @@ class HelpersTest < Test::Unit::TestCase
|
|
16
16
|
def setup
|
17
17
|
@view = FakeView.new
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
# get_position_link_to_がエラー無く終わるか。
|
21
21
|
def test_get_position_link_to_show_all
|
22
22
|
assert_nothing_raised {
|
@@ -26,7 +26,7 @@ class HelpersTest < Test::Unit::TestCase
|
|
26
26
|
|
27
27
|
# get_position_link_to(自動判別), DoCoMo
|
28
28
|
def test_get_position_link_to_docomo
|
29
|
-
@view.request = request_with_ua("DoCoMo/2.0 SH903i(c100;TB;W24H16)")
|
29
|
+
@view.request = request_with_ua("DoCoMo/2.0 SH903i(c100;TB;W24H16)").first
|
30
30
|
links = get_href_and_texts(@view.get_position_link_to("STRING"))
|
31
31
|
assert_equal(1, links.size)
|
32
32
|
text,attrs,path,params = links.first
|
@@ -37,14 +37,14 @@ class HelpersTest < Test::Unit::TestCase
|
|
37
37
|
|
38
38
|
# get_position_link_to(自動判別), TUKA
|
39
39
|
def test_get_position_link_to_tuka
|
40
|
-
@view.request = request_with_ua("UP.Browser/3.04-KCTA UP.Link/3.4.5.9")
|
40
|
+
@view.request = request_with_ua("UP.Browser/3.04-KCTA UP.Link/3.4.5.9").first
|
41
41
|
links = get_href_and_texts(@view.get_position_link_to("STRING"))
|
42
42
|
assert(links.empty?)
|
43
43
|
end
|
44
44
|
|
45
45
|
# get_position_link_to(自動判別), au, location only
|
46
46
|
def test_get_position_link_to_au_location_only
|
47
|
-
@view.request = request_with_ua("KDDI-SN26 UP.Browser/6.2.0.6.2 (GUI) MMP/2.0")
|
47
|
+
@view.request = request_with_ua("KDDI-SN26 UP.Browser/6.2.0.6.2 (GUI) MMP/2.0").first
|
48
48
|
links = get_href_and_texts(@view.get_position_link_to("STRING"))
|
49
49
|
assert_equal(1, links.size)
|
50
50
|
text,attrs,path,params = links.first
|
@@ -52,10 +52,10 @@ class HelpersTest < Test::Unit::TestCase
|
|
52
52
|
assert_equal("device:location", path)
|
53
53
|
assert_equal("http://example.jp", params["url"])
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
# get_position_link_to(自動判別), au, gps
|
57
57
|
def test_get_position_link_to_au_gps
|
58
|
-
@view.request = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0")
|
58
|
+
@view.request = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0").first
|
59
59
|
links = get_href_and_texts(@view.get_position_link_to("STRING"))
|
60
60
|
assert_equal(1, links.size)
|
61
61
|
text,attrs,path,params = links.first
|
@@ -68,10 +68,10 @@ class HelpersTest < Test::Unit::TestCase
|
|
68
68
|
assert_equal("0", params["unit"])
|
69
69
|
assert_equal("0", params["datum"])
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
# get_position_link_to(自動判別), J-PHONE
|
73
73
|
def test_get_position_link_to_jphone
|
74
|
-
@view.request = request_with_ua("J-PHONE/4.3/V603SH/SNXXXX0000000 SH/0007aa Profile/MIDP-1.0 Configuration/CLDC-1.0 Ext-Profile/JSCL-1.3.2")
|
74
|
+
@view.request = request_with_ua("J-PHONE/4.3/V603SH/SNXXXX0000000 SH/0007aa Profile/MIDP-1.0 Configuration/CLDC-1.0 Ext-Profile/JSCL-1.3.2").first
|
75
75
|
links = get_href_and_texts(@view.get_position_link_to("STRING"))
|
76
76
|
assert_equal(1, links.size)
|
77
77
|
text,attrs,path,params = links.first
|
@@ -82,7 +82,7 @@ class HelpersTest < Test::Unit::TestCase
|
|
82
82
|
|
83
83
|
# get_position_link_to(自動判別), Vodafone
|
84
84
|
def test_get_position_link_to_vodafone
|
85
|
-
@view.request = request_with_ua("Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0")
|
85
|
+
@view.request = request_with_ua("Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0").first
|
86
86
|
links = get_href_and_texts(@view.get_position_link_to("STRING"))
|
87
87
|
assert_equal(1, links.size)
|
88
88
|
text,attrs,path,params = links.first
|
@@ -92,7 +92,7 @@ class HelpersTest < Test::Unit::TestCase
|
|
92
92
|
|
93
93
|
# get_position_link_to(自動判別), Softbank
|
94
94
|
def test_get_position_link_to_softbank
|
95
|
-
@view.request = request_with_ua("SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1")
|
95
|
+
@view.request = request_with_ua("SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1").first
|
96
96
|
links = get_href_and_texts(@view.get_position_link_to("STRING"))
|
97
97
|
assert_equal(1, links.size)
|
98
98
|
text,attrs,path,params = links.first
|
@@ -102,7 +102,7 @@ class HelpersTest < Test::Unit::TestCase
|
|
102
102
|
|
103
103
|
# get_position_link_to(自動判別), Willcom
|
104
104
|
def test_get_position_link_to_willcom
|
105
|
-
@view.request = request_with_ua("Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0")
|
105
|
+
@view.request = request_with_ua("Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0").first
|
106
106
|
links = get_href_and_texts(@view.get_position_link_to("STRING"))
|
107
107
|
assert_equal(1, links.size)
|
108
108
|
text,attrs,path,params = links.first
|
@@ -131,6 +131,7 @@ class HelpersTest < Test::Unit::TestCase
|
|
131
131
|
assert_equal("http://w1m.docomo.ne.jp/cp/iarea", path)
|
132
132
|
assert_equal("OPENAREACODE", params["ecode"])
|
133
133
|
assert_equal("OPENAREAKEY", params["msn"])
|
134
|
+
assert_equal("1", params["posinfo"])
|
134
135
|
assert_equal("http://example.jp", params["nl"])
|
135
136
|
end
|
136
137
|
|
@@ -187,7 +188,7 @@ class HelpersTest < Test::Unit::TestCase
|
|
187
188
|
assert_equal("STRING", text)
|
188
189
|
assert_equal("location:auto", path)
|
189
190
|
end
|
190
|
-
|
191
|
+
|
191
192
|
# Willcom 位置情報取得用のリンクが正しく出力されるか。
|
192
193
|
def test_willcom_location_link_to
|
193
194
|
links = get_href_and_texts(@view.willcom_location_link_to("STRING"))
|
@@ -207,7 +208,7 @@ class HelpersTest < Test::Unit::TestCase
|
|
207
208
|
results = []
|
208
209
|
(Hpricot(str)/:a).each do |link|
|
209
210
|
path, query = link["href"].split(/\?/, 2)
|
210
|
-
params = query.nil? ? nil :
|
211
|
+
params = query.nil? ? nil : ActionController::AbstractRequest.parse_query_parameters(query)
|
211
212
|
results << [link.inner_html, link.attributes, path, params]
|
212
213
|
end
|
213
214
|
return results
|
data/test/softbank_test.rb
CHANGED
@@ -3,151 +3,179 @@ require File.dirname(__FILE__)+'/helper'
|
|
3
3
|
class SoftbankTest < Test::Unit::TestCase
|
4
4
|
# SoftBank, 端末種別の識別
|
5
5
|
def test_softbank_910t
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
reqs = request_with_ua("SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1")
|
7
|
+
reqs.each do |req|
|
8
|
+
assert_equal(true, req.mobile?)
|
9
|
+
assert_instance_of(Jpmobile::Mobile::Softbank, req.mobile)
|
10
|
+
assert_kind_of(Jpmobile::Mobile::Softbank, req.mobile)
|
11
|
+
assert_equal(nil, req.mobile.position)
|
12
|
+
assert_equal("000000000000000", req.mobile.serial_number)
|
13
|
+
assert_equal("000000000000000", req.mobile.ident)
|
14
|
+
assert_equal("000000000000000", req.mobile.ident_device)
|
15
|
+
assert_equal(nil, req.mobile.ident_subscriber)
|
16
|
+
assert(req.mobile.supports_cookie?)
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
20
|
# SoftBank, X_JPHONE_UID付き
|
19
21
|
def test_softbank_910t_x_jphone_uid
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
reqs = request_with_ua("SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1", "HTTP_X_JPHONE_UID"=>"aaaaaaaaaaaaaaaa")
|
23
|
+
reqs.each do |req|
|
24
|
+
assert_equal("000000000000000", req.mobile.serial_number)
|
25
|
+
assert_equal("aaaaaaaaaaaaaaaa", req.mobile.x_jphone_uid)
|
26
|
+
assert_equal("aaaaaaaaaaaaaaaa", req.mobile.ident)
|
27
|
+
assert_equal("000000000000000", req.mobile.ident_device)
|
28
|
+
assert_equal("aaaaaaaaaaaaaaaa", req.mobile.ident_subscriber)
|
29
|
+
assert(req.mobile.supports_cookie?)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
# Vodafone, 端末種別の識別
|
30
34
|
def test_vodafone_v903t
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
reqs = request_with_ua("Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0")
|
36
|
+
reqs.each do |req|
|
37
|
+
assert_equal(true, req.mobile?)
|
38
|
+
assert_instance_of(Jpmobile::Mobile::Vodafone, req.mobile)
|
39
|
+
assert_kind_of(Jpmobile::Mobile::Softbank, req.mobile)
|
40
|
+
assert_equal(nil, req.mobile.position)
|
41
|
+
assert_equal(nil, req.mobile.ident)
|
42
|
+
assert(req.mobile.supports_cookie?)
|
43
|
+
end
|
38
44
|
end
|
39
45
|
|
40
46
|
# Vodafone, 端末種別の識別
|
41
47
|
def test_vodafone_v903sh
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
reqs = request_with_ua("Vodafone/1.0/V903SH/SHJ001/SN000000000000000 Browser/UP.Browser/7.0.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0")
|
49
|
+
reqs.each do |req|
|
50
|
+
assert_equal(true, req.mobile?)
|
51
|
+
assert_instance_of(Jpmobile::Mobile::Vodafone, req.mobile)
|
52
|
+
assert_kind_of(Jpmobile::Mobile::Softbank, req.mobile)
|
53
|
+
assert_equal("000000000000000", req.mobile.serial_number)
|
54
|
+
assert_equal("000000000000000", req.mobile.ident)
|
55
|
+
assert_equal("000000000000000", req.mobile.ident_device)
|
56
|
+
assert_equal(nil, req.mobile.ident_subscriber)
|
57
|
+
assert_equal(nil, req.mobile.position)
|
58
|
+
assert(req.mobile.supports_cookie?)
|
59
|
+
end
|
52
60
|
end
|
53
61
|
|
54
62
|
# J-PHONE, 端末種別の識別
|
55
63
|
def test_jphone_v603sh
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
reqs = request_with_ua("J-PHONE/4.3/V603SH/SNXXXX0000000 SH/0007aa Profile/MIDP-1.0 Configuration/CLDC-1.0 Ext-Profile/JSCL-1.3.2")
|
65
|
+
reqs.each do |req|
|
66
|
+
assert_equal(true, req.mobile?)
|
67
|
+
assert_instance_of(Jpmobile::Mobile::Jphone, req.mobile)
|
68
|
+
assert_kind_of(Jpmobile::Mobile::Softbank, req.mobile)
|
69
|
+
assert_equal("XXXX0000000", req.mobile.serial_number)
|
70
|
+
assert_equal("XXXX0000000", req.mobile.ident)
|
71
|
+
assert_equal("XXXX0000000", req.mobile.ident_device)
|
72
|
+
assert_equal(nil, req.mobile.ident_subscriber)
|
73
|
+
assert_equal(nil, req.mobile.position)
|
74
|
+
assert(!req.mobile.supports_cookie?)
|
75
|
+
end
|
66
76
|
end
|
67
77
|
|
68
78
|
# J-PHONE, 端末種別の識別
|
69
79
|
def test_jphone_v301d
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
80
|
+
reqs = request_with_ua("J-PHONE/3.0/V301D")
|
81
|
+
reqs.each do |req|
|
82
|
+
assert_equal(true, req.mobile?)
|
83
|
+
assert_instance_of(Jpmobile::Mobile::Jphone, req.mobile)
|
84
|
+
assert_kind_of(Jpmobile::Mobile::Softbank, req.mobile)
|
85
|
+
assert_equal(nil, req.mobile.serial_number)
|
86
|
+
assert_equal(nil, req.mobile.position)
|
87
|
+
assert(!req.mobile.supports_cookie?)
|
88
|
+
end
|
77
89
|
end
|
78
90
|
|
79
91
|
# J-PHONE
|
80
92
|
# http://kokogiko.net/wiki.cgi?page=vodafone%A4%C7%A4%CE%B0%CC%C3%D6%BC%E8%C6%C0%CA%FD%CB%A1
|
81
93
|
def test_jphone_antenna
|
82
|
-
|
94
|
+
reqs = request_with_ua("J-PHONE/3.0/V301D",
|
83
95
|
"HTTP_X_JPHONE_GEOCODE"=>"353840%1A1394440%1A%93%8C%8B%9E%93s%8D%60%8B%E6%8E%C5%82T%92%9A%96%DA")
|
84
|
-
|
85
|
-
|
86
|
-
|
96
|
+
reqs.each do |req|
|
97
|
+
assert_in_delta(35.64768482, req.mobile.position.lat, 1e-4)
|
98
|
+
assert_in_delta(139.7412141, req.mobile.position.lon, 1e-4)
|
99
|
+
assert_equal("東京都港区芝5丁目", req.mobile.position.options["address"])
|
100
|
+
end
|
87
101
|
end
|
88
102
|
|
89
103
|
# J-PHONE 位置情報なし
|
90
104
|
def test_jphone_antenna_empty
|
91
|
-
|
105
|
+
reqs = request_with_ua("J-PHONE/3.0/V301D",
|
92
106
|
"HTTP_X_JPHONE_GEOCODE"=>"0000000%1A0000000%1A%88%CA%92%75%8F%EE%95%F1%82%C8%82%B5")
|
93
|
-
|
107
|
+
reqs.each do |req|
|
108
|
+
assert_equal(nil, req.mobile.position)
|
109
|
+
end
|
94
110
|
end
|
95
111
|
|
96
112
|
# Vodafone 3G, wgs84, gps
|
97
113
|
def test_vodafone_gps
|
98
|
-
|
114
|
+
reqs = request_with_ua("Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0",
|
99
115
|
{"QUERY_STRING"=>"pos=N43.3.18.42E141.21.1.88&geo=wgs84&x-acr=1"})
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
116
|
+
reqs.each do |req|
|
117
|
+
assert_in_delta(43.05511667, req.mobile.position.lat, 1e-7)
|
118
|
+
assert_in_delta(141.3505222, req.mobile.position.lon, 1e-7)
|
119
|
+
assert_equal("N43.3.18.42E141.21.1.88", req.mobile.position.options["pos"])
|
120
|
+
assert_equal("wgs84", req.mobile.position.options["geo"])
|
121
|
+
assert_equal("1", req.mobile.position.options["x-acr"])
|
122
|
+
end
|
105
123
|
end
|
106
124
|
|
107
125
|
# 正しいIPアドレス空間からのアクセスを判断できるか。
|
108
126
|
def test_softbank_valid_ip_address
|
109
|
-
|
127
|
+
reqs = request_with_ua("Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0",
|
110
128
|
{"REMOTE_ADDR"=>"202.179.204.1"})
|
111
|
-
|
129
|
+
reqs.each do |req|
|
130
|
+
assert_equal(true, req.mobile.valid_ip?)
|
131
|
+
end
|
112
132
|
end
|
113
133
|
|
114
134
|
# 正しいIPアドレス空間からのアクセスを判断できるか。
|
115
135
|
def test_jphone_valid_ip_address
|
116
|
-
|
136
|
+
reqs = request_with_ua("J-PHONE/3.0/V301D",
|
117
137
|
{"REMOTE_ADDR"=>"202.179.204.1"})
|
118
|
-
|
138
|
+
reqs.each do |req|
|
139
|
+
assert_equal(true, req.mobile.valid_ip?)
|
140
|
+
end
|
119
141
|
end
|
120
142
|
|
121
143
|
# 正しくないIPアドレス空間からのアクセスを判断できるか。
|
122
144
|
def test_softbank_ip_address
|
123
|
-
|
145
|
+
reqs = request_with_ua("Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0",
|
124
146
|
{"REMOTE_ADDR"=>"127.0.0.1"})
|
125
|
-
|
147
|
+
reqs.each do |req|
|
148
|
+
assert_equal(false, req.mobile.valid_ip?)
|
149
|
+
end
|
126
150
|
end
|
127
151
|
|
128
152
|
# 端末の画面サイズを正しく取得できるか。
|
129
153
|
def test_softbank_v903t_display
|
130
|
-
|
154
|
+
reqs = request_with_ua("Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0",
|
131
155
|
"HTTP_X_JPHONE_DISPLAY"=>"240*320",
|
132
156
|
"HTTP_X_JPHONE_COLOR"=>"C262144" )
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
157
|
+
reqs.each do |req|
|
158
|
+
assert_equal(240, req.mobile.display.width)
|
159
|
+
assert_equal(320, req.mobile.display.height)
|
160
|
+
assert_equal(240, req.mobile.display.physical_width)
|
161
|
+
assert_equal(320, req.mobile.display.physical_height)
|
162
|
+
assert_equal(true, req.mobile.display.color?)
|
163
|
+
assert_equal(262144, req.mobile.display.colors)
|
164
|
+
end
|
139
165
|
end
|
140
166
|
|
141
167
|
# 端末の画面情報が渡ってない場合に正しく動作するか。
|
142
168
|
def test_softbank_v903t_display_information_omitted
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
169
|
+
reqs = request_with_ua("Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0")
|
170
|
+
reqs.each do |req|
|
171
|
+
assert_equal(nil, req.mobile.display.width)
|
172
|
+
assert_equal(nil, req.mobile.display.height)
|
173
|
+
assert_equal(nil, req.mobile.display.browser_width)
|
174
|
+
assert_equal(nil, req.mobile.display.browser_height)
|
175
|
+
assert_equal(nil, req.mobile.display.physical_width)
|
176
|
+
assert_equal(nil, req.mobile.display.physical_height)
|
177
|
+
assert_equal(nil, req.mobile.display.color?)
|
178
|
+
assert_equal(nil, req.mobile.display.colors)
|
179
|
+
end
|
152
180
|
end
|
153
181
|
end
|
data/test/willcom_test.rb
CHANGED
@@ -3,44 +3,54 @@ require File.dirname(__FILE__)+'/helper'
|
|
3
3
|
class WillcomTest < Test::Unit::TestCase
|
4
4
|
# willcom, 端末種別の識別
|
5
5
|
def test_wilcom_wx310k
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
reqs = request_with_ua("Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0")
|
7
|
+
reqs.each do |req|
|
8
|
+
assert_equal(true, req.mobile?)
|
9
|
+
assert_instance_of(Jpmobile::Mobile::Willcom, req.mobile)
|
10
|
+
assert_equal(nil, req.mobile.position)
|
11
|
+
assert_equal(nil, req.mobile.ident)
|
12
|
+
assert(req.mobile.supports_cookie?)
|
13
|
+
end
|
12
14
|
end
|
13
15
|
|
14
16
|
# DDI-POCKET, 端末種別の識別
|
15
17
|
def test_ddipocket_ah_k3001v
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
reqs = request_with_ua("Mozilla/3.0(DDIPOCKET;KYOCERA/AH-K3001V/1.8.2.71.000000/0.1/C100) Opera 7.0")
|
19
|
+
reqs.each do |req|
|
20
|
+
assert_equal(true, req.mobile?)
|
21
|
+
assert_instance_of(Jpmobile::Mobile::Ddipocket, req.mobile)
|
22
|
+
assert_kind_of(Jpmobile::Mobile::Willcom, req.mobile)
|
23
|
+
assert_equal(nil, req.mobile.position)
|
24
|
+
assert_equal(nil, req.mobile.ident)
|
25
|
+
assert(req.mobile.supports_cookie?)
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
# willcom, antenna
|
26
30
|
def test_wilcom_antenna
|
27
|
-
|
31
|
+
reqs = request_with_ua("Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0",
|
28
32
|
{"QUERY_STRING"=>"pos=N43.04.34.049E141.21.03.279"})
|
29
|
-
|
30
|
-
|
33
|
+
reqs.each do |req|
|
34
|
+
assert_in_delta(43.078568, req.mobile.position.lat, 1e-4)
|
35
|
+
assert_in_delta(141.347223, req.mobile.position.lon, 1e-4)
|
36
|
+
end
|
31
37
|
end
|
32
38
|
|
33
39
|
# 正しいIPアドレス空間からのアクセスを判断できるか。
|
34
40
|
def test_willcom_valid_ip_address
|
35
|
-
|
41
|
+
reqs = request_with_ua("Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0",
|
36
42
|
{"REMOTE_ADDR"=>"61.198.142.1"})
|
37
|
-
|
43
|
+
reqs.each do |req|
|
44
|
+
assert_equal(req.mobile.valid_ip?, true)
|
45
|
+
end
|
38
46
|
end
|
39
47
|
|
40
48
|
# 正しくないIPアドレス空間からのアクセスを判断できるか。
|
41
49
|
def test_willcom_invalid_ip_address
|
42
|
-
|
50
|
+
reqs = request_with_ua("Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0",
|
43
51
|
{"REMOTE_ADDR"=>"127.0.0.1"})
|
44
|
-
|
52
|
+
reqs.each do |req|
|
53
|
+
assert_equal(req.mobile.valid_ip?, false)
|
54
|
+
end
|
45
55
|
end
|
46
56
|
end
|