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
@@ -1,19 +1,8 @@
|
|
1
1
|
# = IPアドレス帯域テーブル(手動更新分)
|
2
|
-
# == DoCoMo
|
3
|
-
# http://www.nttdocomo.co.jp/service/imode/make/content/ip/index.html
|
4
|
-
# 2006/09現在
|
5
2
|
# == SoftBank
|
6
3
|
# http://developers.softbankmobile.co.jp/dp/tech_svc/web/ip.php
|
7
4
|
# 2007/10/09現在
|
8
|
-
|
9
|
-
#:enddoc:
|
10
|
-
Jpmobile::Mobile::Docomo::IP_ADDRESSES = <<EOF
|
11
|
-
210.153.84.0/24
|
12
|
-
210.136.161.0/24
|
13
|
-
210.153.86.0/24
|
14
|
-
EOF
|
15
|
-
|
16
|
-
Jpmobile::Mobile::Softbank::IP_ADDRESSES=<<EOF
|
5
|
+
Jpmobile::Mobile::Softbank::IP_ADDRESSES = %w(
|
17
6
|
123.108.236.0/24
|
18
7
|
123.108.237.0/27
|
19
8
|
202.179.204.0/24
|
@@ -25,4 +14,4 @@ Jpmobile::Mobile::Softbank::IP_ADDRESSES=<<EOF
|
|
25
14
|
210.175.1.128/25
|
26
15
|
210.228.189.0/24
|
27
16
|
211.8.159.128/25
|
28
|
-
|
17
|
+
).map {|ip| IPAddr.new(ip) }
|
@@ -76,4 +76,23 @@ Jpmobile::Mobile::Willcom::IP_ADDRESSES =
|
|
76
76
|
"61.198.139.128/27",
|
77
77
|
"61.198.138.103/32",
|
78
78
|
"61.198.139.0/29",
|
79
|
-
"219.108.15.0/24"
|
79
|
+
"219.108.15.0/24",
|
80
|
+
"61.198.130.0/24",
|
81
|
+
"61.198.163.0/24",
|
82
|
+
"61.204.6.128/25",
|
83
|
+
"61.204.7.0/25",
|
84
|
+
"61.204.92.0/24",
|
85
|
+
"61.204.93.0/24",
|
86
|
+
"61.204.94.0/24",
|
87
|
+
"61.204.95.0/24",
|
88
|
+
"61.198.128.0/24",
|
89
|
+
"61.198.131.0/24",
|
90
|
+
"61.198.143.0/24",
|
91
|
+
"61.198.172.0/24",
|
92
|
+
"61.198.173.0/24",
|
93
|
+
"61.198.252.0/24",
|
94
|
+
"61.204.3.128/25",
|
95
|
+
"211.126.192.128/25",
|
96
|
+
"219.108.11.0/24",
|
97
|
+
"219.108.12.0/24",
|
98
|
+
"219.108.13.0/24"].map {|ip| IPAddr.new(ip) }
|
data/lib/jpmobile/position.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
# plugins/以下にgeokitがインストールされている場合は読み込む
|
4
4
|
begin
|
5
|
-
require
|
6
|
-
rescue MissingSourceFile
|
5
|
+
require RAILS_ROOT + '/vendor/plugins/geokit/lib/geo_kit/mappable'
|
6
|
+
rescue MissingSourceFile, NameError
|
7
7
|
end
|
8
8
|
|
9
9
|
module Jpmobile
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# jpmobile の各機能を提供するモジュール
|
2
|
+
# envメソッドと、parameter あるいは params メソッドが実装されている必要がある。
|
3
|
+
# 今のところはRack::RequestとActionController::AbstractRequestに対応しているはず。
|
4
|
+
|
5
|
+
module Jpmobile
|
6
|
+
module RequestWithMobile
|
7
|
+
# 環境変数 HTTP_USER_AGENT を返す。
|
8
|
+
def user_agent
|
9
|
+
env['HTTP_USER_AGENT']
|
10
|
+
end
|
11
|
+
|
12
|
+
# for reverse proxy.
|
13
|
+
def remote_addr
|
14
|
+
if respond_to? :remote_ip
|
15
|
+
return __send__(:remote_ip)
|
16
|
+
else
|
17
|
+
return ( env["HTTP_X_FORWARDED_FOR"] ? env["HTTP_X_FORWARDED_FOR"].split(',').pop : env["REMOTE_ADDR"] )
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# 環境変数 HTTP_USER_AGENT を設定する。
|
22
|
+
def user_agent=(str)
|
23
|
+
self.env["HTTP_USER_AGENT"] = str
|
24
|
+
end
|
25
|
+
|
26
|
+
# 携帯電話からであれば +true+を、そうでなければ +false+ を返す。
|
27
|
+
def mobile?
|
28
|
+
mobile != nil
|
29
|
+
end
|
30
|
+
|
31
|
+
# 携帯電話の機種に応じて Mobile::xxx を返す。
|
32
|
+
# 携帯電話でない場合はnilを返す。
|
33
|
+
def mobile
|
34
|
+
return @__mobile if @__mobile
|
35
|
+
|
36
|
+
Jpmobile::Mobile.constants.each do |const|
|
37
|
+
c = Jpmobile::Mobile.const_get(const)
|
38
|
+
return @__mobile = c.new(self) if c::USER_AGENT_REGEXP && user_agent =~ c::USER_AGENT_REGEXP
|
39
|
+
end
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
data/lib/jpmobile/trans_sid.rb
CHANGED
@@ -4,12 +4,50 @@
|
|
4
4
|
# by moriq <moriq@moriq.com>
|
5
5
|
#
|
6
6
|
# cookie support detection inspired by takai http://recompile.net/
|
7
|
+
#
|
8
|
+
# Rails 2.0.2 support is based on the code contributed
|
9
|
+
# by masuidrive <masuidrive (at) masuidrive.jp>
|
10
|
+
|
11
|
+
# FastCGI環境では(どういうわけか) cgi.query_string でクエリ文字列を取得できないので
|
12
|
+
# ENV['QUERY_STRING'] に代入しておく。
|
13
|
+
module ActionController
|
14
|
+
class CgiRequest
|
15
|
+
alias_method :initialize_without_ext, :initialize
|
16
|
+
def initialize(cgi, options = {})
|
17
|
+
initialize_without_ext(cgi, options)
|
18
|
+
ENV['QUERY_STRING'] = query_string
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
7
22
|
|
8
23
|
class ActionController::Base #:nodoc:
|
9
|
-
class_inheritable_accessor :
|
10
|
-
|
11
|
-
|
12
|
-
|
24
|
+
class_inheritable_accessor :trans_sid_mode
|
25
|
+
alias :transit_sid_mode :trans_sid_mode
|
26
|
+
class << self
|
27
|
+
def trans_sid(mode=:mobile)
|
28
|
+
include Jpmobile::TransSid
|
29
|
+
self.trans_sid_mode = mode
|
30
|
+
unless mode == :none
|
31
|
+
# CSRF対策への対策
|
32
|
+
session :cookie_only => false
|
33
|
+
# url/postからsession_keyを取得できるようhookを追加する
|
34
|
+
unless ::CGI::Session.private_method_defined?(:initialize_without_session_key_fixation)
|
35
|
+
::CGI::Session.class_eval do
|
36
|
+
alias_method :initialize_without_session_key_fixation, :initialize
|
37
|
+
def initialize(cgi, options = {})
|
38
|
+
key = options['session_key']
|
39
|
+
if cgi.cookies[key].empty?
|
40
|
+
session_id = (CGI.parse(cgi.env_table['RAW_POST_DATA'])[key] rescue nil) ||
|
41
|
+
(CGI.parse(ENV['QUERY_STRING'] || cgi.query_string)[key] rescue nil)
|
42
|
+
cgi.params[key] = session_id unless session_id.blank?
|
43
|
+
end
|
44
|
+
initialize_without_session_key_fixation(cgi, options)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
alias :transit_sid :trans_sid
|
13
51
|
end
|
14
52
|
end
|
15
53
|
|
@@ -20,9 +58,9 @@ module Jpmobile::TransSid #:nodoc:
|
|
20
58
|
|
21
59
|
protected
|
22
60
|
# URLにsession_idを追加する。
|
23
|
-
def default_url_options(options)
|
61
|
+
def default_url_options(options=nil)
|
24
62
|
return unless request # for test process
|
25
|
-
return unless
|
63
|
+
return unless apply_trans_sid?
|
26
64
|
{ session_key => session.session_id }
|
27
65
|
end
|
28
66
|
|
@@ -35,20 +73,20 @@ module Jpmobile::TransSid #:nodoc:
|
|
35
73
|
end
|
36
74
|
# session_idを埋め込むためのhidden fieldを出力する。
|
37
75
|
def sid_hidden_field_tag
|
38
|
-
"<input type
|
76
|
+
"<input type=\"hidden\" name=\"#{CGI::escapeHTML session_key}\" value=\"#{CGI::escapeHTML session.session_id}\" />"
|
39
77
|
end
|
40
78
|
# formにsession_idを追加する。
|
41
79
|
def append_session_id_parameter
|
42
|
-
return unless request # for test process
|
43
|
-
return unless
|
80
|
+
return unless request # for test process
|
81
|
+
return unless apply_trans_sid?
|
44
82
|
response.body.gsub!(%r{(</form>)}i, sid_hidden_field_tag+'\1')
|
45
83
|
end
|
46
|
-
#
|
47
|
-
def
|
84
|
+
# trans_sidを適用すべきかを返す。
|
85
|
+
def apply_trans_sid?
|
48
86
|
return false unless session_enabled?
|
49
|
-
return false if
|
50
|
-
return true if
|
51
|
-
if
|
87
|
+
return false if trans_sid_mode == :none
|
88
|
+
return true if trans_sid_mode == :always
|
89
|
+
if trans_sid_mode == :mobile
|
52
90
|
if request.mobile?
|
53
91
|
return !request.mobile.supports_cookie?
|
54
92
|
else
|
data/lib/jpmobile/version.rb
CHANGED
data/test/au_test.rb
CHANGED
@@ -3,140 +3,171 @@ require File.dirname(__FILE__)+'/helper'
|
|
3
3
|
class AuTest < Test::Unit::TestCase
|
4
4
|
# au, 端末種別の識別
|
5
5
|
def test_au_ca32
|
6
|
-
|
6
|
+
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
7
7
|
"HTTP_X_UP_SUBNO"=>"00000000000000_mj.ezweb.ne.jp")
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
reqs.each do |req|
|
9
|
+
assert_equal(true, req.mobile?)
|
10
|
+
assert_instance_of(Jpmobile::Mobile::Au, req.mobile)
|
11
|
+
assert_equal("00000000000000_mj.ezweb.ne.jp", req.mobile.subno)
|
12
|
+
assert_equal("00000000000000_mj.ezweb.ne.jp", req.mobile.ident)
|
13
|
+
assert_equal("00000000000000_mj.ezweb.ne.jp", req.mobile.ident_subscriber)
|
14
|
+
assert_equal(nil, req.mobile.position)
|
15
|
+
assert(req.mobile.supports_cookie?)
|
16
|
+
end
|
15
17
|
end
|
16
18
|
|
17
19
|
# TuKa, 端末種別の識別
|
18
20
|
def test_tuka_tk22
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
reqs = request_with_ua("UP.Browser/3.04-KCTA UP.Link/3.4.5.9")
|
22
|
+
reqs.each do |req|
|
23
|
+
assert_equal(true, req.mobile?)
|
24
|
+
assert_instance_of(Jpmobile::Mobile::Au, req.mobile)
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
# au, gps, degree, wgs84
|
25
29
|
def test_au_gps_degree
|
26
|
-
|
30
|
+
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
27
31
|
{"QUERY_STRING"=>"ver=1&datum=0&unit=1&lat=%2b43.07772&lon=%2b141.34114&alt=64&time=20061016192415&smaj=69&smin=18&vert=21&majaa=115&fm=1"})
|
28
|
-
|
29
|
-
|
32
|
+
reqs.each do |req|
|
33
|
+
assert_equal(43.07772, req.mobile.position.lat)
|
34
|
+
assert_equal(141.34114, req.mobile.position.lon)
|
35
|
+
end
|
30
36
|
end
|
31
37
|
|
32
38
|
# au, gps, dms, wgs84
|
33
39
|
# これが一番端末を選ばないようだ
|
34
40
|
# http://hiyuzawa.jpn.org/blog/2006/09/gps1_augps_1.html
|
35
41
|
def test_au_gps_dms
|
36
|
-
|
42
|
+
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
37
43
|
{"QUERY_STRING"=>"ver=1&datum=0&unit=0&lat=%2b43.05.08.95&lon=%2b141.20.25.99&alt=155&time=20060521010328&smaj=76&smin=62&vert=65&majaa=49&fm=1"})
|
38
|
-
|
39
|
-
|
44
|
+
reqs.each do |req|
|
45
|
+
assert_in_delta(43.08581944, req.mobile.position.lat, 1e-7)
|
46
|
+
assert_in_delta(141.3405528, req.mobile.position.lon, 1e-7)
|
47
|
+
end
|
40
48
|
end
|
41
49
|
|
42
50
|
# au, gps, degree, tokyo
|
43
51
|
def test_au_gps_degree_tokyo
|
44
|
-
|
52
|
+
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
45
53
|
{"QUERY_STRING"=>"ver=1&datum=1&unit=1&lat=%2b43.07475&lon=%2b141.34259&alt=8&time=20061017182825&smaj=113&smin=76&vert=72&majaa=108&fm=1"})
|
46
|
-
|
47
|
-
|
54
|
+
reqs.each do |req|
|
55
|
+
assert_in_delta(43.07719289, req.mobile.position.lat, 1e-4)
|
56
|
+
assert_in_delta(141.3389013, req.mobile.position.lon, 1e-4)
|
57
|
+
end
|
48
58
|
end
|
49
59
|
|
50
60
|
# au, gps, dms, tokyo
|
51
61
|
def test_au_gps_dms_tokyo
|
52
|
-
|
62
|
+
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
53
63
|
{"QUERY_STRING"=>"ver=1&datum=1&unit=0&lat=%2b43.04.28.26&lon=%2b141.20.33.15&alt=-5&time=20061017183807&smaj=52&smin=36&vert=31&majaa=101&fm=1"})
|
54
|
-
|
55
|
-
|
64
|
+
reqs.each do |req|
|
65
|
+
assert_in_delta(43.07695833, req.mobile.position.lat, 1e-4)
|
66
|
+
assert_in_delta(141.3388528, req.mobile.position.lon, 1e-4)
|
67
|
+
end
|
56
68
|
end
|
57
69
|
|
58
70
|
# au, antenna, dms (au簡易位置情報)
|
59
71
|
def test_au_antenna
|
60
|
-
|
72
|
+
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
61
73
|
{"QUERY_STRING"=>"datum=tokyo&unit=dms&lat=43.04.55.00&lon=141.20.50.75"})
|
62
|
-
|
63
|
-
|
74
|
+
reqs.each do |req|
|
75
|
+
assert_in_delta(43.08194444, req.mobile.position.lat, 1e-7)
|
76
|
+
assert_in_delta(141.3474306, req.mobile.position.lon, 1e-7)
|
77
|
+
end
|
64
78
|
end
|
65
79
|
|
66
80
|
# 正しいIPアドレス空間からのアクセスを判断できるか。
|
67
81
|
def test_au_valid_ip_address
|
68
|
-
|
82
|
+
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
69
83
|
{"REMOTE_ADDR"=>"210.169.40.1"})
|
70
|
-
|
84
|
+
reqs.each do |req|
|
85
|
+
assert_equal(req.mobile.valid_ip?, true)
|
86
|
+
end
|
71
87
|
end
|
72
88
|
|
73
89
|
# 正しくないIPアドレス空間からのアクセスを判断できるか。
|
74
90
|
def test_au_invalid_ip_address
|
75
|
-
|
91
|
+
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
76
92
|
{"REMOTE_ADDR"=>"127.0.0.1"})
|
77
|
-
|
93
|
+
reqs.each do |req|
|
94
|
+
assert_equal(req.mobile.valid_ip?, false)
|
95
|
+
end
|
78
96
|
end
|
79
97
|
|
80
98
|
# 端末の画面サイズを正しく取得できるか。
|
81
99
|
def test_au_w41ca_display
|
82
|
-
|
100
|
+
reqs = request_with_ua("KDDI-CA33 UP.Browser/6.2.0.10.4 (GUI) MMP/2.0",
|
83
101
|
"HTTP_X_UP_DEVCAP_SCREENDEPTH"=>"16,RGB565",
|
84
102
|
"HTTP_X_UP_DEVCAP_SCREENPIXELS"=>"240,346",
|
85
103
|
"HTTP_X_UP_DEVCAP_ISCOLOR"=>"1"
|
86
104
|
)
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
105
|
+
|
106
|
+
reqs.each do |req|
|
107
|
+
assert_equal(240, req.mobile.display.width)
|
108
|
+
assert_equal(346, req.mobile.display.height)
|
109
|
+
assert_equal(true, req.mobile.display.color?)
|
110
|
+
assert_equal(65536, req.mobile.display.colors)
|
111
|
+
end
|
91
112
|
end
|
92
113
|
|
93
114
|
# 端末の画面情報が渡ってない場合に正しく動作するか。
|
94
115
|
def test_au_w41ca_display_information_omitted
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
116
|
+
reqs = request_with_ua("KDDI-CA33 UP.Browser/6.2.0.10.4 (GUI) MMP/2.0")
|
117
|
+
reqs.each do |req|
|
118
|
+
assert_equal(nil, req.mobile.display.width)
|
119
|
+
assert_equal(nil, req.mobile.display.height)
|
120
|
+
assert_equal(nil, req.mobile.display.browser_width)
|
121
|
+
assert_equal(nil, req.mobile.display.browser_height)
|
122
|
+
assert_equal(nil, req.mobile.display.physical_width)
|
123
|
+
assert_equal(nil, req.mobile.display.physical_height)
|
124
|
+
assert_equal(nil, req.mobile.display.color?)
|
125
|
+
assert_equal(nil, req.mobile.display.colors)
|
126
|
+
end
|
104
127
|
end
|
105
128
|
|
106
129
|
# for GeoKit::Mappable
|
107
130
|
def test_au_gps_degree_geokit
|
108
|
-
|
131
|
+
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
109
132
|
{"QUERY_STRING"=>"ver=1&datum=0&unit=1&lat=%2b43.07772&lon=%2b141.34114&alt=64&time=20061016192415&smaj=69&smin=18&vert=21&majaa=115&fm=1"})
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
133
|
+
reqs.each do |req|
|
134
|
+
assert_equal(43.07772, req.mobile.position.lat)
|
135
|
+
assert_equal(141.34114, req.mobile.position.lng)
|
136
|
+
assert_equal("43.07772,141.34114", req.mobile.position.ll)
|
137
|
+
assert_equal(req.mobile.position, req.mobile.position)
|
138
|
+
if req.mobile.position.respond_to?(:distance_to) # GeoKitがインストールされている場合
|
139
|
+
assert_equal(0, req.mobile.position.distance_to(req.mobile.position))
|
140
|
+
end
|
116
141
|
end
|
117
142
|
end
|
118
143
|
|
119
144
|
# 位置情報取得機能の有無, W31CA
|
120
145
|
def test_au_location_capability_w31ca
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
146
|
+
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0")
|
147
|
+
reqs.each do |req|
|
148
|
+
assert_equal("CA32", req.mobile.device_id)
|
149
|
+
assert_equal(true, req.mobile.supports_location?)
|
150
|
+
assert_equal(true, req.mobile.supports_gps?)
|
151
|
+
end
|
125
152
|
end
|
126
153
|
|
127
154
|
# 位置情報取得機能の有無, A1402S
|
128
155
|
def test_au_location_capability_a1402s
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
156
|
+
reqs = request_with_ua("KDDI-SN26 UP.Browser/6.2.0.6.2 (GUI) MMP/2.0")
|
157
|
+
reqs.each do |req|
|
158
|
+
assert_equal("SN26", req.mobile.device_id)
|
159
|
+
assert_equal(true, req.mobile.supports_location?)
|
160
|
+
assert_equal(false, req.mobile.supports_gps?)
|
161
|
+
end
|
133
162
|
end
|
134
163
|
|
135
164
|
# 位置情報取得機能の有無, TK22
|
136
165
|
def test_au_location_capability_tk22
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
166
|
+
reqs = request_with_ua("UP.Browser/3.04-KCTA UP.Link/3.4.5.9")
|
167
|
+
reqs.each do |req|
|
168
|
+
assert_equal("KCTA", req.mobile.device_id)
|
169
|
+
assert_equal(false, req.mobile.supports_location?)
|
170
|
+
assert_equal(false, req.mobile.supports_gps?)
|
171
|
+
end
|
141
172
|
end
|
142
173
|
end
|