Welcome to mirror list, hosted at ThFree Co, Russian Federation.

WebsiteBuilderTest.kt « contactrow « vcard4android « bitfire « at « java « androidTest « src - github.com/bitfireAT/vcard4android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6d7be422329585004fa4cf80b2ea30d2fa9565ef (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/***************************************************************************************************
 * Copyright © All Contributors. See LICENSE and AUTHORS in the root directory for details.
 **************************************************************************************************/

package at.bitfire.vcard4android.contactrow

import android.net.Uri
import android.provider.ContactsContract.CommonDataKinds
import at.bitfire.vcard4android.Contact
import at.bitfire.vcard4android.LabeledProperty
import at.bitfire.vcard4android.property.CustomType
import ezvcard.property.Url
import org.junit.Assert.assertEquals
import org.junit.Test

class WebsiteBuilderTest {

    @Test
    fun testEmpty() {
        WebsiteBuilder(Uri.EMPTY, null, Contact()).build().also { result ->
            assertEquals(0, result.size)
        }
    }


    @Test
    fun testUrl_Empty() {
        WebsiteBuilder(Uri.EMPTY, null, Contact().apply {
            urls += LabeledProperty(Url(""))
        }).build().also { result ->
            assertEquals(0, result.size)
        }
    }

    @Test
    fun testUrl_Value() {
        WebsiteBuilder(Uri.EMPTY, null, Contact().apply {
            urls += LabeledProperty(Url("https://example.com"))
        }).build().also { result ->
            assertEquals("https://example.com", result[0].values[CommonDataKinds.Website.URL])
        }
    }


    @Test
    fun testLabel() {
        WebsiteBuilder(Uri.EMPTY, null, Contact().apply {
            urls += LabeledProperty(Url("https://example.com"), "Label")
        }).build().also { result ->
            assertEquals(CommonDataKinds.Im.TYPE_CUSTOM, result[0].values[CommonDataKinds.Website.TYPE])
            assertEquals("Label", result[0].values[CommonDataKinds.Website.LABEL])
        }
    }


    @Test
    fun testMimeType() {
        WebsiteBuilder(Uri.EMPTY, null, Contact().apply {
            urls += LabeledProperty(Url("https://example.com"))
        }).build().also { result ->
            assertEquals(CommonDataKinds.Website.CONTENT_ITEM_TYPE, result[0].values[CommonDataKinds.Website.MIMETYPE])
        }
    }


    @Test
    fun testType_Blog() {
        WebsiteBuilder(Uri.EMPTY, null, Contact().apply {
            urls += LabeledProperty(Url("https://example.com").apply {
                type = CustomType.Url.TYPE_BLOG
            })
        }).build().also { result ->
            assertEquals(CommonDataKinds.Website.TYPE_BLOG, result[0].values[CommonDataKinds.Im.TYPE])
        }
    }

    @Test
    fun testType_Ftp() {
        WebsiteBuilder(Uri.EMPTY, null, Contact().apply {
            urls += LabeledProperty(Url("ftps://example.com").apply {
                type = CustomType.Url.TYPE_FTP
            })
        }).build().also { result ->
            assertEquals(CommonDataKinds.Website.TYPE_FTP, result[0].values[CommonDataKinds.Im.TYPE])
        }
    }

    @Test
    fun testType_Home() {
        WebsiteBuilder(Uri.EMPTY, null, Contact().apply {
            urls += LabeledProperty(Url("https://example.com").apply {
                type = CustomType.HOME
            })
        }).build().also { result ->
            assertEquals(CommonDataKinds.Website.TYPE_HOME, result[0].values[CommonDataKinds.Im.TYPE])
        }
    }

    @Test
    fun testType_Homepage() {
        WebsiteBuilder(Uri.EMPTY, null, Contact().apply {
            urls += LabeledProperty(Url("https://example.com").apply {
                type = CustomType.Url.TYPE_HOMEPAGE
            })
        }).build().also { result ->
            assertEquals(CommonDataKinds.Website.TYPE_HOMEPAGE, result[0].values[CommonDataKinds.Im.TYPE])
        }
    }

    @Test
    fun testType_None() {
        WebsiteBuilder(Uri.EMPTY, null, Contact().apply {
            urls += LabeledProperty(Url("ftps://example.com"))
        }).build().also { result ->
            assertEquals(CommonDataKinds.Website.TYPE_OTHER, result[0].values[CommonDataKinds.Im.TYPE])
        }
    }

    @Test
    fun testType_Profile() {
        WebsiteBuilder(Uri.EMPTY, null, Contact().apply {
            urls += LabeledProperty(Url("https://example.com").apply {
                type = CustomType.Url.TYPE_PROFILE
            })
        }).build().also { result ->
            assertEquals(CommonDataKinds.Website.TYPE_PROFILE, result[0].values[CommonDataKinds.Im.TYPE])
        }
    }

    @Test
    fun testType_Work() {
        WebsiteBuilder(Uri.EMPTY, null, Contact().apply {
            urls += LabeledProperty(Url("https://example.com").apply {
                type = CustomType.WORK
            })
        }).build().also { result ->
            assertEquals(CommonDataKinds.Website.TYPE_WORK, result[0].values[CommonDataKinds.Im.TYPE])
        }
    }

}