~phablet-team/nuntium/update-july-first

« back to all changes in this revision

Viewing changes to ofono/context_test.go

  • Committer: CI Train Bot
  • Author(s): Alfonso Sanchez-Beato
  • Date: 2015-05-21 06:27:54 UTC
  • mfrom: (93.2.2 packaging)
  • Revision ID: ci-train-bot@canonical.com-20150521062754-0mszsr0o0ku909x8
  [ Sergio Schvezov ]
  * Decode properly content type when there are parameters
  [ Alfonso Sanchez-Beato ]
  * Fix LP: #1441135 in the event of an oFono crash
  * Use oFono's Preferred property when selecting the mobile context

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
var proxy ProxyInfo
40
40
 
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}
46
47
        if messageCenter {
47
48
                p["MessageCenter"] = dbus.Variant{"http://messagecenter.com"}
48
49
        } else {
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),
84
85
        }
85
86
        s.contexts = append(s.contexts, context1)
86
87
 
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),
97
98
        }
98
99
        s.contexts = append(s.contexts, context1)
99
100
 
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),
109
110
        }
110
111
        s.contexts = append(s.contexts, context1)
111
112
 
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),
122
123
        }
123
124
        s.contexts = append(s.contexts, context1)
124
125
 
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),
128
129
        }
129
130
        s.contexts = append(s.contexts, context2)
130
131
 
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),
141
142
        }
142
143
        s.contexts = append(s.contexts, context1)
143
144
 
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),
147
148
        }
148
149
        s.contexts = append(s.contexts, context2)
149
150
 
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),
160
161
        }
161
162
        s.contexts = append(s.contexts, context1)
162
163
 
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),
166
167
        }
167
168
        s.contexts = append(s.contexts, context2)
168
169
 
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),
180
181
        }
181
182
        s.contexts = append(s.contexts, context1)
182
183
 
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),
186
187
        }
187
188
        s.contexts = append(s.contexts, context2)
188
189
 
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),
192
193
        }
193
194
        s.contexts = append(s.contexts, context3)
194
195
 
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),
207
208
        }
208
209
        s.contexts = append(s.contexts, context1)
209
210
 
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),
213
214
        }
214
215
        s.contexts = append(s.contexts, context2)
215
216
 
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),
219
220
        }
220
221
        s.contexts = append(s.contexts, context3)
221
222
 
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),
234
235
        }
235
236
        s.contexts = append(s.contexts, context0)
236
237
 
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),
240
241
        }
241
242
        s.contexts = append(s.contexts, context1)
242
243
 
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),
246
247
        }
247
248
        s.contexts = append(s.contexts, context2)
248
249
 
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),
252
253
        }
253
254
        s.contexts = append(s.contexts, context3)
254
255
 
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),
267
268
        }
268
269
        s.contexts = append(s.contexts, context0)
269
270
 
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),
273
274
        }
274
275
        s.contexts = append(s.contexts, context1)
275
276
 
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),
279
280
        }
280
281
        s.contexts = append(s.contexts, context2)
281
282
 
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),
285
286
        }
286
287
 
287
288
        s.contexts = append(s.contexts, context3)
295
296
        c.Check(contexts[3], DeepEquals, context2)
296
297
}
297
298
 
 
299
func (s *ContextTestSuite) TestOnePreferredContext(c *C) {
 
300
        context0 := OfonoContext{
 
301
                ObjectPath: "/ril_0/context0",
 
302
                Properties: makeGenericContextProperty("Context0", contextTypeInternet, true, true, false, false),
 
303
        }
 
304
        s.contexts = append(s.contexts, context0)
 
305
 
 
306
        context1 := OfonoContext{
 
307
                ObjectPath: "/ril_0/context1",
 
308
                Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false, true),
 
309
        }
 
310
        s.contexts = append(s.contexts, context1)
 
311
 
 
312
        context2 := OfonoContext{
 
313
                ObjectPath: "/ril_0/context2",
 
314
                Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
 
315
        }
 
316
        s.contexts = append(s.contexts, context2)
 
317
 
 
318
        context3 := OfonoContext{
 
319
                ObjectPath: "/ril_0/context3",
 
320
                Properties: makeGenericContextProperty("Context3", contextTypeMMS, true, true, false, false),
 
321
        }
 
322
        s.contexts = append(s.contexts, context3)
 
323
 
 
324
        contexts, err := s.modem.GetMMSContexts("")
 
325
        c.Assert(err, IsNil)
 
326
        c.Assert(len(contexts), Equals, 1)
 
327
        c.Check(contexts[0], DeepEquals, context1)
 
328
}
 
329
 
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),
302
334
        }
303
335
 
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),
313
345
        }
314
346
 
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),
324
356
        }
325
357
        context.Properties["MessageProxy"] = dbus.Variant{fmt.Sprintf("http://%s:%d", proxy.Host, proxy.Port)}
326
358
 
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),
336
368
        }
337
369
        context.Properties["MessageProxy"] = dbus.Variant{fmt.Sprintf("http://%s", proxy.Host)}
338
370