jpmobile 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/README +41 -4
  2. data/Rakefile +11 -9
  3. data/lib/jpmobile.rb +0 -6
  4. data/lib/jpmobile/emoticon.rb +105 -0
  5. data/lib/jpmobile/emoticon/au.rb +644 -0
  6. data/lib/jpmobile/emoticon/conversion_table.rb +3908 -0
  7. data/lib/jpmobile/emoticon/docomo.rb +255 -0
  8. data/lib/jpmobile/emoticon/softbank.rb +477 -0
  9. data/lib/jpmobile/emoticon/z_combine.rb +20 -0
  10. data/lib/jpmobile/filter.rb +73 -51
  11. data/lib/jpmobile/helpers.rb +4 -4
  12. data/lib/jpmobile/hook_abstract_request.rb +6 -2
  13. data/lib/jpmobile/hook_action_controller.rb +10 -0
  14. data/lib/jpmobile/hook_action_view.rb +7 -0
  15. data/lib/jpmobile/mobile/abstract_mobile.rb +5 -1
  16. data/lib/jpmobile/mobile/au.rb +1 -1
  17. data/lib/jpmobile/mobile/docomo.rb +2 -5
  18. data/lib/jpmobile/mobile/softbank.rb +9 -1
  19. data/lib/jpmobile/mobile/z_display_info_docomo.rb +32 -10
  20. data/lib/jpmobile/mobile/z_ip_addresses.rb +6 -6
  21. data/lib/jpmobile/mobile/z_ip_addresses_au.rb +2 -1
  22. data/lib/jpmobile/mobile/z_ip_addresses_willcom.rb +6 -1
  23. data/lib/jpmobile/trans_sid.rb +5 -2
  24. data/lib/jpmobile/version.rb +1 -1
  25. data/test/au_test.rb +1 -0
  26. data/test/docomo_test.rb +8 -0
  27. data/test/emoticon_functional_test.rb +166 -0
  28. data/test/emoticon_test.rb +58 -0
  29. data/test/filter_functional_test.rb +146 -0
  30. data/test/filter_test.rb +8 -8
  31. data/test/softbank_test.rb +18 -0
  32. data/tools/generate_au_emoticon_table.rb +25 -0
  33. data/tools/{update_emoji_docomo.rb → generate_docomo_emoticon_table.rb} +4 -8
  34. data/tools/generate_emoticon_conversion_table.rb +107 -0
  35. data/tools/generate_softbank_emoticon_table.rb +32 -0
  36. data/tools/update_display_info_docomo.rb +3 -5
  37. metadata +18 -75
  38. data/NOTES +0 -21
  39. data/TODO +0 -16
  40. data/doc/classes/ActionController.html +0 -107
  41. data/doc/classes/ActionController/AbstractRequest.html +0 -216
  42. data/doc/classes/ActionView.html +0 -101
  43. data/doc/classes/DatumConv.html +0 -324
  44. data/doc/classes/Jpmobile/Display.html +0 -333
  45. data/doc/classes/Jpmobile/Filter.html +0 -119
  46. data/doc/classes/Jpmobile/Filter/Base.html +0 -269
  47. data/doc/classes/Jpmobile/Filter/Emoji.html +0 -130
  48. data/doc/classes/Jpmobile/Filter/Emoji/Inner.html +0 -183
  49. data/doc/classes/Jpmobile/Filter/Emoji/Outer.html +0 -187
  50. data/doc/classes/Jpmobile/Filter/FilterTable.html +0 -178
  51. data/doc/classes/Jpmobile/Filter/HankakuKana.html +0 -170
  52. data/doc/classes/Jpmobile/Filter/Sjis.html +0 -244
  53. data/doc/classes/Jpmobile/Helpers.html +0 -558
  54. data/doc/classes/Jpmobile/Mobile.html +0 -141
  55. data/doc/classes/Jpmobile/Mobile/AbstractMobile.html +0 -324
  56. data/doc/classes/Jpmobile/Mobile/Au.html +0 -415
  57. data/doc/classes/Jpmobile/Mobile/Ddipocket.html +0 -138
  58. data/doc/classes/Jpmobile/Mobile/Docomo.html +0 -366
  59. data/doc/classes/Jpmobile/Mobile/Jphone.html +0 -212
  60. data/doc/classes/Jpmobile/Mobile/Softbank.html +0 -300
  61. data/doc/classes/Jpmobile/Mobile/Vodafone.html +0 -176
  62. data/doc/classes/Jpmobile/Mobile/Willcom.html +0 -210
  63. data/doc/classes/Jpmobile/Position.html +0 -384
  64. data/doc/created.rid +0 -1
  65. data/doc/files/CHANGELOG.html +0 -110
  66. data/doc/files/NOTES.html +0 -163
  67. data/doc/files/README.html +0 -345
  68. data/doc/files/TODO.html +0 -138
  69. data/doc/files/lib/jpmobile/datum_conv_rb.html +0 -110
  70. data/doc/files/lib/jpmobile/filter_rb.html +0 -115
  71. data/doc/files/lib/jpmobile/helpers_rb.html +0 -105
  72. data/doc/files/lib/jpmobile/hook_abstract_request_rb.html +0 -109
  73. data/doc/files/lib/jpmobile/hook_action_view_rb.html +0 -119
  74. data/doc/files/lib/jpmobile/mobile/abstract_mobile_rb.html +0 -108
  75. data/doc/files/lib/jpmobile/mobile/au_rb.html +0 -112
  76. data/doc/files/lib/jpmobile/mobile/display_rb.html +0 -111
  77. data/doc/files/lib/jpmobile/mobile/docomo_rb.html +0 -105
  78. data/doc/files/lib/jpmobile/mobile/softbank_rb.html +0 -115
  79. data/doc/files/lib/jpmobile/mobile/willcom_rb.html +0 -108
  80. data/doc/files/lib/jpmobile/mobile/z_display_info_docomo_rb.html +0 -114
  81. data/doc/files/lib/jpmobile/mobile/z_emoji_docomo_rb.html +0 -119
  82. data/doc/files/lib/jpmobile/mobile/z_ip_addresses_au_rb.html +0 -114
  83. data/doc/files/lib/jpmobile/mobile/z_ip_addresses_rb.html +0 -117
  84. data/doc/files/lib/jpmobile/mobile/z_ip_addresses_willcom_rb.html +0 -114
  85. data/doc/files/lib/jpmobile/position_rb.html +0 -105
  86. data/doc/files/lib/jpmobile/trans_sid_rb.html +0 -114
  87. data/doc/files/lib/jpmobile/version_rb.html +0 -101
  88. data/doc/files/lib/jpmobile_rb.html +0 -101
  89. data/doc/fr_class_index.html +0 -50
  90. data/doc/fr_file_index.html +0 -50
  91. data/doc/fr_method_index.html +0 -113
  92. data/doc/index.html +0 -24
  93. data/doc/rdoc-style.css +0 -208
  94. data/lib/jpmobile/mobile/z_emoji_docomo.rb +0 -508
  95. data/test/firefox_test.rb +0 -8
  96. data/test/transitsid_test.rb +0 -86
@@ -1,10 +1,10 @@
1
1
  # = IPアドレス帯域テーブル(手動更新分)
2
2
  # == DoCoMo
3
- # http://www.nttdocomo.co.jp/service/imode/make/content/ip/about/
3
+ # http://www.nttdocomo.co.jp/service/imode/make/content/ip/index.html
4
4
  # 2006/09現在
5
5
  # == SoftBank
6
6
  # http://developers.softbankmobile.co.jp/dp/tech_svc/web/ip.php
7
- # 2006/11/17現在
7
+ # 2007/10/09現在
8
8
 
9
9
  #:enddoc:
10
10
  Jpmobile::Mobile::Docomo::IP_ADDRESSES = <<EOF
@@ -14,14 +14,14 @@ Jpmobile::Mobile::Docomo::IP_ADDRESSES = <<EOF
14
14
  EOF
15
15
 
16
16
  Jpmobile::Mobile::Softbank::IP_ADDRESSES=<<EOF
17
+ 123.108.236.0/24
18
+ 123.108.237.0/27
17
19
  202.179.204.0/24
18
- 202.253.96.248/29
20
+ 202.253.96.224/27
19
21
  210.146.7.192/26
20
22
  210.146.60.192/26
21
23
  210.151.9.128/26
22
- 210.169.130.112/29
23
- 210.169.130.120/29
24
- 210.169.176.0/24
24
+ 210.169.130.112/28
25
25
  210.175.1.128/25
26
26
  210.228.189.0/24
27
27
  211.8.159.128/25
@@ -25,4 +25,5 @@ Jpmobile::Mobile::Au::IP_ADDRESSES =
25
25
  "59.135.38.128/25",
26
26
  "219.108.157.0/25",
27
27
  "219.125.151.128/25",
28
- "219.125.145.0/25"]
28
+ "219.125.145.0/25",
29
+ "121.111.231.0/25"]
@@ -71,4 +71,9 @@ Jpmobile::Mobile::Willcom::IP_ADDRESSES =
71
71
  "219.108.10.0/24",
72
72
  "61.198.138.100/32",
73
73
  "61.198.138.101/32",
74
- "61.198.138.102/32"]
74
+ "61.198.138.102/32",
75
+ "61.198.139.160/28",
76
+ "61.198.139.128/27",
77
+ "61.198.138.103/32",
78
+ "61.198.139.0/29",
79
+ "219.108.15.0/24"]
@@ -21,7 +21,7 @@ module Jpmobile::TransSid #:nodoc:
21
21
  protected
22
22
  # URLにsession_idを追加する。
23
23
  def default_url_options(options)
24
- return unless request # for test process
24
+ return unless request # for test process
25
25
  return unless apply_transit_sid?
26
26
  { session_key => session.session_id }
27
27
  end
@@ -29,7 +29,9 @@ module Jpmobile::TransSid #:nodoc:
29
29
  private
30
30
  # session_keyを返す。
31
31
  def session_key
32
- session_key = request.session_options[:session_key] || '_session_id'
32
+ if session_enabled?
33
+ session_key = request.session_options[:session_key] || '_session_id'
34
+ end
33
35
  end
34
36
  # session_idを埋め込むためのhidden fieldを出力する。
35
37
  def sid_hidden_field_tag
@@ -43,6 +45,7 @@ module Jpmobile::TransSid #:nodoc:
43
45
  end
44
46
  # transit_sidを適用すべきかを返す。
45
47
  def apply_transit_sid?
48
+ return false unless session_enabled?
46
49
  return false if transit_sid_mode == :none
47
50
  return true if transit_sid_mode == :always
48
51
  if transit_sid_mode == :mobile
@@ -2,7 +2,7 @@ module Jpmobile #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/test/au_test.rb CHANGED
@@ -9,6 +9,7 @@ class AuTest < Test::Unit::TestCase
9
9
  assert_instance_of(Jpmobile::Mobile::Au, req.mobile)
10
10
  assert_equal("00000000000000_mj.ezweb.ne.jp", req.mobile.subno)
11
11
  assert_equal("00000000000000_mj.ezweb.ne.jp", req.mobile.ident)
12
+ assert_equal("00000000000000_mj.ezweb.ne.jp", req.mobile.ident_subscriber)
12
13
  assert_equal(nil, req.mobile.position)
13
14
  assert(req.mobile.supports_cookie?)
14
15
  end
data/test/docomo_test.rb CHANGED
@@ -11,6 +11,8 @@ class DocomoTest < Test::Unit::TestCase
11
11
  assert_equal(nil, req.mobile.serial_number)
12
12
  assert_equal(nil, req.mobile.icc)
13
13
  assert_equal(nil, req.mobile.ident)
14
+ assert_equal(nil, req.mobile.ident_device)
15
+ assert_equal(nil, req.mobile.ident_subscriber)
14
16
  assert(!req.mobile.supports_cookie?)
15
17
  end
16
18
 
@@ -24,6 +26,8 @@ class DocomoTest < Test::Unit::TestCase
24
26
  assert_equal(nil, req.mobile.serial_number)
25
27
  assert_equal(nil, req.mobile.icc)
26
28
  assert_equal(nil, req.mobile.ident)
29
+ assert_equal(nil, req.mobile.ident_device)
30
+ assert_equal(nil, req.mobile.ident_subscriber)
27
31
  end
28
32
 
29
33
  # DoCoMo, iarea
@@ -59,6 +63,8 @@ class DocomoTest < Test::Unit::TestCase
59
63
  assert_equal("XXXXX000000", req.mobile.serial_number)
60
64
  assert_equal("XXXXX000000", req.mobile.ident)
61
65
  assert_equal(nil, req.mobile.icc)
66
+ assert_equal("XXXXX000000", req.mobile.ident_device)
67
+ assert_equal(nil, req.mobile.ident_subscriber)
62
68
  end
63
69
 
64
70
  # DoCoMo, utn, foma
@@ -67,6 +73,8 @@ class DocomoTest < Test::Unit::TestCase
67
73
  assert_equal("999999999999999", req.mobile.serial_number)
68
74
  assert_equal("0000000000000000000f", req.mobile.icc)
69
75
  assert_equal("0000000000000000000f", req.mobile.ident)
76
+ assert_equal("999999999999999", req.mobile.ident_device)
77
+ assert_equal("0000000000000000000f", req.mobile.ident_subscriber)
70
78
  end
71
79
 
72
80
  # 正しいIPアドレス空間からのアクセスを判断できるか。
@@ -0,0 +1,166 @@
1
+ require File.dirname(__FILE__)+'/helper'
2
+
3
+ class EmoticonTestController < ActionController::Base
4
+ mobile_filter
5
+ def docomo_cr
6
+ render :text=>"&#xE63E;"
7
+ end
8
+ def docomo_utf8
9
+ render :text=>[0xe63e].pack("U")
10
+ end
11
+ def docomo_docomopoint
12
+ render :text=>"&#xE6D5;"
13
+ end
14
+ def au_cr
15
+ render :text=>"&#xE488;"
16
+ end
17
+ def au_utf8
18
+ render :text=>[0xe488].pack("U")
19
+ end
20
+ def softbank_cr
21
+ render :text=>"&#xF04A;"
22
+ end
23
+ def softbank_utf8
24
+ render :text=>[0xf04a].pack("U")
25
+ end
26
+ def query
27
+ @q = params[:q]
28
+ render :text=>@q
29
+ end
30
+ end
31
+
32
+ class EmoticonFunctionalTest < Test::Unit::TestCase
33
+ def setup
34
+ init EmoticonTestController
35
+ end
36
+ def test_docomo
37
+ # PC
38
+ get :docomo_cr
39
+ assert_equal "&#xE63E;", @response.body
40
+ get :docomo_utf8
41
+ assert_equal "\xee\x98\xbe", @response.body
42
+
43
+ # DoCoMo携帯
44
+ user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
45
+ get :docomo_cr
46
+ assert_equal "\xf8\x9f", @response.body
47
+ get :docomo_utf8
48
+ assert_equal "\xf8\x9f", @response.body
49
+ get :query, :q=>"\xf8\x9f"
50
+ assert_equal "\xee\x98\xbe", assigns["q"]
51
+ assert_equal "\xf8\x9f", @response.body
52
+
53
+ get :docomo_docomopoint
54
+ assert_equal "\xf9\x79", @response.body
55
+
56
+ # Au携帯電話での閲覧
57
+ user_agent "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
58
+ get :docomo_cr
59
+ assert_equal "\xf6\x60", @response.body
60
+ get :docomo_utf8
61
+ assert_equal "\xf6\x60", @response.body
62
+ get :docomo_docomopoint
63
+ assert_equal "[ドコモポイント]".tosjis, @response.body
64
+
65
+ # SoftBank携帯電話での閲覧
66
+ user_agent "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
67
+ get :docomo_cr
68
+ assert_equal "\e$Gj\x0f", @response.body
69
+ get :docomo_utf8
70
+ assert_equal "\e$Gj\x0f", @response.body
71
+ get :docomo_docomopoint
72
+ assert_equal "[ドコモポイント]", @response.body
73
+
74
+ # J-PHONE携帯電話での閲覧
75
+ user_agent "J-PHONE/3.0/V301D"
76
+ get :docomo_cr
77
+ assert_equal "\e$Gj\x0f", @response.body
78
+ get :docomo_utf8
79
+ assert_equal "\e$Gj\x0f", @response.body
80
+ get :docomo_docomopoint
81
+ assert_equal "Shift_JIS", @response.charset
82
+ assert_equal "[ドコモポイント]".tosjis, @response.body
83
+ end
84
+ def test_au
85
+ # PC
86
+ get :au_cr
87
+ assert_equal "&#xE488;", @response.body
88
+ get :au_utf8
89
+ assert_equal [0xe488].pack("U"), @response.body
90
+
91
+ # Au
92
+ user_agent "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
93
+ get :au_cr
94
+ assert_equal "\xf6\x60", @response.body
95
+ get :au_utf8
96
+ assert_equal "\xf6\x60", @response.body
97
+ get :query, :q=>"\xf6\x60"
98
+ assert_equal [0xe488].pack("U"), assigns["q"]
99
+ assert_equal "\xf6\x60", @response.body
100
+
101
+ # DoCoMo携帯電話での閲覧
102
+ user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
103
+ get :au_cr
104
+ assert_equal "\xf8\x9f", @response.body
105
+ get :au_utf8
106
+ assert_equal "\xf8\x9f", @response.body
107
+
108
+ # SoftBank携帯電話での閲覧
109
+ user_agent "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
110
+ get :au_cr
111
+ assert_equal "\e$Gj\x0f", @response.body
112
+ get :au_utf8
113
+ assert_equal "\e$Gj\x0f", @response.body
114
+ end
115
+ def test_softbank
116
+ # PCから
117
+ get :softbank_cr
118
+ assert_equal "&#xF04A;", @response.body
119
+ get :softbank_utf8
120
+ assert_equal [0xf04a].pack("U"), @response.body
121
+
122
+ # SoftBank携帯電話から
123
+ user_agent "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
124
+ get :softbank_cr
125
+ assert_equal "\e$Gj\x0f", @response.body
126
+ get :softbank_utf8
127
+ assert_equal "\e$Gj\x0f", @response.body
128
+ get :query, :q=>[0xe04A].pack("U") # 3G端末はUTF-8で絵文字を送ってくる
129
+ assert_equal [0xf04a].pack("U"), assigns["q"]
130
+ assert_equal "\e$Gj\x0f", @response.body
131
+
132
+ # Vodafone3G携帯電話から
133
+ user_agent "Vodafone/1.0/V705SH/SHJ001/SN000000000000000 Browser/VF-NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
134
+ get :softbank_cr
135
+ assert_equal "\e$Gj\x0f", @response.body
136
+ get :softbank_utf8
137
+ assert_equal "\e$Gj\x0f", @response.body
138
+ get :query, :q=>[0xe04A].pack("U") # 3G端末はUTF-8で絵文字を送ってくる
139
+ assert_equal [0xf04a].pack("U"), assigns["q"]
140
+ assert_equal "\e$Gj\x0f", @response.body
141
+
142
+ # J-PHONE携帯電話から
143
+ user_agent "J-PHONE/3.0/V301D"
144
+ get :softbank_cr
145
+ assert_equal "\e$Gj\x0f", @response.body
146
+ get :softbank_utf8
147
+ assert_equal "\e$Gj\x0f", @response.body
148
+ get :query, :q=>"\e$Gj\x0f" # J-PHONE端末はWebcodeで絵文字を送ってくる
149
+ assert_equal [0xf04a].pack("U"), assigns["q"]
150
+ assert_equal "\e$Gj\x0f", @response.body
151
+
152
+ # DoCoMo携帯電話での閲覧
153
+ user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
154
+ get :softbank_cr
155
+ assert_equal "\xf8\x9f", @response.body
156
+ get :softbank_utf8
157
+ assert_equal "\xf8\x9f", @response.body
158
+
159
+ # Au携帯電話での閲覧
160
+ user_agent "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
161
+ get :softbank_cr
162
+ assert_equal "\xf6\x60", @response.body
163
+ get :softbank_utf8
164
+ assert_equal "\xf6\x60", @response.body
165
+ end
166
+ end
@@ -0,0 +1,58 @@
1
+ require File.dirname(__FILE__)+'/helper'
2
+
3
+ class DocomoEmoticonTest < Test::Unit::TestCase
4
+ def test_external_unicodecr_docomo
5
+ assert_equal "&#xe63e;", Jpmobile::Emoticon::external_to_unicodecr_docomo("\xf8\x9f")
6
+ end
7
+ def test_unicodecr_external_docomo
8
+ assert_equal "\xf8\x9f", Jpmobile::Emoticon::unicodecr_to_external("&#xe63e;")
9
+ end
10
+ def test_unicodecr_utf8_docomo
11
+ assert_equal "\356\230\276", Jpmobile::Emoticon::unicodecr_to_utf8("&#xe63e;")
12
+ end
13
+ def test_utf8_unicodecr_docomo
14
+ assert_equal "&#xe63e;", Jpmobile::Emoticon::utf8_to_unicodecr("\356\230\276")
15
+ end
16
+ end
17
+
18
+ class AuEmoticonTest < Test::Unit::TestCase
19
+ def test_au_external_unicodecr
20
+ assert_equal "&#xe481;", Jpmobile::Emoticon::external_to_unicodecr_au("\xf6\x59")
21
+ end
22
+ def test_au_unicodecr_external
23
+ assert_equal "\xf6\x59", Jpmobile::Emoticon::unicodecr_to_external("&#xe481;")
24
+ end
25
+ def test_au_unicodecr_utf8
26
+ assert_equal "\356\222\201", Jpmobile::Emoticon::unicodecr_to_utf8("&#xe481;")
27
+ end
28
+ def test_au_utf8_unicodecr
29
+ assert_equal "&#xe481;", Jpmobile::Emoticon::utf8_to_unicodecr("\356\222\201")
30
+ end
31
+ end
32
+
33
+ class SoftbankEmoticonTest < Test::Unit::TestCase
34
+ def test_jphone_webcode_cr
35
+ assert_equal "&#xf001;&#xf001;", Jpmobile::Emoticon::external_to_unicodecr_jphone("\x1b$G!!\x0f")
36
+ end
37
+ def test_softbank_cr
38
+ assert_equal "&#xf001;", Jpmobile::Emoticon::external_to_unicodecr_softbank([0xe001].pack('U'))
39
+ end
40
+ def test_vodafone_cr
41
+ assert_equal "&#xf001;", Jpmobile::Emoticon::external_to_unicodecr_softbank([0xe001].pack('U'))
42
+ end
43
+ def test_softbank_cr_webcode
44
+ assert_equal "\x1b$G!\x0f", Jpmobile::Emoticon::unicodecr_to_external("&#xf001;")
45
+ end
46
+ def test_softbank_cr_utf8
47
+ assert_equal "\xef\x80\x81", Jpmobile::Emoticon::unicodecr_to_utf8("&#xf001;")
48
+ end
49
+ def test_softbank_utf8_cr
50
+ assert_equal "&#xf001;", Jpmobile::Emoticon::utf8_to_unicodecr("\xef\x80\x81")
51
+ end
52
+ end
53
+
54
+ class KoukaiEmoticonTest < Test::Unit::TestCase
55
+ def test_koukai_sjis
56
+ assert_equal "\x8c\xf6\x8a\x4a", Jpmobile::Emoticon::external_to_unicodecr_docomo("\x8c\xf6\x8a\x4a")
57
+ end
58
+ end
@@ -0,0 +1,146 @@
1
+ require File.dirname(__FILE__)+'/helper'
2
+
3
+ class FilterTestControllerBase < ActionController::Base
4
+ def abracadabra
5
+ render :text=>"アブラカダブラ"
6
+ end
7
+ def query
8
+ @q = params[:q]
9
+ render :text=>@q
10
+ end
11
+ def binary
12
+ send_data "アブラカダブラ"
13
+ end
14
+ def xhtml
15
+ response.content_type = "application/xhtml+xml"
16
+ render :text=>"アブラカダブラ"
17
+ end
18
+ end
19
+
20
+ class FilterTestController < FilterTestControllerBase
21
+ mobile_filter
22
+ end
23
+
24
+ class HankakuFilterTestController < FilterTestControllerBase
25
+ mobile_filter :hankaku=>true
26
+ end
27
+
28
+ class FilterFunctionalTestOutput < Test::Unit::TestCase
29
+ def setup
30
+ init FilterTestController
31
+ end
32
+ def test_docomo
33
+ user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
34
+ get :abracadabra
35
+ assert_equal "Shift_JIS", @response.charset
36
+ assert_equal "\203A\203u\203\211\203J\203_\203u\203\211", @response.body # "アブラカダブラ", 全角, Shift_JIS
37
+ end
38
+ end
39
+
40
+ class HankakuFilterFunctionalTestOutput < Test::Unit::TestCase
41
+ def setup
42
+ init HankakuFilterTestController
43
+ end
44
+ def test_pc
45
+ get :abracadabra
46
+ assert_equal "utf-8", @response.charset
47
+ assert_equal "アブラカダブラ", @response.body
48
+ end
49
+ def test_docomo_binary
50
+ user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
51
+ get :binary
52
+ assert_equal "アブラカダブラ", @response.body
53
+ end
54
+ def test_docomo_xhtml
55
+ user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
56
+ get :xhtml
57
+ assert_equal "Shift_JIS", @response.charset
58
+ assert_equal "\261\314\336\327\266\300\336\314\336\327", @response.body # "アブラカダブラ", 半角, Shift_JIS
59
+ end
60
+ def test_docomo
61
+ user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
62
+ get :abracadabra
63
+ assert_equal "Shift_JIS", @response.charset
64
+ assert_equal "\261\314\336\327\266\300\336\314\336\327", @response.body # "アブラカダブラ", 半角, Shift_JIS
65
+ end
66
+ def test_jphone
67
+ user_agent "J-PHONE/3.0/V301D"
68
+ get :abracadabra
69
+ assert_equal "Shift_JIS", @response.charset
70
+ assert_equal "\261\314\336\327\266\300\336\314\336\327", @response.body # "アブラカダブラ", 半角, Shift_JIS
71
+ end
72
+ def test_au
73
+ user_agent "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
74
+ get :abracadabra
75
+ assert_equal "Shift_JIS", @response.charset
76
+ assert_equal "\261\314\336\327\266\300\336\314\336\327", @response.body # "アブラカダブラ", 半角, Shift_JIS
77
+ end
78
+ def test_softbank
79
+ user_agent "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
80
+ get :abracadabra
81
+ assert_equal "utf-8", @response.charset
82
+ assert_equal "アブラカダブラ", @response.body
83
+ end
84
+ def test_vodafone
85
+ user_agent "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"
86
+ get :abracadabra
87
+ assert_equal "utf-8", @response.charset
88
+ assert_equal "アブラカダブラ", @response.body
89
+ end
90
+ end
91
+
92
+ class FilterFunctionalTestInput < Test::Unit::TestCase
93
+ def setup
94
+ init FilterTestController
95
+ end
96
+ def test_docomo
97
+ user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
98
+ get :query, :q=>"アブラカダブラ".tosjis
99
+ assert_equal "アブラカダブラ", assigns["q"]
100
+ get :query, :q=>"\261\314\336\327\266\300\336\314\336\327"
101
+ assert_equal "アブラカダブラ", assigns["q"]
102
+ end
103
+ end
104
+
105
+ class HankakuFilterFunctionalTestInput < Test::Unit::TestCase
106
+ def setup
107
+ init HankakuFilterTestController
108
+ end
109
+ def test_pc
110
+ get :query, :q=>"アブラカダブラ"
111
+ assert_equal "アブラカダブラ", assigns["q"]
112
+ end
113
+ def test_docomo
114
+ user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
115
+ get :query, :q=>"アブラカダブラ".tosjis
116
+ assert_equal "アブラカダブラ", assigns["q"]
117
+ get :query, :q=>"\261\314\336\327\266\300\336\314\336\327"
118
+ assert_equal "アブラカダブラ", assigns["q"]
119
+ end
120
+ def test_jphone
121
+ user_agent "J-PHONE/3.0/V301D"
122
+ get :query, :q=>"アブラカダブラ".tosjis
123
+ assert_equal "アブラカダブラ", assigns["q"]
124
+ get :query, :q=>"\261\314\336\327\266\300\336\314\336\327"
125
+ assert_equal "アブラカダブラ", assigns["q"]
126
+ end
127
+ def test_au
128
+ user_agent "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
129
+ get :query, :q=>"アブラカダブラ".tosjis
130
+ assert_equal "アブラカダブラ", assigns["q"]
131
+ get :query, :q=>"\261\314\336\327\266\300\336\314\336\327"
132
+ assert_equal "アブラカダブラ", assigns["q"]
133
+ end
134
+ def test_softbank
135
+ user_agent "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
136
+ get :query, :q=>"アブラカダブラ"
137
+ assert_equal "アブラカダブラ", assigns["q"]
138
+ get :query, :q=>"アブラカダブラ"
139
+ assert_equal "アブラカダブラ", assigns["q"]
140
+ end
141
+ def test_vodafone
142
+ user_agent "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"
143
+ get :query, :q=>"アブラカダブラ"
144
+ assert_equal "アブラカダブラ", assigns["q"]
145
+ end
146
+ end