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
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
module Jpmobile
|
3
|
+
module Mobile
|
4
|
+
require 'jpmobile/mobile/abstract_mobile'
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class TestAutoLoad < Test::Unit::TestCase
|
9
|
+
def test_ip_addresses_docomo
|
10
|
+
require 'jpmobile/mobile/docomo'
|
11
|
+
assert_nothing_raised { Jpmobile::Mobile::Docomo::IP_ADDRESSES }
|
12
|
+
assert_kind_of(Array, Jpmobile::Mobile::Docomo::IP_ADDRESSES)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_display_info_docomo
|
16
|
+
require 'jpmobile/mobile/docomo'
|
17
|
+
assert_nothing_raised { Jpmobile::Mobile::Docomo::DISPLAY_INFO }
|
18
|
+
assert_kind_of(Hash, Jpmobile::Mobile::Docomo::DISPLAY_INFO)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_ip_addresses_au
|
22
|
+
require 'jpmobile/mobile/au'
|
23
|
+
assert_nothing_raised { Jpmobile::Mobile::Au::IP_ADDRESSES }
|
24
|
+
assert_kind_of(Array, Jpmobile::Mobile::Au::IP_ADDRESSES)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_ip_addresses_softbank
|
28
|
+
require 'jpmobile/mobile/softbank'
|
29
|
+
assert_nothing_raised { Jpmobile::Mobile::Softbank::IP_ADDRESSES }
|
30
|
+
assert_nothing_raised { Jpmobile::Mobile::Vodafone::IP_ADDRESSES }
|
31
|
+
assert_nothing_raised { Jpmobile::Mobile::Jphone::IP_ADDRESSES }
|
32
|
+
assert_kind_of(Array, Jpmobile::Mobile::Softbank::IP_ADDRESSES)
|
33
|
+
assert_kind_of(Array, Jpmobile::Mobile::Vodafone::IP_ADDRESSES)
|
34
|
+
assert_kind_of(Array, Jpmobile::Mobile::Jphone::IP_ADDRESSES)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_ip_addresses_willcom
|
38
|
+
require 'jpmobile/mobile/willcom'
|
39
|
+
assert_nothing_raised { Jpmobile::Mobile::Willcom::IP_ADDRESSES }
|
40
|
+
assert_kind_of(Array, Jpmobile::Mobile::Willcom::IP_ADDRESSES)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_ip_addresses_emobile
|
44
|
+
require 'jpmobile/mobile/emobile'
|
45
|
+
assert_nothing_raised { Jpmobile::Mobile::Emobile::IP_ADDRESSES }
|
46
|
+
assert_kind_of(Array, Jpmobile::Mobile::Emobile::IP_ADDRESSES)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/test/docomo_test.rb
CHANGED
@@ -3,113 +3,146 @@ require File.dirname(__FILE__)+'/helper'
|
|
3
3
|
class DocomoTest < Test::Unit::TestCase
|
4
4
|
# DoCoMo, 端末種別の識別
|
5
5
|
def test_docomo_sh902i
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
reqs = request_with_ua("DoCoMo/2.0 SH902i(c100;TB;W24H12)")
|
7
|
+
reqs.each do |req|
|
8
|
+
assert_equal(true, req.mobile?)
|
9
|
+
assert_instance_of(Jpmobile::Mobile::Docomo, req.mobile)
|
10
|
+
assert_equal(nil, req.mobile.position)
|
11
|
+
assert_equal(nil, req.mobile.areacode)
|
12
|
+
assert_equal(nil, req.mobile.serial_number)
|
13
|
+
assert_equal(nil, req.mobile.icc)
|
14
|
+
assert_equal(nil, req.mobile.ident)
|
15
|
+
assert_equal(nil, req.mobile.ident_device)
|
16
|
+
assert_equal(nil, req.mobile.ident_subscriber)
|
17
|
+
assert(!req.mobile.supports_cookie?)
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
21
|
# DoCoMo, 端末種別の識別
|
20
22
|
def test_docomo_so506i
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
reqs = request_with_ua("DoCoMo/1.0/SO506iC/c20/TB/W20H10")
|
24
|
+
reqs.each do |req|
|
25
|
+
assert_equal(true, req.mobile?)
|
26
|
+
assert_instance_of(Jpmobile::Mobile::Docomo, req.mobile)
|
27
|
+
assert_equal(nil, req.mobile.position)
|
28
|
+
assert_equal(nil, req.mobile.areacode)
|
29
|
+
assert_equal(nil, req.mobile.serial_number)
|
30
|
+
assert_equal(nil, req.mobile.icc)
|
31
|
+
assert_equal(nil, req.mobile.ident)
|
32
|
+
assert_equal(nil, req.mobile.ident_device)
|
33
|
+
assert_equal(nil, req.mobile.ident_subscriber)
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
# DoCoMo, iarea
|
34
38
|
def test_docomo_iarea
|
35
|
-
|
39
|
+
reqs = request_with_ua("DoCoMo/1.0/SO506iC/c20/TB/W20H10",
|
36
40
|
{"QUERY_STRING"=>"AREACODE=00100&ACTN=OK"})
|
37
|
-
|
41
|
+
reqs.each do |req|
|
42
|
+
assert_equal("00100", req.mobile.areacode)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# DoCoMo, iarea
|
47
|
+
def test_docomo_iarea_with_posinfo
|
48
|
+
reqs = request_with_ua("DoCoMo/1.0/SO506iC/c20/TB/W20H10",
|
49
|
+
{"QUERY_STRING"=>"LAT=%2B35.00.35.600&LON=%2B135.41.35.600&GEO=wgs84&POSINFO=2&AREACODE=00100&ACTN=OK"})
|
50
|
+
reqs.each do |req|
|
51
|
+
assert_equal("00100", req.mobile.areacode)
|
52
|
+
assert_in_delta(35.00988889, req.mobile.position.lat, 1e-7)
|
53
|
+
assert_in_delta(135.6932222, req.mobile.position.lon, 1e-7)
|
54
|
+
end
|
38
55
|
end
|
39
56
|
|
40
57
|
# DoCoMo, gps
|
41
58
|
# http://www.nttdocomo.co.jp/service/imode/make/content/html/outline/gps.html
|
42
59
|
def test_docomo_gps_sa702i
|
43
|
-
|
60
|
+
reqs = request_with_ua("DoCoMo/2.0 SA702i(c100;TB;W30H15)",
|
44
61
|
{"QUERY_STRING"=>"lat=%2B35.00.35.600&lon=%2B135.41.35.600&geo=wgs84&x-acc=3"})
|
45
|
-
|
46
|
-
|
62
|
+
reqs.each do |req|
|
63
|
+
assert_in_delta(35.00988889, req.mobile.position.lat, 1e-7)
|
64
|
+
assert_in_delta(135.6932222, req.mobile.position.lon, 1e-7)
|
65
|
+
end
|
47
66
|
end
|
48
67
|
|
49
68
|
# DoCoMo, 903i, GPS
|
50
69
|
# "WGS84"が大文字。altで高度が取得できているようだ。どちらも仕様書には記述がない。
|
51
70
|
# http://www.nttdocomo.co.jp/service/imode/make/content/html/outline/gps.html
|
52
71
|
def test_docomo_gps_sh903i
|
53
|
-
|
72
|
+
reqs = request_with_ua("DoCoMo/2.0 SH903i(c100;TB;W24H16)",
|
54
73
|
{"QUERY_STRING"=>
|
55
74
|
"lat=%2B35.00.35.600&lon=%2B135.41.35.600&geo=WGS84&alt=%2B64.000&x-acc=1"})
|
56
|
-
|
57
|
-
|
75
|
+
reqs.each do |req|
|
76
|
+
assert_in_delta(35.00988889, req.mobile.position.lat, 1e-7)
|
77
|
+
assert_in_delta(135.6932222, req.mobile.position.lon, 1e-7)
|
78
|
+
end
|
58
79
|
end
|
59
80
|
|
60
81
|
# DoCoMo, utn, mova
|
61
82
|
def test_docomo_utn_mova
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
83
|
+
reqs = request_with_ua("DoCoMo/1.0/SO505iS/c20/TC/W30H16/serXXXXX000000")
|
84
|
+
reqs.each do |req|
|
85
|
+
assert_equal("XXXXX000000", req.mobile.serial_number)
|
86
|
+
assert_equal("XXXXX000000", req.mobile.ident)
|
87
|
+
assert_equal(nil, req.mobile.icc)
|
88
|
+
assert_equal("XXXXX000000", req.mobile.ident_device)
|
89
|
+
assert_equal(nil, req.mobile.ident_subscriber)
|
90
|
+
end
|
68
91
|
end
|
69
92
|
|
70
93
|
# DoCoMo, utn, foma
|
71
94
|
def test_docomo_utn_foma
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
95
|
+
reqs = request_with_ua("DoCoMo/2.0 D902i(c100;TB;W23H16;ser999999999999999;icc0000000000000000000f)")
|
96
|
+
reqs.each do |req|
|
97
|
+
assert_equal("999999999999999", req.mobile.serial_number)
|
98
|
+
assert_equal("0000000000000000000f", req.mobile.icc)
|
99
|
+
assert_equal("0000000000000000000f", req.mobile.ident)
|
100
|
+
assert_equal("999999999999999", req.mobile.ident_device)
|
101
|
+
assert_equal("0000000000000000000f", req.mobile.ident_subscriber)
|
102
|
+
end
|
78
103
|
end
|
79
104
|
|
80
105
|
# 正しいIPアドレス空間からのアクセスを判断できるか。
|
81
106
|
def test_docomo_valid_ip_address
|
82
|
-
|
107
|
+
reqs = request_with_ua("DoCoMo/2.0 SH902i(c100;TB;W24H12)",
|
83
108
|
{"REMOTE_ADDR"=>"210.153.84.1"})
|
84
|
-
|
109
|
+
reqs.each do |req|
|
110
|
+
assert_equal(true, req.mobile.valid_ip?)
|
111
|
+
end
|
85
112
|
end
|
86
113
|
|
87
114
|
# 正しくないIPアドレス空間からのアクセスを判断できるか。
|
88
115
|
def test_docomo_invalid_ip_address
|
89
|
-
|
116
|
+
reqs = request_with_ua("DoCoMo/2.0 SH902i(c100;TB;W24H12)",
|
90
117
|
{"REMOTE_ADDR"=>"127.0.0.1"})
|
91
|
-
|
118
|
+
reqs.each do |req|
|
119
|
+
assert_equal(false, req.mobile.valid_ip?)
|
120
|
+
end
|
92
121
|
end
|
93
122
|
|
94
123
|
# 端末の画面サイズを正しく取得できるか。
|
95
124
|
def test_docomo_so506ic_display
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
125
|
+
reqs = request_with_ua("DoCoMo/1.0/SO506iC/c20/TB/W20H10")
|
126
|
+
reqs.each do |req|
|
127
|
+
assert_equal(240, req.mobile.display.browser_width)
|
128
|
+
assert_equal(256, req.mobile.display.browser_height)
|
129
|
+
assert_equal(240, req.mobile.display.width)
|
130
|
+
assert_equal(256, req.mobile.display.height)
|
131
|
+
assert_equal(true, req.mobile.display.color?)
|
132
|
+
assert_equal(262144, req.mobile.display.colors)
|
133
|
+
end
|
103
134
|
end
|
104
135
|
|
105
136
|
# 端末の画面サイズを正しく取得できるか。
|
106
137
|
def test_docomo_sh902i_display
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
138
|
+
reqs = request_with_ua("DoCoMo/2.0 SH902i(c100;TB;W24H12)")
|
139
|
+
reqs.each do |req|
|
140
|
+
assert_equal(240, req.mobile.display.browser_width)
|
141
|
+
assert_equal(240, req.mobile.display.browser_height)
|
142
|
+
assert_equal(240, req.mobile.display.width)
|
143
|
+
assert_equal(240, req.mobile.display.height)
|
144
|
+
assert_equal(true, req.mobile.display.color?)
|
145
|
+
assert_equal(262144, req.mobile.display.colors)
|
146
|
+
end
|
114
147
|
end
|
115
148
|
end
|
@@ -33,13 +33,16 @@ class EmoticonFunctionalTest < Test::Unit::TestCase
|
|
33
33
|
def setup
|
34
34
|
init EmoticonTestController
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
|
+
def test_docomo_from_pc
|
37
38
|
# PC
|
38
39
|
get :docomo_cr
|
39
40
|
assert_equal "", @response.body
|
40
41
|
get :docomo_utf8
|
41
42
|
assert_equal "\xee\x98\xbe", @response.body
|
43
|
+
end
|
42
44
|
|
45
|
+
def test_docomo_from_docomo
|
43
46
|
# DoCoMo携帯
|
44
47
|
user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
45
48
|
get :docomo_cr
|
@@ -52,7 +55,9 @@ class EmoticonFunctionalTest < Test::Unit::TestCase
|
|
52
55
|
|
53
56
|
get :docomo_docomopoint
|
54
57
|
assert_equal "\xf9\x79", @response.body
|
58
|
+
end
|
55
59
|
|
60
|
+
def test_docomo_from_au
|
56
61
|
# Au携帯電話での閲覧
|
57
62
|
user_agent "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
|
58
63
|
get :docomo_cr
|
@@ -61,7 +66,9 @@ class EmoticonFunctionalTest < Test::Unit::TestCase
|
|
61
66
|
assert_equal "\xf6\x60", @response.body
|
62
67
|
get :docomo_docomopoint
|
63
68
|
assert_equal "[ドコモポイント]".tosjis, @response.body
|
69
|
+
end
|
64
70
|
|
71
|
+
def test_docomo_from_softbank
|
65
72
|
# SoftBank携帯電話での閲覧
|
66
73
|
user_agent "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
|
67
74
|
get :docomo_cr
|
@@ -70,7 +77,9 @@ class EmoticonFunctionalTest < Test::Unit::TestCase
|
|
70
77
|
assert_equal "\e$Gj\x0f", @response.body
|
71
78
|
get :docomo_docomopoint
|
72
79
|
assert_equal "[ドコモポイント]", @response.body
|
80
|
+
end
|
73
81
|
|
82
|
+
def test_docomo_from_jphone
|
74
83
|
# J-PHONE携帯電話での閲覧
|
75
84
|
user_agent "J-PHONE/3.0/V301D"
|
76
85
|
get :docomo_cr
|
@@ -81,13 +90,16 @@ class EmoticonFunctionalTest < Test::Unit::TestCase
|
|
81
90
|
assert_equal "Shift_JIS", @response.charset
|
82
91
|
assert_equal "[ドコモポイント]".tosjis, @response.body
|
83
92
|
end
|
84
|
-
|
93
|
+
|
94
|
+
def test_au_from_pc
|
85
95
|
# PC
|
86
96
|
get :au_cr
|
87
97
|
assert_equal "", @response.body
|
88
98
|
get :au_utf8
|
89
99
|
assert_equal [0xe488].pack("U"), @response.body
|
100
|
+
end
|
90
101
|
|
102
|
+
def test_au_from_au
|
91
103
|
# Au
|
92
104
|
user_agent "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
|
93
105
|
get :au_cr
|
@@ -97,14 +109,18 @@ class EmoticonFunctionalTest < Test::Unit::TestCase
|
|
97
109
|
get :query, :q=>"\xf6\x60"
|
98
110
|
assert_equal [0xe488].pack("U"), assigns["q"]
|
99
111
|
assert_equal "\xf6\x60", @response.body
|
112
|
+
end
|
100
113
|
|
114
|
+
def test_au_from_docomo
|
101
115
|
# DoCoMo携帯電話での閲覧
|
102
116
|
user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
103
117
|
get :au_cr
|
104
118
|
assert_equal "\xf8\x9f", @response.body
|
105
119
|
get :au_utf8
|
106
120
|
assert_equal "\xf8\x9f", @response.body
|
121
|
+
end
|
107
122
|
|
123
|
+
def test_au_from_softbank
|
108
124
|
# SoftBank携帯電話での閲覧
|
109
125
|
user_agent "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
|
110
126
|
get :au_cr
|
@@ -112,13 +128,16 @@ class EmoticonFunctionalTest < Test::Unit::TestCase
|
|
112
128
|
get :au_utf8
|
113
129
|
assert_equal "\e$Gj\x0f", @response.body
|
114
130
|
end
|
115
|
-
|
131
|
+
|
132
|
+
def test_softbank_from_pc
|
116
133
|
# PCから
|
117
134
|
get :softbank_cr
|
118
135
|
assert_equal "", @response.body
|
119
136
|
get :softbank_utf8
|
120
137
|
assert_equal [0xf04a].pack("U"), @response.body
|
138
|
+
end
|
121
139
|
|
140
|
+
def test_softbank_from_softbank
|
122
141
|
# SoftBank携帯電話から
|
123
142
|
user_agent "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
|
124
143
|
get :softbank_cr
|
@@ -128,7 +147,9 @@ class EmoticonFunctionalTest < Test::Unit::TestCase
|
|
128
147
|
get :query, :q=>[0xe04A].pack("U") # 3G端末はUTF-8で絵文字を送ってくる
|
129
148
|
assert_equal [0xf04a].pack("U"), assigns["q"]
|
130
149
|
assert_equal "\e$Gj\x0f", @response.body
|
150
|
+
end
|
131
151
|
|
152
|
+
def test_softbank_from_vodafone3g
|
132
153
|
# Vodafone3G携帯電話から
|
133
154
|
user_agent "Vodafone/1.0/V705SH/SHJ001/SN000000000000000 Browser/VF-NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
|
134
155
|
get :softbank_cr
|
@@ -138,7 +159,9 @@ class EmoticonFunctionalTest < Test::Unit::TestCase
|
|
138
159
|
get :query, :q=>[0xe04A].pack("U") # 3G端末はUTF-8で絵文字を送ってくる
|
139
160
|
assert_equal [0xf04a].pack("U"), assigns["q"]
|
140
161
|
assert_equal "\e$Gj\x0f", @response.body
|
162
|
+
end
|
141
163
|
|
164
|
+
def test_softbank_from_jphone
|
142
165
|
# J-PHONE携帯電話から
|
143
166
|
user_agent "J-PHONE/3.0/V301D"
|
144
167
|
get :softbank_cr
|
@@ -148,14 +171,18 @@ class EmoticonFunctionalTest < Test::Unit::TestCase
|
|
148
171
|
get :query, :q=>"\e$Gj\x0f" # J-PHONE端末はWebcodeで絵文字を送ってくる
|
149
172
|
assert_equal [0xf04a].pack("U"), assigns["q"]
|
150
173
|
assert_equal "\e$Gj\x0f", @response.body
|
174
|
+
end
|
151
175
|
|
176
|
+
def test_softbank_from_docomo
|
152
177
|
# DoCoMo携帯電話での閲覧
|
153
178
|
user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
154
179
|
get :softbank_cr
|
155
180
|
assert_equal "\xf8\x9f", @response.body
|
156
181
|
get :softbank_utf8
|
157
182
|
assert_equal "\xf8\x9f", @response.body
|
183
|
+
end
|
158
184
|
|
185
|
+
def test_softbank_from_au
|
159
186
|
# Au携帯電話での閲覧
|
160
187
|
user_agent "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
|
161
188
|
get :softbank_cr
|
data/test/filter_test.rb
CHANGED
@@ -2,9 +2,6 @@ require File.dirname(__FILE__)+'/helper'
|
|
2
2
|
|
3
3
|
class FilterTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@controller = ActionController::Base.new
|
6
|
-
@controller.response = ActionController::AbstractResponse.new
|
7
|
-
|
8
5
|
@aiu_sjis = "\202\240\202\242\202\244" # あいう
|
9
6
|
@aiu_utf8 = "\343\201\202\343\201\204\343\201\206" # あいう
|
10
7
|
|
@@ -32,65 +29,4 @@ class FilterTest < Test::Unit::TestCase
|
|
32
29
|
assert_equal(@abracadabra_z_utf8, filter.to_internal(@abracadabra_h_utf8, nil))
|
33
30
|
assert_equal(@abracadabra_h_utf8, filter.to_external(@abracadabra_z_utf8, nil))
|
34
31
|
end
|
35
|
-
def test_sjis_filter_for_docomo
|
36
|
-
@controller.request = request_with_ua("DoCoMo/2.0 SH902i(c100;TB;W24H12)", "QUERY_STRING"=>"test=test&abra=%83A%83u%83%89%83J%83_%83u%83%89") # アブラカダブラ, Shift_JIS, urlencoded
|
37
|
-
@controller.params = @controller.request.params
|
38
|
-
|
39
|
-
# before filter のテスト(携帯電話からのパラメータがutf-8で格納されているか)
|
40
|
-
filter = Jpmobile::Filter::Sjis.new
|
41
|
-
filter.before(@controller)
|
42
|
-
assert_equal(@abracadabra_z_utf8, @controller.params["abra"].first)
|
43
|
-
|
44
|
-
# after filter のテスト(携帯電話に向けてsjisで送出しているか)
|
45
|
-
@controller.response.body = @abracadabra_z_utf8
|
46
|
-
filter.after(@controller)
|
47
|
-
assert_equal('Shift_JIS', @controller.response.charset)
|
48
|
-
assert_equal(@abracadabra_z_sjis, @controller.response.body)
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_sjis_filter_for_jphone
|
52
|
-
@controller.request = request_with_ua("J-PHONE/3.0/V401SH", "QUERY_STRING"=>"test=test&abra=%83A%83u%83%89%83J%83_%83u%83%89") # アブラカダブラ, Shift_JIS, urlencoded
|
53
|
-
@controller.params = @controller.request.params
|
54
|
-
|
55
|
-
# before filter のテスト(携帯電話からのパラメータがutf-8で格納されているか)
|
56
|
-
filter = Jpmobile::Filter::Sjis.new
|
57
|
-
filter.before(@controller)
|
58
|
-
assert_equal(@abracadabra_z_utf8, @controller.params["abra"].first)
|
59
|
-
|
60
|
-
# after filter のテスト(携帯電話に向けてsjisで送出しているか)
|
61
|
-
@controller.response.body = @abracadabra_z_utf8
|
62
|
-
filter.after(@controller)
|
63
|
-
assert_equal('Shift_JIS', @controller.response.charset)
|
64
|
-
assert_equal(@abracadabra_z_sjis, @controller.response.body)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_sjis_filter_does_not_work_for_vodafone
|
68
|
-
# VodafoneにはShift_JIS変換を行わないことをテスト
|
69
|
-
@controller.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", "QUERY_STRING"=>"test=test&abra=%83A%83u%83%89%83J%83_%83u%83%89") # アブラカダブラ, Shift_JIS, urlencoded
|
70
|
-
@controller.params = @controller.request.params
|
71
|
-
|
72
|
-
filter = Jpmobile::Filter::Sjis.new
|
73
|
-
filter.before(@controller) # 実行しておかないとカウンタが狂う
|
74
|
-
|
75
|
-
# after filter のテスト(携帯電話に向けてsjisで送出していないことを確認)
|
76
|
-
filter.after(@controller)
|
77
|
-
@controller.response.body = @abracadabra_z_utf8
|
78
|
-
assert_not_equal('Shift_JIS', @controller.response.charset)
|
79
|
-
assert_equal(@abracadabra_z_utf8, @controller.response.body)
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_sjis_filter_does_not_work_for_softbank
|
83
|
-
# VodafoneにはShift_JIS変換を行わないことをテスト
|
84
|
-
@controller.request = request_with_ua("SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1", "QUERY_STRING"=>"test=test&abra=%83A%83u%83%89%83J%83_%83u%83%89") # アブラカダブラ, Shift_JIS, urlencoded
|
85
|
-
@controller.params = @controller.request.params
|
86
|
-
|
87
|
-
filter = Jpmobile::Filter::Sjis.new
|
88
|
-
filter.before(@controller) # 実行しておかないとカウンタが狂う
|
89
|
-
|
90
|
-
# after filter のテスト(携帯電話に向けてsjisで送出していないことを確認)
|
91
|
-
filter.after(@controller)
|
92
|
-
@controller.response.body = @abracadabra_z_utf8
|
93
|
-
assert_not_equal('Shift_JIS', @controller.response.charset)
|
94
|
-
assert_equal(@abracadabra_z_utf8, @controller.response.body)
|
95
|
-
end
|
96
32
|
end
|