-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathandroid_test.go
95 lines (89 loc) · 6.3 KB
/
android_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package devices
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestNewAndroid(t *testing.T) {
Convey("Given a user agent string", t, func() {
So(NewAndroid(NewUAParser("")), ShouldHaveSameTypeAs, &Android{})
})
}
func TestAndroidName(t *testing.T) {
Convey("Subject: #Name", t, func() {
Convey("It should return Android", func() {
So(NewAndroid(NewUAParser(testDevices["android-eclair-2-0"])).Name(), ShouldEqual, "HUAWEI XXGW")
So(NewAndroid(NewUAParser(testDevices["android-eclair-2-1"])).Name(), ShouldEqual, "Xperia Ray")
So(NewAndroid(NewUAParser(testDevices["android-froyo-2-2"])).Name(), ShouldEqual, "Nexus One")
So(NewAndroid(NewUAParser(testDevices["android-froyo-2-2-0"])).Name(), ShouldEqual, "XELECTRON WS777")
So(NewAndroid(NewUAParser(testDevices["android-gingerbread-2-3-5"])).Name(), ShouldEqual, "HTC Desire HD A9191")
So(NewAndroid(NewUAParser(testDevices["android-gingerbread-2-3-6"])).Name(), ShouldEqual, "IM-A760S")
So(NewAndroid(NewUAParser(testDevices["android-gingerbread-2-3-8"])).Name(), ShouldEqual, "Huawei X3")
So(NewAndroid(NewUAParser(testDevices["android-honeycomb-3-1-0"])).Name(), ShouldEqual, "SGH-M919")
So(NewAndroid(NewUAParser(testDevices["android-honeycomb-3-1-4"])).Name(), ShouldEqual, "Nexus 12k")
So(NewAndroid(NewUAParser(testDevices["android-honeycomb-3-2"])).Name(), ShouldEqual, "SAMSUNG-SGH-I957")
So(NewAndroid(NewUAParser(testDevices["android-ice-cream-sandwich-4-0-3"])).Name(), ShouldEqual, "HTC EVO 3D X515m")
So(NewAndroid(NewUAParser(testDevices["android-ice-cream-sandwich-4-0-4"])).Name(), ShouldEqual, "LT18i")
So(NewAndroid(NewUAParser(testDevices["android-jelly-bean-4.1"])).Name(), ShouldEqual, "MI 2S")
So(NewAndroid(NewUAParser(testDevices["android-jelly-bean-4.2"])).Name(), ShouldEqual, "GT-I9505")
So(NewAndroid(NewUAParser(testDevices["android-jelly-bean-4.3"])).Name(), ShouldEqual, "HM 1SW")
So(NewAndroid(NewUAParser(testDevices["android-kitkat-4.4"])).Name(), ShouldEqual, "sm-n9005")
So(NewAndroid(NewUAParser(testDevices["android-lollipop-5.0"])).Name(), ShouldEqual, "Redmi Note 2")
So(NewAndroid(NewUAParser(testDevices["android-loolipop-5.1"])).Name(), ShouldEqual, "Unknown")
So(NewAndroid(NewUAParser(testDevices["android-marshmallow-6-0"])).Name(), ShouldEqual, "MI 4LTE")
So(NewAndroid(NewUAParser(testDevices["android-nougat-7-0"])).Name(), ShouldEqual, "Nexus 5x")
So(NewAndroid(NewUAParser(testDevices["android-nougat-7-1"])).Name(), ShouldEqual, "SM-G935V")
So(NewAndroid(NewUAParser(testDevices["android-oreo-8-0"])).Name(), ShouldEqual, "Pixel XL")
So(NewAndroid(NewUAParser(testDevices["android-pie-9-0"])).Name(), ShouldEqual, "Pixel XL")
So(NewAndroid(NewUAParser(testDevices["android-10"])).Name(), ShouldEqual, "Nexus 7")
So(NewAndroid(NewUAParser(testDevices["android-11"])).Name(), ShouldEqual, "LG-D335")
So(NewAndroid(NewUAParser(testDevices["android-12"])).Name(), ShouldEqual, "Pixel 3a")
So(NewAndroid(NewUAParser(testDevices["android-20-0"])).Name(), ShouldEqual, "Unknown")
So(NewAndroid(NewUAParser(testDevices["android-20-1"])).Name(), ShouldEqual, "SM-J100H")
So(NewAndroid(NewUAParser(testDevices["android-21"])).Name(), ShouldEqual, "SM-G360M")
So(NewAndroid(NewUAParser(testDevices["android-22"])).Name(), ShouldEqual, "Z818L")
})
})
}
func TestAndroidMatch(t *testing.T) {
Convey("Subject: #Match", t, func() {
Convey("When the user agent matches", func() {
Convey("It should return true", func() {
So(NewAndroid(NewUAParser(testDevices["android-eclair-2-0"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-eclair-2-1"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-froyo-2-2"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-froyo-2-2-0"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-gingerbread-2-3-5"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-gingerbread-2-3-6"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-gingerbread-2-3-8"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-honeycomb-3-1-0"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-honeycomb-3-1-4"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-honeycomb-3-2"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-ice-cream-sandwich-4-0-3"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-ice-cream-sandwich-4-0-4"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-jelly-bean-4.1"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-jelly-bean-4.2"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-jelly-bean-4.3"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-kitkat-4.4"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-lollipop-5.0"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-loolipop-5.1"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-marshmallow-6-0"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-nougat-7-0"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-nougat-7-1"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-oreo-8-0"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-pie-9-0"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-10"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-11"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-12"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-20-0"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-20-1"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-21"])).Match(), ShouldBeTrue)
So(NewAndroid(NewUAParser(testDevices["android-22"])).Match(), ShouldBeTrue)
})
})
Convey("When the user agent doesn't match", func() {
Convey("It should return false", func() {
So(NewAndroid(NewUAParser(testDevices["bb-playbook-1"])).Match(), ShouldBeFalse)
})
})
})
}