~boiko/telepathy-ofono/update_tp_qt

« back to all changes in this revision

Viewing changes to tests/ConnectionTest.cpp

  • Committer: CI bot
  • Author(s): Tiago Salem Herrmann
  • Date: 2014-08-22 13:28:14 UTC
  • mfrom: (95.2.6 telepathy-ofono)
  • Revision ID: ps-jenkins@lists.canonical.com-20140822132814-pmb78w7vncowuyjx
- Report "away" status if there is no network and "offline" if the sim card is not present.
- Remove legacy code
- Expose operator name to apps via presence message. 
Approved by: Gustavo Pichorim Boiko

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
                   SIGNAL(accountReady()));
41
41
    QTRY_COMPARE(spy.count(), 1);
42
42
 
 
43
    OfonoMockController::instance()->SimManagerSetPresence(true);
43
44
    OfonoMockController::instance()->ModemSetOnline();
44
45
    OfonoMockController::instance()->NetworkRegistrationSetStatus("registered");
45
46
 
63
64
    OfonoMockController::instance()->NetworkRegistrationSetStatus("unregistered");
64
65
    QTRY_COMPARE(signalSpy.count(), 1);
65
66
    Tp::Presence presence = signalSpy.first().first().value<Tp::Presence>();
66
 
    QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
 
67
    QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAway);
67
68
    signalSpy.clear();
68
69
 
69
70
    // now set the modem as registered to the network again to see if it works
73
74
    QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAvailable);
74
75
    signalSpy.clear();
75
76
 
76
 
    // searching should be reported as offline
 
77
    // searching should be reported as away
77
78
    OfonoMockController::instance()->NetworkRegistrationSetStatus("searching");
78
79
    QTRY_COMPARE(signalSpy.count(), 1);
79
80
    presence = signalSpy.first().first().value<Tp::Presence>();
80
 
    QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
 
81
    QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAway);
81
82
    signalSpy.clear();
82
83
 
83
 
    // denied should be reported as offline (set registered first to force the signal to be emitted)
 
84
    // denied should be reported as away (set registered first to force the signal to be emitted)
84
85
    OfonoMockController::instance()->NetworkRegistrationSetStatus("registered");
85
86
    QTRY_COMPARE(signalSpy.count(), 1);
86
87
    signalSpy.clear();
87
88
    OfonoMockController::instance()->NetworkRegistrationSetStatus("denied");
88
89
    QTRY_COMPARE(signalSpy.count(), 1);
89
90
    presence = signalSpy.first().first().value<Tp::Presence>();
90
 
    QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
 
91
    QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAway);
91
92
    signalSpy.clear();
92
93
 
93
94
    // unknown should be reported as offline (set registered first to force the signal to be emitted)
97
98
    OfonoMockController::instance()->NetworkRegistrationSetStatus("unknown");
98
99
    QTRY_COMPARE(signalSpy.count(), 1);
99
100
    presence = signalSpy.first().first().value<Tp::Presence>();
100
 
    QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
 
101
    QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAway);
101
102
    signalSpy.clear();
102
103
 
103
104
    // roaming should be reported as available
105
106
    QTRY_COMPARE(signalSpy.count(), 1);
106
107
    presence = signalSpy.first().first().value<Tp::Presence>();
107
108
    QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAvailable);
 
109
    signalSpy.clear();
 
110
 
 
111
    // offline modem should be reported as offline (flightmode)
 
112
    OfonoMockController::instance()->ModemSetOnline(false);
 
113
    QTRY_COMPARE(signalSpy.count(), 1);
 
114
    presence = signalSpy.first().first().value<Tp::Presence>();
 
115
    QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
108
116
}
109
117
 
110
118
QTEST_MAIN(ConnectionTest)