wurfl 1.3.6 → 1.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,38 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <wurfl>
3
- <version>
4
- <ver>Test Version</ver>
5
- </version>
6
- <devices>
7
- <device id="apple_generic" user_agent="Mozilla/5.0 (iPhone;" fall_back="generic_xhtml">
8
- <group id="display">
9
- <capability name="columns" value="20"/>
10
- <capability name="max_image_width" value="300"/>
11
- <capability name="rows" value="20"/>
12
- <capability name="resolution_width" value="300"/>
13
- <capability name="resolution_height" value="300"/>
14
- <capability name="max_image_height" value="300"/>
15
- </group>
16
- </device>
17
- <device id="generic_xhtml" user_agent="Mozz" fall_back="generic">
18
- <group id="display">
19
- <capability name="max_image_width" value="120"/>
20
- <capability name="resolution_height" value="92"/>
21
- <capability name="resolution_width" value="128"/>
22
- <capability name="max_image_height" value="92"/>
23
- </group>
24
- </device>
25
- <device id="generic" user_agent="" fall_back="root">
26
- <group id="display">
27
- <capability name="physical_screen_height" value="27"/>
28
- <capability name="columns" value="11"/>
29
- <capability name="physical_screen_width" value="27"/>
30
- <capability name="rows" value="6"/>
31
- <capability name="max_image_width" value="90"/>
32
- <capability name="resolution_height" value="40"/>
33
- <capability name="resolution_width" value="90"/>
34
- <capability name="max_image_height" value="35"/>
35
- </group>
36
- </device>
37
- </devices>
38
- </wurfl>
@@ -1,55 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <wurfl>
3
- <version>
4
- <ver>Test Version</ver>
5
- </version>
6
- <devices>
7
- <device id="generic" user_agent="" fall_back="root">
8
- <group id="display">
9
- <capability name="physical_screen_height" value="27"/>
10
- <capability name="columns" value="11"/>
11
- <capability name="physical_screen_width" value="27"/>
12
- <capability name="rows" value="6"/>
13
- <capability name="max_image_width" value="90"/>
14
- <capability name="resolution_height" value="40"/>
15
- <capability name="resolution_width" value="90"/>
16
- <capability name="max_image_height" value="35"/>
17
- </group>
18
- </device>
19
- <device id="generic_xhtml" user_agent="Mozz" fall_back="generic">
20
- <group id="display">
21
- <capability name="max_image_width" value="120"/>
22
- <capability name="resolution_height" value="92"/>
23
- <capability name="resolution_width" value="128"/>
24
- <capability name="max_image_height" value="92"/>
25
- </group>
26
- </device>
27
- <device id="apple_generic" user_agent="Mozilla/5.0 (iPhone;" fall_back="generic_xhtml">
28
- <group id="display">
29
- <capability name="columns" value="20"/>
30
- <capability name="max_image_width" value="300"/>
31
- <capability name="rows" value="20"/>
32
- <capability name="resolution_width" value="300"/>
33
- <capability name="resolution_height" value="300"/>
34
- <capability name="max_image_height" value="300"/>
35
- </group>
36
- </device>
37
- <device id="apple_iphone_ver1" user_agent="Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A538a Safari/419.3" fall_back="apple_generic" actual_device_root="true">
38
- <group id="product_info">
39
- <capability name="mobile_browser" value="Safari"/>
40
- <capability name="pointing_method" value="touchscreen"/>
41
- <capability name="model_name" value="iPhone"/>
42
- <capability name="device_os_version" value="1.0"/>
43
- </group>
44
- <group id="display">
45
- <capability name="physical_screen_height" value="74"/>
46
- <capability name="dual_orientation" value="true"/>
47
- <capability name="physical_screen_width" value="49"/>
48
- <capability name="max_image_width" value="320"/>
49
- <capability name="resolution_height" value="480"/>
50
- <capability name="resolution_width" value="320"/>
51
- <capability name="max_image_height" value="360"/>
52
- </group>
53
- </device>
54
- </devices>
55
- </wurfl>
@@ -1,110 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
2
- require 'wurfl/handset'
3
-
4
- class HandsetTest < Test::Unit::TestCase
5
- def setup
6
- @fallback = Wurfl::Handset.new("fallback_id", "f", nil)
7
- @handset = Wurfl::Handset.new("handset_id", "h", @fallback)
8
- end
9
-
10
- should("not be equal to nil") { assert_not_equal @handset, nil }
11
- should("not be equal to 1") { assert_not_equal @handset, 1 }
12
- should("not be equal to fallback") { assert_not_equal @handset, @fallback }
13
- should("equal self") { assert_equal @handset, @handset }
14
- should("not have differences") { assert @handset.differences(@fallback).empty? }
15
-
16
- context "key not set" do
17
- should("not have value") { assert_nil @handset["k"] }
18
- should("not have owner") { assert_equal nil, @handset.owner("k") }
19
- end
20
-
21
- context "fallback key set" do
22
- setup { @fallback["k"] = "v" }
23
-
24
- should("fetch value from fallback") { assert_equal "v", @handset["k"] }
25
- should("have fallback as owner") { assert_equal "fallback_id", @handset.owner("k") }
26
-
27
- context "and handset overwrites key" do
28
- setup { @handset["k"] = nil }
29
-
30
- should("fetch value from handset") { assert_nil @handset["k"] }
31
- should("have handset as owner") { assert_equal "handset_id", @handset.owner("k") }
32
- end
33
- end
34
-
35
- context "fallback and handset set different keys" do
36
- setup do
37
- @handset["k1"] = "v1"
38
- @fallback["k2"] = "v2"
39
- end
40
-
41
- should("have keys from handset and fallback") { assert_equal(["k1", "k2"], @handset.keys) }
42
- end
43
-
44
- context "another handset with same wurfl_id and fallback" do
45
- setup { @another_handset = Wurfl::Handset.new("handset_id","h", @fallback) }
46
-
47
- should("equal handset") { assert_equal @handset, @another_handset}
48
-
49
- context "and the other handset sets a key" do
50
- setup { @another_handset["k"] = "v" }
51
-
52
- should("not equal handset") { assert_not_equal @handset, @another_handset }
53
-
54
- context "and the fallback sets identical key" do
55
- setup { @fallback["k"] = "v" }
56
-
57
- should("equal handset") { assert_equal @handset, @another_handset }
58
- end
59
- end
60
- end
61
-
62
- context "another handset with different wurfl_id and fallback" do
63
- setup do
64
- @another_fallback = Wurfl::Handset.new("f2", "f2_ua", nil)
65
- @another_handset = Wurfl::Handset.new("h2","h2_ua", @another_fallback)
66
- end
67
-
68
- context "and no keys set" do
69
- should('have no differences') {assert @handset.differences(@another_fallback).empty? }
70
- end
71
-
72
- context "and the other handset has a key set" do
73
- setup { @another_handset["k"] = "v" }
74
-
75
- should('have the key as a difference') do
76
- assert_equal ["k"], @handset.differences(@another_handset)
77
- end
78
- end
79
-
80
- context "and handset has a key set" do
81
- setup { @handset["k"] = "v" }
82
-
83
- should('have the key as a difference') do
84
- assert_equal ["k"], @handset.differences(@another_handset)
85
- end
86
- end
87
-
88
- context "and both handsets have different values for same key" do
89
- setup do
90
- @handset["k"] = "v"
91
- @another_handset["k"] = "v2"
92
- end
93
-
94
- should 'have the key as a difference' do
95
- assert_equal ["k"], @handset.differences(@another_handset)
96
- end
97
- end
98
-
99
- context "and fallbacks have different values for same key" do
100
- setup do
101
- @fallback["j"] = "1"
102
- @another_fallback["j"] = "2"
103
- end
104
-
105
- should 'have the key as a difference' do
106
- assert_equal ["j"], @handset.differences(@another_handset)
107
- end
108
- end
109
- end
110
- end
@@ -1,72 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
2
- require 'wurfl/loader'
3
-
4
- class LoaderTest < Test::Unit::TestCase
5
-
6
- class << self
7
- def should_have_correct_values(h)
8
- h.each do |wurfl_id, values|
9
- values.each do |key, value|
10
- should "have #{key} set to #{value} for #{wurfl_id}" do
11
- assert_equal value.to_s, @handsets[wurfl_id.to_s][key.to_s]
12
- end
13
- end
14
- end
15
- end
16
-
17
- def should_have_correct_user_agents(h)
18
- h.each do |wurfl_id, user_agent|
19
- should "have user agent '#{user_agent}' for #{wurfl_id}" do
20
- assert_equal user_agent, @handsets[wurfl_id.to_s].user_agent
21
- end
22
- end
23
- end
24
- end
25
-
26
- def setup
27
- @loader = Wurfl::Loader.new
28
- end
29
-
30
- context "loaded base wurfl" do
31
- setup do
32
- @handsets = @loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.simple.xml"))
33
- end
34
- should_have_correct_values(
35
- :apple_generic => { :columns => 20, :max_image_height => 300, :physical_screen_height => 27 },
36
- :generic_xhtml => { :columns => 11, :max_image_height => 92, :physical_screen_height => 27 },
37
- :generic => { :columns => 11, :max_image_height => 35, :physical_screen_height => 27 }
38
- )
39
- should_have_correct_user_agents(
40
- :generic => "",
41
- :apple_generic => "Mozilla/5.0 (iPhone;",
42
- :generic_xhtml => "Mozz"
43
- )
44
-
45
- context 'and patch' do
46
- setup do
47
- @handsets = @loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.generic.patch.xml"))
48
- end
49
- should_have_correct_values(:generic => { :columns => 200, :rows => 6 })
50
- end
51
- should("not be actual device for generic") { assert !@handsets["generic"].actual_device? }
52
- should("be actual device for apple_iphone_ver1") { assert @handsets["apple_iphone_ver1"].actual_device? }
53
- end
54
-
55
- context "loaded wurfl with handsets in reverse order" do
56
- setup do
57
- @handsets = @loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.reverse.xml"))
58
- end
59
- should_have_correct_values(
60
- :apple_generic => { :columns => 20, :max_image_height => 300, :physical_screen_height => 27 },
61
- :generic_xhtml => { :columns => 11, :max_image_height => 92, :physical_screen_height => 27 },
62
- :generic => { :columns => 11, :max_image_height => 35, :physical_screen_height => 27 }
63
- )
64
- should_have_correct_user_agents(
65
- :generic => "",
66
- :apple_generic => "Mozilla/5.0 (iPhone;",
67
- :generic_xhtml => "Mozz"
68
- )
69
- end
70
-
71
- end
72
-
@@ -1,3 +0,0 @@
1
- $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
2
- require 'test/unit'
3
- require 'shoulda'
@@ -1,33 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
2
- require 'wurfl/user_agent_matcher'
3
- require 'wurfl/loader'
4
-
5
- class UserAgentMatcherTest < Test::Unit::TestCase
6
- def setup
7
- loader = Wurfl::Loader.new
8
- handsets = loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.simple.xml"))
9
- @matcher = Wurfl::UserAgentMatcher.new(handsets)
10
- end
11
-
12
- def test_empty_user_agent
13
- a, shortest_distance = @matcher.match_handsets("")
14
- assert_equal 1, a.size
15
- assert_equal "generic", a.first.wurfl_id
16
- assert_equal 0, shortest_distance
17
- end
18
-
19
- def test_matching_user_agent
20
- a, shortest_distance = @matcher.match_handsets("Mozz")
21
- assert_equal 1, a.size
22
- assert_equal "generic_xhtml", a.first.wurfl_id
23
- assert_equal 0, shortest_distance
24
- end
25
-
26
- def test_iphone
27
- s = "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)"
28
- a, shortest_distance = @matcher.match_handsets(s)
29
- assert_equal 1, a.size
30
- assert_equal "apple_generic", a.first.wurfl_id
31
- assert_equal 26, shortest_distance
32
- end
33
- end
@@ -1,18 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
2
- require 'wurfl/utils'
3
- require 'wurfl/loader'
4
- require 'tempfile'
5
-
6
- class TestLoader < Test::Unit::TestCase
7
- include Wurfl::Utils
8
-
9
- def test_save_and_load_wurfl_pstore
10
- loader = Wurfl::Loader.new
11
- handsets = loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.simple.xml"))
12
- tempfile = Tempfile.new("wurfl.pstore").path
13
- save_wurfl_pstore(tempfile,handsets)
14
- loaded_handsets = load_wurfl_pstore(tempfile)
15
- assert_equal handsets, loaded_handsets
16
- end
17
-
18
- end