1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.fatwire.gst.foundation.mobile.mobiforge;
17
18 import static org.junit.Assert.assertEquals;
19
20 import org.junit.Test;
21
22 import com.fatwire.gst.foundation.mobile.DeviceType;
23 import com.fatwire.gst.foundation.mobile.mobiforge.MobiForgeDeviceDetector;
24
25 public class MobiForceDeviceDetectorTest {
26
27 @Test
28 public void testDetectDeviceTypeString_iphone() {
29 String ua = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3";
30
31 DeviceType type = new MobiForgeDeviceDetector().detectDeviceType(ua);
32 assertEquals(DeviceType.MOBILE, type);
33
34 }
35
36 @Test
37 public void testDetectDeviceTypeString_ipad() {
38 String ua = "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10";
39
40 DeviceType type = new MobiForgeDeviceDetector().detectDeviceType(ua);
41 assertEquals(DeviceType.TABLET, type);
42
43 }
44
45 @Test
46 public void testDetectDeviceTypeString_desktop() {
47 String ua = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1";
48
49 DeviceType type = new MobiForgeDeviceDetector().detectDeviceType(ua);
50 assertEquals(DeviceType.DESKTOP, type);
51
52 }
53
54 }