39
39
var proxy ProxyInfo
41
func makeGenericContextProperty(name, cType string, active, messageCenter, messageProxy bool) PropertiesType {
41
func makeGenericContextProperty(name, cType string, active, messageCenter, messageProxy, preferred bool) PropertiesType {
42
42
p := make(PropertiesType)
43
43
p["Name"] = dbus.Variant{name}
44
44
p["Type"] = dbus.Variant{cType}
45
45
p["Active"] = dbus.Variant{active}
46
p["Preferred"] = dbus.Variant{preferred}
47
48
p["MessageCenter"] = dbus.Variant{"http://messagecenter.com"}
80
81
func (s *ContextTestSuite) TestMMSOverInternet(c *C) {
81
82
context1 := OfonoContext{
82
83
ObjectPath: "/ril_0/context1",
83
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true),
84
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true, false),
85
86
s.contexts = append(s.contexts, context1)
93
94
func (s *ContextTestSuite) TestMMSOverInactiveInternet(c *C) {
94
95
context1 := OfonoContext{
95
96
ObjectPath: "/ril_0/context1",
96
Properties: makeGenericContextProperty("Context1", contextTypeInternet, false, true, true),
97
Properties: makeGenericContextProperty("Context1", contextTypeInternet, false, true, true, false),
98
99
s.contexts = append(s.contexts, context1)
105
106
func (s *ContextTestSuite) TestMMSOverInternetNoProxy(c *C) {
106
107
context1 := OfonoContext{
107
108
ObjectPath: "/ril_0/context1",
108
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false),
109
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false),
110
111
s.contexts = append(s.contexts, context1)
118
119
func (s *ContextTestSuite) TestMMSOverMMS(c *C) {
119
120
context1 := OfonoContext{
120
121
ObjectPath: "/ril_0/context1",
121
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, false, false),
122
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, false, false, false),
123
124
s.contexts = append(s.contexts, context1)
125
126
context2 := OfonoContext{
126
127
ObjectPath: "/ril_0/context2",
127
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, true),
128
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, true, false),
129
130
s.contexts = append(s.contexts, context2)
137
138
func (s *ContextTestSuite) TestMMSOverMMSNoProxy(c *C) {
138
139
context1 := OfonoContext{
139
140
ObjectPath: "/ril_0/context1",
140
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, false, false),
141
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, false, false, false),
142
143
s.contexts = append(s.contexts, context1)
144
145
context2 := OfonoContext{
145
146
ObjectPath: "/ril_0/context2",
146
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false),
147
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
148
149
s.contexts = append(s.contexts, context2)
156
157
func (s *ContextTestSuite) TestMMSMoreThanOneValid(c *C) {
157
158
context1 := OfonoContext{
158
159
ObjectPath: "/ril_0/context1",
159
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false),
160
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false),
161
162
s.contexts = append(s.contexts, context1)
163
164
context2 := OfonoContext{
164
165
ObjectPath: "/ril_0/context2",
165
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false),
166
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
167
168
s.contexts = append(s.contexts, context2)
176
177
func (s *ContextTestSuite) TestMMSMoreThanOneValidContextSelectPreferred(c *C) {
177
178
context1 := OfonoContext{
178
179
ObjectPath: "/ril_0/context1",
179
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false),
180
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false),
181
182
s.contexts = append(s.contexts, context1)
183
184
context2 := OfonoContext{
184
185
ObjectPath: "/ril_0/context2",
185
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false),
186
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
187
188
s.contexts = append(s.contexts, context2)
189
190
context3 := OfonoContext{
190
191
ObjectPath: "/ril_0/context3",
191
Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false),
192
Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false, false),
193
194
s.contexts = append(s.contexts, context3)
203
204
func (s *ContextTestSuite) TestMMSMoreThanOneValidContextPreferredNoMatch(c *C) {
204
205
context1 := OfonoContext{
205
206
ObjectPath: "/ril_0/context1",
206
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false),
207
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false),
208
209
s.contexts = append(s.contexts, context1)
210
211
context2 := OfonoContext{
211
212
ObjectPath: "/ril_0/context2",
212
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false),
213
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
214
215
s.contexts = append(s.contexts, context2)
216
217
context3 := OfonoContext{
217
218
ObjectPath: "/ril_0/context3",
218
Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false),
219
Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false, false),
220
221
s.contexts = append(s.contexts, context3)
230
231
func (s *ContextTestSuite) TestMMSMoreThanOneValidContext2Active(c *C) {
231
232
context0 := OfonoContext{
232
233
ObjectPath: "/ril_0/context0",
233
Properties: makeGenericContextProperty("Context0", contextTypeInternet, false, true, false),
234
Properties: makeGenericContextProperty("Context0", contextTypeInternet, false, true, false, false),
235
236
s.contexts = append(s.contexts, context0)
237
238
context1 := OfonoContext{
238
239
ObjectPath: "/ril_0/context1",
239
Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false),
240
Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false, false),
241
242
s.contexts = append(s.contexts, context1)
243
244
context2 := OfonoContext{
244
245
ObjectPath: "/ril_0/context2",
245
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false),
246
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
247
248
s.contexts = append(s.contexts, context2)
249
250
context3 := OfonoContext{
250
251
ObjectPath: "/ril_0/context3",
251
Properties: makeGenericContextProperty("Context3", contextTypeMMS, true, true, false),
252
Properties: makeGenericContextProperty("Context3", contextTypeMMS, true, true, false, false),
253
254
s.contexts = append(s.contexts, context3)
263
264
func (s *ContextTestSuite) TestMMSMoreThanOneValidContextPreferredNotActive(c *C) {
264
265
context0 := OfonoContext{
265
266
ObjectPath: "/ril_0/context0",
266
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false),
267
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false),
268
269
s.contexts = append(s.contexts, context0)
270
271
context1 := OfonoContext{
271
272
ObjectPath: "/ril_0/context1",
272
Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false),
273
Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false, false),
274
275
s.contexts = append(s.contexts, context1)
276
277
context2 := OfonoContext{
277
278
ObjectPath: "/ril_0/context2",
278
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false),
279
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
280
281
s.contexts = append(s.contexts, context2)
282
283
context3 := OfonoContext{
283
284
ObjectPath: "/ril_0/context3",
284
Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false),
285
Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false, false),
287
288
s.contexts = append(s.contexts, context3)
295
296
c.Check(contexts[3], DeepEquals, context2)
299
func (s *ContextTestSuite) TestOnePreferredContext(c *C) {
300
context0 := OfonoContext{
301
ObjectPath: "/ril_0/context0",
302
Properties: makeGenericContextProperty("Context0", contextTypeInternet, true, true, false, false),
304
s.contexts = append(s.contexts, context0)
306
context1 := OfonoContext{
307
ObjectPath: "/ril_0/context1",
308
Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false, true),
310
s.contexts = append(s.contexts, context1)
312
context2 := OfonoContext{
313
ObjectPath: "/ril_0/context2",
314
Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
316
s.contexts = append(s.contexts, context2)
318
context3 := OfonoContext{
319
ObjectPath: "/ril_0/context3",
320
Properties: makeGenericContextProperty("Context3", contextTypeMMS, true, true, false, false),
322
s.contexts = append(s.contexts, context3)
324
contexts, err := s.modem.GetMMSContexts("")
326
c.Assert(len(contexts), Equals, 1)
327
c.Check(contexts[0], DeepEquals, context1)
298
330
func (s *ContextTestSuite) TestGetProxy(c *C) {
299
331
context := OfonoContext{
300
332
ObjectPath: "/ril_0/context1",
301
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true),
333
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true, false),
304
336
p, err := context.GetProxy()
309
341
func (s *ContextTestSuite) TestGetProxyNoProxy(c *C) {
310
342
context := OfonoContext{
311
343
ObjectPath: "/ril_0/context1",
312
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false),
344
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false),
315
347
p, err := context.GetProxy()
320
352
func (s *ContextTestSuite) TestGetProxyWithHTTP(c *C) {
321
353
context := OfonoContext{
322
354
ObjectPath: "/ril_0/context1",
323
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true),
355
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true, false),
325
357
context.Properties["MessageProxy"] = dbus.Variant{fmt.Sprintf("http://%s:%d", proxy.Host, proxy.Port)}
332
364
func (s *ContextTestSuite) TestGetProxyNoPort(c *C) {
333
365
context := OfonoContext{
334
366
ObjectPath: "/ril_0/context1",
335
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true),
367
Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true, false),
337
369
context.Properties["MessageProxy"] = dbus.Variant{fmt.Sprintf("http://%s", proxy.Host)}